5. Let's see why Heapsort is unstable. Consider the list [2,2',1]. Because the length is 3 we know there is a call to converttomaxheap followed by two sets of swap, chop, and maxheapify. (a) What will this list look like after convertomaxheap is run on it? Index 1 2 3 Value (b) What will this list look like after the first swap and chop? [2 pts] [2 pts] Index 1 2 3 Value (c) What will this list look like after the subsequent call to maxheapify? Index 1 2 3 Value [2 pts] (d) What will this list look like after the second swap and chop? [2 pts] Index 1 2 3 Value (e) What will this list look like after the subsequent call to maxheapify? Index 1 2 3 Value [2 pts]

icon
Related questions
Question
5. Let's see why Heapsort is unstable. Consider the list [2,2',1]. Because the length is 3 we
know there is a call to converttomaxheap followed by two sets of swap, chop, and maxheapify.
(a) What will this list look like after convertomaxheap is run on it?
Index
1
2
3
Value
(b) What will this list look like after the first swap and chop?
[2 pts]
[2 pts]
Index
1
2
3
Value
(c) What will this list look like after the subsequent call to maxheapify?
Index
1
2
3
Value
[2 pts]
(d) What will this list look like after the second swap and chop?
[2 pts]
Index
1
2
3
Value
(e) What will this list look like after the subsequent call to maxheapify?
Index
1
2
3
Value
[2 pts]
Transcribed Image Text:5. Let's see why Heapsort is unstable. Consider the list [2,2',1]. Because the length is 3 we know there is a call to converttomaxheap followed by two sets of swap, chop, and maxheapify. (a) What will this list look like after convertomaxheap is run on it? Index 1 2 3 Value (b) What will this list look like after the first swap and chop? [2 pts] [2 pts] Index 1 2 3 Value (c) What will this list look like after the subsequent call to maxheapify? Index 1 2 3 Value [2 pts] (d) What will this list look like after the second swap and chop? [2 pts] Index 1 2 3 Value (e) What will this list look like after the subsequent call to maxheapify? Index 1 2 3 Value [2 pts]
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer