Skip to content

Instantly share code, notes, and snippets.

@techisbeautiful
Created July 12, 2022 08:04
Show Gist options
  • Save techisbeautiful/48af714d26f371c4d7348bee6c5f1a48 to your computer and use it in GitHub Desktop.
Save techisbeautiful/48af714d26f371c4d7348bee6c5f1a48 to your computer and use it in GitHub Desktop.
void bubbleSort(int dataCollection[])
{
int n = dataCollection.length;
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < n - i - 1; j++)
if (dataCollection[j] > dataCollection[j + 1]) {
// swap arr[j+1] and arr[j]
int temp = dataCollection[j];
dataCollection[j] = dataCollection[j + 1];
dataCollection[j + 1] = temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment