1. A method for encoding an input sequence of symbols, the method comprising: selecting an encoding tree, based on an estimated probability determined from a context model; and traversing the encoding tree, based on the input sequence of symbols until either a leaf node is reached, and in response, outputting a primary codeword associated with the leaf node, or a flush event occurs while at an internal node of the encoding tree, and in response, outputting a secondary codeword associated with the internal node.