convenience of explanation this step doesn't exactly follow Vitter's algorithm, but the effects are equivalent. Step 4: Go to leaf node 253. Notice we have two blocks with weight 1. Node 253 and 254 is one block (consisting of leaves), node 255 is another block (consisting of internal nodes). For node 253, the biggest number in its block is 254, so swap the weights and symbols of nodes 253 and 254. Now node 254 and the branch starting from node 255 satisfy the SlideAndIncrement condition and hence must be swapped. At last increase node 255 and 256's weight. Future code for "b" is 1, and for "a" is now 01, which reflects their frequency. References Vitter's original paper: J. S. Vitter, "Design and Analysis of Dynamic Huffman Codes", Journal of the ACM, 34(4), October 1987, pp 825–845. J. S. Vitter, "ALGORITHM 673 Dynamic Huffman Coding", ACM Transactions on Mathematical Software, 15(2), June 1989, pp 158–167. Also appears in Collected Algorithms of ACM. Donald E. Knuth, "Dynamic Huffman Coding", Journal of Algorithm, 6(2), 1985, pp 163–180. External links University of California Dan Hirschberg site Cardiff University Dr. David Marshall site C implementation of Vitter algorithm Excellent description from Duke University Lossless compression algorithms