Huffman Tree (Heffman, Hoffman, Huffman tree, optimal binary trees)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.