Dynamic Programming. CIS 110, Fall University of Pennsylvania
|
|
- Philip Maxwell
- 6 years ago
- Views:
Transcription
1 Dynamic Programming CIS 110, Fall 2012 University of Pennsylvania
2 Dynamic Programming Dynamic programming records saves computation for reuse later. Programming: in the optimization sense ( Linear Programming ) Dynamic:... it s impossible to use [it] in a pejorative way. (Richard Bellman) he name was designed to sound cool to RND management and the US Department of Defense more descriptive term is look-up table Richard Bellman 2 CIS 110, Fall 2012
3 Dynamic Programming Dynamic programming records saves computation for reuse later. Programming: in the optimization sense ( Linear Programming ) Dynamic:... it s impossible to use [it] in a pejorative way. (Richard Bellman) he name was designed to sound cool to RND management and the US Department of Defense more descriptive term is look-up table When is dynamic programming useful? Exponential number of solutions Cost of soluion is recursively computed Different solutions recursively compute same values Richard Bellman 2 CIS 110, Fall 2012
4 Dynamic Programming Dynamic programming records saves computation for reuse later. Programming: in the optimization sense ( Linear Programming ) Dynamic:... it s impossible to use [it] in a pejorative way. (Richard Bellman) he name was designed to sound cool to RND management and the US Department of Defense more descriptive term is look-up table When is dynamic programming useful? Exponential number of solutions Cost of soluion is recursively computed Different solutions recursively compute same values he trick is exposing the common subproblems Richard Bellman 2 CIS 110, Fall 2012
5 Rod Cutting Start with a rod of integer length n and cut it into several smaller pieces (of integer length). 3 CIS 110, Fall 2012
6 Rod Cutting Start with a rod of integer length n and cut it into several smaller pieces (of integer length). Now suppose each length has a different value: = 1 = 5 = 8 = = = = = = = 25 3 CIS 110, Fall 2012
7 Rod Cutting Start with a rod of integer length n and cut it into several smaller pieces (of integer length). Now suppose each length has a different value: = 1 = 5 = 8 = = = = = = = 25 How should we cut the rod into pieces? 2 n 1 possibilities for a rod of length n 3 CIS 110, Fall 2012
8 Rod Cutting First rod-cutting strategy (brute-force): For every possible cut, compute the value of the left part plus the value of optimally cutting the right part. ake the best cut. 4 CIS 110, Fall 2012
9 Rod Cutting First rod-cutting strategy (brute-force): For every possible cut, compute the value of the left part plus the value of optimally cutting the right part. ake the best cut. } {{ } Cut recursively } {{ } Cut recursively } {{ } Cut recursively } {{ } Cut recursively }{{} Cut recursively. 4 CIS 110, Fall 2012
10 Rod Cutting First rod-cutting strategy (brute-force): For every possible cut, compute the value of the left part plus the value of optimally cutting the right part. ake the best cut. } {{ } Cut recursively } {{ } Cut recursively Exponential number of recursive calls! 4 CIS 110, Fall 2012 } {{ } Cut recursively } {{ } Cut recursively }{{} Cut recursively.
11 Rod Cutting Second rod-cutting strategy (top-down): For every cut, compute value of left part and store it in a table Find value of optimal cut for right part in table Compute it recursively if it doesn t exist yet 5 CIS 110, Fall 2012
12 Rod Cutting Second rod-cutting strategy (top-down): For every cut, compute value of left part and store it in a table Find value of optimal cut for right part in table Compute it recursively if it doesn t exist yet } {{ } Cut recursively } {{ } Look up cost in table 5 CIS 110, Fall 2012
13 Rod Cutting Second rod-cutting strategy (top-down): For every cut, compute value of left part and store it in a table Find value of optimal cut for right part in table Compute it recursively if it doesn t exist yet } {{ } Cut recursively } {{ } Look up cost in table Reduces computation from O(2 n ) to O(n 2 ) (Why?) Requires an array of length n to store intermediate computations 5 CIS 110, Fall 2012
14 Rod Cutting hrid rod-cutting strategy (bottom-up): Compute the value of a rod of length 1. Store it. Compute the value of a rod of length 2. You can only cut it into rods of length 1. he value of a rod of length 1 is already computed, so there is no recursion. Compute the value of successively longer rods up to length n. he optimal values of shorter rods are always computed first so there is no recursion. 6 CIS 110, Fall 2012
15 Sequence Matching Human genes are coded by four bases: denine (), hymine (), uanine (), Cytosine (C) DN undergoes mutations with each copy: Substitutions: replace one base with another Deletions: some bases are dropped Suppose we isolate a gene in a new organism: C C C Predict function by comparing to genes in know, organism: e.g. C How similar are C C C and C? 7 CIS 110, Fall 2012
16 Sequence Matching How similar are C C C and C? How many mutations to change first sequence into second? How (un)likely is each mutation Edit Distance: minimum cost to convert one string into another. Each change (mutation) has an associated cost: ap 2 Mismatch 1 Match 0 Example matchings: C C C C C C C - - C CIS 110, Fall 2012
17 Edit Distance Brute-force recursive solution: Start at end of sequence and work backwards C C C C 1 C C - 2 C C C C C - C 2 C C C 0 1 C C C C 2 1 C C C C C C - C 0 2 C C 2 2 Recurse until we have all possible matches, then find minimum hree recursive calls per node O(3 n ) matching cost We need to do better! 9 CIS 110, Fall 2012
18 Edit Distance Dynamic Programming recursive solution Consider a pair of characters in the middle: C C C C What is the cost of matching from this pair of s to the end? Cost of matching s (0) + lowest cost of matching C C to C. Brute force solution computes all possible costs Idea: For each pair of characters, keep track of best match up to end 10 CIS 110, Fall 2012
19 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C Initialization: Cost of zero-length match (lower right) is zero Inserting a gap (move right or down in table) costs two 11 CIS 110, Fall 2012
20 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
21 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
22 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
23 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
24 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
25 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C 4 1O Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
26 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C O Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
27 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C O Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
28 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C O Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
29 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C O Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
30 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C O Iteration: Work back from lower right Cost of cell (i, j) is C(i, j) = min(c(i + i, j) + 2, C(i, j + 1) + 2, C(i + 1, j + 1)) + δ where δ = 1 if the i th character of string and j th character of string B are identical. 11 CIS 110, Fall 2012
31 Dynamic Programming Idea: For each pair of characters, keep track of best match to end C C C C O Recovering the best alignment: Final cost is in cell (0, 0) Follow arrows to reconstruct string aligns letter in the current column with a gap aligns letter in the current row with a gap matches letters in current row and column with each other otal running time: O(mn)! 11 CIS 110, Fall 2012
32 Some More Examples Image Compositing iven a set of overlapping images, what is the best way to stitch them? Cut the images along an invisible seam, and splice them together. he optimal seam can be found through dynamic programming. Even better: shortest path Davis98 12 CIS 110, Fall 2012
33 Some More Examples Matrix parenthesization Need to multiply a sequence of rectangular matrices Which matrices should be multiplied first to minimize the number of operations ( ( )) b1 ( a 1 a 2 a 3 ) b 2 ( c 1 c 2 c 3 ) = ( a 1 b 1 +a2b 2 +a 3 b 3 ) ( c 1 c 2 c 3 ) b 3 ( a 1 a 2 a 3 ) (( ) ) ( ) b1 b1 c 1 b 1 c 2 b 1 c 3 b 2 ( c 1 c 2 c 3 ) = ( a 1 a 2 a 3 ) b 2 c 1 b 2 c 2 b 2 c 3 b 3 b 3 c 1 b 3 c 2 b 3 c 3 13 CIS 110, Fall 2012
34 Some More Examples Matrix parenthesization Need to multiply a sequence of rectangular matrices Which matrices should be multiplied first to minimize the number of operations ( ( )) b1 ( a 1 a 2 a 3 ) b 2 ( c 1 c 2 c 3 ) = ( a 1 b 1 +a2b 2 +a 3 b 3 ) ( c 1 c 2 c 3 ) b 3 ( a 1 a 2 a 3 ) (( ) ) ( ) b1 b1 c 1 b 1 c 2 b 1 c 3 b 2 ( c 1 c 2 c 3 ) = ( a 1 a 2 a 3 ) b 2 c 1 b 2 c 2 b 2 c 3 b 3 b 3 c 1 b 3 c 2 b 3 c 3 Seam carving (see demo) Shrink an image by finding one row or column of pixels to remove he seam doesn t have to be straight it can wiggle Use dynamic programming to find the best set of pixels to remove 13 CIS 110, Fall 2012
CS50 Dynamic Programming
CS50 Dynamic Programming Benedict Brown Dept. of Computer Science, Yale University Dynamic Programming Dynamic programming records saves computation for reuse later. Programming: in the optimization sense
More informationModule 27: Chained Matrix Multiplication and Bellman-Ford Shortest Path Algorithm
Module 27: Chained Matrix Multiplication and Bellman-Ford Shortest Path Algorithm This module 27 focuses on introducing dynamic programming design strategy and applying it to problems like chained matrix
More information1 More on the Bellman-Ford Algorithm
CS161 Lecture 12 Shortest Path and Dynamic Programming Algorithms Scribe by: Eric Huang (2015), Anthony Kim (2016), M. Wootters (2017) Date: May 15, 2017 1 More on the Bellman-Ford Algorithm We didn t
More informationDynamic Programming II
June 9, 214 DP: Longest common subsequence biologists often need to find out how similar are 2 DNA sequences DNA sequences are strings of bases: A, C, T and G how to define similarity? DP: Longest common
More informationWe augment RBTs to support operations on dynamic sets of intervals A closed interval is an ordered pair of real
14.3 Interval trees We augment RBTs to support operations on dynamic sets of intervals A closed interval is an ordered pair of real numbers ], with Interval ]represents the set Open and half-open intervals
More information1 Dynamic Programming
CS161 Lecture 13 Dynamic Programming and Greedy Algorithms Scribe by: Eric Huang Date: May 13, 2015 1 Dynamic Programming The idea of dynamic programming is to have a table of solutions of subproblems
More information15-451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015
15-451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015 Dynamic Programming is a powerful technique that allows one to solve many different types
More informationAlgorithmic Paradigms. Chapter 6 Dynamic Programming. Steps in Dynamic Programming. Dynamic Programming. Dynamic Programming Applications
lgorithmic Paradigms reed. Build up a solution incrementally, only optimizing some local criterion. hapter Dynamic Programming Divide-and-conquer. Break up a problem into two sub-problems, solve each sub-problem
More informationDynamic Programming Group Exercises
Name: Name: Name: Dynamic Programming Group Exercises Adapted from material by Cole Frederick Please work the following problems in groups of 2 or 3. Use additional paper as needed, and staple the sheets
More informationDynamic Programming. Lecture Overview Introduction
Lecture 12 Dynamic Programming 12.1 Overview Dynamic Programming is a powerful technique that allows one to solve many different types of problems in time O(n 2 ) or O(n 3 ) for which a naive approach
More informationDynamic Programming (Part #2)
Dynamic Programming (Part #) Introduction to Algorithms MIT Press (Chapter 5) Matrix-Chain Multiplication Problem: given a sequence A, A,, A n, compute the product: A A A n Matrix compatibility: C = A
More informationDynamic Programming Matrix-chain Multiplication
1 / 32 Dynamic Programming Matrix-chain Multiplication CS 584: Algorithm Design and Analysis Daniel Leblanc 1 1 Senior Adjunct Instructor Portland State University Maseeh College of Engineering and Computer
More informationAlgorithms: 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 5: DYNAMIC PROGRAMMING COMP3121/3821/9101/9801 1 / 38
More informationCS141: Intermediate Data Structures and Algorithms Dynamic Programming
CS141: Intermediate Data Structures and Algorithms Dynamic Programming Amr Magdy Programming? In this context, programming is a tabular method Other examples: Linear programing Integer programming 2 Rod
More informationLecture 8. Dynamic Programming
Lecture 8. Dynamic Programming 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 information1 i n (p i + r n i ) (Note that by allowing i to be n, we handle the case where the rod is not cut at all.)
Dynamic programming is a problem solving method that is applicable to many different types of problems. I think it is best learned by example, so we will mostly do examples today. 1 Rod cutting Suppose
More informationDynamic Programming 1
Dynamic Programming 1 Jie Wang University of Massachusetts Lowell Department of Computer Science 1 I thank Prof. Zachary Kissel of Merrimack College for sharing his lecture notes with me; some of the examples
More information15.Dynamic Programming
15.Dynamic Programming Dynamic Programming is an algorithm design technique for optimization problems: often minimizing or maximizing. Like divide and conquer, DP solves problems by combining solutions
More informationUnit-5 Dynamic Programming 2016
5 Dynamic programming Overview, Applications - shortest path in graph, matrix multiplication, travelling salesman problem, Fibonacci Series. 20% 12 Origin: Richard Bellman, 1957 Programming referred to
More information10/24/ Rotations. 2. // s left subtree s right subtree 3. if // link s parent to elseif == else 11. // put x on s left
13.2 Rotations MAT-72006 AA+DS, Fall 2013 24-Oct-13 368 LEFT-ROTATE(, ) 1. // set 2. // s left subtree s right subtree 3. if 4. 5. // link s parent to 6. if == 7. 8. elseif == 9. 10. else 11. // put x
More informationCSC 373 Lecture # 3 Instructor: Milad Eftekhar
Huffman encoding: Assume a context is available (a document, a signal, etc.). These contexts are formed by some symbols (words in a document, discrete samples from a signal, etc). Each symbols s i is occurred
More informationIntroduction to Algorithms
Introduction to Algorithms Dynamic Programming Well known algorithm design techniques: Brute-Force (iterative) ti algorithms Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic
More informationCS 231: Algorithmic Problem Solving
CS 231: Algorithmic Problem Solving Naomi Nishimura Module 5 Date of this version: June 14, 2018 WARNING: Drafts of slides are made available prior to lecture for your convenience. After lecture, slides
More informationGreedy Algorithms. Informal Definition A greedy algorithm makes its next step based only on the current state and simple calculations on the input.
Greedy Algorithms Informal Definition A greedy algorithm makes its next step based only on the current state and simple calculations on the input. easy to design not always correct challenge is to identify
More informationChapter 3 Dynamic programming
Chapter 3 Dynamic programming 1 Dynamic programming also solve a problem by combining the solutions to subproblems. But dynamic programming considers the situation that some subproblems will be called
More informationVideo 9.1 Jianbo Shi. Property of Penn Engineering, Jianbo Shi
Video 9.1 Jianbo Shi 1 Exmples of resizing 2 820 546 3 3 420 546 3 (a) (b) (c) Guess We use crop, scaling and carving for resizing the given image Guess which one is for carving? 4 5 6 Guess which one
More informationAlgorithms IV. Dynamic Programming. Guoqiang Li. School of Software, Shanghai Jiao Tong University
Algorithms IV Dynamic Programming Guoqiang Li School of Software, Shanghai Jiao Tong University Dynamic Programming Shortest Paths in Dags, Revisited Shortest Paths in Dags, Revisited The special distinguishing
More informationPresentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Dynamic Programming
Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 25 Dynamic Programming Terrible Fibonacci Computation Fibonacci sequence: f = f(n) 2
More informationDynamic Programming II
Lecture 11 Dynamic Programming II 11.1 Overview In this lecture we continue our discussion of dynamic programming, focusing on using it for a variety of path-finding problems in graphs. Topics in this
More informationChapter 6. Dynamic Programming
Chapter 6 Dynamic Programming CS 573: Algorithms, Fall 203 September 2, 203 6. Maximum Weighted Independent Set in Trees 6..0. Maximum Weight Independent Set Problem Input Graph G = (V, E) and weights
More information1 Non greedy algorithms (which we should have covered
1 Non greedy algorithms (which we should have covered earlier) 1.1 Floyd Warshall algorithm This algorithm solves the all-pairs shortest paths problem, which is a problem where we want to find the shortest
More informationDynamic Programming. Design and Analysis of Algorithms. Entwurf und Analyse von Algorithmen. Irene Parada. Design and Analysis of Algorithms
Entwurf und Analyse von Algorithmen Dynamic Programming Overview Introduction Example 1 When and how to apply this method Example 2 Final remarks Introduction: when recursion is inefficient Example: Calculation
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 16 Dynamic Programming (plus FFT Recap) Adam Smith 9/24/2008 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Discrete Fourier Transform
More informationLecture 10. Sequence alignments
Lecture 10 Sequence alignments Alignment algorithms: Overview Given a scoring system, we need to have an algorithm for finding an optimal alignment for a pair of sequences. We want to maximize the score
More informationComputer Sciences Department 1
1 Advanced Design and Analysis Techniques (15.1, 15.2, 15.3, 15.4 and 15.5) 3 Objectives Problem Formulation Examples The Basic Problem Principle of optimality Important techniques: dynamic programming
More informationIndexing and Searching
Indexing and Searching Introduction How to retrieval information? A simple alternative is to search the whole text sequentially Another option is to build data structures over the text (called indices)
More informationDynamic Programming. An Enumeration Approach. Matrix Chain-Products. Matrix Chain-Products (not in book)
Matrix Chain-Products (not in book) is a general algorithm design paradigm. Rather than give the general structure, let us first give a motivating example: Matrix Chain-Products Review: Matrix Multiplication.
More informationData Structures and Algorithms Week 8
Data Structures and Algorithms Week 8 Dynamic programming Fibonacci numbers Optimization problems Matrix multiplication optimization Principles of dynamic programming Longest Common Subsequence Algorithm
More informationElements of Dynamic Programming. COSC 3101A - Design and Analysis of Algorithms 8. Discovering Optimal Substructure. Optimal Substructure - Examples
Elements of Dynamic Programming COSC 3A - Design and Analysis of Algorithms 8 Elements of DP Memoization Longest Common Subsequence Greedy Algorithms Many of these slides are taken from Monica Nicolescu,
More informationFalse Color to NDVI Conversion Precision NDVI Single Sensor
False Color to NDVI Conversion Precision NDVI Single Sensor Contents 1 Sensor Properties... 2 2 Isolating Bands... 2 3 Calculating NDVI from Original Image Pixel DN... 3 4 Calculating NDVI from AgVault
More informationAlgorithms. Algorithms ALGORITHM DESIGN
Algorithms ROBERT SEDGEWICK KEVIN WAYNE ALGORITHM DESIGN Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu analysis of algorithms greedy divide-and-conquer
More informationAlgorithms. Ch.15 Dynamic Programming
Algorithms Ch.15 Dynamic Programming Dynamic Programming Not a specific algorithm, but a technique (like divide-and-conquer). Developed back in the day when programming meant tabular method (like linear
More informationIntroduction to Algorithms
Introduction to Algorithms 6.046J/18.401J LECTURE 12 Dynamic programming Longest common subsequence Optimal substructure Overlapping subproblems Prof. Charles E. Leiserson Dynamic programming Design technique,
More informationLecture 4: Dynamic programming I
Lecture : Dynamic programming I Dynamic programming is a powerful, tabular method that solves problems by combining solutions to subproblems. It was introduced by Bellman in the 950 s (when programming
More information15.4 Longest common subsequence
15.4 Longest common subsequence Biological applications often need to compare the DNA of two (or more) different organisms A strand of DNA consists of a string of molecules called bases, where the possible
More informationChapter 3: Search. c D. Poole, A. Mackworth 2010, W. Menzel 2015 Artificial Intelligence, Chapter 3, Page 1
Chapter 3: Search c D. Poole, A. Mackworth 2010, W. Menzel 2015 Artificial Intelligence, Chapter 3, Page 1 Searching Often we are not given an algorithm to solve a problem, but only a specification of
More informationLast week: Breadth-First Search
1 Last week: Breadth-First Search Set L i = [] for i=1,,n L 0 = {w}, where w is the start node For i = 0,, n-1: For u in L i : For each v which is a neighbor of u: If v isn t yet visited: - mark v as visited,
More informationLectures 12 and 13 Dynamic programming: weighted interval scheduling
Lectures 12 and 13 Dynamic programming: weighted interval scheduling COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski Lectures 12-13: Dynamic Programming 1 Overview Last week: Graph
More informationDynamic Programming: 1D Optimization. Dynamic Programming: 2D Optimization. Fibonacci Sequence. Crazy 8 s. Edit Distance
Dynamic Programming: 1D Optimization Fibonacci Sequence To efficiently calculate F [x], the xth element of the Fibonacci sequence, we can construct the array F from left to right (or bottom up ). We start
More informationDynamic Programming & Smith-Waterman algorithm
m m Seminar: Classical Papers in Bioinformatics May 3rd, 2010 m m 1 2 3 m m Introduction m Definition is a method of solving problems by breaking them down into simpler steps problem need to contain overlapping
More information/463 Algorithms - Fall 2013 Solution to Assignment 3
600.363/463 Algorithms - Fall 2013 Solution to Assignment 3 (120 points) I (30 points) (Hint: This problem is similar to parenthesization in matrix-chain multiplication, except the special treatment on
More informationCMSC351 - Fall 2014, Homework #4
CMSC351 - Fall 2014, Homework #4 Due: November 14th at the start of class PRINT Name: Grades depend on neatness and clarity. Write your answers with enough detail about your approach and concepts used,
More informationComputational Molecular Biology
Computational Molecular Biology Erwin M. Bakker Lecture 2 Materials used from R. Shamir [2] and H.J. Hoogeboom [4]. 1 Molecular Biology Sequences DNA A, T, C, G RNA A, U, C, G Protein A, R, D, N, C E,
More informationCS473-Algorithms I. Lecture 10. Dynamic Programming. Cevdet Aykanat - Bilkent University Computer Engineering Department
CS473-Algorithms I Lecture 1 Dynamic Programming 1 Introduction An algorithm design paradigm like divide-and-conquer Programming : A tabular method (not writing computer code) Divide-and-Conquer (DAC):
More informationDynamic programming 4/9/18
Dynamic programming 4/9/18 Administrivia HW 3 due Wednesday night Exam out Thursday, due next week Multi-day takehome, open book, closed web, written problems Induction, AVL trees, recurrences, D&C, multithreaded
More informationDynamic Programming Intro
Dynamic Programming Intro Imran Rashid University of Washington February 15, 2008 Dynamic Programming Outline: General Principles Easy Examples Fibonacci, Licking Stamps Meatier examples RNA Structure
More informationUnit 1, Lesson 1: Moving in the Plane
Unit 1, Lesson 1: Moving in the Plane Let s describe ways figures can move in the plane. 1.1: Which One Doesn t Belong: Diagrams Which one doesn t belong? 1.2: Triangle Square Dance m.openup.org/1/8-1-1-2
More informationCSE 421: Introduction to Algorithms
CSE 421: Introduction to Algorithms Dynamic Programming Paul Beame 1 Dynamic Programming Dynamic Programming Give a solution of a problem using smaller sub-problems where the parameters of all the possible
More informationCS 380 ALGORITHM DESIGN AND ANALYSIS
CS 380 ALGORITHM DESIGN AND ANALYSIS Lecture 14: Dynamic Programming Text Reference: Chapter 15 Dynamic Programming We know that we can use the divide-and-conquer technique to obtain efficient algorithms
More informationDynamic Programming. December 15, CMPE 250 Dynamic Programming December 15, / 60
Dynamic Programming December 15, 2016 CMPE 250 Dynamic Programming December 15, 2016 1 / 60 Why Dynamic Programming Often recursive algorithms solve fairly difficult problems efficiently BUT in other cases
More informationCS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya
CS60020: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Dynamic programming Design technique, like divide-and-conquer. Example: Longest Common Subsequence (LCS) Given two
More informationIN101: Algorithmic techniques Vladimir-Alexandru Paun ENSTA ParisTech
IN101: Algorithmic techniques Vladimir-Alexandru Paun ENSTA ParisTech License CC BY-NC-SA 2.0 http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Outline Previously on IN101 Python s anatomy Functions,
More informationChain Matrix Multiplication
Chain Matrix Multiplication Version of November 5, 2014 Version of November 5, 2014 Chain Matrix Multiplication 1 / 27 Outline Outline Review of matrix multiplication. The chain matrix multiplication problem.
More informationEECS 4425: Introductory Computational Bioinformatics Fall Suprakash Datta
EECS 4425: Introductory Computational Bioinformatics Fall 2018 Suprakash Datta datta [at] cse.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cse.yorku.ca/course/4425 Many
More informationCSE 417 Dynamic Programming (pt 4) Sub-problems on Trees
CSE 417 Dynamic Programming (pt 4) Sub-problems on Trees Reminders > HW4 is due today > HW5 will be posted shortly Dynamic Programming Review > Apply the steps... 1. Describe solution in terms of solution
More informationOptimization II: Dynamic Programming
Chapter 12 Optimization II: Dynamic Programming In the last chapter, we saw that greedy algorithms are efficient solutions to certain optimization problems. However, there are optimization problems for
More informationDynamic Programming. Ellen Feldman and Avishek Dutta. February 27, CS155 Machine Learning and Data Mining
CS155 Machine Learning and Data Mining February 27, 2018 Motivation Much of machine learning is heavily dependent on computational power Many libraries exist that aim to reduce computational time TensorFlow
More informationIntroduction to Optimization
Introduction to Optimization Dynamic Programming November, 0 École Centrale Paris, Châtenay-Malabry, France Dimo Brockhoff INRIA Lille Nord Europe Course Overview Dimo Brockhoff, INRIA Introduction to
More informationDynamic Programming part 2
Dynamic Programming part 2 Week 7 Objectives More dynamic programming examples - Matrix Multiplication Parenthesis - Longest Common Subsequence Subproblem Optimal structure Defining the dynamic recurrence
More informationCSC 8301 Design & Analysis of Algorithms: Warshall s, Floyd s, and Prim s algorithms
CSC 8301 Design & Analysis of Algorithms: Warshall s, Floyd s, and Prim s algorithms Professor Henry Carter Fall 2016 Recap Space-time tradeoffs allow for faster algorithms at the cost of space complexity
More informationCSE 101, Winter Design and Analysis of Algorithms. Lecture 11: Dynamic Programming, Part 2
CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 11: Dynamic Programming, Part 2 Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Goal: continue with DP (Knapsack, All-Pairs SPs, )
More informationDynamic Programming Shabsi Walfish NYU - Fundamental Algorithms Summer 2006
Dynamic Programming What is Dynamic Programming? Technique for avoiding redundant work in recursive algorithms Works best with optimization problems that have a nice underlying structure Can often be used
More informationSequence Alignment. part 2
Sequence Alignment part 2 Dynamic programming with more realistic scoring scheme Using the same initial sequences, we ll look at a dynamic programming example with a scoring scheme that selects for matches
More informationAlgorithm Design Techniques part I
Algorithm Design Techniques part I Divide-and-Conquer. Dynamic Programming DSA - lecture 8 - T.U.Cluj-Napoca - M. Joldos 1 Some Algorithm Design Techniques Top-Down Algorithms: Divide-and-Conquer Bottom-Up
More informationComputational Genomics and Molecular Biology, Fall
Computational Genomics and Molecular Biology, Fall 2015 1 Sequence Alignment Dannie Durand Pairwise Sequence Alignment The goal of pairwise sequence alignment is to establish a correspondence between the
More information1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors
1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors on an EREW PRAM: See solution for the next problem. Omit the step where each processor sequentially computes the AND of
More informationThe Knapsack Problem an Introduction to Dynamic Programming. Slides based on Kevin Wayne / Pearson-Addison Wesley
The Knapsack Problem an Introduction to Dynamic Programming Slides based on Kevin Wayne / Pearson-Addison Wesley Different Problem Solving Approaches Greedy Algorithms Build up solutions in small steps
More informationDynamic Programming. Outline and Reading. Computing Fibonacci
Dynamic Programming Dynamic Programming version 1.2 1 Outline and Reading Matrix Chain-Product ( 5.3.1) The General Technique ( 5.3.2) -1 Knapsac Problem ( 5.3.3) Dynamic Programming version 1.2 2 Computing
More informationOutline. Sequence Alignment. Types of Sequence Alignment. Genomics & Computational Biology. Section 2. How Computers Store Information
enomics & omputational Biology Section Lan Zhang Sep. th, Outline How omputers Store Information Sequence lignment Dot Matrix nalysis Dynamic programming lobal: NeedlemanWunsch lgorithm Local: SmithWaterman
More informationRecursive-Fib(n) if n=1 or n=2 then return 1 else return Recursive-Fib(n-1)+Recursive-Fib(n-2)
Dynamic Programming Any recursive formula can be directly translated into recursive algorithms. However, sometimes the compiler will not implement the recursive algorithm very efficiently. When this is
More informationMemoization/Dynamic Programming. The String reconstruction problem. CS124 Lecture 11 Spring 2018
CS124 Lecture 11 Spring 2018 Memoization/Dynamic Programming Today s lecture discusses memoization, which is a method for speeding up algorithms based on recursion, by using additional memory to remember
More informationCSE 3101 Design and Analysis of Algorithms Practice Test for Unit 1 Loop Invariants and Iterative Algorithms
CSE 0 Design and Analysis of Algorithms Practice Test for Unit Loop Invariants and Iterative Algorithms Jeff Edmonds First learn the steps. Then try them on your own. If you get stuck only look at a little
More informationPartha Sarathi Manal
MA 515: Introduction to Algorithms & MA353 : Design and Analysis of Algorithms [3-0-0-6] Lecture 29 http://www.iitg.ernet.in/psm/indexing_ma353/y09/index.html Partha Sarathi Manal psm@iitg.ernet.in Dept.
More information15.4 Longest common subsequence
15.4 Longest common subsequence Biological applications often need to compare the DNA of two (or more) different organisms A strand of DNA consists of a string of molecules called bases, where the possible
More informationS Postgraduate Course on Signal Processing in Communications, FALL Topic: Iteration Bound. Harri Mäntylä
S-38.220 Postgraduate Course on Signal Processing in Communications, FALL - 99 Topic: Iteration Bound Harri Mäntylä harri.mantyla@hut.fi ate: 11.10.1999 1. INTROUCTION...3 2. ATA-FLOW GRAPH (FG) REPRESENTATIONS...4
More information.. Fall 2011 CSC 570: Bioinformatics Alexander Dekhtyar..
.. Fall 2011 CSC 570: Bioinformatics Alexander Dekhtyar.. PAM and BLOSUM Matrices Prepared by: Jason Banich and Chris Hoover Background As DNA sequences change and evolve, certain amino acids are more
More informationComputational Biology Lecture 4: Overlap detection, Local Alignment, Space Efficient Needleman-Wunsch Saad Mneimneh
Computational Biology Lecture 4: Overlap detection, Local Alignment, Space Efficient Needleman-Wunsch Saad Mneimneh Overlap detection: Semi-Global Alignment An overlap of two sequences is considered an
More informationtechnique: seam carving Image and Video Processing Chapter 9
Chapter 9 Seam Carving for Images and Videos Distributed Algorithms for 2 Introduction Goals Enhance the visual content of images Adapted images should look natural Most relevant content should be clearly
More informationLecture 57 Dynamic Programming. (Refer Slide Time: 00:31)
Programming, Data Structures and Algorithms Prof. N.S. Narayanaswamy Department of Computer Science and Engineering Indian Institution Technology, Madras Lecture 57 Dynamic Programming (Refer Slide Time:
More information6.001 Notes: Section 4.1
6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,
More informationAdvanced Algorithms Class Notes for Monday, November 10, 2014
Advanced Algorithms Class Notes for Monday, November 10, 2014 Bernard Moret Divide-and-Conquer: Matrix Multiplication Divide-and-conquer is especially useful in computational geometry, but also in numerical
More informationMore Dynamic Programming
CS 374: Algorithms & Models of Computation, Fall 2015 More Dynamic Programming Lecture 12 October 8, 2015 Chandra & Manoj (UIUC) CS374 1 Fall 2015 1 / 43 What is the running time of the following? Consider
More informationRichard Feynman, Lectures on Computation
Chapter 8 Sorting and Sequencing If you keep proving stuff that others have done, getting confidence, increasing the complexities of your solutions for the fun of it then one day you ll turn around and
More informationToday: Matrix Subarray (Divide & Conquer) Intro to Dynamic Programming (Rod cutting) COSC 581, Algorithms January 21, 2014
Today: Matrix Subarray (Divide & Conquer) Intro to Dynamic Programming (Rod cutting) COSC 581, Algorithms January 21, 2014 Reading Assignments Today s class: Chapter 4.1, 15.1 Reading assignment for next
More information1 Dynamic Programming
Recitation 13 Dynamic Programming Parallel and Sequential Data Structures and Algorithms, 15-210 (Fall 2013) November 20, 2013 1 Dynamic Programming Dynamic programming is a technique to avoid needless
More informationThe Further Mathematics Support Programme
Degree Topics in Mathematics Groups A group is a mathematical structure that satisfies certain rules, which are known as axioms. Before we look at the axioms, we will consider some terminology. Elements
More informationDynamic Programming. Nothing to do with dynamic and nothing to do with programming.
Dynamic Programming Deliverables Dynamic Programming basics Binomial Coefficients Weighted Interval Scheduling Matrix Multiplication /1 Knapsack Longest Common Subsequence 6/12/212 6:56 PM copyright @
More informationMatrix Multiplication Studio April 20, 2007
Matrix Multiplication Studio April 20, 2007 A matrix is a rectangular array of numbers. The shape of a matrix is the number of rows by the number of columns. For example 1 2 is a 2 2 matrix 3 4 3 4 0 is
More information1. Stereo Correspondence. (100 points)
1. Stereo Correspondence. (100 points) For this problem set you will solve the stereo correspondence problem using dynamic programming. The goal of this algorithm is to find the lowest cost matching between
More informationShortest Path Problem
Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths
More information