全文预览

上海交大数据结构实验报告

上传者:苏堤漫步 |  格式:doc  |  页数:14 |  大小:261KB

文档介绍
blic Node rchild;Р }Р public Form1()Р {Р ponent();Р }Р private Dictionary<char, string> dictcode = new Dictionary<char, string>();Р private Node huffTree;Р private parisonNode(Node n1, Node n2)Р {Р return (int)(n1.prioirry - n2.prioirry);Р }Р private string encode(string str)Р {Р dictcode.Clear();Р huffTree = null;Р if (string.IsNullOrEmpty(str))Р {Р return "";Р }Р Dictionary<char, uint> priorityQueue = new Dictionary<char, uint>();Р for (int i = 0; i < str.Length; i++)Р {Р if (priorityQueue.ContainsKey(str[i]))Р {Р priorityQueue[str[i]]++;Р }Р elseР {Р priorityQueue.Add(str[i], 1);Р }Р }Р List<Node> listpc = new List<Node>();Р foreach (var item in priorityQueue)Р {Р listpc.Add(new Node()Р {Р prioirry = item.Value, lchild = null, rchild = null, code = item.KeyР });Р }Р listpc.parisonNode);

收藏

分享

举报
下载此文档