University of Texas at Arlington CSE 5314 – Spring 2004 Homework #1 - Solutions [Soumya Sanyal] Q 1.5: Prove that the algorithm “MTF every-other-access” (i.e. move the item to the front on every even request for that item) is strictly 2-competitive. A: To prove this bound, we adopt the original model for proving the competitiveness of the MTF algorithm i.e. by the usual notations we represent the two lists as MTF’ (every-other-access) and OPT. First, the rule is adapted into a ‘marking-like’ algorithm where we MTF when the element is unmarked and then mark it, or simply unmark it if it was originally marked and make no changes. Second, redefine the potential function as follows: Φ(x)= φA(x) + φB(x) , where is ‘x’ is an element in MTF’ and OPT. x є {xo,x1} … ( xo = unmarked, x1 = marked ) where, φA(x0) = # of inversions between MTF’ and OPT. φA(x1) = 0 φB(x1) = # of inversions between MTF’ and OPT. φB(x0) = 0 University of Texas at Arlington It naturally follows that, ΔΦ(x) = ΔφA(x) + ΔφB(x) We use the same notations used in the handouts, i.e. k, j, |W| and |WE| all have their usual meanings. An access to any element ‘x’ will result in either of following two actions: x = x0 (unmarked), move the element to the head of the list and mark it. – after MTF and before marking, ΔφA(x) = -|WE| lost inversions ; ΔφB(x) = 0. – after marking, ΔφB(x) = |W| new inversions. ; ΔφA(x) = 0. x = x1 (marked), unmark it, do nothing. – ΔφA(x) = |W| new inversions ; ΔφB(x) = - |W| lost inversions Hence, ΔΦ(x) = ΔφA(x) + ΔφB(x) ≤ |W| - |WE| … (since the second case contributes nothing) Hence, COSTk(MTF’) = k + ΔΦ(x) --- (1) Now recall the identity, k - |WE| ≤ j ---- (2) From (1) and (2) and the previous results, COSTk(MTF’) ≤ 2j – 1. University of Texas at Arlington Adjusting the cost for the changes made to OPT’s list, COSTk(MTF’) ≤ 2j – 1 - f + p. It follows from previous proof styles that, COSTMTF’(σ) ≤ 2 COSTOPT(σ) – n Hence, as α = - n , the competitive ratio of 2 is strict …. (Q.E.D) Q 1.10: Show that the above derivation holds without strict competitiveness i.e. if in equation 1.6 [i.e. ALG*xy(σ) ≤ c.OPT*xy(σ) ] there is some additive constant α, then ALG is c- competitive up to an additive constant of {αl(l-1)}/2. A: Given, ALG*(σxy) ≤ c.OPT*(σxy) + α … (1) By the pairwise property we have, ALG*(σxy) = ALG*xy(σ) OPT*(σxy) = OPT*xy(σ) … (2) Equation 1.4 gives us, ALG*(σ) = Σ{x,y}⊆L,x≠y ALG*xy(σ) (a) OPT*(σ) = Σ{x,y}⊆L,x≠y OPT*xy(σ) (b) … (3) Using (1) we have, ALG*(σ) ≤ Σ{x,y}⊆L,x≠y {c.OPT*(σxy) + α} University of Texas at Arlington Or, ALG*(σ) ≤ c . Σ{x,y}⊆L,x≠y OPT*(σxy) + α.Σ{x,y}⊆L,x≠y 1 By (2) and subsequently (3), we have ALG*(σ) ≤ c . OPT*(σ) + α.lC2 Or, ALG*(σ) ≤ c . OPT*(σ) + α.l.(l-1)/2 … (Q.E.D.) Q 2.1: Consider the following modification to the BIT algorithm. Instead of always complementing b(x) on every access of the element x, complement b(x) only if it is not in the front of the list. Show that this BIT algorithm is not 7/4 competitive. A: We make an observation about the altered BIT algorithm before we proceed with the proof. It in action is very similar to the randomized MTF (RMTF) algorithm where an element ‘x’ is moved to the front with probability of ½ every time it is accessed. Since we assume an initial uniform random distribution in {0,1}, our modified BIT algorithm essentially follows RMTF behavior. To complete the proof, we will try and construct an input sequence that is going to prove that the competitiveness of 7/4 does not hold. A good starting point is a nemesis request sequence similar to the one constructed for RMTF. Let, σ = [(xl)2 (xl-1)2 (xl-2)2 … (x1)2]k, k>1; x1 is at the front, xl is at the end. It is easy to observe that after the first round with (k=1), all the bits will be University of Texas at Arlington set to 1, and the algorithm thereafter will assume a deterministic behavior. Hence, each xi, i є {1,2,…,l} will be moved to the front on every second request deterministically. Therefore, other than the aberrant first round, where the expected cost is 3/2 [½.1 + ½.2] (because it is a random distribution), the cost to serve the sequence for k>1 is at least 2l2 + 4l – 2l [2l(l+1)] … (from the RMTF derivation). The cost for MTF on this sequence would be l(l+1). Hence the competitiveness is no larger than 2 times the optimal offline for a sufficiently large value of l. Hence it is not 7/4 competitive… (Q.E.D.)