算法Sedgewick第四版-第1章基础-2.3 Quicksort-001快速排序
一、
1.特点
(1)The quicksort algorithm’s desirable features are that it is in-place (uses only a small auxiliary stack) and that
it requires time proportional to N log N on the average to sort an array of length N.
(2)quicksort has a shorter inner loop than most other sorting algorithms, which means that it is fast in practice as well as in theory.
2.缺点:
(1)Its primary drawback is that it is fragile in the sense that some care is involved in the implementation to be sure to avoid bad performance.
(2)
二、
算法Sedgewick第四版-第1章基础-2.3 Quicksort-001快速排序的更多相关文章
- 算法Sedgewick第四版-第1章基础-001递归
一. 方法可以调用自己(如果你对递归概念感到奇怪,请完成练习 1.1.16 到练习 1.1.22).例如,下面给出了 BinarySearch 的 rank() 方法的另一种实现.我们会经常使用递归, ...
- 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-001选择排序法(Selection sort)
一.介绍 1.算法的时间和空间间复杂度 2.特点 Running time is insensitive to input. The process of finding the smallest i ...
- 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-007归并排序(自下而上)
一. 1. 2. 3. 二.代码 package algorithms.mergesort22; import algorithms.util.StdIn; import algorithms.uti ...
- 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-006归并排序(Mergesort)
一. 1.特点 (1)merge-sort : to sort an array, divide it into two halves, sort the two halves (recursivel ...
- 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-005插入排序的改进版
package algorithms.elementary21; import algorithms.util.StdIn; import algorithms.util.StdOut; /***** ...
- 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-004希尔排序法(Shell Sort)
一.介绍 1.希尔排序的思路:希尔排序是插入排序的改进.当输入的数据,顺序是很乱时,插入排序会产生大量的交换元素的操作,比如array[n]的最小的元素在最后,则要经过n-1次交换才能排到第一位,因为 ...
- 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-002插入排序法(Insertion sort)
一.介绍 1.时间和空间复杂度 运行过程 2.特点: (1)对于已排序或接近排好的数据,速度很快 (2)对于部分排好序的输入,速度快 二.代码 package algorithms.elementar ...
- 算法Sedgewick第四版-第1章基础-1.3Bags, Queues, and Stacks-001可变在小的
1. package algorithms.stacks13; /******************************************************************* ...
- 算法Sedgewick第四版-第1章基础-1.4 Analysis of Algorithms-005计测试算法
1. package algorithms.analysis14; import algorithms.util.StdOut; import algorithms.util.StdRandom; / ...
- 算法Sedgewick第四版-第1章基础-1.4 Analysis of Algorithms-002如何改进算法
1. package algorithms.analysis14; import algorithms.util.In; import algorithms.util.StdOut; /******* ...
随机推荐
- 获得客户端ip
获得客户端ip private function GetIP(){ if(!empty($_SERVER["HTTP_CLIENT_IP"])){ ...
- Operating System-进程/线程内部通信-临界区(Critical Regions)
上一篇文章讲述了进程之间的竞争条件:多个进程同时进入一个共享区域,导致了数据的不一致,本文主要介绍如何解决这个问题. 一.临界区介绍 解决这个问题就是阻止多个进程同时进入这个共享区域,换句话说,进程之 ...
- 快速沃尔什变换(FWT)学习笔记
概述 FWT的大体思路就是把要求的 C(x)=A(x)×B(x) 即 \( c[i]=\sum\limits_{j?k=i} (a[j]*b[k]) \) 变换成这样的:\( c^{'}[i]=a^ ...
- flask之Jinja2
Jinja2 is a library found at http://jinja.pocoo.org/; you can use it to produce formatted text with ...
- Windows:cmd的使用
1.如果在cmd.exe中无法运行软件(如python),因为在系统的环境变量中,path中没有该软件的安装路径: 2.通过pip安装软件:pip install 文件路径\文件全名,将软件安装在指定 ...
- Python内置函数:get()
文章转载于:https://www.cnblogs.com/wushuaishuai/p/7738118.html(博主:IT技术随笔) 描述 Python 字典 get() 方法和 setdefau ...
- Django基础(四)
Form表单 Admin Django Form表单 django 中的form 一般有两种功能: 输入html 验证用户输入 1,先写一个form import re from django ...
- declare handler 声明异常处理的语法
声明异常处理的语法 DECLARE {EXIT | CONTINUE} HANDLER FOR {error-number | SQLSTATE error-string | condition} S ...
- POJ 1276 Cash Machine(单调队列优化多重背包)
Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38986 Accepted: 14186 De ...
- apache将不带www域名301重定向到带www的域名的配置方法
#强制重定向到wwwRewriteEngine OnRewriteCond %{HTTP_HOST} ^jb51.net/ [NC]RewriteRule ^(.*)$ http://www.jb51 ...