The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
University
| Teaching Since: | Apr 2017 |
| Last Sign in: | 438 Weeks Ago, 1 Day Ago |
| Questions Answered: | 9562 |
| Tutorials Posted: | 9559 |
bachelor in business administration
Polytechnic State University Sanluis
Jan-2006 - Nov-2010
CPA
Polytechnic State University
Jan-2012 - Nov-2016
Professor
Harvard Square Academy (HS2)
Mar-2012 - Present
The beautiful princess Eve had many suitors. She decided on the following procedure to determine which suitor she would marry. First, all of the suitors would be lined up on after the other and assigned numbers. The first suitor would be number 1, the second number 2, and so on up to the last suitor, number n. starting at the first suitor she would then count three suitors down the line (because of the three letters in her name) and the third suitor would be eliminated from winning her hand and removed from the line. Eve would then continue, counting three more suitors, and eliminating every third suitor. When she reached the end of the line she would continue counting from the beginning.
For example, if there were six suitors then the elimination process would proceed as follows:
123456Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â initial list of suitors, start counting from 1
12456Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â suitor 3 eliminated, continue counting from 4
1245Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â suitor 6 eliminated, continue counting 1
125Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â suitor 4 eliminated, continue from 5
15Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â suitor 2 eliminated, continue from 5
1Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â suitor 5 eliminated, 1 is the lucky winner.
Write a program in C++ that creates a circular linked list of nodes to determine which position you should stand in to marry the princess if there are n suitors. Your program should simulate the elimination process by deleting the node that corresponds to the suitor that is eliminated for each step in the process.
-----------