Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Keep It Simple, Stupid
 
PerlMonks  

Re: Wasting time thinking about wasted time

by salva (Canon)
on May 26, 2006 at 14:08 UTC ( [id://551919]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Wasting time thinking about wasted time

The maths you are doing here are plain wrong!

O expressions only show how an algorithm performance scales depending on the size of the data. They can't be manipulated as regular math expressions, and so O(NlogN) / O(N) != logN .

Undoing the tipical simplifications performed to get to the O expression, we can obtain a valid expression for the number of operations required by an algorithm. For instance, for an O(NlogN) algorithm as perl built-in sort, the number of operations should be something like A*NlogN + B*N + C (where A, B and C are unknown constants).

For an O(N) algorithm the number of operations is usually B'*N + C'. But when sorting using the ST the cost of the algorithm is still O(NlogN), you can not ignore the sort step, even if it is implemented in fast C. So the real number of operations is A'*NlogN + B'*N + C', though A' is much smaller than A.

Considering all this, the resulting relative performance between both algorithms is (A*NlogN + B*N + C)/(A'NlogN + B'*N + C)

It's very different from the logN value you were using and that's why the benchmark results don't mach your expectations.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://551919]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.