Extension of the Josephus Problem with Varying Elimination Steps

Similar documents
Akkad Bakad Bambai Bo

CSE 20 DISCRETE MATH WINTER

Symbolic Evaluation of Sums for Parallelising Compilers

Blocking Combinatorial Games

CS3901 Intermediate Programming and Data Structures Winter 2008 (Q2 AY 08) Assignment #5. Due: noon Tuesday, 3 March 2008

This chapter covers recursive definition, including finding closed forms.

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

UNM - PNM STATEWIDE MATHEMATICS CONTEST XLI. February 7, 2009 Second Round Three Hours

Primes in Classes of the Iterated Totient Function

Agenda. We ve done Growth of functions Asymptotic Notations (O, o,,!, ) Now Binary search as an example Recurrence relations, solving them

Recursively Defined Functions

COE428 Lecture Notes Week 1 (Week of January 9, 2017)

THE SEARCH FOR SYMMETRIC VENN DIAGRAMS

II (Sorting and) Order Statistics

CSE 230 Computer Science II (Data Structure) Introduction

Fast algorithm for generating ascending compositions

Semantics. There is no single widely acceptable notation or formalism for describing semantics Operational Semantics

Discrete Structures. Fall Homework3

1/15 2/19 3/23 4/28 5/12 6/23 Total/120 % Please do not write in the spaces above.

Test Bank Ver. 5.0: Data Abstraction and Problem Solving with C++: Walls and Mirrors, 5 th edition, Frank M. Carrano

Winning Positions in Simplicial Nim

Recursion defining an object (or function, algorithm, etc.) in terms of itself. Recursion can be used to define sequences

Enumerating Tilings of Rectangles by Squares with Recurrence Relations

Graceful Graphs and Graceful Labelings: Two Mathematical Programming Formulations and Some Other New Results

Handout 9: Imperative Programs and State

CONSECUTIVE INTEGERS AND THE COLLATZ CONJECTURE. Marcus Elia Department of Mathematics, SUNY Geneseo, Geneseo, NY

Introduction to Algorithms

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

The Running Time of Programs

SECTION 5.1. Sequences

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

CS220/MATH320 Applied Discrete Mathematics Instructor: Marc Pomplun Practice Exam. Sample Solutions

Discrete Mathematics Exam File Fall Exam #1

Nondeterministic Query Algorithms

Deficient Quartic Spline Interpolation

Sunoj B S *, Mathew Varkey T K Department of Mathematics, Government Polytechnic College, Attingal, Kerala, India

It is important that you show your work. There are 134 points available on this test.

12.1 Formulation of General Perfect Matching

Abstract Combinatorial Games

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

Grey Codes in Black and White

Exact Calculation of Beta Inequalities

ALGORITHMIC DECIDABILITY OF COMPUTER PROGRAM-FUNCTIONS LANGUAGE PROPERTIES. Nikolay Kosovskiy

CS 173 [A]: Discrete Structures, Fall 2012 Homework 8 Solutions

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS

Induction and Recursion. CMPS/MATH 2170: Discrete Mathematics

Midterm CSE 21 Spring 2012

COURSE: NUMERICAL ANALYSIS. LESSON: Methods for Solving Non-Linear Equations

Recursive Definitions Structural Induction Recursive Algorithms

Week - 03 Lecture - 18 Recursion. For the last lecture of this week, we will look at recursive functions. (Refer Slide Time: 00:05)

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

To illustrate what is intended the following are three write ups by students. Diagonalization

Chapter Summary. Recursively defined Functions. Recursively defined sets and Structures Structural Induction

Algorithm Analysis and Design

1.3. Conditional expressions To express case distinctions like

Keywords: Algorithm, Sieve, Prime Number Mathematics Subject Classification (MSC) 2010 : 11Y11, 11Y16, 65Y04, 65Y20, 68Q25

Prefix Computation and Sorting in Dual-Cube

Definition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.

Counting. Andreas Klappenecker

Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F].

A Generalization of the Nim and Wythoff games

CS6382 Theory of Computation. Spring Homework #3

A NOTE ON COST ESTIMATION BASED ON PRIME NUMBERS

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Finding a winning strategy in variations of Kayles

Counting. Rosen, Chapter 6 Walls and Mirrors, Chapter 3

Recursion: The Beginning

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

Complexity, Induction, and Recurrence Relations. CSE 373 Help Session 4/7/2016

Choice of C++ as Language

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

Effect of Regularization on Fuzzy Graph

Theory of control structures

Framework for Design of Dynamic Programming Algorithms

The transition: Each student passes half his store of candies to the right. students with an odd number of candies eat one.

Ramsey s Theorem on Graphs

6.006 Final Exam Name 2. Problem 1. True or False [30 points] (10 parts) For each of the following questions, circle either True, False or Unknown.

Lecture 1: Overview

DOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE

On the Complexity of the Policy Improvement Algorithm. for Markov Decision Processes

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

2.) From the set {A, B, C, D, E, F, G, H}, produce all of the four character combinations. Be sure that they are in lexicographic order.

Celebrity Identification and Recognition in Videos. An application of semi-supervised learning and multiclass classification

Council for Innovative Research Peer Review Research Publishing System Journal: INTERNATIONAL JOURNAL OF COMPUTERS & TECHNOLOGY

ON BINARY TOPOLOGICAL SPACES

Chapter 5. Algorithms Pearson Addison-Wesley. All rights reserved

.Math 0450 Honors intro to analysis Spring, 2009 Notes #4 corrected (as of Monday evening, 1/12) some changes on page 6, as in .

Midterm solutions. n f 3 (n) = 3

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

of Nebraska - Lincoln

arxiv: v1 [cs.ds] 3 Oct 2017

The Number of Convex Topologies on a Finite Totally Ordered Set

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8

COT 5407: Introduction to Algorithms. Giri Narasimhan. ECS 254A; Phone: x3748

Binary Search to find item in sorted array

The Four Color Theorem: A Possible New Approach

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

INVESTIGATING DATA MINING BY ARTIFICIAL NEURAL NETWORK: A CASE OF REAL ESTATE PROPERTY EVALUATION

Final Exam May 6, 2015

Transcription:

DU Journal of Undergraduate Research and Innovation Volume 1, Issue 3 pp 211-218, 2015 Extension of the Josephus Problem with Varying Elimination Steps Shivam Sharma, Raghavendra Tripathi, Shobha Bagai, Rajat Saini, Natasha Sharma shobhabagai@gmail.com, Cluster Innovation Center, University of Delhi, Rugby Sevens Building, University Stadium, G.C. Narang-Marg, New Delhi, India ABSTRACT This paper is an effort of expounding the recursive formula for the Josephus problem (which is the essence of the popular game Akkad Bakad Bambai Bo played in Indian households). The academic extension of this game has been to deal with the cases where elimination steps vary with each turn. Josephus problem is essentially heralded with objective of finding the position of the player who survives the game. Most of the available literature deals with the problem of finding the survival s position when sequential elimination of persons takes place in steps for circled people. There is a simple algorithm known to solve this problem; however the rigorous procedure can be replaced with a formula. The nature of this formula can be either recursive or non-recursive; both of which comprise this paper. We have extended the problem to the situation wherein the elimination step varies with iterations. The non-recursive methods include the binary method & paper [4] contains non-recursive formula for constant elimination step and the recursive formula has been derived using dynamic recursive methods. This dynamic recursive formula can be modified to withstand different extensions of Josephus problem; making it all-inclusive. This work shows the modifications made in the dynamic recursive formula to predict the survival s positions for varying elimination step. We have explained the dynamic recursive formula for steps changing as the count does ( ) and steps changing as multiples of a number ( ). A simulation game for various facets of the Josephus problem have also been programmed using the software MATLAB which provides options to select various step sequences and to view the actual elimination process in the output table. Keywords: Dynamic recursive method, Extended Josephus problem, Josephus Problem, Josephus Problem MATLAB Game and Akkad Bakad Bambai Bo, Recursive Formula. INTRODUCTION 211

The Josephus problem has been named after Flavius Josephus, who with other 40 members was blocked by Romans in a cave and they all decided to kill themselves by forming a circle and killing themselves in step of three over capture by the Romans. Josephus states that by luck or possibly by the hand of God, he and another man remained in the end and gave up to the Romans. So, effectively the problem is that a group of people arranged in a circular format are numbered from 1 to sequentially. We start eliminating every second person. For example, if, the people are removed in the order 2, 4, 6, 3, 1, and the last person to survive the game is intuitively the one standing at the position number 5. Let denote the last person remaining when we started with people. We consider our objective to find a simple way to compute for any positive integer when step changes as the count ( ) and steps change as multiples of a number ( ) where The literature by Miguel Lerma s proof of the Josephus problem gives the relationship between powers of two and binary numbers to calculate winning position in which a non recursive binary method has been depicted in order to calculate the survival position as mentioned in the methodology section. Using induction it has been proved that regardless of the number of participants, person 1 survives as long as the number of person are in powers of. As long as the number of people in the circle is even in each pass the first person remains untouched. Paper [4] proposes and proves non-recursive and recursive formulae for elimination step only. R. Graham and D. Knuth [1] have shown an iterative formula for calculating the next survival position. The dynamic recursive method as explained in the next section can be extended to withstand with variable elimination steps. This paper explains the extension of the dynamic recursive method to calculate the survival position with elimination steps changing as sum sequence and multiple of a number. METHODOLOGY Explanation for recursive formula for step represents the eliminating step represents total number of people represents the survival position when i is the total number of people Recursive formula for constant step and people: The position of the survival in when every second person out of n people standing in a circle is eliminated until only one survives is given by the recurrence relation ;. Explanation: Let i be the position of any survivor s position after first elimination. Clearly, the corresponding position in the circle having elements is. Hence,. 212

