. Problem 1035--(Josephus (circle) 1: Introduction Description: problem Primary
ID: 3742578 • Letter: #
Question
. Problem 1035--(Josephus (circle) 1: Introduction Description: problem Primary level) Problem description and f any) background of the algorithms. n,1,m, ,m, n1, 2, , n, Josephus (circle) problem: Josephus problem is a math puzzle with a grim description: nprisoners are standing on a circle, sequentially numbered from 1 to n. An executioner walks along the circle, starting from prisoner 1, removing every m-th prisoner and killing him. As the process goes on, the circle becomes smaller and smaller, until only one prisoner remains, who is then freed (As a result, we can also get the killing , For example, if there are n = 5 prisoners and m = 2, the order the prisoners are killed in (let's call it the "killing sequence") will be 2, 4, 1, and 5, and the survivor will be E3. (Asa result, we can also get the killing sequence: 2 4 1 5 Given any two positive integers n, m0.find out the king seguence. Tips: use a circularly linked list. () More details: http:rosetacode.org/wikiJosephus problem httpslen.wikipedia.org/wikilJosephus problem) Input: Two Positive integers: n and m. The output sequence Sample Input 4 17 Sample Output 1342 2: Algorithm Specification Description (pseudo-code preferred) of all the algorithms involved for solving the problem, including specifications of main data structures 3: Testing Results Table of test cases. Each test case usally consists of a brief description of the purpose of this case, the expected result, the actual behavior of your program, the possible cause of a bug if your program does not function as expected, and the current statuspass"or 4: Analysis and Comments Analysis of the time and space complexities of the algorithms. Appendix: Source Code (in C/C++)Explanation / Answer
Loop over x from 1 to n to get the order of people killed.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.