User:Feixie/Algo/ProgrammingPearls

Programming Pearls
Define the problem, choose algorithm, choose data structure. (think more before act) Lazy vector initialization. (trade space with time to initialize vector) Rotate a vector (size n) by m. ( AB -> A'B' -> (A'B')' = BA ) Transpose a matrix on tape. (sequantial reading/writing, no enough member to hold all data) assert, precondition, postcondition sum of subvector related problems. preprocess the vector, generate cummulative vector to help. add v onto elements of vector ranged from l to u, generate the final vector. code tuning: profile to find hotspot, tuning hotspot select m elements from vector (size n) randomly. Utility of heap implementation of sequantial file on disk, read ith node in logN time suffex arrays of a text can solve
 * max sum of subvec
 * subvec whose sum is closest to X
 * extend this skill to two dimention (max sum of sub matrix)
 * random pick + swap
 * select element sequantially with proper probability (with known and unknown vector size)
 * huffman
 * comupte sum of large set of floating point
 * find the million largest of a billion numbers on file
 * disk-based merge sort on large file
 * construct suffex array
 * sort
 * search
 * search substring
 * find max length duplicated substring (or occurs M times)
 * find the longest common substring between two strings