Recursive Thinking—Secret Santa
You live in a village that has an annual Holiday of Gifts when each person in the village gives another person a gift. The tradition is that children do not give gifts, and seniors do not receive gifts. Everyone else gives one gift and receives one gift. It is public knowledge who is responsible for whose gift. Starting with every senior there is a chain of giftgivers terminating with a child. Assume that you are neither a senior nor a child. Design a recursive algorithm to determine the length of the chain from a senior to you, and another recursive algorithm to calculate the length of the chain from you to a child.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.