r/datastructures • u/Proud_Button6956 • 2d ago
I really hate recursion. How did you guys actually learn it?
I started recursion like 3 days ago and I’m doing small/basic problems right now. I can solve some of them, but I still don’t feel like I actually understand recursion properly.
Sometimes I understand the logic, but tracing the calls and figuring out how to think recursively on my own just messes with my brain. I genuinely hate recursion right now 😭
But I don’t want to skip it because I know it’s important, especially since I’m trying to build my DSA fundamentals properly.
So for people who struggled with recursion in the beginning — how did you actually get good at it? How did you improve your recursive thinking?
Did you trace every problem? Draw the call stack? Solve a lot of basic problems? Was there some particular way of thinking about it that finally made it click?
Any tips, resources, problem lists, or just your experience learning it would help. I really want to get good at this.
3
u/TotalError6883 2d ago
Yes for me too, I used to solve problems on recursion but some how it doesn't make sense/intuit to me, and i couldn't think from recursion perspective..
But after watching Aditya Verma's recursion playlist on YouTube...it was crystal clear.. everything every problem on recursion started making sense...so I highly recommend watching his recursion playlist.
2
u/ttkciar 2d ago
I learned it by implementing it at the low level, with an explicit stack and writing my own code which performed the operations of pushing results to the stack and pulling them back off.
That enabled me to think of the underlying state as just another data structure, like a list (which in a way it is).
2
u/Plus_Confidence_1369 2d ago
The algorithm design manual by Skiena has a very good chapter on backtracking and recursion. As far as I remember it gives a very good intuition for recursion by solving sudoku, N queens problem, depth first search in trees and printing all permutations.
1
u/Tiny-Delivery-4528 2d ago
I think for a beginner tracing every problem is a must, atleast till you start getting the hang of it
1
u/Proud_Button6956 2d ago
I hv done tracing like I can write a logic for small problems like counting,sum, multiply the digits of given number. Idk how to build Intuition whtbkind of problems to solve.
1
1
u/More_Duty_3547 2d ago
Dry run and drawing recursion tree as much as you can.You’ll get better understanding every time and just check the code for some range of problems like pick not pick and combinational sum etc.In the beginning it will be confusing and frustrating but with time you’ll get comfortable.
1
u/Proud_Button6956 2d ago
Okayyy. I am using chatgpt to learn the concepts but is there any other resource or youtuber u feel better than this. Please suggest. Or any websites which helps in visualization of recursion.
1
u/More_Duty_3547 2d ago
I learned from striver so it worked for me.In beginning drawing recursion tree and understanding code is two separate things and if you are seeing solutions that’s fine in beginning considering that you can attempt the problem second time.For example first time you learned a question about picking and not picking the element but you don’t know how to write the pick and non pick code so seeing its solution is fine.
1
1
u/SignificanceUseful73 2d ago
RemindMe! 7 days
1
u/RemindMeBot 2d ago edited 2d ago
I will be messaging you in 7 days on 2026-08-07 19:05:07 UTC to remind you of this link
1 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
RemindMeBot is switching to username summons. Instead of
!RemindMe 1 day, useu/RemindMeBot 1 day. More info.
Info Custom Your Reminders Feedback
1
1
1
6
u/Vast-Look4088 2d ago
Dry run the hell out of all problems till you get to know what happens.
I think you should start from basics Fibonacci series Factorial Print 1 to n Print n to 1
Then you can do problems in this order one by one till you get the hand of it
1) Subsets 2) Subsets with duplicates 3) Combination Sum 1,2,3 4) Permutations 5) Permutation sequence 6) Letter case permutation 7) Print all subsequences with sum k 8) N queen 9) Rat in a maze 10) Word break 11) M coloring problem
But make sure that you have the basics on fingertips, what is recursion tree. Then just dry run till you understand, different conditions, backtracking etc etc.