top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is dynamic programming?

+1 vote
226 views

What is dynamic programming, please explain in detail along with proper example?

posted Feb 24, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

If we take a basic view over Dynamic Programming,lets see an example we have a seq of operation like 4+4+4+4+4+4+4+4+4 and ask you to tell me the sum, ans will be 36 and again if I say just add one more +4 to the line and again I ask for sum value then you will just add 36+4 i.e. 40 you just added 4 to the previous solution and didn't counted the whole expression again.So In dynamic programming you don't need to recalculate and it helps in saving time.
Dynamic programming (DP) is a general algorithm design technique for solving problems with overlapping sub-problems.
The key idea is to save answers of overlapping smaller sub-problems to avoid re-computation and properties:
->An instance is solved using the solutions for smaller instances.
->The solutions for a smaller instance might be needed multiple times, so store their results in a table.
->Thus each smaller instance is solved only once.
->Additional space is used to save time.
See this example:follow the link
https://www.topcoder.com/community/data-science/data-science-tutorials/dynamic-programming-from-novice-to-advanced/

answer Feb 26, 2016 by Shivam Kumar Pandey
Similar Questions
+3 votes

How to find shortest path in a multistage graph using dynamic programming, C/C++ code would be helpful?

+1 vote

How do you design a boolean circuit that contains at most 2 NOT gates, but may contain as many AND or OR gates that inverts three inputs? IOW: Build three inverters by using only two inverters (and an infinite amount of AND/OR).

Surprisingly, this is possible (and I even know the solution, but won't give it away just yet).

I found this puzzle again and was thinking about: How would I code a brute-force approach to this problem in Python? And to my surprise, it isn't as easy as I thought. So I'm looking for some advice from you guys
(never huts to improve ones coding skills).

...