Difference between revisions of "Template:List data structure comparison"
Jump to navigation
Jump to search
imported>Pmussler m (Spello) |
("Search" is incorrect term since searching any (unordered) list requires O(n); I think they were referring to accessing an element at an index) |
||
| Line 3: | Line 3: | ||
! !![[Linked list]]!![[Array data structure|Array]]!![[Dynamic array|Dynamic<br />array]]!![[Self-balancing binary search tree|Balanced<br />tree]] | ! !![[Linked list]]!![[Array data structure|Array]]!![[Dynamic array|Dynamic<br />array]]!![[Self-balancing binary search tree|Balanced<br />tree]] | ||
|- | |- | ||
| − | | | + | |Get element at index |
|style="background:#ffdddd"|Θ(''n'') | |style="background:#ffdddd"|Θ(''n'') | ||
|style="background:#ddffdd"|Θ(1) | |style="background:#ddffdd"|Θ(1) | ||
Revision as of 23:26, 21 July 2011
| Linked list | Array | Dynamic array |
Balanced tree | |
|---|---|---|---|---|
| Get element at index | Θ(n) | Θ(1) | Θ(1) | Θ(log n) |
| Insert/delete at beginning | Θ(1) | N/A | Θ(n) | Θ(log n) |
| Insert/delete at end | Θ(1) | N/A | Θ(1) amortized | Θ(log n) |
| Insert/delete in middle | search time + Θ(1)[1] |
N/A | Θ(n) | Θ(log n) |
| Wasted space (average) | Θ(n) | 0 | Θ(n)[2] | Θ(n) |
References
- ↑ Gerald Kruse. CS 240 Lecture Notes: Linked Lists Plus: Complexity Trade-offs. Juniata College. Spring 2008.
- ↑ Brodnik, Andrej; Carlsson, Svante; Sedgewick, Robert; Munro, JI; Demaine, ED (Technical Report CS-99-09), Resizable Arrays in Optimal Time and Space (PDF), Department of Computer Science, University of Waterloo Check date values in:
|date=, |year= / |date= mismatch(help)