Skip to content

Instantly share code, notes, and snippets.

@thanhnguyentang
Last active January 11, 2016 02:15
Show Gist options
  • Select an option

  • Save thanhnguyentang/146f61250acf9de08952 to your computer and use it in GitHub Desktop.

Select an option

Save thanhnguyentang/146f61250acf9de08952 to your computer and use it in GitHub Desktop.
BUBBLE-SORT(A)
// repeatedly swap two adjacent elements that are out of order
for i = 1 to A.length() - 1
for j = A.length down to i+1
if A[j] < A[j-1]
swap(A[j], A[j-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment