Posts

Showing posts with the label algorithm

Quick sort in the short version

Image
Ref:  https://www.programcreek.com/2012/11/quicksort-array-in-java/ public class QuickSort {     public static void main(String[] args) {         int[] arr = {4, 5, 1, 2, 3, 3};         quickSort(arr, 0, arr.length-1);         System.out.println(Arrays.toString(arr));     }     public static void quickSort(int[] arr, int start, int end){         int partition = partition(arr, start, end);         if(partition-1>start) {             quickSort(arr, start, partition - 1);         }         if(partition+1<end) {             quickSort(arr, partition + 1, end);         }     }     public static int partition(int[] arr, int start, int end){         int pivot = arr[end];     ...