A single elimination tournament - number of possible combinations
What are the number of combinations in which 8 persons taking part in a single elimination tornament play? Total no of matches pla开发者_运维技巧yed would be 7 but I also need the number of combinations that can for this set
If it doesn't matter where in the tree a player starts, but only which opponents he/she fights, and how long he/she gets, we can say that the left player always wins and then just calculate the number of ways to create the bottom most row, which is 8! 40320.
The first possibility:
a
a e
a c e g
a b c d e f g h
The second possibility:
a
a e
a c e h
a b c d e f h g
There are (8 * 7) / 2 combinations = 28 [ in other words, 8!/(2! * (8-2)!) ]
With Set::Partition in Perl I can write:
my $s = Set::Partition->new(
list => ['a'..'h'],
partition => [2, 6],
);
while (my $p = $s->next) {
print join( ' ', map { "[@$_]" } @$p ), $/;
}
which gives
[a b] [c d e f g h]
[a c] [b d e f g h]
[a d] [b c e f g h]
[a e] [b c d f g h]
[a f] [b c d e g h]
[a g] [b c d e f h]
[a h] [b c d e f g]
[b c] [a d e f g h]
[b d] [a c e f g h]
[b e] [a c d f g h]
[b f] [a c d e g h]
[b g] [a c d e f h]
[b h] [a c d e f g]
[c d] [a b e f g h]
[c e] [a b d f g h]
[c f] [a b d e g h]
[c g] [a b d e f h]
[c h] [a b d e f g]
[d e] [a b c f g h]
[d f] [a b c e g h]
[d g] [a b c e f h]
[d h] [a b c e f g]
[e f] [a b c d g h]
[e g] [a b c d f h]
[e h] [a b c d f g]
[f g] [a b c d e h]
[f h] [a b c d e g]
[g h] [a b c d e f]
which you can interpret two players playing, and the six others standing around cheering and drinking beer.
If you mean, how many possible 2 player matches are there in a pool of 8 players then the answer is 28 (8x7/2). If you mean something else, then clarify your question a bit.
精彩评论