C++數据结构代码.doc

  1. 1、本文档共167页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C數据结构代码

目 录 目 录 1 1、顺序表 1 Seqlist.h 1 Test.cpp 4 2、 单链表 5 ListNode.h 5 SingleList.h 6 test.cpp 12 3、 双向循环链表 13 NodeList.h 13 DoubleList.h 14 Test.cpp 20 4、 单项循环链表 21 ListNode.h 21 CircularList.h 22 Test.cpp 28 5、 顺序栈 29 SeqStack.h 29 Test.cpp 32 6、 链式栈 33 StackNode.h 33 LinkStack.h 33 Test.cpp 36 7.顺序队列 37 SeqQueue.h 37 Test.cpp 40 8、链式队列 41 QueueNode.h 41 LinkQueue.h 42 Test.cpp 44 9、优先级队列 45 QueueNode.h 46 Compare.h 46 PriorityQueue.h 47 Test.cpp 51 10、串 52 MyString.h 52 MyString.cpp 54 test.cpp 60 11、二叉树 61 BinTreeNode.h 62 BinaryTree.h 66 Test.cpp 73 12、线索二叉树 74 ThreadNode.h 74 ThreadTree.h 75 ThreadInorderIterator.h 76 test.cpp 82 13、堆 83 MinHeap.h 83 test.cpp 87 14、哈夫曼树 88 BinTreeNode.h 88 BinaryTree.h 89 MinHeap.h 92 Huffman.h 95 Test.cpp 96 15、树 97 QueueNode.h 97 LinkQueue.h 97 TreeNode.h 100 Tree.h 100 test.cpp 110 16、B+树 111 BTreeNode.h 111 BTree.h 113 test.cpp 126 17、图 127 MinHeap.h 127 Edge.h 130 Vertex.h 131 Graph.h 132 test.cpp 144 18、排序 145 Data.h 146 QueueNode.h 149 LinkQueue.h 152 Sort.h 154 test.cpp 162 1、顺序表 Seqlist.h const int DefaultSize=100; template typename Type class SeqList{ private: Type *m_elements; //指向数组的指针 const int m_nmaxsize; //最大元素个数(数组的长度) int m_ncurrentsize; //当前元素个数 public: SeqList(int sz=DefaultSize) :m_nmaxsize(sz),m_ncurrentsize(-1){ //初始化类成员变量m_nmaxsize=sz, m_ncurrentsize=-1 if(sz0){ m_elements=new Type[m_nmaxsize]; } } ~SeqList(){ delete[] m_elements; } int Length() const{ //获得线性表的长度 return m_ncurrentsize+1; } int Find(Type x) const; //获得元素x在线性表中的位置 int IsElement(Type x) const; //判断元素x是否在本线性表中 int Insert(Type x,int i); //将元素x插入到线性表中的第i号位置 int Remove(Type x); //删除元素x int IsEmpty(){ //判断是否是空表 return m_ncurrentsize==-1; } int IsFull(){ //判断是否是满表 return m_ncurrentsize==m_nmaxsize-1; } Type Get(int i){ //获取第i个元素的值 return i0||im_ncurrentsize?(coutcant find the elementendl,0):m_elements[i]; } void Print(); }; template typename Type int SeqListTyp

文档评论(0)

sd47f8cI + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档