Level order traversal of a rooted tree can be done by starting from the root and performing
GATE CSE 2004Data Structures › Trees & Binary Search TreesVerified
GATE CSE 2004 PYQ: Level order traversal of a rooted tree can be done by starting from the root and performing
- A
preorder traversal
- B
in-order traversal
- C
depth first search
- DCorrect answer
breadth first search
Answer
(D) breadth first search
Approach
Recognize that level-order traversal visits all nodes at the current depth before moving to the next depth. This is exactly the order produced by breadth-first search (BFS), which uses a queue starting from the root.
Level-order traversal is equivalent to breadth-first search on a rooted tree. It uses a queue to visit nodes depth by depth from the root.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.