[prev] [index] [next]

Exercise: Josephus' Ring (cont)

  • For example, if you have a ring of 12 people:

         2  3
       1      4
    12          5
    11          6
      10      7
         9  8
    

    and you start counting at 1, people would be removed in the order:

    3 6 9 12 4 8 1 7 2 11 5
    

  • Implement Josephus' Scheme using a quack as a queue