subject

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++.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
Aconstruction company is creating a powerpoint presentation describing how they calculate costs during each construction step. they plan to email this presentation to clients. the individual clients will be watching the presentation slide show on their own personal computers. what is the most important formatting step the company should take to make the text readable and pleasing to the eye?
Answers: 2
question
Computers and Technology, 24.06.2019 11:20
Colby works as a shipping clerk for a major package delivery service. some of his daily tasks include tracking shipments and entering orders. which aspect of the information technology cluster would he most likely be trained in? a.networkingb.databasesc.hardwared.software
Answers: 2
question
Computers and Technology, 24.06.2019 11:40
100 pts. first person gets brainliest
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Append and make table queries are called queries. select complex simple action i think action
Answers: 1
You know the right answer?
Josephus attended a party where they had a rather strange raffle. Everyone was to stand in a circle,...
Questions
question
Physics, 28.01.2021 23:50
question
Mathematics, 28.01.2021 23:50
question
Computers and Technology, 28.01.2021 23:50
question
Business, 28.01.2021 23:50
Questions on the website: 13722360