Let H be a complete binary tree such that node v stores the

Let H be a complete binary tree such that node v stores the entry (p(v), 0), where p(v) is the level number of v. Is tree H a heap? Why or why not?

Solution

Answer:

Not always a heap because heap has any of two properties : either it is max heap or min heap but every follows binary complete tree structure i.e always when a new node is inserted we insert on left of free node.This help us to bound the height to logn , so complete binary tree may have heap property satisfy but not always. As tree doeS not have max or min property but heap do.

Let H be a complete binary tree such that node v stores the entry (p(v), 0), where p(v) is the level number of v. Is tree H a heap? Why or why not?SolutionAnswe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site