The Kth order statics of n elements is the Kth smallest element of array.Order Statistics
1) m<-ceiling(n/5) 2) for i=1 to m 3) do sort array A[5i-4,min(5i,r)] 4) A1[i]<-median of A[5i-4,min(5i,r)] 5) return select(A1,1,m,m/2)
Huffman coding is a greedy algorithm.It compresses data by using fewer bits to encode more frequently occuring characters so that not all characters are encoded with 8 bits.HUFFMAN CODING TREES
We than determine the two vertices of lowest frequency and replace them with a tree whose root is labled with the sum of these two frequencies and whose two childern are the two vertices that are replaced.We repeatedly do this until single tree left.
Huffman coding tree always produce a variable length code with minimum description length for that string.
Huffman(c)
1) n<-|c| 2) q<-c 3) for i<-1 to n-1 4) do allocate a new node z 5) left[z]<-x<-Extract-min(q) 6) right[z]<-y<-Extract-min(q) 7) f[z]<-f[x]+f[y] 8) insert(q,z) 9) return Extract-min(q)
T(n)=T(m)+O(n) m<-1 to n-1 -> E[T(n)]=E[T(m)]+O(n) -> E[1/n (T(1)+T(2)+.......+T(n-1)]+O(n) -> cn2/n+O(n) -> cn+O(n)For more details refer to the following link.