Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Namespace QuickSort
{
Class Program
{
static void Main (string[] args)
{
list<int> list = new list<int> () {33, 19, 28, 14, 10, 67, 22, 90, 55, 100, 120, 140, 1, 12};
int low = 0;
int high = list. Count-1;
int mid = (low + high)/2;
Quicksortarr (List,low,high);
Console.readkey ();
}
public static void Quicksortarr (list<int> list,int low,int High)
{
Used to end a recursive call
if (Low >= high)
{
Return
}
int start = low;
int end = high;
int mid = (low + high)/2;
int findnum = List[mid];
Tag=0 is the possible location where the tag is initialized to indicate the number to be positioned
int tag = 0;
Tag = mid;
while (Low{
while (Low < high)
{
if (FindNum > List[high])
{
The possible position of the number to be looked for is changing every time, whether it is looking for a small one behind or looking for a large tag=high (positioning possible position, Tag=high is in the update possible location)
List[tag] = List[high];
tag = high;
Break
}
Else
{
high--;
}
}
while (Low < high)
{
if (FindNum < List[low])
{
The possible position of the number to be looked for is changing every time, whether it is looking for a small one behind or looking for a large tag=low (positioning possible position, Tag=low is in the update possible location)
List[tag] = List[low];
tag = low;
Break
}
Else
{
low++;
}
}
}
Low==high when the previous is more than the search for the number of small, behind is looking for the number of large, said that the Low==high subscript is the final number of subscript
List[low] =findnum;
Quicksortarr (list, start,low-1);
Quicksortarr (list, low+1, end);
}
}
}
Quick sort (Pull the carrot method, the essence is always negative looking for the current position of a radish, a pit)