Week 9 Assignment
Week 9 Assignment
1. Applying Dijkstra’s algorithm on the following figure,what is the order in which vertices will be
visited? (Use source vertex B.)
A) BDCAEF
B) BDCFAE
C) BDCAFE
D) BDFCAE
2. In the following figure, the shortest path from A to C is along the edges AB,BC. Find the smallest
positive integer from the given options that can be added to all edge weights of the graph such that
it will change the shortest path from A to C
A) 7
B) 6
C) 3
D) 4
3. What is the time complexity of Graph Traversal for DFS and BFS?
4. In the following figure, which one of the following options gives a negative weight cycle?
A) BAFDACB
B) BACB
C) BAFDCB
D) BADCB
5. The time complexity of Dijkstra’s algorithm while using array as the data structure is:
A) O(1)
B) O(log V)
C) O(log E)
D)O(V2)
6. Consider the given figure and find out which will be the first three vertices traversed by BFS and
DFS, respectively. Take A as starting point.
A) BFS-ABC,DFS-ABC or ADG
B)BFS-ABD,DFS-ABC or ADG
D) BFS-ABG,DFS-ABD or ACG
7. Which of the following algorithms can be used to detect negative weight cycles in a directed
graph?
A) Bellman Ford
B) Prim's
C) Kruskal's
D) Dijkstra's
8. Apply Dijkstra's Algorithm on the following figure and write down the order in which vertices will be
visited starting from vertex A.
A) ABCDEF
B) ABDCEF
C) ACBDEF
D) ABDEFC
9. Using the same figure of question 8, what is the shortest distance from A to each of B,C,D,E,F
respectively?
A) 4 8 6 7 13
B) 4 6 8 7 10
C) 4 8 9 7 10
D) 4 7 6 8 10