In shuffle
Encyclopedia
An in shuffle is a type of perfect shuffle
Shuffle
Shuffling is a procedure used to randomize a deck of playing cards to provide an element of chance in card games. Shuffling is often followed by a cut, to help ensure that the shuffler has not manipulated the outcome.-Shuffling techniques:...

 done in two steps:
  1. Split the cards exactly in half (a bottom half and a top half) and then
  2. Interweave each half of the deck such that every-other card came from the same half of the deck.


If this shuffle moves the top card to be 2nd from the top then it is an in shuffle, otherwise it is known as an out shuffle
Out shuffle
An out shuffle is a type of perfect shuffle done in two steps:#Split the cards exactly in half and then#Interweave each half of the deck such that every-other card came from the same half of the deck....

.

Example

For simplicity, we will use a deck of six cards.

The following shows the order of the deck after each in shuffle. Notice that a deck of this size returns to its original order after 3 in shuffles.
{| class="wikitable" style="text-align:center"

! Step
! Top
Card
! 2
! 3
! 4
! 5
! Bottom
Card
|-
| Start
|
|
|
|
|
|
|-
| 1
|
|
|
|
|
|
|-
| 2
|
|
|
|
|
|
|-
| 3
|
|
|
|
|
|
|}

Mathematics

The number of in shuffles required to return a deck of cards of even size N, to original order is given by the multiplicative order
Multiplicative order
In number theory, given an integer a and a positive integer n with gcd = 1, the multiplicative order of a modulo n is the smallest positive integer k withThe order of a modulo n is usually written ordn, or On.- Example :To determine the multiplicative order of 4 modulo 7, we compute 42 = 16 ≡ 2 ...

 of 2 modulo
Modular arithmetic
In mathematics, modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" after they reach a certain value—the modulus....

 (N + 1).

For example, for a deck size of N = 2, 4, 6, 8, 10, 12 ..., the number of in shuffles needed are: 2, 4, 3, 6, 10, 12, 4, 8, 18, 6, 11, ... .

For a standard deck of 52 playing card
Playing card
A playing card is a piece of specially prepared heavy paper, thin cardboard, plastic-coated paper, cotton-paper blend, or thin plastic, marked with distinguishing motifs and used as one of a set for playing card games...

s, the number of in shuffles required to return the deck to its original order is 52.

Computer Science

In computer science the problem is stated as an in shuffle of sequences A {a .. an} and B {b1 .. bn} such that the resulting in shuffled sequence
In-Shuffle(A,B) → { bi, ai } | i: 1→n


A linear time O(n) algorithm that performs this in constant space O(1) complexity is presented.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK