Unit 6 - Practice Quiz

CSE205 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 Which data structure is primarily used to implement Breadth-First Search (BFS)?

A. Priority Queue
B. Hash Table
C. Queue
D. Stack

2 Which data structure is primarily used to implement Depth-First Search (DFS)?

A. Stack
B. Heap
C. Queue
D. Linked List

3 What is the time complexity of BFS for a graph represented using an adjacency list with V vertices and E edges?

A. O(E)
B. O(V * E)
C. O(V)
D. O(V + E)

4 What is the time complexity of DFS for a graph represented using an adjacency matrix with V vertices?

A. O(V + E)
B. O(V^2)
C. O(V)
D. O(log V)

5 Which algorithm is best suited for finding the shortest path in an unweighted graph?

A. Kruskal's Algorithm
B. BFS
C. Prim's Algorithm
D. DFS

6 Dijkstra’s Algorithm is based on which algorithmic paradigm?

A. Greedy Approach
B. Backtracking
C. Divide and Conquer
D. Dynamic Programming

7 What is the main limitation of Dijkstra’s Algorithm?

A. It is slower than Bellman-Ford.
B. It only works on directed graphs.
C. It cannot handle cycles.
D. It cannot handle negative weight edges.

8 What is the time complexity of Dijkstra’s Algorithm using a binary heap (priority queue)?

A. O(E log V)
B. O(V^2)
C. O(V log E)
D. O(E + V log V)

9 Which algorithm can detect a negative weight cycle in a graph?

A. Bellman-Ford Algorithm
B. Dijkstra’s Algorithm
C. BFS
D. Prim's Algorithm

10 How many iterations does the Bellman-Ford algorithm run to guarantee shortest paths in a graph with V vertices?

A. V - 1
B. E
C. V + 1
D. V

11 What is the time complexity of the Bellman-Ford algorithm?

A. O(V^2)
B. O(VE)
C. O(V + E)
D. O(E log V)

12 The Floyd Warshall algorithm is used to solve which problem?

A. Minimum Spanning Tree
B. Network Flow
C. All-Pairs Shortest Path
D. Single-Source Shortest Path

13 What is the time complexity of the Floyd Warshall algorithm?

A. O(VE)
B. O(V^3)
C. O(V^2)
D. O(E^2)

14 Floyd Warshall algorithm uses which algorithmic paradigm?

A. Dynamic Programming
B. Branch and Bound
C. Greedy Approach
D. Divide and Conquer

15 In the relaxation step if (d[u] + c(u, v) < d[v]), what does d[v] represent?

A. The shortest distance from u to v
B. The current known shortest distance from source to v
C. The weight of edge (u, v)
D. The number of edges from source to v

16 Which traversal is most appropriate for topological sorting?

A. DFS
B. Floyd Warshall
C. Dijkstra
D. BFS

17 If a graph is disconnected, which traversal will fail to visit all vertices if started from a single source?

A. DFS only
B. BFS only
C. Neither
D. Both BFS and DFS

18 In Dijkstra's algorithm, what is the initial distance value assigned to the source vertex?

A. Infinity
B. 1
C. 0
D. -1

19 What does A[i][j] represent in the final matrix of the Floyd Warshall algorithm?

A. Shortest distance from i to j
B. Length of the longest path from i to j
C. Number of edges between i and j
D. Boolean indicating if i and j are connected

20 Which algorithm is strictly faster for sparse graphs when finding the single-source shortest path with non-negative weights?

A. Bellman-Ford
B. Floyd Warshall
C. Matrix Multiplication
D. Dijkstra (with Heap)

21 During DFS, if we encounter an edge to a vertex that is currently in the recursion stack, what does this indicate?

A. A disconnected component
B. A cycle
C. A bridge
D. A shortest path

22 Bellman-Ford works on which type of graphs?

A. Trees only
B. Directed graphs with negative weights (no negative cycles)
C. DAGs only
D. Undirected graphs with positive weights only

23 What is the space complexity of the Floyd Warshall algorithm?

A. O(E)
B. O(V^2)
C. O(V^3)
D. O(V)

24 Which algorithm calculates the shortest path from a single source to all other vertices?

A. Johnson's Algorithm
B. Floyd Warshall
C. Kruskal's Algorithm
D. Dijkstra's Algorithm

25 In BFS, nodes are visited in an order based on their:

A. Weight
B. Finish time
C. Distance from the source
D. Alphabetical order

26 In the context of Bellman-Ford, what happens if the graph contains a negative weight cycle?

