n people decide to elect a leader by arranging themselves in a circle and eliminating every...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
n people decide to elect a leader by arranging themselves in a circle and eliminating every m-th person around the circle, closing ranks as each person drops out. The problem is to find out which person will be the last one remaining. This picture illustrates the problem for n = 9 and m = 5. In this particular case, the person in position 8 is the last person standing and will be elected as the leader. The initial circle of 9 people. Counting starts (counter-clockwise) from person 1 and the fifth person is eliminated. The fifth person (counter-clockwise) from Person # 6 is Person #1. So now Person #1 gets eliminated. Person 5 gets eliminated and the ranks close. Eight people remain in the circle. Counting now starts again from Person #6 Bay until a single person remains. That person is now the winner! Counting continues as usual, eliminating the fifth person at each round. You wish to be the leader of this group of n people. Find the position that you need to occupy in order to be elected leader. circle Test your code for different values of m and n. Here are the results you should get for different values of m and n: o When n = 7 and m = 2, the leader should be 7 (and people are eliminated in this order: 2, 4, 6, 1, 5, 3. Do this by-hand also to ensure this answer is correct). o When n = 9 and m = 5, the leader should be 8 (this is the same as the example shown in the picture above). o When n = 1 000 000 and m = 10, the leader should be the 630 538-th person in the circle. n people decide to elect a leader by arranging themselves in a circle and eliminating every m-th person around the circle, closing ranks as each person drops out. The problem is to find out which person will be the last one remaining. This picture illustrates the problem for n = 9 and m = 5. In this particular case, the person in position 8 is the last person standing and will be elected as the leader. The initial circle of 9 people. Counting starts (counter-clockwise) from person 1 and the fifth person is eliminated. The fifth person (counter-clockwise) from Person # 6 is Person #1. So now Person #1 gets eliminated. Person 5 gets eliminated and the ranks close. Eight people remain in the circle. Counting now starts again from Person #6 Bay until a single person remains. That person is now the winner! Counting continues as usual, eliminating the fifth person at each round. You wish to be the leader of this group of n people. Find the position that you need to occupy in order to be elected leader. circle n people decide to elect a leader by arranging themselves in a circle and eliminating every m-th person around the circle, closing ranks as each person drops out. The problem is to find out which person will be the last one remaining. This picture illustrates the problem for n = 9 and m = 5. In this particular case, the person in position 8 is the last person standing and will be elected as the leader. The initial circle of 9 people. Counting starts (counter-clockwise) from person 1 and the fifth person is eliminated. The fifth person (counter-clockwise) from Person # 6 is Person #1. So now Person #1 gets eliminated. Person 5 gets eliminated and the ranks close. Eight people remain in the circle. Counting now starts again from Person #6 Bay until a single person remains. That person is now the winner! Counting continues as usual, eliminating the fifth person at each round. You wish to be the leader of this group of n people. Find the position that you need to occupy in order to be elected leader. circle Test your code for different values of m and n. Here are the results you should get for different values of m and n: o When n = 7 and m = 2, the leader should be 7 (and people are eliminated in this order: 2, 4, 6, 1, 5, 3. Do this by-hand also to ensure this answer is correct). o When n = 9 and m = 5, the leader should be 8 (this is the same as the example shown in the picture above). o When n = 1 000 000 and m = 10, the leader should be the 630 538-th person in the circle. Test your code for different values of m and n. Here are the results you should get for different values of m and n: o When n = 7 and m = 2, the leader should be 7 (and people are eliminated in this order: 2, 4, 6, 1, 5, 3. Do this by-hand also to ensure this answer is correct). o When n = 9 and m = 5, the leader should be 8 (this is the same as the example shown in the picture above). o When n = 1 000 000 and m = 10, the leader should be the 630 538-th person in the circle.
Expert Answer:
Answer rating: 100% (QA)
To determine the position in the circle that you need to occupy in order to be elected leader you ca... View the full answer
Related Book For
Algorithm Design And Applications
ISBN: 9781118335918
1st Edition
Authors: Michael T. Goodrich, Roberto Tamassia
Posted Date:
Students also viewed these programming questions
-
Respond to the requirements related to the following independent revenue arrangements for Crane products and services. (a) Your answer has been saved. See score details after the due date. Crane...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Read the case study "Southwest Airlines," found in Part 2 of your textbook. Review the "Guide to Case Analysis" found on pp. CA1 - CA11 of your textbook. (This guide follows the last case in the...
-
Find all conjugates in C of the given number over the given field. 1+2 over Q
-
Show that if D is an n à n diagonal matrix, then ll D112 = max (ldil)
-
The equity sections for Atticus Group at the beginning of the year (January 1) and end of the year (December 31) follow. Stockholders' Equity (January 1) Common stock-$5 par value, 100,000 shares...
-
Mass transfer models include transfer in only the packed region. Mass transfer also occurs in the column ends where liquid and vapor are separated. Discuss how these end effects affect a design. How...
-
Montevideo Manufacturing, Inc. produces a single type of small motor. The bookkeeper who does not have an in-depth understanding of accounting principles prepared the following performance report...
-
can help a company gain additional insight comparing a company's ratios with the same ratios for companies in the same business. a. Industrial averages b. Key averages c. Leverage averages d....
-
The Teachers' Retirement System of a midwestern state is selling a bond investment from its portfolio to generate cash to make payments to retirees for the coming year It plans to sell $100 million...
-
(a) At present a company purchases an item X from outside suppliers. The consumption of this item is 10,000 units/year. The cost of the item is Rs 5 per unit and the ordering cost is estimated to be...
-
Discuss the criteria used to select e-commerce software and service provider vendors. Why is it necessary to use these criteria? Explain in details.
-
Discuss the risks, the potential impact of the scenarios, and the potential impacts of the risk applying the value framework. Also, include any comments regarding Swissgrid's CRO officer and the use...
-
Discuss all 7 of Matveyeva's (2023) interpersonal communication improvement tools: mindfulness practices, journaling, self-reflection exercises, visualization techniques, self-affirmations, active...
-
Discuss the types of and different models for change. How can change be a cause of conflict. What are other causes of conflict? Would the conflict caused by change be functional or dysfunctional...
-
Variable costing is a method of assigning only variable manufacturing costs to products, leaving fixed manufacturing overhead costs to be expensed in the period incurred. Discuss the advantages and...
-
Find Net present worht (NPW), and payback period of the following projects with MARR 18% 3871 6.0787 A 698.24 B 156788 -2500 -7000 1650 2000 1650 2000 650 2000 600 1500 600 1500 600 3000 300 4500 300...
-
In a nonmagnetic medium, E = 50 cos (10 9 t 8x) a y + 40 sin (10 9 t 8x) a z V/m find the dielectric constant r and the corresponding H.
-
Is there a heap T storing seven distinct elements such that a preorder traversal of T yields the elements of T in sorted order? How about an inorder traversal? How about a postorder traversal?
-
A grammar G is a way of generating strings of terminal characters from a nonterminal symbol S, by applying simple substitution rules, called productions. If B is a production, then we can convert a...
-
Let p be a prime. Give an efficient alternative algorithm for computing the multiplicative inverse of an element of Zp that is not based on the extended Euclids algorithm. What is the running time of...
-
When we want to add three numbers, say \(a+b+c\), we don't bother inserting parentheses because \((a+b)+c=a+(b+c)\). But with powers, this is not true \(-\left(a^{b} ight)^{c}\) need not be equal to...
-
Prove that if \(x, y>0\) then \(\frac{1}{2}(x+y) \geq \sqrt{x y}\). For which \(x, y\) does equality hold?
-
After a delicious meal at the well-known French restaurant La Racine et Puissance Rationelle, critic Ivor Smallbrain notices that the bill comes to \(x\) pounds, \(y\) pence, where \(x\) and \(y\)...
Study smarter with the SolutionInn App