数据结构学习
数据结构学习
滴滴滴嘟嘟嘟.
即使不好好学习,也要天天向上。
展开
-
数据结构——栈和队列
栈 链栈 //=============链栈基本操作============= typedef struct node { int data; struct node* next; }node; //初始化 node* Init(node* head) { head = (node*)malloc(sizeof(node)); if(!head) exit(0); head->next = NULL; return head; } //压入一个元素 node* Push(node原创 2022-01-20 22:22:00 · 396 阅读 · 0 评论 -
数据结构——链表和顺序表
链表的基本操作 #include <iostream> #include <stdlib.h> using namespace std; typedef struct listNode { int date; struct listNode* next; }listNode; //头插法创建链表 listNode* Creat_head(listNode* head) { head = (listNode*)malloc(sizeof(listNode)); if(!he原创 2022-01-10 22:07:33 · 360 阅读 · 1 评论 -
数据结构——八大排序
八大排序 #include <stdio.h> #include <stdlib.h> //插入排序 void InsertSort(int arr[],int n) { int i = 0,j = 0; for(i = 2;i <= n;i ++) { if(arr[i] < arr[i-1]) { arr[0] = arr[i]; arr[i] = arr[i-1]; for(j = i-2;arr[0] < arr[j];--原创 2022-01-03 00:14:57 · 554 阅读 · 1 评论 -
数据结构——查找
二分查找 int binSeach(int arr[],int n,int num) { int left = 0; int right = n-1; int mid = (right + left) / 2; while(left <= right) { if(arr[mid] == num) return mid + 1; else if(arr[mid] > num) right = mid - 1;原创 2021-12-17 19:18:59 · 344 阅读 · 1 评论 -
数据结构——二叉树基本操作
数据结构——二叉树基本操作 #include <iostream> #include <stdlib.h> #include <stack> using namespace std; typedef struct node { char data; struct node* lchild; struct node* rchild; }node; //前序创建二叉树 node* creaseTree() { node* p = NULL; char ch原创 2021-11-21 12:13:57 · 603 阅读 · 1 评论 -
数据结构——图的基本操作
数据结构——图基本操作 #include <stdio.h> #include <stdlib.h> ///*图的结构定义============*/// #define MAX 500 typedef struct arcnode { int adjvex; struct arcnode *next; int value; } arcnode; typedef struct vnode { int date; arcnode *first原创 2021-12-16 00:23:03 · 1546 阅读 · 1 评论