subject
Mathematics, 27.06.2020 21:01 duartealondra45

A perfect binary tree is a tree in which every node other than the leaves has exactly two children, and the leaves are all at the same level. We are going to find the exact number
of comparisons (in the worst case) for heap creation in a perfect binary tree. We will guess
the formula by looking at a few small examples, and then prove it is correct by mathematical
induction.
(a) The height of a tree is the number of levels of nodes. (A tree consisting of a single root
node has height 0. A tree consisting of a root node with some children has height 1. Etc.)
(i) Assume a perfect binary tree has height h. How many nodes does it have? Justify.
(ii) Assume a perfect binary tree has n nodes. What is its height? Justify.
(b) Calculate by hand the exact number of comparisons for complete trees with heights
0, 1, 2, 3, 4.
(c) We know that the true answer should be approximately 2n. Find the differences between
2n and your calculated values.
(d) Guess a formula for your differences as a function of n.
(e) What formula does that give you for the exact number of comparisons for heap creation
as a function of n?
(f) Heap creation can be thought of as a recursive procedure: Create heap for left child of
root, create heap for right child of root, and sift the root value down. Write a recurrence
for the number of comparisons to create a heap as a function of n.
(g) Use mathematical induction to prove that your formula is a solution to the recurrence.

ansver
Answers: 2

Another question on Mathematics

question
Mathematics, 21.06.2019 18:00
Olga used 100 ounces of flour to make 225 muffins. how many ounces of flour will be used to make 300 muffins?
Answers: 2
question
Mathematics, 21.06.2019 22:30
Sketch the vector field vector f( vector r ) = 8vector r in the xy-plane. select all that apply. the length of each vector is 8. the lengths of the vectors decrease as you move away from the origin. all the vectors point away from the origin. all the vectors point in the same direction. all the vectors point towards the origin. the lengths of the vectors increase as you move away from the origin.
Answers: 2
question
Mathematics, 21.06.2019 23:50
Find the interior angle of a regular polygon which has 6 sides
Answers: 1
question
Mathematics, 22.06.2019 04:30
△def is similar to △stu. write a proportion that contains st and su.
Answers: 3
You know the right answer?
A perfect binary tree is a tree in which every node other than the leaves has exactly two children,...
Questions
question
History, 21.10.2020 05:01
question
Mathematics, 21.10.2020 05:01
question
Mathematics, 21.10.2020 05:01
Questions on the website: 13722361