data structure: linked list
list the worst case time complexity for:
insertion, removal, search, access/peak
(what about averages?)
insert: O(1)
- O(n) if sorted
remove: O(n) at position
- O(1) if removing front (maybe a queue)
search: O(n)
access: O(n)
(averages are the same)
data structure: array
list the worst case time complexity for:
insertion, removal, search, access/peak
(what about averages?)
insert: depends
- O(1) if unsorted (and know the index where inserting)
- O(n) if unsorted. if resizing
remove: O(n)
search: O(n)
- O(logn) if sorted
access: O(1)
(averages are all the same)
data structure: stack
list the worst case time complexity for:
insertion, removal, search, access/peak
(what about averages?)
insert: O(1)
remove: O(1)
search: O(n) (but not really applicable)
access: O(n)
- O(1) from the top
(averages are all the same)
data structure: hash table
list the worst case time complexity for:
insertion, removal, search, access/peak
(what about averages?)
insert: O(n)
- avg: O(1)
remove: O(n)
- avg O(1)
search: O(n)
- avg O(1)
access: N/A
data structure: binary search tree
list the worst case time complexity for:
insertion, removal, search, access/peak
(what about averages?)
insert: O(n)
remove: O(n)
search: O(n)
access: O(n)
(averages are O(logn) for all)
data structure: avl tree
list the worst case time complexity for:
insertion, removal, search, access/peak
(what about averages?)
O(logn) for everything
data structure: 2-3 tree / b-tree
list the worst case time complexity for:
insertion, removal, search, access/peak
(what about averages?)
O(logn) for everything
what does a compression map do?
a compression map takes a hash code and maps it into a specific range (to fit in your table)
To minimize collisions, patterns in the keys should NOT…
result in patterns in the hash values
there are two parts of a hash function…
2 properties of a good hash function:
the load factor of a hash table is:
number of entries (n)
—– divided by —–
size of array (N)
collision resolution
what’s the first step?
then what?
what are the 2 collision strategies that we learned?
(two numbers are relatively prime if they share no common divisors other than 1)
acceptable for low load factors ( < 0.75 )
this strategy allows for load factors > 1
in order to achieve the favourable performance a hash table can have, a hash table needs what 3 properties?
a hash table requires:
in a hash table ordered traversal takes _________ time, although this is rarely used for hash tables
O(n logn)
what is a leaf or terminal node?
a node with no children
sibling nodes all have the same _______ node
parent
In a post-order traversal, all ______ nodes are acted on before their _______ node
child, parent
A pre-order traversal is also called a ___________ search
depth-first
A _____ binary tree is one in which every row has the maximum number of nodes
perfect (i think)
a perfect binary tree of height h contains _________ nodes
(what’s the formula)
2^(h+1) − 1
how do you access the parent of a node in a binary heap?
(k-1) / 2
how do you access the left and right child of a node in a binary heap?
left: k * 2 + 1
right: k * 2 + 2