排序和稳定性
我想知道为什么合并排序稳定而快速排序不稳定。 我知道如果相对顺序始终保留,那么它是稳定的。
合并排序不应该仍然打破平局吗?不打平局的话还能稳定吗?
我知道如果快速排序不进行平局打破,它将会不稳定。
你能给我一些例子吗?谢谢
I would like to know why merge sort is stable and quick sort is not.
I know if the relative order is preserved all the time then it's stable.
shouldn't merge sort still do tie breaking? will it be still stable when it doesn't do tie breaking?
I understand quick sort will be unstable if it doesn't do tie breaking.
can u give me some examples? thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 Stack 已经在另一个线程中找到了答案
快速排序与合并排序
Looks like Stack already has the answer covered in a different thread
Quick Sort Vs Merge Sort