1

I got wrong on this question because the question says in Binary Max Heap, "If y is a node in the right subtree of node x, then y.key >= x.key." I attached the screenshot of the question below.

Binary Max Heap Question

if y is a node in the subtree of node x, I think x.key is bigger than y.key since according to max heap property a parent node is bigger than its children. I would like to know whether I am missing something. Thanks in advance.

2 Answers2

0

Don't think you are missing anything. Minheap bubbles up minimum key to root, maxheap bubbles up maximum key to root.

Now, min-max heaps... those are interesting.

Jason
  • 2,495
  • 4
  • 26
  • 37
0

A Binary-Max Heap is one in which -

  • The root node has the maximum value.

  • The value of each node is equal to or less than the value of its parent node.

  • is a complete binary tree.

In Binary Max-Heap, a parent node is always bigger than any of its children nodes

So you are right ! x.key is bigger than y.key since according to max heap property a parent node is bigger than its children is correct.

Abhishek Bhagate
  • 5,583
  • 3
  • 15
  • 32
  • 1
    @jinmountain Happy to help ! If you feel an answer solved the problem, please mark it as 'accepted' by clicking the green check mark. – Abhishek Bhagate Jun 06 '20 at 19:29