Unit 3 - Practice Quiz

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

1 Which algorithm design paradigm is primarily used by both Merge Sort and Quick Sort?

Merge Sort and Quick Sort Easy
A. Divide and Conquer
B. Dynamic Programming
C. Backtracking
D. Greedy Approach

2 What is the worst-case time complexity of the Binary Search algorithm on a sorted array of elements?

Binary Search Easy
A.
B.
C.
D.

3 The Karatsuba algorithm for multiplying large integers reduces the number of recursive multiplications from 4 to what number?

Multiplication of Large Integers Easy
A. 5
B. 3
C. 6
D. 2

4 Strassen's Matrix Multiplication algorithm is faster than the standard matrix multiplication. What is its time complexity?

Strassen's Matrix Multiplication Easy
A.
B.
C.
D.

5 The Master Method is typically applied to recurrences of which of the following forms?

Master Method for Solving Recurrence Easy
A.
B.
C.
D.

6 In a recursion tree used to solve a recurrence relation, what does the value at each node represent?

Recursion-Tree Method for Solving Recurrences Easy
A. The total number of recursive calls
B. The cost of the subproblem at that level
C. The size of the subproblem
D. The height of the tree

7 What is the primary mathematical technique used to prove the guessed bounds in the Substitution Method?

Substitution Method for Solving Recurrences Easy
A. Mathematical Induction
B. Linear Programming
C. Probability Theory
D. Integration

8 Insertion Sort is a classic example of the Decrease and Conquer paradigm. By how much does it decrease the problem size in each step?

Decrease and Conquer: Insertion Sort Easy
A. By a constant amount of 1
B. By a constant factor of
C. By a constant factor of 2
D. By a variable amount

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

Depth-First Search and Breadth-First Search Easy
A. Stack
B. Hash Table
C. Queue
D. Priority Queue

10 Which data structure is naturally suited for implementing Depth-First Search (DFS) iteratively?

Depth-First Search and Breadth-First Search Easy
A. Binary Search Tree
B. Stack
C. Linked List
D. Queue

11 Topological sorting is only possible for which type of graph?

Topological Sort Easy
A. Complete graphs
B. Undirected graphs
C. Bipartite graphs
D. Directed Acyclic Graphs (DAGs)

12 In the context of the Transform and Conquer paradigm, what is 'presorting'?

Transform and Conquer: Presorting Easy
A. Randomizing the input to avoid worst-case scenarios
B. Sorting the input list before solving the main problem
C. Using a sorted data structure internally
D. Sorting the output before printing

13 In an AVL tree, what is the maximum allowed difference in height between the left and right subtrees of any node?

Balanced Search Trees Easy
A. 1
B. 0
C.
D. 2

14 Which of the following sorting algorithms is a non-comparison-based integer sorting algorithm?

Counting Sort Easy
A. Counting Sort
B. Heap Sort
C. Quick Sort
D. Merge Sort

15 How does Radix Sort typically process the individual digits of numbers?

Radix Sort Easy
A. From the most significant digit to the least significant digit only
B. By adding all digits together
C. By dividing digits into buckets randomly
D. From the least significant digit to the most significant digit

16 Bucket Sort works most efficiently when the input elements are:

Bucket Sort Easy
A. Sorted in reverse order
B. All identical
C. Uniformly distributed over a range
D. Already sorted

17 In a Max-Heap, what is the required relationship between a parent node and its children?

Heaps and Heapsort Easy
A. There is no required relationship
B. The parent must be greater than or equal to its children
C. The parent must be equal to its children
D. The parent must be strictly less than its children

18 What is the primary purpose of a hash function in a Hash Table?

Hashing Easy
A. To map a key to a specific index in an array
B. To encrypt the keys
C. To compress the data size
D. To sort the data securely

19 Which sorting algorithm works by repeatedly swapping adjacent elements if they are in the wrong order?

Selection Sort and Bubble Sort Easy
A. Selection Sort
B. Insertion Sort
C. Merge Sort
D. Bubble Sort

20 The Convex-Hull problem aims to find the smallest convex polygon that:

Closest-Pair and Convex-Hull Problems by Divide and Conquer Easy
A. Contains only half of the given points
B. Connects any two given points
C. Contains all the given points
D. Excludes all given points

21 What is the time complexity of the recurrence relation using the Master Theorem?

Master Method for Solving Recurrence Medium
A.
B.
C.
D.

22 In Quick Sort, if the partition algorithm always chooses the largest or smallest element as the pivot, what is the resulting time complexity?

Merge Sort and Quick Sort Medium
A.
B.
C.
D.

23 How many scalar multiplications are required by Strassen's algorithm to multiply two matrices, and what is its asymptotic time complexity?

Strassen's Matrix Multiplication Medium
A. 7 multiplications,
B. 8 multiplications,
C. 7 multiplications,
D. 8 multiplications,

