
数据结构
文章平均质量分 84
ForSun
爱代码爱工作爱老婆
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【数据结构】·【带头结点的单链表】
比较坑爹的基础啊,大把时间浪费在构造函数上,构造函数(出生决定命运!)。 自己解决的bug,感觉还不错。其实程序的核心是算法,算法建立在数据结构的基础之上。 大部分的程序员现在学的基本都是规则,而不是创造。 但掌握了规则,也能创造很多财富。 重新巩固我弱爆了的数据结构,没敲完数据结构的程序员不是好领导。 注释就不写了,可以提问,或者建议。 #include #include #incl原创 2014-01-25 16:58:53 · 1172 阅读 · 0 评论 -
【数据结构】·【顺序栈】
#include #include using namespace std; const int stackIncreament=20; template class SeqStack{ public: T *elements;//存放栈中元素的栈数组 int top; int maxSize; SeqStack(int sz=50); ~SeqStack(){ delete[]原创 2014-01-26 11:02:58 · 610 阅读 · 0 评论 -
【数据结构】·【链式栈】
#include #include using namespace std; template struct LinkNode{ T data; LinkNode * link; LinkNode(T& item,LinkNode *ptr=NULL){ data=item; link=ptr; } }; template class LinkedStack{ public:原创 2014-01-27 10:50:48 · 778 阅读 · 0 评论 -
【数据结构】·【顺序队列】
#include #include using namespace std; template class SeqQueue{ public: T *elements; int total; SeqQueue(){ total=-1; elements=new T[10]; assert(elements!=NULL); }; ~SeqQueue(){}; bool E原创 2014-01-27 17:14:07 · 605 阅读 · 0 评论 -
【数据结构】·【KMP算法实现】
#include #include using namespace std; int KMP(string& pat,string& str,int k,int *next){ int posP=0; int posT=k; int lengthP=pat.length(); int lengthT=str.length(); while(posP<lengthP && posT<len原创 2014-01-29 13:36:54 · 803 阅读 · 0 评论 -
【数据结构】·【二叉树】
搞懂递归过程就行,其他的(计算高,返回结点)都差不多也就不敲了,实现前序建立二叉树,中序遍历。 #include #include using namespace std; template struct BinTreeNode{ T data; BinTreeNode *leftChild,*rightChild; BinTreeNode(T& item){ data=item;原创 2014-02-05 11:27:29 · 713 阅读 · 0 评论 -
【数据结构】·【顺序表】
/* *数据结构c++版本,参考书籍为《数据结构(第二版)》 殷人昆著 *顺序表·动态存储结构*/#include #include "stdlib.h" using namespace std; const int DefaultSize=100; template class SeqList{ public: T *data;//定义数组 int maxSize; int last;原创 2014-01-24 15:09:23 · 1506 阅读 · 0 评论 -
【数据结构】·【图】
邻接表表示,广度优先搜索,敲了老半天,最后还是用舍友的了。实在找不到bug,有这个思想就行。 #include #include #include using namespace std; template class LinkNode { public: LinkNode *link; LinkNode(const T&item, LinkNode *ptr = NULL)原创 2014-02-13 13:52:07 · 930 阅读 · 0 评论 -
【数据结构】·【链表】·【JAVA版】
和C++并没有差别,其他的链式结构基本可以参照这个 package com.sun.study.test; class Link{ public int data; public Link next; public Link(int data) { this.data = data; } public void display(){ System.ou原创 2015-11-03 18:52:37 · 423 阅读 · 0 评论