Types of Recursion (Part 1) | Direct & Indirect Recursion

  Рет қаралды 291,438

Neso Academy

Neso Academy

Күн бұрын

Пікірлер
@AJewFR0
@AJewFR0 5 жыл бұрын
This is high quality for a KZbin channel on CS. Great Job from the US.
@hetaeramancer
@hetaeramancer 3 жыл бұрын
@@sohamshinde1258 he said he's from the US
@sayantanmondal8630
@sayantanmondal8630 3 жыл бұрын
All are INDIANS
@Ppu_for_a_reason10yrs
@Ppu_for_a_reason10yrs 6 ай бұрын
​@@hetaeramancer 😂 he wasted his time on Duolingo.✅
@HosBarGamers
@HosBarGamers 3 жыл бұрын
I have never found such a channel that is so good at explaining CS stuff. Great job.
@aradhanasoni6616
@aradhanasoni6616 4 жыл бұрын
I've never seen any sir as you explain about C language. You're the God of C. Love you sir 😍
@RiseWithShivam
@RiseWithShivam 3 жыл бұрын
Ya, He is God of C😍😍
@name-iq7on
@name-iq7on 11 ай бұрын
Bro where were you this whole timeeeeee,,, is your words are magic or what ,, why am getting your explantion straight in my brain ,,, seriously bro u made my thinking better ,,, where so many were eating my brain, also i m in love with your explanation, the way u r explaning is incredible.
@saifulislamsarfaraz
@saifulislamsarfaraz 5 жыл бұрын
one day there will be billions of viewers in your tutorial
@sarfaraz6582
@sarfaraz6582 5 жыл бұрын
it should be but people ain't too much interested in studying unlikely they are busy unnecessary drama..
@Dnsx_plus
@Dnsx_plus 4 жыл бұрын
@@sarfaraz6582 You got a girlfriend?
@fortnitelove8129
@fortnitelove8129 4 жыл бұрын
Don't waste time in bf or gf or any other human being, invest only on YOU
@Dnsx_plus
@Dnsx_plus 4 жыл бұрын
@@fortnitelove8129 yeah forreal
@hetaeramancer
@hetaeramancer 3 жыл бұрын
not really billions, but several millions!
@MrTomro
@MrTomro 6 жыл бұрын
Amazing, I like the stack diagram, helps u visualize the whole process
@sanjaykarthicks1226
@sanjaykarthicks1226 3 жыл бұрын
I really like NESO ACADEMY ❤️ It's really effective for me while preparing for my C paper in sem2 Thank you so much sir for your lectures
@surbhitamrakar1638
@surbhitamrakar1638 4 жыл бұрын
Thank you so much sir for this series.I found recursion very hard before I watched your lectures..but now I am comfortable with recursion. Thanks alott.
@matematleta492
@matematleta492 2 ай бұрын
Best explanation of this material on YT. Thank you!
@piyushji2312
@piyushji2312 4 жыл бұрын
One of the best online playlist to learn recursion . Sir please if you could make a series on backtracking and dynamic programming as well. _/\_
@FarhanAli-gd2qv
@FarhanAli-gd2qv 3 жыл бұрын
I totally agree with you.
@enjoylearning210
@enjoylearning210 3 жыл бұрын
Background music at last really motivates me 😊😊 and indulge myself in that thought ..I have achieved something , it's just becoz of ur awesome video series ...really best 👍 . Not so long and not so short , perfect one
@yusraabdullah8261
@yusraabdullah8261 2 жыл бұрын
Now I subscribe your channel for giving us a beautiful example of indirect recursion..... Very beautifully explained...... Now my concepts are clear ❤️Thanks sir..... You deserve millions likes.... And you'll get soon
@accessdenied9393
@accessdenied9393 3 жыл бұрын
Example in same factorial function indirectly: [Fact() can calc the factorial of at least 20 and -20, if you calc fact(21) or fact(-21), this will exceeds the range of long integers, and thus you ended up with wrong results] long Fact(int a) { if (a > 0) return posFact(a); else if (a < 0) return negFact(a); else return 1; } long posFact(int a) { if(a == 1) return a; else return a * Fact(a-1); } long negFact(int a) { if(a == -1) return a; else return -a * Fact(a+1); }
@kesavae9552
@kesavae9552 3 жыл бұрын
Mission accomplished, respect++
@anchalagrawal4332
@anchalagrawal4332 4 жыл бұрын
Sir you explained it very well . nobody can explain like this 👌👌👌👌
@bruhmetsaiharnet6595
@bruhmetsaiharnet6595 3 жыл бұрын
Thank you,God bless you
@pariminagalakshmi5517
@pariminagalakshmi5517 4 жыл бұрын
sir,thank you soo much .... these videos are very helpful for many students like me.. once again thank you soo much sir...
@mani_vk_29
@mani_vk_29 4 жыл бұрын
Answer for homework problem is 15. Thank you
@Adityasharma-oe8zp
@Adityasharma-oe8zp 3 жыл бұрын
I've done the same question like this Int a=1; Void main() { Void fun(int); If (a>10) Return; If(a%2!=0) Printf(" %d",a+1); Else fun(a); a++; main(); } void fun(int b) { printf(" %d",b-1); a++; main(); }
@hetaeramancer
@hetaeramancer 3 жыл бұрын
what's the output?
@Adityasharma-oe8zp
@Adityasharma-oe8zp 3 жыл бұрын
@@hetaeramancer output is same as in the question.... I've tested it after that i posted it
@batsmanist
@batsmanist Жыл бұрын
Thank you for this class. It opened my mind to a hard task I was doing.
@MorrowSind
@MorrowSind 6 жыл бұрын
Nice and very well explained.
@rileshkhatri1209
@rileshkhatri1209 3 жыл бұрын
Since we are using tail recursion here with void function we don't really need the return statement.We will still get the same output even without a return statement
@sujoymollick1239
@sujoymollick1239 3 жыл бұрын
Amazing. Go on.
@manoharsinghrawat1859
@manoharsinghrawat1859 2 жыл бұрын
Very awesome lectures 👌
@zeshanmushtaq5295
@zeshanmushtaq5295 6 жыл бұрын
Love from Pakistan thanks too much sir g
@rizwanriaz7595
@rizwanriaz7595 6 жыл бұрын
Excellent
@sajadulislamdipu1954
@sajadulislamdipu1954 4 жыл бұрын
Thanks sir ❤❤❤
@mohandask1328
@mohandask1328 2 жыл бұрын
if we are not using recursion, the same output can be get by....... int fun(int n); int main() { int i; for(i=1;i
@basavaraj9590
@basavaraj9590 2 жыл бұрын
This one is which problem Bhai.. print o/p upto from 1 to 10 numbers
@Vinay_singh01
@Vinay_singh01 6 жыл бұрын
GOOD sir
@arghyasaha8370
@arghyasaha8370 10 ай бұрын
Great explanation❤
@raktimagupta9605
@raktimagupta9605 9 ай бұрын
your voice >>>
@nityanandrai5341
@nityanandrai5341 5 жыл бұрын
a very simple code for above question #include using namespace std; void fun(int n) { if(n==0) { return; } fun(n-1); if(n%2==0) cout
@iluvyunie
@iluvyunie 4 жыл бұрын
Wow. This is really helpful
@chandanpurbey1058
@chandanpurbey1058 5 жыл бұрын
Well explained.
@Karan_mahra
@Karan_mahra 6 жыл бұрын
Respect....
@nikhilguleria4313
@nikhilguleria4313 2 жыл бұрын
it's wonderfull explanation
@mipa3868
@mipa3868 2 жыл бұрын
wow..amazing sir at 5:04...in cases like these ...will post increment operator not be a problem?
@anirudh4692
@anirudh4692 3 жыл бұрын
that's neat and clear...gud job
@shashank6803
@shashank6803 5 жыл бұрын
By direct Recursion it looks like public class Print { public static int calculate(int n) { if(n>10) { return 0 ; } if(n%2==0)//even { System.out.print(n-1+" ") ; return calculate(n+1); }else{ System.out.print((n+1)+" "); return calculate(n+1); } } public static void main(String[] args) { int n=1 ; calculate(n); } }
@compangit1524
@compangit1524 Жыл бұрын
Comment for myself: 1st step is find the recursive flow, 2nd step is find the base case. The base case is the case that doesn't need to call the function itself again.
@-HarishkumarG
@-HarishkumarG 3 жыл бұрын
you are the best
@kushalavardhan
@kushalavardhan 3 жыл бұрын
in the user defined functions, we wrote If statement and we related values of n and 10. here, what does n mean??? there is no definition of n in any of the functions. in global scope (if compiles goes out) n value is "1". how each function call remembers the value of "n"??
@stranger5548
@stranger5548 6 ай бұрын
Same doubt pls ans
@sabreenparween9696
@sabreenparween9696 4 жыл бұрын
Really osm concept😍
@sayyedaaman5719
@sayyedaaman5719 2 жыл бұрын
Amazing video thank you for explain it
@tanishajaiswal7559
@tanishajaiswal7559 4 жыл бұрын
You made it seem so easy
@cheery3469
@cheery3469 8 ай бұрын
Omg...where i was... thnk u
@HelloWorld40408
@HelloWorld40408 Жыл бұрын
Thank You sir
@anurani548
@anurani548 5 жыл бұрын
Very nice explanation
@daverussell4052
@daverussell4052 3 жыл бұрын
you basicly dont need the return because void functions is a non-return functions
@juliuskamara1348
@juliuskamara1348 2 жыл бұрын
Thank you very much. Do we still return statement for void return type?
@harshvardhananand8795
@harshvardhananand8795 5 жыл бұрын
Nicely explained
@TehreemAyesha
@TehreemAyesha 4 жыл бұрын
What would have happened if there was pre increment in place of post increment?
@ritikshrivastava9442
@ritikshrivastava9442 4 жыл бұрын
If somebody wants to know the same program without indirect recursion 👇 int main() { for(int i = 1; i
@codemonster8240
@codemonster8240 3 жыл бұрын
realy helpfull
@b.himanshu2654
@b.himanshu2654 4 жыл бұрын
Superb
@rohanghosh9700
@rohanghosh9700 5 жыл бұрын
Sir ouput should show in opposite order because it was in stack
@sasikumartangala5001
@sasikumartangala5001 5 жыл бұрын
Sir for this programme we need to write the even and odd logics right
@nitinadarsh
@nitinadarsh 4 жыл бұрын
No He just initialised the variable with n = 1, and after that it falls in the odd function and we increment the value and send it to even function. So no need to write logic for odd and even.
@educationalonly5941
@educationalonly5941 3 жыл бұрын
No ,here we have declared no. From 1(kept in odd fun.) sequentialy no. is incriminating in function itself. Then Obviously the next no is of even type and next odd and so on .
@marvelshorts2.o337
@marvelshorts2.o337 Жыл бұрын
suprab expalnation sir
@true4189
@true4189 4 жыл бұрын
Thank u
@SanjeevKumar-wt9bs
@SanjeevKumar-wt9bs 5 жыл бұрын
sir,please solve indirect recursion question, gate 2017
@namastebhai855
@namastebhai855 3 жыл бұрын
Then what is significance of writing "return 0" in main function?
@binoyabraham4559
@binoyabraham4559 4 жыл бұрын
in this program we should return (n) right ?becoz i learned that only a variable which is declared in a function ......only that function can access to it ...if u want to access in other function u have to return it na
@swarajchoudhary1862
@swarajchoudhary1862 3 жыл бұрын
Over Here how after decreament in even function the n value increases by 2 ?????
@ReflectingOurselves
@ReflectingOurselves 3 жыл бұрын
#include int i; int main() { for(i=1;i
@JathinShyam
@JathinShyam 3 жыл бұрын
In the void functions, why u typed return?
@jeevaalok1467
@jeevaalok1467 3 жыл бұрын
Yea I too have same doubt
@mdkaiserali6830
@mdkaiserali6830 5 жыл бұрын
awesome
@Hell2026
@Hell2026 3 жыл бұрын
You are an outstanding explanation sir but what you have written is that syntax or example? Please give me reply sir
@jeevaalok1467
@jeevaalok1467 3 жыл бұрын
Example ig
@bsaikumarreddy1413
@bsaikumarreddy1413 6 жыл бұрын
Please upload video fastly sir It’s a kind request
@sudhanshuranjan7629
@sudhanshuranjan7629 6 жыл бұрын
By what date should we expect next lectures?
@tomcruise6618
@tomcruise6618 4 жыл бұрын
Sir why is void used before function??
@fasasiwasiu7533
@fasasiwasiu7533 2 жыл бұрын
In video 76(How to write Recursive Functions) you mentioned that if block only should contain Base Case, while else block should contain Recursive Procedure. But in this video, your if block contains Recursive Procedure, while your else block contains Base case. Please can you explain what happened here, thanks
@juliuskamara1348
@juliuskamara1348 2 жыл бұрын
I think hence the base case is been define, doesn't matter whether in an if or while.
@CSEEswarGuptha
@CSEEswarGuptha 4 жыл бұрын
In function defination why we are using void odd,void even
@jeevaalok1467
@jeevaalok1467 3 жыл бұрын
Same doubt
@knSharooq
@knSharooq 4 жыл бұрын
is it necessary to use return; ??? if it is not used then also result will be same right??
@manavjain3930
@manavjain3930 5 жыл бұрын
Man jae sir
@compangit1524
@compangit1524 Жыл бұрын
Comment for myself: Indirect Recursion happens, when the recursion doesn't only happen on the function body alone of the function caller.
@educationalonly5941
@educationalonly5941 3 жыл бұрын
how the return; works? Pls. Explain..
@asha0523
@asha0523 6 жыл бұрын
Mast
@sahil_singhai
@sahil_singhai 2 жыл бұрын
Why we have declared int n =1; in a global variable or not as an inside main function?
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
because if not, it will only be available in main function. unless u use call by reference(pointer).
@eve7722
@eve7722 2 жыл бұрын
Hello when we return value why void came instead of that int may be come
@M4LICIOUS
@M4LICIOUS 2 жыл бұрын
You sure WAP is 'write a program"?,lol🙃
@johnychinese
@johnychinese Жыл бұрын
I came looking for this comment 😂
@الكليةالتقنيةالهندسيةفيميسان
@الكليةالتقنيةالهندسيةفيميسان 6 ай бұрын
how to transfer (n) between odd and even ??? odd()>>>even()!!! how each function call remembers the value of "n"??
@mickey5280
@mickey5280 Ай бұрын
Can someone explain to me why don't he use void not if else?
@sahilsaxena8374
@sahilsaxena8374 5 жыл бұрын
Void odd() It's return how it is possible Void means it's doesn't return???
@bantuthakur9959
@bantuthakur9959 5 жыл бұрын
Hey odd and even function not return any value, it only print on its own function but doesn't return any value.
@sahilsaxena8374
@sahilsaxena8374 5 жыл бұрын
Why we write return statement??
@bantuthakur9959
@bantuthakur9959 5 жыл бұрын
@@sahilsaxena8374 to return some value to the function
@rishabh7011
@rishabh7011 4 жыл бұрын
@@sahilsaxena8374 to stop the execution of that function and return to previous function
@HarshaVardhan-kt5uu
@HarshaVardhan-kt5uu 3 жыл бұрын
Nice question 👍
@HARE_KRISHNA_2399
@HARE_KRISHNA_2399 5 жыл бұрын
But how does the compiler know that which is odd number and which is even ??
@georgiilkov9915
@georgiilkov9915 3 жыл бұрын
A bit late here but we start with 1 which we as humans know is odd. So we make it call odd() first.The number after an odd number is an even one. After an even number follows an odd one. And so on until we reach 11
@jeevaalok1467
@jeevaalok1467 3 жыл бұрын
compiler knows some inbuilt functions ig
@jonasasare5775
@jonasasare5775 4 жыл бұрын
We are returning an integer to the main fun but why is the data type of odd fun and even fun void
@johnychinese
@johnychinese Жыл бұрын
WAP == Write a program Everybody knows that 😂
@jayaprakashl8592
@jayaprakashl8592 Жыл бұрын
in the even function, the if condition and the return statement are useless.
@ameykulkarni8165
@ameykulkarni8165 3 жыл бұрын
are those types applicable in java?
@FarhanAli-gd2qv
@FarhanAli-gd2qv 3 жыл бұрын
What if we do not write return; statement in even and odd function. I didn't write it in my program and I didn't got any type of error. Program executed properly. What if we do not use it or is it necessary to use, if yes then why?
@bablu1921
@bablu1921 3 жыл бұрын
Because we're using a void data type so it doesn't expect anything in return
@FarhanAli-gd2qv
@FarhanAli-gd2qv 3 жыл бұрын
@@bablu1921 I know that but what about int return_type in function header. I have typed int in function header and didn't typed return statement inside function at the last and didn't got any error in the program. According to rules function must return an integer value if int is written in the function header.
@bablu1921
@bablu1921 3 жыл бұрын
@@FarhanAli-gd2qv probably your compiler is smart lol Well then I can't say
@FarhanAli-gd2qv
@FarhanAli-gd2qv 3 жыл бұрын
@@bablu1921 you can try it too in the visual studio code.
@FarhanAli-gd2qv
@FarhanAli-gd2qv 3 жыл бұрын
@@bablu1921 I searched about this issue over stack overflow, over there a user said "it's ur choice whether you want to put it or not". But I need the reason. Why program is not generating any error ?
@CostaKazistov
@CostaKazistov 5 жыл бұрын
Is it the same as Trampoline function?
@hetaeramancer
@hetaeramancer 3 жыл бұрын
what's that?
@b3nythomas284
@b3nythomas284 11 ай бұрын
I wish i thought of WAP as write a program...
@sumitchettri8399
@sumitchettri8399 4 жыл бұрын
if we are already incrementing the value of n in the printf function then why are we incrementing it again??
@FarhanAli-gd2qv
@FarhanAli-gd2qv 3 жыл бұрын
incrementation of n variable in both functions are necessary.
@FarhanAli-gd2qv
@FarhanAli-gd2qv 3 жыл бұрын
Dry run your program then you will get to know.
@indianmusic1770
@indianmusic1770 3 жыл бұрын
Why do you not execute the code
@anoliverma4907
@anoliverma4907 2 жыл бұрын
Why is only odd function called in the main function? Why Even function is not called?
@vallimaylvalliappan9489
@vallimaylvalliappan9489 4 ай бұрын
isnt it dynamic scoping then?
@venkythesmart440
@venkythesmart440 4 жыл бұрын
so many member doubts this. Please reply me. Stack flowed only last in first out. This program not follow that. Return function how it is works. This I am not felt this recursion program
@udbhavvikramsingh3449
@udbhavvikramsingh3449 3 жыл бұрын
Can we write even (n++) instead even ( ) And not write n++
@jeevaalok1467
@jeevaalok1467 3 жыл бұрын
Yea it works
@shovonanand023
@shovonanand023 Ай бұрын
But i didn't understand how it knows that it's odd or even. No you didn't give any condition either.
@omarboug681
@omarboug681 3 жыл бұрын
is my code right to ? it worked by the way int fact( int n ) { if( n % 2 == 0 ) { return n - 1 ; } else { return n + 1 ; } } int main() { int n = 1 ; for( n = 1 ; n
@radha_preymi
@radha_preymi 3 жыл бұрын
🥰🥰🥰💚
@geekyskill4156
@geekyskill4156 3 жыл бұрын
sir it is not working it programe goes to infinity
Types of Recursion (Part 2) | Tail & Non-tail Recursion
13:13
Neso Academy
Рет қаралды 284 М.
Introduction to Two-Dimensional (2D) Arrays
10:20
Neso Academy
Рет қаралды 723 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Recursion (Solved Problem 1)
6:49
Neso Academy
Рет қаралды 205 М.
Recursion in C
11:12
Neso Academy
Рет қаралды 967 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 55 М.
How to write Recursive Functions
9:03
Neso Academy
Рет қаралды 447 М.
Call By Value & Call By Reference in C
8:34
Neso Academy
Рет қаралды 1,4 МЛН
Recursion (Solved Problem 4)
10:37
Neso Academy
Рет қаралды 100 М.
Pointers (Important Questions)
11:11
Neso Academy
Рет қаралды 358 М.
Declaration of Array
4:43
Neso Academy
Рет қаралды 445 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН