Helena Wong, 2001



Download 5.57 Kb.
Date03.05.2017
Size5.57 Kb.
#17092

Tutorial Exercise (Greedy Algorithms) CS3381 Design and Analysis of Algorithms

Helena Wong, 2001




  1. We have studied a recursive strategy (step 2 of dynamic programming), a dynamic programming approach and a greedy strategy approach that solve the activity-selection problem. Describe how these approaches work, using the following example:

Activities sorted in increasing order of finish time:



i 1 2 3 4 5 6 7 8

start_timei 0 3 4 6 5 9 10 11

finish_timei 3 4 7 8 11 11 12 14


  1. For the activity-selection problem, suppose that instead of always selecting the first activity to finish, we select the last activity to start that is compatible with all previously selected activities. Describe how this approach is a greedy algorithm.



  1. a.) State the key ingredients of dynamic programming.

  1. State the key ingredients of greedy algorithms.

  2. Given an optimization problem, how do you determine an appropriate approach to solve it?

4. Give a dynamic-programming solution to the 0-1 knapsack problem.

5. Give a greedy-algorithm solution to the fractional knapsack problem.

6. Fibonacci numbers are defined by the following recurrence:

F0 = 1, F1 = 1, Fi = Fi-1 + Fi-2
What is an optimal Huffman code for the following set of frequencies, based on the first 8 Fibonacci numbers? Describe your observation.

a:1 b:1 c:2 d:3 e:5 f:8 g:13 h:21






Download 5.57 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page