lecture_09 - Dynamic programming s Greedy algorithm . Build...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Dynamic programming s Greedy algorithm . Build up a solution incrementally by optimizing some local criterion. Remark. May not give optimal solutions; when yes, it often involves non-trivial analysis. s Divide and conquer . Break up a problem into two sub- roblems, solving each subproblem ecursively and combine problems, solving each subproblem recursively , and combine their solutions into an overall solution. Remark. Simple and efficient. Subproblems do not overlap. Many problems are too complicated to be divided. s Dynamic programming . Similar to divide-and-conquer. Break up a problem into subproblems, but they might be overlapping. Brute-force recursion: exponential time. Use a table to store up the solutions of subproblems to avoid repeated computation. Classical examples s Weighted compatible intervals s Longest increasing subsequence s Knapsack s Matrix Chain Reading assignment Dasgupta et al. Chapter 6 Cormen et al. Chapter 15 Interval Scheduling Revisited Interval scheduling. s Job j starts at s j , finishes at f j and has value (weight) v j . s Two jobs are compatible if they don't overlap. s Goal : find a subset of mutually compatible jobs whose tal eight maximized. 3 total weight is maximized. TIME 4 20 1 29 Unweighted Interval Scheduling: Greedy alg. Earliest finish time . Sort the jobs in ascending order of finish time fj. Consider the jobs one by one; accept a job if it's compatible with the ones already accepted . 4 O(n log n) time. Theorem. Earliest finish time is optimal for maximizing the number of jobs . In general, max total weight ≠ max number of jobs. Weighted Interval Scheduling Notation. Label jobs from 1 to n so that they are in ascending ordering of finish time , i.e., f 1 ≤ f 2 ≤ … ≤ f n . Definition . Let p (j) = largest i < j such that job i is compatible with job j. Recursion: Binary choice Let OPT (n) be the optimal selection for jobs 1, 2, .., n. [ In general, let OPT(j) be the optimal selection for jobs 1,2,…, j. ] Recursive formulation . Case 1 . OPT (n) selects job n. max value s Job n is incompatible with jobs p(n)+1, p(n)+2, …, n-1. s OPT(n) – {n} is a subset of { 1, 2, …, p(n) }....
View Full Document

This note was uploaded on 03/01/2010 for the course CS 1234 taught by Professor Chan during the Spring '10 term at University of the Bío-Bío.

Page1 / 28

lecture_09 - Dynamic programming s Greedy algorithm . Build...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online