subject

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

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:00
In he example code, what does the title attribute create? a tool tip an element a source a markup
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Plz ( which is an example of a good url?
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
You may see the term faq on websites which stands for frequently asked questions this is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation ken has dipped many dark chocolate marshmallows (which you remember the metric system distance units in decreasing order: kilometers, hectometer, decameter, centimeter, millimeter) is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation !
Answers: 1
You know the right answer?
Problem Statement Josephus attended a party where they had a rather strange raffle. Everyone was to...
Questions
question
Mathematics, 31.03.2021 22:10
question
English, 31.03.2021 22:10
question
Biology, 31.03.2021 22:10
question
Mathematics, 31.03.2021 22:10
question
Advanced Placement (AP), 31.03.2021 22:10
question
Social Studies, 31.03.2021 22:10
Questions on the website: 13722363