GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Programs/QuickSort.java at main · arshcoder13/Java Expand file tree/ Copy pathQuickSort.javaMore file actions 48 lines (42 loc) · 1.06 KB / Copy pathQuickSort.javaFile metadata and controls48 lines (42 loc) · 1.06 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 //Quick Sort import java.util.*; import java.lang.*; import java.io.*; public class QuickSort{ public static void main(String args[]){ int arr[]= {-1,-2,42,1,24,44,32,0,12,100}; quickSort(arr,0,arr.length-1); System.out.println(Arrays.toString(arr)); } public static void quickSort(int arr[],int i, int j){ int pivot = i; if(i<j){ sort(arr,i,j,pivot); quickSort(arr,i,pivot); quickSort(arr,pivot+1,j); } } public static int[] sort(int arr[],int i,int j,int pivot){ if(j<=pivot || i>=arr.length){ return arr; } while(arr[i] < arr[pivot]){ i++; } while(arr[j]> arr[pivot]){ j--; } if(i<j){ int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; return sort(arr,i,j,pivot); } else{ int tmp = arr[pivot]; arr[pivot] = arr[j]; arr[j] = tmp; return arr; } } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |