/*************** Bubble sort **************/
Public class bubblesorter
{
Public static void sort (INT [] list)
{
Int I, J;
For (I = 0; I <list. length; I ++)
{
For (j = 0; j <list. Length-1-I; j ++)
{
If (list [J]> list [J + 1])
{
Int temp = list [J];
List [J] = list [J + 1];
List [J + 1] = temp;
}
}
}
}
}
/**************** Selection sort *************/
Public class selectionsorter
{
Public static void sort (INT [] list)
{
Int I, J;
For (I = 0; I <list. length; I ++)
{
For (j = I + 1; j <list. length; j ++)
{
If (list [J] <list [I])
{
Int temp = list [J];
List [J] = list [I];
List [I] = temp;
}
}
}
}
}
/************* Insert sort ***********/
Public class insertsorter
{
Public static void sort (INT [] list)
{
Int I, J;
For (I = 1; I <list. length; I ++)
{
Int temp = list [I];
J = I;
While (j> 0 & list [J-1]> temp)
{
List [J] = list [J-1];
J --;
}
List [J] = temp;
}
}
}
/************* Quick Sort ***************/
Public class quicksorter
{
Public static void sort (INT [] list)
{
Quicksort (list, 0, list. Length-1 );
}
Public static void quicksort (INT [] list, int low, int high)
{
Int temp = list [(low + high)/2];
Int I = low, j = high;
Do
{
While (I <High & list [I] <temp)
I ++;
While (j> low & list [J]> temp)
J --;
If (I <= J)
{
Swap (Ref List [I], Ref List [J]);
I ++;
J --;
}
}
While (I <= J );
If (j> LOW)
Quicksort (list, low, J );
If (I Quicksort (list, I, high );
}
Public static void swap (ref int L, ref int R)
{
Int temp = L;
L = R;
R = temp;
}
}