KEMBAR78
Dynamic Programming Intro in Algorithm Design | PPTX
Dynamic
Programming
Ahsan Raza
EXAMPLE(Fibonacci Sequence/Series)
f(n)
{
if(n==0)
return 0;
if(n==1)
return 1;
if(n>1)
return (f(n-1)+f(n-2);
}
n : 1 2 3 4 5 6 7 8 9 1 0
f(n): 0 1 1 2 3 5 8 13 21 34 55
F(5)
F(3)
F(4)
F(3)
F(1)
F(2)
F(2)
F(0)
F(1)
F(1)
F(2)
F(0)
F(1)
F(0)
F(1)
• It's a powerful algorithm
technique.
• •Used for Optimization
problems
• Solve complex problems by
breaking them into smaller
subproblems.
• Optimal substructure and
overlapping subproblems.
INTRODUCTION
Two Fundamental
Principles
• Optimal Substructure
• Overlapping Subproblems
FUNDAMENTALS
Optimal Substructure means we
can break a big problem into smaller
subproblems, and if we solve those
smaller subproblems optimally, we
can combine their solutions to solve
the big problem optimally.
OPTIMAL SUBSTRUCTURE:
EXAMPLE: JIGSAW PUZZLE
Overlapping Subproblems refers to
the situation where the same smaller
problems are encountered and solved
multiple times when solving a larger
problem.It's about reusing solutions to
avoid redundant work.
OVERLAPPING SUBPROBLEMS
Memoization(Top-Down)
A lookup table is maintained and
checked before computation of any
state.Recursion is involved.
WAYS TO HANDLE OVERLAPPING SUBPROBLEMS
Tabulation(Bottom-Up)
Solution is built from base.It is an
iterative process.
Dynamic programming, specifically memoization or
tabulation, helps here by storing the results of these
subproblems the first time you solve them.When you
need the same result again, you simply look it up,
avoiding redundant calculations.This significantly
improves efficiency, especially for larger problems.
• Space complexity
• Complexity of identifying subproblems
• Inability to handle problems without
optimal substructure:
LIMITATIONS
LIMITATIONS
• Efficiency: It can improve the efficiency of
algorithms by avoiding redundant computations.
• Optimality: The algorithms are guaranteed to
find optimal solutions to problems with optimal
substructure.
• Generality: Dynamic programming can be
applied to a wide variety of problems.
ADVANTAGES
ADVANTAGES
Thank you.

Dynamic Programming Intro in Algorithm Design

  • 1.
  • 2.
    EXAMPLE(Fibonacci Sequence/Series) f(n) { if(n==0) return 0; if(n==1) return1; if(n>1) return (f(n-1)+f(n-2); } n : 1 2 3 4 5 6 7 8 9 1 0 f(n): 0 1 1 2 3 5 8 13 21 34 55 F(5) F(3) F(4) F(3) F(1) F(2) F(2) F(0) F(1) F(1) F(2) F(0) F(1) F(0) F(1)
  • 3.
    • It's apowerful algorithm technique. • •Used for Optimization problems • Solve complex problems by breaking them into smaller subproblems. • Optimal substructure and overlapping subproblems. INTRODUCTION
  • 4.
    Two Fundamental Principles • OptimalSubstructure • Overlapping Subproblems FUNDAMENTALS
  • 5.
    Optimal Substructure meanswe can break a big problem into smaller subproblems, and if we solve those smaller subproblems optimally, we can combine their solutions to solve the big problem optimally. OPTIMAL SUBSTRUCTURE: EXAMPLE: JIGSAW PUZZLE
  • 6.
    Overlapping Subproblems refersto the situation where the same smaller problems are encountered and solved multiple times when solving a larger problem.It's about reusing solutions to avoid redundant work. OVERLAPPING SUBPROBLEMS
  • 7.
    Memoization(Top-Down) A lookup tableis maintained and checked before computation of any state.Recursion is involved. WAYS TO HANDLE OVERLAPPING SUBPROBLEMS Tabulation(Bottom-Up) Solution is built from base.It is an iterative process.
  • 8.
    Dynamic programming, specificallymemoization or tabulation, helps here by storing the results of these subproblems the first time you solve them.When you need the same result again, you simply look it up, avoiding redundant calculations.This significantly improves efficiency, especially for larger problems.
  • 9.
    • Space complexity •Complexity of identifying subproblems • Inability to handle problems without optimal substructure: LIMITATIONS LIMITATIONS
  • 10.
    • Efficiency: Itcan improve the efficiency of algorithms by avoiding redundant computations. • Optimality: The algorithms are guaranteed to find optimal solutions to problems with optimal substructure. • Generality: Dynamic programming can be applied to a wide variety of problems. ADVANTAGES ADVANTAGES
  • 11.