
数据结构
文章平均质量分 94
Kinghiee
Front-end Developer
展开
-
使用二分查找实现纯文本展开和收起功能
二分查找是一种高效的查找算法,适用于在有序数组中查找特定元素。它的基本思想是通过将数组分成两半来缩小查找范围,从而减少查找次数。算法思想和基本实现步骤初始化边界:定义两个指针,left 指向数组的起始索引,right 指向数组的结束索引。计算中间索引:使用公式 mid = Math.floor((left + right) / 2) 计算中间索引。比较元素:将目标值与中间元素进行比较:如果目标值等于中间元素,查找成功,返回中间索引。原创 2024-11-10 15:41:45 · 637 阅读 · 0 评论 -
数据结构(C语言版)——希尔排序(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define MAXSIZE 20typedef int Status;void shellSort(int data[],int dataArrLenght);void shellSort(int data[],int dataArrLenght);int main(int argc, char *argv[]) { in原创 2020-10-04 16:54:07 · 2755 阅读 · 0 评论 -
数据结构(C语言版)——直接插入排序(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define MAXSIZE 20typedef int Status; void insertSort(int data[],int dataArrLenght);int main(int argc, char *argv[]) { int data[MAXSIZE],i,arrSize; printf("请输入待排序的数原创 2020-10-04 15:33:27 · 6365 阅读 · 0 评论 -
数据结构(C语言版)——简单选择排序(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define MAXSIZE 20#define ERROR 0#define OK 1 typedef int Status;void selectSort(int data[]);int main(int argc, char *argv[]) { int data[MAXSIZE],i,arrSize; printf("请输入待排序的数组大小:"); if(scanf(原创 2020-10-04 13:55:30 · 4784 阅读 · 0 评论 -
数据结构(C语言版)——有序表查找(斐波那契查找)(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define ERROR 0#define OK 1#define MAXSIZE 20typedef int Status; Status fbi(int number);Status fbiSearch(int fbiArr[],int fbiArrLenght,int dataArr[],int dataArrLenght,int wantSearchElement);in原创 2020-10-03 20:18:00 · 429 阅读 · 0 评论 -
数据结构(C语言版)——有序表查找(插值查找)(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define ERROR 0#define OK 1#define MAXSIZE 20typedef int Status;Status binarySearch(int arr[],int arrLenght,int wantSearchElement); int main(int argc, char *argv[]) { int data[MAXSIZE],size,i原创 2020-10-03 18:35:03 · 741 阅读 · 0 评论 -
数据结构(C语言版)——有序表查找(折半查找)(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define ERROR 0#define OK 1#define MAXSIZE 20typedef int Status;Status binarySearch(int arr[],int arrLenght,int wantSearchElement); int main(int argc, char *argv[]) { int data[MAXSIZE],size,i原创 2020-10-03 17:12:26 · 2600 阅读 · 0 评论 -
数据结构(C语言版)——二叉树的顺序存储结构(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#define OK 1#define ERROR 0#define MAXSIZE 30typedef int Status;typedef struct biTree{ char data[MAXSIZE];}BITREE,*BITREEPOINTER;int printMe原创 2020-09-30 16:21:37 · 12772 阅读 · 5 评论 -
数据结构(C语言版)——二叉树链式存储以及前序、中序、后序遍历(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0typedef int Status;typedef struct node{ char data; struct node *leftChild,*rightChild;}biTreeNode,*TREEPOINTER; int printMenu(void);Status PleaseInit(void);Stat原创 2020-09-30 15:46:30 · 2067 阅读 · 4 评论 -
数据结构(C语言版)——树的孩子表示法(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define MAXSIZE 20typedef int Status;typedef struct CTnode{//孩子结构 int child; struct CTnode* next;}*ChildPointer; typedef struct{//表结构 char data; int parent;原创 2020-09-29 10:59:06 · 1910 阅读 · 0 评论 -
数据结构(C语言版)——链队列(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0typedef int Status;typedef struct qNode{ int data; struct qNode* next; }QNODE,*queuePointer; typedef struct{ queuePointer front,rear;}linkQueue;int printMenu(v原创 2020-09-25 11:55:09 · 975 阅读 · 0 评论 -
数据结构(C语言版)——循环顺序队列(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define MAXSIZE 10typedef int Status;typedef struct{ int queue[MAXSIZE]; int front; int rear;}Queue;typedef Queue* QUEUEPOINTER; int printMenu(void);Status Ple原创 2020-09-24 15:36:04 · 832 阅读 · 0 评论 -
数据结构(C语言版)——链栈(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0 typedef int Status;typedef struct stackNode{ long int data; struct stackNode* next;}STACKNODE;//定义链栈结点结构 typedef struct stackNode* nodePointer;typedef struct link原创 2020-09-23 20:43:16 · 3879 阅读 · 3 评论 -
数据结构(C语言版)——共享栈(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define MAXSIZE 10typedef int Status; typedef struct sharingStack{ int data[MAXSIZE]; int top; int bottom;}Stack; typedef struct sharingStack* SHARINGSTACKPOINTER原创 2020-09-23 10:51:36 · 620 阅读 · 0 评论 -
数据结构(C语言版)——顺序栈(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define MAXSIZE 10#define OK 1#define ERROR 0;typedef int Status;typedef struct stackStruct{ int data[MAXSIZE]; int top;} Stack;typedef struct stackStruct* STACK;void PleaseInit(void);int原创 2020-09-22 17:39:42 · 3624 阅读 · 4 评论 -
数据结构(C语言版)——静态链表(代码版)
一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define TRUE 1 #define FALSE 0#define MAXSIZE 100typedef int Status;typedef struct{//定义结构 int data; int cur;} Node;//用typedef命名结构类型时,可以省略结构标签 Node staticLinkLis原创 2020-09-21 20:21:08 · 552 阅读 · 1 评论 -
数据结构(C语言版)——单链表
声明:本篇博客最主要是代码实现一、代码#include <stdio.h>#include <stdlib.h>#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0typedef int Status; struct Node{ int data; struct Node *next;} Node;typedef struct Node* linkList;/*定义一个linkList,它类似原创 2020-09-20 21:30:35 · 1027 阅读 · 0 评论 -
数据结构(C语言版)——顺序线性表
本片博客,以代码为主一、代码再写代码之前先来了解一下,线性结构的特点和定义的几个顺序链表基本操作线性结构的特点顺序链表基本操作1:初始化顺序链表2:插入顺序链表3:判断当前顺序链表是否为空4:清空顺序链表5:打印顺序链表中的元素6:当前顺序链表元素个数代码#include <stdio.h>#include <stdlib.h>#define MAXSIZE 20 //定义数组多大长度#define OK 1#define ERROR 0#原创 2020-09-20 08:09:21 · 421 阅读 · 0 评论