title: Confusion calculating size between Bytes and Megabytes
body: <p>This is a <a href="http://massivealgorithms.blogspot.com/2016/07/missing-int.html" rel="nofollow noreferrer">solved problem</a> where the we have to find a missing integer from the input data which is in form of a file containing 4 billion unsorted unsigned integers. The catch is that only 10 MBytes of memory can be used.</p>
  
  <p>The author gives a solution where we do 2 passes. In the first pass we create an array of  "blocks" of some size. Eg. Block 0 represents <code>0 to 999</code>, 1 represents <code>1000 to 1999</code>, so on. Thus we know how many values <strong>should</strong> be present in each block.</p>
  
  <p>Now we scan through the file and count how many values are <strong>actually present</strong> in each block - which will lead us to the missing integer.</p>
  
  <p>I understand the approach. However, to calculate the appropriate block size starts with this:</p>
  
  <blockquote>
    <p>The array in the first pass can fit in 10 MBytes, or roughly 2^23 bytes, of memory. </p>
  </blockquote>
  
  <p>How is <code>10</code> MB the same as <code>2^23</code>? I am unable to understand where did the <code>2^23</code> number come from.</p>
  
  <p>So <code>2^24</code> is 16MBytes, so probably he is taking <code>2^23</code> which is closest value that is 10 MBytes or less. If that is the case, why can he not use the whole 10 MBytes? i.e. why does he have to use a power of 2 to get the size here?</p>