how the total number of merges comes out to be 1 less than the total number of blocks

link text

let there are n blocks of 2,

so if you merge them all there will be n/2 merges and remaining one willl be upgraded to next number if n is odd

and when there is one block left program terminates

so total number of merges will be always one less than total number of block.

Suppose you have 5 blocks of 2.

Now you are merging these blocks. First 2 blocks (value of 2) are merging (one time merging). After merging of these two blocks. You got result 4(max. number) and rest of all blocks are upgraded to next higher number (means rest of all blocks value is 4 after up-gradation). Now, you have 4 blocks of 4. and these step are repeated and you got maximum number is 32 and total number of merges is 4(means (n-1)).