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:

Answer: A. \(๐œƒ(๐‘›\lgโก๐‘›) \) โ€” 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โ€ฆ

  1. A.

    \(๐œƒ(๐‘›\lgโก๐‘›) \)

  2. B.

    \(๐œƒ(๐‘›^2) \)

  3. C.

    \(๐œƒ(๐‘›) \)

  4. D.

    \( ๐œƒ(lg \ โก๐‘›)\)

Attempted by 108 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.

Explore the full course: Coding For Placement

Loading lessonโ€ฆ