Data Structure Questions and Answers on Breadth First Search for Freshers


1. Breadth First Search is equivalent to which of the traversal in the Binary Trees?

a) Pre-order Traversal
b) Post-order Traversal
c) Level-order Traversal
d) In-order Traversal
Answer: c

Explanation: The Breadth First Search Algorithm searches the nodes on the basis of level. It takes a node (level 0), explores it’s neighbors (level 1) and so on.
2. Time Complexity of Breadth First Search is? (V – number of vertices, E – number of edges)

a) O(V + E)
b) O(V)
c) O(E)
d) None of the mentioned
Answer: a

Explanation: The Breadth First Search explores every node once and every edge once (in worst case), so it’s time complexity is O(V + E).
3. The Data structure used in standard implementation of Breadth First Search is?

a) Stack
b) Queue
c) Linked List
d) None of the mentioned
Answer: b

Explanation: The Breadth First Search explores every node once and put that node in queue and then it takes out nodes from the queue and explores it’s neighbors.
4. The Breadth First Search traversal of a graph will result into?

a) Linked List
b) Tree
c) Graph with back edges
d) All of the mentioned
Answer: b

Explanation: The Breadth First Search will make a graph which don’t have back edges (a tree) which is known as Breadth First Tree.
5. A person wants to visit some places. He starts from a vertex and then wants to visit every place connected to this vertex and so on. What algorithm he should use?

a) Depth First Search
b) Breadth First Search
c) Trim’s algorithm
d) None of the mentioned
Answer: b

Explanation: This is the definition of the Breadth First Search. Exploring a node, then it’s neighbors and so on.
6. What can be the applications of Breadth First Search?

a) Finding shortest path between two nodes
b) Finding bipartiteness of a graph
c) GPS navigation system
d) All of the mentioned
Answer: d

Explanation: Breadth First Search can be applied to all of the mentioned problems. Bipartiteness of a graph means that a graph can be divided into two disjoint sets such that every edge connects a vertex in to one in.
7. When the Breadth First Search of a graph is unique?

a) When the graph is a Binary Tree
b) When the graph is a Linked List
c) When the graph is a n-ary Tree
d) None of the mentioned
Answer: b

Explanation: When Every node will have one successor then the Breadth First Search is unique. In all other cases, when it will have more than one successor, it can choose any of them in arbitrary order.
8. Regarding implementation of Breadth First Search using queues, what is the maximum distance between two nodes present in the queue? (considering each edge length 1)

a) Can be anything
b) 0
c) At most 1
d) Insufficient Information
Answer: c

Explanation: In the queue, at a time, only those nodes will be there whose difference among levels is 1. Same as level order traversal of the tree.
9. In BFS, how many times a node is visited?

a) Once
b) Twice
c) equivalent to number of indegree of the node
d) None of the mentioned
Answer: c

Explanation: In Breadth First Search, we have to see whether the node is visited or not by it’s ancestor. If it is visited, we won’t let it enter it in the queue.

Related

Multiple Choice Questions 4383116462559355623

Post a Comment

emo-but-icon

item