快速排序quickSort
public class Test {
public static void main(String[] args) {
int arr[] = {3, 5, 6, 333, 5, 2, 1111, 1, 2, 3, 4, 5, 6, 7, 8, 8};
quickSort(arr, 0, arr.length - 1);
}
public static void quickSort(int arr[], int start, int end) {
if (start >= end) {return;}
int prviod = partion(arr, start, end);
quickSort(arr, start, prviod - 1);
quickSort(arr, prviod + 1, end);
}
public static int partion(int arr[], int start, int end) {
int j = start - 1;
int index = start;
for (; index < end; index++) {
if (arr[index] < arr[end]) {
swap(arr, j + 1, index);
j++;
}
}
swap(arr, j + 1, end);
System.out.println(Arrays.toString(arr));
return j + 1;
}
public static void swap(int arr[], int j, int index) {
int tmp = arr[j];
arr[j] = arr[index];
arr[index] = tmp;
}
}
分享到:
相关推荐
效率神器:QuickLook.rar
A well structured approach can quickly solve the following 5 common problems: 1. Can’t browse OPC servers on remote PC 2. Can’t connect to OPC Server on remote PC 3. All items show Bad Quality ...
15道考题 在80分以上 大数据Clouder专项技能认证课程:Quick BI企业报表
The X-CUBE-SMBUS Expansion Package contains the SMBus/PMBus stack implementation for STM32Cube. The SMBus stack is built on STM32Cube HAL drivers to implement the transport layer. Middleware also ...
Quick 11 TPM,是国外知名论坛mydigitallife分享发布的一个批处理,它简单直接,只需把下载的Windows镜像(iso、install.wim esd)直接拖放在批处理上即可,批处理将自动去除映像中的硬件检测,你可直接加载原镜像,...
Quick 11 TPM,是国外知名论坛mydigitallife分享发布的一个批处理,它简单直接,只需把下载的Windows镜像(iso、install.wim esd)直接拖放在批处理上即可,批处理将自动去除映像中的硬件检测,你可直接加载原镜像,...
Gaussian Process for regression a quick introduction
这个程序的头文件中包含四种排序方法:泡沫排序法(bubble),插入排序法(insertion),快速排序法(quick)和选择排序法(selection)。头文件中还使用了模板技术,以便可以同时实现几种类型的排序算法。 ...
数据结构,排序算法,快速排序算法的C语言实现, quick sort C qsort.c an c implementation of quick sort
Arduino :A_Quick_Start_Guide
不建议使用QuickReturn 。 不会再有任何发展。 在创建此库时, 不存在。 请检出因为您应该能够在的帮助下实现此库中所有类似的功能。 感谢您的支持! QuickReturn是一个展示QuickReturn UI模式的库。 当内容向上...
快速排序(Quick Sort)
quickapp-cli quickapp的客户端 这是quickapp的unix样式的包装程序,因此可以从命令行创建sbcl buildapp应用程序。 用法示例: quickapp testproject \ -d " (:sdl2 :cl-opengl) " \ --author=cluser 有关更...
关于Github上的Quicksilver 该存储库包含Quicksilver的当前源代码。 如果您在使用最新版本的Quicksilver时遇到问题,请随时将其记录在。 master分支包含当前发布的Quicksilver的源。 如果您需要有关更多信息,可以...
Mac-QuickLook QuickLook插件和软件包列表提供大多数插件和软件包如何安装/卸载QuickLook插件使用安装: brew cask install <package> 卸载: brew cask uninstall 手动地install:将下载的.qlgenerator文件移动到~/...
1、从键盘输入上述8个整数,存放在数组quick[8]中,并输出值。 2、输出各种排序算法每一趟排序的结果,观察关键字次序的变化。 3、如果上述8个整数按照升序输入,即k1={ 2 , 12 , 12 , 21 , 30 , 33 , 45 , 68 },...
抢js文件dist/quickreturn.min.js和源地图dist/quickreturn.min.js.map ,并在您的应用程序的公用文件夹。 一旦脚本在你的页面中,实例化一个新的Quickreturn对象,传递你想要像“quickreturn”一样的 DOM 元素。 ...
MODELING MULTI-SPEAKER LATENT SPACE TO IMPROVE NEURAL TTS: QUICK ENROLLING NEW SPEAKER AND ENHANCING PREMIUM VOICE
博文链接:https://univasity.iteye.com/blog/891669