Advertisement
Guest User

sample

a guest
Apr 4th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1.     if node_lst[root_index].r_type != 0 and node_lst[root_index].l_type != 0:
  2.         last_huff = HuffmanTree()
  3.         last_huff.right = generate_tree_postorder(node_lst[:-1], root_index - 1)
  4.         index_jump = #TODO CALL YOUR LENGTH FUNCTION HERE
  5.         last_huff.left = generate_tree_postorder(node_lst[:-index_jump - 1], root_index - 1 - index_jump)
  6.         return last_huff
  7.     elif node_lst[root_index].l_type != 0 and node_lst[root_index].r_type == 0:
  8.         last_huff = HuffmanTree()
  9.         last_huff.right = HuffmanTree(node_lst[root_index].r_data)
  10.         last_huff.left = generate_tree_postorder(node_lst[:-1], root_index - 1)
  11.         return last_huff
  12.     elif node_lst[root_index].r_type != 0 and node_lst[root_index].l_type == 0:
  13.         last_huff = HuffmanTree()
  14.         last_huff.left = HuffmanTree(node_lst[root_index].l_data)
  15.         last_huff.right = generate_tree_postorder(node_lst[:-1], root_index - 1)
  16.         return last_huff
  17.     else:
  18.         last_huff = HuffmanTree()
  19.         last_huff.left = HuffmanTree(node_lst[root_index].l_data)
  20.         last_huff.right = HuffmanTree(node_lst[root_index].r_data)
  21.         return last_huff
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement