# Include <iostream>
Using namespace STD;
Void choice_sort (int * arr, int Len );
Void quicksort (int * arr, int start, int begin );
Int main ()
{
Int arr [10] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
Quicksort (ARR, 0, 9 );
For (INT I = 0; I <10; I ++) // asymmetric Boundary
{
Cout <arr [I] <"";
}
Cout <Endl;
Return 0;
}
Void bubble_sort (int * arr, int Len)
{
Int temp;
For (INT I = 0; I <len-1; I ++)
{
For (Int J = 0; j <len-1-i; j ++)
{
If (ARR [J]> arr [J + 1])
{
Temp = arr [J];
Arr [J] = arr [J + 1];
Arr [J + 1] = temp;
}
}
}
}
// The insertion sorting idea is: An if statement contains two cases.
// Compare the minimum value with all other values in the array.
void insert_sort (int * arr, int Len)
{< br> int temp;
int Max;
// number of times that the outer large loop is controlled, isn't it?
for (INT I = 0; I {< br> max = I;
for (Int J = I + 1; j {< br> If (ARR [Max]> arr [J])
{< br> max = J;
}< BR >}< br> If (max! = I)
{< br> temp = arr [I];
arr [I] = arr [Max];
arr [Max] = temp;
}< BR >}
void choice_sort (int * arr, int Len)
{< br> // determine the number of large loops, loop n-1
Int J = 0;
int temp;
for (INT I = 0; I {
J = I;
temp = arr [J + 1];
while (j> = 0 & temp {< br> arr [J + 1] = arr [J];
j --;
}< br> arr [J + 1] = temp;
}< BR >}
Int partition (int * arr, int start, int partition)
{
Int I = start;
Int J = start;
Int temp;
For (; j <strong; j ++)
{
If (ARR [J] <arr [region])
{
Temp = arr [I];
Arr [I] = arr [J];
Arr [J] = temp;
I ++;
}
}
Temp = arr [I];
Arr [I] = arr [region];
Arr [temp] = temp;
Return I; // .. return the Axis Position
}
Void quicksort (int * arr, int start, int begin)
{
Int Q;
If (start <begin)
{
Q = partition (ARR, start, partition );
Quicksort (ARR, start, q-1 );
Quicksort (ARR, q + 1, Baidu );
}
}
// Binary Search
// Reduce the problem by half each time.
int binary_search (INT arr, int Len, int target)
{< br> int Top = 0, Bottom = len-1, mid =-1;
while (top <= bottom)
{< br> mid = (top + bottom) >>1;
If (mid> target)
{< br> bottom = mid-1;
}else if (mid {< br> Top = Mid + 1;
}else
{< br> return mid;
}< BR >}< br> return-1;
}