Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

4. What will the team agreement contain?

Answered: 1 week ago