分而治之:多项式乘法时间复杂度
Divide-and-conquer: Polynomial multiplication time complexity
当我在学习分而治之的方法时,我遇到了这个例子(https://www.geeksforgeeks.org/multiply-two-polynomials-2/) about polynomial multiplication. I cannot understand why the time required to add four results (subproblems) is Theta(n). I thought the addition only takes constant time. Why linear time? Thanks in advance!
你是对的。但这里的“所有结果相加”是指将x
的各次方的乘积相加,求出最终结果为多项式,即x
、[=12=的乘积之和], ..., x^n
。从这个意义上说,四个幂为 O(n)
的多项式之和为 O(n)
.
当我在学习分而治之的方法时,我遇到了这个例子(https://www.geeksforgeeks.org/multiply-two-polynomials-2/) about polynomial multiplication. I cannot understand why the time required to add four results (subproblems) is Theta(n). I thought the addition only takes constant time. Why linear time? Thanks in advance!
你是对的。但这里的“所有结果相加”是指将x
的各次方的乘积相加,求出最终结果为多项式,即x
、[=12=的乘积之和], ..., x^n
。从这个意义上说,四个幂为 O(n)
的多项式之和为 O(n)
.