Cody

# Problem 1401. Implement a bubble sort technique and output the number of swaps required

Solution 1719507

Submitted on 2 Feb 2019 by Nikolaos Nikolaou
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = [5 1 4 2 8]; y_correct = 4; assert(isequal(bubblesort(x),y_correct))

t = 1 5 t1 = 5 1 x = 1 1 4 2 8 x = 1 5 4 2 8 t = 4 5 t1 = 5 4 x = 1 4 4 2 8 x = 1 4 5 2 8 t = 2 5 t1 = 5 2 x = 1 4 2 2 8 x = 1 4 2 5 8 t = 5 8 t1 = 5 8 x = 1 4 2 5 8 x = 1 4 2 5 8 t = 1 4 t1 = 1 4 x = 1 4 2 5 8 x = 1 4 2 5 8 t = 2 4 t1 = 4 2 x = 1 2 2 5 8 x = 1 2 4 5 8 t = 4 5 t1 = 4 5 x = 1 2 4 5 8 x = 1 2 4 5 8 t = 5 8 t1 = 5 8 x = 1 2 4 5 8 x = 1 2 4 5 8 c = 4

2   Pass
x = [7 9 17 4 19 3 17 13 20 18]; y_correct = 14; assert(isequal(bubblesort(x),y_correct))

t = 7 9 t1 = 7 9 x = 7 9 17 4 19 3 17 13 20 18 x = 7 9 17 4 19 3 17 13 20 18 t = 9 17 t1 = 9 17 x = 7 9 17 4 19 3 17 13 20 18 x = 7 9 17 4 19 3 17 13 20 18 t = 4 17 t1 = 17 4 x = 7 9 4 4 19 3 17 13 20 18 x = 7 9 4 17 19 3 17 13 20 18 t = 17 19 t1 = 17 19 x = 7 9 4 17 19 3 17 13 20 18 x = 7 9 4 17 19 3 17 13 20 18 t = 3 19 t1 = 19 3 x = 7 9 4 17 3 3 17 13 20 18 x = 7 9 4 17 3 19 17 13 20 18 t = 17 19 t1 = 19 17 x = 7 9 4 17 3 17 17 13 20 18 x = 7 9 4 17 3 17 19 13 20 18 t = 13 19 t1 = 19 13 x = 7 9 4 17 3 17 13 13 20 18 x = 7 9 4 17 3 17 13 19 20 18 t = 19 20 t1 = 19 20 x = 7 9 4 17 3 17 13 19 20 18 x = 7 9 4 17 3 17 13 19 20 18 t = 18 20 t1 = 20 18 x = 7 9 4 17 3 17 13 19 18 18 x = 7 9 4 17 3 17 13 19 18 20 t = 7 9 t1 = 7 9 x = 7 9 4 17 3 17 13 19 18 20 x = 7 9 4 17 3 17 13 19 18 20 t = 4 9 t1 = 9 4 x = 7 4 4 17 3 17 13 19 18 20 x = 7 4 9 17 3 17 13 19 18 20 t = 9 17 t1 = 9 17 x = 7 4 9 17 3 17 13 19 18 20 x = 7 4 9 17 3 17 13 19 18 20 t = 3 17 t1 = 17 3 x = 7 4 9 3 3 17 13 19 18 20 x = 7 4 9 3 17 17 13 19 18 20 t = 17 17 t1 = 17 17 x = 7 4 9 3 17 17 13 19 18 20 x = 7 4 9 3 17 17 13 19 18 20 t = 13 17 t1 = 17 13 x = 7 4 9 3 17 13 13 19 18 20 x = 7 4 9 3 17 13 17 19 18 20 t = 17 19 t1 = 17 19 x = 7 4 9 3 17 13 17 19 18 20 x = 7 4 9 3 17 13 17 19 18 20 t = 18 19 t1 = 19 18 x = 7 4 9 3 17 13 17 18 18 20 x = 7 4 9 3 17 13 17 18 19 20 t = 19 20 t1 = 19 20 x = 7 4 9 3 17 13 17 18 19 20 x = 7 4 9 3 17 13 17 18 19 20 t = 4 7 t1 = 7 4 x = 4 4 9 3 17 13 17 18 19 20 x = 4 7 9 3 17 13 17 18 19 20 t = 7 9 t1 = 7 9 x = 4 7 9 3 17 13 17 18 19 20 x = 4 7 9 3 17 13 17 18 19 20 t = 3 9 t1 = 9 3 x = 4 7 3 3 17 13 17 18 19 20 x = 4 7 3 9 17 13 17 18 19 20 t = 9 17 t1 = 9 17 x = 4 7 3 9 17 13 17 18 19 20 x = 4 7 3 9 17 13 17 18 19 20 t = 13 17 t1 = 17 13 x = 4 7 3 9 13 13 17 18 19 20 x = 4 7 3 9 13 17 17 18 19 20 t = 17 17 t1 = 17 17 x = 4 7 3 9 13 17 17 18 19 20 x = 4 7 3 9 13 17 17 18 19 20 t = 17 18 t1 = 17 18 x = 4 7 3 9 13 17 17 18 19 20 x = 4 7 3 9 13 17 17 18 19 20 t = 18 19 t1 = 18 19 x = 4 7 3 9 13 17 17 18 19 20 x = 4 7 3 9 13 17 17 18 19 20 t = 19 20 t1 = 19 20 x = 4 7 3 9 13 17 17 18 19 20 x = 4 7 3 9 13 17 17 18 19 20 t = 4 7 t1 = 4 7 x = 4 7 3 9 13 17 17 18 19 20 x = 4 7 3 9 13 17 17 18 19 20 t = 3 7 t1 = 7 3 x = 4 3 3 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 7 9 t1 = 7 9 x = 4 3 7 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 9 13 t1 = 9 13 x = 4 3 7 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 13 17 t1 = 13 17 x = 4 3 7 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 17 17 t1 = 17 17 x = 4 3 7 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 17 18 t1 = 17 18 x = 4 3 7 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 18 19 t1 = 18 19 x = 4 3 7 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 19 20 t1 = 19 20 x = 4 3 7 9 13 17 17 18 19 20 x = 4 3 7 9 13 17 17 18 19 20 t = 3 4 t1 = 4 3 x = 3 3 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 4 7 t1 = 4 7 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 7 9 t1 = 7 9 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 9 13 t1 = 9 13 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 13 17 t1 = 13 17 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 17 17 t1 = 17 17 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 17 18 t1 = 17 18 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 18 19 t1 = 18 19 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 t = 19 20 t1 = 19 20 x = 3 4 7 9 13 17 17 18 19 20 x = 3 4 7 9 13 17 17 18 19 20 c = 14

