in reply to Re^2: Algorithm complexity
in thread Algorithm complexity
But you can tell that a program didn't finish after a given threshold (a week or so) without violating Turing's laws.
Yes, that's an incomplete solution. Which doesn't tell you anything about the asymptotic runtime if it didn't finish.
In theory it should be possible to approximate O(n) by benchmarking for increasing n and using numerical methods to interpolate the gotten data.
If you don't try it for all possible inputs you can miss worst case scenarios.
For example old versions of perl used to have an O(n) complexity for hash accesses if the keys followed a certain pattern that lead to 100% hash collisions - which was an attack vector for denial of service attacks.
(Newer perl versions solve that by randomizing hash seeds if too many collisions occur).
You not only have to specify what n in O(n) means, but also if you're talking about worst case, average case or amortized runtime.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Algorithm complexity
by LanX (Saint) on Jul 08, 2009 at 00:45 UTC | |
by spx2 (Deacon) on Jul 08, 2009 at 09:56 UTC | |
by LanX (Saint) on Jul 08, 2009 at 10:46 UTC | |
by spx2 (Deacon) on Jul 08, 2009 at 11:11 UTC | |
by LanX (Saint) on Jul 08, 2009 at 11:27 UTC |