Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: question for perl book & magazine authors

by holli (Abbot)
on Oct 19, 2005 at 21:06 UTC ( [id://501430]=note: print w/replies, xml ) Need Help??


in reply to Re: question for perl book & magazine authors
in thread question for perl book & magazine authors

The hash trick is a nice way if the array is small enough. for huge arrays the algorhitmical/runtime trade may be worth the price to save memory.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^3: question for perl book & magazine authors
by sauoq (Abbot) on Oct 19, 2005 at 21:18 UTC

    Sure... if memory is so tight that you have to choose an O(n * m) time complexity over O(n + m) then I guess you gotta do what you gotta do.

    Of course, in that case (and especially if this is a routine task) you are almost certainly going to win by throwing more RAM at the problem because the larger your dataset the more (time) you are saving with the linear algorithm.

    Update: Also note that the additional memory you need will be relative to the smaller of your two arrays. (As a possible optimization depending, of course, on your data.)

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-03-28 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found