This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Computer Science 340 Reasoning about Computation Homework 5 Due at the beginning of class on Wednesday, October 24, 2007 Problem 1 Consider the three-element list with the following initial configuration: ( x 1 , x 2 , x 3 ), (ie, x 1 is at the front). What is the cost of MTF for the access sequence: x 3 , x 2 , x 3 , x 2 . Prove that the optimal offline cost to serve the same access sequence is 8. Solution sketch: MTF cost is 10. Here is an offline algorithm with cost of 8: make 2 paid transpositions to get ( x 2 , x 3 , x 1 ). Now access-cost ( x 3 ) = 2 and access-cost ( x 2 ) = 1. Total cost=8. No offline algorithm can beat that. Why? First access to x 3 costs at least 3 Next access to x 2 , x 3 costs at least 4. Indeed, case 1: x 1 is between x 2 and x 3 , then cost is 1+3; case 2: x 2 , x 3 head the list, then cost is 1+2+ one paid transposition; case 3: x 1 heads the list, then cost is at least 2+2. Last access to x 2 costs at least 1. So the total cost is 8....
View Full Document
This homework help was uploaded on 01/29/2008 for the course COS 340 taught by Professor Charikarandchazelle during the Fall '07 term at Princeton.
- Fall '07