July2016 cs Q33

0. Which one of the following array represents a binary max-heap?

  • Option : 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.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *