can anyone suggest me how to be good at recursion and what should be my approach? From where shall i solve questions?

# | User | Rating |
---|---|---|

1 | tourist | 3682 |

2 | ecnerwala | 3603 |

3 | Benq | 3549 |

4 | Radewoosh | 3494 |

5 | Petr | 3452 |

6 | ksun48 | 3413 |

7 | maroonrk | 3406 |

8 | Miracle03 | 3314 |

9 | scott_wu | 3313 |

10 | Um_nik | 3299 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 214 |

2 | Errichto | 189 |

3 | awoo | 188 |

4 | rng_58 | 187 |

5 | SecondThread | 186 |

6 | Um_nik | 178 |

7 | Ashishgup | 177 |

8 | maroonrk | 173 |

9 | antontrygubO_o | 172 |

10 | -is-this-fft- | 169 |

can anyone suggest me how to be good at recursion and what should be my approach? From where shall i solve questions?

↑

↓

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/18/2021 17:58:00 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

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....

Too old joke

Good one mate !!

If you see this reply, don't click on the comment above. (Base case)

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

User.Invalid

Of course. Why not!!

The topics Link: https://codeforces.com/group/MWSDmqGsZm/contests

solve recursion problems, duh

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

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

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

Learn, when ready, advanced techniques like DP.

Please note the following:

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) = 0

f(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.

Solve backtracking problems, especially those with lengthy implementation.