Argue the correctness of HEAP-INCREASE-KEY using the following loop invari- ant: At the start of each iteration of the while loop of lines 4-6, the subarray A[1.. A.heap-size] satisfies the max-heap property, except that there may be one violation: A[i] may be larger than A[PARENT(i)]. You may assume that the subarray A[1.. A.heap-size] satisfies the max-heap prop- erty at the time HEAP-INCREASE-KEY is called.

icon
Related questions
Question

Please use the figure provided to answer question 6.5-5

2
8
15
14
14
16
16
10
10
3
3
14
15
14
15
7
16
(b)
16
(d)
10
10
3
Transcribed Image Text:2 8 15 14 14 16 16 10 10 3 3 14 15 14 15 7 16 (b) 16 (d) 10 10 3
Argue the correctness of HEAP-INCREASE-KEY using the following loop invari-
ant:
At the start of each iteration of the while loop of lines 4-6, the subarray
A[1.. A.heap-size] satisfies the max-heap property, except that there may
be one violation: A[i] may be larger than A[PARENT(i)].
You may assume that the subarray A[1 .. A.heap-size] satisfies the max-heap prop-
erty at the time HEAP-INCREASE-KEY is called.
Transcribed Image Text:Argue the correctness of HEAP-INCREASE-KEY using the following loop invari- ant: At the start of each iteration of the while loop of lines 4-6, the subarray A[1.. A.heap-size] satisfies the max-heap property, except that there may be one violation: A[i] may be larger than A[PARENT(i)]. You may assume that the subarray A[1 .. A.heap-size] satisfies the max-heap prop- erty at the time HEAP-INCREASE-KEY is called.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer