由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 大数乘法的另类解法
相关主题
dp真优美,matrix chain multiplication 解法一个图论题
[合集] 报个微软的OFFER以及面经Question:Given a array,find out if there exist a subarray such its sum is zero
a question about combination大牛们,来说说你们DP是怎么练出来的
关于n个数的所有和的一个问题问一道题
general solution for missing number(s) problem帮忙看看这道DP算法题
攒rp,发Careercup上的4个视频,不知道有没有人需要phone interview question
求解比硬币找零稍难的一题算法面试题
问10个老题请教一道题
相关话题的讨论汇总
话题: sample话题: int话题: size
进入JobHunting版参与讨论
1 (共1页)
h******8
发帖数: 55
1
快速傅里叶变换
int * multiplication(int a[], int b[], int size_a, int size_b)
{
int i, j;
for (i = 0; i < size_a + size_b; ++ i) c[i] = 0;
for (i = 0; i < size_a; ++ i)
for (j = 0; j < size_b; ++ j)
c[i+j] += a[i]*b[j]
return c;
}
It will take n^2 operations.
♥ To reduce that, we can transform the coefficient representation to
sample representation. Then do the multiplication, then transform back.
Sample representation: given {(x_0, y_0), ..., (x_n, y_n)}, there is exactly
one polynomial p of degree n s.t. p(x_i) = y_i for all i. Thus, {(x_0, y_0)
, ..., (x_n, y_n)} can represent a n-degree polynomial.
To multiply two polynomials, just multiply their sample values. If we are
multiply two polynomials of degree n, we need to start with 2n+1 sample
values for each polynomials, since that is how many we need to uniquely
represent the product polynomial. This obvious takes O(n).
If we can choose the sample points carefully (e.g., FFT), we can do the
transformation in O(n \log n). Thus, the whole multiplication takes O(n \log
n).
1 (共1页)
进入JobHunting版参与讨论
相关主题
请教一道题general solution for missing number(s) problem
版主要是能组织搞一个每日一题就好了攒rp,发Careercup上的4个视频,不知道有没有人需要
请问有最近G家的Quantitative Analyst的面经吗求解比硬币找零稍难的一题
amazon居然有这么难得phone interview question问10个老题
dp真优美,matrix chain multiplication 解法一个图论题
[合集] 报个微软的OFFER以及面经Question:Given a array,find out if there exist a subarray such its sum is zero
a question about combination大牛们,来说说你们DP是怎么练出来的
关于n个数的所有和的一个问题问一道题
相关话题的讨论汇总
话题: sample话题: int话题: size