O(n)的排序算法可能吗?算法

2023-09-11 07:29:03 作者:掏粪男孩该吃药i

只是一个简单的算法来小整数排序,但它必须是O(N)。

Just a simple algorithm to sort small integers, but it must be O(n).

推荐答案

一个基数排序是一种方法这是 O(N)。既然你要处理的小整数,应该不会太难实现。

A radix sort is one approach that's O(n). Since you're dealing with small integers, it shouldn't be too hard to implement.