parameters: ( v, p )
return_statement: return codes,treelist[0]
docstring: v - list of symbols. p - list of corresponding probabilities for symbol
docstring_summary: v - list of symbols. p - list of corresponding probabilities for symbol
docstring_tokens: v - list of symbols . p - list of corresponding probabilities for symbol
function: def huffman( v, p ):
      """ v - list of symbols. p - list of corresponding probabilities for symbol """
      assert sum(p) >= 0.99,"Sum of p = %g"%sum(p)
      treelist = [Tree(vv,pp) for vv,pp in zip(v,p)]
      while len(treelist) > 1:
          huffman_reduce(treelist)
      assert len(treelist) == 1
      codes = {}
      huffman_get_codes(codes,treelist[0],0,'')
      return codes,treelist[0]
function_tokens: def huffman ( v , p ) : assert sum ( p ) >= 0.99 , "Sum of p = %g" % sum ( p ) treelist = [ Tree ( vv , pp ) for vv , pp in zip ( v , p ) ] while len ( treelist ) > 1 : huffman_reduce ( treelist ) assert len ( treelist ) == 1 codes = { } huffman_get_codes ( codes , treelist [ 0 ] , 0 , '' ) return codes , treelist [ 0 ]