Here answer is 8. With 1024 nodes, we can easily build min heap Check following diagram
Now once we place 1-9 then remaining elements can be placed easily to fill up heap (While keeping heap property of course) Total elements we need for this heap is 512, we have given 1024 ! So Yes, 8 is answer !
yes ...heap should be a complete binary tree and here also it is a complete BT. Because we have total 1024 elements and with height(or depth) = 9 we can have total (2^{(}^{9+1) }- 1) = 1023 element in complete BT.
Why 511 elements are required? element 9 is present at a depth of 8, but in a heap it is not necessary that depth 8 should be completely filled. SO, all depths upto 7 should be filled and it requies 2^{(7+1)} -1 elements upto depth 7 and 1 element 9.
@daddy the question says COMPLETE BINARY MIN HEAP so how have you made the heap??? it is not the diagram of complete binary min heap
babai in image akash just put imagination of tree .. in his ans right of root node i.e. 1 there are 255 nodes in arragment which satisfies the given condition... like then right of node 2 there are 127 nodes... like this tree will be look like...
7808 Points
2746 Points
2692 Points
2672 Points
2426 Points
1980 Points
1920 Points
1854 Points
1770 Points
1718 Points
Gatecse
This might help..