Fundamental (PHP) Algorithm Analysis
Head Permutations Using a Linear Array of 5 Numbers
EXAMPLE_01 Output where N = 5
Sequence |
Output |
Indexes Swapped |
1 |
1 2 3 4 5 |
No Swap |
2 |
2 1 3 4 5 |
swapped(0, 1) |
3 |
3 1 2 4 5 |
swapped(0, 2) |
4 |
1 3 2 4 5 |
swapped(0, 1) |
5 |
2 3 1 4 5 |
swapped(0, 2) |
6 |
3 2 1 4 5 |
swapped(0, 1) |
7 |
3 2 4 1 5 |
swapped(2, 3) |
8 |
2 3 4 1 5 |
swapped(0, 1) |
9 |
4 3 2 1 5 |
swapped(0, 2) |
10 |
3 4 2 1 5 |
swapped(0, 1) |
11 |
2 4 3 1 5 |
swapped(0, 2) |
12 |
4 2 3 1 5 |
swapped(0, 1) |
13 |
4 1 3 2 5 |
swapped(1, 3) |
14 |
1 4 3 2 5 |
swapped(0, 1) |
15 |
3 4 1 2 5 |
swapped(0, 2) |
16 |
4 3 1 2 5 |
swapped(0, 1) |
17 |
1 3 4 2 5 |
swapped(0, 2) |
18 |
3 1 4 2 5 |
swapped(0, 1) |
19 |
2 1 4 3 5 |
swapped(0, 3) |
20 |
1 2 4 3 5 |
swapped(0, 1) |
21 |
4 2 1 3 5 |
swapped(0, 2) |
22 |
2 4 1 3 5 |
swapped(0, 1) |
23 |
1 4 2 3 5 |
swapped(0, 2) |
24 |
4 1 2 3 5 |
swapped(0, 1) |
25 |
5 1 2 3 4 |
swapped(0, 4) |
26 |
1 5 2 3 4 |
swapped(0, 1) |
27 |
2 5 1 3 4 |
swapped(0, 2) |
28 |
5 2 1 3 4 |
swapped(0, 1) |
29 |
1 2 5 3 4 |
swapped(0, 2) |
30 |
2 1 5 3 4 |
swapped(0, 1) |
31 |
2 1 3 5 4 |
swapped(2, 3) |
32 |
1 2 3 5 4 |
swapped(0, 1) |
33 |
3 2 1 5 4 |
swapped(0, 2) |
34 |
2 3 1 5 4 |
swapped(0, 1) |
35 |
1 3 2 5 4 |
swapped(0, 2) |
36 |
3 1 2 5 4 |
swapped(0, 1) |
37 |
3 5 2 1 4 |
swapped(1, 3) |
38 |
5 3 2 1 4 |
swapped(0, 1) |
39 |
2 3 5 1 4 |
swapped(0, 2) |
40 |
3 2 5 1 4 |
swapped(0, 1) |
41 |
5 2 3 1 4 |
swapped(0, 2) |
42 |
2 5 3 1 4 |
swapped(0, 1) |
43 |
1 5 3 2 4 |
swapped(0, 3) |
44 |
5 1 3 2 4 |
swapped(0, 1) |
45 |
3 1 5 2 4 |
swapped(0, 2) |
46 |
1 3 5 2 4 |
swapped(0, 1) |
47 |
5 3 1 2 4 |
swapped(0, 2) |
48 |
3 5 1 2 4 |
swapped(0, 1) |
49 |
4 5 1 2 3 |
swapped(0, 4) |
50 |
5 4 1 2 3 |
swapped(0, 1) |
51 |
1 4 5 2 3 |
swapped(0, 2) |
52 |
4 1 5 2 3 |
swapped(0, 1) |
53 |
5 1 4 2 3 |
swapped(0, 2) |
54 |
1 5 4 2 3 |
swapped(0, 1) |
55 |
1 5 2 4 3 |
swapped(2, 3) |
56 |
5 1 2 4 3 |
swapped(0, 1) |
57 |
2 1 5 4 3 |
swapped(0, 2) |
58 |
1 2 5 4 3 |
swapped(0, 1) |
59 |
5 2 1 4 3 |
swapped(0, 2) |
60 |
2 5 1 4 3 |
swapped(0, 1) |
61 |
2 4 1 5 3 |
swapped(1, 3) |
62 |
4 2 1 5 3 |
swapped(0, 1) |
63 |
1 2 4 5 3 |
swapped(0, 2) |
64 |
2 1 4 5 3 |
swapped(0, 1) |
65 |
4 1 2 5 3 |
swapped(0, 2) |
66 |
1 4 2 5 3 |
swapped(0, 1) |
67 |
5 4 2 1 3 |
swapped(0, 3) |
68 |
4 5 2 1 3 |
swapped(0, 1) |
69 |
2 5 4 1 3 |
swapped(0, 2) |
70 |
5 2 4 1 3 |
swapped(0, 1) |
71 |
4 2 5 1 3 |
swapped(0, 2) |
72 |
2 4 5 1 3 |
swapped(0, 1) |
73 |
3 4 5 1 2 |
swapped(0, 4) |
74 |
4 3 5 1 2 |
swapped(0, 1) |
75 |
5 3 4 1 2 |
swapped(0, 2) |
76 |
3 5 4 1 2 |
swapped(0, 1) |
77 |
4 5 3 1 2 |
swapped(0, 2) |
78 |
5 4 3 1 2 |
swapped(0, 1) |
79 |
5 4 1 3 2 |
swapped(2, 3) |
80 |
4 5 1 3 2 |
swapped(0, 1) |
81 |
1 5 4 3 2 |
swapped(0, 2) |
82 |
5 1 4 3 2 |
swapped(0, 1) |
83 |
4 1 5 3 2 |
swapped(0, 2) |
84 |
1 4 5 3 2 |
swapped(0, 1) |
85 |
1 3 5 4 2 |
swapped(1, 3) |
86 |
3 1 5 4 2 |
swapped(0, 1) |
87 |
5 1 3 4 2 |
swapped(0, 2) |
88 |
1 5 3 4 2 |
swapped(0, 1) |
89 |
3 5 1 4 2 |
swapped(0, 2) |
90 |
5 3 1 4 2 |
swapped(0, 1) |
91 |
4 3 1 5 2 |
swapped(0, 3) |
92 |
3 4 1 5 2 |
swapped(0, 1) |
93 |
1 4 3 5 2 |
swapped(0, 2) |
94 |
4 1 3 5 2 |
swapped(0, 1) |
95 |
3 1 4 5 2 |
swapped(0, 2) |
96 |
1 3 4 5 2 |
swapped(0, 1) |
97 |
2 3 4 5 1 |
swapped(0, 4) |
98 |
3 2 4 5 1 |
swapped(0, 1) |
99 |
4 2 3 5 1 |
swapped(0, 2) |
100 |
2 4 3 5 1 |
swapped(0, 1) |
101 |
3 4 2 5 1 |
swapped(0, 2) |
102 |
4 3 2 5 1 |
swapped(0, 1) |
103 |
4 3 5 2 1 |
swapped(2, 3) |
104 |
3 4 5 2 1 |
swapped(0, 1) |
105 |
5 4 3 2 1 |
swapped(0, 2) |
106 |
4 5 3 2 1 |
swapped(0, 1) |
107 |
3 5 4 2 1 |
swapped(0, 2) |
108 |
5 3 4 2 1 |
swapped(0, 1) |
109 |
5 2 4 3 1 |
swapped(1, 3) |
110 |
2 5 4 3 1 |
swapped(0, 1) |
111 |
4 5 2 3 1 |
swapped(0, 2) |
112 |
5 4 2 3 1 |
swapped(0, 1) |
113 |
2 4 5 3 1 |
swapped(0, 2) |
114 |
4 2 5 3 1 |
swapped(0, 1) |
115 |
3 2 5 4 1 |
swapped(0, 3) |
116 |
2 3 5 4 1 |
swapped(0, 1) |
117 |
5 3 2 4 1 |
swapped(0, 2) |
118 |
3 5 2 4 1 |
swapped(0, 1) |
119 |
2 5 3 4 1 |
swapped(0, 2) |
120 |
5 2 3 4 1 |
swapped(0, 1) |
Click here to return to EXAMPLE_01.
{top}