Question on sorting.. confused! [closed]
There is a question and I have the solution to it also, but I am confused and I am not able to understand it.. Please if anybody can put their thoughts forward....
Question
There are 128 placyers participating in a tennis tournament. Assume that the "x beats y" relationship is transitive, i.e., for all players A, B and C, if A beats B and B beats C, then A beats C.
What is the least number of matches we need to organize to find the best player? How many matches do you need to find the best and the second best player??
Answer
First we consider the problem of finding the best player. Each game eliminates one player and there 128 players, so 127 matches are necessary and also sufficient. >>>> Understood....
To find the second best, we note that the only candidates are the players who are beaten by the player who is eventually determined to be the best - everyone else lost to someone who is not the best. >>>> Understanding (Those who are lost by the best players are the candidates of second best???? rite???)
To find the best player, the order in which we organize the matches is inconsequential - we just pick pairs from the set of candidates and who ever loses is removed from the pool of candidates.
However if we proceed in an arbitrary order, we might start with the best player, who defeats 127 other players and then the players who lost need to play 126 matches amongst themselves to find the second best. >>>>>>>>>>.. confused
We can do much better by organizing the matches as a binary tree - we pair of players arbitrarily who play 64 matches. After these matches we are left with 64 candidates; we pair them off again arbitrarily and they play 32 matches. Proceeding in this fashion, we organize the 127 matches needed to fin开发者_JAVA技巧d the best player and the winner who have played only 7 matches. Therefore we can find the second best player by organizing 6 matches between 7 players who lost to the best player, for a total of 134 matches. >>>>>>> confused......
If you run the tournament as a binary tree, you will at the final end up with two players A and B that are the best of their branch in the tree.
If A beats B in the final, A is (because of the transitivity) better than every other player. There is however nothing guaranteeing that B thereby is the second best, i.e. better than everyone in A:s branch of the tree.
There is a set of 7 players that are the best of some branch of the tree and all have been beaten by A - we don't know which one among these is the best (and thus second best overall) until they (directly or transitively) have played each other.
精彩评论