Dynamic programming is essentially recursion without repetition. Developing a dynamic programming algorithm generally involves two separate steps:
• Formulate problem recursively. Write down a formula for the whole problem as a simple combination of answers to smaller subproblems.
• Build solution to recurrence from bottom up. Write an algorithm that starts with base cases and works its way up to the final solution.
Dynamic programming algorithms need to store the results of intermediate subproblems. This is often but not always done with some kind of table. We will now cover a number of examples of problems in which the solution is based on dynamic programming strategy.
The words “computer” and “commuter” are very similar, and a change of just one letter, p- m, will change the first word into the second. The word “sport” can be changed into “sort” by the deletion of…
View original post 1,769 more words