survival position in people is i I Survival s position in is 1 1 1 2 1 2 1 2 1 4 1 3 1 2 3 3 6 5 4 1 2 3 4 1 8 1 5 1 2 3 4 5 3 10 5 6 1 2 3 4 5 6 5 12 9 7 1 2 3 4 5 6 7 7 14 13 Table-I: Table showing the survival s position in The position of the survival in when every second person out of n persons standing in a circle is eliminated until only one survives is given by the recurrence relation Explanation: Let i be the position of any survivor element after first elimination. Clearly, the corresponding position in the first circle having elements is. Hence, T (2n + 1) = 2T(n) + 1. survival position in Survival s position is 1 1 1 3 3 2 1 2 1 5 3 3 1 2 3 3 7 7 4 1 2 3 4 1 9 3 5 1 2 3 4 5 3 11 7 6 1 2 3 4 5 6 5 13 11 7 1 2 3 4 5 6 7 7 15 15 Table-II: Table showing the survival s position for Non-Recursive binary method for step : Another way of finding the survivor s position T(n) for n persons with constant step is binary method [6]: Therefore, = left rotation of the binary digits of n Suppose for n (base 10) = (base 2)where is the binary values of n with x 1 = 1. Then, T(n) = For example, for with (6) 10 = (110) 2 since in binary expansion of (6) 10 is 1 So, the survival s position is T(6) = (101) 2 = (5) 10 Similar kinds of recursive formulas exits for step 213

