Professional Documents
Culture Documents
Which of the following algorithms can be used to most efficiently determine the presence
of a cycle in a given graph?
A.
B.
C.
D.
There can be a loop in graph so we must maintain a visited flag for every vertex.
DFS of a graph uses stack, but in order traversal of a tree is recursive.
BFS of a graph uses queue, but a time efficient BFS of a tree is recursive.
All of the above.
3. The Breadth First Search algorithm has been implemented using the queue data structure.
One possible order of visiting the nodes of the following graph is
A.
B.
C.
D.
MNOPQR
NQMPOR
QMNPRO
QMNPOR
(unvisited) vertex visited after visiting u in the traversal. Which of the following
statements is always true?
A.
B.
C.
D.
5. Given two vertices in a graph s and t, which of the two traversals (BFS and DFS) can be
used to find if there is path from s to t?
A.
B.
C.
D.
Only BFS
Only DFS
Both BFS and DFS
Neither BFS nor DFS
A.
B.
C.
D.
P, Q, R, S, T, U.
P, Q, R, U, S, T.
P, Q, R, U, T, S.
P, Q, T, R, U, S.
8. Which of the following algorithm can be used to efficiently calculate single source
shortest paths in a Directed Acyclic Graph?
A.
B.
C.
D.
Dijkstra.
Bellman-Ford.
Topological Sort.
Strongly Connected Component.
O(| V |2)
O (| E | + | V | log | V |)
O (| V | log | V |)
O ((| E | + | V |) log | V |)
Answers.
1. A
2. D
3. C
4. C
5. C
6. D
7. B
8. C
9. A
10. D