how to tackle a problem using recursion

I have started dynamic programming,then i found that in most of the problems related to dynamic programming there is heavy use of recursion.So i thought to grip recursion,and I am finding it a bit difficult to tackle,So can anyone please help me in understanding how recursion works,and how to approach for the recuurence relation used in most of the recursion.Like i was trying to understand the solution of this problem via recursion
http://www.spoj.com/problems/DANGER/ (JOSEPHUS PROBLEM),
and i wonder how to come out the recuurence relation of such type of problems.
Thanks in Advance

I would recommend Concrete Mathematics By-Graham,Knuth,Patashnik.
It have complete details on recursion and recurrence and also how to solve Josephus problem with different ways.

1 Like

The answer to your SPOJ problem : http://ideone.com/FUZQNO & https://ideone.com/6hf79H
You can always consider platforms like Stackoverflow for suck queries and yes you can google your queries too.

1 Like