Implement binary encode/decode with frequency tree | Two Sigma