logo资料库

数据结构各种算法实现(C++).doc

第1页 / 共321页
第2页 / 共321页
第3页 / 共321页
第4页 / 共321页
第5页 / 共321页
第6页 / 共321页
第7页 / 共321页
第8页 / 共321页
资料共321页,剩余部分请下载后查看
目 录
1、顺序表
Seqlist.h
Test.cpp
2、单链表
ListNode.h
SingleList.h
test.cpp
3、双向链表
NodeList.h
DoubleList.h
Test.cpp
4、循环链表
ListNode.h
CircularList.h
Test.cpp
5、顺序栈
SeqStack.h
Test.cpp
6、链式栈
StackNode.h
LinkStack.h
Test.cpp
7.顺序队列
SeqQueue.h
Test.cpp
8、链式队列
QueueNode.h
LinkQueue.h
Test.cpp
9、优先级队列
QueueNode.h
Compare.h
PriorityQueue.h
Test.cpp
10、串
MyString.h
MyString.cpp
test.cpp
11、二叉树
BinTreeNode.h
BinaryTree.h
Test.cpp
12、线索二叉树
ThreadNode.h
ThreadTree.h
ThreadInorderIterator.h
test.cpp
13、堆
MinHeap.h
test.cpp
14、哈夫曼树
BinTreeNode.h
BinaryTree.h
MinHeap.h
Huffman.h
Test.cpp
15、树
QueueNode.h
LinkQueue.h
TreeNode.h
Tree.h
test.cpp
16、B+树
BTreeNode.h
BTree.h
test.cpp
17、图
MinHeap.h
Edge.h
Vertex.h
Graph.h
test.cpp
18、排序
Data.h
QueueNode.h
LinkQueue.h
Sort.h
test.cpp
目 录 1、顺序表 ................................................................................................. 1 Seqlist.h .............................................................................................. 1 Test.cpp ............................................................................................... 7 2、单链表 ................................................................................................. 8 ListNode.h ............................................................................................. 9 SingleList.h .......................................................................................... 11 test.cpp .............................................................................................. 22 3、双向链表 .............................................................................................. 25 NodeList.h ............................................................................................ 25 DoubleList.h .......................................................................................... 27 Test.cpp .............................................................................................. 38 4、循环链表 .............................................................................................. 40 ListNode.h ............................................................................................ 40 CircularList.h ........................................................................................ 42 Test.cpp .............................................................................................. 53
5、顺序栈 ................................................................................................ 56 SeqStack.h ............................................................................................ 56 Test.cpp .............................................................................................. 61 6、链式栈 ................................................................................................ 62 StackNode.h ........................................................................................... 63 LinkStack.h ........................................................................................... 64 Test.cpp .............................................................................................. 68 7、顺序队列 .............................................................................................. 70 SeqQueue.h ............................................................................................ 71 Test.cpp .............................................................................................. 76 8、链式队列 .............................................................................................. 78 QueueNode.h ........................................................................................... 79 LinkQueue.h ........................................................................................... 80 Test.cpp .............................................................................................. 84 9、优先级队列 ............................................................................................ 86 QueueNode.h ........................................................................................... 87 Compare.h ............................................................................................. 88
PriorityQueue.h ....................................................................................... 90 Test.cpp .............................................................................................. 96 10、串 ................................................................................................... 99 MyString.h ............................................................................................ 99 MyString.cpp ......................................................................................... 102 test.cpp ............................................................................................. 114 11、二叉树 .............................................................................................. 117 BinTreeNode.h ........................................................................................ 117 BinaryTree.h ......................................................................................... 126 Test.cpp ............................................................................................. 140 12、线索二叉树 .......................................................................................... 142 ThreadNode.h ......................................................................................... 143 ThreadTree.h ......................................................................................... 144 ThreadInorderIterator.h .............................................................................. 145 test.cpp ............................................................................................. 157 13、堆 .................................................................................................. 158 MinHeap.h ............................................................................................ 159
test.cpp ............................................................................................. 167 14、哈夫曼树 ............................................................................................ 168 BinTreeNode.h ........................................................................................ 168 BinaryTree.h ......................................................................................... 171 MinHeap.h ............................................................................................ 177 Huffman.h ............................................................................................ 182 Test.cpp ............................................................................................. 184 15、树 .................................................................................................. 185 QueueNode.h .......................................................................................... 186 LinkQueue.h .......................................................................................... 187 TreeNode.h ........................................................................................... 191 Tree.h ............................................................................................... 192 test.cpp ............................................................................................. 211 16、B+树 ................................................................................................ 214 BTreeNode.h .......................................................................................... 214 BTree.h .............................................................................................. 218 test.cpp ............................................................................................. 243
17、图 .................................................................................................. 245 MinHeap.h ............................................................................................ 246 Edge.h ............................................................................................... 251 Vertex.h ............................................................................................. 252 Graph.h .............................................................................................. 254 test.cpp ............................................................................................. 279 18、排序 ................................................................................................ 282 Data.h ............................................................................................... 282 QueueNode.h .......................................................................................... 289 LinkQueue.h .......................................................................................... 293 Sort.h ............................................................................................... 298 test.cpp ............................................................................................. 314
2008-9-3 数据结构算法实现 1、顺序表 Seqlist.h const int DefaultSize=100; template class SeqList{ public: SeqList(int sz=DefaultSize) :m_nmaxsize(sz),m_ncurrentsize(-1){ if(sz>0){ m_elements=new Type[m_nmaxsize]; } } ~SeqList(){ 1
2008-9-3 数据结构算法实现 delete[] m_elements; } int Length() const{ return m_ncurrentsize+1; } int Find(Type x) const; int IsElement(Type x) const; int Insert(Type x,int i); int Remove(Type x); int IsEmpty(){ return m_ncurrentsize==-1; } int IsFull(){ //get the length //find the position of x //is it in the list //insert data //delete data return m_ncurrentsize==m_nmaxsize-1; } 2
数据结构算法实现 Type Get(int i){ //get the ith data 2008-9-3 return i<0||i>m_ncurrentsize?(cout<<"can't find the element"< int SeqList::Find(Type x) const{ for(int i=0;i
分享到:
收藏