A: 10 1
B: 1 1
C: 10000
D: 100 1
Einstein: 0
Female: 1000 1
Tip: Havermann coding is unequal length coding, in order to reduce the repetition of coding. Firstly, the two letters with the lowest probability of occurrence are selected as leaf nodes, and the sum of their keywords is used as keywords to generate new nodes. Then add new nodes to the original set, then select the two nodes with the lowest probability of occurrence (eliminate the used nodes) to generate new nodes, and so on until all nodes are used.
2. Using heap sorting from largest to smallest, first select the largest point as the root of the tree, then select the second largest number as the root node of the left (or right) subtree, and so on.
This problem is a bit troublesome. I can only give you some ideas. What is the algorithm (algorithm and principle) in Baidu Encyclopedia /view/2882 14.htm?
Tip: 1, the weight represents an attribute of an entity. For a heap graph, it refers to the number of edges between its two nodes. For example, when vertices A and B meet on the way, there are six sides.
2. Minimum Spanning Tree means to form a tree (multi-purpose binary tree) by including all vertices with the least number of edges. (one has it? n? The spanning tree of a connected graph with nodes is the smallest connected subgraph of the original graph, which contains all connected subgraphs in the original graph. n? There are nodes and the least edges to keep the graph connected. )?
Of course, this topic also involves the knowledge of graph theory, such as connectivity, accessibility, directed graph and undirected graph, so I won't say more.