Huffman Tree (Heffman, Hoffman, Huffman tree, optimal binary trees)
Flyfish 2015-8-1
Huffman tree because of the different translation so there are other names Heffman, Hoffman, Huffman tree
Define reference from Min data structure
Path
A branch from one node in the tree to another node forms a path between two nodes.
Path Length
The number of branches on the path is called the path length.
the path length of the tree
The path length of a tree is the sum of the length of the path from the root node to each node.
the length of the belt-weighted path of the node
The length of a node's weighted path is the product of the length of the path from the node to the root and the right of the nodes.
the length of the tree with weighted path
The tree's weighted path length is the sum of the weighted path lengths of all leaf nodes in the tree, usually written as WPL.
Huffman Tree
Suppose there are n weights { w 1 , w 2 ,... .. w n }, construct a two-fork tree with n leaf nodes, each with a right to the leaf knot. < Span class= "Mrow" id= "mathjax-span-187" > w i Span style= "Display:inline-block; width:0px; Height:2.279em; " > , the two-wpl tree with the minimum length of the weighted path is called the Huffman Tree.
Suppose that there is a string with each character appearing as follows
A:5
B:15
C:40
D:30
E:10
Order characters to form an ordered sequence from small to large in number of occurrences
Bottom-up process
The first step
Step Two
Step Three
Fourth Step
Construction complete
Concept Supplement
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Huffman Tree (Heffman, Hoffman, Huffman tree, optimal binary trees)