Unit 2: Divide and Conquer - Practice Quiz

ECAP538 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the first main step in the divide-and-conquer method?

General method Easy
A. Combine all inputs into one value
B. Divide the problem into smaller subproblems
C. Remove every repeated input value
D. Search the input in sequential order

2 Which three steps typically form a divide-and-conquer algorithm?

General method Easy
A. Divide, conquer, and combine
B. Search, swap, and insert
C. Initialize, iterate, and stop
D. Compare, delete, and append

3 What is a base case in a recursive divide-and-conquer algorithm?

General method Easy
A. A case containing invalid input
B. A case requiring extra storage
C. A case divided without stopping
D. A small case solved directly

4 In divide and conquer, what does the combine step do?

General method Easy
A. Checks whether the input is already sorted
B. Builds the final solution from subproblem results
C. Divides each subproblem into equal pieces
D. Selects a random element from the input

5 What condition must normally be satisfied before binary search is applied to an array?

Binary search Easy
A. The array must contain duplicates
B. The array must be sorted
C. The array must have even length
D. The array must be reversed

6 Which element does binary search examine first?

Binary search Easy
A. The first element
B. The middle element
C. A random element
D. The final element

7 What is the worst-case time complexity of binary search on a sorted array of elements?

Binary search Easy
A.
B.
C.
D.

8 If the target is smaller than the middle element in an ascending sorted array, where does binary search continue?

Binary search Easy
A. Across the full array
B. In the left half
C. In the right half
D. At the final element

9 How does merge sort divide an array?

Merge sort Easy
A. Into two smaller halves
B. Into groups of three elements
C. Into sorted and unsorted regions
D. Into positive and negative values

10 What happens during the merge step of merge sort?

Merge sort Easy
A. One pivot is placed correctly
B. The largest value is discarded
C. Adjacent values are always swapped
D. Two sorted sequences are combined

11 What is the worst-case time complexity of merge sort?

Merge sort Easy
A.
B.
C.
D.

12 When does the recursive division in merge sort normally stop?

Merge sort Easy
A. When a subarray has exactly two duplicates
B. When the largest element becomes the first
C. When every element has been compared once
D. When a subarray has at most one element

13 Which special element is selected during quick sort?

Quick sort Easy
A. A pivot
B. A counter
C. A successor
D. A sentinel

14 What is the purpose of partitioning in quick sort?

Quick sort Easy
A. To locate a target by halving
B. To merge two sorted subarrays
C. To copy elements into a matrix
D. To arrange elements around a pivot

15 What is the average-case time complexity of quick sort?

Quick sort Easy
A.
B.
C.
D.

16 What is the worst-case time complexity of quick sort?

Quick sort Easy
A.
B.
C.
D.

17 Why may standard fixed-size data types be unsuitable for very large integers?

Arithmetic with large integers Easy
A. Their digits cannot be compared
B. Their numeric range is limited
C. Their operations require sorting
D. Their values are always negative

18 In divide-and-conquer multiplication, how are large integers commonly divided?

Arithmetic with large integers Easy
A. Into prime and composite factors
B. Into high and low digit parts
C. Into odd and even numeric values
D. Into positive and negative terms

19 Which algorithm is known for multiplying large integers using divide and conquer?

Arithmetic with large integers Easy
A. Karatsuba algorithm
B. Prim algorithm
C. Kruskal algorithm
D. Dijkstra algorithm

20 How many recursive multiplications does the basic Karatsuba method use for each split?

Arithmetic with large integers Easy
A. Two multiplications
B. Five multiplications
C. Three multiplications
D. Four multiplications

21 A divide-and-conquer algorithm divides a problem of size into two subproblems of size and uses time to combine their solutions. What is its time complexity?

General method Medium
A.
B.
C.
D.

22 What is the asymptotic solution of the recurrence ?

General method Medium
A.
B.
C.
D.

23 Which problem characteristic most directly supports an efficient divide-and-conquer solution?

General method Medium
A. The problem splits into smaller solvable subproblems
B. The problem must have only one base case
C. The input must already be sorted
D. The solution must use constant memory

24 An algorithm solves one subproblem of size and performs additional work. What is the solution of ?

General method Medium
A.
B.
C.
D.

25 In the worst case, how many element comparisons are needed for a successful binary search in a sorted array of distinct elements?

Binary search Medium
A.
B.
C.
D.

26 Which recurrence best represents the running time of binary search?

Binary search Medium
A.
B.
C.
D.

27 To find the first occurrence of a target in a sorted array containing duplicates, what should binary search do when it finds the target at index ?

Binary search Medium
A. Record and search the left half
B. Return immediately
C. Remove the element and restart
D. Continue searching the right half

28 A Boolean predicate is false up to some index and true afterward. Using a half-open interval , which update correctly finds the first true index?

Binary search Medium
A. If true, set ; otherwise set
B. If true, set ; otherwise set
C. If true, set ; otherwise set
D. If true, return immediately; otherwise set

29 Which recurrence describes standard merge sort on an array of size ?

Merge sort Medium
A.
B.
C.
D.

30 During merging, which rule preserves the stability of merge sort when the front elements of the two halves have equal keys?

Merge sort Medium
A. Choose the element from the right half
B. Swap both elements before choosing
C. Choose the element from the left half
D. Choose either element at random

31 While counting inversions during a merge, the next element from the right half is smaller than the next element from the left half. How many inversions should be added?

Merge sort Medium
A. The number remaining in the left half
B. One inversion only
C. The size of the right half
D. The number already merged

32 A bottom-up merge sort begins with eight sorted runs of length . How many complete merge passes are required to obtain one sorted run?

Merge sort Medium
A.
B.
C.
D.

33 Lomuto partitioning is applied to using the last element as pivot and the comparison . What array results after partitioning?

Quick sort Medium
A.
B.
C.
D.

34 A naive quick sort uses Lomuto partitioning with the last element as pivot and treats values equal to the pivot as smaller. What is its running time on an array whose elements are all equal?

Quick sort Medium
A.
B.
C.
D.

35 Suppose every quick-sort pivot divides the input into subarrays of sizes approximately and . What is the overall running time?

Quick sort Medium
A.
B.
C.
D.

36 If quick sort selects its pivot uniformly at random from distinct elements, what is the probability that the pivot is either the smallest or the largest element?

Quick sort Medium
A.
B.
C.
D.

37 Let and , where is a power of the number base. Which expression correctly represents ?

Arithmetic with large integers Medium
A.
B.
C.
D.

38 How does Karatsuba multiplication reduce the number of recursive half-size multiplications compared with the basic divide-and-conquer method?

Arithmetic with large integers Medium
A. It uses two products and two divisions
B. It uses one product and repeated shifts
C. It uses four products and no additions
D. It uses three products and extra additions

39 What is the asymptotic running time of Karatsuba multiplication according to ?

Arithmetic with large integers Medium
A.
B.
C.
D.

40 Ignoring lower-order addition costs, what happens to the recursive multiplication work when the operand length is doubled in schoolbook divide-and-conquer multiplication and in Karatsuba multiplication?

Arithmetic with large integers Medium
A. It grows by factors and , respectively
B. It grows by factors and , respectively
C. It grows by factors and , respectively
D. It grows by factors and , respectively

41 Consider the recurrence with constant work at the base case. What is its asymptotic solution?

General method Hard
A.
B.
C.
D.

42 For powers of two, suppose and . Which bound is tight?

General method Hard
A.
B.
C.
D.

43 A divide-and-conquer algorithm satisfies , ignoring rounding. Which asymptotic running time follows?

General method Hard
A.
B.
C.
D.

44 A parallel divide-and-conquer algorithm creates subproblems of size , performs combine work, and has . Subproblems execute concurrently, but the combine operation is sequential. What is the asymptotic parallelism ?

General method Hard
A.
B.
C.
D.

45 A lower-bound search uses the half-open interval and updates when , otherwise setting . Which invariant is sufficient to establish correctness?

Binary search Hard
A. Every index below stores a value , and every index at or above stores a value .
B. Every index below stores a value , and every index at or above stores a value .
C. Every index below stores a value , and every index at or above stores a value .
D. Every index at or below stores a value , and every index above stores a value .

46 A sorted array is rotated at an unknown pivot and may contain arbitrarily many duplicate values. What is the tight worst-case complexity of determining whether a target occurs using comparison-based search?

Binary search Hard
A.
B.
C.
D.

47 Exponential search examines indices until it brackets a present target whose first occurrence is at index , and then performs binary search. What is the tight comparison bound?

Binary search Hard
A.
B.
C.
D.

48 A lower-bound algorithm must distinguish all possible insertion positions using binary predicates of the form . What is the minimum possible worst-case number of predicate evaluations?

Binary search Hard
A.
B.
C.
D.

49 For , what is the exact maximum number of element-to-element comparisons performed by standard top-down merge sort?

Merge sort Hard
A.
B.
C.
D.

50 While merging sorted halves and to count strict inversions satisfying and , which rule handles duplicate values correctly?

Merge sort Hard
A. Take from when ; otherwise add the number of unmerged elements in .
B. Take from when ; otherwise add the number of unmerged elements in .
C. Take from when ; otherwise add the number of unmerged elements in .
D. Take from when ; otherwise add the number of unmerged elements in .

51 A merge-sort variant always splits an input into fractions and , where , and merging costs . Ignoring rounding, what is the leading term of its comparison recurrence?

Merge sort Hard
A.
B.
C.
D.

52 An array consists of already identified nondecreasing runs. If a balanced merge schedule combines these runs, what is the tight worst-case merge cost, including the case ?

Merge sort Hard
A.
B.
C.
D.

53 For randomized quicksort on distinct keys, where each pivot is chosen uniformly from the current subarray, what is the exact expected number of key comparisons?

Quick sort Hard
A.
B.
C.
D.

54 Quicksort is modified to recurse only on the smaller partition and process the larger partition by iteration. What are its worst-case running time and auxiliary call-stack space?

Quick sort Hard
A. time and stack
B. time and stack
C. time and stack
D. time and stack

55 Three-way quicksort partitions elements into regions smaller than, equal to, and greater than the pivot, and does not recurse on the equal region. On an array of identical keys, what behavior results?

Quick sort Hard
A. time and recursion depth
B. time and recursion depth
C. time and recursion depth
D. time and recursion depth

56 For randomized quicksort on distinct keys, what is the probability that every nontrivial recursive call chooses an extreme key and therefore produces a maximally unbalanced partition?

Quick sort Hard
A.
B.
C.
D.

57 Karatsuba multiplication replaces four half-size products with three half-size products. Assuming linear-time additions, which recurrence and complexity describe multiplication of two -digit integers?

Arithmetic with large integers Hard
A. and
B. and
C. and
D. and

58 A three-way large-integer multiplication scheme evaluates enough points to use five recursive multiplications on inputs of size , with evaluation and interpolation work. What is its asymptotic complexity?

Arithmetic with large integers Hard
A.
B.
C.
D.

59 A divide-and-conquer integer multiplication algorithm computes all four products of the high and low halves recursively. Even if its additions are optimized to linear time, what tight bound follows?

Arithmetic with large integers Hard
A.
B.
C.
D.

60 For a power of two, suppose a Karatsuba-style implementation satisfies and . Which expression solves the recurrence exactly?

Arithmetic with large integers Hard
A.
B.
C.
D.