0% found this document useful (0 votes)
9 views14 pages

Group 55-1

Uploaded by

ashishtruf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views14 pages

Group 55-1

Uploaded by

ashishtruf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

UNITED INSTITUTE OF MANAGEMENT

MCA 1st Year || Section A || Group No. 5


DSA Group Assignment : 01

TOPIC- DYNAMIC PROGRAMMING


Presented By :
Arjit Singh
Submitted To: (25)
Ashish Pandey
Mr. Noor Ahmad
(26)
(Assistant Professor)
Ashish Singh
UIM, Prayagraj
(27)
GROUP_5
Ashish Upadhyay
Content
• Dynamic Programming
• Approaches of Dynamic Programming
• Advantages of Dynamic Programming
• Disadvantages of Dynamic Programming

GROUP_5
Dynamic Programming
• Dynamic Programming (DP) is an algorithmic technique for
solving an optimization problem by breaking it down into
simpler sub problems and utilizing the fact that the optimal
solution to the overall problem depends upon the optimal
solution to its sub problems.
• Dynamic programming approach is similar to divide and
conquer in breaking down the problem into smaller and yet
smaller possible sub-problems. But unlike, divide and
conquer, these sub-problems are not solved independently.

GROUP_5
Dynamic Programming
The following are the steps that the dynamic programming
follows:
• It breaks down the complex problem into simpler sub problems.
• It finds the optimal solution to these sub-problems.
• It stores the results of sub problems.
• The process of storing the results of sub problems 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.
GROUP_5
Divide-and-conquer
Divide-and-conquer method for algorithm design:
• Divide: If the input size is too large to deal with in a
straightforward manner, divide the problem into two or more
disjoint subproblems.
• Conquer: Conquer recursively to solve the subproblems.
• Combine: Take the solutions to the subproblems and
"merge" these solutions into a solution for the original
problem.

GROUP_5
Divide-and-conquer - Example
• For example, MergeSort

• The subproblems are independent,

all different.

GROUP_5
Difference between DP and Divide- and-
Conquer
• Using Divide-and-Conquer to solve these problems is
inefficient because the same common subproblems have to be
solved many times.

• DP will solve each of them once and their answers are stored
in a table for future use.

GROUP_5
Dynamic Programming vs Divide &
Conquer
Divide & Conquer Dynamic Programming
Partitions a problem into independent Partitions a problemi into overlapping sub-
smaller sub-problems. problems.

Doesn't store solutions of sub- problems. Stores solutions of sub- problems: thus
(Identical sub-problems may arise results avoids calculations of same quantity twice
in the same computations are performed
repeatedly.)

Top down algorithms: which logically Bottom up algorithms: in which the


progresses from the initial instance down smallest sub-problems are explicitly
to the smallest sub-instances via solved first and the results of these used to
intermediate sub-instances. construct solutions to progressively larger
sub-instances

GROUP_5
Approaches of Dynamic Programming
There are two approaches to dynamic programming:
➤ Top-down approach
➤ Bottom-up approach

Top-down approach:
The top-down method solves the overall problem before you
break it down into sub problems. This process works to solve
larger problems by finding the solution to sub problems
recursively, caching each result.

GROUP_5
Approaches of Dynamic Programming
Bottom-up approach:
• The bottom-up approach is also one of the techniques which
can be used to implement the dynamic programming. It uses
the tabulation technique to implement the dynamic
programming approach. It solves the same kind of problems
but it removes the recursion.
• If we remove the recursion, there is no stack overflow issue
and no overhead of the recursive functions. In this tabulation
technique, we solve the problems and store the results in a
matrix.

GROUP_5
Example
The following computer problems can be solved using
dynamic programming approach.
➤ Fibonacci number series
➤ Knapsack problem
➤ Tower of Hanoi
➤ All pair shortest path by Floyd-Warshall
➤ Shortest path by Dijkstra
➤ Project scheduling

GROUP_5
Advantages of Dynamic Programming
• Dynamic programming can be used to obtain local as well as
the total optimal solution.

• Dynamic programming algorithms are generally compact


code pieces as they are based on recursive functions.

• The linear and non-linear problem, both kind of problems can


be solved using dynamic programming.

• Dynamic programming algorithms are easy to debug.

GROUP_5
Disadvantages of Dynamic Programming
• Dynamic programming uses recursion, which requires more
memory in the call stack, and leads to a stack overflow
condition in the runtime.

• It takes memory to store the solutions of each sub-problem.


There is no guarantee that the stored value will be used later
in execution.

GROUP_5
Thank You

You might also like