# recursion = a function that calls itself from within # helps to visualize a complex problem into basic steps # problems can be solved more easily iteratively or recursively # iterative = faster, complex # recursive = slower, simpler # ----- EXAMPLE 1 ----- # ITERATIVE def walk(steps): for step in range(1, steps+1): print(f"You take step #{step}") # RECURSIVE def walk(steps): if steps == 0: return walk(steps - 1) print(f"You take step #{steps}") walk(100) # ----- EXAMPLE 2 ----- # ITERATIVE def factorial(x): result = 1 if x > 0: for i in range(1, x + 1): result *= i return result # RECURSIVE def factorial(x): if x == 1: return 1 else: return x * factorial(x - 1) print(factorial(10))
@ЙирюВонаирда Жыл бұрын
does it even make sense? I mean... why choose recursive way to solve a matter? Is there any advantages outside of simplification? Mb memory consumption or speed? Why use it if u dont mind complex code? Any example where recursion gave a more suited solution than iterative way?
@captainhostile101 Жыл бұрын
@@ЙирюВонаирда i sure need em for tomorrows exam
@OceanLover8008 Жыл бұрын
Thanks bro for always uploading extremely useful content for free. I'm a student right now and I really appreciate all the efforts that you are taking. ❤️ Proud to be a 'Bro'. 😎
@BroCodez Жыл бұрын
thanks for watching 😎
@randymartin90402 ай бұрын
This taught me something about the stack and how code functions that I haven't learned from anywhere else, invaluable. Thank you! Blessings.
@Loco4Waffles7 ай бұрын
Best example I have seen on explaining recursion
@zabehullahalizadeh2310 Жыл бұрын
Learn python with Bro is as enjoyable as playing our favorite games
@mihailomilenkovic6382 Жыл бұрын
True
@salihmorta41729 ай бұрын
This is the best BEST explanation for recursion I’ve ever heard
@itayzabar2953 Жыл бұрын
Hi Bro Code! I'm studying computer science in highschool rn and after two month learning how to use recursion i am still struggling. I think that your video on it might gave me some crucial insights about the topic and the usage of it. Thank you so much❤️ I rly like your videos so keep creating great content!! Have a great day!
@edipedipbulmaz Жыл бұрын
I just wanted to thank you. For teaching me programming and starting my coding career. Tanks again.
@abdulhannan-18 Жыл бұрын
def add(*args): total = 0 for arg in args: total = total + arg return total print(add(1,2,3,4,5,6,7)) 28
@ssmith5048 Жыл бұрын
Excellent explanation and examples!
@farhisoki4805Күн бұрын
Help a lot, thanks
@randymartin90402 ай бұрын
Cool way of understanding this, thank you.
@MalaPalabra-zr6wg Жыл бұрын
I'm a student of Telecommunications engineering, and I made Calculus Lambda with Haskell to improve my programmation abilities. And thanks to that elective I learnt how to use recursive.
@chrisogonas3 ай бұрын
Very well illustrated! Thanks
@anshhmalviyaa Жыл бұрын
Best channel for learning to program on KZbin. ❤
@eddisonlewis8099 Жыл бұрын
Very interesting illustration
@fluffyisyermom763110 ай бұрын
Bro is the g. Ty my friend. When other KZbinrs fail to deliver an answer that is simple and easy to understand, you come in and kill it. ❤ I was stuck on this for an hour before trying this video. But man I wish I knew this a month ago 😂
@OllyCybSec6 ай бұрын
Thank You and Salute to @Bro Code‼️. I watched the entire 106 video playlist of Python. Brilliantly demonstrated and explained. 🏆🏆🏆
@tictactechin Жыл бұрын
from this video i learn that programming is solving your own error code problem while trying to achieve your goal code
@Wolfoffreedom111 Жыл бұрын
Great 👍
@audiemolinger64506 ай бұрын
Great course, great instructor
@shoukatiqbal567425 күн бұрын
very impressive demonstration well done Sir
@recursion.5 күн бұрын
Good to see so many people interested in me🥰🥰🥰
@flashplaysyt5719 Жыл бұрын
It is seems very essy to learn with you thanks for making videos
@kristijanlazarev9 ай бұрын
Finished in a less than a week, even though I work a full time job, very good course!
@Daniyar-AbuUmar Жыл бұрын
Subscribed and liked without even thinking twice
@bryce38516 ай бұрын
This has showed me the important part for data analysis thanks bro 🙏
@ZyrusAlvez8 ай бұрын
Thank you. No one told me that the best way to understand recursion is first understanding the stack
@Geniuspaul-Projects Жыл бұрын
thanks allot for your help
@kadirv8 ай бұрын
excellent. well clarified 👏👏
@hxhchimeraantarc2268 Жыл бұрын
I am studying for finals right now and your videos are the best. You are so good at explaining. Thank you so much.
@fredcunningham804910 ай бұрын
Great tut, thanks!
@poi96962 ай бұрын
✨✨
@onter6 ай бұрын
really well explained, good stuff
@rockey5508 Жыл бұрын
I'm glad I found Bro Code, I'm still learning but Bro Code makes coding easy to learn.
@abhisaragarwal9084 Жыл бұрын
Sir your videos are very good thnx for uploading programming language tutorials for free.
@TheKr0ckeR7 ай бұрын
For 1 year later, learning 8 min tutorial decreased to 5 min. :D Thanks for the tutorial
@Simonjoel-4695 ай бұрын
I really enjoyed watching your videos but I think you should share your resources pls...!!
You should add a positive only condition for the factorial in the recursice function :)
@Nishitha_Jay7 ай бұрын
Thanks alot for this my Bro. You are a true BRO. ❤
@informativecontent47783 күн бұрын
An easier approach to understand and solve finding the factorial of a number using recursion number, result = int(input("Enter Any Number")), 1 # both of these are global variables def fact(num): global result # to access and modify value of a global variable in python if num == 1: return result *= num # we need to use global keyword and here we are telling the function to change # the value of result globally fact(num - 1) fact(number)
@EmilioAt773 ай бұрын
As always, you are the best, Bro 🤝🏻🤝🏻
@杨玄-v4k10 ай бұрын
really helpful thanks bro
@tigerli22628 ай бұрын
love it
@sinankodur4251 Жыл бұрын
Bro you are the best I am without words bro, your examples are perfect Anyone can learn coding with this Great work and big fan of you
@yashvashist5347 Жыл бұрын
Thanks bro❤️✨
@harley_randelo Жыл бұрын
great video. thanks for uploading. and btw, first
@calmlivingclub Жыл бұрын
Great sharing
@julia-kc3kp Жыл бұрын
hey! just realized i'm your 850,000st subscriber 🥳 love this channel, you are doing something very valuable and precious here. thank you for being an absolute bro!
@malvernmabvira1562 Жыл бұрын
1:47 no brackets to define scope of a function. Java for me.
@marshmelows Жыл бұрын
I'm amazed how the recursive approach tends to be simpler to write. Thanks Bro Code!
@sweet_coconut Жыл бұрын
thank you! now recursion is a bit clearer to me :)
@Vue-daigle Жыл бұрын
Hi Bro, thanks for all the work you've put into these tutorials.
@keldur16 Жыл бұрын
I understand what recursion is. I am struggling to understand why I would use it Love your videos tho. You’re always a major help.
Got my comp sci final in 1 hour and couldn't for the life of me figure out recursion before this (its 40% of my final). I think I understand it better now, and this should help me a lot!
@francescodiniccolo3 ай бұрын
Thanks Bro, that was a great explanation Bro
@SoundKing Жыл бұрын
Hi Code Bro from what I can see, you are the most thorough and clear person teaching coding on KZbin. Whatever your teaching style it matches my learning style. Is there any chance that you can do a full course on React?
@AntonSobolev Жыл бұрын
nice
@OBGCORP Жыл бұрын
Hey man, love your videos! Watched all the playlist to have a clear understanding when I get asked an algorithm question in an interview. However, I am struggling to find all the permutations of a given string and return the permutations in an array. Could you please make a video about it where you explain the recursion we use there in depth? (in Java please) Thank you...
@SeanPatrickGoАй бұрын
Thanks Bro! This video really helped!
@codecaine Жыл бұрын
Keep up the excellent work
@arsacode6145 Жыл бұрын
you're doing gods work, bro
@prizepig Жыл бұрын
Just when I thought I was out, they pulled me back in.
@tilkesh Жыл бұрын
Thx
@GhostGaming-tt9tu9 күн бұрын
You are a legend
@mdayubali9751 Жыл бұрын
could you please make devops or aws videos please......!
@AlexTerrable Жыл бұрын
Thanks bro
@rishusingh19959 ай бұрын
BROOO!! Finally I understand recursion 😂
@Osamu_GWAD Жыл бұрын
Good job!!! 🤝
@ohChardy5 ай бұрын
last video of the playlist
@AayushBashyal14 ай бұрын
was it worth the watch?
@AbelBen-fz6hs6 ай бұрын
sick video dog. got 89% for my test just from this video
@sohelqureshi4183 Жыл бұрын
Sir you're can Please make video for django python course or playlist
@MarcosBilly-x7y11 ай бұрын
cool video)
@nik4465 Жыл бұрын
Thank you, Bro😎
@zohahs5276 Жыл бұрын
nice one can you please also mention link to the complete playlist to which this video belongs its hard to find the playlist where I can check out other videos. I will add one like for the youtube prayer algo now thanks.
@BüblySnowfláke-m3x6 ай бұрын
Who's watching dis in 2024,love all ur tutorials bro❤
@FaraDuMatin Жыл бұрын
Bruh I just saw that in class on week ago and didn’t understood shit. You are a wizard my guy.
@QhY-j2e4 ай бұрын
Hi bro, may i ask the logic behind how at 2:28 changing the print function to below walk (steps -1) makes the counter go forward? i cant seem to wrap my head around it
@ThomasC-e8i13 күн бұрын
do you understand now?
@Jess-xg7ok Жыл бұрын
I like the style of your video and the examples and the sample code. I am wondering if you can do the tutorial on Python Panda, NumPy, and others that are more commonly used in data analysis/data science? Thanks!
@hamidgholami2683 Жыл бұрын
Hello bro what do you think about chat gpt? will it replace devs?!
@Mario-xk7kh10 ай бұрын
Ohhhhhhh, I get it now. Oh my gosh I was going through this in Data Structures today and I was lost. I understand better mow
@codeplays56722 ай бұрын
what is the sequence the code will go if there is more than one code calling back the function within the function?
@geerliglecluse529711 ай бұрын
Not going to say I really get it after only watching this video, I'm not that smart. But I do understand that's it's worth diving deeper into this.
@Vue-daigle Жыл бұрын
Thks Bro, great Python videos simply explaining all these features of the language ... 😎 Would you consider moving on to commonly used frameworks like Flask + Strapi ? They seem to be complementary and powerfull for Web dev. (=
@pankela8883 Жыл бұрын
Hey Bro I really appreciate your work, right now I m struggling to import the java library JCap can you guide me trought it?
@heinrichsmit2 Жыл бұрын
Hey bro, was wondering if you could show us how to make our own JDK? That way one can conveniently use heaps of code without having to actually add libraries and modules when starting a fresh project. So we wouldn't be replacing JDK 19 but just adding our JDK to the IDE with our few packages we have in there to use.
@phamducphutrong Жыл бұрын
Why youtube does not provide the ability to help viewer knows which playlist that the currently video belongs to? I must see the code inside the video and see the hastag name to guess the playlist while the author have added that video into specefic playlist!
@ameyagupta7285 Жыл бұрын
tysm!
@tjbennett126615 күн бұрын
Word
@maxim1308 Жыл бұрын
Why are numbers in the output of walk function reversed?
@rubayetulalam112610 ай бұрын
why print (f'you take step #{steps}') works upward while using after recursive function call?
@nxthingbutv0id958 Жыл бұрын
I’m the future, please do a series on rust
@kristheog8546 Жыл бұрын
Hi sir, are you planning to make a tutorial for Lua language? thanks in advance