Back Recursion - Level 1 Questions (Theory + Code + Tips)

60-90
Created By: Kunal Kushwaha
Published At: 2021-10-03
Search Query: Java Recursion
Tags: recursion in java interview preparation course recursion fibonacci series recursion and backtracking recursion in programming recursion in 1 shot introduction to recursion recursive functions recursion masterclass recursion from scratch how to master recursion backtracking recursion basics java course recurrence relations recursion playlist best recursion tutorial recursion basic questions recursion level 1 questions recursion questions recursion tutorial
In this video, we cover level 1 questions of #recursion. These are questions that will build the foundation of various concepts snd improve the thinking process. It will also set the base for future videos.

Take part in the learning in public initiative! Share your learnings on LinkedIn and Twitter with #DSAwithKunal & don't forget to tag us!

👉 Resources
- Join Replit: http://join.replit.com/kunal-kushwaha
- Complete Java DSA playlist: https://www.youtube.com/playlist?list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ
- Code, Assignments, & Notes: https://github.com/kunal-kushwaha/DSA-Bootcamp-Java

➡️ Connect with me: http://kunalkushwaha.com

=========================================
Timestamps:
0:00:00 Introduction
0:02:26 Revision
0:02:40 Q-01 : n to 1
0:08:52 Q-02 : 1 to n
0:15:04 Q-03 : Product of n to 1
0:23:37 Q-04 : Sum of n to 1
0:24:28 Q-05 : Sum of digits
0:30:42 Q-06 : Product of digits
0:31:56 Concept : Passing Numbers
0:35:19 Q-07 : Reverse a number
0:40:29 Way-1 for Q-07
0:48:20 Way-2 for Q-07
0:54:40 Q-08 : Palindrome
0:58:07 Q-09 : Count Zeros
1:08:05 Q-10 : Count Steps
1:12:41 Outro

#placement #dsa #interviews
logo Ask VidTutorAssistant
Comment
or
Question
Your name
Comments with generated responses
@venkateswararaothotakura945
2021-12-05

I don't why we use helper function instead we pass the argument in the original function itself example num of steps taken to become a num zero
steps(int n, int c)
If(n==0)
return c;
If(n%2==0)
return steps (n/2, c+1) ;
return steps (n-1, c+1) ;
Correct me this algo was wrong I am glad if anyone help me out with this

@KunalKushwaha

to make code clean

VidTutorAssistant (GPT-4)

Hi @venkateswararaothotakura945! Thanks for asking that question. The usage of helper functions in recursion is quite common as it gives us flexibility when we need to involve more aspects. In the function you've given as an example, it seems you have two parameters: n (the number) and c (count). Your algorithm seems to do what's intended.

However, because this is an introductory case and I'm aiming to teach certain patterns to beginners, we leveraged the usage of a helper function in these videos. For instance, in more complex cases, we may require several parameters and initial values that need to be set, and fulfilling such needs would lead to an overloaded function declaration. This is where the helper function proves to be useful.

Hope this clarifies your question and keep coding!