The task of the stadium: to provide an algorithm to solve the problem

In a small stadium in the stands there are several thousand people. Develop a distributed algorithm that allows the audience to consider themselves. Do not assume any specific stadium geometry, unless, if you wish, it has a bowl shape. Clearly state your assumptions, then present your algorithm and analysis

I assumed that the participants would be a linked list and add a counter and free (ptr). Maybe I'm wrong ... Please provide some useful information

Thanks in adv ...

+6
c algorithm puzzle
source share
5 answers

Assuming everyone can talk to their neighbor (possibly in many empty places), and that fans of Team A are ready to talk with fans of Team B, the following might work:

Each captures its closest neighbor, which no one has yet grabbed to form groups of no more than two people. Now everyone remembers the size of the group in which they are located (maybe 1 or 2). Now the leader of each group is selected so that he can communicate with a member of another group. The leaders of each group try to join their group with each other, and each member of the two (now joined) groups remembers the sum of the members of each group (this can be done by passing a new value to be added to the group). This process continues until until only one group remains. At the end of this process, everyone knows the number of people in the stadium.

Hope this helps.

+11
source share

In a small stadium there are several thousand people in the stands. Develop a distributed algorithm that allows the audience to consider themselves.

Feynman's answer (see round question in the hatch ): Ask everyone to shout, โ€œA few thousand!โ€

+3
source share

For each column, the leader is selected with the rule: "the person in the row closest to the field is the leader" (these places are usually filled). The leader initiates a count of people in this column as follows:
1. Shake your hand with the person who is sitting behind and asks: โ€œyou?โ€
2. If there is no person behind the person, the answer should be 1 , or take step 1 with the person behind, and the answer is more than the answer from the person behind him. 3. The leader immediately writes this number on the board and holds it 4. Among these leaders, the youngest should start collecting these boards and adding them. If she meets a person younger than her colleagues, the account is then transferred to another person. If the same age, a taller person will prevail.

+2
source share
  • Everyone throws his words, and the "way out" is available in the local newspaper the next day, when "people arrested in the world's first mass incident" were arrested. (that is, the application asks the system to do the work).
  • Each person chooses another person to fight, and first asks how many people they knocked out. The winner finds another opponent, adds the score of the defeated opponent. The last man (or woman) has an answer.
  • Everyone gets up, rips off his hair, and then extends it to someone nearby, at least with so much hair, before sitting down again. Permanent people continue to look for others to give hair to too. The last person counts hair.
  • You invite people to take a bag from the mints from the cafeteria, and then hand it out until they can find anyone who does not have it, and then drop the bag at a central point. Multipoint bags * number of coins per bag - number of coins - left in bags.
+2
source share

Here is another algorithm:

  • Let everyone count the rest and themselves.
  • Then, at the sound of the horn, each counter counts its own score.
  • Keep the most screams.

With this algorithm, you can handle errors.

+2
source share

All Articles