数据结构书
文章平均质量分 64
leafinsnowfield
这个作者很懒,什么都没留下…
展开
-
链队列
#ifndef _LINKQUEUE_H_ #define _LINKQUEUE_H_ #include "Node.h" #include using namespace std; enum StatusCode{UNDER_FLOW,SUCCESS}; template class LinkQueue { protected: Node *rear,*front; void原创 2015-10-17 17:38:05 · 281 阅读 · 0 评论 -
用顺序栈解决将读入的数按相反的方向解决
#ifndef _SQSTACK_H_ #define _SQSTACK_H_ #include using namespace std; enum StatusCode{SUCCESS,RANGE_ERROR,OVER_FLOW,UNDER_FLOW}; const int DEFAULT_SIZE=10; template class SqStack { protected: int原创 2015-10-04 11:17:17 · 1544 阅读 · 0 评论 -
双向链表的实现
#ifndef _SIMPLEDBLLINKLIST_H_ #define _SIMPLEDBLLINKLIST_H_ #include #include "NodeDbl.h" using namespace std; enum StatusCode{SUCCESS,RANGE_ERROR}; template class SimpleDblLinkList { protected:原创 2015-10-03 21:41:16 · 400 阅读 · 0 评论 -
用循环链表解决约瑟夫循环
注意1在getElemPtr的时候的position的范围是0到Length() 2在约瑟夫循环中应为出去的位置是position-1而出去了之后紧接着原来的元素位置被后面一个元素补上,所以position—1的位置 #include #include "Node.h" #include "SimpleCircLinkList.h" using namespace std; void J原创 2015-10-03 19:38:12 · 469 阅读 · 0 评论 -
线性链表之将单调递增的la和lb中的数据元素按值递增,将la和lb合并为新的线性表lc,使lc中的元素仍然单调递增
#ifndef _SIMPLELINKLIST_H_ #define _SIMPLELINKLIST_H_ #include "Node.h" using namespace std; enum StatusCode{SUCCESS,RANGE_ERROR}; template class SimpleLinkList { protected: Node *head; void原创 2015-10-02 12:27:21 · 3513 阅读 · 0 评论 -
翻转线性表中的元素
#ifndef _NODE_H_ #define _NODE_H_ #include using namespace std; template class Node { public: ElemType data; Node *next; Node(); Node(ElemType e,Node* link=NULL); //Node(ElemType e,Node*原创 2015-10-03 15:29:31 · 683 阅读 · 0 评论 -
KMP
#include using namespace std; int KMPIndexHelp(const string &T,const string &P,int pos,int next[]) { int i=pos,j=0; while(i<T.length()&&j<P.length()) { // cout<<"111"<<endl; if(j==-1) { i原创 2015-10-18 23:08:01 · 309 阅读 · 0 评论 -
用顺序表调整la的左右两边,左边元素全部为奇数,右边元素全部为偶数
//#include "SqList.h" #include using namespace std; const int Default=20; enum StatusCode{SUCCESS,RANGE_ERROR,OVER_FLOW}; template class SqList { protected: int count; int maxSize; ElemType *pt原创 2015-10-02 12:12:26 · 1102 阅读 · 0 评论 -
矩阵
#ifndef _MATRIX_H_ #define _MATRIX_H_ #include using namespace std; template class Matrix { protected: ElemType *elems; int rows,cols; public: Matrix(int rs,int cs); void SetMatrix(const原创 2015-11-03 18:40:34 · 369 阅读 · 0 评论 -
首尾字符匹配算法
#include using namespace std; int FrontRearIndex(const string &T,const string &P,int pos=0) { int startPos=pos; while(startPos<T.length()-P.length()+1) { int front=0,rear=P.length()-1; while(原创 2015-10-18 14:38:20 · 1027 阅读 · 0 评论 -
用顺序表求lc=la-lb
#ifndef _SQLIST_H_ #define _SQLIST_H_ #include using namespace std; const DEFAULT_SIZE=10; enum StatusCode{RANGE_ERROR,SUCCESS,NOT_PRESENT,ENTRY_FOUND,OVER_FLOW}; template class SqList { protected:原创 2015-10-02 10:44:45 · 872 阅读 · 0 评论 -
顺序表的头文件和头文件的实现
注意:1模板类中的函数有const,那么定义此函数时const必须要有 2定义模板类的函数时,template一定要有class #ifndef _SQLIST_H_//SqList.h #define _SQLIST_H_ #include const DEFAULT_SIZE=10; enum StatusCode{RANGE_ERROR,SUCCESS,NOT_PRESENT,ENT原创 2015-10-01 21:33:31 · 4853 阅读 · 0 评论 -
链式栈
#include #include "Node.h" #include "SimpleLinkStack.h" using namespace std; bool Merg(char *s) { char tmpsChar; SimpleLinkStack la; for(int i=0;i<strlen(s);i++) { if(s[i]=='('||s[i]=='['||s[i原创 2015-10-17 16:10:25 · 330 阅读 · 0 评论 -
简单匹配算法
#include using namespace std; int SimpleIndex(const string &T,const string &P,int pos=0) { int i=pos,j=0; while(i<T.length()&&j<P.length()) { if(T[i]==P[j]) { i++; j++; }else { i原创 2015-10-18 11:10:35 · 676 阅读 · 0 评论 -
循环队列
#include "SqQueue.h" #include using namespace std; void main() { SqQueue a; a.InQueue(5); int elem; a.GetHead(elem); cout<<elem<<endl; a.InQueue(6); cout<<a.Length()<<endl; a.OutQueue(elem);原创 2015-10-17 22:30:21 · 368 阅读 · 0 评论 -
实现基本二叉树操作
//mytree.h #pragma once typedef int ElemType; #ifndef _MYTREE_H_ #define _MYTREE_H_ struct TreeNode; typedef struct TreeNode *SearchTree; typedef struct TreeNode *Position; void MakeEmpty(SearchTree原创 2017-03-27 12:36:38 · 311 阅读 · 0 评论