Bubble sort [8, 7, 6, 5, 4, 3, 2, 1].
Ready — edit the code above and click Run.
using System;
class Program
{
static void Main()
{
int[] arr = { 8, 7, 6, 5, 4, 3, 2, 1 };
Array.Sort(arr);
Console.WriteLine(string.Join(", ", arr));
}
}
Try solving on your own first, then reveal the official answer.
Bubble is O(n²)—implement manually in interviews.