BaseLine of Recursion
Rules |
---|
Base Condition |
Recurrence Relation |
Draw Stack to Debug 😇 |
Let's take a question to understand the above baseline:-
Reverse the char [] array Using Recursion
- Input: ["H","a","n","n","a","h"]
- Output: ["h","a","n","n","a","H"]
Solution
Swap Node Using Recursion
- Input: [1,2,3,4]
- Output: [2,1,4,3]
😉Debugging
Its a stack
Green indicate pop operation from stack
https://codereview.stackexchange.com/questions/240216/reverse-string-recursion
I have put code on Code Review Stack Exchange.
Disclaimer: Code Review Stack Exchange is a good opportunity for you to review code and follow the best code pattern/design.
Discuss memory optimization.
Hint: 1. see how you can u avoid creating an object and use the static method.
Hint: 2. Why I have used end
*mid = start + (end - start)/2
and why not * mid = (start + end)/2
Share your thoughts over Code Review Stack Exchange.; I would love to hear that.
Soon I will create a video over it 😅
Top comments (0)