当前位置:网站首页>64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least

64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least

2022-07-05 05:02:00 Fierce chicken

64 The horse race problem

This is an interview question I saw on the Internet some time ago , The description of the title is as follows :

existing 64 horse ,8 Tracks , How to use the least number of comparisons to find the fastest 4 horse

When I first saw this question , I was thinking if there was timer Words ,64 Ma Ma Fen 8 Group run , Find the shortest 4 Just a piece , In this way, we just need to 1 Time For the comparison of the length of time . And strictly speaking, the word points 8 Group running can be regarded as 8 Compare it to , So at least 8 Time . But the answer to the question is not so simple , Because according to others , This race did not “ timer ”, It's impossible to know 8 The fastest between groups 4 Where is the horse 4 horse

So it's going to take a turn in thinking

First of all, let 64 Ma Ma Fen 8 The first group ran a race . here the 8 Compare it to
Then let's 8 The third in each group 1 Run once , According to the ranking of running out of the 8 Group , The rank of the group and the number of the group 1 The place of this race is the same . here the 9 Compare it to

Completed the above 8 After the groups are sorted , Because what needs to be decided is the fastest 4 horse , So the fastest 4 It can't be at the bottom of the list 4 In the group of bits ( after 4 Group No 1 It's not in the top of the list 4, Not to mention after 4 Other horses in the group ), After that 4 Set up all the stables
And then there's the front 4 Of the group 32 horse , And because you need the fastest 4 horse , So before 4 In each group of the group 4 It's not going to be the fastest 4 horse ( Since they are not the top of this group 4 name , It's even less likely to be the first of all horses 4 Name ), So before 4 All in the group after 4 Go to the famous horse shed , And then there's 16 horse
At this time, I see the number one ranking 4 The top four in our group , Because of the group's No 1 First name only in all groups 1 No. 1 in the horse 4, So the first 4 Of the group 2 To 4 The name can't be the front 4, So you can put the second 4 Second in group 2 To 4 Go to the famous horse shed
For the first 3 Before group 4 For example , Because of the group's No 1 The first name can be ranked in all groups 1 The first of the famous horses 3, So the group that follows 2 It could be number one 4, But then 3、4 Name can't be the top of all horses 4 了 , So you can put the second 3 In the group 3、4 Go to the famous horse shed
For the first 2 The group analysis is similar : Since the second time 2 Group No 1 The first name can be in all groups 1 It's number one 2, So the group that follows 2、3 The name is probably the first of all horses 3、4 name , And the second in the group 4 Name can't be the front of all horses 4, So give up the second 2 In the group 4 Famous horse
For the first 1 The rest of the group 4 horse , Since the group is No 1 The first name is the number one in all groups 1 One of the fastest , So then 3 Horses can be all horses before 4 The horse in , Don't give up
The number of horses left is 10 horse (1 Group 4 horse ,2 Group 3 horse ,3 Group 2 horse 、4 Group 1 horse )

Due to the first 1 Group No 1 The first name is all the 1 The fastest of all , You can be sure of the 1 Group No 1 Name is everything 64 The fastest of the horses , That is to say, No 1 The first name is determined as 1 Group No 1 name , Then it needs to be in the remaining 9 Before the horse comes out 3

Because only 8 Tracks , To minimize the number of comparisons , Will remain 9 Remove the second from the horse 1 Group I 4 Named 8 I'm going to 1 Compare it to , According to the first 1 Group I 3 The ranking of the first place decides whether to place the second place 1 Group I 4 Compared with other horses ( Now it's The first 10 Compare it to ):
After this comparison , The first 1 Group I 3 Top of the list 2 name , So the first 1 Group I 4 Name can be surplus 9 The front of the horse 3 name , This requires that the second 1 Group I 4 Name and number 10 After the first comparison, it is not the second 1 Of 7 Horses are more , this 8 Before the horse comes out 2 Name is the number one of all the horses left 3、 The first 4 name ( Now it's The first 11 Compare it to
If after the second 10 Compare it to , The first 1 Group I 3 The first name is not in the first place 2 name , You don't have to let the second 1 Group I 4 Take part in the comparison , There's no need for the second 11 It's a comparison , At this time 10 Before the second comparison 3 Name is the first of all horses 2 To 4 name

Sum up , You need at least 10 or 11 The second comparison

原网站

版权声明
本文为[Fierce chicken]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140623557788.html