The time complexity to multiply two polynomials of degree π using Fastβ¦
2019
The time complexity to multiply two polynomials of degreeΒ πΒ using Fast Fourier transform method is:
- A.
\(π(π\lgβ‘π) \) - B.
\(π(π^2) \) - C.
\(π(π) \) - D.
\( π(lg \ β‘π)\)
Attempted by 44 students.
Show answer & explanation
Correct answer: A
Answer: ΞΈ(n log n)
Explanation:
Pad the two coefficient sequences to length N, where N is a power of two at least 2n+1. This ensures N = Ξ(n).
Compute the FFT of both sequences. Each FFT takes O(N log N), so two FFTs cost O(N log N).
Multiply the transformed values pointwise. This step is O(N).
Compute the inverse FFT to interpolate the product coefficients. This is another O(N log N) step.
Total time: O(N log N) + O(N) = O(N log N). Since N = Ξ(n), the complexity is Ξ(n log n).
Note: The naive coefficient-by-coefficient multiplication takes Ξ(n^2), so the FFT-based method gives a substantial improvement for large n.
A video solution is available for this question β log in and enroll to watch it.