Similar questions 4 more →
Heaps & Priority Queues
![Question 59, GATE 2009: Which zero-based array is a binary max-heap? A[25, 12, 16, 13, 10, 8, 14]; B[25, 14, 13, 16, 10, 8, 12]; C[25, 14, 16, 13, 10, 8, 12]; D[25, 14, 12, 13, 10, 8, 16].](../../assets/questions/CS-2009-Q59-1.webp)
![Question 59, GATE 2009: Which zero-based array is a binary max-heap? A[25, 12, 16, 13, 10, 8, 14]; B[25, 14, 13, 16, 10, 8, 12]; C[25, 14, 16, 13, 10, 8, 12]; D[25, 14, 12, 13, 10, 8, 16].](../../assets/questions/CS-2009-Q59-2.webp)
Answer & solution
Answer: C (no official key was published)
In a zero-based heap each parent at i must be at least as large as children at 2i+1 and 2i+2. In C, [25, 14, 16, 13, 10, 8, 12], the checks are 25≥14, 16; 14≥13, 10; and 16≥8, 12, so every edge satisfies max-heap order. A fails because parent 12 has child 13; B fails because parent 14 has child 16; D fails because parent 12 has child 16. Thus C alone is a max-heap.
A max-heap needs parent≥child along every edge, not a globally descending array. In C, root 25 exceeds 14/16; 14 exceeds 13/10; 16 exceeds 8/12. A fails at 12<13; B at 14<16; D at 12<16. Checking only the root would wrongly admit the distractors; every internal node must satisfy the local condition.