Mathematics
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.

answer
Answers: 2

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 16:30, happy121906
Astandard american eskimo dog has a mean weight of 30 pounds with a standard deviation of 2 pounds. assuming the weights of standard eskimo dogs are normally distributed, what range of weights would 99.7% of the dogs have? approximately 26–34 pounds approximately 24–36 pounds approximately 28–32 pounds approximately 29–31 pounds
Answers: 1
image
Mathematics, 21.06.2019 17:40, fdzgema17
An apartment has a replacement cost of $950,000 and contents valued at $1,450,000. it has a classification of a and a territory rating of 3. find the annual premium a) $10,185 b) $9,230 c) $3,155 d) $13,830
Answers: 2
image
Mathematics, 21.06.2019 20:20, Kelbee781
Each person in an it department of 25 people works on at least one of 3 major projects: system security, program implementation, platform development. 10 people work on system security, 13 work on program implementation, and 12 work on platform development. 4 people work on system security and platform development, 5 people work on program implementation and platform development, and 2 people work on all three projects. how many people work on system security and program implementation?
Answers: 1
image
Mathematics, 21.06.2019 21:30, errr5529
On traditional maps, earth is represented in a flat plane, or by euclidean geometry. however, a globe is a more accurate model that comes from elliptical geometry. how does a globe represent the fact that there are no parallel lines in elliptical geometry? the equator is not parallel to any other latitudinal lines. the north and south poles are never connected by a geodesic. the geodesics connecting the north and south poles never intersect. the geodesics connecting the north and south poles intersect at both of the poles.
Answers: 3
Do you know the correct answer?
A perfect binary tree is a tree in which every node other than the leaves has exactly two children,...

Questions in other subjects:

Konu
Mathematics, 08.12.2021 02:50
Konu
Mathematics, 08.12.2021 02:50
Konu
Mathematics, 08.12.2021 02:50