BFS Traversal
BFS Traversal
BFS Traversal
1. Start with the source node and initialize an empty list to store paths.
2. Use a helper function that:
o Adds the current node to the current path.
o If the current node is the destination:
Save the current path.
o Otherwise:
For each neighbor of the current node:
If the neighbor hasn’t been visited:
Recursively call the helper function for the neighbor.
o After exploring all neighbors, backtrack by removing the current node from the
path.
Preorder Traversal:
Inorder Traversal:
Postorder Traversal: