Question 137Asked in DSSSB TGT Computer Science, 25 Jun 2023, Shift 3 (4:30 PM)
What is the main difference between a depth-first search (DFS) and a breadth-tint search (BFS) algorithm?
ABFS is used for traversing a tree, while DFS is used for traversing a graph.
BDFS is used for traversing a tree, while BFS is used for traversing a graph.
CDFS explores as far as possible along each branch before backtracking, while BFS visits all the vertices at the current depth before moving on to the next level.
DBFS explores as far as possible along each branch before backtracking, while DFS visits all the vertices at the current depth before moving on to the next level.
Show answerHide answer
Correct answer: (C) DFS explores as far as possible along each branch before backtracking, while BFS visits all the vertices at the current depth before moving on to the next level.
Explanation
DFS goes as deep as possible along one branch before backtracking (using a stack). BFS visits all vertices at the current level before the next level (using a queue).
From DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 3 (4:30 PM)