

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


ECE 537 - Foundations of Computing Prof. Sen Homework # Solutions
ci =
i, if i is an exact power of 2, 1 , otherwise.
If we charge $3 per operation (i.e., ˆc = 3), then if i is not a power of 2, we’ll be paying $ for the operation, and saving $2 on the balance sheet, and when i is a power of 2, we’ll need to pay $i using some of the credits stored on the balance sheet. Furthermore, if there are m total operations, then
∑m i=1 cˆ^ = 3m. We can see from the table below that the balance sheet can never go negative.
operation am. cost actual cost balance 1 3 1 2 2 3 2 3 3 3 1 5 4 3 4 4 5 3 1 6 6 3 1 8 7 3 1 10 8 3 8 5 9 3 1 7 .. .
Therefore,
∑m i=1 ˆc^ ≥^
∑m i=1 c, and since^
∑m i=1 cˆ^ = 3m, the amortized cost per operation is^ Θ(1).
Φ(Di) =
x∈Di
(di(x) + 1)
= ni +
x∈Di
di(x).
(^1) In order to be consistent with the lecture notes, I’m using the name DeleteMin rather than Extract-Min.
Note that Φ(D 0 ) = 0, and Φ(Di) > 0 for all i > 0. Thus, this is a suitably defined potential function. Now, if the i-th operation is an Insert , the sum in the previous potential function will only change by an amount that is equal to the depth of the new vertex, which has been inserted as the rightmost vertex on the last level. Thus, the sum will increase by blg nic, and the change in potential due to this operation is:
∆Φ(Di) = 1 + blg nic = O(log n).
Therefore, the amortized cost of the Insert operation is:
ˆci = O(log n) + O(log n) = O(log n).
For the DeleteMin operation we have:
∆Φ(Di) = −(1 + blg ni− 1 c = −O(log n),
and the amortized cost of the DeleteMin operation is:
ˆci = O(log n) − O(log n) = O(log n).
∑^ m
i=
cM T F i (d) ≤ d
∑^ m
i=
cAi + XA^ − F A^ − m
where A is any self-organizing list algorithm that obeys the other assumptions given in class. Note that when d = 1, this reduces to the analysis provided in the lecture. Solution: This proof is very similar to the one given in the lecture. Once again we simultaneously maintain two initially empty lists—one using M T F (d), and the other using A. In this case, however, the potential function will be d times the number of inversions in M T F (d)’s list with respect to A’s list. This potential function works because it is initially zero, and can never be nonnegative. We will show that the amortized cost of any operation in M T F (d)’s list is at most d(2cA^ − 1). As before, we assume that any DICTIONARY ADT operation that takes place at position μ in M T F (d)’s list takes place at position α in A’s list. Consider first the Search operation. Let Iα be the element stored at position α in A’s list. In the M T F (d) list, Iα is moved