(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
ADA Unit 2.pptx
1.
2. Dynamic programming is a technique that
breaks the problems into sub-problems, and
saves the result for future purposes so that
we do not need to compute the result again.
The subproblems are optimized to optimize
the overall solution is known as optimal
substructure property
3. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ,…
The numbers in the above series are not
randomly calculated. Mathematically, we
could write each of the terms using the
below formula:
F(n) = F(n-1) + F(n-2),
How can we calculate F(20)
4.
5. As we can observe in the above figure that
F(20) is calculated as the sum of F(19) and
F(18). In the dynamic programming
approach, we try to divide the problem into
the similar subproblems. We are following
this approach in the above case where F(20)
into the similar subproblems, i.e., F(19) and
F(18).
6. following are the steps that the dynamic
programming follows:
It breaks down the complex problem into simpler
subproblems.
It finds the optimal solution to these sub-problems.
It stores the results of subproblems (memoization).
The process of storing the results of subproblems is
known as memorization.
It reuses them so that same sub-problem is
calculated more than once.
Finally, calculate the result of the complex problem.
7. Stages
The given problem can be divided into a number of subproblems which
are called stages. A stage is a small portion of given problem.
States
This indicates the subproblem for which the decision has to be taken.
The variables which are used for taking a decision at every stage that
is called as a state variable.
Decision
At every stage, there can be multiple decisions out of which one of the
best decisions should be taken. The decision taken at each stage
should be optimal; this is called as a stage decision.
Optimal policy
It is a rule which determines the decision at each and every stage; a
policy is called an optimal policy if it is globally optimal. This is called
as Bellman principle of optimality.
8. There are two main properties of a problem
that suggest that the given problem can be
solved using Dynamic programming:
1) Overlapping Subproblems
2) Optimal Substructure
9. Like Divide and Conquer, Dynamic Programming
combines solutions to sub-problems. Dynamic
Programming is mainly used when solutions to the same
subproblems are needed again and again. In dynamic
programming, computed solutions to subproblems are
stored in a table so that these don’t have to be
recomputed. So Dynamic Programming is not useful when
there are no common (overlapping) subproblems because
there is no point in storing the solutions if they are not
needed again. For example, Binary Search doesn’t
have common subproblems. If we take the example of
following a recursive program for Fibonacci Numbers,
there are many subproblems that are solved again and
again.
10. Top down approach
It is also termed as memoization technique. In this, the
problem is broken into subproblem and these subproblems
are solved and the solutions are remembered, in case if
they need to be solved in future. Which means that the
values are stored in a data structure, which will help us to
reach them efficiently when the same problem will occur
during the program execution.
Bottom up approach
It is also termed as tabulation technique. In this, all
subproblems are needed to be solved in advance and then
used to build up a solution to the larger problem.
11. It implies that the optimal solution can be
obtained from the optimal solution of its
subproblem. So optimal substructure is
simply an optimal selection among all the
possible substructures that can help to select
the best structure of the same kind to exist.