C++ FUNCTIONS (2020) - What is recursion? Learn recursive functions! PROGRAMMING TUTORIAL

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ส.ค. 2024
  • Recursion is a process in which a function invokes itself, and the corresponding function is called a recursive function.
    Recursion is one of those topics in programming that often confuses students, and in this video, I'm explaining how recursion works and also comparing different solutions to the same problem (using loops and using recursion)
    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.
    Download Visual Assist here: bit.ly/WT-CB
    I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
    Download Ultra Edit here: bit.ly/UE_CB
    It is a powerful, secure text editor designed specifically for programmers.
    ☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. You can use the link below to make a contribution: bit.ly/CodeBeauty_BuyMeACoffee
    However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇
    Contents:
    00:00 - Solution without recursion
    05:39 - Skip to the solution that uses recursion
    For loop video (Calculate factorial of a number) - • C++ FOR BEGINNERS (202...
    Follow me on other platforms:
    Instagram 📸 - / truecodebeauty
    Twitter 🐦- / truecodebeauty
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 248

  • @CodeBeauty
    @CodeBeauty  3 ปีที่แล้ว +23

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.

    • @user-Ali-Al-Mosleh
      @user-Ali-Al-Mosleh ปีที่แล้ว

      I have questin for you ,
      why varible ' m ' doesn't equal to parameter 'm' through recursion ?

  • @carlabalos3884
    @carlabalos3884 2 ปีที่แล้ว +44

    Finally after a few days of sleepless nights thinking how recursion works I finally manage to understand the logic of recursion in this video. Thanks!

  • @sohumramouthar9722
    @sohumramouthar9722 3 ปีที่แล้ว +152

    She literally explains this better than my University Professor who has a PhD😂😂😂

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +28

      🙏❤️

    • @karimullah6235
      @karimullah6235 2 ปีที่แล้ว +4

      Offcource her explanation is better than fantastic would be an understatement.

    • @TheJoshuamcgowan
      @TheJoshuamcgowan 2 ปีที่แล้ว +1

      Yeah been learning so much this last year from these

    • @ltmega1665
      @ltmega1665 ปีที่แล้ว +1

      Absolutely she is amazing

  • @georgeallan9220
    @georgeallan9220 3 ปีที่แล้ว +10

    You save me as I am having my final exams tomorrow. still struggling to catch up on my reading but this clears it all. Appreciate your hardwork! Definitely subscribing. Tropical Greetings from the Pacific!

  • @claritydive
    @claritydive ปีที่แล้ว +8

    I've searched TH-cam and Google and this is the best beginner-friendly explanation I've seen on recursion!

  • @goldensands2104
    @goldensands2104 3 ปีที่แล้ว +10

    9:35 commenting and keeping track of what is happening is really smart, thank you for teaching us like that

  • @wolfflayergaming4476
    @wolfflayergaming4476 10 หลายเดือนก่อน +1

    I have watched so many videos on recursion and this is the first time I can say I understand it fully. Thank you so much.

  • @jameszenos4045
    @jameszenos4045 3 ปีที่แล้ว +2

    Super Solid & Simplest Ever Explanation of Recursion. Thanks a ton!

  • @NEONARMOR
    @NEONARMOR ปีที่แล้ว +2

    Thank you so much, everytime I don't understand something, I come to your channel and problem solve, the way you explain is just amazing

  • @kannamsai9913
    @kannamsai9913 2 ปีที่แล้ว +5

    After traveling through so many channels at last I found the real logic of recursions Thanks Ma'am

  • @alikhaled7845
    @alikhaled7845 ปีที่แล้ว +1

    Ive been watching your videos for the last 2 weeks, Thank you so much. You are amazing!

  • @behroozrashidi1987
    @behroozrashidi1987 ปีที่แล้ว +1

    Hi Saldina,
    your explanation is really amazing and for add between two number we can use this for loop for (int i=m+1;i

  • @bulaha2978
    @bulaha2978 2 ปีที่แล้ว +5

    Finally found this channel! She is more better than my university professor 👨‍🏫!

  • @zuhairanwar
    @zuhairanwar ปีที่แล้ว +6

    If first number is larger than second number, no need to swap values, just call the function with reversed arguments in an else block, like,
    if (n

  • @jeanahollings
    @jeanahollings 2 ปีที่แล้ว +1

    you're explanation is done at a good pace with just enough explanation but not to much. thanks!

  • @phindilemfeka7945
    @phindilemfeka7945 2 ปีที่แล้ว

    You are a star.
    I have been struggling to understand from many sources unit found your tutorial.

  • @andrewzheng7246
    @andrewzheng7246 2 ปีที่แล้ว +3

    Thank you!!! You make code more understandable.

  • @fernandotrovao4093
    @fernandotrovao4093 4 หลายเดือนก่อน

    I teach in Montreal and I found this to be best and simplest explanation ever. This is what I was looking for.

  • @jameszenos4045
    @jameszenos4045 3 ปีที่แล้ว

    I'm super excited to learn DSA from you. Anxiously Waiting!!!

  • @ventasonline3305
    @ventasonline3305 3 ปีที่แล้ว +8

    Muchas gracias, te veo desde la Ciudad de México, sigo en lo básico. me han ayudado mucho tus videos. ¡Gracias!

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +8

      Muchos saludos para Ciudad de México! Me hace muy feliz saver que con mis videos puedo ajudar a algien ne el otro lado del mundo! 🥰

  • @aurelienbaraka2527
    @aurelienbaraka2527 2 ปีที่แล้ว +1

    J'aime beaucoup ta manière d'enseigner et surtout le son qui sonne très bien.
    Vraiment courage et va de l'avant !
    Je suis ton fan.

    • @abifanny
      @abifanny ปีที่แล้ว +1

      Elle est vraiment au top. je l aime beaucoup!

  • @aditisingh4952
    @aditisingh4952 3 ปีที่แล้ว +5

    You are the greatest!!! Never change..you're an inspiration!

  • @user-lf5ky8bj6e
    @user-lf5ky8bj6e 2 ปีที่แล้ว +1

    Finally I got it !! Thanks a lot ! 💛💛💛💛💛

  • @nurmuhammadsobirov1015
    @nurmuhammadsobirov1015 3 ปีที่แล้ว +4

    Thank you so much, it was really useful😊😊

  • @tarynx8330
    @tarynx8330 3 ปีที่แล้ว

    Fantastic video!!! Thank you so much

  • @sul3y
    @sul3y 3 ปีที่แล้ว +1

    I'm impressed how you explain things thnk you .

  • @gazelledeleuze
    @gazelledeleuze 8 หลายเดือนก่อน +1

    incredible. ur a gifted teacher ❤

  • @anakagunggdedutaramadana1024
    @anakagunggdedutaramadana1024 3 ปีที่แล้ว

    thank you so much, your explanation is very helpful

  • @mohab4616
    @mohab4616 2 ปีที่แล้ว +1

    Thanks so much for your help and your effort

  • @caseyspaulding
    @caseyspaulding ปีที่แล้ว +1

    Thank you. Great explanation

  • @mailenolivera1523
    @mailenolivera1523 3 ปีที่แล้ว +2

    Great video Saldina ! Just one question, why you keep using system("pause>0")?? I read somewhere that it is not good practice and it makes your program slow. Thanks for the videos !

  • @anninaecker
    @anninaecker 3 ปีที่แล้ว +8

    Haha, great intro! Thanks for making such helpful tutorials in C++! I'm glad I've found your channel :)

    • @pedrocollins4521
      @pedrocollins4521 3 ปีที่แล้ว

      haha, haha. haha this is not programming introduction.this is the language of ___________.

  • @FatemehAsgari1
    @FatemehAsgari1 6 หลายเดือนก่อน

    You're video was perfect!

  • @nahomsamuel6452
    @nahomsamuel6452 3 ปีที่แล้ว +2

    This was very helpful

  • @hayachiq
    @hayachiq ปีที่แล้ว +1

    best recursion explain ever thank you

  • @icode5671
    @icode5671 3 ปีที่แล้ว +6

    Very simple , Very unique, Very clarity..!!!
    God sent you on this planet to save us 🤗😍

  • @camilabalsemao1184
    @camilabalsemao1184 ปีที่แล้ว

    Great explanation!

  • @musaddiklalkot3514
    @musaddiklalkot3514 2 ปีที่แล้ว +1

    You made it so simple to understand wow ,amazed by your teaching thank you..

    • @CodeBeauty
      @CodeBeauty  2 ปีที่แล้ว

      you're welcome ☺️😄

  • @Roro-ej7ke
    @Roro-ej7ke 8 หลายเดือนก่อน

    ur my new go to for coding

  • @willcastlereviews
    @willcastlereviews 2 ปีที่แล้ว

    omg I love your videos! They've been so helpful! Also, I've always loved learning from women because for some reason I always understand better lol

  • @deep-lofi
    @deep-lofi 2 หลายเดือนก่อน

    I found a well explainer on TH-cam, I learned a lot from you Mam, thank you so much😍Love from Pakistan.

  • @kolbe6436
    @kolbe6436 2 ปีที่แล้ว +1

    You really inspire me 🥺. Much love from my side of the world❤🥰, keep doing what you're doing😊

  • @ashenhewavithana9479
    @ashenhewavithana9479 3 ปีที่แล้ว +31

    Thanks a lot, Saldina for these amazing videos, they are very helpful.
    Code for finding the factorial with a recursive function,
    #include
    using namespace std;
    int recursive_factorial(int num){
    if(num == 1)
    return num;
    return num * recursive_factorial(num - 1);
    }
    int main()
    {
    cout > num;
    cout

    • @kekenny6648
      @kekenny6648 2 ปีที่แล้ว +3

      Nice, but you forgot to define your variable num.

  • @georgefratila6773
    @georgefratila6773 3 ปีที่แล้ว +2

    So simple when you explain like this :)

  • @charlesmaganga8430
    @charlesmaganga8430 ปีที่แล้ว

    After a long hours of trying to understand someone code (that contain recursive function) and came out empty.....
    I found myself in this video...
    But after watching this video
    Now i know what was going on with the codes
    God bless you...You are doing a good job

  • @dandon.3667
    @dandon.3667 6 หลายเดือนก่อน

    Your youtube channel has saved my life . Thank you 🥰🥰🥰🥰🥰

    • @CodeBeauty
      @CodeBeauty  6 หลายเดือนก่อน

      You're welcome 🥰
      Also, I believe you will be interested to know that my practical programming course will be out in a week or two and that it will propel your career to the stars.
      You can sign up here if you re interested, and I'll send you a link when it it out, and I'll make sure to include a special discount as my way of saying th k you for watching my TH-cam and writing supportive comments. 🥰
      bit.ly/SimplifyingCoding

  • @nucavani
    @nucavani 3 ปีที่แล้ว

    Thank youuuuu! 🎈❤️

  • @geogeo14000
    @geogeo14000 3 ปีที่แล้ว +1

    Very good videos, thanks a lot !

  • @trippics8465
    @trippics8465 3 ปีที่แล้ว

    What a way to teach, like it.

  • @eyesplash
    @eyesplash ปีที่แล้ว +3

    Another banging lesson. Here's my attempt at the factorial excersise
    #include
    using namespace std;
    int factorial(int n) {
    if (n n;
    cout

    • @trlavalley9909
      @trlavalley9909 4 หลายเดือนก่อน

      TYVM, total Brain Freeze on that one. At least now I know what a solution would look like.

  • @makoto7275
    @makoto7275 3 ปีที่แล้ว

    you're an life savior

  • @mk-ep7yk
    @mk-ep7yk 3 ปีที่แล้ว +2

    your expression is really nice. If it happens in other matters, it would be very nice

  • @noitnettaattention
    @noitnettaattention 3 ปีที่แล้ว +25

    Don't hurt yourself, your students (ehhm solders) demand healthy Soldina to win the war of recursion ... ;)

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +1

      hahaha 🤓☺️

  • @alexandresordi346
    @alexandresordi346 3 ปีที่แล้ว +2

    Thanks for your videos. You are very nice.

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +1

      You're welcome 😊🤗

  • @boitumelomorongwa1116
    @boitumelomorongwa1116 2 ปีที่แล้ว

    I find this very helpful .Thank you mam.
    Can you please do a tutorial on sudoku using recursion PLEASE

  • @rayankhan6815
    @rayankhan6815 8 หลายเดือนก่อน

    ma'am 1 hour later i have exam, watching this vedio made me fully confident to ace the question relates to recursion 😍😍😍😍 thanks dear maam

  • @AineMcCaughley
    @AineMcCaughley 2 ปีที่แล้ว

    which tool allows you to hand off recursive functions to
    external servers?

  • @aquibkaneki571
    @aquibkaneki571 3 ปีที่แล้ว +11

    int rec(int number)
    {;
    if (number == 1)
    return number ;
    else
    return number * rec(number -1);
    }

    • @alokkr1835
      @alokkr1835 3 ปีที่แล้ว

      in the if condition just add the condition n==0. :):)

  • @almasnvlrr
    @almasnvlrr ปีที่แล้ว

    Thanks!

  • @zfazzershroudvietcynide64e58
    @zfazzershroudvietcynide64e58 3 ปีที่แล้ว

    Thank you!!!!

  • @chesshooligan1282
    @chesshooligan1282 3 ปีที่แล้ว +3

    Numerical analysis theorem: every problem that can be solved recursively can also be solved with loops.

  • @revan_hajiyev
    @revan_hajiyev 11 หลายเดือนก่อน

    goog explanation, thanks )))

  • @_mehedi.hridoy
    @_mehedi.hridoy ปีที่แล้ว

    Intro was too cute🥰

  • @hammadahmad1702
    @hammadahmad1702 2 ปีที่แล้ว

    Thanks you❤🥺

  • @linuxenthusiastgamer7189
    @linuxenthusiastgamer7189 3 ปีที่แล้ว +1

    great video mam, you should run a coding school for both kids and adults.

  • @TheBookOfRon
    @TheBookOfRon 2 ปีที่แล้ว

    nice explanation

  • @Menahel19
    @Menahel19 2 ปีที่แล้ว

    Bestest Saldina ,

  • @hpreetik
    @hpreetik ปีที่แล้ว

    Thank you

  • @jameszenos4045
    @jameszenos4045 3 ปีที่แล้ว

    Can you please do a video for merge sort

  • @alexanderbrittain1486
    @alexanderbrittain1486 ปีที่แล้ว

    I love you!

  • @yt_bharat
    @yt_bharat 3 ปีที่แล้ว +1

    Brilliant explanation

  • @Ilyaselho
    @Ilyaselho ปีที่แล้ว +2

    You explained what my professor couldn't do in 4 hours

  • @abhilashr6565
    @abhilashr6565 2 ปีที่แล้ว +1

    Really beauty code

  • @subee128
    @subee128 2 ปีที่แล้ว

    Thanks

  • @chilobumakayi
    @chilobumakayi 3 หลายเดือนก่อน

    what app do you use

  • @otabeksaibnazarov5704
    @otabeksaibnazarov5704 3 ปีที่แล้ว +1

    thank you, I came to know a lot about Recursions

  • @Rabolisk
    @Rabolisk 3 ปีที่แล้ว

    How do you comment out a selected code block without having to do it manually? Like in 5:47

  • @mba2ceo
    @mba2ceo 2 ปีที่แล้ว

    plz CODE to exit before STACK overflow example

  • @markganus1085
    @markganus1085 3 ปีที่แล้ว +1

    it's a beautiful day in Bosnia and Herzegovina. most pleasant indeed

  • @alexandruteodor3585
    @alexandruteodor3585 3 ปีที่แล้ว

    Would you like to make a tutorial on backtracking, please?

  • @dadisthatyou452
    @dadisthatyou452 ปีที่แล้ว

    BRO..FOCUS!!!

  • @vujkopopovic3713
    @vujkopopovic3713 3 ปีที่แล้ว

    Very nice explanation, just a question, what's gonna happen when number m is bigger then n ? I think it's gonna overflow stack memory and there is a problem. Maybe a one another if - else condition fix everything :)

    • @vk2ig
      @vk2ig 3 ปีที่แล้ว +1

      if (m>n)
      return -1;
      would prevent the stack overflow as well as provide a return value that can be used to indicate an error condition.

  • @karenyounikian3111
    @karenyounikian3111 3 ปีที่แล้ว

    So in this case what is the input?

  • @badariahsharif2339
    @badariahsharif2339 3 ปีที่แล้ว +2

    #include
    using namespace std;
    int recursive_fac(int m, int n){
    if (m==n) //base case
    return n;
    return m*recursive_fac(m+1,n);
    }
    int main(){
    int m=1, n;
    coutn;
    cout

  • @user-jv6zy7mq4f
    @user-jv6zy7mq4f 8 หลายเดือนก่อน +1

    #include
    using namespace std;
    long Factorial(int);
    int main() {
    int n;
    do {
    cout > n;
    } while (n < 0);
    cout

  • @tomiadventures
    @tomiadventures 3 ปีที่แล้ว

    Hi, I am wondering if you make a new project for each of these tutorials. I have been doing that, but I thought I would make a new file (.cpp) in the same project (for the challenge), but it doesn't work. After googling this I am still unsure. Did I do something wrong, or is having more than 1 .cpp file in 1 project a nono?

    • @vk2ig
      @vk2ig 3 ปีที่แล้ว

      I make a new project for each video. I am guessing that in a project you can have lots of c++ files (class files?) but you can have only one function called "main", which is why the IDE might be generate an error.

  • @alix8787
    @alix8787 3 ปีที่แล้ว +1

    Hello ! If I insert "m" number greater than "n" number the program isn't work. For loop mode I solve the problem:
    if (m

  • @madhubankhatri2525
    @madhubankhatri2525 ปีที่แล้ว

    you are lookiing amazing. Which city you belong to?

  • @armochim
    @armochim 3 ปีที่แล้ว

    Hi all! If you put a cout

    • @danieljohncanedacatudio5072
      @danieljohncanedacatudio5072 3 ปีที่แล้ว

      recursive_sum will carry the 9 after if became true.
      as soon as m == n the current sum of m will be return to recursive_sum and cout will display the result via recursive_sum

  • @mr.president6922
    @mr.president6922 2 ปีที่แล้ว

    hi can you please fix the subtitle it's stuck with the korean (auto generated)

  • @muneeburrehman4690
    @muneeburrehman4690 2 ปีที่แล้ว

    Why do we need recursive functions when we have loops?

  • @bVillaplana93
    @bVillaplana93 ปีที่แล้ว

    This is what I've done:
    int FactorialNumber(int num)
    {
    if (num

    • @John_Wall
      @John_Wall ปีที่แล้ว +1

      Hi Beltrán, this might be too late now but I would change your Base Case to: If (num

    • @bVillaplana93
      @bVillaplana93 ปีที่แล้ว

      @@John_Wall I didn't think about that, thanks for the feedback

    • @John_Wall
      @John_Wall ปีที่แล้ว

      @@bVillaplana93 You're welcome.

  • @gigishankulashvili2050
    @gigishankulashvili2050 2 ปีที่แล้ว

    Do more videos please.

  • @calebbarrerareny9003
    @calebbarrerareny9003 2 ปีที่แล้ว

    So in a sense without the +1 this is a factorial calculator?

  • @coltbolt3583
    @coltbolt3583 2 ปีที่แล้ว

    what happens when we insert a return into the function
    does return halt compiling statements or else does it direct the function back to control commands?

    • @day4834
      @day4834 2 ปีที่แล้ว

      Hi, (updated version): I think that a return statement returns a value which you can further use in your function or program. A function that returns a certain value cannot be void and is used to generate such value/s which you can further use in your code (e.g. you can print it on the screen).

    • @coltbolt3583
      @coltbolt3583 2 ปีที่แล้ว

      @@day4834 What happens when we put return statement in the middle

    • @day4834
      @day4834 2 ปีที่แล้ว

      @@coltbolt3583 Hi, I thought about it and adjusted the previous answer since the return does not end a function, it rather returns a value of your choice.

  • @TheKBC14
    @TheKBC14 3 ปีที่แล้ว

    Lovely intro xD

  • @MissChelsie24
    @MissChelsie24 3 ปีที่แล้ว +1

    Great video! Hvala lijepa :)

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว

      Thanks! Nema na cemu 🤗

  • @tommylemur8516
    @tommylemur8516 3 ปีที่แล้ว +1

    ty

  • @jesseblackhawk
    @jesseblackhawk ปีที่แล้ว +1

    Why is she better at this than my college professor?

  • @kineticknight1267
    @kineticknight1267 3 ปีที่แล้ว +1

    Ma'am, please make tutorials on data structures and algorithm most important ly dynamic programming in C++ because every word you say, clicks my mind.