Content deleted Content added
Jorge Stolfi (talk | contribs) →Asymptotic worst-case analysis: (1) unlink repeated links, per WP custom; (2) separate unsorted array from value-indexed one; (3) delete for unsorted array is O(1) |
|||
Line 25:
====Asymptotic worst-case analysis====
In this table, the [[big-O notation|notation O(''f''(''n'')]] means "
{| class="wikitable"
Line 36:
! Space usage
|-
| Unsorted [[Array data structure|
| [[
| O(1)
| [[Linear time|O(''n'')]] | O(''n'')
| O(n)
|-
| Value-indexed array
| O(1)
| O(1)
| O(1)
| O(''n'')
| O(''n'')
|-
| Sorted Array
|
|
| [[Logarithmic time|O(log ''n'')]]
|
| O(''n'')
|-
| Unsorted [[Linked list]]
|
|
|
|
| O(''n'')
|-
| Sorted linked list
|
|
|
|
| O(''n'')
|-
| [[Self-balancing binary tree]]
|
|
|
|
| O(n)
|-
| [[Heap (data structure)|Heap]]
|
| O(log ''n'')<ref>
|
|
| O(''n'')
|-
| [[Hash table]]
|
|
|
| O(''n'')
| O(''n'')
|}
This table is only an approximate summary; for each data structure there are special situations and variants that may lead to different costs.
== Footnotes ==
|