Computers and Technology

Problem Statement Josephus attended a party where they had a rather strange raffle. Everyone was to stand in a circle, and every Mth person was to be eliminated until only one person was remaining, who won the lawnmower.
Write the function Josephus, which takes as parameters a vector representing the N guests at the party in the order they line up for the raffle, and the integer M, giving which person will be eliminated at each turn. Your function should return a string giving the name of the winner of the raffle (the last person standing).
Hint: While there is a mathematical solution, a queue will be much more straightforward.
Constraints
N, the length of the vector guests, will be greater than 0 and less than 2,000.
M will be greater than zero and less than 2,000.
Examples
guests = {"Josephus", "Titus", "Simon", "Eleazar"}
M = 3
Returns: "Josephus"
Counting every third person from Josephus (remember, they are in a circle), Simon is eliminated first. Skipping Eleazar and Josephus, Titus goes next. Skipping Eleazar and Josephus, we come back to Eleazar. Josephus, who cleverly suggested M = 3, comes out the winner!
guests = {"Bradford", "Rosette", "Ji", "Ashleigh", "Avery", "Lavonna", "Fredericka"}
M = 2
Returns: "Fredericka"
guests = {"Tiffany", "Randy", "Kit", "Sharlene", "Marquerite", "Debra", "Pok", "Tanisha", "Claudio"}
M = 17
Result: "Debra"
Given Function
string Josephus(vector guests, int M) {
// your code here
}
Use the given function to solve the problem statement. Please follow the given notes and constraints. Please code this problem in C++.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:00, yyy77uh
You will be given two character arrays of the same size, one will contain a number of ships. ships will move around the character array based on which way they are facing and the route they are on. routes are given in the other array. the route consists of '-' and '|' for straight paths, '\' and '/' for curves, and '+' for intersections. there are ships on these routes. ships always face a direction, '^' for up, '> ' for right, 'v' for down, and '< ' for left. any time the ships hit a '\' or a '/' it will turn as you would expect a ship to turn (e. g. a '^' that moves into a '/' will turn right). at an intersection, ships will always continue straight through. all ships move at the same speed, ships take turns moving and all ships move during one 'tick'. the one in the most top left goes first, followed by those to its right, then the ones in the next row. it iterates along the rows and then down the columns. each ship moves one space on its turn moving along the route. your function needs to return the position of the first collision between two ships and the number of ticks before the crash occurred.
Answers: 2
image
Computers and Technology, 22.06.2019 16:20, Aleja9
It policy compliance and emerging technologies respond to the following: propose at least three control measures that organizations need to put in place to ensure that they remain complaint with emerging technologies and in a continually changing it environment. examine the correlation of effective configuration management and change control procedures to remain compliant with emerging technologies and it security changes.
Answers: 2
image
Computers and Technology, 22.06.2019 20:00, BreadOfTheBear
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, GEEKLIFE6598
After you present a proposal, the committee starts asking you questions, some beyond the strict focus of your proposal. they ask questions about implications in other fields and knowledge about other fields. you are asked to redo your proposal. what is most likely missing? breadth of material depth of material clarity of material details of material
Answers: 1
Do you know the correct answer?
Problem Statement Josephus attended a party where they had a rather strange raffle. Everyone was to...

Questions in other subjects:

Konu
Mathematics, 30.04.2021 04:30
Konu
Mathematics, 30.04.2021 04:30
Konu
Mathematics, 30.04.2021 04:30