![](https://img-blog.csdnimg.cn/2019092715111047.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
数据结构
数据结构基础代码练习
蔡徐坤学C++
听说计算机离职率特别高,很多还是大厂。我是大三的,我觉得这个专业还是很不错的,毕业也好找工作。现在很多别的什么专业工作可不好找,看到很多师兄抱怨计算机怎么怎么样的,我就想这点苦都受不了,干别的肯定也不行。
展开
-
数据结构常见排序(6种)
冒泡、选择、插入、快速、归并和堆排序原创 2022-11-01 18:35:04 · 92 阅读 · 0 评论 -
数据结构二叉树的创建、遍历、深度
【代码】数据结构二叉树的创建、遍历、深度。原创 2022-11-01 10:10:56 · 78 阅读 · 0 评论 -
数据结构希尔排序
//希尔排序不稳定排序方法但是效率很高#include <stdio.h>void show(int arr[], int length) { for (int i = 0; i < length; i++) printf("%d ", arr[i]); printf("\n");}void xiershengxu(int arr[], int length,int xier) { for (int i = 0; i < length; i++) { fo原创 2022-04-09 00:00:00 · 177 阅读 · 0 评论 -
数据结构插入排序以及力扣算法寻找两个正序数组的中位数的练习
#include <stdio.h>//本次只用到了这个头文件#include <string.h>#include <stdlib.h>#include <conio.h>#include<time.h>void show(int arr[], int length) { for (int i = 0; i < length; i++) printf("%d->", arr[i]); printf("NULL\n")原创 2022-04-08 08:00:00 · 107 阅读 · 0 评论 -
数据结构哈希表的建立和查找数据
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <conio.h>#define NUM 5typedef struct hash { int num;//哈希表多少个值 char* data;//data的指针}hash;hash* init() { hash* L = (hash*)malloc(sizeof(hash)); L->num = 0.原创 2022-04-06 15:54:48 · 1906 阅读 · 0 评论 -
数据结构二分查找
二分查找代码://二分(要求线性表必须有序)查找#include <stdlib.h>#include <stdio.h>typedef struct list { int* data; int length;//元素长度 int num;}list;list* init(int length) { list* L = (list*)malloc(sizeof(list)); L->length = length; L->data= (int*)m原创 2022-04-05 08:00:00 · 189 阅读 · 0 评论 -
数据结构顺序查找(常规及哨兵)
顺序查找//顺序查找//ASL平均查找长度(越低越好)#include <stdlib.h>#include <stdio.h>typedef struct list { int* data; int length;//元素长度 int num;}list;list* init(int length) { list* L = (list*)malloc(sizeof(list)); L->length = length; L->data= (in原创 2022-04-03 22:32:15 · 1984 阅读 · 0 评论 -
数据结构KMP算法的实现
//#include <iostream>//using namespace std;#include <stdio.h>#include <stdlib.h>typedef struct String { char* data; int length;} String;String* init() { String* S = (String*)malloc(sizeof(String)); S->data = NUL.原创 2022-03-18 18:54:44 · 382 阅读 · 0 评论 -
数据结构字符串的匹配练习
此代码下若用C++编写出现此问题:“const char *” 类型的实参与 “char *” 类型的形参不兼容解决方法是:项目->(重载)属性->C/C+±>所有选项->符合模【修改为否即可】)//传统的字符匹配//P79,算法4.5思想#include <iostream>using namespace std;//C语言只需修改头文件和以及cout即可//#include <stdio.h>//#include <stdli原创 2022-03-17 19:17:21 · 1073 阅读 · 0 评论 -
数据结构循环队列插入和删除练习
#include <iostream>using namespace std;//C语言只需要修改头文件以及cout改成printf即可//#include<stdio.h>//#include<stdlib.h>#define MAXSIZE 5//只能实现四个元素插入//不能因为下面的定义认为是// a[0],a[1],a[2],a[3],a[4],a[5],事实上只到a[4]就结束了//循环队列C++实现typedef struct queue {原创 2022-03-16 11:45:00 · 511 阅读 · 0 评论 -
数据结构队列的插入删除练习
#include<stdio.h>#include<stdlib.h>typedef struct queue {int data;struct queuenext;}queue;//队:FIFO尾插法【尾插头出】//尾插法要先遍历到尾指针的位置struct queue init() {queue* L = (queue*)malloc(sizeof(queue));L->data = 0;// 表示当前栈的元素个数,为0时表示空栈L->next =原创 2022-03-15 15:34:09 · 1520 阅读 · 0 评论 -
数据结构栈的插入和删除
#include<stdio.h>#include<stdlib.h>typedef struct stack {int data;struct stacknext;}stack;//栈:LIFO只能在栈顶删除插入(类似头插法)stack init() {stack* L = (stack*)malloc(sizeof(stack));L->data = 0;// 表示当前栈的元素个数,为0时表示空栈L->next = NULL;return L;原创 2022-03-14 22:38:42 · 2484 阅读 · 0 评论 -
数据结构双循环链表头插法尾插法和删除练习
#include<stdio.h>#include<stdlib.h>typedef struct list {int data;struct list* pre;struct list* next;}list;list* init() {list* L = (list*)malloc(sizeof(list));L->data = 0;//链表节点个数为0L->pre = L;//双循环链表自己指自己L->next = L;//同上retu原创 2022-03-14 20:12:46 · 126 阅读 · 0 评论 -
数据结构双链表头插法尾插法和删除练习
#include<stdio.h>#include<stdlib.h>typedef struct list {int data;struct list* pre;struct list* next;}list;list* init() {list* L = (list*)malloc(sizeof(list));L->data = 0;L->pre = NULL;//初始时指向的都是NULL除了循环时指向自己L->next = NULL;r原创 2022-03-13 21:29:28 · 937 阅读 · 0 评论 -
数据结构循环链表头尾删练习
#include <stdio.h>#include<stdlib.h>typedef struct list {int data;//数据域类型struct list* next;}list;list* init() {list* L = (list*)malloc(sizeof(list));L->data = 0;L->next = L;//单循环链表,后面没有则自己指自己return L;}void headIns(list* L, int原创 2022-03-12 20:23:42 · 474 阅读 · 0 评论 -
数据结构单链表头插尾插和删除练习
#include <stdio.h>#include<stdlib.h>typedef struct list {int data;struct list* next;}list;list* init() {list* L = (list*)malloc(sizeof(list));L->data = 0;L->next = NULL;return L;}void in(list* L, int data) {list* S = (list*)m原创 2022-03-12 18:38:04 · 1390 阅读 · 0 评论