由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - [question] what is the time complexity of qsort in standard c libarary(GCC, more specifically)?
相关主题
Ryan DL的心声...C和C++的复数
complexity of set operation?请教:函数后面的 throw() 有意义么?
关于那个经典的missing number的题 (转载)C++ Q19: throw 3
[合集] 面试问题C & C++ mixing question
C++ head files help~access function static variable
Why should i include .cpp instead of .h请问java应该看什么书
[合集] A question for a C++ interview question想写个简单的 JVM- 用C++还是Java
Question in C++ complex number implementationRe: 这里有人做p2p的么?
相关话题的讨论汇总
话题: gcc话题: qsort话题: libarary话题: complexity
进入Programming版参与讨论
1 (共1页)
l*********s
发帖数: 5409
1
[question] what is the time complexity of qsort in standard c libarary(GCC,
more specifically)? Is is based on quick sort algorithm?
t****t
发帖数: 6806
2
theoretically it's not specified, but usually it's based on quick sort (see
the name). so it's O(NlogN) on average.

,

【在 l*********s 的大作中提到】
: [question] what is the time complexity of qsort in standard c libarary(GCC,
: more specifically)? Is is based on quick sort algorithm?

l*********s
发帖数: 5409
3
Thank you!

see

【在 t****t 的大作中提到】
: theoretically it's not specified, but usually it's based on quick sort (see
: the name). so it's O(NlogN) on average.
:
: ,

f*******n
发帖数: 12623
4
assuming it's quick sort, quick sort is O(n log n) average-case, and O(n^2)
worst-case
d****n
发帖数: 1637
5
That would be only the partial answer.
if the sequence/array to be sorted has very good randomness(pivot good),
then the O(Nlog(N)).
if the array has been almost sorted or bad chose of pivot, the run time
would be O(N^2).
The Glib C qsort is a text-book implementation, which is terrible slow on
sorting on huge data set.
See introsort. or C++ stl::sort if you are looking for a industry solution.
l*********s
发帖数: 5409
6
Thank you! How about qsort in GCC?

【在 d****n 的大作中提到】
: That would be only the partial answer.
: if the sequence/array to be sorted has very good randomness(pivot good),
: then the O(Nlog(N)).
: if the array has been almost sorted or bad chose of pivot, the run time
: would be O(N^2).
: The Glib C qsort is a text-book implementation, which is terrible slow on
: sorting on huge data set.
: See introsort. or C++ stl::sort if you are looking for a industry solution.

1 (共1页)
进入Programming版参与讨论
相关主题
Re: 这里有人做p2p的么?C++ head files help~
How to know # of threads in an app?Why should i include .cpp instead of .h
An algorithm question.[合集] A question for a C++ interview question
an interview problemQuestion in C++ complex number implementation
Ryan DL的心声...C和C++的复数
complexity of set operation?请教:函数后面的 throw() 有意义么?
关于那个经典的missing number的题 (转载)C++ Q19: throw 3
[合集] 面试问题C & C++ mixing question
相关话题的讨论汇总
话题: gcc话题: qsort话题: libarary话题: complexity