- 1、本文档共324页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据结构C算法.
目 录
1、顺序表 1
Seqlist.h 1
Test.cpp 6
2、单链表 8
ListNode.h 8
SingleList.h 10
test.cpp 20
3、双向链表 22
NodeList.h 22
DoubleList.h 24
Test.cpp 34
4、循环链表 36
ListNode.h 36
CircularList.h 37
Test.cpp 47
5、顺序栈 49
SeqStack.h 49
Test.cpp 54
6、链式栈 55
StackNode.h 55
LinkStack.h 56
Test.cpp 60
7、顺序队列 62
SeqQueue.h 63
Test.cpp 68
8、链式队列 70
QueueNode.h 70
LinkQueue.h 71
Test.cpp 75
9、优先级队列 77
QueueNode.h 77
Compare.h 78
PriorityQueue.h 80
Test.cpp 85
10、串 88
MyString.h 88
MyString.cpp 90
test.cpp 101
11、二叉树 104
BinTreeNode.h 104
BinaryTree.h 112
Test.cpp 124
12、线索二叉树 126
ThreadNode.h 126
ThreadTree.h 128
ThreadInorderIterator.h 128
test.cpp 139
13、堆 140
MinHeap.h 140
test.cpp 147
14、哈夫曼树 149
BinTreeNode.h 149
BinaryTree.h 151
MinHeap.h 156
Huffman.h 161
Test.cpp 163
15、树 164
QueueNode.h 164
LinkQueue.h 165
TreeNode.h 169
Tree.h 170
test.cpp 187
16、B+树 189
BTreeNode.h 189
BTree.h 192
test.cpp 215
17、图 217
MinHeap.h 217
Edge.h 222
Vertex.h 223
Graph.h 224
test.cpp 246
18、排序 249
Data.h 249
QueueNode.h 255
LinkQueue.h 259
Sort.h 263
test.cpp 278
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)
return
文档评论(0)