关于qsort库函数的问题 [英] question on qsort library function

查看:76
本文介绍了关于qsort库函数的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

稳定的qsort是什么意思?

What is meant by stable qsort ?

推荐答案

在文章< 11 ********** ************@n33g2000cwc.googlegroups .com> ;,
su ************** @ yahoo.com ,印度< su ************** @ yahoo.comwrote:
In article <11**********************@n33g2000cwc.googlegroups .com>,
su**************@yahoo.com, India <su**************@yahoo.comwrote:

> stable qsort是什么意思?
>What is meant by stable qsort ?



一个稳定的排序算法是保持比较相等的

项的顺序。 C'的qsort()不保证这样做。


- Richard

-

"考虑应该在一些字母表中需要多达32个字符

- X3.4,1963。

A stable sort algorithm is one which leaves unchanged the order of
items that compare equal. C''s qsort() is not guaranteed to do this.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.


" su ************** @ yahoo.com,India"写道:
"su**************@yahoo.com, India" wrote:

>

stable qsort是什么意思?
>
What is meant by stable qsort ?



如果qsort是通过quicksort实现的,那就不稳定了。稳定

表示输出中输出的等号键出现在输出中。

。稳定的O(nLOGn)排序是mergesort。


-

Chuck F(cinefalconer at maineline dot net)

可用用于咨询/临时嵌入式和系统。

< http://cbfalconer.home.att.net>

If qsort is implemented via quicksort, it is not stable. Stable
means that equal keys appear in the output in the order in which
they appeared in the input. A stable O(nLOGn) sort is mergesort.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


CBFalconer < cb ******** @ yahoo.comwrites:
CBFalconer <cb********@yahoo.comwrites:

" su ************** @ yahoo.com,印度写道:
"su**************@yahoo.com, India" wrote:

> stable qsort是什么意思?
>What is meant by stable qsort ?



如果qsort是通过quicksort实现的,那就不稳定了。稳定

表示输出中输出的等号键出现在输出中。

。稳定的O(nLOGn)排序是mergesort。


If qsort is implemented via quicksort, it is not stable. Stable
means that equal keys appear in the output in the order in which
they appeared in the input. A stable O(nLOGn) sort is mergesort.



Quicksort的变种是稳定的(在
速度下需要付出一些代价)。


请注意,标准中没有暗示qsort()是Quicksort算法的

实现;它甚至可能是Bubblesort

或Bogosort的一个充分反常的实现。你可以合理地期望qsort()使用O(n log n)算法。 (如果你很好奇,你甚至可以通过在你的compar()例程中添加

跟踪代码来调查其内部行为。)

(嗯,我想知道为什么它叫做比较()而不是比较()。

历史原因,我想。)


-

Keith Thompson(The_Other_Keith) ks***@mib.org < http: //www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *< http://users.sdsc.edu/~kst>

" ;我们必须做点什么。这是事情。因此,我们必须这样做。

- Antony Jay和Jonathan Lynn,是部长

There are variants of Quicksort that are stable (at some cost in
speed).

Note that there is no implication in the standard that qsort() is an
implementation of the Quicksort algorithm; it could even be Bubblesort
or Bogosort in a sufficiently perverse implementation. You can
reasonably expect qsort() to use an O(n log n) algorithm. (If you''re
curious, you can even investigate its internal behavior by adding
tracing code to your compar() routine.)

(Hmm, I wonder why it''s called compar() rather than compare().
Historical reasons, I suppose.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


这篇关于关于qsort库函数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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