lec14 - Introduction to Algorithms 6.046J/18.401J LECTURE...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
November 2, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.1 Introduction to Algorithms 6.046J/18.401J L ECTURE 14 Competitive Analysis Self-organizing lists Move-to-front heuristic Competitive analysis of MTF Prof. Charles E. Leiserson
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
November 2, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.2 Self-organizing lists List L of n elements The operation A CCESS ( x ) costs rank L ( x )= distance of x from the head of L . L can be reordered by transposing adjacent elements at a cost of 1 .
Background image of page 2
November 2, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.3 Self-organizing lists List L of n elements The operation A CCESS ( x ) costs rank L ( x )= distance of x from the head of L . L can be reordered by transposing adjacent elements at a cost of 1 . Example: 12 12 3 3 50 50 14 14 17 17 4 4 L
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
November 2, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.4 Self-organizing lists List L of n elements The operation A CCESS ( x ) costs rank L ( x )= distance of x from the head of L . L can be reordered by transposing adjacent elements at a cost of 1 . Example: 12 12 3 3 50 50 14 14 17 17 4 4 L Accessing the element with key 14 costs 4 .
Background image of page 4
November 2, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.5 Self-organizing lists List L of n elements The operation A CCESS ( x ) costs rank L ( x )= distance of x from the head of L . L can be reordered by transposing adjacent elements at a cost of 1 . Example: 12 12 3 3 50 50 3 3 14 14 17 17 4 4 50 50 L Transposing 3 and 50 costs 1 .
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
November 2, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.6 On-line and off-line problems Definition. A sequence S of operations is provided one at a time. For each operation, an on-line algorithm A must execute the operation immediately without any knowledge of future operations (e.g., Tetris ). An off-line algorithm may see the whole sequence S in advance. Goal: Minimize the total cost C A ( S ) . The game of Tetris
Background image of page 6
November 2, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.7 Worst-case analysis of self- organizing lists An adversary always accesses the tail ( n th) element of L . Then, for any on-line algorithm A , we have C A ( S ) = (| S | n ) in the worst case.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L14.8 Average-case analysis of self- organizing lists Suppose that element x is accessed with probability p ( x ) . Then, we have = L x L A x x p S C ) ( rank ) ( )] ( [ E , which is minimized when L is sorted in decreasing order with respect to p . Heuristic:
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/19/2010 for the course CS 477 taught by Professor Gewali during the Spring '08 term at University of Nevada, Las Vegas.

Page1 / 40

lec14 - Introduction to Algorithms 6.046J/18.401J LECTURE...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online