Bubble sort in c# + dry run using excel
Sorting a array using bubble sort
public void PerformBubbleSort() {
int temp = 0;
int[] a = { 2, 4, 5, 1, 3 };
for (int i = 0; i < a.Length; i++)
{
int last = (a.Length - 1) - i;
for (int j = 0; j < last; j++)
{
if (a[j] > a[j + 1])
{
temp = a[j];t
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
}
0 comments:
Post a Comment