Dynamic Programming From An Excel Perspective. Dynamic Programming From An Excel Perspective Ranette Halverson, Richard Simpson, Catherine Stringfellow.

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 Introduction Prof. Muhammad Saeed.
Dynamic Programming (DP)
Dynamic Programming From An
Dynamic Programming.
Dynamic Programming An algorithm design paradigm like divide-and-conquer “Programming”: A tabular method (not writing computer code) Divide-and-Conquer.
Overview What is Dynamic Programming? A Sequence of 4 Steps
1 Dynamic Programming Jose Rolim University of Geneva.
Data Structures Lecture 10 Fang Yu Department of Management Information Systems National Chengchi University Fall 2010.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Lecture 2 Tuesday, 2/5/02 Dynamic Programming.
Dynamic Programming Reading Material: Chapter 7..
Dynamic Programming Technique. D.P.2 The term Dynamic Programming comes from Control Theory, not computer science. Programming refers to the use of tables.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2009 Design Patterns for Optimization Problems Dynamic Programming.
Design and Analysis of Algorithms - Chapter 81 Dynamic Programming Dynamic Programming is a general algorithm design technique Dynamic Programming is a.
Dynamic Programming Dynamic Programming algorithms address problems whose solution is recursive in nature, but has the following property: The direct implementation.
Chapter 8 Dynamic Programming Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Dynamic Programming1. 2 Outline and Reading Matrix Chain-Product (§5.3.1) The General Technique (§5.3.2) 0-1 Knapsack Problem (§5.3.3)
Dynamic Programming Reading Material: Chapter 7 Sections and 6.
© 2004 Goodrich, Tamassia Dynamic Programming1. © 2004 Goodrich, Tamassia Dynamic Programming2 Matrix Chain-Products (not in book) Dynamic Programming.
Lecture 8: Dynamic Programming Shang-Hua Teng. First Example: n choose k Many combinatorial problems require the calculation of the binomial coefficient.
Dynamic Programming 0-1 Knapsack These notes are taken from the notes by Dr. Steve Goddard at
Analysis of Algorithms
Longest Common Subsequence
Dynamic Programming Introduction to Algorithms Dynamic Programming CSE 680 Prof. Roger Crawfis.
First Ingredient of Dynamic Programming
Dynamic Programming Part One HKOI Training Team 2004.
The power of logarithmic computations Jordi Cortadella Department of Computer Science.
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.
Dynamic Programming Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by or formulated.
Dynamic Programming Tutorial &Practice on Longest Common Sub-sequence.
CS 5243: Algorithms Dynamic Programming Dynamic Programming is applicable when sub-problems are dependent! In the case of Divide and Conquer they are.
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.
CSC401: Analysis of Algorithms CSC401 – Analysis of Algorithms Chapter Dynamic Programming Objectives: Present the Dynamic Programming paradigm.
CS 8833 Algorithms Algorithms Dynamic Programming.
DP (not Daniel Park's dance party). Dynamic programming Can speed up many problems. Basically, it's like magic. :D Overlapping subproblems o Number of.
Dynamic Programming continued David Kauchak cs302 Spring 2012.
Dynamic Programming David Kauchak cs302 Spring 2013.
Dynamic Programming Day 3: Examples. Longest Common Subsequence Given two sequences of characters A, B Find the longest sequence C such that C is a subsequence.
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.
Introduction to Algorithms Jiafen Liu Sept
Dynamic Programming1. 2 Outline and Reading Matrix Chain-Product (§5.3.1) The General Technique (§5.3.2) 0-1 Knapsack Problem (§5.3.3)
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 David Kauchak cs161 Summer 2009.
Chapter 7 Dynamic Programming 7.1 Introduction 7.2 The Longest Common Subsequence Problem 7.3 Matrix Chain Multiplication 7.4 The dynamic Programming Paradigm.
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.
Dynamic Programming (DP) By Denon. Outline Introduction Fibonacci Numbers (Review) Longest Common Subsequence (LCS) More formal view on DP Subset Sum.
1Computer Sciences Department. 2 Advanced Design and Analysis Techniques TUTORIAL 7.
Dynamic Programming Tutorial &Practice on Longest Common Sub-sequence.
Fundamental Data Structures and Algorithms Ananda Guna March 18, 2003 Dynamic Programming Part 1.
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
9/27/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 16 Dynamic.
TU/e Algorithms (2IL15) – Lecture 4 1 DYNAMIC PROGRAMMING II
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.
Simplifying Dynamic Programming Jamil Saquer & Lloyd Smith Computer Science Department Missouri State University Springfield, MO USA.
Lecture 12.
CS200: Algorithm Analysis
CSCE 411 Design and Analysis of Algorithms
Dynamic Programming 1/15/2019 8:22 PM Dynamic Programming.
Dynamic Programming Dynamic Programming 1/18/ :45 AM
CSE 326: Data Structures Lecture #24 The Algorhythmics
Algorithms CSCI 235, Spring 2019 Lecture 28 Dynamic Programming III
Trevor Brown DC 2338, Office hour M3-4pm
Longest Common Subsequence
Advanced Programming Techniques
This is not an advertisement for the profession
Longest Common Subsequence
Dynamic Programming.
Presentation transcript:

Dynamic Programming From An Excel Perspective

Dynamic Programming From An Excel Perspective Ranette Halverson, Richard Simpson, Catherine Stringfellow Department of Computer Science Midwestern State University

Dynamic Programming From An Excel Perspective Ranette Halverson, Richard Simpson, Catherine Stringfellow Department of Computer Science Midwestern State University

Dynamic Programming From An Excel Perspective Dynamic Programming  A popular method for solving some problems by breaking them down to overlapping sub-problems that display optimal substructure.  The method can be thought of as a top-down approach utilizing a bottom up evaluation  Normally used to solve optimization problems

Dynamic Programming From An Excel Perspective Excel  A spreadsheet from Microsoft  Just one of the many spreadsheets out there  Generally taught in the freshman application classes  Seldom taught to computer science majors for the obvious reason that its an application.  In reality CS majors need to be able to use spreadsheets. So what do we do?

Dynamic Programming From An Excel Perspective Solution  Include spreadsheet usage in quite a few of their projects and/or homework  We really do not need to teach the spreadsheet AT ALL  Spreadsheet usage includes  to graph data collected via empirical analysis of say two algorithms. Supports their analysis within a paper.  to rapidly construct mathematical tables for some applications  Simulate wave-front parallel algorithms  to evaluate dynamic programming tables ( the point of this talk)  etc.

Dynamic Programming From An Excel Perspective A Very Simple Example (used in computer science for science majors) The memo-ization of the recursive Fibonacci function. Recall the complexity of the following int Fib( int n) { if (n<3) return 1 else return ( Fib(n-1)+Fib(n-2) ); }

Dynamic Programming From An Excel Perspective The O(n) solutions that are well known to all of us are int Fib( int n) { A=new int[n+1]; A[1]=A[2]=1; for(int i=3 ; i<=n ; i++) A[i] = A[i-1] + A[i-2]; return A[n]; } // Pure Bottom up calculation using // an array. The non array version is // not relative to our discussion. int FibMemo(int n,int * A){ if (A[n]!=0) return A[n]; else { A[n]= FibMemo(n-1,A) + FibMemo(n-2,A); return A[n]; } }; int Fib(int n) { int * A = new int[n+1] ; for (int i=1;i<n+1;i++){ A[i]=0;} A[1]=A[2]=1; return FibMemo(n,A); } // A recursive Memoized version

Dynamic Programming From An Excel Perspective And in excel we have this simple approach =A1+B1 Kand copy cell to the right

Dynamic Programming From An Excel Perspective Here the formula =B1+A2 is copied from B2 to the remaining cells. Here Pascal's triangle is constructed in Excel in the usual bottom up approach. The programmed solution can be handled via DP as in the Fibonacci example, either using an array with or without memoized recursion. The pure recursive version is of course computationally unacceptable.

Dynamic Programming From An Excel Perspective There are many DP algorithms that appear throughout our curriculum. These include  Longest Common Subsequence Bioinformatics class.  Sequence Alignment : Bioinformatics  Optimal Binary Search Tree : Algorithms  Matrix Chain Multiplication : Algorithms  Many graph algorithms etc.

Dynamic Programming From An Excel Perspective Longest Common Subsequence (LCS) Definition: find the longest subsequence that is common to two (or more) sequences. Example Seq1 = B D C A B A Seq2 = A B C B D A B LCS = BCBA Note: The LCS is not a substring!

Dynamic Programming From An Excel Perspective Longest Common Subsequence (LCS) The DP approach leads to the following recursive approach. Let z=z 1 z 2 … x k be the LCS of x 1 x 2 … x i-1 x i y 1 y 2 … y j-1 y j Where c[ib,j] is the length of the LCS of x 1..x i and y 1..y j

Dynamic Programming From An Excel Perspective The initialized LCS Table IF(D$2=$B4,C3+1,MAX(D3,C4)) Cell formula Copy the following Cell Formula to all the grey cells. These represent the c(i,j)’s

Dynamic Programming From An Excel Perspective And the solution is Note diagonal increments Length of LCS

Dynamic Programming From An Excel Perspective DP Problems with complicated table manipulation  Optimal Binary Search Tree (in paper)  Matrix Chain Multiplication  etc. Question: What do you do with problems that require the processing of rows or columns in such a way that the usual cell function approach is not adequate. Excel does not allow cell function side effects! Hmm. Write the code in the include macro language (VB?)

Dynamic Programming From An Excel Perspective Summarizing  CS students really need some work with excel whether it is officially taught or not.  There are many projects that Excel can support in the CS curriculum.  The table processing available in Excel supports some algorithm visualization quite well  This works particularly well with the simpler DP problems.

THE END