Created
July 12, 2022 08:04
-
-
Save techisbeautiful/48af714d26f371c4d7348bee6c5f1a48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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