<Dl> <Dt> Second Pass </Dt> </Dl> <P> (1 4 2 5 8) → (\ displaystyle \ to) (1 4 2 5 8) (1 4 2 5 8) → (\ displaystyle \ to) (1 2 4 5 8), Swap since 4> 2 (1 2 4 5 8) → (\ displaystyle \ to) (1 2 4 5 8) (1 2 4 5 8) → (\ displaystyle \ to) (1 2 4 5 8) Now, the array is already sorted, but the algorithm does not know if it is completed . The algorithm needs one whole pass without any swap to know it is sorted . </P> <Dl> <Dt> Third Pass </Dt> </Dl> <P> (1 2 4 5 8) → (\ displaystyle \ to) (1 2 4 5 8) (1 2 4 5 8) → (\ displaystyle \ to) (1 2 4 5 8) (1 2 4 5 8) → (\ displaystyle \ to) (1 2 4 5 8) (1 2 4 5 8) → (\ displaystyle \ to) (1 2 4 5 8) </P>

Bubble sort algorithm different from modified bubble sort algorithm