Блог пользователя marawan222

Автор marawan222, история, 9 часов назад, По-английски

Hello codeforces , a few days ago i started learning more about recursion , and i indeed tried to solve some very basic problems on it , however , when it comes to tricky problems i cannot think how to implement a recursive function to solve the problem , another thing makes me wondring is when should i implement a recursive function and when i use the iterative function, so if anyone has some ideas about the previous questions , write it below.

thanks.

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
9 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

https://codeforces.net/problemset/problem/1385/D

you can try this question it is fully recursion based question

»
9 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Try to solve a few problems on the complete search section of USACO.guide I would suggest trying to think in similar lines of how we think of dynamic programming. In fact tutorials for dynamic programming may exactly be what you need to fully understand how to use recursion. The overall goal is always to define a state and break the problem into indepedent subproblems and instead of focusing on actually solving the problem, we focus on how we transition from the sub problems to the higher problem.

Its a personal rant but recursion in my humble opinion is actually a very difficult thing to fully grasp, especially when one is starting out. I still don't understand why it was taught to me and many others even before pointers and stuff, as If their difficulty in terms of understanding and applying is even close let alone being easier.

But keep practicing obviously, it becomes second nature soon enough.