This que is so looking so interesting... For now I didn't get the concept... Will definitely return to this que after getting some more concept about recursion 🙂
@Hiyori___4 жыл бұрын
the tree makes sense but I cannot possibly understand the concept behind it. I'll come back to this when I'll have better knowledge
@VimalVimal-d7z5 ай бұрын
😂😂
@MeteorSky413 жыл бұрын
Guys watch it again to understand.. And for if(n
@krishpatil96094 жыл бұрын
After get(0) -->if(0True-->return--> control goes to *get(1)*---->> then get(n-3)=get(-2) and then if(-2True-->return to get(-2) And then evaluate print(n) ------->>>>here n=1 hence will be printed.. Then control shifts to *get(2)*---->>get(2-3)=get(-1) then control will shift to if(-1>True-->>return-->get(-1) Then printf will get evaluated and hence will print n=2 Then control shifts to *get(3)*--->>get(3-3)=get(0)-->> if(0True-->return to get(0) Evaluate printf n=3 Now control transfers to *get(4)*--->>get(4-3)=get(1)--> if(1>False-->>Hence now get(n-1) will evaluate.(note:n=1 for following statements) -->>get(1-1)=get(0)-->> if(0return at get(1)-->now printf will evaluate and print n=1 n=1 Control will shift back to parent function i.e. get(4) hence it will print n=4 Control shifts to *get(5)*--->>get(5-3)-->>get(2)--> if(2False--> get(n-1) will eval. Now n=2, get(n-1)=get(1)--> if(1False-->return to get(2)-->>get(n-1)-->get(1) And as get(1) evaluates printf will consider n=1 Hence n=1 will be printed And control shifts to get(2) i.e.get(5-3)i.e.get(n-3) Hence printf will evaluate n=2. Control will shift back to parent function get(5) Hence will print n=5 Same applicable for get(6) n=1 n=2 n=3 n=6 O/p:-- 123141251236 I understood this much...still confused. It will be more helpful if someone can elaborate it more in deapth ..🥰
@aniketrohit72872 жыл бұрын
thank you for sharing this i am also confused with that now it is much more clear
@Karthik-or2fy4 жыл бұрын
Confused program changed to simple program through your explanation 👌
@realrawt Жыл бұрын
🧢
@gopinathsubramani13203 жыл бұрын
Now I understood how multiple recursion works... Thank you bro
@nikhilanand9844 жыл бұрын
coming back in this question is really confusing. please explain more clearly and easily. I am really looking forward to it.
@phani27394 жыл бұрын
Now I understood how the gate questions be.
@hetaeramancer3 жыл бұрын
What does GATE mean?
@phani27393 жыл бұрын
@@hetaeramancer The Graduate Aptitude Test in Engineering (GATE) is anexamination that primarily tests the comprehensive understanding of various undergraduate subjects in engineering and science for admission into the Masters Program and Job in Public Sector Companies in India.
@akrzha3 жыл бұрын
@@hetaeramancer Graduate Aptitude Test in Engineering
@saswatpradhan55495 жыл бұрын
This is a very confusing problem 🙁
@AshishKhetwalАй бұрын
sir the questions you provide are really interesting and I always learn something new from them! thanks!
@ahmed65691804 жыл бұрын
how is the condition is true when n=1 and if (n
@Sake6794 жыл бұрын
No if it's n
@bablu19213 жыл бұрын
Thats not how compiler will work its just takes the argument if 1 is less than 1 which in this case it's not therefore it will execute further
@charuarora66213 жыл бұрын
and if it executes further it must not reach to get(0) part, there might be some problem with operators.
@radheshyamsingh13005 жыл бұрын
This program is really very confusing..
@Sake6794 жыл бұрын
No it ain't
@dannyboy34133 жыл бұрын
@@Sake679 stfu
@eswarvankayala56065 жыл бұрын
Please any body reply me Why we return to get(2) after get(1) At 3:44 seconds in video?? Please let me know
@zitrakzsingh72955 жыл бұрын
get(1) completes get(0) and get(-2) so after that it wont call again so it will return to its parent call that is get(2) u can think it like the student reports to the teacher after all the work ,the teacher reports to the higher authority and so on ..
@tanaykamath14155 жыл бұрын
Maybe bcoz its void!?
@nikhilanand9844 жыл бұрын
I am having the same doubt. If anyone can clear it with valid concept
@Manuevaral4 жыл бұрын
because of this is recursion.....so compiler automatically set up as recursion body so it's going get(1) to get(2);-)
@techodisha48363 жыл бұрын
I have to watch for infinite times🤯😂😂
@riturajsharma39372 жыл бұрын
These questions deserve 100.marks 😂
@shravya84923 жыл бұрын
Though your explanation is excellent, this question is quite confusing😅. I guess I will come back again after watching some more videos.
@nothingHere_X3 жыл бұрын
All are confused😅
@nishantraj97622 жыл бұрын
@@nothingHere_X hmmmm
@anonymousindinymous73065 жыл бұрын
sir pls expaliN how the OUTPUT is printed : o/p is::: 1 2 3 1 4 1 2 5 1 2 3 6 pls explain each one by one its really cant understand with out u! Thanks for above wonderful simple explanation ........
@akshitarora4704 жыл бұрын
the get(n-3) value goes less than 1, the base case is triggered, it says to the caller, just stop what ever you're doing and return, at this point whatever the poor function get(n-3) had as the value of n, it prints it out in the next line and that explains the output! Try and dry run it on a sheet, you will see how the calling goes.
@enjoylearning2103 жыл бұрын
This problem is quite confusing ..I think 🤔 I need to watch it several times ...but ur way of explanation is pretty good
@scars7073 жыл бұрын
No need to watch several times , KHABY : LIFE MADE EAZY
@manuelconte21279 ай бұрын
For all those who have had difficulty solving it, don't give up, try and try again; Sooner or later you will understand it, I assure you!
@pratikneupane9513 жыл бұрын
I didn't understand when to use gate(n-1) and when to use get(n-3) .Please help me.
@dipeshranadipeshrana8812 жыл бұрын
Its non tail recursive implement it's concept
@krishwanthkishore8299 Жыл бұрын
@@dipeshranadipeshrana881yo he didn't mention any concept like that, in tail recursion there is no need to keep record of past recursions
@riyazahmed79075 жыл бұрын
Beautiful explanation sir
@andistheinforitbutso75133 жыл бұрын
Tough one nicely done ✔ 👏
@cyethacksolutions67613 жыл бұрын
this is code for this recursion to count the Recursion output and count for calling #include int count=1; void get(int n) { if(n
@BilalBerek-tl3tq Жыл бұрын
why do you initialize count from one bro what is logic
@akashade5031 Жыл бұрын
@@BilalBerek-tl3tq to count or include first call to get(6) by main() function
@milesli2751 Жыл бұрын
I just wonder why we called the get() function 25 times, but when we run this code there are only 12 numbers are printed out?
@TruthTongue10 ай бұрын
ok so u see when we were calling the get(n-1) function, we were not able to reach the printf function. even after going to the get(n-3) function,..since the returned number were (n
@bollyedits60304 жыл бұрын
If( 1< 1 ) , this condition is false so how get(0) is evaluated ?
@Sake6794 жыл бұрын
No it's true cause 1< 1 so we go to zero function next
@dekhbhai93284 жыл бұрын
@@Sake679 no this is false 1
@MurariSingh-mw8ze3 жыл бұрын
@@dekhbhai9328 1 is not less than 1,1 is equal to 1 therefore ,condition is true
@dekhbhai93283 жыл бұрын
@@MurariSingh-mw8ze no bro there is clearly mention n
@muskansadaka94583 жыл бұрын
@GAURAV MALHOTRA ya condition is false so it will not return . so get(0) will be called . Please think it like that : if(n-1) { return; }
@radheyshreeagrawal88682 жыл бұрын
this might be wrong, as when Get(1) is formed value of N is 2. and so on. sir please reply?
@TruthTongue10 ай бұрын
it is not 2, it is -2.
@abhaypratap98983 жыл бұрын
Please suggest any book for such questions 🥺🥺🥺
@rtm48293 жыл бұрын
How after get(-2) it goes back to get(1) and then to get(2) ??
@cqwshi Жыл бұрын
same doubt. but if you understand by now,can you please explain it?
@Sake6794 жыл бұрын
Guys 1
@gitanjalikumari92624 жыл бұрын
Nice explanation sir...
@saipraneeth2311 Жыл бұрын
Sir superb explanation sir.
@TEeducation4 жыл бұрын
Awesome Explanation
@colloidalsilver1776 жыл бұрын
2:52 is that part i am confused on
@sheentoosi96426 жыл бұрын
So my understanding is that the first recursive call at the end of the sequence stops because it satisfy the "n
@tejastej27623 жыл бұрын
Superb explanation
@shahidmujawar92775 жыл бұрын
Hello, can you please make a vedio on space and time complexity in c
@rohandevaki43495 жыл бұрын
after get (5) to get(4) to so on get(1) after that it becomes get(0) and it prints o and it comes out of the function right? please reply fast sir
@friedrichmyers5 ай бұрын
Am I the only one who found it easy and got the answer first try?
@digitalgoldmine-0077 ай бұрын
could u plz make a video on how to guess the last part of recursive cuz teachers r making questions in exam which they give first part of recursive code and want us to write the other part.
@pratikagrawal86374 жыл бұрын
Superb... Content
@VikashShukla073 жыл бұрын
Amazing question.nicely explained sir
@scien-terrific70045 жыл бұрын
Ans should be 35...not 25 as when (n-1)=1 ; then (n-3)= -1 , not -2 & here @nesoacademy has done a mistake by taking (n-3)=-2, plz recheck it!
@varunpandey31723 жыл бұрын
I have a doubt that when the fun will be 1 then at that time the condition is going to get wrong bcz if (n
@thinq53393 жыл бұрын
my question is after calling get(1) in get(4) the get(1) should go back to get(2)
@codelikeapro97242 жыл бұрын
at that point get(1) is branch of get(4) not get(2)..... or you can say get(1) comes from get(4) it will simply retrun back to it...
@kaveeshnayak43285 жыл бұрын
Great explaination
@meenalsolanki92865 жыл бұрын
I have a query in condition if( n
@vivekojha48075 жыл бұрын
get(1) is called because the condition says strictly less than 1. When it calls get(0), the condition gets true and it goes back to get(1).
@jeedikantivenkat78145 жыл бұрын
Guys dont get confused . Watch it twice U will get it ..
@Dnsx_plus4 жыл бұрын
@@jeedikantivenkat7814 thanks
@arjunshaik30714 жыл бұрын
@@vivekojha4807 bro can u explain in clean manner plz
@vivekojha48074 жыл бұрын
@@arjunshaik3071 It's difficult to explain through text only. You need to visualize it. You may put the code in visualgo.net/en/recursion and visualize. But you should know how recursion stack works.
@s.o.s62013 жыл бұрын
take a bow... god of C
@PriyaSingh-ul4hl4 жыл бұрын
What if we are asked about print output. Can anybody explain please?
@VikasKumar-xu8if3 жыл бұрын
Output: 12131241213512131246 and the function will be called 41 times , there is some mistake in above solution (explained in video) as you can check by running the program and counting the calls by a global variable initialized with zero.
@uraharakisuke53052 жыл бұрын
@@VikasKumar-xu8if 41 toh option mein bhi nahi hai
@b.himanshu26544 жыл бұрын
Excellent
@compangit1524 Жыл бұрын
Answer is Option B, 25
@Anonymous____________A7213 жыл бұрын
Can you explain with output
@vivekojha48075 жыл бұрын
Thank you sir.
@sushantkumar49173 жыл бұрын
Before starting video I made guss like (1+3)*6 = 24, so answer should be 25 😂😂✌️
@getayawkaltamrat13143 жыл бұрын
you will end up getting an A if you keeping guessing like this :D
@ruthviksaikalahastri7513 Жыл бұрын
Answer is (B) 25
@HelloWorld404082 жыл бұрын
Thank you SIr
@talentotech-p1e Жыл бұрын
I wonder what real program/algorithm would behave like that
@nedstark97345 жыл бұрын
If you solved it in your mind you gonna confuse at some time so I solved it using method II and got correct answer on my first try
@dilsumankaur65435 жыл бұрын
Which 2nd method
@raosahebkolgatram92933 жыл бұрын
Is this indirect recursion?
@harmankaur39382 жыл бұрын
Thank you :)
@nour_780 Жыл бұрын
Thank you
@nikp99994 жыл бұрын
Nice problem.
@NandanKumar-vq9iw8 ай бұрын
It is wrong:- when get(1) called the function returns there is no way to call get(0)
@stepsjr3 ай бұрын
Its not 1 = 1 its n < 1
@psarvani69945 жыл бұрын
Sir how have you gone from step get(4) to get (5) as the value n will be 1 and we need to satisfy the condition n
@red_l66345 жыл бұрын
yes thats why he writes +2 calls.he means that get(4-3)=get(1) plus what g(1) calls. But we know what get(1) calls!!! it calls get(0) and get(-2) n
@brocklesnarufcchamp14 жыл бұрын
This question's not worth the trouble for 2 marks
@DSAbyraj17293 жыл бұрын
super question
@hritushreemog93335 жыл бұрын
how there is 7 calls , i mean i got confused, i am getting 6 calls which gives me total 24 calls can you elaborate please
@zitrakzsingh72955 жыл бұрын
count the get(6) call too
@ExploreWithShiva_4 жыл бұрын
First we call get(6) till get(0) total 7 calls
@ExploreWithShiva_4 жыл бұрын
Then iteration
@VikasKumar-xu8if3 жыл бұрын
"get" function will be called 41 times , there is some mistake in above solution (explained in video) as you can check by running the program and counting the calls by a global variable initialized with zero.
@asharya53113 жыл бұрын
@@VikasKumar-xu8if But 41 is not present in the options.
@boyarangaswamy34305 ай бұрын
here first iteration get(1)
@stepsjr3 ай бұрын
Its not 1 = 1 its n < 1
@charuarora66213 жыл бұрын
But when get(1) function is called .. condition(n
@areebshaikh3213 жыл бұрын
Yes. After get (1) is called ,as (n
@chakradharthota11003 жыл бұрын
Here get function is not in the if function.. so here condition failed if is not evaluted .. so control reaches to get (0)👍
@true41894 жыл бұрын
Thank u
@bellalmahtab82203 жыл бұрын
Understood
@mlungisinkomo23822 жыл бұрын
DUDE YOU ARE DOPE
@harshitpathak53763 жыл бұрын
So much confusion 😕😐..
@sagarsahu69594 жыл бұрын
This question is very interesting ❤️
@latasharma73284 жыл бұрын
N value????
@mohammadtaqiahsan56203 жыл бұрын
May I know your name sir?
@psarvani69945 жыл бұрын
Can someone explain me the answer
@shivamrohatgi44953 ай бұрын
not able to understand this one
@gauravnegi78715 жыл бұрын
But there are 24 calls not 25
@BilalBerek-tl3tq Жыл бұрын
you did not count first call from main function for get(6).
@jeedikantivenkat78145 жыл бұрын
Guys dont get confused Its very easy
@devkego53145 жыл бұрын
stfu mate
@arjunshaik30714 жыл бұрын
Can u explain it
@dagesrinu31303 жыл бұрын
U R right bro
@real_kim84553 жыл бұрын
When we get the 1st get(0) after that why aren't we pop'ing out all the way back to get(6) & instead going to get(-2)? Unable to understand. Please explain.
@shaiksameerbasha47022 жыл бұрын
👍
@shubhamjain1543 жыл бұрын
This paper setter will definitely go in hell....
@nahidmony7860 Жыл бұрын
Brainstrorming
@dilipkumar-ku5jx Жыл бұрын
fun fact: activation record also stores execution line where the function last left its execution and when it returns it starts executing from next line of execution line stored. I hope this comment will reduce the confusions if there are any +-------------------------------------+ | Activation Record for 'get' | +-------------------------------------+ | Parameters: | | | +-------------------------------------+ | Local Variables: | | | +-------------------------------------+ | Return Value: | | | +-------------------------------------+ | Execution Line: | | get(n-1); | +-------------------------------------+
@cqwshi Жыл бұрын
do you mean this by saying how the execution flow was from get (n-1) until n =0 and after this the flow was from only (n