Dynamic programming Topics for this week: - backtracking revisited: - - PowerPoint PPT Presentation

dynamic programming
SMART_READER_LITE
LIVE PREVIEW

Dynamic programming Topics for this week: - backtracking revisited: - - PowerPoint PPT Presentation

[Week 9] Dynamic programming Topics for this week: - backtracking revisited: a brute-force technique that finds a solution by trying all possibilities (usually VERY SLOW) - sometimes can be remedied by storing pre-computed values: called


slide-1
SLIDE 1

Dynamic programming

Topics for this week:

  • backtracking revisited: a brute-force technique that finds a

solution by trying all possibilities (usually VERY SLOW)

  • sometimes can be remedied by storing pre-computed values:

called dynamic programming

  • comparing the time complexities: dyn-prog is usually very

fast

[Week 9]

slide-2
SLIDE 2

Problem: Job Scheduling with Pay

You are a tile installer who has many jobs to choose from. Every job has a start time, finish time, and the pay you get for doing the job. You want to take those non-overlapping jobs that maximize your pay. Example: repairing old tiles, 8-10am, $200 grout sealing, 11-11:30am, $50 installing new tiles, 9am-12pm, $400

slide-3
SLIDE 3

Problem: Job Scheduling with Pay

Greedy approaches:

  • Do the greedy strategies from last quarter work ?
  • What about a strategy that takes the most expensive job

first, removes overlapping jobs, and continues with the same approach ?

slide-4
SLIDE 4

Problem: Job Scheduling with Pay

Backtracking through all possible sets of non-overlapping jobs. [This is also called exhaustive enumeration.] Pseudo code:

slide-5
SLIDE 5

Problem: Job Scheduling with Pay

A stack-frame diagram of the enumeration pseudo code: Time complexity:

slide-6
SLIDE 6

Problem: Job Scheduling with Pay

A dynamic programming approach: Time complexity:

slide-7
SLIDE 7

Problem: Job Scheduling with Pay

Tracing a more interesting example: Testing: