Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 2 MCQsDivide and Conquer
ECAP538 ·
60 questions. Pick an option to check it.
What is the first main step in the divide-and-conquer method?
Not quite. Try another option.
Answer: Divide the problem into smaller subproblems
Divide and conquer begins by dividing a problem into smaller subproblems of the same general type.
Question 2 of 60 · General method · Easy
Which three steps typically form a divide-and-conquer algorithm?
Not quite. Try another option.
Answer: Divide, conquer, and combine
The method divides the problem, solves the smaller subproblems, and combines their solutions.
Question 3 of 60 · General method · Easy
What is a base case in a recursive divide-and-conquer algorithm?
Not quite. Try another option.
Answer: A small case solved directly
A base case is simple enough to solve directly, so no further recursive division is needed.
Question 4 of 60 · General method · Easy
In divide and conquer, what does the combine step do?
Not quite. Try another option.
Answer: Builds the final solution from subproblem results
The combine step joins the solutions of smaller subproblems to produce the solution to the original problem.
Question 5 of 60 · Binary search · Easy
What condition must normally be satisfied before binary search is applied to an array?
Not quite. Try another option.
Answer: The array must be sorted
Binary search relies on sorted order to decide which half may contain the target.
Question 6 of 60 · Binary search · Easy
Which element does binary search examine first?
Not quite. Try another option.
Answer: The middle element
Binary search first compares the target with the middle element of the current search range.
Question 7 of 60 · Binary search · Easy
What is the worst-case time complexity of binary search on a sorted array of elements?
Not quite. Try another option.
Answer:
Each comparison reduces the remaining search range by approximately half, giving time.
Question 8 of 60 · Binary search · Easy
If the target is smaller than the middle element in an ascending sorted array, where does binary search continue?
Not quite. Try another option.
Answer: In the left half
In ascending order, values smaller than the middle element can only occur in the left half.
Question 9 of 60 · Merge sort · Easy
How does merge sort divide an array?
Not quite. Try another option.
Answer: Into two smaller halves
Merge sort repeatedly divides the array into two smaller halves until the base cases are reached.
Question 10 of 60 · Merge sort · Easy
What happens during the merge step of merge sort?
Not quite. Try another option.
Answer: Two sorted sequences are combined
The merge step combines two sorted sequences into one sorted sequence.
Question 11 of 60 · Merge sort · Easy
What is the worst-case time complexity of merge sort?
Not quite. Try another option.
Answer:
Merge sort has logarithmically many division levels, and merging at each level takes time.
Question 12 of 60 · Merge sort · Easy
When does the recursive division in merge sort normally stop?
Not quite. Try another option.
Answer: When a subarray has at most one element
A subarray containing zero or one element is already sorted and forms a base case.
Question 13 of 60 · Quick sort · Easy
Which special element is selected during quick sort?
Not quite. Try another option.
Answer: A pivot
Quick sort selects a pivot and uses it to partition the other elements.
Question 14 of 60 · Quick sort · Easy
What is the purpose of partitioning in quick sort?
Not quite. Try another option.
Answer: To arrange elements around a pivot
Partitioning places smaller and larger elements on appropriate sides of the pivot.
Question 15 of 60 · Quick sort · Easy
What is the average-case time complexity of quick sort?
Not quite. Try another option.
Answer:
With reasonably balanced partitions, quick sort runs in time on average.
Question 16 of 60 · Quick sort · Easy
What is the worst-case time complexity of quick sort?
Not quite. Try another option.
Answer:
Quick sort takes time when its partitions are repeatedly very unbalanced.
Question 17 of 60 · Arithmetic with large integers · Easy
Why may standard fixed-size data types be unsuitable for very large integers?
Not quite. Try another option.
Answer: Their numeric range is limited
A fixed-size type can represent only a limited range, so an integer with too many digits may overflow.
Question 18 of 60 · Arithmetic with large integers · Easy
In divide-and-conquer multiplication, how are large integers commonly divided?
Not quite. Try another option.
Answer: Into high and low digit parts
Each large integer is commonly split into a high-order part and a low-order part.
Question 19 of 60 · Arithmetic with large integers · Easy
Which algorithm is known for multiplying large integers using divide and conquer?
Not quite. Try another option.
Answer: Karatsuba algorithm
The Karatsuba algorithm uses divide and conquer to multiply large integers efficiently.
Question 20 of 60 · Arithmetic with large integers · Easy
How many recursive multiplications does the basic Karatsuba method use for each split?
Not quite. Try another option.
Answer: Three multiplications
Karatsuba reduces the usual four products of two split numbers to three recursive multiplications.
Question 21 of 60 · General method · Medium
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?
Not quite. Try another option.
Answer:
The recurrence is . Each recursion level costs , and there are levels.
Question 22 of 60 · General method · Medium
What is the asymptotic solution of the recurrence ?
Not quite. Try another option.
Answer:
By the Master Theorem, grows faster than the nonrecursive term , so it determines the result.
Question 23 of 60 · General method · Medium
Which problem characteristic most directly supports an efficient divide-and-conquer solution?
Not quite. Try another option.
Answer: The problem splits into smaller solvable subproblems
Divide and conquer is effective when a problem can be divided into smaller instances, solved recursively, and combined efficiently.
Question 24 of 60 · General method · Medium
An algorithm solves one subproblem of size and performs additional work. What is the solution of ?
Not quite. Try another option.
Answer:
The work forms the geometric sum , whose total is .
Question 25 of 60 · Binary search · Medium
In the worst case, how many element comparisons are needed for a successful binary search in a sorted array of distinct elements?
Not quite. Try another option.
Answer:
A balanced search over elements has five levels, so a successful search requires at most five comparisons.
Question 26 of 60 · Binary search · Medium
Which recurrence best represents the running time of binary search?
Not quite. Try another option.
Answer:
Binary search examines one half of the input after a constant-time comparison, giving logarithmic running time.
Question 27 of 60 · Binary search · Medium
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 ?
Not quite. Try another option.
Answer: Record and search the left half
The current match is a candidate, but an earlier occurrence may exist to its left.
Question 28 of 60 · Binary search · Medium
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?
Not quite. Try another option.
Answer: If true, set ; otherwise set
A true midpoint may be the first true index, so it remains in the interval; a false midpoint and all earlier indices can be discarded.
Question 29 of 60 · Merge sort · Medium
Which recurrence describes standard merge sort on an array of size ?
Not quite. Try another option.
Answer:
Merge sort recursively sorts two halves and then merges them in linear time.
Question 30 of 60 · Merge sort · Medium
During merging, which rule preserves the stability of merge sort when the front elements of the two halves have equal keys?
Not quite. Try another option.
Answer: Choose the element from the left half
Choosing the left element first preserves the original relative order of equal-key elements.
Question 31 of 60 · Merge sort · Medium
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?
Not quite. Try another option.
Answer: The number remaining in the left half
Because both halves are sorted, the selected right element is smaller than every unmerged element in the left half.
Question 32 of 60 · Merge sort · Medium
A bottom-up merge sort begins with eight sorted runs of length . How many complete merge passes are required to obtain one sorted run?
Not quite. Try another option.
Answer:
The run lengths double as , requiring three merge passes.
Question 33 of 60 · Quick sort · Medium
Lomuto partitioning is applied to using the last element as pivot and the comparison . What array results after partitioning?
Not quite. Try another option.
Answer:
The values , , and are moved before pivot , while remains after it.
Question 34 of 60 · Quick sort · Medium
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?
Not quite. Try another option.
Answer:
Each partition places the pivot at one end, producing subproblems of sizes and .
Question 35 of 60 · Quick sort · Medium
Suppose every quick-sort pivot divides the input into subarrays of sizes approximately and . What is the overall running time?
Not quite. Try another option.
Answer:
The partitions remain proportionally balanced, giving logarithmic recursion depth with partition work per level.
Question 36 of 60 · Quick sort · Medium
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?
Not quite. Try another option.
Answer:
Exactly two of the possible pivots are extreme elements, so the probability is .
Question 37 of 60 · Arithmetic with large integers · Medium
Let and , where is a power of the number base. Which expression correctly represents ?
Not quite. Try another option.
Answer:
Expanding gives .
Question 38 of 60 · Arithmetic with large integers · Medium
How does Karatsuba multiplication reduce the number of recursive half-size multiplications compared with the basic divide-and-conquer method?
Not quite. Try another option.
Answer: It uses three products and extra additions
Karatsuba computes , , and , deriving the middle term through additions and subtractions.
Question 39 of 60 · Arithmetic with large integers · Medium
What is the asymptotic running time of Karatsuba multiplication according to ?
Not quite. Try another option.
Answer:
The Master Theorem gives , approximately .
Question 40 of 60 · Arithmetic with large integers · Medium
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?
Not quite. Try another option.
Answer: It grows by factors and , respectively
Schoolbook splitting makes four half-size products, while Karatsuba makes three, so doubling the size scales their recursive work by and .
Question 41 of 60 · General method · Hard
Consider the recurrence with constant work at the base case. What is its asymptotic solution?
Not quite. Try another option.
Answer:
The subproblem fractions satisfy a characteristic exponent below , while the additive term is linear. By the Akra–Bazzi theorem, the linear combine cost dominates, giving .
Question 42 of 60 · General method · Hard
For powers of two, suppose and . Which bound is tight?
Not quite. Try another option.
Answer:
At recursion level , the nonrecursive work is proportional to . Summing these costs produces times a harmonic sum, yielding .
Question 43 of 60 · General method · Hard
A divide-and-conquer algorithm satisfies , ignoring rounding. Which asymptotic running time follows?
Not quite. Try another option.
Answer:
Although the recursion tree is unbalanced, the subproblem sizes at each expansion sum to . The tree has logarithmic effective depth, so linear work across its levels totals .
Question 44 of 60 · General method · Hard
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 ?
Not quite. Try another option.
Answer:
The work is at the balanced recurrence boundary. The span follows only one recursive branch and is , so their ratio is .
Question 45 of 60 · Binary search · Hard
A lower-bound search uses the half-open interval and updates when , otherwise setting . Which invariant is sufficient to establish correctness?
Not quite. Try another option.
Answer: Every index below stores a value , and every index at or above stores a value .
The updates preserve these two excluded regions. At termination , so that index is exactly the first position whose value is at least .
Question 46 of 60 · Binary search · Hard
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?
Not quite. Try another option.
Answer:
Duplicates can make the first, middle, and last values equal, revealing no reliably sorted half. An adversarial array can therefore force examination of linearly many elements.
Question 47 of 60 · Binary search · Hard
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?
Not quite. Try another option.
Answer:
Doubling takes comparisons and produces a bracket of size . Binary search within that bracket has the same asymptotic cost.
Question 48 of 60 · Binary search · Hard
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?
Not quite. Try another option.
Answer:
A binary decision tree of height has at most leaves. Representing insertion positions requires , and balanced binary search attains this bound.
Question 49 of 60 · Merge sort · Hard
For , what is the exact maximum number of element-to-element comparisons performed by standard top-down merge sort?
Not quite. Try another option.
Answer:
Merging lists of total length requires at most comparisons. Summing this maximum over all merge levels gives .
Question 50 of 60 · Merge sort · Hard
While merging sorted halves and to count strict inversions satisfying and , which rule handles duplicate values correctly?
Not quite. Try another option.
Answer: Take from when ; otherwise add the number of unmerged elements in .
Equal values are not strict inversions, so the left value must be selected on equality without increasing the count. If , every remaining left value forms an inversion with .
Question 51 of 60 · Merge sort · Hard
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?
Not quite. Try another option.
Answer:
For , substitution gives a leading coefficient inversely proportional to the binary entropy .
Question 52 of 60 · Merge sort · Hard
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 ?
Not quite. Try another option.
Answer:
Each element participates in at most balanced merge levels. Writing the bound as also captures the linear handling cost when only one run exists.
Question 53 of 60 · Quick sort · Hard
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?
Not quite. Try another option.
Answer:
A pair of ranks is compared exactly when one of them is the first pivot selected from the interval between them. Summing those pairwise probabilities yields .
Question 54 of 60 · Quick sort · Hard
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?
Not quite. Try another option.
Answer: time and stack
Iteration does not prevent consistently poor partitions, so the time can remain quadratic. The recursively processed smaller side is at most half the current size, bounding stack depth by .
Question 55 of 60 · Quick sort · Hard
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?
Not quite. Try another option.
Answer: time and recursion depth
A single partition scan places every key in the equal region. Both recursive outer regions are empty, so no nontrivial recursive chain remains.
Question 56 of 60 · Quick sort · Hard
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?
Not quite. Try another option.
Answer:
At subproblem size , an extreme pivot is chosen with probability . Multiplying from through gives .
Question 57 of 60 · Arithmetic with large integers · Hard
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?
Not quite. Try another option.
Answer: and
Karatsuba computes the low, high, and combined cross products recursively. The Master theorem gives exponent , approximately .
Question 58 of 60 · Arithmetic with large integers · Hard
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?
Not quite. Try another option.
Answer:
The recurrence is . Since , recursive multiplication dominates the linear overhead.
Question 59 of 60 · Arithmetic with large integers · Hard
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?
Not quite. Try another option.
Answer:
The recurrence remains . Its recursive term has exponent , so improving additions alone does not beat quadratic time.
Question 60 of 60 · Arithmetic with large integers · Hard
For a power of two, suppose a Karatsuba-style implementation satisfies and . Which expression solves the recurrence exactly?
Not quite. Try another option.
Answer:
At level , the additive work is . Summing the geometric series and adding leaves gives .
That's unit 2
Answer a few questions and your score shows up here.
Nearly through. Did unit 2 of ECAP538 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 2 of ECAP538 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.