没有合适的资源?快使用搜索试试~ 我知道了~
首页数据结构各种算法实现(C++版)
资源详情
资源评论
资源推荐
目 录
目 录..........................................................................................................................................................................................................................................................................................1
1、顺序表.................................................................................................................................................................................................................................................................................1
Seqlist.h.............................................................................................................................................................................................................................................................................1
Test.cpp..............................................................................................................................................................................................................................................................................6
2、 单链表................................................................................................................................................................................................................................................................................8
ListNode.h.........................................................................................................................................................................................................................................................................8
SingleList.h........................................................................................................................................................................................................................................................................9
test.cpp.............................................................................................................................................................................................................................................................................17
3、 双向链表..........................................................................................................................................................................................................................................................................19
NodeList.h.......................................................................................................................................................................................................................................................................19
DoubleList.h....................................................................................................................................................................................................................................................................20
Test.cpp............................................................................................................................................................................................................................................................................28
4、 循环链表..........................................................................................................................................................................................................................................................................30
ListNode.h.......................................................................................................................................................................................................................................................................30
CircularList.h...................................................................................................................................................................................................................................................................31
Test.cpp............................................................................................................................................................................................................................................................................38
5、 顺序栈..............................................................................................................................................................................................................................................................................40
SeqStack.h.......................................................................................................................................................................................................................................................................40
Test.cpp............................................................................................................................................................................................................................................................................43
6、 链式栈..............................................................................................................................................................................................................................................................................44
StackNode.h.....................................................................................................................................................................................................................................................................44
LinkStack.h......................................................................................................................................................................................................................................................................45
Test.cpp............................................................................................................................................................................................................................................................................48
7.顺序队列..............................................................................................................................................................................................................................................................................49
SeqQueue.h......................................................................................................................................................................................................................................................................49
Test.cpp............................................................................................................................................................................................................................................................................53
8、链式队列...........................................................................................................................................................................................................................................................................55
QueueNode.h...................................................................................................................................................................................................................................................................55
LinkQueue.h....................................................................................................................................................................................................................................................................56
Test.cpp............................................................................................................................................................................................................................................................................61
9、优先级队列.......................................................................................................................................................................................................................................................................63
QueueNode.h...................................................................................................................................................................................................................................................................63
Compare.h.......................................................................................................................................................................................................................................................................64
PriorityQueue.h...............................................................................................................................................................................................................................................................66
Test.cpp............................................................................................................................................................................................................................................................................72
10、串.....................................................................................................................................................................................................................................................................................75
MyString.h.......................................................................................................................................................................................................................................................................75
MyString.cpp...................................................................................................................................................................................................................................................................78
test.cpp.............................................................................................................................................................................................................................................................................90
11、二叉树.............................................................................................................................................................................................................................................................................93
BinTreeNode.h................................................................................................................................................................................................................................................................93
BinaryTree.h..................................................................................................................................................................................................................................................................101
Test.cpp..........................................................................................................................................................................................................................................................................114
12、线索二叉树...................................................................................................................................................................................................................................................................117
ThreadNode.h................................................................................................................................................................................................................................................................117
ThreadTree.h..................................................................................................................................................................................................................................................................119
ThreadInorderIterator.h.................................................................................................................................................................................................................................................119
test.cpp...........................................................................................................................................................................................................................................................................131
13、堆...................................................................................................................................................................................................................................................................................133
MinHeap.h.....................................................................................................................................................................................................................................................................133
test.cpp...........................................................................................................................................................................................................................................................................141
14、哈夫曼树.......................................................................................................................................................................................................................................................................142
BinTreeNode.h..............................................................................................................................................................................................................................................................143
BinaryTree.h..................................................................................................................................................................................................................................................................145
MinHeap.h.....................................................................................................................................................................................................................................................................151
Huffman.h......................................................................................................................................................................................................................................................................156
Test.cpp..........................................................................................................................................................................................................................................................................158
15、树...................................................................................................................................................................................................................................................................................159
QueueNode.h.................................................................................................................................................................................................................................................................159
LinkQueue.h..................................................................................................................................................................................................................................................................160
TreeNode.h....................................................................................................................................................................................................................................................................165
Tree.h.............................................................................................................................................................................................................................................................................166
test.cpp...........................................................................................................................................................................................................................................................................185
16、B+树..............................................................................................................................................................................................................................................................................187
BTreeNode.h..................................................................................................................................................................................................................................................................187
BTree.h..........................................................................................................................................................................................................................................................................191
test.cpp...........................................................................................................................................................................................................................................................................216
17、图...................................................................................................................................................................................................................................................................................218
MinHeap.h.....................................................................................................................................................................................................................................................................218
Edge.h............................................................................................................................................................................................................................................................................224
Vertex.h..........................................................................................................................................................................................................................................................................225
Graph.h..........................................................................................................................................................................................................................................................................226
test.cpp...........................................................................................................................................................................................................................................................................252
18、排序...............................................................................................................................................................................................................................................................................254
Data.h.............................................................................................................................................................................................................................................................................255
QueueNode.h.................................................................................................................................................................................................................................................................261
LinkQueue.h..................................................................................................................................................................................................................................................................266
Sort.h..............................................................................................................................................................................................................................................................................271
test.cpp...........................................................................................................................................................................................................................................................................287
数据结构算法实现 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];}
}
~SeqList(){delete[] m_elements;}
int Length() const{ //get the length
1
数据结构算法实现 2008-9-3
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(){return m_ncurrentsize==m_nmaxsize-1;}
Type Get(int i){ //get the ith data
return i<0||i>m_ncurrentsize?(cout<<"can't find the element"<<endl,0):m_elements[i];
}
void Print();
private:
Type *m_elements;
2
剩余63页未读,继续阅读
zzx799548914
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- 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
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0