是否性病::排序实现快速排序? [英] Does std::sort implement Quicksort?

查看:155
本文介绍了是否性病::排序实现快速排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/1840121/which-type-of-sorting-is-used-in-the-function-sort">which分拣的类型是用于在功能分类()?中

是否标准::排序实现快速排序?

Does std::sort implement Quicksort?

推荐答案

但是也有一些传统上使用两种算法。

There are two algorithms that are traditionally used.

的std ::排序 是最有可能使用快速排序,或者至少变化为快速排序所谓的IntroSort ,其中退化到堆排序当递归过犹深。

std::sort is most likely to use QuickSort, or at least a variation over QuickSort called IntroSort, which "degenerates" to HeapSort when the recursion goes too deep.

从标准:

复杂度:O(N日志(N))比较

Complexity: O(N log(N)) comparisons.

的std :: stable_sort 是最有可能使用归并 ,由于稳定​​性要求。但是请注意,归并需要为了额外的空间是有效的。

std::stable_sort is most likely to use MergeSort, because of the stability requirement. However note that MergeSort requires extra space in order to be efficient.

从标准:

复杂性:它确实最多N日志 2 (N)的比较;如果有足够的额外内存可用,它是N的log(n)。

Complexity: It does at most N log2(N) comparisons; if enough extra memory is available, it is N log(N).

我还没有看到一个的std ::排序实施 TimSort 这是希望的,在Python(其实制作的吧)已经通过,Java和Android的(至今)。

I have yet to see a std::sort implementing TimSort which is promising and has been adopted in Python (crafted for it in fact), Java and Android (to date).

这篇关于是否性病::排序实现快速排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