COURSE TITLE: DESIGN ANALYSIS AND
COURSE CODE: 231CSC402T
ALGORTHMS
DYNAMIC PROGRAMMING
ALGORITHMS
DONE BY:
CHELSIA GLADWIN - 310623104031
K. S. ADITYA - 310623104004
ADITYA G - 310623104005
HARISH GOPAL - 310623104053
1 What is Dynamic Programming
Algorithms
TABLE OF 2
Where to use DP Algorithms
CONTENT
Techniques to solve Dynamic
3
Programming Problems
4 Principle of Optimality
WHAT IS DYNAMIC
PROGRAMMING ALGORITHM
Dynamic Programming (DP) solves complex problems by
breaking them into smaller, overlapping subproblems and
storing results to avoid redundant calculations.
01
KEY CONCEPTS
OVERLAPPING OPTIMAL
SUBPROBLEMS SUBSTRUCTURE
Solve and reuse solutions Build the best solution from
instead of recalculating. smaller optimal solutions.
Example: Finding the shortest route between cities by storing and reusing distances.
Dynamic Programming helps solve problems efficiently by reducing time complexity.
02 "Work smarter, not harder!"
WHERE TO USE DP ALGORITHMS
There are various cases where we can use Dynamic
Programming Algorithms. One classic example includes the
Fibbonaci Sequence.
Fibonacci sequence: Each number is the sum of the two
preceding ones, starting with 0 and 1.
Formula: F(n) = F(n-1) + F(n-2)
Problem: Calculating F(10) involves overlapping subproblems
(e.g., F(8) is repeated).
We can solve this problem by applying Dynamic Programming
Concept.
Memoization: Store results of computed subproblems in an
array.
Efficiency: Reuse stored values (e.g., F(7), F(8)) to avoid
redundant calculations.
Key Advantage: Improves performance by eliminating
redundant work.
03
Let’s look at a few more applications of Dynamic Programming.
1. Optimization Problems
Knapsack Problem: Maximize value with weight constraints.
Coin Change Problem: Minimize number of coins for a given amount.
Longest Increasing Subsequence: Find longest subsequence of increasing elements.
2. Pathfinding Problems
Fibonacci Sequence: Avoid redundant calculations with DP.
Matrix Chain Multiplication: Find efficient matrix multiplication order.
Shortest Path Problems: Algorithms like Floyd-Warshall for shortest paths in graphs.
3. Scheduling Problems
Job Scheduling: Maximize profit with deadline constraints.
Optimal Resource Allocation: Minimize costs or maximize profits over time.
4. Stock Market Predictions
Stock Buy-Sell Problem: Maximize profit by determining optimal times to buy and sell stock.
Hence, DP is essential for problems with overlapping subproblems and optimal
substructure.
It reduces computation time by reusing results of subproblems.
TECHNIQUES TO SOLVE DYNAMIC
PROGRAMMING PROBLEMS
TOP - DOWN BOTTOM - UP
Breakdown the given problem in order to solve it Analyze the problem and see in what order the
Referred as Memoization subproblems are solved
Stores the result of function calls in tables Referred as Bottom-up Dynamic Programming
Recursive implementation Iterative Implementation
Entries are filled in Bottom-up manner
05
PRINCIPLE OF OPTIMALITY
Dynamic Programming follows the principle
of optimality. The principle of optimality
states that “in an optimal sequence of
choices and decisions, each subsequence
must also be optimal.“
When it’s not possible to apply principle of
optimality, it is almost impossible to obtain
the solution using dynamic programming
approach
06
COIN CHANGING PROBLEM
Solve making change problem for d1 = 1, d2 = 4, d3 = 6, n = 3 and given that N = 8 units.
1 2
3 4
07
Keep updating the
table with values
08
09
Algorithm for
minimum number
of coins required to
make
10
THANK YOU