Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data Structure C++ language People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds

Data Structure C++ language

People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a clockwise 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 certain number of people remains. The number of survivors depends on the number of people skipped. For example, if every 3rd person is executed then the executions stop when only 2 people remain.

The problem given the number of people, starting point and number to be skipped is to choose the position in the initial circle to avoid execution.

Use a queue to solve the Josephus problem and the general count out problem.

Write a function that solves the general count out problem where the length of the list and the count out interval are parameters. The function returns the survivor list as a vector.

The function prototype is

vector countOut(unsigned begin_size = 41, unsigned count_out = 3);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+and non-compete agreements in three to five different countries.

Answered: 1 week ago