Sol0 - CS 577 Introduction to Algorithms Homework Solution...

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 Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 577: Introduction to Algorithms 9/12/06 Homework Solution: 00 Instructor: Shuchi Chawla Question 1 1a Our search strategy is to go (say) right one mile then come back to the start position and go right two miles then we return to the start position and go four miles to the left and so on, see Figure 1. Essentially we travel to twice the distance on each side of the starting points in each successive round. Obviously the strategy is guaranteed to find the treasure. 1 2 1 2 3 4 Figure 1: Treasure Hunt Now we determine the distance traveled in order to reach a point n miles on the right of the starting point. Let us call walking in a single direction at a stretch a round . Also we call the point at a distance of k miles left of the starting point as L k and the point at a distance on the right of the starting point as R k . So to get to L 8 on the left we go through 4 rounds, namely • A: Starting point to R 1 • B: R 1 to L 2 • C: L 2 to R 4 • D: R 4 to L 8 Also note that in round A we travel 1 mile in round B we travel 3 miles ( 1 mile from the left to 2 mile on the right), in round C we travel 4 + 2 i.e. 6 miles. Finally in round D we travel 4 + 8 miles. The pattern is clear, the distance traveled in round r is r + r 2 . We reach n miles on the right in round number ⌈ log n ⌉ + 1. Let n = 2 k be a point on the right, distance traveled to reach the treasure in each round is summed up as shown below d...
View Full Document

{[ snackBarMessage ]}

Page1 / 4

Sol0 - CS 577 Introduction to Algorithms Homework Solution...

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