### i_m_jp99's blog

By i_m_jp99, history, 3 months ago, can anyone suggest me how to be good at recursion and what should be my approach? From where shall i solve questions?  Comments (25)
 » Standard recursion problem are in most cases easy. Recursion becomes harder when you’re solving dp with recursion so try some recursion dp problems.
 » Solving problems involving dfs is also a good thing to practice recursion.
 » Try to solve standard problems on dp. If not able to solve, understand it properly and solve some similar problems. Solve 50+ problems(if totally uncomfortable) and you will be good to go.
 » Check this
•  » » Still checking....
•  » »
•  » » Good one mate !!
•  » » If you see this reply, don't click on the comment above. (Base case)
 » 3 months ago, # | ← Rev. 2 →   You can practice those problems for improving your skill on recursion. I hope it will be helpful for you.Problems Link: https://codeforces.com/group/MWSDmqGsZm/contest/223339
•  » » how can i get more such questions on other topics ? I really love this group and the questions given in it.Can u plz tell how i can alsao join more such groups? @User.Invalid
•  » » »
•  » » » » Of course. Why not!!The topics Link: https://codeforces.com/group/MWSDmqGsZm/contests
 » solve recursion problems, duh
 » 3 months ago, # | ← Rev. 2 →   Solve problems tagged DP, Divide and Conquer, DFS and similar, for example 1461D - Divide and Summarize.Surprisingly only 5 problems are tagged Divide and Conquer but are below 1600 rating.
•  » » c_oconut_owo thank u bruh
 » Recursion? Check this out.
 » First, you must be good at recursion
•  » » 3 months ago, # ^ | ← Rev. 2 →   ivan100sic can u plz suggest me some good places to start with recursion?
•  » » » Okay, let's be a bit more serious now.To be good at recursion, you must first identify simple cases which you will not solve recursively. Depending on the problem, this may be small values of $n$ e.g. $0,1$, or leaf nodes of a tree. Then, you must figure out how solving one instance of a problem relates to smaller problems. For example, when finding the maximum depth of a tree, the solution is the maximum of the maximum depths of all direct subtrees, plus one. Finally, when writing the recursive function, put the "simple case check" at the top and return the solution immediately if true, otherwise, make recursive calls, gather all the results, and form the return value based on those.
 » Rosen Discrete Mathematics is the book and there are excellent and plenty problems in it. If you somehow gain interest also learn about generating functions and how to solve the recursive equations.
 » To be good at Recursion, you first need to be good at Recursion XD
 » 3 months ago, # | ← Rev. 3 →   TLDR, learn from multiple resources. read and watch a lot of examples being solved. and do a lot of examples by yourself, gradually increase level, understand well how recursive code behaves. think of recursion as a method of solving problems by decomposing them into smaller versions. try to write a formal definition of your recursive solutions. Some detailsI think a good approach is the following: Watch and read about recursion in many different resources. This helps me. Watch or read about as many well-explained examples as you can. You should also try to actively engage and solve at this stage while watching Now, do as many examples as you can by yourself . If you had some source of feedback, then excellent. if not, it's not a big problem since you should have some ability to self-correct now gradually increase difficulty of problems. Learn, when ready, advanced techniques like DP. Please note the following: Knowing how to write recursive CODE and understanding its behavior is the easiest part but it's crucial, so make sure you do get it. I suggest doing some simulation of a recursive code using some graphics or debugger. know about call stack, stack frames, local and global variable ... see recursion as a way of solving a computational problem by decomposing it into easier to solve instances of the problem. Always try to well-define relationship between the problem and its subproblems and make it as clear as possible. IDEALLY, express it formally. This will payoff later when you start solving DP problems. example: count the min number of moves needed to solve 3-sticks Hanoi tower with n plates, a good formal expression of the recursive solution is: Let f(n) denote the answer of n-plates tower. then f(0) = 0f(n) = f(n-1) + 1 + f(n-1) = 2 * f(n-1) + 1. Now writing code is a piece of cake and also writing iterative solution is very easy. Please note that, the more complex the recursion, the more important is the formal definition.
•  » » X-O__O-X thaks a lot buddy!! solving from Leetcode might help ?
•  » » » I think solving problems in general will help regardless of the source. Leetcode is good.
 » 3 months ago, # | ← Rev. 3 →   Solve backtracking problems, especially those with lengthy implementation.