Skip to content

Instantly share code, notes, and snippets.

@hsynkrcf
Last active June 21, 2024 00:38
Show Gist options
  • Save hsynkrcf/d7e2f6fdb77303cbeccd83a2b457f39b to your computer and use it in GitHub Desktop.
Save hsynkrcf/d7e2f6fdb77303cbeccd83a2b457f39b to your computer and use it in GitHub Desktop.
Bubble Sort Algorithm Performed On C#
public int[] BubbleSort(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - i - 1; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment