Jamil Saquer and Razib Iqbal Computer Science Department

Slides:



Advertisements
Similar presentations
Dynamic Programming From An
Advertisements

Dynamic Programming.
A spreadsheet is like a big table. It contains rows and columns which work together. Left-click to go to the next slide.
Two-Player Zero-Sum Games
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Factoring Quadratic Expressions ax 2 + bx + c. 2x2x 3x3x +3 – 4 Setting the Stage Do you remember how to multiply these together? (Referred to as FOIL.
Comp 122, Fall 2004 Dynamic Programming. dynprog - 2 Lin / Devi Comp 122, Spring 2004 Longest Common Subsequence  Problem: Given 2 sequences, X =  x.
Dynamic Programming Lets begin by looking at the Fibonacci sequence.
11-1 Elements of Dynamic Programming For dynamic programming to be applicable, an optimization problem must have: 1.Optimal substructure –An optimal solution.
CPSC 311, Fall 2009: Dynamic Programming 1 CPSC 311 Analysis of Algorithms Dynamic Programming Prof. Jennifer Welch Fall 2009.
Game Theory and Applications following H. Varian Chapters 28 & 29.
CPSC 411 Design and Analysis of Algorithms Set 5: Dynamic Programming Prof. Jennifer Welch Spring 2011 CPSC 411, Spring 2011: Set 5 1.
1 Dynamic Programming Andreas Klappenecker [based on slides by Prof. Welch]
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
Dynamic Programming From An Excel Perspective. Dynamic Programming From An Excel Perspective Ranette Halverson, Richard Simpson, Catherine Stringfellow.
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.
Tables 4 th grade. Lesson and Behavioral Objectives.
CS 312: Algorithm Design & Analysis Lecture #23: Making Optimal Change with Dynamic Programming Slides by: Eric Ringger, with contributions from Mike Jones,
Algorithm Paradigms High Level Approach To solving a Class of Problems.
We want to calculate the score for the yellow box. The final score that we fill in the yellow box will be the SUM of two other scores, we’ll call them.
Dynamic Programming Louis Siu What is Dynamic Programming (DP)? Not a single algorithm A technique for speeding up algorithms (making use of.
Computer Science 1000 Spreadsheets IV Permission to redistribute or use these slides is strictly prohibited without permission.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Dynamic Programming.
A JAVASCRIP BOUNCING BALL ANIMATION - NIFTY ASSIGNMENT Jamil Saquer Computer Science Department Missouri State University Springfield, MO.
Excel Spreadsheet Notes. What is a Spreadsheet? Columns and rows of data.
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.
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 Bottleneck Routing Games on Grids Costas Busch Rajgopal Kannan Alfred Samman Department of Computer Science Louisiana State University.
2-dimensional Arrays A 2-dimensional array has rows and columns It is actually an “array of arrays” A Tic-Tac-Toe board is an example of a 3 by 3 2-d array.
TU/e Algorithms (2IL15) – Lecture 3 1 DYNAMIC PROGRAMMING
RELATE ARRAYS TO TAPE DIAGRAMS TO MODEL THE COMMUTATIVE PROPERTY OF MULTIPLICATION. Module 1 Lesson 15.
The Transportation Problem Simplex Method Remember our initial transportation problem with the associated cost to send a unit from the factory to each.
1 Chapter 15-2: Dynamic Programming II. 2 Matrix Multiplication Let A be a matrix of dimension p x q and B be a matrix of dimension q x r Then, if we.
Alignment, Part II Vasileios Hatzivassiloglou University of Texas at Dallas.
Dynamic Programming for the Edit Distance Problem.
Simplifying Dynamic Programming Jamil Saquer & Lloyd Smith Computer Science Department Missouri State University Springfield, MO USA.
Lecture 5 of Computer Science II
Rod cutting Decide where to cut steel rods:
Instructions: 1. Type your categories (1-4) along the top row of the
9.1 Fifteen-Game (Board Game)
Seminar on Dynamic Programming.
Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.
Chapter 8 Dynamic Programming
Sequence comparison: Dynamic programming
Topic 25 Dynamic Programming
CSCE 411 Design and Analysis of Algorithms
CS330 Discussion 4 Spring 2017.
Dynamic Programming.
Prepared by Chen & Po-Chuan 2016/03/29
Solutions Sample Games 1
A CASE STUDY INTRODUCING DYNAMIC PROGRAMMING IN CS2
Picture This! Reducing Fractions
CSCI N207 Data Analysis Using Spreadsheet
CS Fall 2016 (Shavlik©), Lecture 10, Week 6
Picture This! Reducing Fractions
Dynamic Programming.
Breakfast Bytes Easy, Hard, and Impossible
Dynamic Programming.
DYNAMIC PROGRAMMING.
Elements of Dynamic Programming
Matrix Chain Multiplication
Players choose either light or dark blue blocks to play.
How well do you KNOW your 2 times table ?
Using Two-Way Frequency Tables (4.2.2)
Seminar on Dynamic Programming.
Building pattern  Complete the following tables and write the rule 
Unit II Game Playing.
MORE WAYS TO PLAY.
Presentation transcript:

A Dynamic Programing Based Solution to the Two-Dimensional Jump-It Problem Jamil Saquer and Razib Iqbal Computer Science Department Missouri State University Springfield, MO

Introducing the problem 2D board with a cost to visit each cell A player starts at the top-left cell and wants to reach the bottom-right (exit) cell with the lowest cost Allowed moves: one cell to the right one cell below jump over one cell to the right Jump over one cell below 5 7 2 4 8 1 6 3 9

Possible Paths 5 7 2 4 8 1 6 3 9 5 7 2 4 8 1 6 3 9 cost = 5 + 1 + 4 + 7 + 3 = 20 cost = 5 + 7 + 1 + 5 + 8 + 3 = 29 5 7 2 4 8 1 6 3 9 cost = 5 + 2 + 4 + 1 + 3 + 3 = 18

Goal Find the cheapest cost of playing the game Find path that leads to playing the game with the cheapest cost

Review – 1D Jump-It 5 15 75 7 43 11

Review – 1D Jump-It solution: if board length == 1, visit that cell 5 start solution: if board length == 1, visit that cell 5 15 75 7 43 11

Review – 1D Jump-It solution: if board length == 1, visit that cell start solution: if board length == 1, visit that cell if board length == 2, visit both cells 5 15 75 7 43 11

Review – 1D Jump-It solution: if board length == 1, visit that cell start solution: if board length == 1, visit that cell if board length == 2, visit both cells if board length == 3, cheaper to jump over 5 15 75 7 43 11

Review – 1D Jump-It solution: if board length == 1, visit that cell start solution: if board length == 1, visit that cell if board length == 2, visit both cells if board length == 3, cheaper to jump over else min_cost = board[i] + min{jumpIt(i+1), jumpIt(i+2)} 5 15 75 7 43 11

2D Jump-It Finding the Cheapest Cost Let jumpIt(r, c) be the cheapest cost of playing the game starting at any cell (r, c) Many cases 5 7 2 4 8 1 6 3 9

Finding the Cheapest Cost 5 7 2 4 8 1 6 3 9

Finding the Cheapest Cost 5 7 2 4 8 1 6 3 9

Dynamic Programming Solution 2D jump-It is a good candidate for DP Overlapping sub-problems Optimal sub-structure

Top-Down DP Solution board[i][j] contains cost of visiting cell (i, j) costs – a cache table for storing solutions costs[i][j] minimum cost starting game at cell (i, j) fill cache table starting with basic cases 5 7 2 4 8 1 6 3 9 costs board

Top-Down DP Solution costs board fill last row starting fill in last column fill the row before last fill the column before last fill rest of cache table 18 18 13 11 14 5 7 2 4 8 1 6 3 9 14 13 14 7 6 21 12 16 16 11 14 11 10 12 3 costs board

Finding Optimal path board costs path Use another cache table, path, to remember moves path[i][j] - coordinates of cell visited after cell (i ,j) 1 2 3 4 5 7 2 4 8 1 6 3 9 18 18 13 11 14 14 13 14 7 6 1 21 12 16 16 11 2 14 11 10 12 3 3 board costs (0, 2) (0, 3) (0, 3) (1, 3) (1, 4) 1 (1,1) (1, 3) (1, 4) (1, 4) (3, 4) 2 (2, 1) (3, 1) (3, 2) (2, 4) (3, 4) 3 (3, 2) (3, 2) (3,4) (3, 4) (-1,-1) 1 2 3 4 path

2D Jump-It in The CS Curriculum Good problem to use when teaching DP

Questions