Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

ICS 46 Study Guide – Cheat Sheet

Type of Data Structure Time Complexity/Details


LinkedList O(N) if searching
O(1) if adding to front
O(N) if adding to end with no trailer node
O(1) if adding to end with trailer node
Min-Heap O(log2 N) for insertion, deletion, and search
O(N) if offline (given all values at once)
Arrays O(N) to search
O(1) to insert value at index
Binary Trees O(log2 N) search
O(N) worst case
AVL (Adelson-Velskii and Landis) Trees O(log N) worst case for searching, adding, etc
(Special kind of BST with order and structure
properties)
Digital Trees O(M log N)
Insertion Sort O(N^2) worse case
O(N) best case

Type Time Complexity/Details


HeapSort O(N log2 N)
In-Place
Unstable
Guaranteed to run in O(N log2 N)
Guaranteed to run slowest of O(N log2 N) sorts
Done in place, but not stable.
MergeSort O(N log2 N)
Not in-place (requires an equal sized array)
Stable
Guaranteed to run in O(N log2 N), but typically runs
slower than QuickSort. Not in place, but stable.
QuickSort Best/Average are O(N log2 N)
Worst is O(N^2)
In-place
O(N^2) comparisons and movement worst case, O(N
log 2N) on average.
Unstable
Not guaranteed to run O(N log2 N), with O(N^2) in bad
cases. If choose good pivot, then it will run well.
Can be done in place, but not stable. Uses little space.

You might also like