Bubble Sort
Bubble Sort
bubble through to end of data
bubble through to end of data but one
bubble through to end of data but two
etc.
set stopping point at length of data minus one
while stopping point is bigger than one
bubble through to the stopping point
reduce stopping point by one
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
7 | 2 | 9 | 5 | 4 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
7 | 2 | 9 | 5 | 4 |
set stopping point at length of data minus one while stopping point is bigger than one bubble through to the stopping point reduce stopping point by one
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
7 | 2 | 9 | 5 | 4 |
set stopping point at length of data minus one while stopping point is bigger than one bubble through to the stopping point reduce stopping point by one
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
7 | 2 | 9 | 5 | 4 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 9 | 5 | 4 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 9 | 5 | 4 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 9 | 5 | 4 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 5 | 9 | 4 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 5 | 9 | 4 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 5 | 4 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 5 | 4 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 7 | 5 | 4 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 5 | 7 | 4 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 5 | 7 | 4 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 5 | 4 | 7 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 5 | 4 | 7 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 5 | 4 | 7 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 4 | 5 | 7 | 9 |
Bubble Sort
data[1] | data[2] | data[3] | data[4] | data[5] |
---|---|---|---|---|
2 | 4 | 5 | 7 | 9 |
Bubble Sort
stop | |
temp | |
counter | |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter |
Bubble Sort
stop | 5 |
temp | |
counter | |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 1 |
Bubble Sort
stop | 5 |
temp | |
counter | |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
GT
program counter | 2 |
Bubble Sort
stop | 5 |
temp | |
counter | |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
GT
program counter | 3 |
Bubble Sort
stop | 5 |
temp | |
counter | 1 |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 4 |
Bubble Sort
stop | 5 |
temp | |
counter | 1 |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 5 |
Bubble Sort
stop | 5 |
temp | |
counter | 1 |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 6 |
Bubble Sort
stop | 5 |
temp | |
counter | 1 |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
GT
program counter | 7 |
Bubble Sort
stop | 5 |
temp | |
counter | 1 |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
GT
program counter | 8 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 1 |
data[1] | 7 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 9 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 1 |
data[1] | 2 |
data[2] | 2 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 10 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 1 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 11 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 2 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 12 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 2 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 13 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 2 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 5 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 2 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 6 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 2 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 7 |
Bubble Sort
stop | 5 |
temp | 7 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 8 |
stop | 5 |
temp | 7 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
GT
program counter | 12 |
stop | 5 |
temp | 7 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 13 |
stop | 5 |
temp | 7 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 5 |
stop | 5 |
temp | 7 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 6 |
stop | 5 |
temp | 7 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
GT
program counter | 7 |
stop | 5 |
temp | 7 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
GT
program counter | 8 |
stop | 5 |
temp | 9 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 9 |
stop | 5 |
temp | 9 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 5 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 10 |
stop | 5 |
temp | 9 |
counter | 3 |
data[1] | 2 |
data[2] | 7 |
data[3] | 5 |
data[4] | 9 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 11 |
stop | 5 |
temp | 9 |
counter | 4 |
data[1] | 2 |
data[2] | 7 |
data[3] | 5 |
data[4] | 9 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 12 |
stop | 5 |
temp | 9 |
counter | 4 |
data[1] | 2 |
data[2] | 7 |
data[3] | 5 |
data[4] | 9 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 13 |
stop | 5 |
temp | 9 |
counter | 4 |
data[1] | 2 |
data[2] | 7 |
data[3] | 5 |
data[4] | 9 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 5 |
stop | 5 |
temp | 9 |
counter | 4 |
data[1] | 2 |
data[2] | 7 |
data[3] | 5 |
data[4] | 9 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
LT
program counter | 6 |
stop | 5 |
temp | 7 |
counter | 4 |
data[1] | 2 |
data[2] | 7 |
data[3] | 9 |
data[4] | 5 |
data[5] | 4 |
data[6] | 1 |
1 | set stop data.length |
2 | compare stop, 1 |
3 | LTE go to end |
4 | set counter 1 |
5 | compare counter, stop |
6 | GTE go to 14 |
7 | compare data[counter], data[counter+1] |
8 | LTE go to 12 |
9 | set temp, data[counter] |
10 | set data[counter], data[counter+1] |
11 | set data[counter+1], temp |
12 | increment counter |
13 | go to 5 |
14 | decrement stop |
15 | go to 2 |
16 | end |
program counter | 7 |
Bubble Sort
By Dan Ryan
Bubble Sort
- 208