2. If x is a parent of y, then x is older than y. If x is mother of y, then x is parent of y. Lulu is mother of Fifi. Therefore, Lulu is older than Fifi
4. Take a look at the below graph, we will use the Breadth-First Search algorithm to traverse through the graph.
In our case, we’ll assign node ‘a’ as the root node and start traversing downward and follow the steps mentioned above.
The above image depicts the end-to-end process of Breadth-First Search Algorithm. Let me explain this in more depth.
- Assign ‘a’ as the root node and insert it into the Queue.
- Extract node ‘a’ from the queue and insert the child nodes of ‘a’, i.e., ‘b’ and ‘c’.
- Print node ‘a’.
- The queue is not empty and has node ‘b’ and ‘c’. Since ‘b’ is the first node in the queue, let’s extract it and insert the child nodes of ‘b’, i.e., node ‘d’ and ‘e’.
- Repeat these steps until the queue gets empty. Note that the nodes that are already visited should not be added to the queue again.