排序和稳定性

发布于 2024-12-15 12:53:12 字数 142 浏览 5 评论 0原文

我想知道为什么合并排序稳定而快速排序不稳定。 我知道如果相对顺序始终保留,那么它是稳定的。

合并排序不应该仍然打破平局吗?不打平局的话还能稳定吗?

我知道如果快速排序不进行平局打破,它将会不稳定。

你能给我一些例子吗?谢谢

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独﹏钓一江月 2024-12-22 12:53:12

看起来 Stack 已经在另一个线程中找到了答案

快速排序与合并排序

Looks like Stack already has the answer covered in a different thread

Quick Sort Vs Merge Sort

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文