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
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
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?
@@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¹
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
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.
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.
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.
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??
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
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..
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?
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.
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
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
@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.
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..
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
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.
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
The general rule is to "start solving problems at the easiest part" ---> "fun(1)" then you gradualy continue towards the surrounding parts.
thank you
When examiner don't want you to pass...😂😂
Exactly 😂
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
Yo i have a doubt , how can the function goes recursion again here if it's not called separately 😅
Best method to solve this question
There was so much fun. Maja aa gaya 😂
Confused unga bunga 😂
What a brilliant question with an excellent explanation.!!!!
that was a lenthy one , how much time it is given to solve a question in GATE!
@@urstrulysandeep7209 lol
@@urstrulysandeep7209 wtf!
I love u , man!! You r such a genius person. Lots of love from Bangladesh.❤❤
Your approach for solving the problem is awesome, thanks for sharing this.
keep this up we need more videos related to GATE
Thx a lot, it was such a perfect example
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
This was a unique question and you made it very interesting to understand.
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?
Yes I am also can't understand this why we jump to again for loop before calling the function
@@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¹
@@krishwanthkishore8299tq bro
even with the trick the question takes more than 2 mints😹
you are a true magician.
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.
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
What will be the time complexity of this fun(n) ?
n
Its exponential that is O(2^n)
Why is that k
it is taken as 1 to n-1 ie k
Time consuming question ; but easy if solved *_patiently_* - which we lack during exams.... 😪😅😅😨
Lectures are good..pls upload structure and union
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.
can you explain about cmos using all logic gates in one video it is very useful
Nice approach to solve this problems.
omg i am surprise i am able to solve this ques correctly
why dont uou use {} brackets after if and for loop to make it easy to understand what's inside and what not!
nice explanation.... easy to understand..
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.
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).
I too have this doubt ,can anyone explain me?
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.
So you really need to review your mathematical skills in order to get around with this.
Thankfully this tutorial exist.
both hard but awesome
this question is so much fun
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??
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
@@manasgupta5004 thanks for you concern. Tho I was able to figure it out then.
@@badxcode no problem bro ! Have A great day☺️
7:34 "infantry"
Very Good question
The absolute KEY of this problem is not to add 1 after every iteration of the for loop. So easy to miss.
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
No. in for loop increment/decrement executed at the end of iteration so it doesn't matter whether you write ++k or k++
There is no difference in ++I or I++ in case of looping.
omg yes i thought of the same thing there for i couldny solve it
great explaination sir
I had a lot of fun😃
What a question 🫡
nicely done, excellent job......
What a mindfuck! Some Inception level shit.
as there is ++k and as it is a preincrement operator, will not k be preinremented before using it in the loop?
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..
Value of x is not being added back to x? elaborate?
Excellent Question
But I got a lot of confusion
Questions getting tougher and tougher but we will be continuously nagging till the tough Questions surrender with irritation
Why did you not consider ++k ?
Good question amazing
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?
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.
im happy to find 51
wont there be any difference of
++k or k++
??
PLEASE DO EXPLAIN
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
When they say:" Programming is easy"
is the greatest insult ever to mankind.
Why were u saying k
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
At 10:15 Victory:)
It's pre increment not post increment so , is there no difference???????
thanks sir
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)???
No here for n=4 ,for loop continues till k=3,after loop ends,so values k will be 1,2,3
@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.
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..
@@rushikothari1261 so you're saying that there is no difference between ++k and k++ in for loop?
@@khaledabdlhamid5692 yes,kindof
i think he must have assumed it as k++...because before diving into his solution i tried to solve it by myself
and the way u did it is correct
Answer is (C) 51
Hardest question I have seen so far🫡
there are very dangerous fun 😂😂😂 be carefully. 👍
I didn't understand why you were jumping on the next iteration without calling by fun(k) and fun(n-k)?
Sir i think there should be k++ instead of ++k in for loop.
Am i correct?
@@nesoacademy ok thank you sir
@@nesoacademy Why is that k
@@pranaypraneeth1740 bcus it is k
Sir please upload video on data structure...........
I think X value should be added second iteration 😇
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
great
Thank u
my my the explanation is on top but the problem took itself like 4-5 minutes totally not worth if you see time
elegant!!!!!!!
#include
int fun(int n)
{
int x=1,k;
if(n==1) return x;
for(k=1;k
You've written return x inside the for loop.
Take it outside
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
Bhai mai itna ganja marka bhi nahi soch sakta😂
😁😁
Recursion makes me dizzy ☹️
Sir, please upload videos fast
why 1+fun(1)*fun(3)+fun(2)*fun(2)+fun(3)*fun(1) IS = 1+5+4+5 Cant understand
Who did this at first shot
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
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.
Very difficult
very hard
👍
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
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
😀😀🙏
😭😤
51 eh pingaaaaaaaaa
add is so much disturbing nesooo.....plz stop it...........
matarani raksha krna... aise aise questions naa hi aaaye
😁😁
❤️❤️❤️❤️❤️
I think CSE gate exam is soo easy than EE
You cleared CSE gate exam ??
keep this up we need more videos related to GATE