![]() |
|
Solve exercises 6.5-3, 6.5-8 and problem 6.1 form CLRS chapter 6. 6.5-3 Write pseudocode for the procedures HEAP-MINIMUM, HEAP-EXTRACT-MIN, HEAPDECREASE-
KEY, and MIN-HEAP-INSERT that implement a min-priority queue with a 6.5-8 Give an O(n lg k)-time algorithm to merge k sorted lists into one sorted list, where n is the total number of elements in all the input lists. (Hint: Use a min-heap for k-way merging.) 6.1 The procedure BUILD-MAX-HEAP in Section 6.3 can be implemented by repeatedly using MAX-HEAP-INSERT to insert the elements into the heap. Consider the following implementation:
a. Do the procedures BUILD-MAX-HEAP and BUILD-MAX-HEAP' always create the
same heap when run on the same input array? Prove that they do, or provide a
counterexample. |
|