The basic idea of rapid sorting is based on granted policies. For input subsequences AP.., if the scale is small enough to sort, otherwise three steps: Divide: Decompose: Divide the input sequence AP.. AP..AQ and AQ 1..or, the value of any element in the AP.. AQ is not more than any element of the AQ 1. Cancer Solution: Sort by recursive P ... AQ and AQ 1..Ar. Merge: Since the sort of the decomposed two subsequences is carried out, there is no need to perform any calculations after the AP..aq and AQ 1..ar are sequenced. Such sequence. This solution process is the basic steps that meet the grahe method. Therefore, the rapid sorting method is one of the classic application examples of the granted method. Using system;
Namespace vcquicksort {///
Private Void Swap (Ref INT I, REF INT J) // Swap Two Integer {INT T; T = I; I = J; J = T;} Public Void Sort (int [] list, int low, int high) { IF (high <= low) {// only one element in array list // so it do not need sort return;} else if (high == low 1) {// means two elements in Array List // SO WE Just Compare Themiff (List [Low]> List [high]) {// Exchange Them swap (ref list [high]); return;}} // more Than 3 Elements in the arrary List / / Begin Quicksort Myquicksort (List, Low, HIGH);
Public void myquicksort (int]) {if (LOW Private int partict, int low, int high {// get the pivot of the arrary list int spread; pivot = list [low]; while (low