【问题标题】:How to implement counting sort (O(n)) using list in OCaml?如何使用 OCaml 中的列表实现计数排序 (O(n))?
【发布时间】:2013-04-14 09:53:44
【问题描述】:

Counting sort 使用数组并且如果被排序的数字在已知范围内,则可以具有 O(n) 性能。

但是是否可以仅在 OCaml 中使用 list 实现计数排序?

我的直觉是可以在不使用可变数组的情况下使用listmap 模拟counting sort,但性能不会是O(n)。

如果是这样,counting sort 在不使用可变事物的情况下真的可以帮助 OCaml 应用程序处理任何事情吗?

【问题讨论】:

    标签: sorting functional-programming ocaml


    【解决方案1】:

    我相信,是的,没有数组就不可能实现 O(n) 计数排序。你在问什么?

    【讨论】:

    • 我在问If so, does counting sort really help OCaml application with anything under the context of not using mutable things?
    猜你喜欢
    • 2015-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-18
    • 2013-02-12
    • 2011-11-10
    • 2015-12-16
    • 2015-01-01
    相关资源
    最近更新 更多