Elements of Dynamic ProgrammingAn Introduction byTafhimUl IslamC091008CSE 4th SemesterInternational Islamic University Chittagong
What is Dynamic ProgrammingDynamic Programming (DP) is not an algorithm. It’s a technique/approach that we use to build efficient algorithms for problems of very specific class
The ElementsOptimal SubstructureOverlapping sub-problemMemoization
What is Substructure?A substructure is a structure itself that helps a bigger structure of the same kind to exist.The substructure does not play an auxiliary roleIt is an essential part of the super structureIt is only smaller in size compared to the super structureIt has the same properties of the superstructure
Optimal SubstructureSo optimal substructure is simply the optimal selection among all the possible substructures that can help a super structure of the same kind to existExample: To know how to multiply n matrices optimally we must multiply the last matrix with the optimal multiplication result of the n-1 other matrices. The base case for the recursion here is that the optimal parenthesization of
Optimal SubstructureTo build a building with the best possible strength, we need to build each level as optimally as possibleTo solve a mathematical problem, we all the smaller problems inside that problem to have the correct result. Each problem might depend on the previous problem solved. So we need to take care of all the problems optimally, with correct calculations.
Overlapping Sub-problemOverlapping sub-problem is found in those problems where bigger problems share the same smaller problems. This means, while solving larger problems through their sub-problems we find the same sub-problems in two or more different large problems. In these cases a sub-problem is usually found to be solved previously.
Overlapping Sub-problemOverlapping sub-problems can be found in Matrix-Chain-Multiplication (MCM) problem.
Cases where mistakes might occurUnweighted shortest path: Find a path from u to v consisting of the fewest edges. Such a path must be simple, since removing a cycle from a path pro-duces a path with fewer edges.Unweighted longest simple path: Find a simple path from u to v consisting of the most edges. We need to include the requirement of simplicity because other-wise we can traverse a cycle as many times as we like to create paths with an arbitrarily large number of edges.
MemoizaitonThe memoization technique is the method of storing values of solutions to previously solved problems. This generally means storing the values in a data structure that helps us reach them efficiently when the same problems occur during the program’s execution. The data structure can be anything that helps us do that but generally a table is used.

Elements of dynamic programming

  • 1.
    Elements of DynamicProgrammingAn Introduction byTafhimUl IslamC091008CSE 4th SemesterInternational Islamic University Chittagong
  • 2.
    What is DynamicProgrammingDynamic Programming (DP) is not an algorithm. It’s a technique/approach that we use to build efficient algorithms for problems of very specific class
  • 3.
  • 4.
    What is Substructure?Asubstructure is a structure itself that helps a bigger structure of the same kind to exist.The substructure does not play an auxiliary roleIt is an essential part of the super structureIt is only smaller in size compared to the super structureIt has the same properties of the superstructure
  • 5.
    Optimal SubstructureSo optimalsubstructure is simply the optimal selection among all the possible substructures that can help a super structure of the same kind to existExample: To know how to multiply n matrices optimally we must multiply the last matrix with the optimal multiplication result of the n-1 other matrices. The base case for the recursion here is that the optimal parenthesization of
  • 6.
    Optimal SubstructureTo builda building with the best possible strength, we need to build each level as optimally as possibleTo solve a mathematical problem, we all the smaller problems inside that problem to have the correct result. Each problem might depend on the previous problem solved. So we need to take care of all the problems optimally, with correct calculations.
  • 7.
    Overlapping Sub-problemOverlapping sub-problemis found in those problems where bigger problems share the same smaller problems. This means, while solving larger problems through their sub-problems we find the same sub-problems in two or more different large problems. In these cases a sub-problem is usually found to be solved previously.
  • 8.
    Overlapping Sub-problemOverlapping sub-problemscan be found in Matrix-Chain-Multiplication (MCM) problem.
  • 9.
    Cases where mistakesmight occurUnweighted shortest path: Find a path from u to v consisting of the fewest edges. Such a path must be simple, since removing a cycle from a path pro-duces a path with fewer edges.Unweighted longest simple path: Find a simple path from u to v consisting of the most edges. We need to include the requirement of simplicity because other-wise we can traverse a cycle as many times as we like to create paths with an arbitrarily large number of edges.
  • 10.
    MemoizaitonThe memoization techniqueis the method of storing values of solutions to previously solved problems. This generally means storing the values in a data structure that helps us reach them efficiently when the same problems occur during the program’s execution. The data structure can be anything that helps us do that but generally a table is used.