{menu} {mirror}



Fundamental Algorithm Analysis

Head Permutations Using a Linear Array of 4 Numbers
EXAMPLE_01 Output where N = 4

Sequence

Output

Indexes Swapped

1

1 2 3 4

No Swap

2

2 1 3 4

swapped(0, 1)

3

3 1 2 4

swapped(0, 2)

4

1 3 2 4

swapped(0, 1)

5

2 3 1 4

swapped(0, 2)

6

3 2 1 4

swapped(0, 1)

7

3 2 4 1

swapped(2, 3)

8

2 3 4 1

swapped(0, 1)

9

4 3 2 1

swapped(0, 2)

10

3 4 2 1

swapped(0, 1)

11

2 4 3 1

swapped(0, 2)

12

4 2 3 1

swapped(0, 1)

13

4 1 3 2

swapped(1, 3)

14

1 4 3 2

swapped(0, 1)

15

3 4 1 2

swapped(0, 2)

16

4 3 1 2

swapped(0, 1)

17

1 3 4 2

swapped(0, 2)

18

3 1 4 2

swapped(0, 1)

19

2 1 4 3

swapped(0, 3)

20

1 2 4 3

swapped(0, 1)

21

4 2 1 3

swapped(0, 2)

22

2 4 1 3

swapped(0, 1)

23

1 4 2 3

swapped(0, 2)

24

4 1 2 3

swapped(0, 1)


Click here to return to EXAMPLE_01.