Q. In a tree, which traversal method is equivalent to a level order traversal?
-
A.
DFS
-
B.
BFS
-
C.
In-order
-
D.
Pre-order
Solution
Level order traversal of a tree is equivalent to BFS, as it visits nodes level by level.
Correct Answer:
B
— BFS
Learn More →
Q. What is the space complexity of BFS in the worst case?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(V^2)
Solution
The space complexity of BFS in the worst case is O(V) due to the storage of the queue.
Correct Answer:
A
— O(V)
Learn More →
Q. Which algorithm is typically used for finding the shortest path in a weighted graph?
-
A.
DFS
-
B.
BFS
-
C.
Dijkstra's Algorithm
-
D.
Prim's Algorithm
Solution
Dijkstra's Algorithm is used for finding the shortest path in a weighted graph.
Correct Answer:
C
— Dijkstra's Algorithm
Learn More →
Q. Which of the following applications can be solved using BFS?
-
A.
Finding connected components
-
B.
Topological sorting
-
C.
Cycle detection
-
D.
Finding strongly connected components
Solution
BFS can be used to find connected components in an undirected graph.
Correct Answer:
A
— Finding connected components
Learn More →
Q. Which of the following is a characteristic of Depth-First Search (DFS)?
-
A.
Uses a queue
-
B.
Can be implemented using recursion
-
C.
Always finds the shortest path
-
D.
Visits nodes level by level
Solution
DFS can be implemented using recursion, which allows it to explore as far as possible along each branch before backtracking.
Correct Answer:
B
— Can be implemented using recursion
Learn More →
Showing 1 to 5 of 5 (1 Pages)