Re: Combinatorics question
- From: Mariano Suárez-Alvarez <mariano.suarezalvarez@xxxxxxxxx>
- Date: Sun, 6 Apr 2008 11:18:03 -0700 (PDT)
On 6 abr, 12:08, Mensanator <mensana...@xxxxxxx> wrote:
On Apr 6, 12:37 am, Mariano Suárez-Alvarez
<mariano.suarezalva...@xxxxxxxxx> wrote:
On 5 abr, 21:13, Mensanator <mensana...@xxxxxxx> wrote:
On Apr 5, 6:46�pm, Ketakop...@xxxxxxxxx wrote:
Thanks a lot for the help so far. It sure has been of much help. The
only thing is, that I'm having a bit of hard time understanding the
codes ;)
Whose? If it's MSA's code, that's understandable as
it's incorrect. Althought he does, in fact, generate
the correct count of C(10,4), all the numbers generated
end in '00', his minimum number being 0000111100
instead of the correct 0000001111. And some of his
numbers have 12 bits. You'll find in gerneral that
generating wrong answers asymtotically faster isn't
better.
Ah. What I wrote and tested was:
def subsets(n, i, min = 1):
if i == 0:
yield []
elif n - min + 1 >= i:
for m in xrange(min, n + 1):
for s in subsets(n, i - 1, m + 1):
yield [m] + s
which enumerates the actual subsets and
messed up in trying to come up with
def subsets(n, i, min = 1):
if i == 0:
yield 0
elif n - min + 1 >= i:
for m in xrange(min, n + 1):
for s in subsets(n, i - 1, m + 1):
yield (1 << (m - 1)) + s
which instead enumerates numbers coding the
subsets. That's what one gets from not testing.
You are surely not contesting the claim
about efficiency, of course ;-)
No, of course not. Doesn't solve the OP's problem though.
Do you have an asymptotically faster way of doing the
Hamming Distance check?
I doubt there is a known algorithm to do what
the OP wants efficiently in general, and I
certainly do not have one. But simply replacing
your `while xrange(last)' loop by a loop using
my generator, the number of iterations in
the outer loop goes from exponential to
polynomial in the number of elements in the
set.
I do not think a brute force algorithm is
going to do much better. The Johnson graph
has a lot of structure, so it would not be
surprising that there is something different
one can do to obtain independent sets in it
efficiently. But to put the issue in
perspective, the size of a maximal independent
set in the Johnson graph is not known, so...
-- m
.
- References:
- Combinatorics question
- From: Ketakopter
- Re: Combinatorics question
- From: Mensanator
- Re: Combinatorics question
- From: Mariano Suárez-Alvarez
- Re: Combinatorics question
- From: Ketakopter
- Re: Combinatorics question
- From: Mensanator
- Re: Combinatorics question
- From: Mariano Suárez-Alvarez
- Re: Combinatorics question
- From: Mensanator
- Combinatorics question
- Prev by Date: Re: Line does not consist of points..
- Next by Date: Re: (finite)galois field
- Previous by thread: Re: Combinatorics question
- Next by thread: Re: Combinatorics question
- Index(es):
Relevant Pages
|