Recursive Thinking—Trees
You live in B-land where the King is named B. The King has two advisers. Each of these advisers has two other advisers and so on. Everyone in the village has two advisers except the peasants. Everyone in the village advises exactly one person, except the King who advises nobody. The peasants have no advisers (but each advises one other person). The name of a person’s two advisers is public knowledge.
Design recursive algorithms to:
• count the number of peasants in B-land.
• count the total number of people in B-land.
• list the names of everyone in B-land.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here