Skip to content

Instantly share code, notes, and snippets.

package selectionsort;
public class SelectionSort
{
public static void Selection_Sort( int array[] )
{
int hold;
int index;
for ( int i = 0; i < array.length - 1; i++ )
package insertion.sort;
public class InsertionSort
{
public static void Insertion_Sort( Integer[] A )
{
int key;
int i;
for ( int j = 2; j < A.length; j++ )
package counting.sort;
public class CountingSort
{
public static int maximumElement( Integer array[] )
{
// Set the largest element to the first for comparison
int max;
max = array[ 1 ];
QUICKSORT( A, left, right )
if left < right
pivot = PARTITION( A, left, right )
QUICKSORT( A, left, pivot - 1 )
QUICKSORT( A, pivot + 1, right )
PARTITION( A, left, right )
pivot = A[ right ]
i = left - 1
for j = left to right - 1
package quicksort;
public class QuickSort
{
public static int partition( int array[], int left, int right )
{
// Create the pivot by picking the last spot in the array
int pivot_index;
int pivot;