数据结构课程代码
数据结构书本上的基础代码
御坂御坂Matlab工作室
喜爱编程,喜爱游戏设计,喜爱动漫
展开
-
python创建二叉树以及对二叉树的3种遍历顺序
通过python语言创建树,并对树进行三种顺序的遍历原创 2022-11-14 23:27:44 · 639 阅读 · 0 评论 -
树的性质总结
数据结构——树原创 2022-11-06 12:23:20 · 348 阅读 · 0 评论 -
插入排序总结
插入排序代码原创 2022-10-17 23:49:24 · 183 阅读 · 0 评论 -
c语言万年历
c语言小项目原创 2022-09-30 09:49:03 · 545 阅读 · 0 评论 -
数据结构-计数排序
文章目录2.代码2.代码#include <stdio.h>#include <stdlib.h>#define random(x) rand()%(x)#define num 10 // 产生10个随机数#define maxnum 20 //待排序的数字范围是0-20void countingSort(int arr[], int n, int k){ int *c, *b; int i; c = (int *)malloc(s原创 2022-04-07 15:01:15 · 62 阅读 · 0 评论 -
数据结构-希尔排序
1.原理6 5 2 7 12 15 1 4 3 9 8 105排序6 15 85 1 102 47 312 9结果:6 1 2 3 9 8 5 4 7 12 15 103排序6 3 5 121 9 4 152 8 7 10结果:3 1 2 5 4 7 6 9 8 12 15 101排序:1 2 3 4 5 6 7 8 9 10 12 15因每趟的排序间隔逐渐减小,希尔排序也称为缩小增量排序2.代码#include <stdio.h>#include &原创 2022-04-05 17:34:25 · 1019 阅读 · 0 评论 -
数据结构-树基础
1.创建一棵树 5 6 78#include<stdio.h>#include<stdlib.h>typedef struct node { int data; struct node* left; struct node* right;} Node;void preorder(Node* node){ if(node!=NULL){ printf("%d\n",node->data); preorder(node->left)原创 2022-04-05 13:02:55 · 72 阅读 · 0 评论 -
数据结构-插入排序
1.原理3 6 7 4 2 1 5分为两段,一段已经排好顺序,一段还没有排序[3 6 7] 4 2 1 5从4开始插到前面已经排好序的位置中去理论上是这样,但是在真正写代码的时候还需要其他来实现插入的操作0 1 2 3arr 3 6 7 4 …ikeykey =4while(arr[i-1]>key){=>arr[i]=arr[i-1];i–;}arr[i]=key;2.代码# include<stdio.h>void insert(原创 2022-04-05 11:13:43 · 820 阅读 · 0 评论 -
数据结构-选择排序
1.原理找出最大值与最后一个元素交换3 7 4 2 6 1【3 1 4 2 6 】7【3 1 4 2】6 7【3 1 2】4 6 72.代码#include <stdio.h>//int findMax(int arr[],int n){//这里注意我们要找的是最大值的位置 // int max = arr[0];// int i;// for (i=0;i<n;i++){// if (arr[i]>max){// max = arr[i];/原创 2022-04-05 10:54:26 · 1112 阅读 · 0 评论 -
数据结构-冒泡排序
1.冒泡排序原理3 7 4 2 6 1[3 7] 4 2 6 13 [7 4] 2 6 13 4 [7 2] 6 13 4 2 [7 6] 13 4 2 6 [7 1]3 4 2 6 1 7一趟冒泡排序作用:把当前的最大值放到一组数字的最后面代码# include <stdio.h>void bubble(int arr[],int n){ int i; int temp; for(i=0;i<n-1;i++){ if (arr[i]>arr[i+1原创 2022-04-05 10:41:24 · 866 阅读 · 0 评论 -
c语言实现顺序表
#include<stdio.h>#include<malloc.h>#define ElemType int #define MaxSize 100 typedef struct{ ElemType *data; int length;}SqList;//创建一个空表void InitList(SqList *L){ L->data = (ElemType *)malloc(MaxSize*sizeof(ElemType));//注意L-&原创 2022-04-05 10:21:15 · 497 阅读 · 0 评论