Difference between revisions of "Template:List data structure comparison"
Jump to navigation
Jump to search
imported>Abionab |
imported>DavidCary (yet another implementation of the "dynamic array" abstract data type) |
||
| Line 8: | Line 8: | ||
![[Self-balancing binary search tree|Balanced tree]] | ![[Self-balancing binary search tree|Balanced tree]] | ||
![[Random access list|Random {{nowrap|access list}}]] | ![[Random access list|Random {{nowrap|access list}}]] | ||
| + | ![[hashed array tree]] | ||
|- | |- | ||
|Indexing | |Indexing | ||
| Line 22: | Line 23: | ||
|doi=10.1145/224164.224187 | |doi=10.1145/224164.224187 | ||
}}</ref> | }}</ref> | ||
| + | |style="background:PaleGreen"|Θ(1) | ||
|- | |- | ||
|{{nowrap|Insert/delete}} at beginning | |{{nowrap|Insert/delete}} at beginning | ||
| Line 29: | Line 31: | ||
|style="background:#ffffdd"|Θ(log n) | |style="background:#ffffdd"|Θ(log n) | ||
|style="background:#ddffdd"|Θ(1) | |style="background:#ddffdd"|Θ(1) | ||
| + | |style="background:Pink"|Θ(''n'') | ||
|- | |- | ||
|{{nowrap|Insert/delete}} at end | |{{nowrap|Insert/delete}} at end | ||
| Line 36: | Line 39: | ||
|style="background:#ffffdd"|Θ(log ''n'') | |style="background:#ffffdd"|Θ(log ''n'') | ||
|style="background:#ffffdd"|Θ(log ''n'') updating | |style="background:#ffffdd"|Θ(log ''n'') updating | ||
| + | |style="background:PaleGreen"|Θ(1) [[Amortized analysis|amortized]] | ||
|- | |- | ||
|{{nowrap|Insert/delete}} in middle | |{{nowrap|Insert/delete}} in middle | ||
| Line 43: | Line 47: | ||
|style="background:#ffffdd"|Θ(log ''n'') | |style="background:#ffffdd"|Θ(log ''n'') | ||
|style="background:#ffffdd"|Θ(log ''n'') updating | |style="background:#ffffdd"|Θ(log ''n'') updating | ||
| + | |style="background:Pink"|Θ(''n'') | ||
|- | |- | ||
|{{nowrap|Wasted space}} (average) | |{{nowrap|Wasted space}} (average) | ||
| Line 50: | Line 55: | ||
|style="background:#ffdddd"|Θ(''n'') | |style="background:#ffdddd"|Θ(''n'') | ||
|style="background:#ffdddd"|Θ(''n'') | |style="background:#ffdddd"|Θ(''n'') | ||
| + | |style="background:LightYellow"|Θ({{sqrt|''n''}}) | ||
|} | |} | ||
</div> | </div> | ||
<noinclude>{{Template reference list}}</noinclude> | <noinclude>{{Template reference list}}</noinclude> | ||
Revision as of 16:29, 10 August 2016
| Linked list | Array | Dynamic array | Balanced tree | Random access list | hashed array tree | |
|---|---|---|---|---|---|---|
| Indexing | Θ(n) | Θ(1) | Θ(1) | Θ(log n) | Θ(log n)[1] | Θ(1) |
| Insert/delete at beginning | Θ(1) | N/A | Θ(n) | Θ(log n) | Θ(1) | Θ(n) |
| Insert/delete at end | Θ(n) when last element is unknown; Θ(1) when last element is known |
N/A | Θ(1) amortized | Θ(log n) | Θ(log n) updating | Θ(1) amortized |
| Insert/delete in middle | search time + Θ(1)[2][3][4] | N/A | Θ(n) | Θ(log n) | Θ(log n) updating | Θ(n) |
| Wasted space (average) | Θ(n) | 0 | Θ(n)[5] | Θ(n) | Θ(n) | Θ(Template:Sqrt) |
References
- ↑ Chris Okasaki (1995). "Purely Functional Random-Access Lists". Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture: 86–95. doi:10.1145/224164.224187.
- ↑ Gerald Kruse. CS 240 Lecture Notes: Linked Lists Plus: Complexity Trade-offs. Juniata College. Spring 2008.
- ↑ Day 1 Keynote - Bjarne Stroustrup: C++11 Style at GoingNative 2012 on channel9.msdn.com from minute 45 or foil 44
- ↑ Number crunching: Why you should never, ever, EVER use linked-list in your code again at kjellkod.wordpress.com
- ↑ Brodnik, Andrej; Carlsson, Svante; Sedgewick, Robert; Munro, JI; Demaine, ED (1999), Resizable Arrays in Optimal Time and Space (Technical Report CS-99-09) (PDF), Department of Computer Science, University of Waterloo