The main parameters in modeling the game are the numberof original people in the
ID: 3612676 • Letter: T
Question
The main parameters in modeling the game are the numberof original people in the group, and the number of syllables usedin the phrase for removing people. In this assignment, we will letN denote the number of players in the game and K denote the numberof consectutive steps which are taken around the circle before theelimination of a player. Once a person has been removed from thegroup, they should never be counted again when countingsteps.
For consistency, you should refer to the originalplayers as if they are numbered from {0, ..., N-1}. Also, pleasestart the game so that the first step is at Player 0. As a simpleexample, if we play the game with N=5 and K=3, players would beremoved in the following order:
Player 2 is removed.
Player 0 is removed.
Player 4 is removed.
Player 1 is removed.
Player 3 has survived!
Please simulate the above example by hand. If you do notget exactly the same result as shown then you are misinterpretingthe conventions for this assignment.
Maintain an array of booleans which will be used to representwhether or not a particular person has been eliminated. Afterinitializing this array, you begin by removing people according tothe rules of the game. You will need to take care when counting Ksteps, as you are not to count any players who had been removed inan earlier round.
Part 2: LinkedGame
Use a circular singly-linked list to represent the circle ofplayers. You will still need to maintain a variable whichreferences some node of the list so that you will be able to findthe list!
In this implementation, rather than using a boolean to markplayers as removed, you must actually remove each associated nodefrom the linked list. In this way, when you later want to take Ksteps in the game, you will know that all of the players in thelinked list are still part of the game.
Note: You will need to create your own Node structurein the LinkedGame.h file (declare it outside of the LinkedGameclass).
Explanation / Answer
please rate - thanks I don't know anything about node structures, you'll have to changethat this is how I learned linked lists, when programming languages were"simpler" by the way this is called "the josephus problem" #include using namespace std; main() {int i,j=0,n,k,upto,camefrom; int men[25]; coutn; coutk; for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.