Input:

Sequence <A1', A2', ...An'> of numbers

Output:

Permutation of numbers <A1',A2',...An'>

Description:
  • Swipe first two elements if the 1st element is greater
  • Swipe 2nd and 3rd element if 2nd element is greater
  • Repeat same until array is sorted
Running Time:

Space: O(1)

Worst Case:

O(n2)

Average Case:

O(n2)