Lecture 5 Dynamic Programming

Slides:



Advertisements
Similar presentations
Dynamic Programming ACM Workshop 24 August Dynamic Programming Dynamic Programming is a programming technique that dramatically reduces the runtime.
Advertisements

Dynamic Programming.
Algorithm Design Methodologies Divide & Conquer Dynamic Programming Backtracking.
Dynamic Programming An algorithm design paradigm like divide-and-conquer “Programming”: A tabular method (not writing computer code) Divide-and-Conquer.
Dynamic Programming.
S. J. Shyu Chap. 1 Introduction 1 The Design and Analysis of Algorithms Chapter 1 Introduction S. J. Shyu.
1 Divide & Conquer Algorithms. 2 Recursion Review A function that calls itself either directly or indirectly through another function Recursive solutions.
CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
1 Dynamic Programming Jose Rolim University of Geneva.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 1 (Part 3) Design Patterns for Optimization Problems.
Dynamic Programming Carrie Williams. What is Dynamic Programming? Method of breaking the problem into smaller, simpler sub-problems Method of breaking.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2009 Design Patterns for Optimization Problems Dynamic Programming.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2002 Lecture 1 (Part 3) Tuesday, 9/3/02 Design Patterns for Optimization.
UNC Chapel Hill Lin/Manocha/Foskey Optimization Problems In which a set of choices must be made in order to arrive at an optimal (min/max) solution, subject.
Lecture 34 CSE 331 Nov 30, Graded HW 8 On Wednesday.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Lecture 5 Dynamic Programming. Dynamic Programming Self-reducibility.
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
Fundamentals of Algorithms MCS - 2 Lecture # 7
Dynamic Programming.
1 Summary: Design Methods for Algorithms Andreas Klappenecker.
COSC 3101A - Design and Analysis of Algorithms 7 Dynamic Programming Assembly-Line Scheduling Matrix-Chain Multiplication Elements of DP Many of these.
Algorithm Paradigms High Level Approach To solving a Class of Problems.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 28, 2014.
CS 8833 Algorithms Algorithms Dynamic Programming.
Lecture 7 All-Pairs Shortest Paths. All-Pairs Shortest Paths.
Algorithms: Design and Analysis Summer School 2013 at VIASM: Random Structures and Algorithms Lecture 4: Dynamic Programming Phan Th ị Hà D ươ ng 1.
Optimization Problems In which a set of choices must be made in order to arrive at an optimal (min/max) solution, subject to some constraints. (There may.
Computer Sciences Department1.  Property 1: each node can have up to two successor nodes (children)  The predecessor node of a node is called its.
1 Today’s Material Dynamic Programming – Chapter 15 –Introduction to Dynamic Programming –0-1 Knapsack Problem –Longest Common Subsequence –Chain Matrix.
2016/3/13Page 1 Semester Review COMP3040 Dept. Computer Science and Technology United International College.
TU/e Algorithms (2IL15) – Lecture 3 1 DYNAMIC PROGRAMMING
Chapter 5 Guillotine Cut (1) Rectangular Partition Ding-Zhu Du.
Lecture 2 Sorting.
Dynamic Programming Typically applied to optimization problems
Advanced Algorithms Analysis and Design
Topics Covered after Mid-Term
Unit 1. Sorting and Divide and Conquer
Summary of lectures Introduction to Algorithm Analysis and Design (Chapter 1-3). Lecture Slides Recurrence and Master Theorem (Chapter 4). Lecture Slides.
Lecture 4 Divide-and-Conquer
Seminar on Dynamic Programming.
Advanced Design and Analysis Techniques
Lecture 22 Complexity and Reductions
Types of Algorithms.
Lecture 5 Dynamic Programming
Dynamic Programming.
Lecture 7 All-Pairs Shortest Paths
Types of Algorithms.
Dynamic Programming General Idea
Lecture 6 Shortest Path Problem.
Dynamic Programming.
Analysis of Algorithms CS 477/677
Chapter 15: Dynamic Programming II
Ch. 15: Dynamic Programming Ming-Te Chi
Dynamic Programming General Idea
Dynamic Programming.
DYNAMIC PROGRAMMING.
Types of Algorithms.
Divide & Conquer Algorithms
Dynamic Programming 動態規劃
Lecture 6 Shortest Path Problem.
Total running time is O(E lg E).
Topic 14 Algorithm Families.
CSCI 235, Spring 2019, Lecture 25 Dynamic Programming
INTRODUCTION TO ALOGORITHM DESIGN STRATEGIES
COMPSCI 330 Design and Analysis of Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 27 Dynamic Programming II
Seminar on Dynamic Programming.
Data Structures and Algorithms Dynamic Programming
Presentation transcript:

Lecture 5 Dynamic Programming

Quiz Sample True or false? Every algorithm that contains a divide step and a conquer step is a divide-and-conquer algorithm. Answer: No A dynamic programming contains a divide step and a conquer step and may not be a divide-and-conquer algorithm.

Dynamic Programming Self-reducibility

Divide and Conquer Divide the problem into subproblems. Conquer the subproblems by solving them recursively. Combine the solutions to subproblems into the solution for original problem.

Dynamic Programming Divide the problem into subproblems. Conquer the subproblems by solving them recursively. Combine the solutions to subproblems into the solution for original problem.

Remark on Divide and Conquer Key Point: Divide-and-Conquer is a DP-type technique.

Algorithms with Self-Reducibility Dynamic Programming Divide and Conquer Greedy Local Ratio

Matrix-chain Multiplication

Fully Parenthesize

Scalar Multiplications

e.g., # of scalar multiplications

Step 1. Find recursive structure of optimal solution

Step 2. Build recursive formula about optimal value

Step 3. Computing optimal value

Step 3. Computing optimal value

Step 4. Constructing an optimal solution

151 15,125 11,875 10,500 9,375 7,125 5,375 7,875 4,375 2,500 3,500 15,700 2,625 750 1,000 5,000

Optimal solution 151 15,125 (3) 11,875 10,500 (3) (3) 9,375 7,125 5,375 (3) (3) (3) 7,875 4,375 2,500 3,500 (1) (3) (3) (5) 15,700 2,625 750 1,000 5,000 (1) (2) (3) (4) (5) Optimal solution

Running Time

Running Time How many recursive calls? How many m[I,j] will be computed?

# of Subproblems

Running Time

Remark on Running Time (1) Time for computing recursive formula. (2)The number of subproblems. (3) Multiplication of (1) and (2)

Longest Common Subsequence

Problem 10110110 00100100

Recursive Formula

Related Problem 10110110 00100100

Recursive Formula

More Examples

A Rectangle with holes NP-Hard!!!

Guillotine cut

Guillotine Partition A sequence of guillotine cuts Canonical one: every cut passes a hole.

Minimum length Guillotine Partition Given a rectangle with holes, partition it into smaller rectangles without hole to minimize the total length of guillotine cuts.

Minimum Guillotine Partition Dynamic programming In time O(n ): 5 Each cut has at most 2n choices. 4 There are O(n ) subproblems. Minimum guillotine partition can be a polynomial-time approximation.

What we learnt in this lecture? How to design dynamic programming. Two ways to implement. How to analyze running time.

Quiz Sample True or False Analysis method for dynamic programming can also be applied to divide-and-conquer algorithms. Answer: True

Quiz Sample True or False Every dynamic programming can be analyzed with formula: Run-time = (table size) x (computation time of recursive formula). Answer: False A counterexample can be seen in study of the shortest path problem.

Puzzle