Q. In a graph, if you want to find the shortest path in an unweighted graph, which traversal method would you use?
A.
DFS
B.
BFS
C.
Dijkstra's Algorithm
D.
A* Search
Show solution
Solution
BFS is used to find the shortest path in an unweighted graph because it explores all nodes at the present depth before moving on.
Correct Answer:
B
— BFS
Learn More →
Q. In BFS, which node is visited first?
A.
The deepest node
B.
The first node added to the queue
C.
The last node added to the queue
D.
The parent node
Show solution
Solution
In BFS, the first node added to the queue is visited first, as BFS explores all neighbors at the present depth prior to moving on to nodes at the next depth level.
Correct Answer:
B
— The first node added to the queue
Learn More →
Q. What does BFS stand for in graph traversal?
A.
Binary First Search
B.
Breadth First Search
C.
Best First Search
D.
Backtracking First Search
Show solution
Solution
BFS stands for Breadth First Search, which is an algorithm for traversing or searching tree or graph data structures.
Correct Answer:
B
— Breadth First Search
Learn More →
Q. What is the main difference between BFS and DFS?
A.
BFS uses a stack, DFS uses a queue
B.
BFS explores neighbors level by level, DFS explores as far as possible along a branch
C.
BFS is faster than DFS
D.
DFS is used for unweighted graphs only
Show solution
Solution
The main difference is that BFS explores neighbors level by level, while DFS explores as far as possible along a branch before backtracking.
Correct Answer:
B
— BFS explores neighbors level by level, DFS explores as far as possible along a branch
Learn More →
Q. What is the space complexity of BFS?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V^2)
Show solution
Solution
The space complexity of BFS is O(V) due to the storage of the queue that holds all vertices at the current level.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the time complexity of BFS in a graph with V vertices and E edges?
A.
O(V + E)
B.
O(V^2)
C.
O(E log V)
D.
O(V log V)
Show solution
Solution
The time complexity of BFS is O(V + E), where V is the number of vertices and E is the number of edges in the graph.
Correct Answer:
A
— O(V + E)
Learn More →
Q. Which algorithm is more memory efficient for deep graphs?
A.
BFS
B.
DFS
C.
Both are equal
D.
Neither is efficient
Show solution
Solution
DFS is generally more memory efficient for deep graphs because it uses a stack and does not need to store all nodes at the current level like BFS does.
Correct Answer:
B
— DFS
Learn More →
Q. Which of the following data structures is typically used to implement DFS?
A.
Queue
B.
Stack
C.
Array
D.
Linked List
Show solution
Solution
DFS (Depth First Search) is typically implemented using a stack data structure, either explicitly or via recursion.
Correct Answer:
B
— Stack
Learn More →
Q. Which of the following is true about DFS?
A.
It can be implemented using recursion
B.
It always finds the shortest path
C.
It uses a queue
D.
It is not suitable for cyclic graphs
Show solution
Solution
DFS can be implemented using recursion, as it explores each branch of the graph until it reaches a leaf node.
Correct Answer:
A
— It can be implemented using recursion
Learn More →
Q. Which traversal method uses a queue for its implementation?
A.
DFS
B.
BFS
C.
In-order
D.
Pre-order
Show solution
Solution
BFS (Breadth First Search) uses a queue for its implementation to keep track of the next vertex to visit.
Correct Answer:
B
— BFS
Learn More →
Showing 1 to 10 of 10 (1 Pages)