hw5sol - Computer Science 340 Reasoning about Computation...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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

Page1 / 2

hw5sol - Computer Science 340 Reasoning about Computation...

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

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