0% found this document useful (0 votes)
18 views4 pages

Discrete Sturcture MCQ

The document contains questions and answers about depth first search (DFS) and breadth first search (BFS) graph traversal algorithms. Key points: - DFS is equivalent to pre-order tree traversal and results in a depth first tree when applied to a graph. - BFS is equivalent to level-order tree traversal and results in a breadth first tree when applied to a graph. - Both have time complexity of O(V+E) where V is vertices and E is edges. DFS uses a stack while BFS uses a queue.

Uploaded by

alia bano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Discrete Sturcture MCQ

The document contains questions and answers about depth first search (DFS) and breadth first search (BFS) graph traversal algorithms. Key points: - DFS is equivalent to pre-order tree traversal and results in a depth first tree when applied to a graph. - BFS is equivalent to level-order tree traversal and results in a breadth first tree when applied to a graph. - Both have time complexity of O(V+E) where V is vertices and E is edges. DFS uses a stack while BFS uses a queue.

Uploaded by

alia bano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

. Depth 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: a
2. Time Complexity of DFS is? (V – number of vertices, E – number of edges)
a) O(V + E)
b) O(V)
c) O(E)
d) O(V*E)

Answer: a

3. The Data structure used in standard implementation of Breadth First Search is?
a) Stack
b) Queue
c) Linked List
d) Tree

Answer: a

4. The Depth First Search traversal of a graph will result into?


a) Linked List
b) Tree
c) Graph with back edges
d) Array

Answer: b
Clarification: The Depth First Search will make a graph which don’t have back edges
(a tree) which is known as Depth First Tree.
5. A person wants to visit some places. He starts from a vertex and then wants to
visit every vertex till it finishes from one vertex, backtracks and then explore other
vertex from same vertex. What algorithm he should use?
a) Depth First Search
b) Breadth First Search
c) Trim’s algorithm
d) Kruskal’s Algorithm

Answer: a

6. Which of the following is not an application of Depth First Search?


a) For generating topological sort of a graph
b) For generating Strongly Connected Components of a directed graph
c) Detecting cycles in the graph
d) Peer to Peer Networks

Answer: d

7. When the Depth 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) When the graph is a ternary Tree

Answer: b

8. Regarding implementation of Depth First Search using stacks, what is the


maximum distance between two nodes present in the stack? (considering each edge
length 1)
a) Can be anything
b) 0
c) At most 1

Answer: a

9. In Depth First Search, how many times a node is visited?


a) Once
b) Twice
c) Equivalent to number of indegree of the node
d) Thrice
Answer: c

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

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) O(V*E)

Answer: a

3. The Data structure used in standard implementation of Breadth First Search is?
a) Stack
b) Queue
c) Linked List
d) Tree

Answer: b

4. The Breadth First Search traversal of a graph will result into?


a) Linked List
b) Tree
c) Graph with back edges
d) Arrays

Answer: b

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) Kruskal’s algorithm

Answer: b

6. Which of the following is not an application of Breadth First Search?


a) Finding shortest path between two nodes
b) Finding bipartiteness of a graph
c) GPS navigation system
d) Path Finding

Answer: d

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) When the graph is a Ternary Tree

Answer: b

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

9. In BFS, how many times a node is visited?


a) Once
b) Twice
c) Equivalent to number of indegree of the node
d) Thrice

Answer: c

You might also like