CSE 5314 – Spring 2004 Homework #1 - Solutions

5
CSE 5314 – Spring 2004 CSE 5314 – Spring 2004 Homework #1 - Solutions Homework #1 - Solutions [Soumya Sanyal] [Soumya Sanyal] Q 1.5: Prove that the algorithm “MTF every-other-access” (i.e. 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) move the item to the front on every even request for that item) is strictly 2-competitive. is strictly 2-competitive. A: To prove this bound, we adopt the original model for proving A: To prove this bound, we adopt the original model for proving the competitiveness of the MTF algorithm i.e. by the usual the competitiveness of the MTF algorithm i.e. by the usual notations we represent the two lists as MTF’ (every-other-access) notations we represent the two lists as MTF’ (every-other-access) and OPT. First, the rule is adapted into a ‘marking-like’ and OPT. First, the rule is adapted into a ‘marking-like’ algorithm where we MTF when the element is unmarked and then mark 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 it, or simply unmark it if it was originally marked and make no changes. Second, redefine the potential function as follows: changes. Second, redefine the potential function as follows: Φ (x)= (x)= φ A (x) + (x) + φ B (x) , where is ‘x’ is an element in MTF’ and OPT. (x) , where is ‘x’ is an element in MTF’ and OPT. x x є {x {x o ,x ,x 1 } … ( x } … ( x o o = unmarked, x = unmarked, x 1 = marked ) = marked ) where, where, φ A (x (x 0 ) = # of inversions between MTF’ and OPT. ) = # of inversions between MTF’ and OPT. φ A (x (x 1 ) = 0 ) = 0 φ B (x (x 1 ) = # of inversions between MTF’ and OPT. ) = # of inversions between MTF’ and OPT. University of Texas at University of Texas at Arlington Arlington

description

University of Texas at Arlington. @. CSE. UTA. 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. - PowerPoint PPT Presentation

Transcript of CSE 5314 – Spring 2004 Homework #1 - Solutions

Page 1: CSE 5314 – Spring 2004 Homework #1 - Solutions

CSE 5314 – Spring 2004CSE 5314 – Spring 2004Homework #1 - SolutionsHomework #1 - Solutions

[Soumya Sanyal][Soumya Sanyal]

Q 1.5: Prove that the algorithm “MTF every-other-access” (i.e. move 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 the item to the front on every even request for that item) is strictly 2-competitive.2-competitive.

A: To prove this bound, we adopt the original model for proving the 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 competitiveness of the MTF algorithm i.e. by the usual notations we represent the two lists as MTF’ (every-other-access) and OPT. First, represent the two lists as MTF’ (every-other-access) and OPT. First, the rule is adapted into a ‘marking-like’ algorithm where we MTF 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 when the element is unmarked and then mark it, or simply unmark it if it was originally marked and make no changes. Second, redefine if it was originally marked and make no changes. Second, redefine the potential function as follows:the potential function as follows:

ΦΦ(x)= (x)= φφAA(x) + (x) + φφBB(x) , where is ‘x’ is an element in MTF’ and OPT. (x) , where is ‘x’ is an element in MTF’ and OPT. x x єє {x {xoo,x,x11} … ( x} … ( xo o = unmarked, x= unmarked, x11 = marked ) = marked )where,where,φφAA(x(x00) = # of inversions between MTF’ and OPT.) = # of inversions between MTF’ and OPT.φφAA(x(x11) = 0) = 0

φφBB(x(x11) = # of inversions between MTF’ and OPT.) = # of inversions between MTF’ and OPT.φφBB(x(x00) = 0) = 0

University of Texas at ArlingtonUniversity of Texas at Arlington

Page 2: CSE 5314 – Spring 2004 Homework #1 - Solutions

University of Texas at Arlington

It naturally follows that, It naturally follows that, ΔΦΔΦ(x) = (x) = ΔφΔφAA(x) + (x) + ΔφΔφBB(x)(x)

We use the same notations used in the handouts, i.e. k, j, |W| and |WE| all We use the same notations used in the handouts, i.e. k, j, |W| and |WE| all have their usual meanings.have their usual meanings.

An access to any element ‘x’ will result in either of following two actions:An access to any element ‘x’ will result in either of following two actions:x = x = xx00 (unmarked), move the element to the head of the list and mark it. (unmarked), move the element to the head of the list and mark it.

– after MTF and before marking,after MTF and before marking,

ΔφΔφAA(x) = -|WE| lost inversions ; (x) = -|WE| lost inversions ; ΔφΔφBB(x) = 0.(x) = 0.

– after marking,after marking,

ΔΔφφBB(x) = |W| new inversions. ; (x) = |W| new inversions. ; ΔΔφφAA(x) = 0.(x) = 0.

x = xx = x11 (marked), unmark it, do nothing. (marked), unmark it, do nothing.– ΔφΔφAA(x) = |W| new inversions ; (x) = |W| new inversions ; ΔφΔφBB(x) = - |W| lost inversions(x) = - |W| lost inversions

Hence, Hence, ΔΦΔΦ(x) = (x) = ΔφΔφAA(x) + (x) + ΔφΔφBB(x)(x)

≤ ≤ |W| - |WE| … (since the second case contributes nothing)|W| - |WE| … (since the second case contributes nothing)

Hence, COSTHence, COSTk(MTF’)k(MTF’) = k + = k + ΔΦΔΦ(x) --- (1) (x) --- (1)

Now recall the identity,Now recall the identity,

k - |WE| ≤ j ---- (2)k - |WE| ≤ j ---- (2)

From (1) and (2) and the previous results,From (1) and (2) and the previous results,

COSTCOSTk(MTF’)k(MTF’) ≤ 2j – 1. ≤ 2j – 1.

Page 3: CSE 5314 – Spring 2004 Homework #1 - Solutions

University of Texas at Arlington

Adjusting the cost for the changes made to OPT’s list,Adjusting the cost for the changes made to OPT’s list,

COSTCOSTk(MTF’)k(MTF’) ≤ 2j – 1 - f + p. ≤ 2j – 1 - f + p.

It follows from previous proof styles that,It follows from previous proof styles that,

COSTCOSTMTF’MTF’((σσ) ≤ 2 COST) ≤ 2 COSTOPTOPT((σσ) – n ) – n

Hence, as Hence, as αα = - n , the competitive ratio of 2 is strict …. (Q.E.D) = - n , the competitive ratio of 2 is strict …. (Q.E.D)

Q 1.10: Show that the above derivation holds without strict Q 1.10: Show that the above derivation holds without strict competitiveness competitiveness

i.e. if in equation 1.6 [i.e. ALGi.e. if in equation 1.6 [i.e. ALG**xyxy((σσ) ≤ c.OPT) ≤ c.OPT**

xyxy((σσ) ] there is some additive ) ] there is some additive constant constant αα, then ALG is c- competitive up to an additive constant of {, then ALG is c- competitive up to an additive constant of {ααl(l-l(l-1)}/2.1)}/2.

A: Given, A: Given,

ALGALG**((σσxyxy) ≤ c.OPT) ≤ c.OPT**((σσxyxy) + ) + αα … (1) … (1)

By the pairwise property we have,By the pairwise property we have,

ALGALG**((σσxyxy) = ALG) = ALG**xyxy((σσ) )

OPTOPT**((σσxyxy) = OPT) = OPT**xyxy((σσ) … (2)) … (2)

Equation 1.4 gives us, Equation 1.4 gives us,

ALGALG**((σσ) = ) = ΣΣ{x,y}{x,y}⊆L,x≠y⊆L,x≠y ALG ALG**xyxy((σσ) (a)) (a)

OPTOPT**((σσ) = ) = ΣΣ{x,y}{x,y}⊆L,x≠y⊆L,x≠y OPT OPT**xyxy((σσ) (b)) (b)… (3)… (3)

Using (1) we have,Using (1) we have,

ALGALG**((σσ) ≤ ) ≤ ΣΣ{x,y}{x,y}⊆L,x≠y⊆L,x≠y {c.OPT{c.OPT**((σσxyxy) + ) + αα}}

Page 4: CSE 5314 – Spring 2004 Homework #1 - Solutions

University of Texas at Arlington

Or,Or, ALGALG**((σσ) ≤ c . ) ≤ c . ΣΣ{x,y}{x,y}⊆L,x≠y⊆L,x≠y OPTOPT**((σσxyxy) + ) + αα..ΣΣ{x,y}{x,y}⊆L,x≠y⊆L,x≠y 1 1

By (2) and subsequently (3), we haveBy (2) and subsequently (3), we have

ALGALG**((σσ) ≤ c . OPT) ≤ c . OPT**((σσ) + ) + αα..llCC22

Or, Or, ALGALG**((σσ) ≤ c . OPT) ≤ c . OPT**((σσ) + ) + αα.l.(l-1)/2 … (Q.E.D.).l.(l-1)/2 … (Q.E.D.)

Q 2.1: Consider the following modification to the BIT algorithm. Instead Q 2.1: Consider the following modification to the BIT algorithm. Instead of always complementing b(x) on every access of the element x, 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 complement b(x) only if it is not in the front of the list. Show that this BIT algorithm is not 7/4 competitive.BIT algorithm is not 7/4 competitive.

A: We make an observation about the altered BIT algorithm before we 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 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 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 probability of ½ every time it is accessed. Since we assume an initial uniform random distribution in {0,1}, our modified BIT algorithm uniform random distribution in {0,1}, our modified BIT algorithm essentially follows RMTF behavior. To complete the proof, we will try essentially follows RMTF behavior. To complete the proof, we will try and construct an input sequence that is going to prove that the and construct an input sequence that is going to prove that the competitiveness of 7/4 does not hold. competitiveness of 7/4 does not hold.

A good starting point is a nemesis request sequence similar to the one A good starting point is a nemesis request sequence similar to the one constructed for RMTF. constructed for RMTF.

Let, Let, σσ = [(x = [(xll))22 (x (xl-1l-1))22 (x (xl-2l-2))22 … (x … (x11))22]]kk, ,

k>1; xk>1; x11 is at the front, x is at the front, xll is at the end. is at the end.

It is easy to observe that after the first round with (k=1), all the bits will It is easy to observe that after the first round with (k=1), all the bits will bebe

Page 5: CSE 5314 – Spring 2004 Homework #1 - Solutions

University of Texas at Arlington

set to 1, and the algorithm thereafter will assume a deterministic set to 1, and the algorithm thereafter will assume a deterministic behavior. behavior.

Hence, each xHence, each xii, i , i єє {1,2,…,l} will be moved to the front on every {1,2,…,l} will be moved to the front on every second request deterministically. Therefore, other than the aberrant second request deterministically. Therefore, other than the aberrant first round, where the expected cost is 3/2 [½.1 + ½.2] (because it is 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 a random distribution), the cost to serve the sequence for k>1 is at least 2lleast 2l22 + 4l – 2l [2l(l+1)] … (from the RMTF derivation). + 4l – 2l [2l(l+1)] … (from the RMTF derivation).

The cost for MTF on this sequence would be l(l+1). The cost for MTF on this sequence would be l(l+1).

Hence the competitiveness is no larger than 2 times the optimal 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 offline for a sufficiently large value of l. Hence it is not 7/4 competitive… (Q.E.D.)competitive… (Q.E.D.)