The Josephus Problem
People are standing in a circle (Links to an external site.)Links to an external site. waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of people are skipped, the next person is executed. The procedure is repeated with the remaining people, starting with the next person, going in the same direction and skipping the same number of people, until only a specified number of persons remain, and are freed. The problem — given the number of people, starting point, direction, and number to be skipped — is to choose the positions in the initial circle to avoid execution. In the original Josephus problem 41 men stand in a circle and decide to kill every 3rd person until 2 men remain who then kill themselves. Write a function that declares a local queue to solve the original Josephus problem as a special case. The function's prototype is vector solveJosephus( int ncandidates, int nsurvivors);
The function returns the positions in the original circle of the survivors. The function returns an empty vector if any of its parameters is bad. What are the characteristics of a bad parameter?
Data Structure C++. Visual Studios 2017