SHARE
TWEET
Untitled
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- /*
- https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q12210709112
- このプログラムの流用による不具合の責任を上記URLの回答者・質問者・サイト
- 運営者に問うことはできません。
- */
- public static void quickSort(int[] data){
- int[] Left = new int[data.length];
- int[] Right= new int[data.length];
- int index = 0;
- Left[index] = 0;
- Right[index] = data.length - 1;
- while(index>= 0){
- int left = Left[index];
- int right = Right[index];
- if(left>=right) {index--;continue;}
- int pivot = data[(left+right)/2];
- for(;;){
- while(data[left] < pivot)left++;
- while(data[right] > pivot)right--;
- if(left < right){
- int tmp = data[left];
- data[left] = data[right];
- data[right] = tmp;
- left++;right--;
- continue;
- }
- break;
- }
- Left[index+1]=Left[index];
- Right[index+1]=(left-1>Left[index])?left-1:Left[index];
- Left[index]=(right+1<Right[index])?right+1:Right[index];
- index++;
- }
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.