文件名称:Huffman-tree
介绍说明--下载内容均来自于网络,请自行研究使用
数据结构
1、算法思路:
哈夫曼树算法:a)根据给定的n个权值{W1,W2… ,Wn }构成 n棵二叉树的集合F={T1,T2…,T n },其中每棵二叉树T中只有一个带权为W i的根结点,其左右子树均空;b)在F中选取两棵根结点的权值最小的树作为左右子树构造一棵新的二叉树,且置新的二叉树的根结点的权值为其左、右子树上结点的权值之和;c)F中删除这两棵树,同时将新得到的二叉树加入F中; d)重复b)和c),直到F只含一棵树为止。
-Data Structure 1, Algorithm idea: Huffman tree algorithm: a) in accordance with a given value of n of the right (W1, W2 ..., Wn) constitute a set of n binary tree trees F = (T1, T2 ..., T n) , which for each binary tree T with only one right for the W i of the root node, its about subtree are empty b) in the F 2 in the root node of the right to select the smallest value of the tree as a subtree structure around a new binary tree, binary tree and the new home of the root node of the right value for the left and right sub-tree nodes and the right value c) F in the deletion of the two trees, at the same time obtained by adding a new binary tree F in d) repeat b) and c), until a tree F containing only so far.
1、算法思路:
哈夫曼树算法:a)根据给定的n个权值{W1,W2… ,Wn }构成 n棵二叉树的集合F={T1,T2…,T n },其中每棵二叉树T中只有一个带权为W i的根结点,其左右子树均空;b)在F中选取两棵根结点的权值最小的树作为左右子树构造一棵新的二叉树,且置新的二叉树的根结点的权值为其左、右子树上结点的权值之和;c)F中删除这两棵树,同时将新得到的二叉树加入F中; d)重复b)和c),直到F只含一棵树为止。
-Data Structure 1, Algorithm idea: Huffman tree algorithm: a) in accordance with a given value of n of the right (W1, W2 ..., Wn) constitute a set of n binary tree trees F = (T1, T2 ..., T n) , which for each binary tree T with only one right for the W i of the root node, its about subtree are empty b) in the F 2 in the root node of the right to select the smallest value of the tree as a subtree structure around a new binary tree, binary tree and the new home of the root node of the right value for the left and right sub-tree nodes and the right value c) F in the deletion of the two trees, at the same time obtained by adding a new binary tree F in d) repeat b) and c), until a tree F containing only so far.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
实验5 中序线索二叉树和哈夫曼树.doc