3   Pass
x = [73 72 27 56 16 12 21 12 19 1 9 52 44]; y_correct = 54; assert(isequal(bubblesort(x),y_correct))

t = 72 73 t1 = 73 72 x = 72 72 27 56 16 12 21 12 19 1 9 52 44 x = 72 73 27 56 16 12 21 12 19 1 9 52 44 t = 27 73 t1 = 73 27 x = 72 27 27 56 16 12 21 12 19 1 9 52 44 x = 72 27 73 56 16 12 21 12 19 1 9 52 44 t = 56 73 t1 = 73 56 x = 72 27 56 56 16 12 21 12 19 1 9 52 44 x = 72 27 56 73 16 12 21 12 19 1 9 52 44 t = 16 73 t1 = 73 16 x = 72 27 56 16 16 12 21 12 19 1 9 52 44 x = 72 27 56 16 73 12 21 12 19 1 9 52 44 t = 12 73 t1 = 73 12 x = 72 27 56 16 12 12 21 12 19 1 9 52 44 x = 72 27 56 16 12 73 21 12 19 1 9 52 44 t = 21 73 t1 = 73 21 x = 72 27 56 16 12 21 21 12 19 1 9 52 44 x = 72 27 56 16 12 21 73 12 19 1 9 52 44 t = 12 73 t1 = 73 12 x = 72 27 56 16 12 21 12 12 19 1 9 52 44 x = 72 27 56 16 12 21 12 73 19 1 9 52 44 t = 19 73 t1 = 73 19 x = 72 27 56 16 12 21 12 19 19 1 9 52 44 x = 72 27 56 16 12 21 12 19 73 1 9 52 44 t = 1 73 t1 = 73 1 x = 72 27 56 16 12 21 12 19 1 1 9 52 44 x = 72 27 56 16 12 21 12 19 1 73 9 52 44 t = 9 73 t1 = 73 9 x = 72 27 56 16 12 21 12 19 1 9 9 52 44 x = 72 27 56 16 12 21 12 19 1 9 73 52 44 t = 52 73 t1 = 73 52 x = 72 27 56 16 12 21 12 19 1 9 52 52 44 x = 72 27 56 16 12 21 12 19 1 9 52 73 44 t = 44 73 t1 = 73 44 x = 72 27 56 16 12 21 12 19 1 9 52 44 44 x = 72 27 56 16 12 21 12 19 1 9 52 44 73 t = 27 72 t1 = 72 27 x = 27 27 56 16 12 21 12 19 1 9 52 44 73 x = 27 72 56 16 12 21 12 19 1 9 52 44 73 t = 56 72 t1 = 72 56 x = 27 56 56 16 12 21 12 19 1 9 52 44 73 x = 27 56 72 16 12 21 12 19 1 9 52 44 73 t = 16 72 t1 = 72 16 x = 27 56 16 16 12 21 12 19 1 9 52 44 73 x = 27 56 16 72 12 21 12 19 1 9 52 44 73 t = 12 72 t1 = 72 12 x = 27 56 16 12 12 21 12 19 1 9 52 44 73 x = 27 56 16 12 72 21 12 19 1 9 52 44 73 t = 21 72 t1 = 72 21 x = 27 56 16 12 21 21 12 19 1 9 52 44 73 x = 27 56 16 12 21 72 12 19 1 9 52 44 73 t = 12 72 t1 = 72 12 x = 27 56 16 12 21 12 12 19 1 9 52 44 73 x = 27 56 16 12 21 12 72 19 1 9 52 44 73 t = 19 72 t1 = 72 19 x = 27 56 16 12 21 12 19 19 1 9 52 44 73 x = 27 56 16 12 21 12 19 72 1 9 52 44 73 t = 1 72 t1 = 72 1 x = 27 56 16 12 21 12 19 1 1 9 52 44 73 x = 27 56 16 12 21 12 19 1 72 9 52 44 73 t = 9 72 t1 = 72 9 x = 27 56 16 12 21 12 19 1 9 9 52 44 73 x = 27 56 16 12 21 12 19 1 9 72 52 44 73 t = 52 72 t1 = 72 52 x = 27 56 16 12 21 12 19 1 9 52 52 44 73 x = 27 56 16 12 21 12 19 1 9 52 72 44 73 t = 44 72 t1 = 72 44 x = 27 56 16 12 21 12 19 1 9 52 44 44 73 x = 27 56 16 12 21 12 19 1 9 52 44 72 73 t = 72 73 t1 = 72 73 x = 27 56 16 12 21 12 19 1 9 52 44 72 73 x = 27 56 16 12 21 12 19 1 9 52 44 72 73 t = 27 56 t1 = 27 56 x = 27 56 16 12 21 12 19 1 9 52 44 72 73 x = 27 56 16 12 21 12 19 1 9 52 44 72 73 t = 16 56 t1 = 56 16 x = 27 16 16 12 21 12 19 1 9 52 44 72 73 x = 27 16 56 12 21 12 19 1 9 52 44 72 73 t = 12 56 t1 = 56 12 x = 27 16 12 12 21 12 19 1 9 52 44 72 73 x = 27 16 12 56 21 12 19 1 9 52 44 72 73 t = 21 56 t1 = 56 21 x = 27 16 12 21 21 12 19 1 9 52 44 72 73 x = 27 16 12 21 56 12 19 1 9 52 44 72 73 t = 12 56 t1 = 56 12 x = 27 16 12 21 12 12 19 1 9 52 44 72 73 x = 27 16 12 21 12 56 19 1 9 52 44 72 73 t = 19 56 t1 = 56 19 x = 27 16 12 21 12 19 19 1 9 52 44 72 73 x = 27 16 12 21 12 19 56 1 9 52 44 72 73 t = 1 56 t1 = 56 1 x = 27 16 12 21 12 19 1 1 9 52 44 72 73 x = 27 16 12 21 12 19 1 56 9 52 44 72 73 t = 9 56 t1 = 56 9 x = 27 16 12 21 12 19 1 9 9 52 44 72 73 x = 27 16 12 21 12 19 1 9 56 52 44 72 73 t = 52 56 t1 = 56 52 x = 27 16 12 21 12 19 1 9 52 52 44 72 73 x = 27 16 12 21 12 19 1 9 52 56 44 72 73 t = 44 56 t1 = 56 44 x = 27 16 12 21 12 19 1 9 52 44 44 72 73 x = 27 16 12 21 12 19 1 9 52 44 56 72 73 t = 56 72 t1 = 56 72 x = 27 16 12 21 12 19 1 9 52 44 56 72 73 x = 27 16 12 21 12 19 1 9 52 44 56 72 73 t = 72 73 t1 = 72 73 x = 27 16 12 21 12 19 1 9 52 44 56 72 73 x = 27 16 12 21 12 19 1 9 52 44 56 72 73 t = 16 27 t1 = 27 16 x = 16 16 12 21 12 19 1 9 52 44 56 72 73 x = 16 27 12 21 12 19 1 9 52 44 56 72 73 t = 12 27 t1 = 27 12 x = 16 12 12 21 12 19 1 9 52 44 56 72 73 x = 16 12 27 21 12 19 1 9 52 44 56 72 73 t = 21 27 t1 = 27 21 x = 16 12 21 21 12 19 1 9 52 44 56 72 73 x = 16 12 21 27 12 19 1 9 52 44 56 72 73 t = 12 27 t1 = 27 12 x = 16 12 21 12 12 19 1 9 52 44 56 72 73 x = 16 12 21 12 27 19 1 9 52 44 56 72 73 t = 19 27 t1 = 27 19 x = 16 12 21 12 19 19 1 9 52 44 56 72 73 x = 16 12 21 12 19 27 1 9 52 44 56 72 73 t = 1 27 t1 = 27 1 x = 16 12 21 12 19 1 1 9 52 44 56 72 73 x = 16 12 21 12 19 1 27 9 52 44 56 72 73 t = 9 27 t1 = 27 9 x = 16 12 21 12 19 1 9 9 52 44 56 72 73 x = 16 12 21 12 19 1 9 27 52 44 56 72 73 t = 27 52 t1 = 27 52 x = 16 12 21 12 19 1 9 27 52 44 56 72 73 x = 16 12 21 12 19 1 9 27 52 44 56 72 73 t = 44 52 t1 = 52 44 x = 16 12 21 12 19 1 9 27 44 44 56 72 73 x = 16 12 21 12 19 1 9 27 44 52 56 72 73 t = 52 56 t1 = 52 56 x = 16 12 21 12 19 1 9 27 44 52 56 72 73 x = 16 12 21 12 19 1 9 27 44 52 56 72 73 t = 56 72 t1 = 56 72 x = 16 12 21 12 19 1 9 27 44 52 56 72 73 x = 16 12 21 12 19 1 9 27 44 52 56 ...

