【问题标题】:Different data structures & Complexities [closed]不同的数据结构和复杂性[关闭]
【发布时间】:2011-01-06 13:37:29
【问题描述】:

我知道这个 wiki link 存在,它具有不同的数据结构。

我想知道是否有一个地方可以让我以简洁的表格格式(供参考)获取复杂性(插入、删除、更新等)。

【问题讨论】:

    标签: language-agnostic data-structures reference complexity-theory


    【解决方案1】:

    您在问题中链接到的页面包含许多数据结构的列表。他们每个人都有一个详细说明特定数据结构的页面。我知道您想要现成格式的比较表,但由于它似乎不存在,因此您可以通过浏览各个页面轻松地将其组合在一起。例如,数组中各种算法的比较给出了here,而对于b-tree,则给出了here。因此,可能需要一些工作才能将其全部编译成一个简单的参考。嗯...也许正在制作一篇博文。

    【讨论】:

    • 这正是我想要避免的。但谁知道这可能很有趣。无论如何,谢谢。
    【解决方案2】:

    它在维基百科上:Worst-case analysis of data structures

    +----------------------+----------+------------+----------+--------------+
    |                      |  Insert  |   Delete   |  Search  | Space Usage  |
    +----------------------+----------+------------+----------+--------------+
    | Unsorted array       | O(1)     | O(1)       | O(n)     | O(n)         |
    | Value-indexed array  | O(1)     | O(1)       | O(1)     | O(n)         |
    | Sorted array         | O(n)     | O(n)       | O(log n) | O(n)         |
    | Unsorted linked list | O(1)*    | O(1)*      | O(n)     | O(n)         |
    | Sorted linked list   | O(n)*    | O(1)*      | O(n)     | O(n)         |
    | Balanced binary tree | O(log n) | O(log n)   | O(log n) | O(n)         |
    | Heap                 | O(log n) | O(log n)** | O(n)     | O(n)         |
    | Hash table           | O(1)     | O(1)       | O(1)     | O(n)         |
    +----------------------+----------+------------+----------+--------------+
    
     * The cost to add or delete an element into a known location in the list
       (i.e. if you have an iterator to the location) is O(1).
       If you don't know the location, then you need to traverse the list to the location of deletion/insertion, which takes O(n) time. 
    ** The deletion cost is O(log n) for the minimum or maximum, O(n) for an arbitrary element.
    

    【讨论】:

      猜你喜欢
      • 2020-01-03
      • 2020-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多