Unit 4 - Practice Quiz

CSE408 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 Which algorithmic technique is generally used to efficiently compute the Binomial Coefficient by avoiding recomputation of subproblems?

Dynamic Programming: Computing a Binomial Coefficient Easy
A. Greedy Technique
B. Dynamic Programming
C. Divide and Conquer
D. Backtracking

2 What is the primary purpose of Warshall's algorithm?

Warshall's and Floyd's Algorithm Easy
A. To find the minimum spanning tree
B. To find the transitive closure of a directed graph
C. To find the shortest path between all pairs of vertices
D. To perform a topological sort

3 Floyd's algorithm is used to solve which of the following problems?

Warshall's and Floyd's Algorithm Easy
A. Single-Source Shortest Paths
B. Minimum Spanning Tree
C. All-Pairs Shortest Paths
D. Maximum Flow

4 In an Optimal Binary Search Tree, what is minimized?

Optimal Binary Search Trees Easy
A. The height of the tree
B. The number of leaf nodes
C. The average search cost
D. The number of edges

5 Which of the following problems can be optimally solved using dynamic programming by building a 2D table representing item weights and knapsack capacity?

Knapsack Problem and Memory Functions Easy
A. Maximum Flow Problem
B. Travelling Salesperson Problem
C. Fractional Knapsack Problem
D. 0/1 Knapsack Problem

6 What is a 'memory function' in the context of dynamic programming?

Knapsack Problem and Memory Functions Easy
A. A function that limits memory usage of an algorithm
B. A hardware component to store array elements
C. A top-down approach that caches results of solved subproblems
D. A bottom-up approach that fills an entire table

7 What is the goal of the Matrix-Chain Multiplication problem?

Matrix-Chain Multiplication Easy
A. To sort the matrices in ascending order of size
B. To multiply matrices using minimum memory
C. To find the product of matrices as fast as possible by changing matrix values
D. To find the optimal parenthesization to minimize scalar multiplications

8 If string A is 'ABC' and string B is 'AC', what is the length of their Longest Common Subsequence?

Longest Common Subsequence Easy
A. 3
B. 0
C. 2
D. 1

9 A Minimum Spanning Tree of a connected, undirected graph with vertices will always have exactly how many edges?

Greedy Technique and Graph Algorithm: Minimum Spanning Trees Easy
A.
B.
C.
D.

10 Prim's algorithm builds a minimum spanning tree by:

Prim's Algorithm Easy
A. Connecting isolated components randomly
B. Sorting all edges and picking them one by one
C. Growing a single tree by adding the cheapest edge from the tree to a non-tree vertex
D. Finding the shortest path from a source vertex

11 Which data structure is most commonly used in Kruskal's algorithm to check for cycles efficiently?

Kruskal's Algorithm Easy
A. Binary Search Tree
B. Stack
C. Hash Table
D. Disjoint-Set (Union-Find)

12 Dijkstra's algorithm is used to solve which problem?

Dijkstra's Algorithm Easy
A. Maximum Flow
B. Minimum Spanning Tree
C. Single-Source Shortest Paths
D. All-Pairs Shortest Paths

13 Which algorithmic design technique does Dijkstra's algorithm employ?

Dijkstra's Algorithm Easy
A. Dynamic Programming
B. Divide and Conquer
C. Backtracking
D. Greedy Technique

14 Huffman coding is widely used for which application?

Huffman Code Easy
A. Finding shortest paths
B. Sorting arrays
C. Data compression
D. Matrix multiplication

15 In a Huffman tree, where are the characters with the highest frequencies placed?

Huffman Code Easy
A. In the middle levels
B. Only on the left branches
C. At the deepest leaves
D. Near the root

16 Which algorithm is capable of finding single-source shortest paths even when the graph contains negative weight edges?

Single-Source Shortest Paths Easy
A. Kruskal's Algorithm
B. Prim's Algorithm
C. Dijkstra's Algorithm
D. Bellman-Ford Algorithm

17 What is the time complexity of Floyd's algorithm for a graph with vertices?

All-Pairs Shortest Paths Easy
A.
B.
C.
D.