Dynamic recursive formulae: So, another way of computing the survivor s position is by using the dynamic recursive method [5] [7] which have running time complexity. Before using the formula let us fix some notations mentioned in [5] for the recursive formula. Number the positions in the circle by and start counting at number. Then every k th element is removed. It is then defined as to be the number of the i th element which is removed by the process described above (see example in Figure-I). Figure-I. Here the denotes the person eliminated at step. In [5] the recursive formula for the has been explained and it states that for Josephus problem the following recursion holds: With initial value or It is proved in [5] Suppose, we know the value of. Hence, if we start counting at number 1, the i th member removed is number g. Now consider Because of in the first step number is removed and for the second step we start counting at number k+1. Therefore the problem is to find the i th member which is removed (after removing when we start counting at number. But this is. So, we get the recursive formula. If we know that ( ), then we start counting at 1 then the member removed is. Now we need to find the number removed in the next step when we start counting from k+1 number i.e. we need to find So, the 214

For example, the survival position for with constant step is calculated and the output calculated recursively is shown in the Table-III. No of People left Elements Remained in the sequence Survival s Position with initial 11 1 2 3 4 5 6 7 8 9 10 11 f(11,3) = (f(10,3) + 2)%11+1= 7 10 1 2 3 4 5 6 7 8 9 10 f(10,3)=(f(9,3)+2)%10 +1= 4 9 1 2 3 4 5 6 7 8 9 f(9,3)=(f(8,3)+2)%9 +1=1 8 1 2 3 4 5 6 7 8 f(8,3)=(f(7,3)+2)%8 +1=7 7 1 2 3 4 5 6 7 f(7,3)=(f(6,3)+2)%7 +1= 4 6 1 2 3 4 5 6 f(6,3)=(f(5,3)+2)%6 +1 = 1 5 1 2 3 4 5 f(5,3)=(f(4,3)+2)%5 +1 = 4 4 1 2 3 4 f(4,3)=(f(3,3)+2)%4 +1 = 1 3 1 2 3 f(3,3)=(f(2,3)+2)%3 +1 = 2 2 1 2 f(2,3)=(f(1,3)+2)%2 +1 = 2 1 1 f(1,3) = 1 Table-III: Table showing the survival s position for constant elimination step using the dynamic programming method Mathematical Analysis RESULTS Extended Josephus Problem: Extended Josephus problem is to determine the survivor s position with variable elimination steps i.e., we assume that, unlike the original Josephus problem where second person was being eliminated each time, at every count being-eliminated number is different. For instance we eliminate second person in 1 st iteration, then 2 nd in second iteration and so on. Survivor s position can easily be calculated with slight modification in the dynamic recursive method. Steps changing as counting: For n people with steps changing as a counting sequence For instance k takes the sequences after elimination of person at each step with initial step So, the dynamic recursive formula becomes For example, the survival s position for people with initial step is calculated using the dynamic programming method and the output calculated iteratively is shown in the Table-IV. 215

No of People left (n) Element Remained Survival s Position f(n,k)=(f(n-1,k+1,i+1)+k-1)%n +1 f(1,k) = 1 with initial k=3, i=1 11 1 2 3 4 5 6 7 8 9 10 11 f(11,3,1) = (f(10,4,2) + 2)%11 +1=10 10 1 2 3 4 5 6 7 8 9 10 f(10,4,2)=(f(10,4,2) + 2)%11 +1=7 9 1 2 3 4 5 6 7 8 9 f(9,5,3)=(f(10,4,2) + 2)%11 +1=3 8 1 2 3 4 5 6 7 8 f(8,6,4)=(f(10,4,2) + 2)%11 +1=7 7 1 2 3 4 5 6 7 f(7,7,5)=(f(10,4,2) + 2)%11 +1=1 6 1 2 3 4 5 6 f(6,8,6)=(f(10,4,2) + 2)%11 +1=1 5 1 2 3 4 5 f(5,9,7)=(f(10,4,2) + 2)%11 +1=5 4 1 2 3 4 f(4,10,8)=(f(10,4,2) + 2)%11 +1=1 3 1 2 3 f(3,11,9)=(f(10,4,2) + 2)%11 +1=3 2 1 2 f(2,12,10)=(f(10,4,2) + 2)%11 +1=1 1 1 1 Table-IV: Table showing the survival s position with steps as sequence and initial elimination step using the dynamic programming method Steps changing as multiples: For instance takes the values with initial step as With initial step, it takes the values So, the dynamic recursive formula becomes For example, the survival s position for people with initial step is calculated using the dynamic recursive method and the output calculated iteratively is shown in the Table-V. No of People left Element Remained Survival s Position with initial 11 1 2 3 4 5 6 7 8 9 10 11 f(11,3,1) = (f(10,3,2) + 2)%11+1= 6 10 1 2 3 4 5 6 7 8 9 10 f(10,3,2)=(f(9,3,3)+ 5)%10 +1= 3 9 1 2 3 4 5 6 7 8 9 f(9,3,3)=(f(8,3,4)+ 8)%9 +1= 7 8 1 2 3 4 5 6 7 8 f(8,3,4)=(f(7,3,5)+ 11)%8 +1= 7 7 1 2 3 4 5 6 7 f(7,3,5)=(f(6,3,6)+ 14)%7 +1= 3 6 1 2 3 4 5 6 f(6,3,6)=(f(5,3,7)+ 17)%6 +1 = 2 5 1 2 3 4 5 f(5,3,7)=(f(4,3,8)+ 20)%5 +1 = 2 4 1 2 3 4 f(4,3,8)=(f(3,3,9)+ 23)%4 +1 = 1 3 1 2 3 f(3,3,9)=(f(2,3,10)+ 26)%3 +1 = 1 2 1 2 f(2,3,10)=(f(1,3,11)+ 29)%2 +1 = 1 1 1 1 Table-V: Table showing the survival s position with multiples of the initial k = 3 elimination step using the dynamic programming method Implementation of the Algorithm A game based on the Josephus Algorithm has been built to predict the survival s position and a GUI to depict the Josephus game simulation 216

Figure-II.GUI layout of the game The game has two options - either a person can play the simulation or he can predict the survival position and the graphical user interface would give him the correct answer referring to the different options of eliminating steps. Playing the simulation for the Josephus Problem: Figure-III. The simulation layout The outputs after elimination; the positions of elimination have been marked with red circles and the green circle shows the survivor in the Figure-IV. 217

Figure-IV. Figure after elimination of all persons and with only one survived person and with the output table on the right side depicting the person eliminated at each step CONCLUSIONS We have successfully implemented the Josephus s problem mathematically in MATLAB by first keeping constant and then taking recursive values of to make the game more interesting. Various methods and formulae for extended Josephus problem have been explained. The implementation is based on the recursive formula so going beyond a certain number of recursion requires permission in MATLAB for. ACKNOWLEDGEMENT We would like to acknowledge Cluster Innovation Center (CIC), DU for providing computational resources and an active environment for carrying out such work. REFERENCES 1. R. Graham, D. Knuth, O. Patashnik Concrete Mathematics, 2nd edition, Addison-Wesley, 1994 2. RobinsonW.J The Josephus Problem Mathematical Gazette 44(1960), 47-52 3. Woodhouse, D. The Extended Josephus Problem, Rev. Mat. Hisp. Amer (4)33 (1973), 207-218 4. Armin Shams-Baragh Formulating the Extended Josephus Problem (December 2002) 5. Lorez Halbeisen, ETH Zurich Norbert Hunger Buhler, University of Freiburg The Josephus Problem (1997) 6. Miguel A. Lerma Josephus Problem (2003) 7. Wikipedia Josephus Problem, Link http://en.wikipedia.org/wiki/josephus_problem 218