Data structures Flashcards
List/array complexity
Build: n
Insert, delets, find: n
Case: worst
Strengths: Fast look ups, fast appends
Weakness: Fixed inserts and deletes
Sorted array
Build: nlogn
Insert delete, find: log n
case: worst
Stack, queue, deque
Build: n
IDF: 1
case: worst
Strength: Fast operations
Uses: BFS (Queue) DFS(Stack)
Dynamic array
BUild: n
ID: 1
find: log n
case: average
Strengths: Fast lookups, variable size
Weaknesses: Slow worst-case appends. Costly insert and deletes
Heap/Priority queue
Build: n logn
idf: log n
case: worst
Strength: Heap used to implement a priority queue
Hash table
build: n
idf: 1 but in fact m
case: expected
Strengths: Fast Lookups, flexible keys
Weaknesses: Unordered
Skip list
Build: nlogn
idf: logn
case expected
BST
idf: n
case: worst
Strength: Sorted
Weakness: Poor performance if unbalanced.
AVL, Red-Black,B-tree
Build: nlogn
idf: log n
case: worst
Adj list
Build: n_m
id: deg(v)
find vertex: n
find edge(v,w): deg(v)
case: worst
Graph adjacency matrix
: Find vertex: log n
Find edge: n
Case: worst
k-d tree
Build: nlogn
idfL logn
case: worst
Range queries in k-dimensional space
Union-find/disjoin-set
Build: n log n
case: worst
Useful for tracking items that can be partitioned into disjoint sets
Trie
Build: n
idf: m
2d array
Build: nm
case: worst