Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

2 The C function popMinHeap() given below is supposed to delete the smallest integer from a inin 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 int pop MinHeap(int *n, int* heap) { int parent, child, min, tmp; 3 min = heap[1]; tmp = heap[n--]; 4 parent = 1; child = 2; 5 while (child heap(child + 1])) 7 child++; 8 if (tmp > heap[child]) break; 9 heap[parent] = heap (child); parent = child; 10 child = parent*2; } 11 heap[parent] = tmp: 12 return min; 13]

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

Students also viewed these Databases questions

Question

Is Dillers approach value-creating diversification? Why or Why not?

Answered: 1 week ago

Question

What is the total annual turnover rate?

Answered: 1 week ago

Question

5. If yes, then why?

Answered: 1 week ago

Question

3. What changes should I be making?

Answered: 1 week ago