Content deleted Content added
Dalton Quinn (talk | contribs) Added balancing speed to the table to distinguish between data structures that would otherwise appear similar. |
|||
Line 34:
! Insert
! Delete
! Balance
! Get at index
! Search
! Find
! Find maximum
! Space usage
|-
Line 42 ⟶ 44:
| [[Linear time|O(''n'')]]
| O(''n'')
|
| N/A
| O(''n'')
| O(''n'')
| O(''n'')
Line 48 ⟶ 52:
|-
| [[Sorted array]]
| O(''n'')
| O(''n'')
| O(''n'')
| O(1)
| O(log ''n'')
| O(1)
| O(1)
| O(''n'')
|-
| Unsorted [[linked list]]
| O(1)<sup>
| O(1)< | N/A
| O(''n'')
| O(''n'')
| O(''n'')
Line 64 ⟶ 72:
|-
| Sorted linked list
| O(1)
| O(1)
| O(''n'')
| O(''n'')
| O(''n'')
| O(1)
| O(''n'')
| O(''n'')
|-
| [[Self-balancing binary tree]]
| O(log ''n'')
| O(log ''n'')
| O(log ''n'')
| N/A
| O(log ''n'')
| O(log ''n'')
| O(log ''n'')
Line 81 ⟶ 93:
| [[Heap (data structure)|Heap]]
| O(log ''n'')
| O(log ''n'')
| O(log ''n'')
| N/A
| O(''n'')
| O(1)
| O(''n'')
| O(''n'')
|-
Line 90 ⟶ 104:
| O(1)
| O(1)
| O(''n'')
| N/A
| O(1)
| O(''n'')
| 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. Also two or more data structures can be combined to obtain lower costs.
|