Dynamic Programming | Set 1 (Overlapping Subproblems Property) | GeeksforGeeks
Articles,  Blog

Dynamic Programming | Set 1 (Overlapping Subproblems Property) | GeeksforGeeks

Hi Guys! Welcome to GeeksforGeeks. In this video, we’ll talk about Dynamic
Programming. But, before we start, let’s first cover
some mathematical background. Consider the following function written on
the screen. We have, f(n) equals f(n-1) + f(n-2), where
n>=2. This function gives us a series of numbers
called the Fibonacci series. So, what’s special about the Fibonacci series? Well, what’s special is that it has a simple
recursive definition. As you can see, the Fibonacci series is defined
as a series of numbers in which each number is given by the sum of the two preceding numbers. For example, we get f(2) by adding f(0) and
f(1), we get f(3) by adding f(1) and f(2) and so on. Now, that we know the recursive definition
of Fibonacci numbers, we can easily write a recursive function that helps us calculate
the Fibonacci numbers. As you can see, the function fib() takes an
integer argument n. First, we check whether n


Leave a Reply

Your email address will not be published. Required fields are marked *