Question

Problem 8. (Heap Top-k) Prof Dubious has made the following claim, and has provided a proof Claim. Let n and k be positive in

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Most of the things in the given statement are right except the point that the top 3 elements lie in top 2 layers Top element always do lie on the root Both of its subtree contains lesser value than the root But we cannot compare amongst them and there subtrees Consider the case as shown -

6 6 1 5 3 3 2 2 4

This is a max-heap All the subtree follows max-heap property Note that subtree of 30 contains element greater than 10 (That is right subtree of 42) But top 3 3 elements are not present in top 2 layers

I have tried to explain it in very simple language and I hope that i have answered your question satisfactorily.Leave doubts in comment section if any.

Add a comment
Know the answer?
Add Answer to:
Problem 8. (Heap Top-k) Prof Dubious has made the following claim, and has provided a proof Claim. Let n and k be posit...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Since we do not want to have to rewrite this code when the element type changes,...

    Since we do not want to have to rewrite this code when the element type changes, this classes uses a Comparator to assist in ordering the elements. You will need to complete the siftUpComparator() and siftDownComparator() methods in the LinkedHeap Class. siftUp §Added element may violate heap-order property §siftUp() restores order starting at added node §Processing will continue working up the tree until: úFinds properly ordered node & parent úReaches the root (reaches node without parent) siftDown §Restores heap’s order...

  • Please do exercise 129: Exercise 128: Define r:N + N by r(n) = next(next(n)). Let f:N...

    Please do exercise 129: Exercise 128: Define r:N + N by r(n) = next(next(n)). Let f:N → N be the unique function that satisfies f(0) = 2 and f(next(n)) =r(f(n)) for all n E N. 102 1. Prove that f(3) = 8. 2. Prove that 2 <f(n) for all n E N. Exercise 129: Define r and f as in Exercise 128. Assume that x + y. Define r' = {(x,y),(y,x)}. Let g:N + {x,y} be the unique function that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT