Question: 1 Answer the following questions about binary tree and heap: (a) For a complete binary tree of height 4 (we consider a tree with just

1 Answer the following questions about binary tree and heap:

(a) For a complete binary tree of height 4 (we consider a tree with just root node as having height 0), whats the range for the number of nodes in the tree? i.e., whats the maximum and minimum numbers of nodes for a complete binary tree of height 4, respectively? Draw both cases out below.

(b) If a heap has n elements, whats the height of the tree?

(c) If an array stores the following integers in the given order, is it a min-heap?

Draw the heap, and label each node with the numbering of the nodes (i.e., root is node 1, roots left child is node 2, roots right child is node 3, ....).

If a heap has n nodes, verify that nodes numbering from n/2 + 1, ..., n are leaf nodes using this example. Also note that node is parent is node i/2, and node is left child is node 2i, and its right child is node 2i + 1.

Check if the min-heap property is satisfied (How do you write a code to check this?)

9, 10, 12, 36 23, 11, 24, 21

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!