Question: Given a min-priority queue A[1..7] = <2, 4, 3, 5, 7, 8, 6>, consider calling Heap- Decrease-Key(A, 5, 1). Note that index starts from
Given a min-priority queue A[1..7] = , consider calling Heap- Decrease-Key(A, 5, 1). Note that index starts from 1. HEAP-DECREASE-KEY(A, i, k) 1 if k > A[i] 2 3 A[i] = k 4 while i>1 and A[PARENT(i)]> A[i] 5 6 error "new key is greater than current key" 2, 4, 3, 5, 1, 8, 6 1, 2, 3, 4, 7, 8, 6 1, 2, 3, 4, 5, 6, 8 1, 2, 3, 5, 4, 8, 6 swap A[i] with A[PARENT(i)] i = PARENT(i) What will be the resulting min-priority queue A?
Step by Step Solution
3.49 Rating (149 Votes )
There are 3 Steps involved in it
Lets go through the steps of Heap DecreaseKeyA 5 1 usin... View full answer
Get step-by-step solutions from verified subject matter experts
