Recursion (Solved Problem 4)

  Рет қаралды 100,460

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 135
@71GA
@71GA 4 жыл бұрын
The general rule is to "start solving problems at the easiest part" ---> "fun(1)" then you gradualy continue towards the surrounding parts.
@yogitshankar6348
@yogitshankar6348 2 жыл бұрын
thank you
@shubhamjain154
@shubhamjain154 3 жыл бұрын
When examiner don't want you to pass...😂😂
@irfanahmad-uy6dx
@irfanahmad-uy6dx Жыл бұрын
Exactly 😂
@veerrajusingamsetti352
@veerrajusingamsetti352 4 жыл бұрын
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 Жыл бұрын
Yo i have a doubt , how can the function goes recursion again here if it's not called separately 😅
@avirsingh7251
@avirsingh7251 6 жыл бұрын
Best method to solve this question
@umairalvi7382
@umairalvi7382 5 жыл бұрын
What a brilliant question with an excellent explanation.!!!!
@skyvoz
@skyvoz 4 жыл бұрын
There was so much fun. Maja aa gaya 😂
@afsarsayyed4980
@afsarsayyed4980 Жыл бұрын
Confused unga bunga 😂
@ahmed_raaphat
@ahmed_raaphat 3 жыл бұрын
Your approach for solving the problem is awesome, thanks for sharing this.
@mdadnan7985
@mdadnan7985 2 жыл бұрын
I love u , man!! You r such a genius person. Lots of love from Bangladesh.❤❤
@kostavsheoran1530
@kostavsheoran1530 5 жыл бұрын
that was a lenthy one , how much time it is given to solve a question in GATE!
@urstrulysandeep7209
@urstrulysandeep7209 Жыл бұрын
@herohera3497
@herohera3497 Жыл бұрын
@@urstrulysandeep7209 lol
@peasant12345
@peasant12345 Жыл бұрын
@@urstrulysandeep7209 wtf!
@Codality
@Codality 4 жыл бұрын
Thx a lot, it was such a perfect example
@johnychinese
@johnychinese Жыл бұрын
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 жыл бұрын
This was a unique question and you made it very interesting to understand.
@rajdeepmajumder4697
@rajdeepmajumder4697 6 жыл бұрын
keep this up we need more videos related to GATE
@mipa3868
@mipa3868 2 жыл бұрын
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
@bhavintrivedi6194
@bhavintrivedi6194 4 жыл бұрын
you are a true magician.
@pranaypraneeth1740
@pranaypraneeth1740 5 жыл бұрын
Why is that k
@zitrakzsingh7295
@zitrakzsingh7295 5 жыл бұрын
it is taken as 1 to n-1 ie k
@dipeshranadipeshrana881
@dipeshranadipeshrana881 Жыл бұрын
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 Жыл бұрын
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
@payalsagar1808
@payalsagar1808 5 жыл бұрын
even with the trick the question takes more than 2 mints😹
@Chinjukr_aac
@Chinjukr_aac 6 жыл бұрын
Lectures are good..pls upload structure and union
@prakasharja569
@prakasharja569 6 жыл бұрын
can you explain about cmos using all logic gates in one video it is very useful
@godowntown2456
@godowntown2456 3 жыл бұрын
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.
@GSN-TG
@GSN-TG 2 ай бұрын
why dont uou use {} brackets after if and for loop to make it easy to understand what's inside and what not!
@gitanjalikumari9262
@gitanjalikumari9262 4 жыл бұрын
Nice approach to solve this problems.
@lordstinson8095
@lordstinson8095 4 жыл бұрын
What will be the time complexity of this fun(n) ?
@shodipojmarydee3853
@shodipojmarydee3853 Жыл бұрын
n
@congomigue9072
@congomigue9072 6 ай бұрын
Its exponential that is O(2^n)
@samsons8279
@samsons8279 3 жыл бұрын
Time consuming question ; but easy if solved *_patiently_* - which we lack during exams.... 😪😅😅😨
@yavuzer5765
@yavuzer5765 5 жыл бұрын
7:34 "infantry"
@Aabara_ka_dabara
@Aabara_ka_dabara Жыл бұрын
nice explanation.... easy to understand..
@DJAKASHOFFICIAL998
@DJAKASHOFFICIAL998 Жыл бұрын
Very Good question
@harshitsingh480
@harshitsingh480 6 жыл бұрын
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 жыл бұрын
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
@universalcosmologist3675
@universalcosmologist3675 Жыл бұрын
this question is so much fun
@nik-ys8ki
@nik-ys8ki 4 жыл бұрын
nicely done, excellent job......
@truth-12345.
@truth-12345. Жыл бұрын
So you really need to review your mathematical skills in order to get around with this. Thankfully this tutorial exist.
@badxcode
@badxcode 4 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@badxcode no problem bro ! Have A great day☺️
@VishalKumar-uu3xm
@VishalKumar-uu3xm 2 жыл бұрын
great explaination sir
@ashishsingh7056
@ashishsingh7056 4 жыл бұрын
both hard but awesome
@sammilyeen1848
@sammilyeen1848 3 жыл бұрын
omg i am surprise i am able to solve this ques correctly
@sounavapal762
@sounavapal762 6 жыл бұрын
I had a lot of fun😃
@mohdezazulhaq1654
@mohdezazulhaq1654 3 жыл бұрын
Good question amazing
@cococookie67
@cococookie67 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 жыл бұрын
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 3 жыл бұрын
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.
@tomigoi
@tomigoi 3 ай бұрын
The absolute KEY of this problem is not to add 1 after every iteration of the for loop. So easy to miss.
@dakshpatel1769
@dakshpatel1769 Жыл бұрын
What a question 🫡
@nextrealm
@nextrealm Жыл бұрын
thanks sir
@soumyaranjanpadihari9696
@soumyaranjanpadihari9696 Жыл бұрын
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..
@sr-sunny-raj
@sr-sunny-raj 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 жыл бұрын
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 жыл бұрын
@@rushikothari1261 so you're saying that there is no difference between ++k and k++ in for loop?
@rushikothari1261
@rushikothari1261 4 жыл бұрын
@@khaledabdlhamid5692 yes,kindof
@nishchaysingh7601
@nishchaysingh7601 4 жыл бұрын
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 жыл бұрын
and the way u did it is correct
@true4189
@true4189 4 жыл бұрын
Thank u
@devukun8358
@devukun8358 2 жыл бұрын
When they say:" Programming is easy" is the greatest insult ever to mankind.
@mimSamad
@mimSamad Жыл бұрын
im happy to find 51
@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
@narendrajatav9969
@narendrajatav9969 5 жыл бұрын
Value of x is not being added back to x? elaborate?
@eftyshanabid6517
@eftyshanabid6517 2 жыл бұрын
great
@Thegrand3412
@Thegrand3412 2 жыл бұрын
elegant!!!!!!!
@Vaibhavpatil0201
@Vaibhavpatil0201 4 жыл бұрын
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
@harshitsingh480
@harshitsingh480 6 жыл бұрын
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 6 ай бұрын
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.
@MANYAKAPOOR-o8f
@MANYAKAPOOR-o8f Жыл бұрын
wont there be any difference of ++k or k++ ?? PLEASE DO EXPLAIN
@arpitkesarwani6123
@arpitkesarwani6123 6 жыл бұрын
Sir i think there should be k++ instead of ++k in for loop. Am i correct?
@arpitkesarwani6123
@arpitkesarwani6123 6 жыл бұрын
@@nesoacademy ok thank you sir
@pranaypraneeth1740
@pranaypraneeth1740 5 жыл бұрын
@@nesoacademy Why is that k
@duanedsilva
@duanedsilva 5 жыл бұрын
@@pranaypraneeth1740 bcus it is k
@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
@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
@kaushalmittal3257
@kaushalmittal3257 3 жыл бұрын
At 10:15 Victory:)
@henrypaul5676
@henrypaul5676 3 жыл бұрын
What a mindfuck! Some Inception level shit.
@mohdaslamshah2345
@mohdaslamshah2345 5 жыл бұрын
Sir please upload video on data structure...........
@sayantanghosh6700
@sayantanghosh6700 4 жыл бұрын
It's pre increment not post increment so , is there no difference???????
@interpreter001
@interpreter001 2 жыл бұрын
Why did you not consider ++k ?
@ruthviksaikalahastri7513
@ruthviksaikalahastri7513 Жыл бұрын
Answer is (C) 51
@rohitupasani3239
@rohitupasani3239 9 ай бұрын
I didn't understand why you were jumping on the next iteration without calling by fun(k) and fun(n-k)?
@missionimpossible5657
@missionimpossible5657 10 ай бұрын
Hardest question I have seen so far🫡
@user-dj9zb3bs1b
@user-dj9zb3bs1b 3 жыл бұрын
there are very dangerous fun 😂😂😂 be carefully. 👍
@damareswaramaddepalli9714
@damareswaramaddepalli9714 6 жыл бұрын
I think X value should be added second iteration 😇
@johnychinese
@johnychinese Жыл бұрын
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
@abhishekmukherjee7673
@abhishekmukherjee7673 3 жыл бұрын
#include int fun(int n) { int x=1,k; if(n==1) return x; for(k=1;k
@pradhanan9413
@pradhanan9413 3 жыл бұрын
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
@jagdeepsingh-tv4ty
@jagdeepsingh-tv4ty 5 жыл бұрын
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 жыл бұрын
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.
@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
@shibambiswas
@shibambiswas Жыл бұрын
👍
@pratikagarwala2919
@pratikagarwala2919 5 жыл бұрын
Bhai mai itna ganja marka bhi nahi soch sakta😂
@pookystudio6702
@pookystudio6702 4 жыл бұрын
😁😁
@dsdcp
@dsdcp 4 жыл бұрын
why 1+fun(1)*fun(3)+fun(2)*fun(2)+fun(3)*fun(1) IS = 1+5+4+5 Cant understand
@eslamwaled492
@eslamwaled492 Жыл бұрын
very hard
@bsaikumarreddy1413
@bsaikumarreddy1413 6 жыл бұрын
Sir, please upload videos fast
@gauravsinghgaherwar6548
@gauravsinghgaherwar6548 4 жыл бұрын
😀😀🙏
@abhishekthakur2933
@abhishekthakur2933 4 жыл бұрын
Very difficult
@kavithapriyacj4868
@kavithapriyacj4868 4 жыл бұрын
😭😤
@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
@nihalpandey5675
@nihalpandey5675 4 жыл бұрын
Who did this at first shot
@TheFeralEngineer
@TheFeralEngineer 3 жыл бұрын
Recursion makes me dizzy ☹️
@kaushikipathak9258
@kaushikipathak9258 4 жыл бұрын
matarani raksha krna... aise aise questions naa hi aaaye
@pookystudio6702
@pookystudio6702 4 жыл бұрын
😁😁
@dipeshranadipeshrana881
@dipeshranadipeshrana881 Жыл бұрын
❤️❤️❤️❤️❤️
@shuvrobrothabiswas3122
@shuvrobrothabiswas3122 Жыл бұрын
add is so much disturbing nesooo.....plz stop it...........
@gabrielbelo2289
@gabrielbelo2289 Жыл бұрын
51 eh pingaaaaaaaaa
@HarshaVardhan-kt5uu
@HarshaVardhan-kt5uu 3 жыл бұрын
I think CSE gate exam is soo easy than EE
@dakshpatel1769
@dakshpatel1769 Жыл бұрын
You cleared CSE gate exam ??
@rajdeepmajumder4697
@rajdeepmajumder4697 6 жыл бұрын
keep this up we need more videos related to GATE
Recursion (Solved Problem 5)
6:29
Neso Academy
Рет қаралды 83 М.
Recursion in C
11:12
Neso Academy
Рет қаралды 967 М.
General Discussion || Exam Date Odd Semester 2024-25 || AKTU B.Tech First & Second Year || Vimal Sir
44:10
EduRudram Success Classes Technical Education
Рет қаралды 2,4 М.
Solving Recurrences using Substitution Method (Solved Problem 3)
13:12
Arrays in C (Solved Problem 2)
10:03
Neso Academy
Рет қаралды 358 М.
Recursion (Solved Problem 1)
6:49
Neso Academy
Рет қаралды 205 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 62 М.
8.2 What is Transaction in DBMS ?
12:34
KnowledgeGATE by Sanchit Sir
Рет қаралды 473 М.
Recursion (Solved Problem 3)
4:31
Neso Academy
Рет қаралды 101 М.
What is mathematical thinking actually like?
9:44
Benjamin Keep, PhD, JD
Рет қаралды 537
Pointers (Program 8)
11:12
Neso Academy
Рет қаралды 66 М.
Types of Recursion (Part 1) | Direct & Indirect Recursion
9:45
Neso Academy
Рет қаралды 291 М.