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
-
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
-
NPV may be preferred to IRR, why?
-
The number N (in thousands) of cellular phone subscribers in Malaysia is shown in the table. (Midyear estimates are given.) (a) Use the data to sketch a rough graph of N as a function of (b) Use your...
-
Repeat Problem 8.106 if the downspout is circular. Problem 8.106 Rainwater flows through the galvanized iron downspout shown in Fig. P8.106 at a rate of \(0.006 \mathrm{~m}^{3} / \mathrm{s}\)....
-
The following determination and distribution of excess schedule is prepared on January 1, 2012, the date on which Parker Company purchases a 60% interest in Share Company: On December 31, 2013,...
-
Answer question (i) to (v) as in Program 7 below with suitable codes to produce output as in Figure 3. //Program 7 public class TestException { public static void main(String args[]) { int array[]...
-
Discuss how and why signature stories can help an organisation to communicate more effectively with strategic messages. Give references also.
-
When is technology transfer complete?
-
Which federal agency oversees the credit practices of banks, mortgage lenders, and credit card companies?
-
What are the appropriate HRM practices conducive to global R&D?
-
Which federal rule protects consumers who buy goods over the phone, through the mail, or online?
-
The Truth-in-Lending Act applies to creditors who, in the ordinary course of business, lend money or sell goods on credit to consumers. (True/False)
-
The following cost data relate to the manufacturing activities of the SIS Limited during the most recent year: Opening raw materials Closing raw materials Raw materials purchase Opening work in...
-
How do the principles of (a) Physical controls and (b) Documentation controls apply to cash disbursements?
-
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...
-
To what amount will the following investments accumulate? a. $6,000 invested for 12 years at 12 percent compounded annually b. $7,500 invested for 8 years at 8 percent compounded annually c. $6,400...
-
What is the present value of the following future amounts? a. $805 to be received 10 years from now discounted back to the present at 10 percent b. $376 to be received 5 years from now discounted...
-
At what annual rate would the following have to be invested? a. \($820\) to grow to \($1,988.12\) in 13 years b. \($320\) to grow to \($423.10\) in 6 years c. \($57\) to grow to \($290.30\) in 18...
Study smarter with the SolutionInn App