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. Hash Table
B. Priority Queue
C. Queue
D. Stack

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

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

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

A. O(V)
B. O(V + E)
C. O(E)
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)
C. O(log V)
D. O(V^2)

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. Divide and Conquer
B. Backtracking
C. Greedy Approach
D. Dynamic Programming

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

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

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

A. O(V^2)
B. O(E log V)
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
B. V + 1
C. V - 1
D. E

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

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

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

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

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

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

14 Floyd Warshall algorithm uses which algorithmic paradigm?

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

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

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

16 Which traversal is most appropriate for topological sorting?

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

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

A. BFS only
B. DFS 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. 1
B. Infinity
C. -1
D. 0

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

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

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

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

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

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

22 Bellman-Ford works on which type of graphs?

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

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

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

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

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

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

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

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 converts negative weights to positive.
C. The algorithm returns the correct shortest path.
D. The algorithm can report the existence of the cycle.

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

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

28 Which of the following is an application of DFS?

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

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

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

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

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

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

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

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

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

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

A. Undefined
B. 0
C. 1
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. Dijkstra using Priority Queue
C. Floyd Warshall
D. Bellman-Ford

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

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

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

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

37 Can Floyd Warshall algorithm detect negative cycles?

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

38 Which algorithm calculates the Transitive Closure of a graph?

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

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. Max-Priority Queue
B. Stack
C. Min-Priority Queue
D. Queue

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

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

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

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

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

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

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

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

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

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

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 -log(weight)
C. Use weight^2
D. Use 1 - 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. Adjacency Matrix
B. Adjacency List
C. 2D Array
D. Incidence Matrix

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

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

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

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