The growth of encode
is t * d where t is the number of tokens at particular tree level and
d is the height / depth of the tree.
For a tree of n tokens
1 <= t <= n and so the growth of searching for a token t is O(n)
(balanced) log2n <= d <= n-1 (unbalanced) which is growth O(n)
The overall is encode is O(n2)