Recursion (Solved Problem 4)

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 135

  • @71GA
    @71GA 4 роки тому +53

    The general rule is to "start solving problems at the easiest part" ---> "fun(1)" then you gradualy continue towards the surrounding parts.

  • @shubhamjain154
    @shubhamjain154 3 роки тому +55

    When examiner don't want you to pass...😂😂

  • @veerrajusingamsetti352
    @veerrajusingamsetti352 4 роки тому +10

    i understand this problem very easily. you have divided bigger problem into sub problems which made easy to understand
    you are really great sir
    thank you

    • @krishwanthkishore8299
      @krishwanthkishore8299 Рік тому +1

      Yo i have a doubt , how can the function goes recursion again here if it's not called separately 😅

  • @avirsingh7251
    @avirsingh7251 5 років тому +19

    Best method to solve this question

  • @skyvoz
    @skyvoz 4 роки тому +30

    There was so much fun. Maja aa gaya 😂

  • @umairalvi7382
    @umairalvi7382 5 років тому +10

    What a brilliant question with an excellent explanation.!!!!

  • @kostavsheoran1530
    @kostavsheoran1530 5 років тому +46

    that was a lenthy one , how much time it is given to solve a question in GATE!

  • @mdadnan7985
    @mdadnan7985 2 роки тому +3

    I love u , man!! You r such a genius person. Lots of love from Bangladesh.❤❤

  • @ahmed_raaphat
    @ahmed_raaphat 3 роки тому +3

    Your approach for solving the problem is awesome, thanks for sharing this.

  • @rajdeepmajumder4697
    @rajdeepmajumder4697 5 років тому +5

    keep this up we need more videos related to GATE

  • @Codality
    @Codality 4 роки тому +5

    Thx a lot, it was such a perfect example

  • @johnychinese
    @johnychinese Рік тому +2

    The left hand side of the equation is already what is fed into the x in the first iteration. So in the second iteration all of that first iteration solution becomes your new x

  • @omgaikwad0510
    @omgaikwad0510 3 роки тому +1

    This was a unique question and you made it very interesting to understand.

  • @mipa3868
    @mipa3868 2 роки тому +3

    thanks sir for amazing content..
    sir doubt at 3:40...sir when we are calculating fun(5)...and we encounter fun(1) and fun(4) in the first iteration ..shouldn't the control go to fun(1) and then fun(4)....why are we jumping to second iteration directly?

    • @msgudaduramath4980
      @msgudaduramath4980 2 роки тому

      Yes I am also can't understand this why we jump to again for loop before calling the function

    • @krishwanthkishore8299
      @krishwanthkishore8299 Рік тому

      ​@@msgudaduramath4980yo it actually goes based on the for loop , when k=1 , we find x value for k=1 and let's take this x as x¹ and since there's a ' return ' statement , it return ' x¹ ' value to the next iteration aka when k=2 and x=x+f(k) +f(n-k) and here the value of x in the left hand side is what we found in the previous iteration (x¹) and instead of applying directly x¹ here we substitute the value of x¹

    • @msgudaduramath4980
      @msgudaduramath4980 Рік тому

      ​@@krishwanthkishore8299tq bro

  • @payalsagar1808
    @payalsagar1808 5 років тому +17

    even with the trick the question takes more than 2 mints😹

  • @bhavintrivedi6194
    @bhavintrivedi6194 4 роки тому +1

    you are a true magician.

  • @dipeshranadipeshrana881
    @dipeshranadipeshrana881 Рік тому +3

    Many people are confused why we don't add 1 for 2nd, 3rd and 4th iteration of for loop. Why we add 1 in function fun(5) only.

    • @johnychinese
      @johnychinese Рік тому +1

      The left hand side of the equation is already what is fed into the x in the first iteration. So in the second iteration all of that first iteration solution becomes your new x

  • @lordstinson8095
    @lordstinson8095 4 роки тому +11

    What will be the time complexity of this fun(n) ?

  • @pranaypraneeth1740
    @pranaypraneeth1740 5 років тому +3

    Why is that k

  • @samsons8279
    @samsons8279 3 роки тому +2

    Time consuming question ; but easy if solved *_patiently_* - which we lack during exams.... 😪😅😅😨

  • @Chinjukr_aac
    @Chinjukr_aac 5 років тому +2

    Lectures are good..pls upload structure and union

  • @godowntown2456
    @godowntown2456 3 роки тому +1

    Enjoy when you read this cause I rarely comment on any video. But Neso, you are a channel of perfection.I am a perfectionist and I know one when I see one. You should post a documentry in your channel about Neso and PEOPLE(or person) behind it.
    I am sure all viewers will agree on this.

  • @prakasharja569
    @prakasharja569 5 років тому +3

    can you explain about cmos using all logic gates in one video it is very useful

  • @gitanjalikumari9262
    @gitanjalikumari9262 4 роки тому

    Nice approach to solve this problems.

  • @sammilyeen1848
    @sammilyeen1848 3 роки тому +1

    omg i am surprise i am able to solve this ques correctly

  • @GSN-TG
    @GSN-TG Місяць тому +1

    why dont uou use {} brackets after if and for loop to make it easy to understand what's inside and what not!

  • @Aabara_ka_dabara
    @Aabara_ka_dabara Рік тому

    nice explanation.... easy to understand..

  • @cococookie67
    @cococookie67 5 років тому +5

    Sir, can u please explain to me why you weren't adding 1 for each iteration? We had x=x+fun(k)*fun(n-k) but u only added that 1 for x once, for the first iteration. I don;t understand why.

    • @vivekojha4807
      @vivekojha4807 5 років тому +8

      It's because x+fun(k)*fun(n-k) becomes your new value of x. The new value of x gets added to fun(k)*fun(n-k).

    • @mariappanduraisamy862
      @mariappanduraisamy862 3 роки тому

      I too have this doubt ,can anyone explain me?

    • @seven7846
      @seven7846 2 роки тому +1

      I don't know that is the right explantaion but here is what i think about that:-
      When the loop is working then only this statement ( x=x+fun(k)*fun(n-k)) is execute
      so, (return x) statement won't execute till loop doesn't finish it's working ,so when when the working of loop is finish the we have this statement
      (fun(3)= x =1+fun(1)*fun(2)+ fun(2)*fun(1) ) this is the only equation left when command goes to return x so that's why we added 1 for x once.
      (sorry for bad grammer), i hope you understand it.

  • @truth-12345.
    @truth-12345. Рік тому

    So you really need to review your mathematical skills in order to get around with this.
    Thankfully this tutorial exist.

  • @ashishsingh7056
    @ashishsingh7056 4 роки тому +1

    both hard but awesome

  • @universalcosmologist3675
    @universalcosmologist3675 Рік тому

    this question is so much fun

  • @badxcode
    @badxcode 4 роки тому +1

    when you entered the for loop for second time in 3:28 with value k = 2, why din you add 1 again.
    fun(5) = x + fun(1) * fun (4) {for k = 1}
    next when k = 2 then it was supposed to be fun(5) = x + fun(1) * fun(4) + fun(2) * fun (3) ..and so on {k = 2}
    why you din add (x) once again??

    • @manasgupta5004
      @manasgupta5004 4 роки тому +1

      No as because value of x changes to last one after each iteration so actually we just need to add new one to the last one not point of adding whole

    • @badxcode
      @badxcode 4 роки тому

      @@manasgupta5004 thanks for you concern. Tho I was able to figure it out then.

    • @manasgupta5004
      @manasgupta5004 4 роки тому +1

      @@badxcode no problem bro ! Have A great day☺️

  • @yavuzer5765
    @yavuzer5765 5 років тому +2

    7:34 "infantry"

  • @DJAKASHOFFICIAL998
    @DJAKASHOFFICIAL998 Рік тому

    Very Good question

  • @tomigoi
    @tomigoi 2 місяці тому

    The absolute KEY of this problem is not to add 1 after every iteration of the for loop. So easy to miss.

  • @harshitsingh480
    @harshitsingh480 5 років тому +3

    I think there is error in question it should be k++. (as if it is ++k pre increment operatorthen in the first iteration itself it would be x=1+fun(2 )+fun(3)) . if i am wrong please point me out by making video.please help neso academy and keep uo good work you are doing

    • @nedstark9734
      @nedstark9734 5 років тому +10

      No. in for loop increment/decrement executed at the end of iteration so it doesn't matter whether you write ++k or k++

    • @ayushrawat7951
      @ayushrawat7951 2 роки тому

      There is no difference in ++I or I++ in case of looping.

    • @palestinianlivesmatter7861
      @palestinianlivesmatter7861 Рік тому

      omg yes i thought of the same thing there for i couldny solve it

  • @VishalKumar-uu3xm
    @VishalKumar-uu3xm 2 роки тому

    great explaination sir

  • @sounavapal762
    @sounavapal762 5 років тому +1

    I had a lot of fun😃

  • @dakshpatel1769
    @dakshpatel1769 Рік тому +1

    What a question 🫡

  • @nik-ys8ki
    @nik-ys8ki 4 роки тому

    nicely done, excellent job......

  • @henrypaul5676
    @henrypaul5676 3 роки тому +3

    What a mindfuck! Some Inception level shit.

  • @soumyaranjanpadihari9696
    @soumyaranjanpadihari9696 Рік тому +1

    as there is ++k and as it is a preincrement operator, will not k be preinremented before using it in the loop?

    • @dakshpatel1769
      @dakshpatel1769 Рік тому

      When condition is true, then code written inside loop will executed first and then after increment will happen...
      Here pre increment doesn't matter because eventually it will be incremented..

  • @narendrajatav9969
    @narendrajatav9969 5 років тому +1

    Value of x is not being added back to x? elaborate?

  • @Vaibhavpatil0201
    @Vaibhavpatil0201 4 роки тому +2

    Excellent Question
    But I got a lot of confusion

  • @andistheinforitbutso7513
    @andistheinforitbutso7513 2 роки тому

    Questions getting tougher and tougher but we will be continuously nagging till the tough Questions surrender with irritation

  • @interpreter001
    @interpreter001 2 роки тому +1

    Why did you not consider ++k ?

  • @mohdezazulhaq1654
    @mohdezazulhaq1654 3 роки тому

    Good question amazing

  • @harshitsingh480
    @harshitsingh480 5 років тому +2

    I am completely unable to understand the soln also that why you added fun 2 and fun 3
    rather you should have written 1+fun(2)*fun(3) why you mussed out one for k=2?

    • @congomigue9072
      @congomigue9072 5 місяців тому

      I guess am 5 years late, but the reason is that the '1' you are asking about has been added in those fun 2 and fun 3 on an individual level, like if you open up fun 2 and fun 3, you'll realize that 1 was taken care of if broken down, it contains the 1 you are worried about.

  • @mimSamad
    @mimSamad Рік тому

    im happy to find 51

  • @MANYAKAPOOR-o8f
    @MANYAKAPOOR-o8f 11 місяців тому

    wont there be any difference of
    ++k or k++
    ??
    PLEASE DO EXPLAIN

  • @universalstarcpu9522
    @universalstarcpu9522 3 роки тому

    I don't know but I did the sm manner by pausing the video and I did it in 8 min
    It is too time taker prblm
    If we sit on this type of prblms in gate exam we get less marks as even if a small mistake in adding may result wrong ans

  • @devukun8358
    @devukun8358 2 роки тому

    When they say:" Programming is easy"
    is the greatest insult ever to mankind.

  • @roshanmhatre8810
    @roshanmhatre8810 4 роки тому

    Why were u saying k

    • @yu_a_vi4427
      @yu_a_vi4427 4 роки тому

      He said the loop will ittrate for n-1 times which is true for (k= 1 ; k< n ;)
      You are confused about if the loop will ittrate for n times as if in for (k=0 ; k

  • @kaushalmittal3257
    @kaushalmittal3257 3 роки тому

    At 10:15 Victory:)

  • @sayantanghosh6700
    @sayantanghosh6700 4 роки тому +1

    It's pre increment not post increment so , is there no difference???????

  • @nextrealm
    @nextrealm Рік тому

    thanks sir

  • @the_ocean_eyes
    @the_ocean_eyes 3 роки тому

    In 2nd iteration when we are calculating fun(4) i.e n=4 and k=2 ... So why are we not taking x= 1 + fun(1) + fun(4) + fun(2) + fun(4-2=2)???

    • @msgudaduramath4980
      @msgudaduramath4980 2 роки тому

      No here for n=4 ,for loop continues till k=3,after loop ends,so values k will be 1,2,3

  • @sr-sunny-raj
    @sr-sunny-raj 4 роки тому +4

    @Neso Academy , Sir their is ++k in the for loop which is pre increment so in the first iteration it would be x = x + fun(2) * fun(3), but you are doing something else.
    please sir kindly solve my issue.

    • @rushikothari1261
      @rushikothari1261 4 роки тому +4

      Steps of For Loop:
      1.Initialization
      2.Check condition
      3.Execute Body Operation
      4. Increment .
      Therefore For first iteration, x= x+fun(1)+fun(4)
      After Completion of this Body expression K is incremented..

    • @khaledabdlhamid5692
      @khaledabdlhamid5692 4 роки тому +4

      @@rushikothari1261 so you're saying that there is no difference between ++k and k++ in for loop?

    • @rushikothari1261
      @rushikothari1261 4 роки тому +4

      @@khaledabdlhamid5692 yes,kindof

    • @nishchaysingh7601
      @nishchaysingh7601 4 роки тому +1

      i think he must have assumed it as k++...because before diving into his solution i tried to solve it by myself

    • @nishchaysingh7601
      @nishchaysingh7601 4 роки тому +1

      and the way u did it is correct

  • @ruthviksaikalahastri7513
    @ruthviksaikalahastri7513 Рік тому

    Answer is (C) 51

  • @missionimpossible5657
    @missionimpossible5657 10 місяців тому

    Hardest question I have seen so far🫡

  • @user-dj9zb3bs1b
    @user-dj9zb3bs1b 3 роки тому

    there are very dangerous fun 😂😂😂 be carefully. 👍

  • @rohitupasani3239
    @rohitupasani3239 8 місяців тому

    I didn't understand why you were jumping on the next iteration without calling by fun(k) and fun(n-k)?

  • @arpitkesarwani6123
    @arpitkesarwani6123 5 років тому +5

    Sir i think there should be k++ instead of ++k in for loop.
    Am i correct?

  • @mohdaslamshah2345
    @mohdaslamshah2345 5 років тому

    Sir please upload video on data structure...........

  • @damareswaramaddepalli9714
    @damareswaramaddepalli9714 5 років тому +4

    I think X value should be added second iteration 😇

    • @johnychinese
      @johnychinese Рік тому +1

      The left hand side of the equation is already what is fed into the x in the first iteration. So in the second iteration all of that first iteration solution becomes your new x

  • @eftyshanabid6517
    @eftyshanabid6517 2 роки тому

    great

  • @true4189
    @true4189 4 роки тому

    Thank u

  • @mrunalshende1663
    @mrunalshende1663 4 роки тому

    my my the explanation is on top but the problem took itself like 4-5 minutes totally not worth if you see time

  • @Thegrand3412
    @Thegrand3412 2 роки тому

    elegant!!!!!!!

  • @abhishekmukherjee7673
    @abhishekmukherjee7673 3 роки тому

    #include
    int fun(int n)
    {
    int x=1,k;
    if(n==1) return x;
    for(k=1;k

    • @pradhanan9413
      @pradhanan9413 3 роки тому +1

      You've written return x inside the for loop.
      Take it outside

    • @aniketrohit7287
      @aniketrohit7287 2 роки тому

      no you have not correctly write code my code gives output 51
      #include

      int fun(int n){
      int x=1,k;
      if(n==1) return x;
      for(k=1;k

  • @pratikagarwala2919
    @pratikagarwala2919 5 років тому +3

    Bhai mai itna ganja marka bhi nahi soch sakta😂

  • @TheFeralEngineer
    @TheFeralEngineer 3 роки тому

    Recursion makes me dizzy ☹️

  • @bsaikumarreddy1413
    @bsaikumarreddy1413 5 років тому

    Sir, please upload videos fast

  • @dsdcp
    @dsdcp 4 роки тому

    why 1+fun(1)*fun(3)+fun(2)*fun(2)+fun(3)*fun(1) IS = 1+5+4+5 Cant understand

  • @nihalpandey5675
    @nihalpandey5675 4 роки тому

    Who did this at first shot

  • @jagdeepsingh-tv4ty
    @jagdeepsingh-tv4ty 5 років тому +3

    sir i think you forget to mention x+fun(2)*fun(3) [x in these cases]
    my computer executes the code and gives me 81 as answer

    • @Mets0311
      @Mets0311 5 років тому +3

      You made a mistake. This program executes 51.
      The mistake you made was on " x = x + fun(k) * fun(n-k); "
      What you did was add the two recursive calls instead of multiplying. Which would have gave you 81.

  • @abhishekthakur2933
    @abhishekthakur2933 4 роки тому

    Very difficult

  • @eslamwaled492
    @eslamwaled492 Рік тому

    very hard

  • @shibambiswas
    @shibambiswas Рік тому

    👍

  • @cyethacksolutions6761
    @cyethacksolutions6761 3 роки тому

    in order to visulise this Problem i Have Modified the program Little bit:
    #include
    int fun(int n )
    {
    int x=1,k;
    if(n==1)
    return x;
    for(int k=1;k

    • @cyethacksolutions6761
      @cyethacksolutions6761 3 роки тому

      also i follow different way to solve this problem:
      start evaluating the fun(5) to Fun(1) now start finding the values of Fun(1 to 4) , it repeat the last calculating value of fun(2)=1+fun(1)*fun(1), so fun(2)=2 similarly find fun(3) . I might sound like the same way he explain in video but, the method is different and lengthy, i make 2 time mistake while solving it by my own

  • @gauravsinghgaherwar6548
    @gauravsinghgaherwar6548 3 роки тому

    😀😀🙏

  • @kavithapriyacj4868
    @kavithapriyacj4868 4 роки тому +2

    😭😤

  • @gabrielbelo2289
    @gabrielbelo2289 Рік тому

    51 eh pingaaaaaaaaa

  • @shuvrobrothabiswas3122
    @shuvrobrothabiswas3122 Рік тому

    add is so much disturbing nesooo.....plz stop it...........

  • @kaushikipathak9258
    @kaushikipathak9258 4 роки тому +2

    matarani raksha krna... aise aise questions naa hi aaaye

  • @HarshaVardhan-kt5uu
    @HarshaVardhan-kt5uu 3 роки тому

    I think CSE gate exam is soo easy than EE

  • @rajdeepmajumder4697
    @rajdeepmajumder4697 5 років тому

    keep this up we need more videos related to GATE