Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: redo entire loop

by jonadab (Parson)
on Aug 13, 2010 at 18:06 UTC ( #854966=note: print w/ replies, xml ) Need Help??


in reply to redo entire loop

From an algorithm analysis perspective, avoiding a second pass is a relatively minor optimization. Your algorithm is O(n) with the second pass, and it's still O(n) with the optimization. Unless the performance is so bad that users are timing it with a clock, they won't notice the difference.

If the performance is so bad that users are timing it with a clock, you should probably think about O(log n) possibilities (such as running a binary search against a sorted index) or, depending on the nature of your data, maybe replacing the flat-file implementation with a DBMS.


Comment on Re: redo entire loop

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://854966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2014-04-17 19:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (454 votes), past polls