Professional Documents
Culture Documents
January 2022
3. Let A be a sorted array. Find i such that A[i] = i in O(log n) time if it exists.
4. A majority element in an array of length n is an element that occurs more than ⌈n/2⌉
times. It is easy to find such an element in O(n log n) time by sorting. Can you find it
in linear time? (Hint: Pair up numbers arbitrarily, if they are the same, keep one; if they are different, remove both. You are now left with at most
n/2 numbers.)
5. Suppose we divide the numbers into 3 groups of n/3 digits each as in Karatsuba’s algo-
rithm. The trivial algorithm now would require 9 multiplications recursively yielding
Θ(n2 ) time. How much do you have to reduce this to improve upon Karatsuba’s algo-
rithm?