尝试从Quicksort的实现中学习,我无法找出为什么它没有正确排序.
使用此序列:
6,7,12,5,9,8,65,3
它返回:
3,5,7,8,9,65,12,6
它似乎有些不同,但不是全部.我错过了什么?
这是我的代码:
static void Main(string[] args)
{
QuickSort qs = new QuickSort();
int[] arr = new int[] { 6, 7, 12, 5, 9, 8, 65, 3 };
foreach (int l in arr)
{
Console.Write(l + ", ");
}
int left = 0;
int right = arr.Count() - 1;
int[] arrr = qs.DoQuickSort(ref arr, left, right);
Console.WriteLine("Sorted List: ");
foreach (int i in arrr)
{
Console.Write(i + " ");
}
Console.ReadLine();
}
public int Partition(int[] array, …Run Code Online (Sandbox Code Playgroud)