Design an efficient algorithm to sort 5 distinct keys in fewer than 8 comparisons

前端 未结 13 1410
轮回少年
轮回少年 2020-12-01 11:30

Design an efficient algorithm to sort 5 distinct - very large - keys less than 8 comparisons in the worst case. You can\'t use radix sort.

13条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 11:51

    According to Wikipedia:

    Determining the exact number of comparisons needed to sort a given number of entries is a computationally hard problem even for small n, and no simple formula for the solution is known."

    Presumably this means there is no known tractable (efficient) algorithm for determining an exactly optimal comparison sort.

提交回复
热议问题