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

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

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

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

View Full Document
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 .
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

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

View Full Document
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 .
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 .

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

View Full Document
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
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.

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

View Full Document
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:
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online