Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: algorithm for 'best subsets'

by Limbic~Region (Chancellor)
on Mar 03, 2005 at 21:27 UTC ( [id://436377]=note: print w/replies, xml ) Need Help??


in reply to Re^3: algorithm for 'best subsets'
in thread algorithm for 'best subsets'

halley,
For the record, my solution has a very small memory footprint even for really large test cases but it can be really slow to finish. A half hour with this test case for a target size of 3.

Cheers - L~R

Replies are listed 'Best First'.
Re^5: algorithm for 'best subsets'
by fizbin (Chaplain) on Mar 03, 2005 at 22:57 UTC
    As I think I've said elsewhere, Limbic~Region's solution has a time complexity that goes up as O(K!/(N!(K-N)!)), that is as "K choose N", where K is the number of keywords and N the size of your tuples. However, I think that the memory requirements of his solution are only O(K*I), where I is the number of items.

    Contrast my solution, which while it wins on this set of data (5 seconds for what takes L~R's 30 minutes), has a time complexity of at least O(I*L!/(N!(L-N)!)), and so bogs down if the size of the sets increases, (just change rand(8) to rand(80) and watch it fall over) and has a memory complexity of something like that as well. (where "L" is the average size of a set)

    -- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-03-28 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found