You are on page 1of 1

Data Structures Cheat Sheet

[Data Structures I] [Data Structures II] [Data Structures III] [Data Structures IV] [Data Structures Cheat Sheet]

Search for
remove from remove from Random
add to end insert at middle In-order Access specific Notes
end middle Access
element

Most efficient use of


memory; use in cases
Array O(n) O(n) O(n) O(n) O(1) O(1) O(n) where data size is
fixed.

best case O(1); Implementation is


optimized for speed.
List<T> worst case O(1) O(n) O(n) O(1) O(1) O(n) In many cases, List
O(n) will be the best choice.

best case O(1); List is a better choice,


Collection<T> worst case O(1) O(n) O(n) O(1) O(1) O(n) unless publicly
exposed as API.
O(n)

Many operations are


LinkedList<T> O(1) O(1) O(1) O(1) O(n) O(1) O(n) fast, but watch out for
cache coherency.

best case O(1); Shouldn't be selected


for performance
Stack<T> worst case O(1) N/A N/A N/A N/A N/A reasons, but
O(n) algorithmic ones.

best case O(1); Shouldn't be selected


for performance
Queue<T> worst case O(1) N/A N/A N/A N/A N/A reasons, but
O(n) algorithmic ones.

Although in-order
access time is
best case O(1); best case O(1); constant time, it is
Dictionary<K,T> worst case O(1) worst case O(1) O(1)* O(1)* O(1) usually slower than
other structures due to
O(n) O(n) the over-head of
looking up the key.

You might also like