Open In App

UGC-NET | UGC NET CS 2016 July – III | Question 33

Like Article
Like
Save
Share
Report

Which one of the following array represents a binary max-heap?
(A) [26, 13, 17, 14, 11, 9, 15]
(B) [26, 15, 14, 17, 11, 9, 13]
(C) [26, 15, 17, 14, 11, 9, 13]
(D) [26, 15, 13, 14, 11, 9, 17]


Answer: (C)

Explanation: For max heap we will compare parent node(i) with its left-child(2 * i) and right-child(2 * i + 1):

  • In first option node(2) < node(5) which is violating the max-heap property.
  • In second option node node(2) < node(5) which is violating the max-heap property.
  • In third option there is no violation.
  • In fourth option node(3) < node(7) which is violating the max-heap property.

So, option (C) is correct.


Quiz of this Question


Last Updated : 25 Apr, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads