Unit 1: Analysis of Algorithms and Divide-and-Conquer - Practice Quiz

CSE408 — Design And Analysis Of Algorithms 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does the time complexity of an algorithm describe?

Time and Space Complexity Easy
A. The number of variables in the program
B. The accuracy of the produced output
C. The programming language used for coding
D. The growth of running time with input size

2 What does auxiliary space complexity measure?

Time and Space Complexity Easy
A. The size of the input data
B. The extra memory used by the algorithm
C. The number of output values
D. The time required to read input

3 What is the best-case time complexity of insertion sort when the array is already sorted?

Complexity Analysis of Insertion Sort and Merge Sort Easy
A.
B.
C.
D.

4 What is the worst-case time complexity of insertion sort?

Complexity Analysis of Insertion Sort and Merge Sort Easy
A.
B.
C.
D.

5 What is the standard time complexity of merge sort for an array of elements?

Complexity Analysis of Insertion Sort and Merge Sort Easy
A.
B.
C.
D.

6 How much auxiliary space does the standard array-based merge sort use?

Complexity Analysis of Insertion Sort and Merge Sort Easy
A.
B.
C.
D.

7 A loop executes exactly times and performs constant work in each iteration. What is its time complexity?

Analysis of Iterative Algorithms Easy
A.
B.
C.
D.

8 Two nested loops each execute times. If the inner operation takes constant time, what is the total time complexity?

Analysis of Iterative Algorithms Easy
A.
B.
C.
D.

9 What is the purpose of a base case in a recursive algorithm?

Analysis of Recursive Algorithms Easy
A. To divide the input into equal parts
B. To increase the recursion depth
C. To stop further recursive calls
D. To combine all recursive results

10 Which recurrence represents a function that makes one recursive call on input size and performs constant additional work?

Analysis of Recursive Algorithms Easy
A.
B.
C.
D.

11 What is the main idea of the substitution method for solving recurrences?

Substitution Method Easy
A. Guess a bound and prove it by induction
B. Replace recursion with an iterative loop
C. Draw every recursive call as a tree
D. Apply only the merge sort recurrence

12 In the recursion tree method, what does each level of the tree represent?

Recursion Tree Method Easy
A. One element of the final output
B. One stage of recursive subproblems
C. One statement in the source code
D. One variable used by the program

13 For , what is the total work performed at each non-leaf level of the recursion tree?

Recursion Tree Method Easy
A.
B.
C.
D.

14 What is the standard form of a recurrence handled by the Master Method?

Master Method Easy
A.
B.
C.
D.

15 Using the Master Method, what is the solution of ?

Master Method Easy
A.
B.
C.
D.

16 How many recursive matrix multiplications does Strassen's algorithm use for two partitioned matrices?

Strassen's Matrix Multiplication Easy
A. Seven multiplications
B. Nine multiplications
C. Six multiplications
D. Eight multiplications

17 What is the asymptotic time complexity of Strassen's matrix multiplication algorithm?

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

18 In a set of distinct elements, what is the first order statistic?

Order Statistics Easy
A. The minimum element
B. The maximum element
C. The average element
D. The median element

19 What is the average-case time complexity of Quick Select?

Quick Select Easy
A.
B.
C.
D.

20 What is the third smallest element in the array ?

k-th Smallest Element Easy
A.
B.
C.
D.

21 Consider the following loops, where is a power of :

for (i = 1; i <= n; i *= 2)

for (j = 0; j < i; j++)

operation();

What are the time and auxiliary space complexities?

Time and Space Complexity Medium
A. time and space
B. time and space
C. time and space
D. time and space

22 When insertion sort processes the array , how many element shifts are performed?

Complexity Analysis of Insertion Sort and Merge Sort Medium
A. shifts
B. shifts
C. shifts
D. shifts

23 A standard top-down merge sort uses temporary arrays during merging. What are its worst-case time and auxiliary space complexities?

Complexity Analysis of Insertion Sort and Merge Sort Medium
A. time and auxiliary space
B. time and auxiliary space
C. time and auxiliary space because only the recursion stack is counted and temporary merge arrays require no storage
D. time and auxiliary space

24 What is the time complexity of the following loop structure?

for (i = 1; i <= n; i++)

for (j = 1; j <= i; j++)

operation();

Analysis of Iterative Algorithms Medium
A.
B.
C.
D.

25 Determine the time complexity of the following code:

for (i = 1; i <= n; i++)

for (j = i; j <= n; j += i)

operation();

Analysis of Iterative Algorithms Medium
A.
B.
C.
D.

26 An algorithm has recurrence with . What is its asymptotic running time?

Analysis of Recursive Algorithms Medium
A.
B.
C.
D.

27 A recursive function makes two calls on inputs of size and performs a loop taking time outside the calls. What is its running time?

Analysis of Recursive Algorithms Medium
A.
B.
C.
D.

28 For , suppose the inductive hypothesis is for . What expression results after substitution and simplification?

Substitution Method Medium
A.
B.
C. for every positive value of , without requiring any restriction on the inductive constant
D.

29 To prove is , assume . What condition on makes the induction step valid?

Substitution Method Medium
A.
B.
C.
D.

30 For the recurrence , how does the nonrecursive cost change from one recursion-tree level to the next, and what is the resulting complexity?

Recursion Tree Method Medium
A. It increases by , giving
B. It increases by , giving
C. It decreases by , giving
D. It remains constant, giving

31 Consider . What complexity is indicated by a recursion-tree analysis?

Recursion Tree Method Medium
A.
B.
C.
D.

32 Use the Master Method to solve .

Master Method Medium
A.
B.
C.
D.

33 What is the solution of according to the Master Method?

Master Method Medium
A.
B.
C.
D.

34 Strassen's algorithm divides each matrix into four blocks but uses seven recursive block multiplications. Which pair correctly describes its recurrence and asymptotic time?

Strassen's Matrix Multiplication Medium
A. and
B. and
C. and
D. and

35 An array contains distinct elements. After partitioning, a pivot has exactly elements smaller than it and elements larger than it. Which order statistic is the pivot?

Order Statistics Medium
A. Its order cannot be identified because partitioning provides no rank information unless the entire array is first sorted in increasing order
B. The th smallest element
C. The th smallest element
D. The th smallest element

36 Using the pairwise method, what is the minimum number of comparisons needed to find both the minimum and maximum of distinct elements?

Order Statistics Medium
A. comparisons
B. comparisons
C. comparisons
D. comparisons

37 For randomized Quick Select, which pair correctly states the expected and worst-case running times?

Quick Select Medium
A. expected and worst case
B. expected and worst case
C. expected and worst case
D. expected and worst case

38 Quick Select seeks the th smallest element. After partitioning, the pivot is the th smallest element of the current subarray. What should the algorithm do next?

Quick Select Medium
A. Search for the th smallest element in the right partition
B. Search for the th smallest element in the left partition
C. Search for the rd smallest element in the left partition
D. Search for the rd smallest element in the right partition

39 To find the th smallest element in an unsorted array, an algorithm maintains a max-heap containing the smallest values seen so far. What does the heap root represent at the end, and what is the running time?

k-th Smallest Element Medium
A. The smallest element in time
B. The th smallest element in time
C. The th largest element in time
D. The largest element in time

40 An array of distinct elements is sorted in ascending order and indexed from . At which index is the th largest element?

k-th Largest Element Medium
A. Index
B. Index
C. Index
D. Index

41 Consider a recursive procedure that makes two calls with parameter until , performs work per call, and stores no results. If output storage is excluded, what are its time and auxiliary-space complexities when called with ?

Time and Space Complexity Hard
A. time and space
B. time and space
C. time and space
D. time and space

42 An array of length contains exactly inversions. Insertion sort uses a sentinel, so every insertion performs one final unsuccessful key comparison. What are the exact number of shifts and key comparisons?

Complexity Analysis of Insertion Sort and Merge Sort Hard
A. shifts and comparisons
B. shifts and comparisons
C. shifts and comparisons
D. shifts and comparisons

43 A top-down merge sort allocates a temporary array proportional to the current subproblem size in each active call and releases it when that call returns. What are its worst-case time and peak auxiliary-space complexities?

Complexity Analysis of Insertion Sort and Merge Sort Hard
A. time and space
B. time and space
C. time and space
D. time and space

44 Determine the running time of the following loop, assuming the body is :

for (i = 1; i <= n; i *= 2)

for (j = i; j <= n; j += i)

body

Analysis of Iterative Algorithms Hard
A.
B.
C.
D.

45 What is the asymptotic running time of the following algorithm?

for (i = 1; i <= n; i++)

for (j = i; j <= n; j += i)

for (k = 1; k <= j; k *= 2)

body

Analysis of Iterative Algorithms Hard
A.
B.
C.
D.

46 For constant-size base cases, determine the tight bound for

Analysis of Recursive Algorithms Hard
A.
B.
C.
D.

47 For , suppose the induction hypothesis is substituted directly, without adding a lower-order term. Which condition on makes the inductive inequality hold for all sufficiently large ?

Substitution Method Hard
A. only
B.
C.
D.

48 Let be a power of two and consider



with a constant-size base case. What bound follows from a recursion-tree analysis?

Recursion Tree Method Hard
A.
B.
C.
D.

49 Using the Master Method, determine the tight bound for

Master Method Hard
A.
B.
C.
D.

50 Consider



Which statement is correct?

Master Method Hard
A. Master Method case 3 applies, and
B. Master Method case 2 applies, and
C. The basic Master Method is inconclusive, and
D. Master Method case 1 applies, and

51 Strassen's algorithm is applied to two matrices where is not a power of two. Each matrix is padded to size , where is the next power of two. What is the resulting asymptotic running time in terms of ?

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

52 At recursion level of Strassen's algorithm, there are subproblems of dimension . What is the total matrix-addition work at that level?

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

53 In the comparison model, what is the optimal worst-case number of comparisons needed to find both the minimum and maximum of elements?

Order Statistics Hard
A.
B.
C.
D.

54 Quick Select repeatedly chooses a pivot that is the smallest remaining element while searching for the largest element. What recurrence and worst-case running time result?

Quick Select Hard
A. and
B. and
C. and
D. and

55 For randomized Quick Select on an arbitrary fixed input, where each pivot is chosen uniformly from the active subarray, which pair of bounds is correct?

Quick Select Hard
A. Expected and worst-case
B. Expected and worst-case
C. Expected and worst-case
D. Expected and worst-case

56 Two arrays of lengths and are individually sorted. Without merging them, what time and auxiliary-space bounds can a binary-partition algorithm achieve for finding the -th smallest element?

k-th Smallest Element Hard
A. time and space
B. time and space
C. time and space
D. time and space

57 A three-way partition around pivot produces elements greater than , elements equal to , and the rest smaller than . For ranks counted with multiplicity, when is the -th largest element?

k-th Largest Element Hard
A.
B.
C.
D.

58 Suppose deterministic selection groups elements in threes, recursively finds the median of the group medians, and partitions around it. Ignoring rounding, which recurrence describes the standard worst-case analysis, and what bound does it yield?

Order Statistics Hard
A. , yielding
B. , yielding
C. , yielding
D. , yielding

59 An algorithm scans unsorted elements while maintaining a min-heap containing the largest elements seen so far. What are its worst-case time and auxiliary-space complexities?

k-th Largest Element Hard
A. time and space
B. time and space
C. time and space
D. time and space

60 In median-of-medians selection with groups of five, which worst-case recurrence correctly captures the pivot-selection call and the largest possible recursive partition, up to constant rounding terms?

k-th Smallest Element Hard
A.
B.
C.
D.