• Implement the codes must use the LinkedList implementation • Add an additional empty node (“dummy...

60.1K

Verified Solution

Question

Programming

• Implement the codes must use the LinkedList implementation

• Add an additional empty node (“dummy node”) that connects theend of the list with the beginning, transforming the list to acircular list

Code in c++

The Josephus problem is named after thehistorian Flavius Josephus, who lived between the years 37 and 100CE. Josephus was a reluctant leader of the Jewish revolt againstthe Roman Empire. When it appeared that Josephus and his band wereto be captured, they resolved to kill themselves. Josephuspersuaded the group by saying, “Let us commit our mutual deaths todetermination by lot. He to whom the first lot falls, let him bekilled by him that hath the second lot, and thus fortune shall makeits progress through us all; nor shall any of us erish by his ownright hand, for it would be unfair if, when the rest are gone,somebody should repent and save himself” (Flavius Josephus, TheWars of the Jews, Book III, Chapter 8, Verse 7, tr. WilliamWhiston, 1737). Yet that is exactly what happened; Josephus wasleft for last, and he and the person he was to kill surrendered tothe Romans. Although Josephus does not describe how the lots wereassigned, the following approach is generally believed to be theway it was done. People form a circle and count around the circlesome predetermined number. When this number is reached, that personreceives a lot and leaves the circle. The count starts over withthe next person. Using the circular linked list developed inExercise 6, simulate this problem.

Your program should take twoparameters: n, the number of people that start, and

m, the number of counts. For example,try n = 20 and m = 12. Where does Josephus need to be in theoriginal list so that he is the last one chosen?

Answer & Explanation Solved by verified expert
4.1 Ratings (551 Votes)
includeusing namespace stdstruct Nodeint positionstruct Node nextNode newNodeint posNode temp new Nodetempnext    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students