Lecture 1:a. Correctnes b. Applets c. Tables Lecture 2 a.Applets b.Tables c.Exercises Lecture 3Lecture 4a.Appletsb. ProblemsLecture 5 Lecture 6 Lecture 7 Lecture 8 Test 1 Test 2

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
min-heap.

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:

BUILD-MAX-HEAP'(A)
1 heap-size[A] ← 1
2____for i ← 2 to length[A]
3______do MAX-HEAP-INSERT(A, A[i])

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.
b. Show that in the worst case, BUILD-MAX-HEAP' requires Θ(n lg n) time to build an n-element heap.

Algorithms | Blackboard | UNAL | SIA |Bibliotecas|UNALdotNET

Hosted by www.Geocities.ws

1