Skip to main content

10 PYQ / MCQ questions related to.BFS (Breadth-First Search) and DFS (Depth-First Search)

Here are some MCQ questions related to BFS (Breadth-First Search) and DFS (Depth-First Search) with descriptions:

1. GATE CS 2020
Which data structure is commonly used to implement Breadth-First Search (BFS)?
A) Stack
B) Queue
C) Priority Queue
D) Linked List
Answer: B) Queue
Description: BFS explores nodes level by level and uses a queue to store the nodes to be visited next.

2. UGC NET 2019
Which data structure is commonly used to implement Depth-First Search (DFS)?
A) Queue
B) Stack
C) Priority Queue
D) Binary Tree
Answer: B) Stack
Description: DFS uses a stack to explore the deepest nodes first before backtracking. A recursive implementation uses the call stack.

3. ISRO Scientist 2018
The time complexity of Breadth-First Search (BFS) for a graph with VV vertices and EE edges is:
A) O(V + E)
B) O(V²)
C) O(E²)
D) O(V * E)
Answer: A) O(V + E)
Description: BFS traverses every vertex and edge at most once, resulting in a linear time complexity.

4. GATE CS 2017
In which scenario is DFS preferred over BFS?
A) Finding the shortest path
B) Detecting cycles in a graph
C) Level-order traversal
D) Topological sorting
Answer: B) Detecting cycles in a graph
Description: DFS is efficient for cycle detection and topological sorting, while BFS is better for finding shortest paths in unweighted graphs.

5. NIELIT Scientist B 2019
Which traversal technique is used in finding connected components of an undirected graph?
A) BFS
B) DFS
C) Both A and B
D) None of these
Answer: C) Both A and B
Description: Both BFS and DFS can be used to find connected components by visiting all reachable nodes from each unvisited vertex.

6. GATE CS 2018
Which of the following is true regarding DFS and BFS in a tree?
A) Both traverse all nodes
B) BFS requires more space than DFS
C) DFS requires more space than BFS
D) Both have the same space complexity
Answer: B) BFS requires more space than DFS
Description: BFS stores all child nodes at each level, while DFS only needs to store nodes along the current path, so BFS typically uses more space.

7. UGC NET 2020
Which of the following traversal techniques uses backtracking?
A) BFS
B) DFS
C) Dijkstra’s Algorithm
D) Prim’s Algorithm
Answer: B) DFS
Description: DFS uses backtracking to explore all possible paths before moving to the next branch.

8. GATE CS 2016
Which of the following is NOT a characteristic of BFS?
A) Uses a queue
B) Suitable for finding shortest paths in unweighted graphs
C) Can detect cycles in a graph
D) Uses recursion
Answer: D) Uses recursion
Description: BFS typically uses an iterative approach with a queue, while DFS may use recursion.

9. NIELIT Scientist B 2021
If a graph has V vertices and E edges, what is the space complexity of DFS using an adjacency list?
A) O(V)
B) O(E)
C) O(V + E)
D) O(V²)
Answer: C) O(V + E)
Description: Storing the graph in an adjacency list takes O(V + E) space, and the DFS traversal itself uses O(V) space for the recursion stack.

10. GATE CS 2015
What is the primary difference between BFS and DFS?
A) BFS uses backtracking, DFS does not
B) DFS uses a queue, BFS uses a stack
C) BFS explores level by level, DFS goes deep
D) Both use the same traversal strategy
Answer: C) BFS explores level by level, DFS goes deep
Description: BFS explores each level fully before moving deeper, while DFS goes as deep as possible along one branch before backtracking.

Comments

Popular posts from this blog

Top 5 Safe Chat Apps for Kids with Parental Controls

Now a days kids are growing up with technology at their fingertips. While communication apps help children stay connected with family and friends, safety remains a top concern for parents. Unregulated platforms can expose children to inappropriate content, online predators, and cyberbullying. That’s why choosing a kid-friendly chat app with parental controls is essential. To help parents find the best options, we’ve compiled a list of the top five safest chat apps for kids that offer safe and controlled environment. 1. Messenger Kids (By Meta) Best for: Safe video calls and text messaging with parental supervision Features: Parents approve all contacts No ads or in-app purchases Fun filters, stickers, and games Monitored messaging and activity reports Why It’s Safe: Messenger Kids is designed for children under 13 and requires parental approval for every contact. Parents can monitor chats and control screen time through the Parent Dashboard. Download Messenger Kids 2...

10 Routing Protocol MCQ

10 multiple-choice questions on Routing protocol s  with explanations, useful for UGC NET, SET, GATE, ISRO, and other competitive exams . Question 1: Purpose of Routing Protocols Q1: What is the primary purpose of a routing protocol? A) To assign IP addresses to devices B) To determine the best path for data packets to reach their destination C) To encrypt data during transmission D) To physically connect different networks Answer: B) To determine the best path for data packets to reach their destination Explanation: Routing protocols help routers determine the most efficient path for data transmission across a network, ensuring fast and reliable communication. Question 2: Classification of Routing Protocols Q2: Routing protocols can be broadly classified into which two main categories? A) TCP and UDP B) Distance Vector and Link-State C) IPv4 and IPv6 D) Static and Dynamic Answer: B) Distance Vector and Link-State Explanation: Routing prot...

10 Distance Vector and Link-State Routing MCQ

  10 multiple-choice questions  on  Distance Vector and Link-State Routing with explanations, useful for  UGC NET, SET, GATE, ISRO, and other competitive exams . Question 1: Basic Concept of Distance Vector Routing Q1: In a distance vector routing protocol, how do routers share routing information? A) By flooding the entire network with routing updates B) By periodically exchanging routing tables with their immediate neighbors C) By using a link-state database to determine the shortest path D) By dynamically updating paths based on link failure reports Answer: B) By periodically exchanging routing tables with their immediate neighbors Explanation: In Distance Vector Routing, routers share their routing tables with neighbors at regular intervals, leading to a simple but slow convergence mechanism. Question 2: Example of Distance Vector Routing Protocol Q2: Which of the following is an example of a Distance Vector routing protocol? A) OSPF ...