By using the Max-Heap data structure to implement a priority queue, some applica
ID: 641433 • Letter: B
Question
By using the Max-Heap data structure to implement a priority queue, some applications may need to change the data (priority) of a specific node i. That is, given an index i, change the priority of node i to a new priority t. Please write a pseudocode for this procedure.
Max-Heap-update(A, i, t) {
}
____________________________________________________
Given an array A, we try to sort the array using the quicksort algorithm. In this sorting, assume on each recursive step the partition procedure always partition each subarray into n ? 2 to 2 ratio, where n is the size of the subarray. What
Explanation / Answer
SEARCH(A; i; j; x) _rst A[i] middle A[(i + j)=2] last A[j] if x 2 f_rst; middle; lastg: then return the corresponding index else : if (x < _rst and x > middle) or (x > _rst and x > middle): [xxx IsnRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.