Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following sequence of numbers: 2 2 4 , 5 7 , 4 5 , 1 3 , 1 8 , 7 , 4

Given the following sequence of numbers:
224,57,45,13,18,7,4,6,2
Build a min-heap
(a) What is the heap-property that must be held?
(b) Construct the complete tree. For every adding into the heap, show the intermediate steps of the percolate/up and
percolate/down in the complete tree and in the array
add 224
iv. add 13
v. add 18
vii. add -4
ii. add 57
viii. add 6
iii. add 45
ix. add 2
vi. add 7
Draw the final result of built min heap
Based on the result of build-min heap from previous question, perform heap-sort. (Hint: Build-min + remove-min will lead
to the heap sort)
(a) Show the intermediate steps of the percolation (up/down) for every removeMin()
(b) Show the state of the array that keeps the results of the removeMin() every step
Fill out the following array with the resulting array from previous question. Suppose the target i=3
(a) what is heap [3]'s parent? What is the formula to calculate its parent?
(b) what is heap [3]'s left child? What is the formula to calculate its left child?
(c) what is heap[3]'s right child? what is the formula to calculate its right child?
image text in transcribed

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions