# hw5sol - Computer Science 340 Reasoning about Computation...

• Homework Help
• PresidentHackerCaribou10582
• 2
• 100% (7) 7 out of 7 people found this document helpful

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

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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern