Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Josephus problem is the following game: N people, numbered 1 to N, are sitti

ID: 3651982 • Letter: T

Question

The Josephus problem is the following game: N people, numbered 1 to N, are sitting in a circle. Starting at person 1, a hot potato is passed. After M passes, the person holding the hot potato is eliminated, the circle closes ranks, and the game continues with the person who was sitting after the eliminated person picking up the hot potato. The last remaining person wins. Thus, if M = 0 and N = 5, players are eliminated in order , and player 5 wins. If M = 1 and N = 5, the order of elimination is 2, 4, 1, 5.

c. If M = 1, what is the running time of your program? How is the actual speed affected by the delete routine for large values of N (N > 100,000)?

Note: This is C++.

Explanation / Answer

if (M=1) running time = O(N) so if N is large complexity will be large

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote