Difference between revisions of "Template:List data structure comparison"
Jump to navigation
Jump to search
imported>Pmussler |
imported>Pmussler m (Spello) |
||
| Line 15: | Line 15: | ||
|style="background:#ffffdd"|Θ(log n) | |style="background:#ffffdd"|Θ(log n) | ||
|- | |- | ||
| − | |Insert/ | + | |Insert/delete at end |
|style="background:#ddffdd"|Θ(1) | |style="background:#ddffdd"|Θ(1) | ||
|{{n/a}} | |{{n/a}} | ||
| Line 21: | Line 21: | ||
|style="background:#ffffdd"|Θ(log n) | |style="background:#ffffdd"|Θ(log n) | ||
|- | |- | ||
| − | |Insert/ | + | |Insert/delete in middle |
|style="background:#ddffdd"|search time +<br/>Θ(1)<ref>Gerald Kruse. [http://www.juniata.edu/faculty/kruse/cs240/syllabus.htm CS 240 Lecture Notes]: [http://www.juniata.edu/faculty/kruse/cs240/linkedlist2.htm Linked Lists Plus: Complexity Trade-offs]. Juniata College. Spring 2008.</ref> | |style="background:#ddffdd"|search time +<br/>Θ(1)<ref>Gerald Kruse. [http://www.juniata.edu/faculty/kruse/cs240/syllabus.htm CS 240 Lecture Notes]: [http://www.juniata.edu/faculty/kruse/cs240/linkedlist2.htm Linked Lists Plus: Complexity Trade-offs]. Juniata College. Spring 2008.</ref> | ||
|{{n/a}} | |{{n/a}} | ||
Revision as of 22:28, 1 July 2011
| Linked list | Array | Dynamic array |
Balanced tree | |
|---|---|---|---|---|
| Search | Θ(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)