A. The algorithm loops infinitely.
B. The algorithm can report the existence of the cycle.
C. The algorithm returns the correct shortest path.
D. The algorithm converts negative weights to positive.

27 The recurrence relation D[i][j] = min(D[i][j], D[i][k] + D[k][j]) belongs to which algorithm?

A. Dijkstra
B. Floyd Warshall
C. Bellman-Ford
D. DFS

28 Which of the following is an application of DFS?

A. Broadcasting in a network
B. Finding the shortest path in unweighted graphs
C. GPS Navigation systems
D. Solving the maze problem

29 If we use an adjacency matrix to represent a graph for Dijkstra's algorithm, the time complexity becomes:

A. O(V^3)
B. O(E log V)
C. O(E + V)
D. O(V^2)

30 What is the maximum number of edges in a connected undirected graph with V vertices?

A. V - 1
B. V
C. V^2
D. V(V-1)/2

31 Which traversal algorithm uses less memory (space complexity) for a very deep but narrow tree?

A. Bellman-Ford
B. DFS
C. Dijkstra
D. BFS

32 Which of the following algorithms can handle directed graphs with negative edges?

A. Kruskal
B. Bellman-Ford
C. Prim
D. Dijkstra

33 What is the initial state of the distance array in Dijkstra's algorithm for all vertices except the source?

A. 1
B. 0
C. Undefined
D. Infinity

34 In a Dense Graph (where E is close to V^2), which algorithm is generally preferred for Single Source Shortest Path?

A. Dijkstra using Array
B. Bellman-Ford
C. Dijkstra using Priority Queue
D. Floyd Warshall

35 A 'Cross Edge' is a concept encountered in which algorithm?

A. DFS
B. BFS
C. Floyd Warshall
D. Bellman-Ford

36 To reconstruct the shortest path after running Dijkstra’s or Bellman-Ford, what additional information must be stored?

A. The parent (predecessor) of each node
B. The visit time
C. The degree of nodes
D. The edge weights

37 Can Floyd Warshall algorithm detect negative cycles?

A. No, never.
B. Yes, if the total sum of weights is negative.
C. Yes, if a diagonal element distance becomes negative.
D. Only if the graph is undirected.

38 Which algorithm calculates the Transitive Closure of a graph?

A. Floyd Warshall
B. Dijkstra
C. Prim
D. Bellman-Ford

39 In BFS, what are the colors usually associated with nodes during processing?

A. True, False, Null
B. White, Gray, Black
C. Red, Green, Blue
D. 0, 1, 2

40 Dijkstra's algorithm can be implemented efficiently using:

A. Stack
B. Queue
C. Min-Priority Queue
D. Max-Priority Queue

41 If you need to find the shortest path between two specific nodes (u, v), which algorithm is typically stopped early?

A. Bellman-Ford
B. Floyd Warshall
C. Dijkstra
D. Kruskal

42 Which algorithm is capable of handling a graph with cycles?

A. Dijkstra
B. DFS
C. All of the above
D. BFS

43 The process of updating the distance of a vertex v using a neighbor u is called:

A. Exploration
B. Relaxation
C. Initialization
D. Visitation

44 What is the minimum number of edges required to connect a graph with N vertices?

A. 0
B. N
C. N - 1
D. N / 2

45 Which algorithm is most sensitive to the order of edges processed if not using a specific data structure?

A. Floyd Warshall
B. BFS
C. Bellman-Ford
D. None

46 In a graph where edge weights represent probabilities of success, how do we transform the problem to use Shortest Path algorithms?

A. Use 1/weight
B. Use weight^2
C. Use 1 - weight
D. Use -log(weight)

47 Breadth-First Search is equivalent to Level-Order Traversal in which data structure?

A. Tree
B. Graph
C. Array
D. Stack

48 Which graph representation is most space-efficient for sparse graphs?

A. Incidence Matrix
B. 2D Array
C. Adjacency List
D. Adjacency Matrix

49 In the classification of edges in DFS, what is a 'Forward Edge'?

A. The edge connecting parent to child in the DFS tree
B. An edge from a node to its ancestor
C. An edge to a previously visited node in a different branch
D. An edge from a node to a descendant that is not a child

50 Why is Bellman-Ford not preferred over Dijkstra for graphs with non-negative weights?

A. Bellman-Ford requires more space
B. Bellman-Ford is harder to implement
C. Bellman-Ford gives incorrect results for positive weights
D. Bellman-Ford has a higher time complexity