GATE 2023 CS – Question 12
Which one of the following sequences when stored in an array at locations A[1],...,A[10] forms a max-heap?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (B) 23, 17, 14, 7, 13, 10, 1, 5, 6, 12
Explanation
Check A[i] ≥ A[2i], A[2i+1]. (A) fails at 10 < 14. (C) fails at 13 < 15. (D) fails at 1 < 12. (B) satisfies all parent-child relations.