24. After First Pass of Outer Loop
331445 6 67 4223 98
pos_akhir
index
6
7
N 8
Finished first “Bubble Up”
did_swap true
0 1 2 3 4 5 6 7
25. The Second “Bubble Up”
331445 6 67 4223 98
pos_akhir
index
5
0
N 8 did_swap false
0 1 2 3 4 5 6 7
26. The Second “Bubble Up”
331445 6 67 4223 98
pos_akhir
index
5
0
N 8 did_swap false
No Swap
0 1 2 3 4 5 6 7
27. The Second “Bubble Up”
331445 6 67 4223 98
pos_akhir
index
5
1
N 8 did_swap false
0 1 2 3 4 5 6 7
28. The Second “Bubble Up”
331445 6 67 4223 98
pos_akhir
index
5
1
N 8 did_swap false
Swap
0 1 2 3 4 5 6 7
29. The Second “Bubble Up”
334514 6 67 4223 98
pos_akhir
index
5
1
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
30. The Second “Bubble Up”
334514 6 67 4223 98
pos_akhir
index
5
2
N 8 did_swap true
0 1 2 3 4 5 6 7
31. The Second “Bubble Up”
334514 6 67 4223 98
pos_akhir
index
5
2
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
32. The Second “Bubble Up”
33614 45 67 4223 98
pos_akhir
index
5
2
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
33. The Second “Bubble Up”
33614 45 67 4223 98
pos_akhir
index
5
3
N 8 did_swap true
0 1 2 3 4 5 6 7
34. The Second “Bubble Up”
33614 45 67 4223 98
pos_akhir
index
5
3
N 8 did_swap true
No Swap
0 1 2 3 4 5 6 7
35. The Second “Bubble Up”
33614 45 67 4223 98
pos_akhir
index
5
4
N 8 did_swap true
0 1 2 3 4 5 6 7
36. The Second “Bubble Up”
33614 45 67 4223 98
pos_akhir
index
5
4
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
37. The Second “Bubble Up”
67614 45 33 4223 98
pos_akhir
index
5
4
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
38. The Second “Bubble Up”
67614 45 33 4223 98
pos_akhir
index
5
5
N 8 did_swap true
0 1 2 3 4 5 6 7
39. The Second “Bubble Up”
67614 45 33 4223 98
pos_akhir
index
5
5
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
40. The Second “Bubble Up”
42614 45 33 6723 98
pos_akhir
index
5
5
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
41. After Second Pass of Outer
Loop
42614 45 33 6723 98
pos_akhir
index
5
6
N 8 did_swap true
Finished second “Bubble Up”
0 1 2 3 4 5 6 7
42. The Third “Bubble Up”
42614 45 33 6723 98
pos_akhir
index
4
0
N 8 did_swap false
0 1 2 3 4 5 6 7
43. The Third “Bubble Up”
42614 45 33 6723 98
pos_akhir
index
4
0
N 8 did_swap false
Swap
0 1 2 3 4 5 6 7
44. The Third “Bubble Up”
42623 45 33 6714 98
pos_akhir
index
4
0
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
45. The Third “Bubble Up”
42623 45 33 6714 98
pos_akhir
index
4
1
N 8 did_swap true
0 1 2 3 4 5 6 7
46. The Third “Bubble Up”
42623 45 33 6714 98
pos_akhir
index
4
1
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
47. The Third “Bubble Up”
42236 45 33 6714 98
pos_akhir
index
4
1
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
48. The Third “Bubble Up”
42236 45 33 6714 98
pos_akhir
index
4
2
N 8 did_swap true
0 1 2 3 4 5 6 7
49. The Third “Bubble Up”
42236 45 33 6714 98
pos_akhir
index
4
2
N 8 did_swap true
No Swap
0 1 2 3 4 5 6 7
50. The Third “Bubble Up”
42236 45 33 6714 98
pos_akhir
index
4
3
N 8 did_swap true
0 1 2 3 4 5 6 7
51. The Third “Bubble Up”
42236 45 33 6714 98
pos_akhir
index
4
3
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
52. The Third “Bubble Up”
42236 33 45 6714 98
pos_akhir
index
4
3
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
53. The Third “Bubble Up”
42236 33 45 6714 98
pos_akhir
index
4
4
N 8 did_swap true
0 1 2 3 4 5 6 7
54. The Third “Bubble Up”
42236 33 45 6714 98
pos_akhir
index
4
4
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
55. The Third “Bubble Up”
45236 33 42 6714 98
pos_akhir
index
4
4
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
56. After Third Pass of Outer Loop
45236 33 42 6714 98
pos_akhir
index
4
5
N 8 did_swap true
Finished third “Bubble Up”
0 1 2 3 4 5 6 7
57. The Fourth “Bubble Up”
45236 33 42 6714 98
pos_akhir
index
3
0
N 8 did_swap false
0 1 2 3 4 5 6 7
58. The Fourth “Bubble Up”
45236 33 42 6714 98
pos_akhir
index
3
0
N 8 did_swap false
Swap
0 1 2 3 4 5 6 7
59. The Fourth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
3
0
N 8 did_swap true
Swap
0 1 2 3 4 5 6 7
60. The Fourth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
3
1
N 8 did_swap true
0 1 2 3 4 5 6 7
61. The Fourth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
3
1
N 8 did_swap true
No Swap
0 1 2 3 4 5 6 7
62. The Fourth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
3
2
N 8 did_swap true
0 1 2 3 4 5 6 7
63. The Fourth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
3
2
N 8 did_swap true
No Swap
0 1 2 3 4 5 6 7
64. The Fourth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
3
3
N 8 did_swap true
0 1 2 3 4 5 6 7
65. The Fourth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
3
3
N 8 did_swap true
No Swap
0 1 2 3 4 5 6 7
66. After Fourth Pass of Outer Loop
452314 33 42 676 98
pos_akhir
index
3
4
N 8 did_swap true
Finished fourth “Bubble Up”
0 1 2 3 4 5 6 7
67. The Fifth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
2
0
N 8 did_swap false
0 1 2 3 4 5 6 7
68. The Fifth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
2
0
N 8 did_swap false
No Swap
0 1 2 3 4 5 6 7
69. The Fifth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
2
1
N 8 did_swap false
0 1 2 3 4 5 6 7
70. The Fifth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
2
1
N 8 did_swap false
No Swap
0 1 2 3 4 5 6 7
71. The Fifth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
2
2
N 8 did_swap false
0 1 2 3 4 5 6 7
72. The Fifth “Bubble Up”
452314 33 42 676 98
pos_akhir
index
2
2
N 8 did_swap false
No Swap
0 1 2 3 4 5 6 7
73. After Fifth Pass of Outer Loop
452314 33 42 676 98
pos_akhir
index
2
3
N 8 did_swap false
Finished fifth “Bubble Up”
0 1 2 3 4 5 6 7
74. Finished “Early”
452314 33 42 676 98
pos_akhir
index
2
3
N 8 did_swap false
We didn’t do any swapping,
so all of the other elements
must be correctly placed.
We can “skip” the last two
passes of the outer loop.
0 1 2 3 4 5 6 7