You are on page 1of 1

Problem Set 2

January 2022

1. Use Karatsuba’s algorithm to multiply 12345678 and 87654321.

2. Compute the product of 1 + 2x + 3x2 + 4x3 and 4 + 3x + 2x2 + x3 using FFT.

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?

6. If we consider an n-digit number as an (n − 1)-degree polynomial (Just put x = 10


in the decimal representation) and perform FFT-based polynomial multiplication, do
we get a O(n log n) time multiplication algorithm for numbers? Why or why not?

You might also like