review2sol - Computer Science 340 Reasoning about...

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

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

Computer Science 340 Reasoning about Computation Review Session 2 Friday, January 11, 2008 Problem 1 Recall the cow grazing problem from Homework 5. The cow is on a path that leads to food, but the cow doesn’t know what direction the food lies in. The goal was to design an online algorithm for the cow to traverse the path and find the food. The deterministic algorithm we proposed in the solution was the following. The cow starts in an arbitrary direction for one unit of distance. If it does not find food, it comes back to the starting position and tries the other direction going 2 units of distance. Each time it comes back to the start position, it goes in the other direction for twice the distance it tried before. We argued that the competitive ratio of this algorithm was 9. Several of you got this, or some variant of this idea. Next we asked you to design a randomized algorithm with better competitive ratio. Several students proposed randomizing the previous deterministic algorithm by picking a direction to traverse at random every time the cow returns to the origin. So, the cow goes distance 2 i - 1 in the i th iteration (and returns to the start if unsuccessful), but the direction of travel is picked at random at every iteration. Determine the competitive ratio of this algorithm. Solution: The algorithm is not competitive. Suppose that the field is at position 1. Compute the expected distance traveled by the algorithm in this case. The expected distance is . The expression for expected distance turns out to be 1 2 (1) + 1 4
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '07
  • CharikarandChazelle
  • Graph Theory, Analysis of algorithms

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern