final Flashcards
mapping ADT
refers to items by a key rather than their index
hashing
a hash function converts a key to an index; try f(x) = x % (# of keys)
hash collision
keys hash to the same integer, potentially overwriting existing values
runtime: mapping with mod hashing
put - O(n); get - O(n)
load factor
values hash function produces / entries currently in table;
capacity / entries;
minimal empty slots
runtime: mapping with rehashing
put - O(1); get - O(1)
mapping with dictionaries
dictionaries support O(1) for put and get, regardless of n
only immutable built-ins can be keys, meaning:
only tuples and strings can be keys
sets
cannot be hashed
tree
hierarchal collection of nodes
root
top node of a tree
children
any node with a node above it
parent
any node with a node below it
edge
connections between two vertices; connect nodes in a graph
path
series of edges connecting two nodes
path length
number of edges in a path
depth
length of path from a node to the root
height
maximum depth of any node in a tree
descendants
all nodes for which there is a path from x’
ancestors
all nodes which x is a descendant of
subtree
node x and its descendents; where x is not the parent node of the original tree
binary tree
nodes of a graph;
often stored as a set
binary search tree
binary tree where all the descendants to the left are less and all the descendants to the right are greater
graph - mathematic
a set of vertices V and a set of edges E: G(V, E)