Data Structures - Chapter 5 Trees - Huffman Trees

data structure


⚡️Data Structures-Chapter 1
⚡️Abstract Data Type Case
⚡️Data Structures-Chapter 2(1)-Linear Structures
⚡️Data Structures-Chapter 2(2)-Sequential Representation and Implementation of Linear Tables
⚡️Data Structures-Chapter 2 (3) - Sequence table (with code)
⚡️ Data structure - Chapter 2 (4) - Case of sequence table (with code)
⚡️ Data structure - Chapter 2 (5) - Chained storage structure
⚡️ Data structure - Chapter 2 (6) - Implementation of basic operations of singly linked list
⚡️ Data structure - Chapter 2 (7) - Doubly linked list and circular linked list

Huffman tree

  Given NNN weights asNNN leaf nodes, construct a binary tree, if the weighted path length of the tree reaches the minimum, such a binary tree is called the optimal binary tree, also known as Huffman Tree(Huffman Tree) (Huffman Tree)( H u f f m a n T r e e ) . The Huffman tree is the tree with the shortest weighted path length, and the node with the larger weight is closer to the root.
insert image description here
insert image description here
insert image description here

Basic Concepts of Huffman Trees

insert image description here
insert image description here
  Weight is also known as weight: assign a node in the tree to a value with a certain meaning, (the specific meaning is determined according to the occasion of the tree use), then this value is called the weight of the node. For example, in the judgment tree mentioned above, 5% represents the proportion of people in the corresponding score segment in the total number of people.

  Weighted path length of a node: The product of the length of the path from the root node to this node and the weight on the node.
insert image description here
insert image description here
Induce Huffman tree
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Huffman tree construction algorithm

insert image description here

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Huffman tree - adopts sequential storage structure

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Huffman coding

Huffman coding idea

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

insert image description here
insert image description here

Encoding and decoding of files

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Summarize

I look forward to your communication with me, leave a message or private message, learn together and make progress together!

Guess you like

Origin blog.csdn.net/CltCj/article/details/122560166