【问题标题】:Sort algorithm that sorts according to original index根据原始索引排序的排序算法
【发布时间】:2016-09-10 07:22:32
【问题描述】:

任何sort algorithms 是否对给定的整数数组进行排序,这样在a[i]=a[j] 的情况下,如果i>j 则认为a[i]>a[j]

【问题讨论】:

  • 你写的那个是这样做的。
  • 是的。你想要一个所谓的稳定排序算法。

标签: arrays algorithm sorting quicksort


【解决方案1】:

您可能正在寻找稳定的排序算法。稳定的排序算法保持具有相同键(即值)的记录的相对顺序。 概念解释 - https://en.wikipedia.org/wiki/Sorting_algorithm#Stability

稳定的算法 - https://en.wikipedia.org/wiki/Sorting_algorithm#Comparison_of_algorithms

【讨论】:

    【解决方案2】:

    排序算法定义了对输入进行排序的一般步骤。此类边缘情况由实际实现处理,具体取决于用户的要求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      • 2018-12-13
      • 2017-03-19
      • 2010-09-17
      • 1970-01-01
      • 2012-02-29
      相关资源
      最近更新 更多