Copyright 2000, Kevin Wayne 1

Size: px
Start display at page:

Download "Copyright 2000, Kevin Wayne 1"

Transcription

1 /9/ lgorithmic Paradigms hapter Dynamic Programming reed. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer. Break up a problem into two sub-problems, solve each sub-problem independently, and combine solution to sub-problems to form solution to original problem. Dynamic programming. Break up a problem into a series of overlapping sub-problems, and build up solutions to larger and larger sub-problems. Slides by Kevin Wayne. opyright Pearson-ddison Wesley. ll rights reserved. Dynamic Programming History Dynamic Programming pplications Bellman. Pioneered the systematic study of dynamic programming in the 9s. Etymology. Dynamic programming = planning over time. Secretary of Defense was hostile to mathematical research. Bellman sought an impressive name to avoid confrontation. "it's impossible to use dynamic in a pejorative sense" "something not even a ongressman could object to" Reference: Bellman, R. E. Eye of the Hurricane, n utobiography. reas. Bioinformatics. ontrol theory. Information theory. Operations research. omputer science: theory, graphics, I, systems,. Some famous dynamic programming algorithms. Viterbi for hidden Markov models. nix diff for comparing two files. Smith-Waterman for sequence alignment. Bellman-Ford for shortest path routing in networks. ocke-kasami-younger for parsing context free grammars. opyright, Kevin Wayne

2 /9/ Weighted Interval Scheduling. Weighted Interval Scheduling Weighted interval scheduling problem. Job j starts at s j, finishes at f j, and has weight or value v j. Two jobs compatible if they don't overlap. oal: find maximum weight subset of mutually compatible jobs. a b c d e f g 8 9 h Time nweighted Interval Scheduling Review Weighted Interval Scheduling Recall. reedy algorithm works if all weights are. onsider jobs in ascending order of finish time. dd job to subset if it is compatible with previously chosen jobs. Notation. Label jobs by finishing time: f f... f n. Def. p(j) = largest index i < j such that job i is compatible with j. Ex: p(8) =, p() =, p() =. Observation. reedy algorithm can fail spectacularly if arbitrary weights are allowed. weight = 999 b weight = a 8 9 Time Time 8 opyright, Kevin Wayne

3 /9/ Dynamic Programming: Binary hoice Weighted Interval Scheduling: Brute Force Notation. OPT(j) = value of optimal solution to the problem consisting of job requests,,..., j. Brute force algorithm. ase : OPT selects job j. can't use incompatible jobs { p(j) +, p(j) +,..., j - must include optimal solution to problem consisting of remaining compatible jobs,,..., p(j) ase : OPT does not select job j. optimal substructure must include optimal solution to problem consisting of remaining compatible jobs,,..., j- # if j = OPT( j) = $ % max { v j + OPT( p( j)), OPT( j ) otherwise Input: n, s,,s n, f,,f n, v,,v n Sort jobs by finish times so that f f... f n. ompute p(), p(),, p(n) ompute-opt(j) { if (j = ) return else return max(v j + ompute-opt(p(j)), ompute-opt(j-)) 9 Weighted Interval Scheduling: Brute Force Weighted Interval Scheduling: Memoization Observation. Recursive algorithm fails spectacularly because of redundant sub-problems exponential algorithms. Memoization. Store results of each sub-problem in a cache; lookup as needed. Ex. Number of recursive calls for family of "layered" instances grows like Fibonacci sequence. Input: n, s,,s n, f,,f n, v,,v n Sort jobs by finish times so that f f... f n. ompute p(), p(),, p(n) p() =, p(j) = j- for j = to n M[j] = empty M[j] = global array M-ompute-Opt(j) { if (M[j] is empty) M[j] = max(w j + M-ompute-Opt(p(j)), M-ompute-Opt(j-)) return M[j] opyright, Kevin Wayne

4 /9/ Weighted Interval Scheduling: Running Time laim. Memoized version of algorithm takes O(n log n) time. Sort by finish time: O(n log n). omputing p( ) : O(n) after sorting by start time. M-ompute-Opt(j): each invocation takes O() time and either (i) returns an existing value M[j] (ii) fills in one new entry M[j] and makes two recursive calls Progress measure Φ = # nonempty entries of M[]. initially Φ =, throughout Φ n. (ii) increases Φ by at most n recursive calls. Overall running time of M-ompute-Opt(n) is O(n). Remark. O(n) if jobs are pre-sorted by start and finish times. omputing the Index p(.) in Linear Time Interval 8 Finish time 8 9 Interval 8 Start time 8 Interval 8 p(.) 8 Time 8 9 utomated Memoization Weighted Interval Scheduling: Finding a Solution utomated memoization. Many functional programming languages (e.g., Lisp) have built-in support for memoization. Q. Why not in imperative languages (e.g., Java)? Q. Dynamic programming algorithms computes optimal value. What if we want the solution itself?. Do some post-processing. (defun F (n) (if (<= n ) n (+ (F (- n )) (F (- n ))))) Lisp (efficient) static int F(int n) { if (n <= ) return n; else return F(n-) + F(n-); F(8) F(9) Java (exponential) F() F() F() F(8) F() Run M-ompute-Opt(n) Run Find-Solution(n) Find-Solution(j) { if (j = ) output nothing else if (v j + M[p(j)] > M[j-]) print j Find-Solution(p(j)) else Find-Solution(j-) F() F() F() F() F() F() F() F() # of recursive calls n O(n). opyright, Kevin Wayne