18 Which method is commonly used to solve the Maximum-Flow problem by iteratively finding augmenting paths?

Iterative Improvement: The Maximum-Flow Problem Easy
A. Floyd-Warshall method
B. Kruskal's method
C. Dijkstra's method
D. Ford-Fulkerson method

19 In a flow network, what condition must hold for every vertex other than the source and sink?

Iterative Improvement: The Maximum-Flow Problem Easy
A. Flow in must be greater than flow out
B. Flow in must equal flow out
C. Capacity must be infinite
D. Flow out must be zero

20 What does a lower bound of a problem indicate?

Limitations of Algorithm Power: Lower-Bound Theory Easy
A. The fastest algorithm possible has been found
B. The minimum amount of work (time/operations) required to solve the problem by any algorithm
C. The maximum amount of time an algorithm will take
D. The specific algorithm to use

21 What is the time complexity of computing a binomial coefficient using dynamic programming (Pascal's Triangle approach)?

Dynamic Programming: Computing a Binomial Coefficient Medium
A.
B.
C.
D.

22 In Floyd's algorithm for finding all-pairs shortest paths, what does the intermediate matrix represent?

Warshall's and Floyd's Algorithm Medium
A. The shortest paths between all pairs using exactly edges.
B. The distances between all pairs after iterations of Breadth-First Search.
C. The shortest paths between all pairs of path length at most .
D. The shortest paths between all pairs using only the first vertices as intermediate nodes.

23 When constructing an Optimal Binary Search Tree using dynamic programming, what is the primary objective?

Optimal Binary Search Trees Medium
A. Minimize the number of nodes in the tree.
B. Minimize the height of the tree.
C. Minimize the expected number of comparisons for a search.
D. Maximize the search speed by keeping the tree strictly balanced.

24 How do memory functions improve the standard bottom-up dynamic programming approach for the Knapsack Problem?

Knapsack Problem and Memory Functions Medium
A. They allow the problem to be solved with fractional items.
B. They reduce the space complexity from to .
C. They solve the problem using a greedy approach, reducing time complexity.
D. They compute only the necessary subproblems required to find the optimal solution.

25 Given three matrices (dimensions ), (), and (), what is the minimum number of scalar multiplications required to compute ?

Matrix-Chain Multiplication Medium
A. $7500$
B. $75000$
C. $52500$
D. $25000$

26 What is the length of the Longest Common Subsequence (LCS) for the strings and ?

Longest Common Subsequence Medium
A. $5$
B. $6$
C. $4$
D. $3$

27 Which of the following properties is true for a Minimum Spanning Tree (MST) of a graph with distinct edge weights?

Greedy Technique and Graph Algorithm: Minimum Spanning Trees Medium
A. There can be multiple MSTs.
B. The MST must be a binary tree.
C. The MST includes the edge with the maximum weight in the graph.
D. The MST is unique.

28 What data structure is typically used in Prim's Algorithm to achieve an optimal time complexity of ?

Prim's Algorithm Medium
A. Min-Priority Queue
B. Stack
C. Disjoint Set (Union-Find)
D. Queue

29 Why is the Disjoint Set (Union-Find) data structure used in Kruskal's algorithm?

Kruskal's Algorithm Medium
A. To quickly check if adding an edge forms a cycle.
B. To store the final Minimum Spanning Tree.
C. To find the shortest path between two vertices.
D. To sort the edges by weight.

30 In which scenario will Dijkstra's algorithm fail to produce the correct shortest paths?

Dijkstra's Algorithm Medium
A. When the graph is dense.
B. When the graph contains edges with negative weights.
C. When the graph is a directed acyclic graph.
D. When the graph contains a cycle.

31 Given characters A, B, C, D with frequencies 45, 13, 12, 16 respectively. What is the length of the Huffman code for character A?

Huffman Code Medium
A. 1 bit
B. 3 bits
C. 4 bits
D. 2 bits

32 Which algorithm is suitable for finding single-source shortest paths in a graph that may contain negative weight edges (but no negative weight cycles)?

Single-Source Shortest Paths Medium
A. Dijkstra's Algorithm
B. Prim's Algorithm
C. Bellman-Ford Algorithm
D. Floyd's Algorithm

33 How does the time complexity of running Dijkstra's algorithm from every vertex compare to Floyd-Warshall for a dense graph with vertices?

All-Pairs Shortest Paths Medium
A. Both are exactly .
B. Floyd-Warshall is strictly worse than Dijkstra for dense graphs.
C. Dijkstra is (using binary heap) while Floyd-Warshall is .
D. Dijkstra is while Floyd-Warshall is .

34 In the Ford-Fulkerson method, what defines the residual capacity of a directed edge if its capacity is and current flow is ?

Iterative Improvement: The Maximum-Flow Problem Medium
A.
B.
C.
D.

35 What happens if the Ford-Fulkerson algorithm is applied to a network with irrational edge capacities?

Iterative Improvement: The Maximum-Flow Problem Medium
A. It might not terminate and may not converge to the true maximum flow.
B. It finds the maximum flow in time.
C. It converts irrational capacities to rational ones and solves the problem.
D. It always terminates but may yield an incorrect flow.

36 What is the information-theoretic lower bound for sorting distinct items using only comparisons?

Limitations of Algorithm Power: Lower-Bound Theory Medium
A.
B.
C.
D.

37 In the dynamic programming solution for Matrix-Chain Multiplication, how is the optimal split point chosen when computing the minimum cost ?

Matrix-Chain Multiplication Medium
A. By selecting the midpoint
B. By selecting that maximizes
C. By selecting that minimizes
D. By recursively solving without evaluating costs

38 In the 0/1 Knapsack Problem, if item has weight (where is the current remaining capacity), what is the value of the dynamic programming table entry ?

Knapsack Problem and Memory Functions Medium
A. $0$
B.
C.
D.

39 Which of the following guarantees that a Huffman code is a prefix code?

Huffman Code Medium
A. The most frequent character gets the longest code.
B. The tree is built as a complete binary tree.
C. Characters are placed only at the leaves of the Huffman tree.
D. Characters are assigned codes of equal length.

40 Warshall's algorithm is specifically designed to compute which of the following?

Warshall's and Floyd's Algorithm Medium
A. The transitive closure of a directed graph.
B. The shortest path tree of a graph.
C. The Minimum Spanning Tree of a graph.
D. The maximum flow in a network.

41 When computing a binomial coefficient using dynamic programming to avoid redundant calculations, what is the optimal space complexity that can be achieved if only the final value is needed?

Dynamic Programming: Computing a Binomial Coefficient Hard
A.
B.
C.
D.

42 In Floyd-Warshall's algorithm, what happens to the distance matrix if the graph contains a negative-weight cycle?

Warshall's and Floyd's Algorithm Hard
A. The matrix elements become complex numbers.
B. The algorithm goes into an infinite loop.
C. The algorithm correctly computes the shortest path assuming the cycle is traversed once.
D. The diagonal elements of the distance matrix become negative.

43 For an Optimal Binary Search Tree with keys and dummy keys, Knuth's optimization reduces the time complexity from to . Which property allows this optimization?

Optimal Binary Search Trees Hard
A. The principle of optimality
B. The triangle inequality
C. The subadditivity of the cost function
D. The monotonicity of the optimal roots

44 Consider the 0/1 Knapsack problem with a weight capacity and items. If the weights are extremely large but the values are small integers bounded by , how can the problem be solved optimally in pseudo-polynomial time?

Knapsack Problem and Memory Functions Hard
A. It is impossible; the problem is strictly NP-Hard and cannot be solved in pseudo-polynomial time if is large.
B. Define DP state representing the minimum weight needed to achieve exactly value .
C. Use the standard DP with state representing max value.
D. Use a greedy fractional approach and round down.

45 If the dimension of matrix is for , what is the cost function for the minimum number of scalar multiplications to compute ?

Matrix-Chain Multiplication Hard
A.
B.
C.
D.

46 Given two sequences of lengths and , what is the lower bound on the space complexity to find just the length of the LCS using DP?

Longest Common Subsequence Hard
A.
B.
C.
D.

47 Let be a connected graph with distinct edge weights. Let be the edge of maximum weight in a cycle in . Which of the following statements is unconditionally true?

Greedy Technique and Graph Algorithm: Minimum Spanning Trees Hard
A. might be part of the Minimum Spanning Tree if spans all vertices.
B. is part of the Maximum Spanning Tree but definitely not the Minimum Spanning Tree.
C. is not part of any Minimum Spanning Tree of .
D. The Minimum Spanning Tree is not unique.

48 When implementing Prim's algorithm using a Fibonacci heap on a dense graph where , what is the asymptotic time complexity?

Prim's Algorithm Hard
A.
B.
C.
D.

49 If the edges of a graph are already sorted by weight, what is the tightest time complexity of Kruskal's algorithm using a Disjoint Set Union (DSU) with path compression and union by rank?

Kruskal's Algorithm Hard
A.
B.
C.
D.

50 Dijkstra's algorithm fails for graphs with negative weight edges. However, if we simply add a large constant to all edge weights to make them non-negative, and then run Dijkstra's, what is the outcome?

Dijkstra's Algorithm Hard
A. It will find the longest paths instead of shortest paths.
B. It will work correctly only if is greater than the absolute value of the most negative edge.
C. It will always yield the correct shortest paths.
D. It may yield incorrect shortest paths because paths with more edges are penalized more.

51 Consider a set of characters where the frequency of the -th character is the -th Fibonacci number (). What is the depth of the optimal Huffman tree for this set (assuming , etc.)?

Huffman Code Hard
A.
B.
C.
D.

52 In the Bellman-Ford algorithm, if a graph has vertices, how many times can a vertex's shortest path distance be updated in the worst-case scenario before detecting a negative cycle?

Single-Source Shortest Paths Hard
A. times
B. times
C. times
D. times

53 Johnson's algorithm for All-Pairs Shortest Paths reweights edges to handle negative weights. The reweighting function uses a potential function . What is the transformed weight for an edge with original weight ?

All-Pairs Shortest Paths Hard
A.
B.
C.
D.

54 In the Ford-Fulkerson method, if the capacities of the edges are irrational numbers, which of the following statements is true?

Iterative Improvement: The Maximum-Flow Problem Hard
A. The algorithm will always terminate but may yield a sub-optimal flow.
B. The algorithm might not terminate, and the flow value might converge to a value strictly less than the maximum flow.
C. The algorithm will always terminate with the correct maximum flow.
D. The algorithm is guaranteed to terminate in time.

55 Using the decision tree model, what is the information-theoretic lower bound for sorting an array of distinct elements by comparisons?

Limitations of Algorithm Power: Lower-Bound Theory Hard
A.
B.
C.
D.

56 In Dinic's algorithm, what is the time complexity to find the maximum flow in a bipartite graph for maximum bipartite matching?

Iterative Improvement: The Maximum-Flow Problem Hard
A.
B.
C.
D.

57 If you compute the binomial coefficient modulo a prime (where ), which theorem is optimally used alongside DP or recursion to compute it efficiently?

Dynamic Programming: Computing a Binomial Coefficient Hard
A. Chinese Remainder Theorem
B. Fermat's Little Theorem
C. Lucas' Theorem
D. Wilson's Theorem

58 When constructing an Optimal Binary Search Tree, let be the probability of searching for key and be the probability of a search falling in the interval between keys. What is the sum of all probabilities and ?

Optimal Binary Search Trees Hard
A. $0.5$
B.
C. $1$
D. It depends on the depth of the tree.

59 Is the greedy approach (always multiplying the two matrices that result in the smallest number of scalar multiplications at the current step) guaranteed to find the optimal order for matrix-chain multiplication?

Matrix-Chain Multiplication Hard
A. No, because the subproblem optimality does not guarantee global optimality due to overlapping subproblems.
B. No, because greedy algorithms cannot be applied to matrices.
C. Yes, but only if matrix dimensions are strictly increasing.
D. Yes, it always finds the optimal solution.

60 What is the lower bound on the number of comparisons required to find both the maximum and the minimum of an array of elements simultaneously?

Limitations of Algorithm Power: Lower-Bound Theory Hard
A.
B.
C.
D.