Table of Contents
Fetching ...

A New 0(klog n) Algorithm for Josephus Problem

Hikaru Manabe, Ryohei Miyadera, Yuji Sasaki, Shoei Takahashi, Yuki Tokuni

TL;DR

A new O(k log n) algorithm of the Josephus problem is presented, based on a relation between the Josephus problem and a maximum Nim of combinatorial game theory, which is better than the existing O(k log n) algorithm.

Abstract

We present a new O(k log n) algorithm of the Josephus problem. The time complexity of our algorithm is O(k log n), and this time complexity is on a par with the existing O(k log n) algorithm. We do not have any recursion overhead or stack overflow because we do not use any recursion. Therefore, the space complexity of our algorithm is O(1), and ours is better than the existing O(k log n) algorithm in this respect. When k is small and n is large, our algorithm is better than the existing O(k log n) algorithm. This new algorithm is based on a relation between the Josephus problem and a maximum Nim of combinatorial game theory.

A New 0(klog n) Algorithm for Josephus Problem

TL;DR

A new O(k log n) algorithm of the Josephus problem is presented, based on a relation between the Josephus problem and a maximum Nim of combinatorial game theory, which is better than the existing O(k log n) algorithm.

Abstract

We present a new O(k log n) algorithm of the Josephus problem. The time complexity of our algorithm is O(k log n), and this time complexity is on a par with the existing O(k log n) algorithm. We do not have any recursion overhead or stack overflow because we do not use any recursion. Therefore, the space complexity of our algorithm is O(1), and ours is better than the existing O(k log n) algorithm in this respect. When k is small and n is large, our algorithm is better than the existing O(k log n) algorithm. This new algorithm is based on a relation between the Josephus problem and a maximum Nim of combinatorial game theory.

Paper Structure

This paper contains 7 sections, 5 theorems, 15 equations, 2 figures.

Key Result

Theorem 1

For any position $(x)$, $\mathcal{G}(x)=0$ if and only if $(x)$ is the $\mathcal{P}$-position.

Figures (2)

  • Figure 1: $k=200$
  • Figure 2: $n=300$

Theorems & Definitions (11)

  • Definition 1
  • Definition 2
  • Definition 3
  • Theorem 1
  • Definition 4
  • Theorem 2
  • Definition 5
  • Lemma 1
  • Proposition 1
  • Theorem 3
  • ...and 1 more