4   Pass
x = [4 15 2 5 1 5 8 6 12 13 22 7]; y_correct = 18; assert(isequal(bubblesort(x),y_correct))

t = 4 15 t1 = 4 15 x = 4 15 2 5 1 5 8 6 12 13 22 7 x = 4 15 2 5 1 5 8 6 12 13 22 7 t = 2 15 t1 = 15 2 x = 4 2 2 5 1 5 8 6 12 13 22 7 x = 4 2 15 5 1 5 8 6 12 13 22 7 t = 5 15 t1 = 15 5 x = 4 2 5 5 1 5 8 6 12 13 22 7 x = 4 2 5 15 1 5 8 6 12 13 22 7 t = 1 15 t1 = 15 1 x = 4 2 5 1 1 5 8 6 12 13 22 7 x = 4 2 5 1 15 5 8 6 12 13 22 7 t = 5 15 t1 = 15 5 x = 4 2 5 1 5 5 8 6 12 13 22 7 x = 4 2 5 1 5 15 8 6 12 13 22 7 t = 8 15 t1 = 15 8 x = 4 2 5 1 5 8 8 6 12 13 22 7 x = 4 2 5 1 5 8 15 6 12 13 22 7 t = 6 15 t1 = 15 6 x = 4 2 5 1 5 8 6 6 12 13 22 7 x = 4 2 5 1 5 8 6 15 12 13 22 7 t = 12 15 t1 = 15 12 x = 4 2 5 1 5 8 6 12 12 13 22 7 x = 4 2 5 1 5 8 6 12 15 13 22 7 t = 13 15 t1 = 15 13 x = 4 2 5 1 5 8 6 12 13 13 22 7 x = 4 2 5 1 5 8 6 12 13 15 22 7 t = 15 22 t1 = 15 22 x = 4 2 5 1 5 8 6 12 13 15 22 7 x = 4 2 5 1 5 8 6 12 13 15 22 7 t = 7 22 t1 = 22 7 x = 4 2 5 1 5 8 6 12 13 15 7 7 x = 4 2 5 1 5 8 6 12 13 15 7 22 t = 2 4 t1 = 4 2 x = 2 2 5 1 5 8 6 12 13 15 7 22 x = 2 4 5 1 5 8 6 12 13 15 7 22 t = 4 5 t1 = 4 5 x = 2 4 5 1 5 8 6 12 13 15 7 22 x = 2 4 5 1 5 8 6 12 13 15 7 22 t = 1 5 t1 = 5 1 x = 2 4 1 1 5 8 6 12 13 15 7 22 x = 2 4 1 5 5 8 6 12 13 15 7 22 t = 5 5 t1 = 5 5 x = 2 4 1 5 5 8 6 12 13 15 7 22 x = 2 4 1 5 5 8 6 12 13 15 7 22 t = 5 8 t1 = 5 8 x = 2 4 1 5 5 8 6 12 13 15 7 22 x = 2 4 1 5 5 8 6 12 13 15 7 22 t = 6 8 t1 = 8 6 x = 2 4 1 5 5 6 6 12 13 15 7 22 x = 2 4 1 5 5 6 8 12 13 15 7 22 t = 8 12 t1 = 8 12 x = 2 4 1 5 5 6 8 12 13 15 7 22 x = 2 4 1 5 5 6 8 12 13 15 7 22 t = 12 13 t1 = 12 13 x = 2 4 1 5 5 6 8 12 13 15 7 22 x = 2 4 1 5 5 6 8 12 13 15 7 22 t = 13 15 t1 = 13 15 x = 2 4 1 5 5 6 8 12 13 15 7 22 x = 2 4 1 5 5 6 8 12 13 15 7 22 t = 7 15 t1 = 15 7 x = 2 4 1 5 5 6 8 12 13 7 7 22 x = 2 4 1 5 5 6 8 12 13 7 15 22 t = 15 22 t1 = 15 22 x = 2 4 1 5 5 6 8 12 13 7 15 22 x = 2 4 1 5 5 6 8 12 13 7 15 22 t = 2 4 t1 = 2 4 x = 2 4 1 5 5 6 8 12 13 7 15 22 x = 2 4 1 5 5 6 8 12 13 7 15 22 t = 1 4 t1 = 4 1 x = 2 1 1 5 5 6 8 12 13 7 15 22 x = 2 1 4 5 5 6 8 12 13 7 15 22 t = 4 5 t1 = 4 5 x = 2 1 4 5 5 6 8 12 13 7 15 22 x = 2 1 4 5 5 6 8 12 13 7 15 22 t = 5 5 t1 = 5 5 x = 2 1 4 5 5 6 8 12 13 7 15 22 x = 2 1 4 5 5 6 8 12 13 7 15 22 t = 5 6 t1 = 5 6 x = 2 1 4 5 5 6 8 12 13 7 15 22 x = 2 1 4 5 5 6 8 12 13 7 15 22 t = 6 8 t1 = 6 8 x = 2 1 4 5 5 6 8 12 13 7 15 22 x = 2 1 4 5 5 6 8 12 13 7 15 22 t = 8 12 t1 = 8 12 x = 2 1 4 5 5 6 8 12 13 7 15 22 x = 2 1 4 5 5 6 8 12 13 7 15 22 t = 12 13 t1 = 12 13 x = 2 1 4 5 5 6 8 12 13 7 15 22 x = 2 1 4 5 5 6 8 12 13 7 15 22 t = 7 13 t1 = 13 7 x = 2 1 4 5 5 6 8 12 7 7 15 22 x = 2 1 4 5 5 6 8 12 7 13 15 22 t = 13 15 t1 = 13 15 x = 2 1 4 5 5 6 8 12 7 13 15 22 x = 2 1 4 5 5 6 8 12 7 13 15 22 t = 15 22 t1 = 15 22 x = 2 1 4 5 5 6 8 12 7 13 15 22 x = 2 1 4 5 5 6 8 12 7 13 15 22 t = 1 2 t1 = 2 1 x = 1 1 4 5 5 6 8 12 7 13 15 22 x = 1 2 4 5 5 6 8 12 7 13 15 22 t = 2 4 t1 = 2 4 x = 1 2 4 5 5 6 8 12 7 13 15 22 x = 1 2 4 5 5 6 8 12 7 13 15 22 t = 4 5 t1 = 4 5 x = 1 2 4 5 5 6 8 12 7 13 15 22 x = 1 2 4 5 5 6 8 12 7 13 15 22 t = 5 5 t1 = 5 5 x = 1 2 4 5 5 6 8 12 7 13 15 22 x = 1 2 4 5 5 6 8 12 7 13 15 22 t = 5 6 t1 = 5 6 x = 1 2 4 5 5 6 8 12 7 13 15 22 x = 1 2 4 5 5 6 8 12 7 13 15 22 t = 6 8 t1 = 6 8 x = 1 2 4 5 5 6 8 12 7 13 15 22 x = 1 2 4 5 5 6 8 12 7 13 15 22 t = 8 12 t1 = 8 12 x = 1 2 4 5 5 6 8 12 7 13 15 22 x = 1 2 4 5 5 6 8 12 7 13 15 22 t = 7 12 t1 = 12 7 x = 1 2 4 5 5 6 8 7 7 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 12 13 t1 = 12 13 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 13 15 t1 = 13 15 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 15 22 t1 = 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 1 2 t1 = 1 2 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 2 4 t1 = 2 4 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 4 5 t1 = 4 5 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 5 5 t1 = 5 5 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 5 6 t1 = 5 6 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 5 6 8 7 12 13 15 22 t = 6 8 t1 = 6 8 x = 1 2 4 5 5 6 8 7 12 13 15 22 x = 1 2 4 5 ...

