Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The Big-O notation doesn't work in such a simple way as taking the complexity of two algorithms and comparing them directly like that. Big-O notation relies heavily on exactly what 'N' is. Just because two algorithms are O(N) or O(N^2) doesn't mean a thing, because in one algorithm, N could be a large, time-consuming mathematical calculation, and in the other N could be a simple regular expression.

The power of Big-O notation comes with being able to roughly be able to predict how an algorithm will act on different sizes of datasets, and taking that information and tailoring your algorithm to get the best performance based on the fastest running time of the average-sized set of data. If one algorithm is O(N), and the other is O(N^2), the latter may be a better choice in some cases, if the former has a much larger N, and you can ensure that there won't be too much data to negate the smaller N.

Basically, it all boils down to the necessity of doing much more testing than you did. The best efficiency takes many steps to reach. If you did more benchmarks with different numbers of IP addresses, different complexity algorithms, and things like that, you'd start to see how the Big-O notation would help you predict future tests.


In reply to RE: Sorting a list of IP addresses (aka Why I hate Big O) by plaid
in thread Sorting a list of IP addresses (aka Why I hate Big O) by jeffa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-16 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found