Big O of clojure library functions

a 夏天 提交于 2019-12-04 05:37:15

Here is a table composed by John Jacobsen and taken from this discussion:

Late to the party here, but I found the link in the comments of the first answer to be more definitive, so I'm reposting it here with a few modifications (that is, english->big-o):


Table Markdown source

On unsorted collections, O(log32n) is nearly constant time, and because 232 nodes can fit in the bit-partitioned trie nodes, this means a worst-case complexity of log32232 = 6.4. Vectors are also tries where the indices are keys.

Sorted collections utilize binary search where possible. (Yes, these are both technically O(log n); including the constant factor is for reference.)

Lists guarantee constant time for operations on the first element and O(n) for everything else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!