
数据结构
文章平均质量分 77
yuanyuanprince
这个作者很懒,什么都没留下…
展开
-
数据结构与算法分析 感悟
#include#include#include#include#includeusing namespace std;const int & findMax(const vector &vec){ size_t max=0; for(size_t i=1;i!=vec.size();i++) { if(vec[i]>vec[max])原创 2012-05-29 08:48:55 · 726 阅读 · 0 评论 -
串的实现
#includeusing namespace std;/*串的定长顺序存储表示*//*在顺序存储结构中,实现串的操作的原操作为“字符序列的复制”,操作的时间复杂度基于复制的字符序列的长度。另一个操作的特点:如果在操作中出现串值序列的长度超过上限MAXSTRLEN则约定用截尾法处理。*/#define MAXSTRLEN 5/*用户可在255以内定义最大串长*/原创 2012-05-22 22:20:31 · 408 阅读 · 0 评论 -
线性表的链式表示与实现
#include#includeusing namespace std;typedef int ElemType;typedef int Status;#define OK 1#define ERROR 0typedef struct LNode{ ElemType data; struct LNode *next;}LNode,*LinkList;原创 2012-05-19 10:30:36 · 570 阅读 · 0 评论 -
c语言实现顺序表的插入,删除和求给定元素在表中的位序等运算
/*在顺序表中插入与删除数据*/#include#include#define LIST_SIZE 100/*初始长度*/#define LIST_INCREMENT 10/*长度增量*/typedef char ElemType;/*定义顺序表类型*/typedef struct{ ElemType *elem; int len原创 2012-05-12 23:26:19 · 17558 阅读 · 1 评论 -
数据结构与算法分析 树
由后缀式构造二叉表达树,前序遍历是前缀式,中序遍历是中缀式,后序遍历是后缀式#include#includeusing namespace std;templatestruct BinaryNode{ Object data; BinaryNode *left; BinaryNode *right; BinaryNode(const Object & x,BinaryN原创 2012-06-04 15:33:12 · 595 阅读 · 0 评论 -
排序算法
#include#include#include#includeusing namespace std;#define MAXSIZE 20typedef int KeyType;typedef struct{ KeyType key; string otherinfo;}RedType;typedef struct{ RedType原创 2012-05-16 07:58:45 · 479 阅读 · 0 评论 -
表,栈,队列程序代码片段
#include#includeusing namespace std;template void printLots(const list & L,const list & P){ list::const_iterator iter1=L.begin(); list::const_iterator iter2=P.begin(); int start=1; for(;iter原创 2012-06-02 21:59:45 · 571 阅读 · 0 评论 -
数据结构与算法分析 随笔2
#includeusing namespace std;/*n的二进制数中1的个数*//*n是奇数的话,它等于n/2的二进制表示中的1的个数加1*/int ones(int n){ cout<<"调用"<<n<<endl; if(n<2) return n; return n%2+ones(n/2);}int main(){ cout<<o原创 2012-05-31 08:59:34 · 324 阅读 · 0 评论 -
基于栈的平衡符号匹配问题
栈的实现基于vector顺序容器的栈的实现#ifndef WEIWEI_H#define WEIWEI_H#includeusing std::vector;templateclass Stack{public: Stack(int val=-1):topOfStack(val){} void push(const object& val) {原创 2012-06-02 00:17:16 · 566 阅读 · 0 评论 -
数据结构之串
串的堆分配表示#include#include#includetypedef struct{ char *ch; int length;}HString;/* 初始化(产生空串)字符串T。另加 */void InitString(HString *T){ (*T).length=0; (*T).ch=NULL;}/* 生成一原创 2012-05-26 20:17:31 · 940 阅读 · 0 评论