Dynamic programming Design technique, like divide-and-conquer Example: Longest Common Subsequence (LCs) Given two sequences x[l.. m] and yll.n], find a longest subsequence common to them both a' not the
How large should a hash table be? Goal: Make the table as small as possible but large enough so that it wont overflow(or otherwise become inefficient Problem: what if we don 't know the proper size
ynamic order statistics OS-SELECT(i, S): returns the i th smallest element in the dynamic set S. OS-RANK(, S): returns the rank ofx E S in the sorted order of s s elements IDEA: Use a red-black tree for the set S, but keep subtree sizes in the nodes
a weakness of hashing Problem: For any hash function h, a set of keys exists that can cause the average access time of a hash table to skyrocket An adversary can pick all keys from tkeU: h(k)=i for some slot i IDEA Choose the hash function at random independently of the keys
Order statistics Select the ith smallest of n elements(the element with rank i i=l: minimum, .i=n: marimum, i=L(n+1)/2]or[(n+1)/2 median Naive algorithm: Sort and index ith element Worst-case running time =o(n Ig n)+o(1 o(nIg n using merge sort or heapsort(not quicksort) c 2001 by Charles E Leiserson
Quicksort Proposed by C. A.R. Hoare in 1962 Divide-and-conquer algorithm Sorts“ in place”( like insertion sort, but not like merge sort Very practical(with tuning)