Simplifying Dynamic Programming Jamil Saquer & Lloyd Smith Computer Science Department Missouri State University Springfield, MO USA.

Slides:



Advertisements
Similar presentations
Dynamic Programming Introduction Prof. Muhammad Saeed.
Advertisements

Dynamic Programming From An
CS 206 Introduction to Computer Science II 02 / 27 / 2009 Instructor: Michael Eckmann.
Dynamic Programming.
Algorithm Design Methodologies Divide & Conquer Dynamic Programming Backtracking.
Types of Algorithms.
Analysis of Algorithms
Overview What is Dynamic Programming? A Sequence of 4 Steps
Problem Solving Dr. Andrew Wallace PhD BEng(hons) EurIng
1 Dynamic Programming (1). 2 Dynamic Programming The dynamic programming archetype is used to solve problems that can be defined by recurrences with overlapping.
Introduction to Algorithms
RAIK 283: Data Structures & Algorithms
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 11.
11-1 Elements of Dynamic Programming For dynamic programming to be applicable, an optimization problem must have: 1.Optimal substructure –An optimal solution.
Dynamic Programming Technique. D.P.2 The term Dynamic Programming comes from Control Theory, not computer science. Programming refers to the use of tables.
CS 261 – Winter 2010 Trees. Ubiquitous – they are everywhere in CS Probably ranks third among the most used data structure: 1.Vectors and Arrays 2.Lists.
Dynamic Programming A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 8 ©2012 Pearson Education, Inc. Upper Saddle River,
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 From An Excel Perspective. Dynamic Programming From An Excel Perspective Ranette Halverson, Richard Simpson, Catherine Stringfellow.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 8 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Dynamic Programming. Well known algorithm design techniques:. –Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic programming.
ADA: 7. Dynamic Prog.1 Objective o introduce DP, its two hallmarks, and two major programming techniques o look at two examples: the fibonacci.
Fundamentals of Algorithms MCS - 2 Lecture # 7
Dynamic Programming Nattee Niparnan. Dynamic Programming  Many problem can be solved by D&C (in fact, D&C is a very powerful approach if you generalized.
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.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 17.
Dynamic Programming Louis Siu What is Dynamic Programming (DP)? Not a single algorithm A technique for speeding up algorithms (making use of.
1 Dynamic Programming Andreas Klappenecker [partially based on slides by Prof. Welch]
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.
Greedy Algorithms. What is “Greedy Algorithm” Optimization problem usually goes through a sequence of steps A greedy algorithm makes the choice looks.
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.
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
Computer Sciences Department1.  Property 1: each node can have up to two successor nodes (children)  The predecessor node of a node is called its.
PROBLEM-SOLVING TECHNIQUES Rocky K. C. Chang November 10, 2015.
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.
1 Today’s Material Dynamic Programming – Chapter 15 –Introduction to Dynamic Programming –0-1 Knapsack Problem –Longest Common Subsequence –Chain Matrix.
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
Greedy Algorithms Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Lecture 12.
Dynamic Programming Sequence of decisions. Problem state.
Rod cutting Decide where to cut steel rods:
Design & Analysis of Algorithm Dynamic Programming
Dynamic Programming Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Introduction to the Design and Analysis of Algorithms
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Advanced Design and Analysis Techniques
Types of Algorithms.
Topic 25 Dynamic Programming
CS330 Discussion 4 Spring 2017.
Dynamic Programming.
Dynamic Programming.
Prepared by Chen & Po-Chuan 2016/03/29
Data Structures and Algorithms
Unit-5 Dynamic Programming
Types of Algorithms.
A CASE STUDY INTRODUCING DYNAMIC PROGRAMMING IN CS2
Jamil Saquer and Razib Iqbal Computer Science Department
CS Algorithms Dynamic programming 0-1 Knapsack problem 12/5/2018.
Chapter 15-1 : Dynamic Programming I
Analysis of Algorithms CS 477/677
CS 261 – Data Structures Trees.
DYNAMIC PROGRAMMING.
Types of Algorithms.
Elements of Dynamic Programming
Dynamic Programming.
Analysis of Algorithms CS 477/677
Presentation transcript:

Simplifying Dynamic Programming Jamil Saquer & Lloyd Smith Computer Science Department Missouri State University Springfield, MO USA

Motivation Dynamic programming (DP) is a fundamental topic in an algorithms course Many students find DP challenging This presentation is work in progress for making DP easier for students 2

Idea Introduce subject early in the curriculum –CS2 –start with simple and interesting problems This should make DP easier for students when they encounter it later 3

Where to start? Fibonacci sequence –F 1 = F 2 = 1 –F n = F n-1 + F n-2, if n >2 It can be introduced when students study recursion or big-O Shows how using a cache table improves performance 4

What else with Fibonacci? Also using the Fibonacci sequence to show –overlapping sub-problems property –optimal substructure property: solution to original problem contains solutions to sub- problems 5

What else with Fibonacci? (cont.) top down approach –when a value is needed, first look for it in table –only if not there, call function, store value in table, then return it bottom up approach: –a table is built starting with basic case(s) –then, rest of table is filled in a bottom up fashion to reach the solution 6

Where to go from here Use simple and interesting problems Bottom up approach is easier and better to stick with initially 7

Examples of Problems The jump it game Number of ways to climb n steps Robot in a grid Maximum number of golden coins Minimum cost path 8

The Jump It Game Given a board with n cells Each cell, except the first, contains a positive integer representing the cost to visit that cells First cell contains 0 Player starts at first cell Player has two types of moves –either move to the adjacent cell –or jump over adjacent cell Cost of game is the sum of costs of visited cells Goal: reach last cell with the cheapest cost Task: find this cheapest cost

Number of Ways to climb Stairs Given a stairway consisting of n steps A child stands at the bottom of the stairway and wants to reach the top most step The child can take 1, 2 or 3 steps at a time Goal: find the number of possible ways to climb the stairs 10

Robot in a Grid Imagine a robot at the top left corner in a two dimensional grid The robot can only move right or bottom to an adjacent cell Find the number of possible ways for the robot to reach the bottom right cell 11 finish start

Maximum Number of Golden Coins Given an m by n table Each cell contains a number of golden coins One starts at the top-left corner and wants to reach the bottom-right corner At each step one can move one cell right or down Goal: find the maximum number of golden coins you can collect

Minimum Cost Path Given a 2D grid where each cell contains a cost One can move one cell right, down or diagonal Find the minimum cost to reach the bottom-right cell starting from the top-left cell Cost of a path is the sum of the costs of all cells on that path 13

What have we done? Collected data in the algorithms course Introduced DP in CS2 this semester This group will take algorithms next semester We will collect data next semester Compare performance of two groups 14

Questions 15