5 /9/ Weighted Interval Scheduling: Bottom-p Bottom-up dynamic programming. nwind recursion.. Segmented Least Squares Input: n, s,,s n, f,,f n, v,,v n Sort jobs by finish times so that f f... f n. ompute p(), p(),, p(n) Iterative-ompute-Opt { M[] = for j = to n M[j] = max(v j + M[p(j)], M[j-]) Segmented Least Squares Segmented Least Squares Least squares. Foundational problem in statistic and numerical analysis. iven n points in the plane: (x, y ), (x, y ),..., (x n, y n ). Find a line y = ax + b that minimizes the sum of the squared error: Segmented least squares. Points lie roughly on a sequence of several line segments. iven n points in the plane (x, y ), (x, y ),..., (x n, y n ) with x < x <... < x n, find a sequence of lines that minimizes f(x). n SSE = ( y i ax i b) i= y Q. What's a reasonable choice for f(x) to balance accuracy and parsimony? number of lines goodness of fit x y Solution. alculus min error is achieved when a = n x i i y i ( i x i ) ( i y i ), b = n x i ( x i ) i i i y i a i x i n x 9 opyright, Kevin Wayne

6 /9/ Segmented Least Squares Dynamic Programming: Multiway hoice Segmented least squares. Points lie roughly on a sequence of several line segments. iven n points in the plane (x, y ), (x, y ),..., (x n, y n ) with x < x <... < x n, find a sequence of lines that minimizes: the sum of the sums of the squared errors E in each segment the number of lines L Tradeoff function: E + c L, for some constant c >. Notation. OPT(j) = minimum cost for points p, p i+,..., p j. e(i, j) = minimum sum of squares for points p i, p i+,..., p j. To compute OPT(j): Last segment uses points p i, p i+,..., p j for some i. ost = e(i, j) + c + OPT(i-). y $ & if j = OPT( j) = % min { e(i, j) + c + OPT(i ) otherwise '& i j x Segmented Least Squares: lgorithm INPT: n, p,,p N, c. Knapsack Problem Segmented-Least-Squares() { M[] = for j = to n for i = to j compute the least square error e ij for the segment p i,, p j for j = to n M[j] = min i j (e ij + c + M[i-]) return M[n] Running time. O(n ). can be improved to O(n ) by pre-computing various statistics Bottleneck = computing e(i, j) for O(n ) pairs, O(n) per pair using previous formula. opyright, Kevin Wayne

7 /9/ Knapsack Problem Dynamic Programming: False Start Knapsack problem. iven n objects and a "knapsack." Item i weighs w i > kilograms and has value v i >. Knapsack has capacity of W kilograms. oal: fill knapsack so as to maximize total value. Ex: {, has value. W = Item Value reedy: repeatedly add item with maximum ratio v i / w i. Ex: {,, achieves only value = greedy not optimal. 8 8 Weight Def. OPT(i) = max profit subset of items,, i. ase : OPT does not select item i. OPT selects best of {,,, i- ase : OPT selects item i. accepting item i does not immediately imply that we will have to reject other items without knowing what other items were selected before i, we don't even know if we have enough room for i onclusion. Need more sub-problems! Dynamic Programming: dding a New Variable Knapsack Problem: Bottom-p Def. OPT(i, w) = max profit subset of items,, i with weight limit w. Knapsack. Fill up an n-by-w array. ase : OPT does not select item i. OPT selects best of {,,, i- using weight limit w ase : OPT selects item i. new weight limit = w w i OPT selects best of {,,, i using this new weight limit # if i = % OPT(i, w) = $ OPT(i, w) if w i > w % & max{ OPT(i, w), v i + OPT(i, w w i ) otherwise Input: n, w,,w N, v,,v N for w = to W M[, w] = for i = to n for w = to W if (w i > w) M[i, w] = M[i-, w] else M[i, w] = max {M[i-, w], v i + M[i-, w-w i ] return M[n, W] 8 opyright, Kevin Wayne

8 /9/ Knapsack lgorithm Knapsack Problem: Running Time φ W Running time. Θ(n W). Not polynomial in input size! "Pseudo-polynomial." Decision version of Knapsack is NP-complete. [hapter 8] n + { {, {,, {,,, Knapsack approximation algorithm. There exists a polynomial algorithm that produces a feasible solution that has value within.% of optimum. [Section.8] {,,,, Item Value Weight OPT: {, value = + 8 = W = String Similarity. Sequence lignment How similar are two strings? ocurrance occurrence o c u r r a n c e - o c c u r r e n c e mismatches, gap o c - u r r a n c e o c c u r r e n c e mismatch, gap o c - u r r - a n c e o c c u r r e - n c e mismatches, gaps opyright, Kevin Wayne 8

9 /9/ Edit Distance Sequence lignment pplications. Basis for nix diff. Speech recognition. omputational biology. Edit distance. [Levenshtein 9, Needleman-Wunsch 9] ap penalty δ; mismatch penalty α pq. ost = sum of gap and mismatch penalties. T T T - T T T oal: iven two strings X = x x... x m and Y = y y... y n find alignment of minimum cost. Def. n alignment M is a set of ordered pairs x i -y j such that each item occurs in at most one pair and no crossings. Def. The pair x i -y j and x i' -y j' cross if i < i', but j > j'. cost( M ) = α xi y j + δ + δ (x i, y j ) M i : x!#" # $ i unmatched j : y j unmatched!### #" ##### $ mismatch gap T T T α T + α T + α + α T - T T δ + α Ex: T vs. TT. Sol: M = x -y, x -y, x -y, x -y, x -y. x x x x x x T - - T T y y y y y y Sequence lignment: Problem Structure Sequence lignment: lgorithm Def. OPT(i, j) = min cost of aligning strings x x... x i and y y... y j. ase : OPT matches x i -y j. pay mismatch for x i -y j + min cost of aligning two strings x x... x i- and y y... y j- ase a: OPT leaves x i unmatched. pay gap for x i and min cost of aligning x x... x i- and y y... y j ase b: OPT leaves y j unmatched. pay gap for y j and min cost of aligning x x... x i and y y... y j- " jδ if i = $ " α xi y j + OPT(i, j ) $ $ OPT(i, j) = # min # δ + OPT(i, j) otherwise $ $ δ + OPT(i, j ) % % $ iδ if j = Sequence-lignment(m, n, x x...x m, y y...y n, δ, α) { for i = to m M[, i] = iδ for j = to n M[j, ] = jδ for i = to m for j = to n M[i, j] = min(α[x i, y j ] + M[i-, j-], δ + M[i-, j], δ + M[i, j-]) return M[m, n] nalysis. Θ(mn) time and space. English words or sentences: m, n. omputational biology: m = n =,. billions ops OK, but B array? opyright, Kevin Wayne 9

10 /9/ Sequence lignment: lgorithm y n +. RN Secondary Structure φ T T x m + φ T ap penalty = Mismatch penalty = x x x x x x T - - T T y y y y y y RN Secondary Structure RN Secondary Structure RN. String B = b b b n over alphabet {,,,. Secondary structure. RN is single-stranded so it tends to loop back and form base pairs with itself. This structure is essential for understanding behavior of molecule. Ex: Secondary structure. set of pairs S = { (b i, b j ) that satisfy: [Watson-rick.] S is a matching and each pair in S is a Watson- rick complement: -, -, -, or -. [No sharp turns.] The ends of each pair are separated by at least intervening bases. If (b i, b j ) S, then i < j -. [Non-crossing.] If (b i, b j ) and (b k, b l ) are two pairs in S, then we cannot have i < k < j < l. Free energy. sual hypothesis is that an RN molecule will form the secondary structure with the optimum total free energy. approximate by number of base pairs oal. iven an RN molecule B = b b b n, find a secondary structure S that maximizes the number of base pairs. complementary base pairs: -, - 9 opyright, Kevin Wayne

11 /9/ RN Secondary Structure: Examples RN Secondary Structure: Subproblems Examples. First attempt. OPT(j) = maximum number of base pairs in a secondary structure of the substring b b b j. match b t and b n base pair t n Difficulty. Results in two sub-problems. Finding secondary structure in: b b b t-. Finding secondary structure in: b t+ b t+ b n-. OPT(t-) need more sub-problems ok sharp turn crossing Dynamic Programming Over Intervals Bottom p Dynamic Programming Over Intervals Notation. OPT(i, j) = maximum number of base pairs in a secondary structure of the substring b i b i+ b j. Q. What order to solve the sub-problems?. Do shortest intervals first. ase. If i j -. OPT(i, j) = by no-sharp turns condition. ase. Base b j is not involved in a pair. OPT(i, j) = OPT(i, j-) RN(b,,b n ) { for k =,,, n- for i =,,, n-k j = i + k ompute M[i, j] i ase. Base b j pairs with b t for some i t < j -. non-crossing constraint decouples resulting sub-problems OPT(i, j) = + max t { OPT(i, t-) + OPT(t+, j-) return M[, n] using recurrence 8 9 j take max over t such that i t < j- and b t and b j are Watson-rick complements Running time. O(n ). Remark. Same core idea in KY algorithm to parse context-free grammars. opyright, Kevin Wayne

12 /9/ Dynamic Programming Summary Recipe. haracterize structure of problem. Recursively define value of optimal solution. ompute value of optimal solution. onstruct optimal solution from computed information. Dynamic programming techniques. Binary choice: weighted interval scheduling. Multi-way choice: segmented least squares. dding a new variable: knapsack. Viterbi algorithm for HMM also uses DP to optimize a maximum likelihood tradeoff between parsimony and accuracy Dynamic programming over intervals: RN secondary structure. KY parsing algorithm for context-free grammar has similar structure Top-down vs. bottom-up: different people have different intuitions. opyright, Kevin Wayne

Areas. ! Bioinformatics. ! Control theory. ! Information theory. ! Operations research. ! Computer science: theory, graphics, AI, systems,.

Areas. ! Bioinformatics. ! Control theory. ! Information theory. ! Operations research. ! Computer science: theory, graphics, AI, systems,. lgorithmic Paradigms hapter Dynamic Programming reed Build up a solution incrementally, myopically optimizing some local criterion Divide-and-conquer Break up a problem into two sub-problems, solve each

More information

Dynamic Programming. Weighted Interval Scheduling. Algorithmic Paradigms. Dynamic Programming

Dynamic Programming. Weighted Interval Scheduling. Algorithmic Paradigms. Dynamic Programming lgorithmic Paradigms Dynamic Programming reed Build up a solution incrementally, myopically optimizing some local criterion Divide-and-conquer Break up a problem into two sub-problems, solve each sub-problem

More information

Dynamic Programming 1

Dynamic Programming 1 Dynamic Programming 1 lgorithmic Paradigms Divide-and-conquer. Break up a problem into two sub-problems, solve each sub-problem independently, and combine solution to sub-problems to form solution to original

More information

Chapter 6. Weighted Interval Scheduling. Dynamic Programming. Algorithmic Paradigms. Dynamic Programming Applications

Chapter 6. Weighted Interval Scheduling. Dynamic Programming. Algorithmic Paradigms. Dynamic Programming Applications lgorithmic Paradigms hapter Dynamic Programming reedy. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer. Break up a problem into sub-problems, solve each

More information

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Algorithmic Paradigms Greed. Build up a solution incrementally, myopically optimizing

More information

CSE 202 Dynamic Programming II

CSE 202 Dynamic Programming II CSE 202 Dynamic Programming II Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Algorithmic Paradigms Greed. Build up a solution incrementally,

More information

6. DYNAMIC PROGRAMMING I

6. DYNAMIC PROGRAMMING I lgorithmic paradigms 6. DYNMI PRORMMIN I weighted interval scheduling segmented least squares knapsack problem RN secondary structure reedy. Build up a solution incrementally, myopically optimizing some

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 //8 Fast Integer Division Too (!) Schönhage Strassen algorithm CS 8: Algorithm Design and Analysis Integer division. Given two n-bit (or less) integers s and t, compute quotient q = s / t and remainder

More information

6. DYNAMIC PROGRAMMING I

6. DYNAMIC PROGRAMMING I 6. DYNAMIC PROGRAMMING I weighted interval scheduling segmented least squares knapsack problem RNA secondary structure Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 208 Announcement: Homework 3 due February 5 th at :59PM Final Exam (Tentative): Thursday, May 3 @ 8AM (PHYS 203) Recap: Divide

More information

6. DYNAMIC PROGRAMMING I

6. DYNAMIC PROGRAMMING I 6. DYNAMIC PRORAMMIN I weighted interval scheduling segmented least squares knapsack problem RNA secondary structure Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 58: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 28 Announcement: Homework 3 due February 5 th at :59PM Midterm Exam: Wed, Feb 2 (8PM-PM) @ MTHW 2 Recap: Dynamic Programming

More information

Chapter 6. Dynamic Programming. CS 350: Winter 2018

Chapter 6. Dynamic Programming. CS 350: Winter 2018 Chapter 6 Dynamic Programming CS 350: Winter 2018 1 Algorithmic Paradigms Greedy. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer. Break up a problem into

More information

Dynamic Programming. Cormen et. al. IV 15

Dynamic Programming. Cormen et. al. IV 15 Dynamic Programming Cormen et. al. IV 5 Dynamic Programming Applications Areas. Bioinformatics. Control theory. Operations research. Some famous dynamic programming algorithms. Unix diff for comparing

More information

Dynamic Programming: Interval Scheduling and Knapsack

Dynamic Programming: Interval Scheduling and Knapsack Dynamic Programming: Interval Scheduling and Knapsack . Weighted Interval Scheduling Weighted Interval Scheduling Weighted interval scheduling problem. Job j starts at s j, finishes at f j, and has weight

More information

CSE 421 Weighted Interval Scheduling, Knapsack, RNA Secondary Structure

CSE 421 Weighted Interval Scheduling, Knapsack, RNA Secondary Structure CSE Weighted Interval Scheduling, Knapsack, RNA Secondary Structure Shayan Oveis haran Weighted Interval Scheduling Interval Scheduling Job j starts at s(j) and finishes at f j and has weight w j Two jobs

More information

CSE 421 Dynamic Programming

CSE 421 Dynamic Programming CSE Dynamic Programming Yin Tat Lee Weighted Interval Scheduling Interval Scheduling Job j starts at s(j) and finishes at f j and has weight w j Two jobs compatible if they don t overlap. Goal: find maximum

More information

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov Dynamic Programming Data Structures and Algorithms Andrei Bulatov Algorithms Dynamic Programming 18-2 Weighted Interval Scheduling Weighted interval scheduling problem. Instance A set of n jobs. Job j

More information

Outline DP paradigm Discrete optimisation Viterbi algorithm DP: 0 1 Knapsack. Dynamic Programming. Georgy Gimel farb

Outline DP paradigm Discrete optimisation Viterbi algorithm DP: 0 1 Knapsack. Dynamic Programming. Georgy Gimel farb Outline DP paradigm Discrete optimisation Viterbi algorithm DP: Knapsack Dynamic Programming Georgy Gimel farb (with basic contributions by Michael J. Dinneen) COMPSCI 69 Computational Science / Outline

More information

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Algorithmic Paradigms Greed. Build up a solution incrementally, myopically optimizing some

More information

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Algorithmic Paradigms Greed. Build up a solution incrementally, myopically optimizing

More information

CS Lunch. Dynamic Programming Recipe. 2 Midterm 2! Slides17 - Segmented Least Squares.key - November 16, 2016

CS Lunch. Dynamic Programming Recipe. 2 Midterm 2! Slides17 - Segmented Least Squares.key - November 16, 2016 CS Lunch 1 Michelle Oraa Ali Tien Dao Vladislava Paskova Nan Zhuang Surabhi Sharma Wednesday, 12:15 PM Kendade 307 2 Midterm 2! Monday, November 21 In class Covers Greedy Algorithms Closed book Dynamic

More information

Dynamic Programming( Weighted Interval Scheduling)

Dynamic Programming( Weighted Interval Scheduling) Dynamic Programming( Weighted Interval Scheduling) 17 November, 2016 Dynamic Programming 1 Dynamic programming algorithms are used for optimization (for example, finding the shortest path between two points,

More information

6.6 Sequence Alignment

6.6 Sequence Alignment 6.6 Sequence Alignment String Similarity How similar are two strings? ocurrance o c u r r a n c e - occurrence First model the problem Q. How can we measure the distance? o c c u r r e n c e 6 mismatches,

More information

Lecture 2: Divide and conquer and Dynamic programming

Lecture 2: Divide and conquer and Dynamic programming Chapter 2 Lecture 2: Divide and conquer and Dynamic programming 2.1 Divide and Conquer Idea: - divide the problem into subproblems in linear time - solve subproblems recursively - combine the results in

More information

1.1 First Problem: Stable Matching. Six medical students and four hospitals. Student Preferences. s6 h3 h1 h4 h2. Stable Matching Problem

1.1 First Problem: Stable Matching. Six medical students and four hospitals. Student Preferences. s6 h3 h1 h4 h2. Stable Matching Problem //0 hapter Introduction: Some Representative Problems Slides by Kevin ayne. opyright 00 Pearson-ddison esley. ll rights reserved.. First Problem: Stable Matching Six medical students and four hospitals

More information

Objec&ves. Review. Dynamic Programming. What is the knapsack problem? What is our solu&on? Ø Review Knapsack Ø Sequence Alignment 3/28/18

Objec&ves. Review. Dynamic Programming. What is the knapsack problem? What is our solu&on? Ø Review Knapsack Ø Sequence Alignment 3/28/18 /8/8 Objec&ves Dynamic Programming Ø Review Knapsack Ø Sequence Alignment Mar 8, 8 CSCI - Sprenkle Review What is the knapsack problem? What is our solu&on? Mar 8, 8 CSCI - Sprenkle /8/8 Dynamic Programming:

More information

RNA Secondary Structure. CSE 417 W.L. Ruzzo

RNA Secondary Structure. CSE 417 W.L. Ruzzo RN Secondary Structure SE 417 W.L. Ruzzo The Double Helix Los lamos Science The entral Dogma of Molecular Biology DN RN Protein gene Protein DN (chromosome) cell RN (messenger) Non-coding RN Messenger

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 18 Dynamic Programming (Segmented LS recap) Longest Common Subsequence Adam Smith Segmented Least Squares Least squares. Foundational problem in statistic and numerical

More information

6. DYNAMIC PROGRAMMING II

6. DYNAMIC PROGRAMMING II 6. DYNAMIC PROGRAMMING II sequence alignment Hirschberg's algorithm Bellman-Ford algorithm distance vector protocols negative cycles in a digraph Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison

More information

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo CSE 431/531: Analysis of Algorithms Dynamic Programming Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Paradigms for Designing Algorithms Greedy algorithm Make a

More information

Algoritmiek, bijeenkomst 3

Algoritmiek, bijeenkomst 3 Algoritmiek, bijeenkomst 3 Mathijs de Weerdt Today Introduction Greedy Divide and Conquer (very briefly) Dynamic programming Slides with thanks to Kevin Wayne and Pearson Education (made available together

More information

Aside: Golden Ratio. Golden Ratio: A universal law. Golden ratio φ = lim n = 1+ b n = a n 1. a n+1 = a n + b n, a n+b n a n

Aside: Golden Ratio. Golden Ratio: A universal law. Golden ratio φ = lim n = 1+ b n = a n 1. a n+1 = a n + b n, a n+b n a n Aside: Golden Ratio Golden Ratio: A universal law. Golden ratio φ = lim n a n+b n a n = 1+ 5 2 a n+1 = a n + b n, b n = a n 1 Ruta (UIUC) CS473 1 Spring 2018 1 / 41 CS 473: Algorithms, Spring 2018 Dynamic

More information

The Double Helix. CSE 417: Algorithms and Computational Complexity! The Central Dogma of Molecular Biology! DNA! RNA! Protein! Protein!

The Double Helix. CSE 417: Algorithms and Computational Complexity! The Central Dogma of Molecular Biology! DNA! RNA! Protein! Protein! The Double Helix SE 417: lgorithms and omputational omplexity! Winter 29! W. L. Ruzzo! Dynamic Programming, II" RN Folding! http://www.rcsb.org/pdb/explore.do?structureid=1t! Los lamos Science The entral

More information

Matrix Multiplication. Data Structures and Algorithms Andrei Bulatov

Matrix Multiplication. Data Structures and Algorithms Andrei Bulatov Matrix Multiplicatio Data Structures ad Algorithms Adrei Bulatov Algorithms Matrix Multiplicatio 7- Matrix Multiplicatio Matrix multiplicatio. Give two -by- matrices A ad B, compute A B. k kj ik ij b a

More information

Dynamic programming. Curs 2015

Dynamic programming. Curs 2015 Dynamic programming. Curs 2015 Fibonacci Recurrence. n-th Fibonacci Term INPUT: n nat QUESTION: Compute F n = F n 1 + F n 2 Recursive Fibonacci (n) if n = 0 then return 0 else if n = 1 then return 1 else

More information

Matching Residents to Hospitals

Matching Residents to Hospitals Midterm Review Matching Residents to Hospitals Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. Unstable pair: applicant x and

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright Pearson-Addison Wesley. All rights reserved. 4 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and finishes

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and

More information

Dynamic programming. Curs 2017

Dynamic programming. Curs 2017 Dynamic programming. Curs 2017 Fibonacci Recurrence. n-th Fibonacci Term INPUT: n nat QUESTION: Compute F n = F n 1 + F n 2 Recursive Fibonacci (n) if n = 0 then return 0 else if n = 1 then return 1 else

More information

Greedy Algorithms My T. UF

Greedy Algorithms My T. UF Introduction to Algorithms Greedy Algorithms @ UF Overview A greedy algorithm always makes the choice that looks best at the moment Make a locally optimal choice in hope of getting a globally optimal solution

More information

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 Approximation Algorithms Q. Suppose I need to solve an NP-hard problem. What should

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 6 Greedy Algorithms Interval Scheduling Interval Partitioning Scheduling to Minimize Lateness Sofya Raskhodnikova S. Raskhodnikova; based on slides by E. Demaine,

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17 601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17 12.1 Introduction Today we re going to do a couple more examples of dynamic programming. While

More information

More Dynamic Programming

More Dynamic Programming CS 374: Algorithms & Models of Computation, Spring 2017 More Dynamic Programming Lecture 14 March 9, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 42 What is the running time of the following? Consider

More information

More Dynamic Programming

More Dynamic Programming Algorithms & Models of Computation CS/ECE 374, Fall 2017 More Dynamic Programming Lecture 14 Tuesday, October 17, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 48 What is the running time of the following?

More information

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming Algorithms and Theory of Computation Lecture 9: Dynamic Programming Xiaohui Bei MAS 714 September 10, 2018 Nanyang Technological University MAS 714 September 10, 2018 1 / 21 Recursion in Algorithm Design

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 0, Winter 08 Design and Analysis of Algorithms Lecture 8: Consolidation # (DP, Greed, NP-C, Flow) Class URL: http://vlsicad.ucsd.edu/courses/cse0-w8/ Followup on IGO, Annealing Iterative Global Optimization

More information

Lecture 9. Greedy Algorithm

Lecture 9. Greedy Algorithm Lecture 9. Greedy Algorithm T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2018

More information

Activity selection. Goal: Select the largest possible set of nonoverlapping (mutually compatible) activities.

Activity selection. Goal: Select the largest possible set of nonoverlapping (mutually compatible) activities. Greedy Algorithm 1 Introduction Similar to dynamic programming. Used for optimization problems. Not always yield an optimal solution. Make choice for the one looks best right now. Make a locally optimal

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 5 Greedy Algorithms Interval Scheduling Interval Partitioning Guest lecturer: Martin Furer Review In a DFS tree of an undirected graph, can there be an edge (u,v)

More information

What is Dynamic Programming

What is Dynamic Programming What is Dynamic Programming Like DaC, Greedy algorithms, Dynamic Programming is another useful method for designing efficient algorithms. Why the name? Eye of the Hurricane: An Autobiography - A quote

More information

DAA Unit- II Greedy and Dynamic Programming. By Mrs. B.A. Khivsara Asst. Professor Department of Computer Engineering SNJB s KBJ COE, Chandwad

DAA Unit- II Greedy and Dynamic Programming. By Mrs. B.A. Khivsara Asst. Professor Department of Computer Engineering SNJB s KBJ COE, Chandwad DAA Unit- II Greedy and Dynamic Programming By Mrs. B.A. Khivsara Asst. Professor Department of Computer Engineering SNJB s KBJ COE, Chandwad 1 Greedy Method 2 Greedy Method Greedy Principal: are typically

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Announcement: Homework 1 due soon! Due: January 25 th at midnight (Blackboard) Recap: Graphs Bipartite Graphs Definition

More information

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved. Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 P and NP P: The family of problems that can be solved quickly in polynomial time.

More information

CS473 - Algorithms I

CS473 - Algorithms I CS473 - Algorithms I Lecture 10 Dynamic Programming View in slide-show mode CS 473 Lecture 10 Cevdet Aykanat and Mustafa Ozdal, Bilkent University 1 Introduction An algorithm design paradigm like divide-and-conquer

More information

Chapter 8 Dynamic Programming

Chapter 8 Dynamic Programming Chapter 8 Dynamic Programming Copyright 2007 Pearson Addison-Wesley. All rights reserved. Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by

More information

Knapsack and Scheduling Problems. The Greedy Method

Knapsack and Scheduling Problems. The Greedy Method The Greedy Method: Knapsack and Scheduling Problems The Greedy Method 1 Outline and Reading Task Scheduling Fractional Knapsack Problem The Greedy Method 2 Elements of Greedy Strategy An greedy algorithm

More information

CS 6901 (Applied Algorithms) Lecture 3

CS 6901 (Applied Algorithms) Lecture 3 CS 6901 (Applied Algorithms) Lecture 3 Antonina Kolokolova September 16, 2014 1 Representative problems: brief overview In this lecture we will look at several problems which, although look somewhat similar

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 03 Dynamic Programming (Chapter 15) Stephen Scott and Vinodchandran N. Variyam sscott@cse.unl.edu 1/44 Introduction Dynamic

More information

CS 6783 (Applied Algorithms) Lecture 3

CS 6783 (Applied Algorithms) Lecture 3 CS 6783 (Applied Algorithms) Lecture 3 Antonina Kolokolova January 14, 2013 1 Representative problems: brief overview of the course In this lecture we will look at several problems which, although look

More information

Pair Hidden Markov Models

Pair Hidden Markov Models Pair Hidden Markov Models Scribe: Rishi Bedi Lecturer: Serafim Batzoglou January 29, 2015 1 Recap of HMMs alphabet: Σ = {b 1,...b M } set of states: Q = {1,..., K} transition probabilities: A = [a ij ]

More information

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 6.8 Shortest Paths Shortest Paths Shortest path problem. Given a directed graph G = (V,

More information

1 Assembly Line Scheduling in Manufacturing Sector

1 Assembly Line Scheduling in Manufacturing Sector Indian Institute of Information Technology Design and Manufacturing, Kancheepuram, Chennai 600 27, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 209T Design and Analysis

More information

Dynamic Programming. Credits: Many of these slides were originally authored by Jeff Edmonds, York University. Thanks Jeff!

Dynamic Programming. Credits: Many of these slides were originally authored by Jeff Edmonds, York University. Thanks Jeff! Dynamic Programming Credits: Many of these slides were originally authored by Jeff Edmonds, York University. Thanks Jeff! Optimization Problems For most, the best known algorithm runs in exponential time.

More information

Lecture 2: Pairwise Alignment. CG Ron Shamir

Lecture 2: Pairwise Alignment. CG Ron Shamir Lecture 2: Pairwise Alignment 1 Main source 2 Why compare sequences? Human hexosaminidase A vs Mouse hexosaminidase A 3 www.mathworks.com/.../jan04/bio_genome.html Sequence Alignment עימוד רצפים The problem:

More information

CSE 202 Homework 4 Matthias Springer, A

CSE 202 Homework 4 Matthias Springer, A CSE 202 Homework 4 Matthias Springer, A99500782 1 Problem 2 Basic Idea PERFECT ASSEMBLY N P: a permutation P of s i S is a certificate that can be checked in polynomial time by ensuring that P = S, and

More information

Chapter 8 Dynamic Programming

Chapter 8 Dynamic Programming Chapter 8 Dynamic Programming Copyright 007 Pearson Addison-Wesley. All rights reserved. Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by

More information

CS583 Lecture 11. Many slides here are based on D. Luebke slides. Review: Dynamic Programming

CS583 Lecture 11. Many slides here are based on D. Luebke slides. Review: Dynamic Programming // CS8 Lecture Jana Kosecka Dynamic Programming Greedy Algorithms Many slides here are based on D. Luebke slides Review: Dynamic Programming A meta-technique, not an algorithm (like divide & conquer) Applicable

More information

Dynamic Programming. Prof. S.J. Soni

Dynamic Programming. Prof. S.J. Soni Dynamic Programming Prof. S.J. Soni Idea is Very Simple.. Introduction void calculating the same thing twice, usually by keeping a table of known results that fills up as subinstances are solved. Dynamic

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms Computer Science & Engineering 423/823 Design and Analysis of s Lecture 09 Dynamic Programming (Chapter 15) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 41 Spring 2010 Dynamic programming

More information

This means that we can assume each list ) is

This means that we can assume each list ) is This means that we can assume each list ) is of the form ),, ( )with < and Since the sizes of the items are integers, there are at most +1pairs in each list Furthermore, if we let = be the maximum possible

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 // lgorithmic Paradigms haptr Dynamic Programming rd. Build up a solution incrmntally, myopically optimizing som local critrion. Divid-and-conqur. Brak up a problm into two sub-problms, solv ach sub-problm

More information

Algorithms Design & Analysis. Dynamic Programming

Algorithms Design & Analysis. Dynamic Programming Algorithms Design & Analysis Dynamic Programming Recap Divide-and-conquer design paradigm Today s topics Dynamic programming Design paradigm Assembly-line scheduling Matrix-chain multiplication Elements

More information

General Methods for Algorithm Design

General Methods for Algorithm Design General Methods for Algorithm Design 1. Dynamic Programming Multiplication of matrices Elements of the dynamic programming Optimal triangulation of polygons Longest common subsequence 2. Greedy Methods

More information

Partha Sarathi Mandal

Partha Sarathi Mandal MA 252: Data Structures and Algorithms Lecture 32 http://www.iitg.ernet.in/psm/indexing_ma252/y12/index.html Partha Sarathi Mandal Dept. of Mathematics, IIT Guwahati The All-Pairs Shortest Paths Problem

More information

Greedy Algorithms. Kleinberg and Tardos, Chapter 4

Greedy Algorithms. Kleinberg and Tardos, Chapter 4 Greedy Algorithms Kleinberg and Tardos, Chapter 4 1 Selecting breakpoints Road trip from Fort Collins to Durango on a given route. Fuel capacity = C. Goal: makes as few refueling stops as possible. Greedy

More information

CS Analysis of Recursive Algorithms and Brute Force

CS Analysis of Recursive Algorithms and Brute Force CS483-05 Analysis of Recursive Algorithms and Brute Force Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 4:30pm - 5:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/

More information

CS60007 Algorithm Design and Analysis 2018 Assignment 1

CS60007 Algorithm Design and Analysis 2018 Assignment 1 CS60007 Algorithm Design and Analysis 2018 Assignment 1 Palash Dey and Swagato Sanyal Indian Institute of Technology, Kharagpur Please submit the solutions of the problems 6, 11, 12 and 13 (written in

More information

2.1 Computational Tractability. Chapter 2. Basics of Algorithm Analysis. Computational Tractability. Polynomial-Time

2.1 Computational Tractability. Chapter 2. Basics of Algorithm Analysis. Computational Tractability. Polynomial-Time Chapter 2 2.1 Computational Tractability Basics of Algorithm Analysis "For me, great algorithms are the poetry of computation. Just like verse, they can be terse, allusive, dense, and even mysterious.

More information

Foundations of Natural Language Processing Lecture 6 Spelling correction, edit distance, and EM

Foundations of Natural Language Processing Lecture 6 Spelling correction, edit distance, and EM Foundations of Natural Language Processing Lecture 6 Spelling correction, edit distance, and EM Alex Lascarides (Slides from Alex Lascarides and Sharon Goldwater) 2 February 2019 Alex Lascarides FNLP Lecture

More information

Topic 17. Analysis of Algorithms

Topic 17. Analysis of Algorithms Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 26 Computational Intractability Polynomial Time Reductions Sofya Raskhodnikova S. Raskhodnikova; based on slides by A. Smith and K. Wayne L26.1 What algorithms are

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 Chapter 2 2.1 Computational Tractability Basics of Algorithm Analysis "For me, great algorithms are the poetry of computation. Just like verse, they can be terse, allusive, dense, and even mysterious.

More information

COSC 341: Lecture 25 Coping with NP-hardness (2)

COSC 341: Lecture 25 Coping with NP-hardness (2) 1 Introduction Figure 1: Famous cartoon by Garey and Johnson, 1979 We have seen the definition of a constant factor approximation algorithm. The following is something even better. 2 Approximation Schemes

More information

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018 CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Chapter 9 PSPACE: A Class of Problems Beyond NP Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights

More information

Copyright 2000, Kevin Wayne 1

Copyright 2000, Kevin Wayne 1 Divide-and-Conquer Chapter 5 Divide and Conquer Divide-and-conquer. Break up problem into several parts. Solve each part recursively. Combine solutions to sub-problems into overall solution. Most common

More information

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University Algorithms NP -Complete Problems Dong Kyue Kim Hanyang University dqkim@hanyang.ac.kr The Class P Definition 13.2 Polynomially bounded An algorithm is said to be polynomially bounded if its worst-case

More information

Reductions. Reduction. Linear Time Reduction: Examples. Linear Time Reductions

Reductions. Reduction. Linear Time Reduction: Examples. Linear Time Reductions Reduction Reductions Problem X reduces to problem Y if given a subroutine for Y, can solve X. Cost of solving X = cost of solving Y + cost of reduction. May call subroutine for Y more than once. Ex: X

More information

Final exam study sheet for CS3719 Turing machines and decidability.

Final exam study sheet for CS3719 Turing machines and decidability. Final exam study sheet for CS3719 Turing machines and decidability. A Turing machine is a finite automaton with an infinite memory (tape). Formally, a Turing machine is a 6-tuple M = (Q, Σ, Γ, δ, q 0,

More information

CSE 421 Introduction to Algorithms Final Exam Winter 2005

CSE 421 Introduction to Algorithms Final Exam Winter 2005 NAME: CSE 421 Introduction to Algorithms Final Exam Winter 2005 P. Beame 14 March 2005 DIRECTIONS: Answer the problems on the exam paper. Open book. Open notes. If you need extra space use the back of

More information

Algorithms: COMP3121/3821/9101/9801

Algorithms: COMP3121/3821/9101/9801 NEW SOUTH WALES Algorithms: COMP3121/3821/9101/9801 Aleks Ignjatović School of Computer Science and Engineering University of New South Wales TOPIC 4: THE GREEDY METHOD COMP3121/3821/9101/9801 1 / 23 The

More information

CSE 421. Dynamic Programming Shortest Paths with Negative Weights Yin Tat Lee

CSE 421. Dynamic Programming Shortest Paths with Negative Weights Yin Tat Lee CSE 421 Dynamic Programming Shortest Paths with Negative Weights Yin Tat Lee 1 Shortest Paths with Neg Edge Weights Given a weighted directed graph G = V, E and a source vertex s, where the weight of edge

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Lectures 15-16 Dynamic Programming Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments

More information

2. ALGORITHM ANALYSIS

2. ALGORITHM ANALYSIS 2. ALGORITHM ANALYSIS computational tractability asymptotic order of growth survey of common running times Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

13 Dynamic Programming (3) Optimal Binary Search Trees Subset Sums & Knapsacks

13 Dynamic Programming (3) Optimal Binary Search Trees Subset Sums & Knapsacks 13 Dynamic Programming (3) Optimal Binary Search Trees Subset Sums & Knapsacks Average-case analysis Average-case analysis of algorithms and data structures: Input is generated according to a known probability

More information

Greedy vs Dynamic Programming Approach

Greedy vs Dynamic Programming Approach Greedy vs Dynamic Programming Approach Outline Compare the methods Knapsack problem Greedy algorithms for 0/1 knapsack An approximation algorithm for 0/1 knapsack Optimal greedy algorithm for knapsack

More information

0-1 Knapsack Problem in parallel Progetto del corso di Calcolo Parallelo AA

0-1 Knapsack Problem in parallel Progetto del corso di Calcolo Parallelo AA 0-1 Knapsack Problem in parallel Progetto del corso di Calcolo Parallelo AA 2008-09 Salvatore Orlando 1 0-1 Knapsack problem N objects, j=1,..,n Each kind of item j has a value p j and a weight w j (single

More information

CS781 Lecture 3 January 27, 2011

CS781 Lecture 3 January 27, 2011 CS781 Lecture 3 January 7, 011 Greedy Algorithms Topics: Interval Scheduling and Partitioning Dijkstra s Shortest Path Algorithm Minimum Spanning Trees Single-Link k-clustering Interval Scheduling Interval

More information