Dynamic Programming 4-10-2002. Opening Discussion zDo you have any questions about the quiz? zWhat did we talk about last class? zDo you have any questions.

Slides:



Advertisements
Similar presentations
Dynamic Programming 25-Mar-17.
Advertisements

Dynamic Programming Introduction Prof. Muhammad Saeed.
Dynamic Programming An algorithm design paradigm like divide-and-conquer “Programming”: A tabular method (not writing computer code) Divide-and-Conquer.
Types of Algorithms.
Analysis of Algorithms
Dynamic Programming.
Introduction to Algorithms
For Monday Read 10.3 Homework: –Chapter 10, exercise 10.
15-May-15 Dynamic Programming. 2 Algorithm types Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
16-May-15 Dynamic Programming. 2 Algorithm types Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
1 Dynamic Programming Jose Rolim University of Geneva.
CPSC 311, Fall 2009: Dynamic Programming 1 CPSC 311 Analysis of Algorithms Dynamic Programming Prof. Jennifer Welch Fall 2009.
CS 206 Introduction to Computer Science II 10 / 14 / 2009 Instructor: Michael Eckmann.
CSE 780 Algorithms Advanced Algorithms Greedy algorithm Job-select problem Greedy vs DP.
CPSC 411 Design and Analysis of Algorithms Set 5: Dynamic Programming Prof. Jennifer Welch Spring 2011 CPSC 411, Spring 2011: Set 5 1.
CS 206 Introduction to Computer Science II 10 / 16 / 2009 Instructor: Michael Eckmann.
Fundamental Techniques
Analysis of Algorithms
CS 206 Introduction to Computer Science II 10 / 08 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 02 / 25 / 2009 Instructor: Michael Eckmann.
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Dynamic Programming CSC 172 SPRING 2002 LECTURE 6.
David Luebke 1 8/23/2015 CS 332: Algorithms Greedy Algorithms.
Compsci 201 Recitation 12 Professor Peck Jimmy Wei 11/15/2013.
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
Recursion and Dynamic Programming. Recursive thinking… Recursion is a method where the solution to a problem depends on solutions to smaller instances.
Recursion Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? zWhat is a recursive function?
Algorithm Fundamentals Shane Carr CSE 232, Fall 2015.
String Processing Opening Discussion zDo you have any questions about the quiz? zWhat did we talk about last class? zDo you have questions.
1 Summary: Design Methods for Algorithms Andreas Klappenecker.
David Luebke 1 10/24/2015 CS 332: Algorithms Greedy Algorithms Continued.
CSC 413/513: Intro to Algorithms Greedy Algorithms.
Recursion. What is recursion? Rules of recursion Mathematical induction The Fibonacci sequence Summary Outline.
CS 8833 Algorithms Algorithms Dynamic Programming.
Dynamic Programming. Algorithm Design Techniques We will cover in this class: ◦ Greedy Algorithms ◦ Divide and Conquer Algorithms ◦ Dynamic Programming.
Recursion Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? Don’t let problems hang.
1 Programming for Engineers in Python Autumn Lecture 12: Dynamic Programming.
CS 206 Introduction to Computer Science II 02 / 23 / 2009 Instructor: Michael Eckmann.
Dynamic Programming continued David Kauchak cs302 Spring 2012.
Dynamic Programming David Kauchak cs302 Spring 2013.
Topic 25 Dynamic Programming "Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it.
Threads Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment?
Backtracking Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignments?
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Dynamic Programming. Many problem can be solved by D&C – (in fact, D&C is a very powerful approach if you generalize it since MOST problems can be solved.
Conditionals Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? zPass by value limitations.
1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.
Computer Sciences Department1.  Property 1: each node can have up to two successor nodes (children)  The predecessor node of a node is called its.
Dynamic Programming.  Decomposes a problem into a series of sub- problems  Builds up correct solutions to larger and larger sub- problems  Examples.
CSC5101 Advanced Algorithms Analysis
Dynamic Programming David Kauchak cs161 Summer 2009.
Lecture 151 Programming & Data Structures Dynamic Programming GRIFFITH COLLEGE DUBLIN.
COSC 3101NJ. Elder Announcements Midterm Exam: Fri Feb 27 CSE C –Two Blocks: 16:00-17:30 17:30-19:00 –The exam will be 1.5 hours in length. –You can attend.
Red-Black Trees Opening Discussion zDo you have any questions about the quiz? zWhat did we talk about last class? zDo you have any questions.
Dynamic Programming academy.zariba.com 1. Lecture Content 1.Fibonacci Numbers Revisited 2.Dynamic Programming 3.Examples 4.Homework 2.
Mergesort and Quicksort Opening Discussion zWhat did we talk about last class? zDo you have any questions about assignment #4? Have you thought.
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
Maximum Flow and Dynamic Programming Opening Discussion zWho can describe a flow network to me. What are the properties it has and what types.
A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding.
Lecture 12.
Dynamic Programming Sequence of decisions. Problem state.
Lecture 5 Dynamic Programming
Advanced Design and Analysis Techniques
Topic 25 Dynamic Programming
CSCE 411 Design and Analysis of Algorithms
Dynamic Programming.
Dynamic Programming.
Dynamic Programming 23-Feb-19.
DYNAMIC PROGRAMMING.
Lecture 4 Dynamic Programming
Presentation transcript:

Dynamic Programming

Opening Discussion zDo you have any questions about the quiz? zWhat did we talk about last class? zDo you have any questions about the assignments? What elements of the assignments are causing you problems at this point?

Minute Essay Comments zMultithreading yModern operating systems have the ability to act like they are running many things at once. When they share the same memory and are part of the same program they are called threads. Do man pthread for more in C/C++. zGraphics libraries yOpenGL for 3D-graphics. Mesa is free. zExciting projects/teaching Java

Repeating Work with Recursion zWhen we first discussed recursion we talked about how it wasn’t ideal for all problems. The Fibonacci numbers were a key example of this. zThe problem is that it doesn’t remember what work it has done and can often repeat large amounts of work computing the same value over and over again.

Dynamic Programming zDynamic programming is a way of constructing solutions to these problems that doesn’t repeat the work. It can be quite efficient. It is also best when we get rid of the recursion completely. zLike D&C we are interested in problems that can be broken into pieces. In this case though we want common subproblems that we only solve once.

Steps in DP (Form CLR) zCharacterize the structure of an optimal solution. zRecursively define the structure of an optimal solution. zComputer the value of an optimal solution in a bottom-up fashion. zConstruct an optimal solution from computed information (optional).

Principle of Optimality zFor dynamic programming to work the problem has to follow the principle of optimality. This implies that “no matter what the first decision, the remaining decisions must be optimal with respect to the state that results from the first decision”. zThis is much nicer than greedy algorithms where proving they are actually optimal can be quite painful.

Memoization zThe real key to DP is that we want to keep track of what we have already solved. This is the real difference between it and D&C. With D&C we always recurse to get solutions. With DP we look for earlier solutions if they are available.

Change Maker Problem zYour book presents a change maker problem as a good DP problem. The objective is to make change with as few coins as possible. In some cases this can be done with greedy algorithms but they give a nice example where it can’t. zThe recursive solution they present is to test all possibilities where we break it into 2 pieces using a divide and conquer type method. zYou could also loop through all denominations and recurse assuming each one was used at that point.

Change Maker Continued zThat method is very inefficient however, because it recalculates many values. Instead, we can work up from 1 cent storing off the minimum number of coins it takes to get that value. zAt each value we loop through all denominations and use the one where we can get to that value with the fewest coins using previously calculated values.

Minute Essay zTrace through the DP solution to the change maker using denominations of 1, 4, and 5 cents for making change on 13 cents. Just write the number of coins used to make each amount of change between 1 and 13 cents.