- 1、本文档共322页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据结构各种算法实现(C模板).
目 录
1、顺序表 1
Seqlist.h 1
Test.cpp 7
2、单链表 8
ListNode.h 9
SingleList.h 11
test.cpp 22
3、双向链表 22
NodeList.h 25
DoubleList.h 27
Test.cpp 38
4、循环链表 36
ListNode.h 41
CircularList.h 42
Test.cpp 53
5、顺序栈 49
SeqStack.h 56
Test.cpp 61
6、链式栈 55
StackNode.h 63
LinkStack.h 64
Test.cpp 69
7、顺序队列 62
SeqQueue.h 71
Test.cpp 77
8、链式队列 70
QueueNode.h 79
LinkQueue.h 80
Test.cpp 85
9、优先级队列 77
QueueNode.h 87
Compare.h 88
PriorityQueue.h 90
Test.cpp 97
10、串 88
MyString.h 100
MyString.cpp 102
test.cpp 115
11、二叉树 104
BinTreeNode.h 118
BinaryTree.h 127
Test.cpp 140
12、线索二叉树 126
ThreadNode.h 143
ThreadTree.h 145
ThreadInorderIterator.h 145
test.cpp 157
13、堆 140
MinHeap.h 159
test.cpp 167
14、哈夫曼树 149
BinTreeNode.h 169
BinaryTree.h 172
MinHeap.h 177
Huffman.h 183
Test.cpp 185
15、树 164
QueueNode.h 186
LinkQueue.h 187
TreeNode.h 192
Tree.h 193
test.cpp 212
16、B+树 189
BTreeNode.h 214
BTree.h 218
test.cpp 243
17、图 217
MinHeap.h 246
Edge.h 252
Vertex.h 252
Graph.h 254
test.cpp 279
18、排序 249
Data.h 282
QueueNode.h 289
LinkQueue.h 294
Sort.h 298
test.cpp 315
1、顺序表
Seqlist.h
const int DefaultSize=100;
template typename Type class SeqList{
public:
SeqList(int sz=DefaultSize)
:m_nmaxsize(sz),m_ncurrentsize(-1){
if(sz0){
m_elements=new Type[m_nmaxsize];
}
}
~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(){
return m_ncurrentsize==m_nmaxsize-1;
}
Type Get(int i){ //get the ith data
return i0||im_ncurrentsize?(coutcant find the elementendl,0):m_elements[i];
}
void Print();
private:
Type *m_elements;
const int m_nmaxsize;
int m_ncurrentsize;
};
template typename Type int SeqListType::Find(Type x) const{
for(int i=0;im_ncurrentsize;i++)
if(m_elements[i]==x)
retur
文档评论(0)