p(x)
at [a0, a1, ... am]
in general is hard, even though we have the recurrence p(x) = po(x^2) + x pe(x^2)
. This makes the polynomials smaller (degree of po
, pe
is half of that of p
). However, we need to evaluate at all the points [a0...am]
, so to merge we need to merge values at [a0...am]
at each step. So our recurrence will be T(n) = T(n/2) + m
with T(1) = m
. This solves to O(nm)
. p(x)
at [w[n][0], ... wn[n][n-1]]
given the values of po
, pe
at [w[n/2][1], w[n/2][2], w[n/2][3], ... w[n/2][n/2-1]]
. So the number of points we need to evaluate the polynomial decreases with the size of the polynomial! T(n) = T(n/2) + n
with T(1) = 1
which is O(n log n)
. T(n) = n + T(n/2)
, with T(1) = 1
= T(n)
= n + 2T(n/2)
= n + 2[n/2 + T(n/4)]
= n + n + 4T(n/4)
= n + n + 4[n/4 + 2T(n/8)]
= n + n + n + 8T(n/8)
= ...
= kn + ... 2^k T(n/2^k)
= (log n)n + 2^(log n) T(n/2^(log n))
= (log n)n + n T(n/n)
= (log n)n + n* 1
= (log n)n + n
8
mrg:8
4 4
mrg:4 mrg:4
2 2 2 2
mrg:2 mrg:2 mrg:2 mrg:2
1 1 1 1 1 1 1 1
n
. Cost of each leaf is T(1) = 1
. Total cost of leaf level is n
. 8 = 4*2 = 2*4
. log n
. n
, plus cost of interior nodes n log n
.