Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Important: Please provide code in C language. Please s eparate the coding by each part (part a, b, c, etc.) and do not provide one

Important: Please provide code in C language. Please separate the coding by each part (part a, b, c, etc.) and do not provide one combined code (please break it down by each part)

Coding is required for each part.

Consider the following set of elements: 23, 53, 64, 5, 87, 32, 50, 90, 14, 41

a.Implement the above min-heap structure using an array representation as described in class. (2*i+1 and 2*i+2)

b.Visit the different array elements in part b and print the index and value of the parent and children of each element visited. Use the formulas for finding the index of the children and parent as presented in class. (floor (i-1/2])

c.Implement the code for inserting the values 44, and then 20 into the min-heap.

d.Select a random integer in the range [0, array_size-1]. Delete the heap element at that heap index and apply the necessary steps to maintain the min-heap property.

e.Increase the value of the root element to 25. Apply the necessary steps in code to maintain the min-heap property.

f.Change the value of the element with value 50 to 0. Apply the necessary steps in code to maintain the min-heap property.

g.Implement the delete-min algorithm on the heap.

h.Recursively apply the delete-min algorithm to sort the elements of the heap.

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions