数据结构课程设计报告
};
void ShowNodeBit(LinkList
3.程序的主要流程图
统计每种字符出现的 1 2 输出原文本 输出 Huafuman3 树 4 输出Huafuman密 5 输出译文 6 T F F
输出每个结点的选择要进行的操作 开始 输入字符串 结束 是否继续? 5
数据结构课程设计报告
4.程序的主要模块
#pragma once #include\#include\#include\
template
template
HuaffmanTree
template
HuaffmanTree
this->Root =NULL;
HuaffmanTreeNode
void SetRoot(HuaffmanTreeNode
HuaffmanTreeNode
void Display(HuaffmanTreeNode
void ShowNodeBit(LinkList
public:
并两个结点
6
数据结构课程设计报告
}
template
HuaffmanTreeNode
} else { temp->SetLchild (pb); pb->SetTag (0); temp->SetRchild (pa); pa->SetTag (1); pa->SetFlag (true); pb->SetFlag (true); }
temp->SetData ('0');
temp->SetKey (pa->GetKey ()+pb->GetKey ()); pa->SetParent (temp); pb->SetParent (temp); return temp;
}
template
void HuaffmanTree
HuaffmanTreeNode
pa->SetParent(temp);
*pa,
*temp=new
7
数据结构课程设计报告
pb->SetParent(temp);
if(pa->GetKey()>pb->GetKey()) { temp->SetLchild(pb); pb->SetTag(0); pb->SetFlag(true); temp->SetRchild(pa); pa->SetTag(1); pa->SetFlag(true);
} else { temp->SetLchild(pa); pa->SetTag(0); pa->SetFlag(true); temp->SetRchild(pb); pb->SetTag(1); pb->SetFlag(true); }
L1.Insert (temp); pa=pb->GetNext (); if(pa==NULL) { this->SetRoot (pb); return ;
}
pb=pa->GetNext (); if(!pb) { this->SetRoot(pa); return;
}
}
}
template
void HuaffmanTree
return ;
this->Display(p->GetRchild(),n+1); for(int i=0;i cout<<'\\t'; 8 数据结构课程设计报告 if(p->GetData()=='0') cout< else {cout< this->Display(p->GetLchild(),n+1); } template int *HuaffmanTree HuaffmanTreeNode current=current->GetNext(); } if(current) { while(current->GetParent ()) { s.push(current->GetTag()); current=current->GetParent(); } } int i=0; while(!s.Empty()) { qu.EnQueue (s.pop()); i++; } return integer; } template HuaffmanTreeNode return current; current=current->GetNext(); 9 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库哈夫曼编、译码器(2)在线全文阅读。
相关推荐: