1 / 14

# Self-Organizing Lists Competitive Analysis - PowerPoint PPT Presentation

Self-Organizing Lists Competitive Analysis. Lee Wee Sun SoC1 5-26 [email protected] Modified by Orgad Keller Modified again by Ariel Rosenfeld. Self-Organizing List. List L of n elements Operations Access(x) cost rank(x)=position of x in the list

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Self-Organizing Lists Competitive Analysis' - libra

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Self-Organizing ListsCompetitive Analysis

Lee Wee Sun

SoC1 5-26

[email protected]

Modified again by Ariel Rosenfeld

Self-Organizing Lists

• List L of n elements

• Operations Access(x) cost

rank(x)=position of x in the list

• L can be reordered by transposing adjacent elements – cost = 1.

Self-Organizing Lists

• Problem: Sequence S of operations to which the algorithm must respond to without knowing the future inputs.

• Goal: Minimize the total cost of responding to the operations

Self-Organizing Lists

• Worst case:

• Adversary can always access the tail element of L

• Cost: in worst case

• Average case:

• Suppose element x is accessed with a probability of p(x)

• Minimized when L sorted in decreasing order WRT p.

• Keep count of #times the element is accessed and maintain a list in order to decrease count.

Self-Organizing Lists

• Move to Front (MTF):

• After accessing x, move x to head of L (by transposes)

• Cost is

• Responds well to locality in access pattern.

Self-Organizing Lists

• An online algorithm A is -competitive if there exists a constant k such that for any sequence S of operations

• is the algorithm that performs optimally for that particular sequence

• Knows the whole sequence in advance and has infinite computation power to find the method for achieving the optimal cost.

Self-Organizing Lists

• Theorem: MTF is 4-competitive for self-organizing lists.

• Proof:

• Let Li be MTF’s list after i-th access.

• Let Li* be OPT’s list after i-th access

• Let ci= MTF’s cost for i-th operation

• Let ci* = OPT’s cost for the i-th operation = rank*(x) + ti if OPT performs titransposes

Self-Organizing Lists

• Define potential function by

• x preceded y in Li and y precedes x in Li* = #inversions

• Example:

• Li = <E,C,A,D,B>

• Li* = <C,A,B,D,E>

• |{(E,C),(E,A),(E,D),(E,B),(D,B)| = 10

• Note:

• for every i

• if MTF and OPT have the same list

Self-Organizing Lists

• How much does change in 1 transpose?

• Transpose either creates or destroys 1 inversion

• Let = amortized cost WRT of MTF for the i-th operation

• Note (#inversions created - #inversions destroyed).

Self-Organizing Lists

Self-Organizing Lists

r = rank(x) = |A| + |B| + 1

A  B

C  D

Li-1:

x

• A = elements preceding x in Li-1 and preceding x in Li-1*

• B = elements preceding x in Li-1 and following x in Li-1*

• C = elements following x in Li-1 and preceding x in Li-1*

• D = elements following x in Li-1 and following x in Li-1*

A  C

B  D

Li-1*:

x

r* = rank*(x)  |A| + 1

Self-Organizing Lists

• When x is moved to front

• # inversions created = |A|

• # inversions destroyed = |B|

• Each transpose by OPT creates  1 inversions

Transposes by OPT



Actual cost by OPT

Self-Organizing Lists

Self-Organizing Lists

Summary “free”, then MTF is 2-competitive (see Sleator and Tarjan)

• Definition of competitive analysis

• MTF is competitive for self organizing lists

• Potential function method

• Number of inversions with the OPT’s list is the potential.

Self-Organizing Lists