没有合适的资源?快使用搜索试试~ 我知道了~
首页数据结构各种算法实现(C++模板)
数据结构各种算法实现(C++模板)
需积分: 30 9 下载量 94 浏览量
更新于2023-03-16
评论
收藏 707KB DOC 举报
数据结构各种算法实现(C++模板) 顺序表 单链表 双向链表 循环链表 顺序栈 链式栈 顺序队列 链式队列 优先级队列 串 二叉树 线索二叉树 堆 哈夫曼树 树 B+树 图 排序
资源详情
资源评论
资源推荐
目 录
目 录..........................................................................................................................................................................................................................................................................................1
1、顺序表.................................................................................................................................................................................................................................................................................1
Seqlist.h.............................................................................................................................................................................................................................................................................1
Test.cpp..............................................................................................................................................................................................................................................................................7
2、 单链表................................................................................................................................................................................................................................................................................9
ListNode.h.........................................................................................................................................................................................................................................................................9
SingleList.h......................................................................................................................................................................................................................................................................11
test.cpp.............................................................................................................................................................................................................................................................................22
3、 双向链表..........................................................................................................................................................................................................................................................................25
NodeList.h.......................................................................................................................................................................................................................................................................25
DoubleList.h....................................................................................................................................................................................................................................................................27
Test.cpp............................................................................................................................................................................................................................................................................37
4、 循环链表..........................................................................................................................................................................................................................................................................40
ListNode.h.......................................................................................................................................................................................................................................................................40
CircularList.h...................................................................................................................................................................................................................................................................41
Test.cpp............................................................................................................................................................................................................................................................................52
5、 顺序栈..............................................................................................................................................................................................................................................................................55
SeqStack.h.......................................................................................................................................................................................................................................................................55
Test.cpp............................................................................................................................................................................................................................................................................60
6、 链式栈..............................................................................................................................................................................................................................................................................61
StackNode.h.....................................................................................................................................................................................................................................................................62
LinkStack.h......................................................................................................................................................................................................................................................................63
Test.cpp............................................................................................................................................................................................................................................................................67
7.顺序队列..............................................................................................................................................................................................................................................................................69
SeqQueue.h......................................................................................................................................................................................................................................................................70
Test.cpp............................................................................................................................................................................................................................................................................75
8、链式队列...........................................................................................................................................................................................................................................................................77
QueueNode.h...................................................................................................................................................................................................................................................................77
LinkQueue.h....................................................................................................................................................................................................................................................................78
Test.cpp............................................................................................................................................................................................................................................................................83
9、优先级队列.......................................................................................................................................................................................................................................................................85
QueueNode.h...................................................................................................................................................................................................................................................................85
Compare.h.......................................................................................................................................................................................................................................................................86
PriorityQueue.h...............................................................................................................................................................................................................................................................88
Test.cpp............................................................................................................................................................................................................................................................................94
10、串.....................................................................................................................................................................................................................................................................................97
MyString.h.......................................................................................................................................................................................................................................................................97
MyString.cpp.................................................................................................................................................................................................................................................................100
test.cpp...........................................................................................................................................................................................................................................................................112
11、二叉树...........................................................................................................................................................................................................................................................................115
BinTreeNode.h...............................................................................................................................................................................................................................................................115
BinaryTree.h..................................................................................................................................................................................................................................................................124
Test.cpp..........................................................................................................................................................................................................................................................................137
12、线索二叉树...................................................................................................................................................................................................................................................................139
ThreadNode.h................................................................................................................................................................................................................................................................139
ThreadTree.h..................................................................................................................................................................................................................................................................141
ThreadInorderIterator.h.................................................................................................................................................................................................................................................142
test.cpp...........................................................................................................................................................................................................................................................................153
13、堆...................................................................................................................................................................................................................................................................................155
MinHeap.h.....................................................................................................................................................................................................................................................................155
test.cpp...........................................................................................................................................................................................................................................................................163
14、哈夫曼树.......................................................................................................................................................................................................................................................................165
BinTreeNode.h..............................................................................................................................................................................................................................................................165
BinaryTree.h..................................................................................................................................................................................................................................................................168
MinHeap.h.....................................................................................................................................................................................................................................................................173
Huffman.h......................................................................................................................................................................................................................................................................178
Test.cpp..........................................................................................................................................................................................................................................................................180
15、树...................................................................................................................................................................................................................................................................................181
QueueNode.h.................................................................................................................................................................................................................................................................182
LinkQueue.h..................................................................................................................................................................................................................................................................183
TreeNode.h....................................................................................................................................................................................................................................................................187
Tree.h.............................................................................................................................................................................................................................................................................188
test.cpp...........................................................................................................................................................................................................................................................................207
16、B+树..............................................................................................................................................................................................................................................................................209
BTreeNode.h..................................................................................................................................................................................................................................................................209
BTree.h..........................................................................................................................................................................................................................................................................213
test.cpp...........................................................................................................................................................................................................................................................................238
17、图...................................................................................................................................................................................................................................................................................240
MinHeap.h.....................................................................................................................................................................................................................................................................241
Edge.h............................................................................................................................................................................................................................................................................246
Vertex.h..........................................................................................................................................................................................................................................................................247
Graph.h..........................................................................................................................................................................................................................................................................248
test.cpp...........................................................................................................................................................................................................................................................................274
18、排序...............................................................................................................................................................................................................................................................................277
Data.h.............................................................................................................................................................................................................................................................................277
QueueNode.h.................................................................................................................................................................................................................................................................284
LinkQueue.h..................................................................................................................................................................................................................................................................288
Sort.h..............................................................................................................................................................................................................................................................................293
test.cpp...........................................................................................................................................................................................................................................................................309
数据结构算法实现 2008-9-3
1、顺序表
Seqlist.h
const int DefaultSize=100;
template <typename Type> class SeqList{
public:
SeqList(int sz=DefaultSize)
:m_nmaxsize(sz),m_ncurrentsize(-1){
if(sz>0){
m_elements=new Type[m_nmaxsize];
}
1
数据结构算法实现 2008-9-3
}
~SeqList(){
delete[] m_elements;
}
int Length() const{ //get the length
return m_ncurrentsize+1;
}
int Find(Type x) const; //find the position of x
int IsElement(Type x) const; //is it in the list
int Insert(Type x,int i); //insert data
int Remove(Type x); //delete data
int IsEmpty(){
return m_ncurrentsize==-1;
}
int IsFull(){
2
剩余63页未读,继续阅读
pwm1987
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- stc12c5a60s2 例程
- Android通过全局变量传递数据
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0