![]() Hints: Note how similar moving through a circle is to moving someone from the front of a line to its end. Use the QueueArray implementation of the Queue interface to accomplish this task. Write a class Josephus that prompts the user for a number of people in a circle, and a value $n$, where every $n^$ person will be killed, and then finds (using a queue) and displays the positions of those people killed, in the order they died, in a manner similar to the one shown in the sample run below. The precise mechanism for choosing the order of the executions was not completely described in Josephus' account, however in 1612 Claude Gaspar Bachet (the writer of books on mathematical puzzles and tricks that formed the basis for almost all later books on mathematical recreations) suggested that the men arranged themselves in a circle, and then started counting by threes from a randomly selected man. Josephus states that by luck or possibly the hand of God, he and another man remained until the end and surrendered to the Romans rather than killing themselves. ![]() Choosing suicide over capture, they settled on a serial method of committing suicide where each person to die would be killed by the next person to die. A Jewish historian living in the 1st century named Flavius Josephus gave an account of the siege of Yodfat, where he and his 40 soldiers were trapped in a cave by Roman soldiers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |