median of a list of n numbers
can be found by sorting the listand picking the middle value if nis odd or calculating the mean of the two middle values if nis even
Hashing
The folding method
Divide the digits of the item into equal size pieces (except possibly the last). Then, add the pieces together and take the remainder when the total is divided by the number of slots.
The mid-square method
Square the item. Then, extract the middle digit or middle two digits, depending on whether the number of digits of the squared item is odd or even.Finally, take the remainder when this number is dividedby the number of slots.
open addressing
if a collision occurs, the item is placed in another slot
Linear probing
searches sequentially for the next open slot
Quadratic probing
avoids clustering by adding successive square numbers to the index
chaining
each slot may contain a collection of items, all having the same hash value
Binary search trees
A binary tree (not necessarily complete), such that for every node p, all the keys within p’s left subtree are less than the key of p; and all the keys withinp’s right subtree are greater than the key of p.
Insert to BST
Delete from BST
AVL trees
A self-balancing binary search tree.
height of a tree
number of edges on the longest path from the tree’s root to a leaf, if the tree is non-empty, and −1 otherwise.
A balanced BST
a BST for which the difference in height between any node’s left and right subtree doesn’t exceed 1.
balance factor
calculated by subtracting the height of the node’s right subtree from the height of its left subtree