[llvm-commits] PATCH: Fix quadratic behavior in PR12652

Jay Foad jay.foad at gmail.com
Fri Jul 6 03:20:05 PDT 2012


On 6 July 2012 09:42, Chandler Carruth <chandlerc at gmail.com> wrote:
> It doesn't grow by the size of the input squared, it grows by a constant
> factor of the size of the input, the constant happens to be "2" instead of
> "1".

So on input size n, the runtime is 2n. (*)

> Thus if I double the size of the input, I quadruple the runtime.

No. Input size 2n ==> runtime 4n. Both have doubled.

> It
> isn't quadratic unless when I quadruple the size of the input, it multiplies
> the time by 16 (4*4) -- currently it just multiplies it by 8 (2 * 4).

You're telling me that doubling input size quadruples runtime, but two
successive doublings don't give two successive quadruplings.
Seriously?

(*) Obviously the units are arbitrary here, which makes the constant
factor arbitrary too. This is very basic big-O notation stuff.

Jay.



More information about the llvm-commits mailing list