0% found this document useful (0 votes)
11 views9 pages

File 1716180627 66059 DynamicProgramming

Uploaded by

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

File 1716180627 66059 DynamicProgramming

Uploaded by

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

Dynamic Programming

Dr. Preeti Mittal


Dynamic Programming-Introduction

● Used to solve optimization problems. Such problems can have many possible solutions.
● Each solution has a value, and we wish to find a solution with the optimal (minimum or maximum)
value.
● We call such a solution an optimal solution to the problem
● Dynamic programming is a powerful optimization technique used to solve problems by breaking them
down into smaller overlapping subproblems.
● It involves solving each subproblem only once and storing the solutions to avoid redundant
computations.
● Dynamic programming is particularly useful for optimization problems where the goal is to find the
best solution among a set of feasible solutions.
Key Concepts
● Optimal Substructure:
The optimal solution to the original problem can be constructed from optimal solutions of its
subproblems.
● Overlapping Subproblems:
The problem can be broken down into smaller, overlapping subproblems that are solved independently.
Solutions to these subproblems are stored for reuse.
● Memoization:
Memoization involves storing the solutions to subproblems in a data structure (like a table or a
memoization array) to avoid redundant computations.
● Bottom-Up Approach:
Dynamic programming can be implemented using a bottom-up approach, starting from the simplest
subproblems and gradually building up to solve the original problem.
Dynamic Programming
When developing a dynamic-programming algorithm, we follow a sequence of four
steps:
1. Characterize the structure of an optimal solution.
2. Recursively define the value of an optimal solution.
3. Compute the value of an optimal solution, typically in a bottom-up fashion.
4. Construct an optimal solution from computed information
Dijkstra Algorithm
● for finding the shortest paths from a single source vertex to all other vertices in a weighted
directed graph G =(V, E) with non-negative edge weights.
● maintains a set S of vertices whose shortest distance from the source s is known and continually
expands this set by selecting the vertex with the smallest tentative distance.
● widely used in applications such as network routing protocols and transportation systems.
Algorithm

Example
Example

You might also like