( 12 17 18 19 25 )
<u>Explanation:</u>
<u>First Pass:</u>
( 19 18 25 17 12 ) –> ( 18 19 25 17 12 ), Here, algorithm compares the first two elements, and swaps since 19 > 18.
( 18 19 25 17 12 ) –> ( 18 19 25 17 12 ), Now, since these elements are already in order (25 > 19), algorithm does not swap them.
( 18 19 25 17 12 ) –> ( 18 19 17 25 12 ), Swap since 25 > 17
( 18 19 17 25 12 ) –> ( 18 19 17 12 25 ), Swap since 25 > 12
<u>Second Pass:</u>
( 18 19 17 12 25 ) –> ( 18 19 17 12 25 )
( 18 19 17 12 25 ) –> ( 18 17 19 12 25 ), Swap since 19 > 17
( 18 17 19 12 25 ) –> ( 18 17 12 19 25 ), Swap since 19 > 12
( 18 17 12 19 25 ) –> ( 18 17 12 19 25 )
<u>Third Pass:</u>
( 18 17 12 19 25 ) –> ( 17 18 12 19 25 ), Swap since 18 > 17
( 17 18 12 19 25 ) –> ( 17 12 18 19 25 ), Swap since 18 > 12
( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )
( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )
<u>Fourth Pass:</u>
( 17 12 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 17 > 12
( 12 17 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 18 > 12
( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )
( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )
Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.
<u>Fifth Pass:</u>
( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )
( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )
( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )
( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )