Question: C++ ONLY This problem is an exercise in the implementation of queue. We will look at the implementation of a circular array. Then we will

C++ ONLY

This problem is an exercise in the implementation of queue. We will look at the implementation of a circular array. Then we will use the implementation to solve a problem called the Josephus problem.

Josephus Flavius was a famous historian of the first century at the time of the Second Temple destruction. During the war he got trapped in a cave with a group of 39 soldiers surrounded by Romans. The legend has it that preferring suicide to capture, the people decided to form a circle and, proceeding clockwise around it, to kill every seventh(It will be given as an input) person until only one was left, who must then commit suicide. Josephus, an accomplished mathematician, quickly found the safe spot in the circle (24th) to be the last to go. But when the time came, instead of killing himself he joined the Roman side. The problem rightfully raises the question of how someone might be able to quickly compute the correct place to stand.

In this assignment you are to simulate the Josephus problem.

Input data (interactively input by keyboard):

How many soldiers? -> 10

Type 10 soldiers name:

Andy

Shawna

Jianjia

Adam

Jacob

Wesley

Zahari

Thomas

Chris

Ben

The program should simulate the Josephus problem by repeatedly removing the n-th name from the list and displaying it. At the end, display the name of the survivor. For the example above, your output should be:

Enter the position -> 3

Eliminating order:

1. Jianjia (3) 2. Wesley(6) 3. Chris(9) 4. Shawna(2) 5. Zahari(7) 6. Andy(1) 7. Thomas(8) 8. Jacob(5)

9. Ben(10)

The survivor is Adam(4).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!