Which traversal of tree resembles the breadth first search of the grap...
Breadth first search visits all the neighbors first and then deepens into each neighbor one by one. The level order traversal of the tree also visits nodes on the current level and then goes to the next level.
Which traversal of tree resembles the breadth first search of the grap...
Explanation:
Breadth First Search (BFS) is a graph traversal algorithm that explores all the vertices of a graph or tree in a breadthward motion, i.e., it visits all the vertices at the same level before moving to the next level.
The given options for tree traversals are:
a) Preorder: In preorder traversal, the order of traversal is root, left, right.
b) Inorder: In inorder traversal, the order of traversal is left, root, right.
c) Postorder: In postorder traversal, the order of traversal is left, right, root.
d) Level order: In level order traversal, the order of traversal is from left to right at each level, starting from the root.
Comparison with Breadth First Search:
To determine which traversal of a tree resembles the BFS of a graph, let's compare the characteristics of BFS with the given options:
1. Preorder, Inorder, and Postorder traversals are depth-first traversals, which means they explore the nodes in a depthward motion, i.e., they visit the deeper nodes before moving to the next level. Therefore, these traversals do not resemble BFS.
2. Level order traversal explores the nodes in a breadthward motion, similar to BFS. It visits all the nodes at the same level before moving to the next level. Therefore, level order traversal resembles BFS.
Conclusion:
Based on the comparison, the traversal that resembles the breadth first search of a graph is Level order traversal (option D).