Dynamic programming

From WikiMD's Wellness Encyclopedia

Shortest path optimal substructure
Error creating thumbnail:
Fibonacci dynamic programming
Error creating thumbnail:
Tower of Hanoi
Error creating thumbnail:
Tower of Hanoi 4

Dynamic programming is a method for solving complex problems by breaking them down into simpler subproblems. It is a technique used in algorithm design, which finds its application across a broad range of fields from computer science to operations research, economics, and bioinformatics. The core idea behind dynamic programming is to avoid computing the same results multiple times by storing the results of these subproblems for future use.

Overview[edit | edit source]

Dynamic programming is applicable to problems exhibiting two key attributes: optimal substructure and overlapping subproblems. Optimal substructure means that the solution to a given optimization problem can be obtained by the combination of optimal solutions to its subproblems. Overlapping subproblems imply that the space of subproblems must be small, that is, a recursive algorithm solving the problem should solve the same subproblems over and over, rather than generating new subproblems.

History[edit | edit source]

The concept of dynamic programming was introduced by Richard Bellman in the 1950s. The term "dynamic programming" was originally used in the context of a mathematical method for solving dynamic decision problems. Bellman sought a name that would provide a good initial impression and thus chose "dynamic" to capture the time-varying aspect of the problems, and "programming" in the sense of planning or scheduling.

Technique[edit | edit source]

Dynamic programming solutions are implemented using two approaches: top-down with memoization or bottom-up. The top-down approach involves writing the recursive algorithm directly and then applying memoization to store the results of subproblems, typically in a hash table or an array. The bottom-up approach, on the other hand, involves solving the subproblems first and then solving the larger problems based on the solutions of these subproblems. This approach usually fills up a table based on the dependencies of subproblems.

Applications[edit | edit source]

Dynamic programming is used in a variety of disciplines:

Examples[edit | edit source]

One of the classic examples of dynamic programming is the calculation of Fibonacci numbers. A naive recursive algorithm recalculates the same values multiple times, leading to an exponential time complexity. By using dynamic programming, either through memoization or a bottom-up approach, the time complexity can be reduced to linear.

Another example is the knapsack problem, where the goal is to maximize the total value of items that can be carried in a knapsack of fixed capacity. Dynamic programming provides a polynomial time solution to this problem, which would otherwise be solved by brute force in exponential time.

Conclusion[edit | edit source]

Dynamic programming is a powerful technique that allows for the efficient solution of problems that would otherwise be intractable. By breaking down problems into smaller, manageable subproblems, dynamic programming makes it possible to tackle a wide range of challenges in algorithm design and beyond.

Dynamic programming Resources
Wikipedia
WikiMD
Navigation: Wellness - Encyclopedia - Health topics - Disease Index‏‎ - Drugs - World Directory - Gray's Anatomy - Keto diet - Recipes

Search WikiMD

Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro / Zepbound) available.
Advertise on WikiMD

WikiMD's Wellness Encyclopedia

Let Food Be Thy Medicine
Medicine Thy Food - Hippocrates

Medical Disclaimer: WikiMD is not a substitute for professional medical advice. The information on WikiMD is provided as an information resource only, may be incorrect, outdated or misleading, and is not to be used or relied on for any diagnostic or treatment purposes. Please consult your health care provider before making any healthcare decisions or for guidance about a specific medical condition. WikiMD expressly disclaims responsibility, and shall have no liability, for any damages, loss, injury, or liability whatsoever suffered as a result of your reliance on the information contained in this site. By visiting this site you agree to the foregoing terms and conditions, which may from time to time be changed or supplemented by WikiMD. If you do not agree to the foregoing terms and conditions, you should not enter or use this site. See full disclaimer.
Credits:Most images are courtesy of Wikimedia commons, and templates Wikipedia, licensed under CC BY SA or similar.

Contributors: Prab R. Tumpati, MD