Professional Documents
Culture Documents
1.what Is Dynamic Programming?
1.what Is Dynamic Programming?
Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive
solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming.
The idea is to simply store the results of subproblems, so that we do not have to re-compute them
when needed later. This simple optimization reduces time complexities from exponential to
polynomial.
In optimization of a design, the design objective could be simply to minimize the cost of production
or to maximize the efficiency of production. An optimization algorithm is a procedure which is
executed iteratively by comparing various solutions till an optimum or a satisfactory solution is
found. With the advent of computers, optimization has become a part of computer-aided design
activities. There are two distinct types of optimization algorithms widely used today.
1.No general formation of Dynamic Program is available; every problem has to be solving in its own
way.
2.Dividing problem in sub problem and storing inter mediate results consumes memory.
(iii) Bioinformatics.
The dynamic programming is among the most powerful for designing algorithms for optimization
problem. This is true for two reasons. Firstly, dynamic programming solutions are based on few
common elements. Secondly, dynamic programming problems are typical optimization problems
i.e., find the minimum or maximum cost solution, subject to various constraints.
Step 3 – Memorization
Step 4 – Implementation
The principle of optimality is the basic principle of dynamic programming, which was developed by
Richard Bellman: that an optimal path has the property that whatever the initial conditions and
control variables (choices) over some initial period, the control (or decision variables) chosen over
the remaining period must be optimal for the remaining problem, with the state resulting from the
early decisions taken to be the initial condition.
The single-source shortest path problem, in which we have to find shortest paths from a source
vertex v to all other vertices in the graph. The single-destination shortest path problem, in which
we have to find shortest paths from all vertices in the directed graph to a single destination vertex
v.
10.Write the algorithm for single source shortest path?
1) Create a set sptSet (shortest path tree set) that keeps track of vertices included in shortest path
tree, i.e., whose minimum distance from source is calculated and finalized. Initially, this set is
empty.
2) 2) Assign a distance value to all vertices in the input graph. Initialize all distance values as
INFINITE. Assign distance value as 0 for the source vertex so that it is picked first.
….a) pick a vertex u which is not there in sptSet and has minimum distance value.
….c) Update distance value of all adjacent vertices of u. To update the distance values, iterate
through all adjacent vertices. For every adjacent vertex v, if sum of distance value of u (from
source) and weight of edge u-v, is less than the distance value of v, then update the distance value
of v.