Final Flashcards
(15 cards)
Hashing
Collision
Open Hashing
Closed Hashing
Linear Probing
Upon collision, proceed to next available cell or cycle back to the first cell if the last cell is reached.
Linear Probing - Search
Search according to the hash function, and if another value occupies the expected cell, continue to the next until the expected value or an empty cell is found.
Linear Probing - Problems
Does not work if n (values) > m (keys)
Deletions are not straightforward
B-Tree
Aims to use the hard disk for storage as opposed to RAM. The memory only holds the addresses/pointers to the data.
B-Tree Definitions
A B-tree of order m is an m way tree.
# of keys in each non-leaf node = number of children -1, and keys partition the children like a search tree
All leaves on same level
All non-leaf nodes except root have >= ceil(m/2) children
Root has up to m children
Leaf contains no more than m-1 keys.
M should be odd (so there is a middle key)
Dynamic Programming
Solving problems defined by recurrences with overlapping sub problems.
ex: Fibonnaci sequence
Coin Row Problem
Row of n coins with positive integer values (not distinct)
Pick up maximum money without picking adjacent coins. Solve with dynamic programming
F(n) = max{F(n-2) + nth coin, F(n-1)}
Change Problem
Find the minimum number of coins to reach a total value n.
Blocking pair
Augmenting path
Stable marriage problem