24 Which of the following is the recurrence relation for the standard Binary Search algorithm?

Binary Search Medium
A.
B.
C.
D.

25 Karatsuba's algorithm for multiplying two -digit integers reduces the number of recursive multiplications from 4 to 3. What is its time complexity?

Multiplication of Large Integers Medium
A.
B.
C.
D.

26 In the divide and conquer algorithm for the Closest-Pair problem, after dividing the points into two halves, what is the maximum number of points in the strip that need to be checked for a given point?

Closest-Pair and Convex-Hull Problems by Divide and Conquer Medium
A.
B. 4
C. 6
D. 8

27 Suppose we guess that for the recurrence . What is the condition on to make the inductive proof work (ignoring base cases)?

Substitution Method for Solving Recurrences Medium
A. Any positive value of
B.
C.
D.

28 In the recursion tree for , what is the total cost at depth of the tree?

Recursion-Tree Method for Solving Recurrences Medium
A.
B.
C.
D.

29 Which data structure is primarily used to implement Breadth-First Search (BFS) and Depth-First Search (DFS) respectively?

Depth-First Search and Breadth-First Search Medium
A. Priority Queue and Array
B. Queue and Stack
C. Stack and Queue
D. Linked List and Tree

30 Topological sorting can only be applied to which type of graph?

Topological Sort Medium
A. Complete Graph
B. Directed Acyclic Graph (DAG)
C. Directed Cyclic Graph
D. Undirected Graph

31 In the worst-case scenario, how many comparisons are made by Insertion Sort to sort an array of elements?

Decrease and Conquer: Insertion Sort Medium
A.
B.
C.
D.

32 What is the minimum number of comparisons required to find both the minimum and maximum of an array of elements simultaneously?

Minimum and Maximum Medium
A.
B.
C.
D.

33 Which of the following is a key limitation of the Counting Sort algorithm?

Counting Sort Medium
A. Its time complexity is in the worst case.
B. It requires the input array to be partially sorted.
C. It requires extra space proportional to the range of input values.
D. It cannot sort integers.

34 If Radix Sort uses Counting Sort as a subroutine to sort numbers having digits each, what is the overall time complexity? (Assume the base/radix is ).

Radix Sort Medium
A.
B.
C.
D.

35 What is the time complexity to build a max-heap from an unsorted array of elements using the standard bottom-up build-heap approach?

Heaps and Heapsort Medium
A.
B.
C.
D.

36 In open addressing with linear probing, the hash function is modified to . What primary issue does linear probing suffer from?

Hashing Medium
A. Primary clustering
B. Inability to delete elements
C. Secondary clustering
D. High load factor limits

37 In an AVL tree, what is the maximum allowed difference in heights between the left and right subtrees of any node?

Balanced Search Trees Medium
A.
B. 2
C. 0
D. 1

38 How does presorting an array optimize the problem of checking for duplicate elements in an array?

Transform and Conquer: Presorting Medium
A. It avoids the need to iterate through the array.
B. It allows the use of hashing.
C. It reduces the time complexity to .
D. It reduces the time complexity from to .

39 Which algorithm is commonly used to find all Strongly Connected Components (SCCs) of a directed graph in time?

Connected Components Medium
A. Dijkstra's Algorithm
B. Kosaraju's Algorithm
C. Prim's Algorithm
D. Kruskal's Algorithm

40 Which sorting algorithm performs the minimum number of swaps in the worst-case scenario?

Selection Sort and Bubble Sort Medium
A. Insertion Sort
B. Bubble Sort
C. Merge Sort
D. Selection Sort

41 Consider the recurrence relation . Which case of the Master Theorem applies, and what is the tight asymptotic bound?

Master Method for Solving Recurrence Hard
A. Case 2 applies,
B. Case 1 applies,
C. The Master Theorem does not apply directly without the extended version.
D. Case 3 applies,

42 In Quick Sort, suppose the partition function is modified such that it always produces a split of and of the array elements. What is the exact depth of the deepest node in the recursion tree (in terms of )?

Merge Sort and Quick Sort Hard
A.
B.
C.
D.

43 Strassen's algorithm multiplies two matrices using $7$ multiplications of matrices. If a new divide-and-conquer algorithm breaks matrices into submatrices, what is the maximum number of submatrix multiplications it can use to be asymptotically faster than Strassen's?

Strassen's Matrix Multiplication Hard
A. 22
B. 27
C. 21
D. 26

44 When solving the recurrence using the substitution method to prove , why does a direct induction hypothesis often fail for the base cases (e.g., )?

Substitution Method for Solving Recurrences Hard
A. Because the floor function violates the monotonicity of the logarithm.
B. Because evaluates to $0$ at , which cannot bound a positive base case.
C. Because the constant must be negative.
D. Because the substitution method requires exact powers of 2.

45 In the divide-and-conquer algorithm for the Closest-Pair problem in 2D, a strip of width is analyzed where is the minimum distance found in the left and right subsets. What is the maximum number of points in the right half of the strip that need to be compared against a given point in the left half, ensuring the distance condition is maintained?

Closest-Pair and Convex-Hull Problems by Divide and Conquer Hard
A. 8
B. 7
C. 6
D. 4

46 Given a Directed Acyclic Graph (DAG) , how many unique topological sorts exist if is a set of disjoint directed paths, where the -th path has length ?

Topological Sort Hard
A.
B.
C.
D.

47 In a directed graph, a DFS is performed. Which combination of edge types implies the graph has a cycle?

Depth-First Search and Breadth-First Search Hard
A. Tree edges and Forward edges
B. Tree edges and Cross edges
C. Back edges
D. Cross edges and Forward edges

48 Karatsuba's algorithm for multiplying two -bit integers achieves a time complexity of . If applied to two numbers of size , what is the size of the recursive subproblems, and how many are there?

Multiplication of Large Integers Hard
A. 4 subproblems of size
B. 2 subproblems of size
C. 3 subproblems of size
D. 3 subproblems of size

49 For the recurrence , what is the total cost of the nodes at depth in the recursion tree, assuming the tree is full at that depth?

Recursion-Tree Method for Solving Recurrences Hard
A.
B.
C.
D.

50 In an AVL tree, what is the maximum number of rotations required to restore the AVL property after a single node deletion?

Balanced Search Trees Hard
A.
B.
C. $2$
D. $1$

51 Counting Sort is stable. If an array of elements has a maximum value , why is standard Counting Sort generally not used, and how can Radix Sort resolve this?

Counting Sort Hard
A. Time complexity becomes . Radix sort uses comparison to reduce time.
B. Counting sort cannot handle duplicate values. Radix sort hashes the duplicates.
C. Counting sort is not stable for . Radix sort preserves stability.
D. Space complexity becomes . Radix sort with base reduces time and space to .

52 Given an array of elements, the Floyd method to build a Max-Heap (calling max_heapify bottom-up) takes time. Why is it strictly faster asymptotically than inserting elements one by one into an initially empty heap?

Heaps and Heapsort Hard
A. Insertion takes time on average, but worst-case is , making it .
B. Bottom-up build-heap uses fewer comparisons per level.
C. The sum of heights of all nodes in a complete binary tree is , whereas the sum of depths is .
D. Insertions require dynamically resizing the array, adding overhead.

53 In a hash table using open addressing with linear probing, the table size is and there are elements. If and the step size are not coprime, what is the worst-case consequence for insertion?

Hashing Hard
A. The probe sequence will only visit a subset of slots, potentially causing an infinite loop if those slots are full.
B. The hash function will map all keys to the same slot.
C. Primary clustering is eliminated completely.
D. The load factor will exceed 1.

54 To find both the minimum and maximum of an array of elements simultaneously, the optimal number of comparisons is:

Minimum and Maximum Hard
A.
B.
C.
D.

55 When analyzing Insertion Sort, the number of shifts (or swaps) is directly proportional to which specific property of the input array?

Decrease and Conquer: Insertion Sort Hard
A. The number of distinct elements.
B. The number of inversions.
C. The maximum element in the array.
D. The longest strictly increasing subsequence.

56 In Tarjan's strongly connected components algorithm, a node is identified as the root of an SCC if and only if:

Connected Components Hard
A. lowlink[u] == dfn[u]
B. lowlink[u] < dfn[u]
C. It has no outgoing edges to nodes in different SCCs.
D. It is the first node visited in the DFS traversal.

57 Given a sorted array of distinct integers , finding an index such that can be done in time using Binary Search. If the integers are not distinct, what is the worst-case time complexity?

Binary Search Hard
A.
B.
C.
D.

58 Suppose we sort strings of length over an alphabet of size using LSD (Least Significant Digit) Radix sort. If , what is the overall time complexity?

Radix Sort Hard
A.
B.
C.
D.

59 An algorithm determines if an array contains two elements that sum to exactly . By presorting the array in time, the search phase can be reduced to:

Transform and Conquer: Presorting Hard
A. time using two pointers.
B. time using repeated binary searches.
C. time using hashing.
D. time using binary search.

60 Consider Bubble Sort and Selection Sort applied to an array of elements. Which statement accurately compares their minimum number of element swaps in the worst-case input scenario?

Selection Sort and Bubble Sort Hard
A. Both require swaps.
B. Both require swaps.
C. Bubble Sort requires swaps; Selection Sort requires swaps.
D. Bubble Sort requires swaps; Selection Sort requires swaps.