我在本书后面列出的这个问题有点麻烦,我目前正处于测试准备阶段,但我似乎无法在书中找到任何相关内容。
有人有个主意吗?
A real polynomial of degree n is a function of the form f(x)=a(n)x^n+⋯+a1x+a0, where an,…,a1,a0 are real numbers. In computational situations, such a polynomial is represented by a sequence of its coefficients (a0,a1,…,an). Assuming that any two real numbers can be added/multiplied in O(1) time, design an o(n^2)-time algorithm to compute, given two real polynomials f(x) and g(x) both of degree n, the product h(x)=f(x)g(x). Your algorithm should **not** be based on the Fast Fourier Transform (FFT) technique.
请注意 它必须是小-o(n ^ 2) ,这意味着它的复杂性必须是次二次的。
我发现的显而易见的解决方案确实是FFT,但当然我无法使用它。还有另一种我发现称为卷积的方法,其中如果你将多项式A作为信号而多项式B作为滤波器。通过B的A产生一个已经被A“平滑”的移位信号,结果是A * B.这应该在O(n log n)时间内起作用。当然,我完全不确定实施。
如果有人对如何实现小o(n ^ 2)实现有任何想法请分享,谢谢。
答案 0 :(得分:1)
small-o:f(x) = o(g(x)) is equivalent to lim x -> inf f(x)/g(x) = 0
。
使用Karatsuba algorithm