快速排序
来源:互联网 发布:扫描网络摄像头ip 编辑:程序博客网 时间:2024/06/08 03:05
排序法
最差时间分析平均时间复杂度稳定度空间复杂度冒泡排序O(n2)O(n2)稳定O(1)快速排序O(n2)O(n*log2n)不稳定O(log2n)~O(n)选择排序O(n2)O(n2)稳定O(1)二叉树排序O(n2)O(n*log2n)不一顶O(n)插入排序
O(n2)O(n2)稳定O(1)堆排序O(n*log2n)O(n*log2n)不稳定O(1)希尔排序OO不稳定O(1)package com.sort.test;public class QuickSort {public static void main(String[] args) {int a[] = {-11,49,38,65,97,76,13,27,49,78,34,12,-1,64,5,4,62,99,98,54,56,17,18,23,34,15,35,25,53,51}; //quickT(a);for (int i = 0; i < a.length; i++) {System.out.print(" "+ a[i]);}}public static void quickT(int[] a){if(a.length>0){_quickSortT(a,0,a.length-1);}}private static void _quickSortT(int[] a, int low, int high) {if(low<high){int middle = getMiddleT(a,low,high);//_quickSortT(a, middle+1, high);_quickSortT(a, low, middle-1);}}private static int getMiddleT(int[] a, int low, int high) {//数组第一个作为中轴int temp = a[low];while(low<high){while(low<high && a[high] >= temp){high -- ;}a[low] = a[high];while(low<high && a[low] <= temp ){low++;}a[high] = a[low];}a[low] = temp;return low;}}
阅读全文
0 0
- 快速排序
- 快速排序
- 快速排序
- 快速排序!
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- POJ-2395 Out of Hay
- 宏内核与微内核
- codeforces 855E 数位DP
- 构建乘积数组
- cocos2dx3.1.15.1打android包出现闪退
- 快速排序
- 51Nod-1615-跳跃的杰克
- MV3D -- 3D 点云表示
- 【安全牛学习笔记】w3af-截断代理
- D3力导向图及树状布局变换
- DB2 V9.7.4 下使用LISTAGG时报错,SQL0440N,SQLSTATE=42884解决办法
- On Date/Timestamp Value in A Distributed System
- VNC配置
- IDEA添加toString方法的模板