Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The C function popMinHeap() given below is supposed to delete the smallest integer from a min heap which is stored in an integer array

 

The C function popMinHeap() given below is supposed to delete the smallest integer from a min heap which is stored in an integer array heap[]. After executing popMinHeap(), the heap remains as a min heap structure. Variable n indicates the number of keys contained in array heap[]. Unfortunately, popMinHeap() has some bugs. Please correct all the bugs in the program. DO NOT rewrite the entire program, just show your modification with the line number. (10 points) 1 2 3 4 5 TT84HM23 6 7 9 10 11 12 13 int popMinHeap(int *n, int* heap) { int parent, child, min, tmp; min = heap[1]; } tmp = heap[n--]; child = 2; parent = 1; while (child heap[child]) break; heap[parent] = heap [child]; child parent*2; } heap[parent] = tmp; return min; parent = child;

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

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Programming questions

Question

What is the purpose of a Notice of Assessment?

Answered: 1 week ago

Question

Date decision to be made (if known)

Answered: 1 week ago