## 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

## Rekha Tokas

Oct 10, 2016, 1:52 pmVery well explained .

## rohit sancheti

Nov 11, 2016, 7:35 amupload more videos for DP.. its a big help.. thanks in Advance!!

## Osman Tursun

Dec 12, 2016, 11:05 amwhy it is intuitively @3:01? is there a very simple method? or you just know the formula?

## Yuding Chow

Mar 3, 2017, 12:39 pmStackOverFlowException 🙁

## Siva R

Mar 3, 2017, 3:31 pmGood explanation…..good u started videos also….

## Aaish Sindwani

May 5, 2017, 10:51 amfor a problem to be solved using dp, do we need both optimal substructure and overlapping subproblems to be satisfied by the problem or any one condition makes it eligible for dp

## Just the thing u wanted !

May 5, 2017, 7:50 pmThank GG.

Nice video it is.

I did the computation of 40th fib.no. using codeblocks and i got the correct answer in 1.081seconds using recursion.

## Sona Barman

Jun 6, 2017, 4:16 amsometimes books doesn't help much to understand difficult topics but this video help much to understand dynamic programming.

## Vasu Chitti

Jul 7, 2017, 1:49 pmhelped me a lot.

## Marcos 5

Jul 7, 2017, 3:34 pmawesome!

## Vineet Kothari

Jul 7, 2017, 12:56 pmnice

## Abhilash Patel

Jul 7, 2017, 6:14 pmThe 40th one is 63245986 starting from 0 at 1st position.

## MAHTAB ALAM

Jul 7, 2017, 2:17 pmgood explanation….upload more videos on dp…it helps alot..

## Md Affan

Aug 8, 2017, 1:26 pmI think u are too fast..Looks like u are in so much hurry

## Ram

Oct 10, 2017, 2:49 pmHow you pronounced o(1) o(2^n) can tell me again

## mohan krishna

Nov 11, 2017, 10:36 amwhat is difference between big O and small o

## Nick Lordi

Nov 11, 2017, 5:13 amThis is actually great, thanks. (PS get a better microphone!)

## Vijai Murugan

Dec 12, 2017, 6:28 pmwww.hackerrank.com/coding-21

Just give a try

## southrodney

Jan 1, 2018, 1:45 pmit's FIB O NA CHI. cc in Italian makes the "ch" sound

## Peter Benc

Jan 1, 2018, 7:29 pmgeeksforgeeks has seemed like really decent utube channel, then this video started….c'mon, buy some normal microphone m8 😀

## Amit Singh

Jan 1, 2018, 4:27 pmis the base condition in recursive fib() function correct? i feel it should be if( i==1 || i==2 ) return 1;

## Carl’s On Carlson

Feb 2, 2018, 4:50 pmWho disliked this video?

## kokoinmars

Feb 2, 2018, 5:19 pmWall time in jupyter: 29.4 secs, 533 microseconds, 0 nanoseconds. This was pretty cool! 🙂

## Ankit Yadav

Mar 3, 2018, 7:05 pm102334155

## Mus Alhilo

Oct 10, 2018, 5:48 pmwhat is the functions used to calculate the time like this in python 3.6? for this algo for example

## sandeep jaisawal

Jan 1, 2019, 12:52 pmYour videos are suberrb but why the audio quality is so so so bad like old Radio player

## Aman kumar

Aug 8, 2019, 7:58 amSolution to Excercise:- (Java Implementation):- public class Main{

public static void main (String[] args) {

int n=39;

System.out.println("The fibonacci series till number "+n+" is:- ");

System.out.print(fib(n));

}

public static int fib(int num){

int res=0;

if(num<=1)

res=1;

else

res=fib(num-1)+fib(num-2);

return res;

}

}

## Ramakant Soni

Aug 8, 2019, 7:24 pmI don't know but recursion is also taking .71 seconds . You can better check https://ide.geeksforgeeks.org/HhIDrFymBx

## Vishal Kumar Saini

Sep 9, 2019, 11:36 amSar pass hona Ka re bato

## Guangwei Zhang

Sep 9, 2019, 10:08 amthanks a lot