Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1 (15 points) A max-heap with capacity 20 and size 10 is shown in the following array format. The following three sub-questions all refer to
Q1 (15 points) A max-heap with capacity 20 and size 10 is shown in the following array format. The following three sub-questions all refer to this max-heap (not the heap you obtained after doing some operations). i 1 2 3 4 5 6 7 8 9 10 A[i] 29 27 25 23 21 19 17 15 13 11 (a) On the answer sheet, show the result after applying heap-extract-max (A) to the max- heap at the start of this question. (b) On the answer sheet, show the result after applying heap-increase-key (A, 10, 28) to the max-heap at the start of this question. (c) On the answer sheet, show the result after applying max-heap-insert(A, 29) to the max-heap at the start of this question. Q2 (15 points) In class, we have studied max-heap and its operations in details. The min-heap data structure is defined similarly, with max replaced by min, greater than replaced by less than, etc. The operations of min-heap is also symmetric to the corresponding operations of the max-heap. This question is about the min-heap. A min-heap with capacity 20 and size 10 is shown in the following array format. The following three sub-questions all refer to this min-heap (not the heap you obtained after doing some operations). i 1 2 3 4 5 6 7 8 9 10 A[i] 11 13 15 17 19 21 23 25 27 29 (a) On the answer sheet, show the result after applying heap-extract-min(A) to the min- heap at the start of this question. (b) On the answer sheet, show the result after applying heap-decrease-key(A, 9, 10) to the min-heap at the start of this question. (c) On the answer sheet, show the result after applying min-heap-insert(A, 9) to the min-heap at the start of this question. Q1: Read the instructions for question Q1 in the assignment document. For each of the three sub-questions, write your answer to the question in the given space. After the extract-max operation, we have A[1]= A[21= A[3]= A[5]= A[10]= (b): After the increase-key operation, we have A[1]= A[2]= A[3]= A[5]= A[10]= (c): After the insertion operation, we have A[1]= A[2= A[3]= A[5]= A[11]= Q2: Read the instructions for question Q2 in the assignment document. For each of the three sub-questions, write your answer to the question in the given space. (a): After the extract-min operation, we have A[1]= A[2]= A[33= A[4]= A[8]= (b): After the decrease-key operation, we have A[1]= A[21- A[3]= A[4] A[9]- (c): After the insertion operation, we have A[11- A[2]- A[3]- A[51- A[111
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 Started