3 ms·
I think the family tree example would work better upside down, as you can easily state a problem that is obviously more intuitive to solve recursively (depth fi
by tiagod 4y ago
I think the family tree example would work better upside down, as you can easily state a problem that is obviously more intuitive to solve recursively (depth first search).
Start by defining a node object (a person) which contains a name and a list of their offspring (other nodes).
Find if the given starting node or any of their descendants have a certain first name, or some other property.