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 14:40
Write the sentence as an equation. 6 fewer than the quantity 140 times j equals 104
Answers: 2
question
Mathematics, 21.06.2019 18:00
Find the slope and the y-intercept if there's one and the equation of the line given these two points( 3, 2) and( 3, -4)
Answers: 2
question
Mathematics, 21.06.2019 20:30
In priyas math class there are 10 boys and 15 girls. what is the ratio of boys to girls in priyas math class? express your answer as a decimal
Answers: 1
question
Mathematics, 21.06.2019 22:00
Asales representative from a local radio station is trying to convince the owner of a small fitness club to advertise on her station. the representative says that if the owner begins advertising on the station today, the club's total number of members will grow exponentially each month. she uses the given expression to model the number of club members, in hundreds, after advertising for t months.
Answers: 2
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, 04.12.2019 00:31
question
Health, 04.12.2019 00:31
question
Mathematics, 04.12.2019 00:31
Questions on the website: 13722367