Choose the incorrect statement about DFS and BFS from the following?

Choose the incorrect statement about DFS and BFS from the following?
A. BFS is equivalent to level order traversal in trees
B. DFS is equivalent to post order traversal in trees
C. DFS and BFS code has the same time complexity
D. BFS is implemented using queue
 
Answer: B
Explanation: DFS is equivalent to pre order traversal in trees, not post order traversal. It is so because in DFS we keep on exploring as far as possible along each branch before backtracking. So it should be equivalent to pre order traversal.
 

Tìm kiếm

Back
Top