We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
要知道,快速排序利用的是分治的思想,基于交换!就是元素通过比较最终确定好每个元素的位置。
void QuickSort(int R[], int low, int high) //对R[low]到R[r]的关键字进行快速排序 { int temp; int i = low , j = high; if (low < high) { temp = R[low]; //下面这个循环完成了一趟排序,将数组中小于temp的关键字放在左边,大于temp的关键字放在右边 while (i != j) { while (j > i && R[j] >= temp) { --j //从左往右扫描,找一个小于temp的关键字 } if(i < j) { R[i] = R[j];//挖j位置的数出来放在i位置上 i++; //i右移一位 } while (i < j && R[i] < R[j]) { i++; } if(i < j) { R[j] = R[i]; j--; } } R[i] = temp; QuickSort(R, low, i-1); QuickSort(R, i+1,high); } return R; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
要知道,快速排序利用的是分治的思想,基于交换!就是元素通过比较最终确定好每个元素的位置。
快速排序简单易懂之灵魂画手模拟快速排序过程
快速排序之简单代码实现
The text was updated successfully, but these errors were encountered: