CS 361: Algorithms and Data Structures
Homework 5


Assignments will be collected at the beginning of the class period. Please bring a hardcopy to turn in. Your assignment can be hand-written or typed.

For the questions on the homework that ask you to "design an algorithm" or "give an algorithm", please review the "Homework Guide" so you know what your answer must include.


Homework Questions

  1. Suppose you and your friends are hiking along a trail of length L and that you're able to hike at most d miles each day. Along the trail are stopping sites given by an array of distances A = [x1 x2 ... xn] from the start of the trail. For example, suppose L = 30, d = 8 and the stopping sites are given by A = [7, 11, 15, 16, 17, 20, 24].

    This means the first stopping site is 7 miles from the start, the second site is 11 miles from the start, the third stopping site is 15 miles from the start, etc. You may assume the distance between each stopping site is less than or equal to d.

    Design a greedy algorithm for choosing the subset of stopping sites that minimizes the number of stops made. Prove that your algorithm is optimal using an exchange argument

  2. Algorithm Design 4.3

  3. Algorithm Design 4.5 (Note: you need to provide a proof of optimality for your algorithm)


Last modified: Fri Jan 24 10:58:47 PST 2014