Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: Finding Neighbours of a String

by Aristotle (Chancellor)
on Mar 01, 2006 at 11:44 UTC ( #533626=note: print w/replies, xml ) Need Help??

in reply to Re: Finding Neighbours of a String
in thread Finding Neighbours of a String

Your approach generates oodles of duplicates which it then filters back out by eating up memory for hashes. The approach I outlined above generates no dupes to begin with.

I didnít know about Math::Combinatorics though; nice module. It did annoy me that I had to use two different modules with confusing differences in their APIs. Iíll update my code to use M::C instead. Nope, doesnít help, still need S::CP.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^3: Finding Neighbours of a String
by inman (Curate) on Mar 01, 2006 at 12:31 UTC
    Is this such a bad thing? The OP suggests that he is going to do this for a large number of strings. My code builds up the combinations first in a preparation step and then calculates the different strings that have the desired HD. The prep work can then be re-used for all strings of the same length.

      Depends on just how many dupes you produce to get there. If you have to throw away more dupes than you generated valid neighbours in the first place, it seems much better to invest a fraction of the effort in redoing the combinatorics over and over. You get to save all the memory too.

      The first versions of the approach I went with were not directly designed to avoid duplicates, and produced nearly 4◊ as many results as there were unique results, for a Hamming distance of 2 on a string of length 6. I assume that as numbers go up, any approach that does not avoid dupes to begin with will waste humongous amounts of time on them. Of course this is relatively off-the-cuff; I havenít reasoned it deeply, so it might not be as bad as I think.

      Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://533626]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-03-17 23:26 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (227 votes). Check out past polls.