5   Pass
x = [48 15 16 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 9]; y_correct = 180; assert(isequal(bubblesort(x),y_correct))

t = 15 48 t1 = 48 15 x = Columns 1 through 29 15 15 16 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 48 16 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 16 48 t1 = 48 16 x = Columns 1 through 29 15 16 16 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 48 86 t1 = 48 86 x = Columns 1 through 29 15 16 48 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 86 89 t1 = 86 89 x = Columns 1 through 29 15 16 48 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 89 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 29 89 t1 = 89 29 x = Columns 1 through 29 15 16 48 86 29 29 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 89 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 56 89 t1 = 89 56 x = Columns 1 through 29 15 16 48 86 29 56 56 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 89 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 2 89 t1 = 89 2 x = Columns 1 through 29 15 16 48 86 29 56 2 2 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 89 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 59 89 t1 = 89 59 x = Columns 1 through 29 15 16 48 86 29 56 2 59 59 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 89 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 57 89 t1 = 89 57 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 57 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 89 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 2 89 t1 = 89 2 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 2 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 89 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 6 89 t1 = 89 6 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 6 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 89 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 27 89 t1 = 89 27 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 27 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 89 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 53 89 t1 = 89 53 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 53 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 89 91 t1 = 89 91 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 91 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 29 91 t1 = 91 29 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 29 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 91 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 52 91 t1 = 91 52 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 52 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 91 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 32 91 t1 = 91 32 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 32 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 91 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 4 91 t1 = 91 4 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 4 4 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 4 91 61 67 18 99 12 37 76 71 85 91 Column 30 9 t = 61 91 t1 = 91 61 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 4 61 61 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 4 61 91 67 18 99 12 37 76 71 85 91 Column 30 9 t = 67 91 t1 = 91 67 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 4 61 67 67 18 99 12 37 76 71 85 91 Column 30 9 x = Columns 1 through 29 15 16 48 86 29 56 2 59 57 2 6 27 53 89 29 52 32 4 61 67 91 18 99 12 37 76 71 85 91 Column 30 9 t = 18 91 t1 = 91 18 x = Columns 1 through 29 15 16 48 86 29...