![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 92
木一叶liuyue
fighting
展开
-
数据结构(Kruskal算法)
main.cpp#include<iostream>#include <stdio.h>#include <algorithm>using namespace std;const int N=50005;int head[N],tot=0,n,m,cnt=0,fa[N];int ans=0;struct Edge{ int u,v;//边的两个顶点 int w;//边的权值 inline friend bool operator &原创 2020-12-31 21:09:51 · 192 阅读 · 0 评论 -
数据结构(顺序队列/链队列//循环队列)
顺序队列#include<iostream>#include<malloc.h>using namespace std;typedef int ElemType;const int MaxSize=200;typedef struct{ ElemType data[MaxSize]; int rear,front;}SqQueue;void InitQueue(SqQueue *&s){ s=(SqQueue *)malloc(原创 2020-11-10 22:07:49 · 136 阅读 · 0 评论 -
数据结构(线索二叉树)
#include<iostream>#include<malloc.h>using namespace std;typedef char ElemType;typedef struct node{ struct node *lchild; struct node *rchild; int ltag,rtag; //增加的线索标记 ElemType data;} TBTnode;TBTnode *pre;void Create(T原创 2020-10-31 11:44:47 · 157 阅读 · 0 评论 -
数据结构(二叉树)
#include<iostream>#include<malloc.h>using namespace std;typedef char ElemType;typedef struct node{ ElemType data; struct node *lchild;//指向左孩子节点 struct node *rchild;//指向右孩子节点}BTNode;int Create(BTNode *&b){ b=(BTNode原创 2020-10-30 21:25:12 · 121 阅读 · 0 评论 -
数据结构(双链表/循环链表例题 )
有一个带头结点的双链表L设计一个算法让其所有元素逆置,即第一个元素变成最后元素,第二个元素变成倒数第二个元素void conversion(Dlinknode *&L){ Dlinknode *p=L->next,*q; while(p!=NULL) { q=p->next; p->next=L->next; if(L->next!=NULL) L->next-&原创 2020-10-24 22:53:08 · 2426 阅读 · 0 评论 -
数据结构(双链表的创建 插入 删除)
#include<iostream>#include<malloc.h>using namespace std;typedef int ElemType;typedef struct DNode{ ElemType data; struct DNode *prior; struct DNode *next;}Dlinknode;void CreateList(Dlinknode *&L,ElemType a[],int n){原创 2020-10-24 21:11:08 · 150 阅读 · 0 评论 -
数据结构(判断字符串是否是回文串--顺序栈)
#include<iostream>#include<malloc.h>using namespace std;typedef char ElemType;#define MaxSize 100typedef char ElemType;typedef struct{ ElemType data[MaxSize]; int top;}SqStack;void InitStack(SqStack *&s){ s=(SqStack *)mal原创 2020-10-23 21:27:20 · 1584 阅读 · 1 评论 -
数据结构(判断三种括号是否配对 顺序栈 )
#include<iostream>#include<malloc.h>using namespace std;typedef char ElemType;#define MaxSize 100typedef char ElemType;typedef struct{ ElemType data[MaxSize]; int top;}SqStack;void InitStack(SqStack *&s){ s=(SqStack *)mal原创 2020-10-23 21:43:42 · 286 阅读 · 0 评论 -
数据结构(链栈-链表)
#include<iostream>#include<cstdio>#include<malloc.h>using namespace std;const int MaxSize=50;typedef int ElemType;typedef struct linknode{ ElemType data; struct linknode *next;}LinkStNode;void Push(LinkStNode *s,int e){原创 2020-10-07 21:57:57 · 193 阅读 · 0 评论 -
数据结构(共享栈-顺序数组方法)
#include<iostream>#include<cstring>#include<malloc.h>using namespace std;const int MaxSize=50;typedef int ElemType;typedef struct{ ElemType data[MaxSize]; int top1,top2;} DStack;void Init(DStack *&s){ s=(DStack原创 2020-10-07 21:56:42 · 143 阅读 · 0 评论 -
数据结构(一二章链表题目)
已知长度为n的线性表A采用顺序存储结构,请写一时间复杂度为O(n)、空间复杂度为O(1)的算法,该算法删除线性表中所有值为item的数据元素。#include <iostream>#include<malloc.h>#include<cstdio>using namespace std;typedef int ElemType;typedef struct{ ElemType data[50]; int length;} SqList.原创 2020-10-01 18:21:51 · 1463 阅读 · 0 评论 -
数据结构(双链表的逆置)
试写一个算法,对双链表进行就地逆置(头插法)void Reserve(DLinkNode *&L){ DLinkNode *p=NULL,*q;// L->next=NULL; while(p!=NULL) { q=p>next;//用q标记后继节点 if(L->next!=NULL)//这步发生是,表里一个数都没有,L指向空 L->next->prior=p;原创 2020-09-22 23:00:04 · 4867 阅读 · 4 评论 -
数据结构(单链表,顺序结构)
//顺序表基本运算算法#include <stdio.h>#include <malloc.h>#define MaxSize 50typedef int ElemType; typedef struct { ElemType data[MaxSize]; //存放顺序表元素 int length; //存放顺序表的长度} SqList; //顺序表的类型void CreateList(SqList *&L,ElemType a[原创 2020-09-20 12:32:14 · 1112 阅读 · 0 评论 -
数据结构(顺序栈)
实现栈的初始化,进栈,出栈,取栈顶,判断是否空栈,销毁栈#include<iostream>#include<cstdio>#include<malloc.h>using namespace std;typedef int ElemType;const int MaxSize=50;typedef struct{ ElemType data[50]; int length;}LinkList;void CreateList(LinkL原创 2020-10-07 21:58:28 · 671 阅读 · 0 评论