随笔分类 - 数据结构(DS)
本人教学过程中的一些程序
摘要:源程序: #include <stdio.h>#include <stdlib.h>typedef int DataType;typedef struct LinkQueueNode{ DataType data; struct LinkQueueNode *next;}LkQueNode; typ
阅读全文
摘要:源程序: //循环队列 #include <stdio.h> #include <stdlib.h> #define MAXSIZE 100 typedef struct cycqueue { int data[MAXSIZE]; int front,rear; //声明队列的头指针和尾指针 }Cy
阅读全文
摘要:二分法查找(选择排序) 源程序: #include <stdio.h>#define MaxSize 8typedef struct{ int stuno; char stuname[20];}TableElem; TableElem stu[]={{1009,"wang"},{4400,"ren"
阅读全文
摘要:顺序查找(通用算法) 源程序: #include <stdio.h>#define MaxSize 8typedef struct{ int stuno; char stuname[20];}TableElem; //基本分量结构体类型 TableElem stu[]={{1001,"zhang"}
阅读全文
摘要:Hash函数的实现(线性探测法,除留余数法) 源程序: #include <iostream>#include <stdlib.h>#include <stdio.h>#define HASHSIZE 12#define NULLKEY -1struct HashTable{ int *elem;
阅读全文
摘要:二叉排序树 源程序: #include "stdio.h"#include "stdlib.h" typedef struct tnode{ int id; int score; struct tnode *lchild,*rchild;}stu;void Ins_Student(stu **p,l
阅读全文
摘要:menu.h #pragma once#include <stdio.h>#include <stdlib.h>#if!defined(menu_H)#define menu_h //定义单链表结点类型typedef struct node{ int data; struct node* next;
阅读全文
摘要:// ConsoleApplication8.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。// #include <stdio.h>#include <stdlib.h>#define MaxSize 50typedef char DataType;typedef str
阅读全文
摘要:源程序: #include <stdio.h> #include <stdlib.h> //#define MAXSIZE 100 /* 存储空间初始分配量 */ const int MAX_INT = 32767; const int vnum = 20; typedef struct gp {
阅读全文
摘要:源程序: #include <stdio.h> #include <stdlib.h> #define MAXSIZE 9 /* 存储空间初始分配量 */ const int vnum = 20; typedef struct gp { char vexs[vnum]; /* 顶点表 */ int
阅读全文
摘要:源程序: #include <stdio.h>#include <stdlib.h> #define vnum 100 typedef char VerTexType; //定义链接队列的结点typedef struct LinkQueueNode{ int data1; struct LinkQu
阅读全文
摘要:源程序: #include <stdio.h>#include <stdlib.h> #define vnum 100 typedef char VerTexType;typedef struct arcnode{ int adjvex; //下一条边的顶点编号 struct arcnode *ne
阅读全文
摘要:源程序: #include <stdio.h>#include <stdlib.h>#include <malloc.h>#include <string.h> #define MAX 100#define isLetter(a) ((((a)>='a')&&((a)<='z')) || (((a)
阅读全文
摘要:源程序: /*无向带权图的邻接矩阵表示法*/#include <stdio.h>#define vnum 20const int MAX_INT=0;typedef struct gp{ char vexs[vnum]; /*顶点信息*/ int arcs[vnum][vnum]; /*邻接矩阵*/
阅读全文
摘要:源程序: #include <stdio.h>#include <stdlib.h> const int vnum=20; typedef struct gp{ char vexs[vnum]; int arcs[vnum][vnum]; int vexnum,arcnum;}Graph; //输入
阅读全文
摘要:源程序: #include <stdio.h>#define N 5 //快速排序 int pass(int a[],int x,int y){ int temp=a[x]; int i=x+1; int j=y; int stemp; while(1) { while(a[j]>temp) j--
阅读全文
摘要:源程序: // // main.cpp // bitree // // Created by duanqibo on 2019/11/25. // Copyright © 2019年 duanqibo. All rights reserved. // #include <iostream> #inc
阅读全文
摘要:源程序: // 32 66 90//15,32,9,22,18 43,66,49,35,53 90,78,71,86 //分析:分块查找由索引查找和子表查找两步完成。设n个数据元素的查找表分为m个子表,且每个子表//均为t个元素,则t=n/m 。这样,分块查找的平均查找长度为:// ASL=ASL索
阅读全文
摘要:源程序: //二分查找法#include <stdio.h>#define MaxSize 8typedef struct{ int stuno; char stuname[20];}TableElem; TableElem stu[]={{1001,"zhang"},{1009,"wang"},{
阅读全文
摘要:源程序: #include <stdio.h>#define MaxSize 8typedef struct{ int stuno; char stuname[20];}TableElem; TableElem stu[]={{1001,"zhang"},{1009,"wang"},{2005,"s
阅读全文