| ▲ | orlp 2 hours ago | |
> N tokens looking at N tokens is quadratic Convolving two arrays can be done perfectly accurately in O(n log n), despite every element being combined with every other element. Or consider the even more basic sum of products a[i] * b[j] for all possible i, j:
This can be computed in linear time as sum(a) * sum(b).Your logic that 'the result contains terms of all pairs, therefore the algorithm must be quadratic' simply doesn't hold. | ||
| ▲ | anvuong an hour ago | parent [-] | |
This brings me back to DSP class, man learning about FFT was eye-opening. | ||