UMass%20Lowell%20Computer%20Science%2091.404%20Analysis%20of%20Algorithms%20Prof.%20Karen%20Daniels%20Fall,%202006 - PowerPoint PPT Presentation

About This Presentation
Title:

UMass%20Lowell%20Computer%20Science%2091.404%20Analysis%20of%20Algorithms%20Prof.%20Karen%20Daniels%20Fall,%202006

Description:

Compute value of an optimal solution in bottom-up fashion. Construct an optimal solution from computed information. source: 91.404 textbook Cormen, et al. ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 16
Provided by: murrayd
Learn more at: http://www.cs.uml.edu
Category:

less

Transcript and Presenter's Notes

Title: UMass%20Lowell%20Computer%20Science%2091.404%20Analysis%20of%20Algorithms%20Prof.%20Karen%20Daniels%20Fall,%202006


1
UMass Lowell Computer Science 91.404 Analysis
of Algorithms Prof. Karen Daniels Fall, 2006
  • Design Patterns
  • for
  • Optimization Problems
  • Dynamic Programming Greedy Algorithms

2
Algorithmic Paradigm Context
Make choice, then solve subproblem(s)
Solve subproblem(s), then make choice
Subproblem solution order
3
Activity Selection Optimization Problem
  • Problem Instance
  • Set S 1,2,...,n of n activities
  • Each activity i has
  • start time si
  • finish time fi
  • Activities i, j are compatible iff
    non-overlapping
  • Objective
  • select a maximum-sized set of mutually compatible
    activities

source 91.404 textbook Cormen, et al.
4
source 91.404 textbook Cormen, et al.
5
Activity SelectionAlgorithmic Progression
  • Brute-Force
  • (board work)
  • Dynamic Programming 1
  • Exponential number of subproblems
  • (board work)
  • Dynamic Programming 2
  • Quadratic number of subproblems
  • (board work)
  • Greedy Algorithm
  • (board work)

6
  • Dynamic Programming

Activity Selection
7
Dynamic Programming Approach to Optimization
Problems
  1. Characterize structure of an optimal solution.
  2. Recursively define value of an optimal solution.
  3. Compute value of an optimal solution in bottom-up
    fashion.
  4. Construct an optimal solution from computed
    information.

source 91.404 textbook Cormen, et al.
8
Activity Selection
Solution to Sij including ak produces 2
subproblems 1) Sik (start after ai finishes
finish before ak starts) 2) Skj (start after ak
finishes finish before aj starts)
ci,jsize of maximum-size subset of mutually
compatible activities in Sij.
source 91.404 textbook Cormen, et al.
9
  • Greedy Algorithms

10
What is a Greedy Algorithm?
  • Solves an optimization problem
  • Optimal Substructure
  • optimal solution contains in it optimal solutions
    to subproblems
  • Greedy Strategy
  • At each decision point, do what looks best
    locally
  • Choice does not depend on evaluating potential
    future choices or presolving overlapping
    subproblems
  • Top-down algorithmic structure
  • With each step, reduce problem to a smaller
    problem
  • Greedy Choice Property
  • locally best globally best

11
Greedy Strategy Approach
  1. Determine the optimal substructure of the
    problem.
  2. Develop a recursive solution.
  3. Prove that, at any stage of the recursion, one of
    the optimal choices is the greedy choice.
  4. Show that all but one of the subproblems caused
    by making the greedy choice are empty.
  5. Develop a recursive greedy algorithm.
  6. Convert it to an iterative algorithm.

source 91.404 textbook Cormen, et al.
12
Recursive Greedy Activity Selection
High-level call RECURSIVE-ACTIVITY-SELECTOR(s,f,0
,n)
Returns an optimal solution for
Errors from earlier printing are corrected in
red.
source web site accompanying 91.404 textbook
Cormen, et al.
13
source web site accompanying 91.404 textbook
Cormen, et al.
14
Iterative Greedy Activity Selection
source 91.503 textbook Cormen, et al.
  • Iterative Greedy Algorithm
  • S presort activities in S by nondecreasing
    finish time
  • and renumber
  • GREEDY-ACTIVITY-SELECTOR(S)
  • n lengthS
  • A 1
  • j 1
  • for i 2 to n
  • do if
  • then
  • j i
  • return A

15
Streamlined Greedy Strategy Approach
  1. View optimization problem as one in which making
    choice leaves one subproblem to solve.
  2. Prove there always exists an optimal solution
    that makes the greedy choice.
  3. Show that greedy choice optimal solution to
    subproblem optimal solution to problem.

Greedy Choice Property locally best globally
best
source 91.404 textbook Cormen, et al.
Write a Comment
User Comments (0)
About PowerShow.com