数据结构
pfeiKing
安安静静地先稳住
展开
-
数据结构-单线新表链式尾插法
#include#includeusing namespace std;typedef struct LNODE{ int data; struct LNODE *next;}Lnode;Lnode* Input(int n){ Lnode *head,*p,*q; head=p=(Lnode*)malloc(sizeof(Lnode)); p->next=NULL;原创 2017-09-13 15:27:44 · 512 阅读 · 0 评论 -
数据结构-链队列的基本操作
#include#include#define OK 1#define ERROR 0using namespace std;typedef struct LNode{ int data; struct LNode *next;}LNode;typedef struct Queue{ LNode *front ,*rear;}Queue;void init_que原创 2017-09-22 16:06:51 · 947 阅读 · 0 评论 -
数据结构-栈的链式表示(指针双星问题**prt)
实现简单,主要是搞清楚,当指针作为参数的时候,如何在函数值对行参进行修改 st. 调用函数处传入的参数同时修改。#include#include#define OK 1#define ERROR 0using namespace std;typedef struct Stack_Node{ int data; struct Stack_Node *next;}Stack_N原创 2017-09-19 23:38:02 · 699 阅读 · 0 评论 -
数据结构-栈的静态顺序存储表示-初始化压栈弹栈
和上一个博客,动态方式一样#include#include#define MAX_STACKSIZE 100#define OK 1#define ERROR 0using namespace std;typedef struct sqstack{ int stack_array[MAX_STACKSIZE]; int top; int bottom;}SqStack;原创 2017-09-19 21:56:10 · 890 阅读 · 0 评论 -
数据结构-栈的动态顺序存储表示-初始化压栈弹栈
由于没有设置index参数,所以该code不能随时的输出,然后再继续进行push和pop,因为一次输出栈,就把top压到了bottom,可以通过增加index,进行恢复。#include#include#define STACK_SIZE 100#define STACKINCREMENT 10#define ERROR 0#define OK 1using namespace s原创 2017-09-17 12:56:56 · 781 阅读 · 0 评论 -
数据结构-单线性链式-头插法
#include#include using namespace std;typedef struct Lnode{ int data; struct Lnode* next;}Linknode;int main(){ int n; while(cin>>n) { Linknode *head,*p; head=(Linknode*)malloc(size原创 2017-09-10 22:01:23 · 591 阅读 · 0 评论 -
数据结构-顺序线性表的初始化,插入,删除
#include#include#include#define MAX_SIZE 100 #define OK 1#define ERROR 0 using namespace std;typedef struct{ int* x; int length;}sqList;int init_sqList(sqList* L){ L->x=(int*)malloc(MAX原创 2017-09-10 21:32:18 · 1347 阅读 · 0 评论 -
数据结构-二叉树先序中序后序的非递归算法
#include#include#define MAX_SIZE 100using namespace std;typedef struct Node{ int data; struct Node *Lson,*Rson;}Node;void BulitTree(Node **node){ char a; cin>>a; if(a=='#') { *node=N原创 2017-09-25 23:25:06 · 594 阅读 · 0 评论 -
数据结构-二叉树的建立
二叉树的建立可通过 ab#d##c#e##这种形式建立说明: ROOT:a a的左儿子b a的右儿子c b无左儿子 b的右儿子d c无左儿子 c的右儿子e原创 2017-09-24 22:50:37 · 613 阅读 · 0 评论 -
数据结构-双链表删除
依旧分文next(正向)和prior(逆向)两种:正向code:#include#includeusing namespace std;typedef struct Dulnode{ int data; struct Dulnode *prior,*next;}DulNode;DulNode *Input(int n){ DulNode *head,*p,*q;原创 2017-09-15 20:58:42 · 353 阅读 · 0 评论 -
数据结构-双向链表插入
分为正向序号插入数值和逆向序号插入数值正向code: #include #include using namespace std; typedef struct Dulnode { int data; struct Dulnode *prior,*next; }DulNode; DulNode *Input(int n) { DulNode *head,*原创 2017-09-15 20:42:12 · 743 阅读 · 0 评论 -
数据结构-双向循环链表
对输入的数据通过head分别进行双向的输出 #include #include using namespace std; typedef struct Dulnode { int data; struct Dulnode *prior,*next; }DulNode; DulNode *Input(int n) { DulNode *head,*p,*q;原创 2017-09-15 20:08:38 · 406 阅读 · 0 评论 -
数据结构-单链表的合并
#include#include#define OK 1#define ERROR 0using namespace std;typedef struct LNODE{ int data; struct LNODE *next;}Lnode;Lnode* Input(int n){ Lnode *head,*p,*q; head=p=(Lnode*)malloc(si原创 2017-09-13 17:38:30 · 919 阅读 · 0 评论 -
数据结构-单链表按值删除
#include#include#define OK 1#define ERROR 0using namespace std;typedef struct LNODE{ int data; struct LNODE *next;}Lnode;Lnode* Input(int n){ Lnode *head,*p,*q; head=p=(Lnode*)malloc(si原创 2017-09-13 17:07:18 · 4555 阅读 · 0 评论 -
数据结构-单链表按序号删除
#include#include#define OK 1#define ERROR 0using namespace std;typedef struct LNODE{ int data; struct LNODE *next;}Lnode;Lnode* Input(int n){ Lnode *head,*p,*q; head=p=(Lnode*)malloc(si原创 2017-09-13 17:00:47 · 826 阅读 · 0 评论 -
数据结构-单链表的插入
#include#include#define OK 1#define ERROR 0using namespace std;typedef struct LNODE{ int data; struct LNODE *next;}Lnode;Lnode *Input(int n){ Lnode *head,*p,*q; head=p=(Lnode*)malloc(si原创 2017-09-13 16:28:36 · 671 阅读 · 0 评论 -
数据结构-单链表查找按值查找
#include#include#define ERROR -40000using namespace std;typedef struct LNODE{ int data; struct LNODE *next;}Lnode;Lnode *Input(int n){ Lnode *head,*p,*q; head=p=(Lnode*)malloc(sizeof(Lno原创 2017-09-13 16:02:18 · 11233 阅读 · 0 评论 -
数据结构-单链表查找按序号查找
#include#include#define ERROR -40000using namespace std;typedef struct LNODE{ int data; struct LNODE *next;}Lnode;Lnode *Input(int n){ Lnode *head,*p,*q; head=p=(Lnode*)malloc(sizeof(Lno原创 2017-09-13 15:55:09 · 6533 阅读 · 0 评论 -
数据结构-邻接链表的建立和使用
邻接链表其实和前向星基本一致。通过一个点u,进而找出由他出发通向的其他的点v1,v2,v3...... 对于一个点u,将他指向的所有点{Vi},按照插入的先后顺序,建立单链表,当有新的点进入是,采用头插法增加链表,不采用尾插法的原因是,每一次的插入都要遍历一遍{Vi}非常浪费时间,然后为了满足建立,{Vi}的顺序是不被要求的,故,在建成的图中会发现u点指向的点的遍历顺序是最后加入的最先遍历出...原创 2017-10-02 21:40:09 · 3626 阅读 · 0 评论