Professional Documents
Culture Documents
Selection sort :
{
}
// swap arr[j+1] and arr[j]
arr[j] = arr[j+1];
Output
} 11 12 22 25 34 64 90
int n = arr.length;
System.out.println();
}
Insertion Sort :
{ {
int j = i - 1; printArray(arr);
{ } //class end
arr[j + 1] = arr[j];
arr[j + 1] = key;
} Output:
static void printArray(int arr[])
5 6 11 12 13
{
int n = arr.length;
System.out.println();
}
Quick Sort :
public class QSort static void quickSort(int[] arr, int low, int high)
{ {
{ {
quickSort(arr, 0, n - 1);
}
} //class end
Output
Sorted array:
1 5 7 8 9 10