Question

Suppose H is a binary min-heap with n nodes, Prove the fact: The maximum key is...

Suppose H is a binary min-heap with n nodes, Prove the fact:

The maximum key is at one of the leaves.

Homework Answers

Answer #1

The min-heap has the following 2 properties:

1. It is a complete binary tree, which means all the levels in min heap are filled, except maybe the last one. It may be filled or not.

2. The value of all the parent nodes must always be less than or equal to the children.

Now, let us suppose that in a min heap the maximum key is not a leaf node but any random node in middle. This node will have 2 children as defined by the first property (the heap is complete binary tree). Being in a min heap, both its children should be greater than itself. But then it won't be the maximum key because if children are smaller, it would violate the second property. As our assumption is wrong, therefore we can conclude that the maximum node will always be one of the leaves.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. a) Suppose that a binary tree of height h has n nodes. Show that h...
1. a) Suppose that a binary tree of height h has n nodes. Show that h ≥ log2 (n+2) - 1. b) Using the formula in part (a) find the minimum height if a binary tree with 1000 nodes. c) What is the maximum possible height of a binary tree with 1000 nodes?
Maximum how many nodes can there be in a complete Binary Tree with level h?
Maximum how many nodes can there be in a complete Binary Tree with level h?
Maximum how many nodes can there be in a complete Binary Tree with level h? (java...
Maximum how many nodes can there be in a complete Binary Tree with level h? (java programing)
What is the worst-case time (in Big-O) for building a Min-Heap of N nodes, using bulk...
What is the worst-case time (in Big-O) for building a Min-Heap of N nodes, using bulk insertion (bottom-up construction), assuming comparing two keys takes constant time. Justify your answer. You may assume N = 2h+1 – 1, for simplicity.
(Data Structure) Suppose we want to store the data of a binary heap in an array....
(Data Structure) Suppose we want to store the data of a binary heap in an array. Show the data of that array after inserting the given keys one by one. Assume that initially binary heap is empty. Show all steps of insertions. Note: No need to show the changes for each step of “percolate up”. The contents of the array must be shown after completing one insertion. Create the “Min Heap” for the following data set 7,      3,      18,    -9,    ...
How can I prove that any node of a binary search tree of n nodes can...
How can I prove that any node of a binary search tree of n nodes can be made the root in at most n − 1 rotations?
Please explain/justify/prove your answer to your answer to this question: In constant time for a min-heap...
Please explain/justify/prove your answer to your answer to this question: In constant time for a min-heap is it possible for someone to implement both deleteMin(used for deleting the min element) and insert (used for inserting one element)? (in c++ language) please type answer if you can
A binary tree isfullif every non-leaf node has exactly two children. For context, recallthat we saw...
A binary tree isfullif every non-leaf node has exactly two children. For context, recallthat we saw in lecture that a binary tree of heighthcan have at most 2h+1−1 nodes, and thatit achieves this maximum if it iscomplete, meaning that it is full and all leaves are at the samedistance from the root. Findμ(h), theminimumnumber of nodes that a full tree of heighthcan have, and prove your answer using ordinary induction onh. Note that tree of height of 0 isa single...
Suppose G and H are groups and ϕ:G -> H is a homomorphism. Let N be...
Suppose G and H are groups and ϕ:G -> H is a homomorphism. Let N be a normal subgroup of G contained in ker(ϕ). Define a mapping ψ: G/N -> H by ψ (aN)= ϕ (a) for all a in G. Prove that ψ is a well-defined homomorphism from G/N to H. Is ψ always an isomorphism? Prove it or give a counterexample
Suppose : phi :G -H is a group isomorphism . If N is a normal subgroup...
Suppose : phi :G -H is a group isomorphism . If N is a normal subgroup of G then phi(N) is a normal subgroup of H. Prove it is a subgroup and prove it is normal?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT