Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Elements Of Chemical Reaction Engineering
Authors: H. Fogler
6th Edition
013548622X, 978-0135486221
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App