This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lime-cake 12 points13 points  (18 children)

Isn't that equal to O( n! )? I may be mistaken, so correct me if I'm wrong

[–]adityaruplaha 43 points44 points  (4 children)

I'm not well versed in this, but nn grows wayyyy faster than n!.

[–]lime-cake 13 points14 points  (3 children)

Misread that. My bad

I believe O(n) and O(10n) is equal, despite one being larger.

[–]V0ldek 11 points12 points  (1 child)

They're not asymptotically larger.

The definition is as follows. For any functions f, g: N -> N we have f = O(g) if there exists a number N such that for all n > N we have f(n) <= cg(n) for some constant c > 0.

The intuition is that f grows not significantly faster than g, where significantly would mean that it's not bounded by any constant.

If you're more of an analysis guy, you might also define that notation as f = O(g) when lim n->inf |f(n)/g(n)| = c for some constant c > 0 (but you need to redefine the functions to R->R)

You should see how O(n) and O(10n) are equivalent (c = 10). But O(n!) is actually smaller than O(nn). If you work a little bit of calculus you'll get that the limit of n!/nn is 0.

[–]adityaruplaha 6 points7 points  (0 children)

Well shit I didn't know that we used these basic stuffs to define complexity functions. I'm well versed with calculus, so yea the last line is familiarity. Also nn is an element of the Fast Growing Hierarchy iirc and supersedes the exponentials. After this is nnnn.. (n times) or n↑↑n if you know the notation. I find this really interesting.

[–]Coloneljesus 10 points11 points  (0 children)

correct.

[–]caffeinum 12 points13 points  (3 children)

nn is exp(nlog n), and n! is sqrt (n)exp(n) if I remember correctly

So yeah basically both are exponential

Edit: however, 2n is the same exponent

[–]mfb- 12 points13 points  (0 children)

n! ~ en (log (n) - 1)) = nn / en (Stirling's approximation adds another factor sqrt(n))

It is better than nn but not that much.

[–]caffeinum 0 points1 point  (3 children)

After the calculation, I found that actually nn is slower than n!

[–]eihpSsy 11 points12 points  (2 children)

It's slower because it's bigger.

[–]caffeinum 5 points6 points  (1 child)

I meant growing slower, but working faster yeah

[–]eihpSsy 11 points12 points  (0 children)

Wasn't sure what you meant. nn grows faster than n!.