0% found this document useful (0 votes)
219 views

Dynamic Programming

Dynamic programming is a method for solving complex problems by breaking them down into simpler subproblems. It reduces the number of computations needed by solving each subproblem only once and storing the results for future use, which is especially useful when the number of repeating subproblems grows exponentially with the size of the input. Dynamic programming algorithms are used for optimization problems like finding the shortest path or fastest matrix multiplication. They examine previously solved subproblems to find the best overall solution, unlike greedy algorithms that make locally optimal choices that may not lead to a global optimum.

Uploaded by

adesloop
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
219 views

Dynamic Programming

Dynamic programming is a method for solving complex problems by breaking them down into simpler subproblems. It reduces the number of computations needed by solving each subproblem only once and storing the results for future use, which is especially useful when the number of repeating subproblems grows exponentially with the size of the input. Dynamic programming algorithms are used for optimization problems like finding the shortest path or fastest matrix multiplication. They examine previously solved subproblems to find the best overall solution, unlike greedy algorithms that make locally optimal choices that may not lead to a global optimum.

Uploaded by

adesloop
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Dynamic programming

From Wikipedia, the free encyclopedia


Not to be confused with Dynamic programming language.
In mathematics, computer science, economics, and bioinformatics, dynamic programming is a method
for solving a complex problem by breaking it down into a collection of simpler subproblems. It is
applicable to problems exhibiting the properties of overlapping subproblems[1] and optimal
substructure (described below). When applicable, the method takes far less time than naive methods
that don't take advantage of the subproblem overlap (like depth-first search).

In order to solve a given problem, using a dynamic programming approach, we need to solve different
parts of the problem (subproblems), then combine the solutions of the subproblems to reach an overall
solution. Often when using a more naive method, many of the subproblems are generated and solved
many times. The dynamic programming approach seeks to solve each subproblem only once, thus
reducing the number of computations: once the solution to a given subproblem has been computed, it is
stored or "memo-ized": the next time the same solution is needed, it is simply looked up. This approach
is especially useful when the number of repeating subproblems grows exponentially as a function of the
size of the input.

Dynamic programming algorithms are used for optimization (for example, finding the shortest path
between two points, or the fastest way to multiply many matrices). A dynamic programming algorithm
will examine the previously solved subproblems and will combine their solutions to give the best
solution for the given problem. The alternatives are many, such as using a greedy algorithm, which picks
the locally optimal choice at each branch in the road. The locally optimal choice may be a poor choice
for the overall solution. While a greedy algorithm does not guarantee an optimal solution, it is often
faster to calculate. Fortunately, some greedy algorithms (such as minimum spanning trees) are proven
to lead to the optimal solution.

For example, let's say that you have to get from point A to point B as fast as possible, in a given city,
during rush hour. A dynamic programming algorithm will look at finding the shortest paths to points
close to A, and use those solutions to eventually find the shortest path to B. On the other hand, a greedy
algorithm will start you driving immediately and will pick the road that looks the fastest at every
intersection. As you can imagine, this strategy might not lead to the fastest arrival time, since you might
take some "easy" streets and then find yourself hopelessly stuck in a traffic jam.

Sometimes, applying memoization to a naive basic recursive solution already results in an optimal
dynamic programming solution; however, many problems require more sophisticated dynamic
programming algorithms. Some of these may be recursive as well but para

You might also like