
数据结构
Ferlan
天下大事,必作于细!
展开
-
二叉树基础练习
binarytree.h#include<stdio.h>#include<windows.h>#include<assert.h>typedef int BTDataType;typedef struct BinaryTreeNode{ struct BinaryTreeNode原创 2018-04-22 20:38:15 · 343 阅读 · 0 评论 -
双向链表 练习
#include<stdio.h>#include<windows.h>#include<assert.h>typedef int DataType;typedef struct DListNode{ struct DListNode* _prev; DataType _data; struct DListNode* _ne原创 2018-03-28 00:49:07 · 391 阅读 · 0 评论 -
栈与队列 练习
栈#include<stdio.h>#include<windows.h>#include<assert.h>typedef int DataType;#define Stack_size 10typedef struct Stack{ DataType* _array;//数组指针 size_t _top; //栈顶原创 2018-03-27 20:14:12 · 336 阅读 · 0 评论 -
链表练习题
从尾到头输出单链表void ReversePrint(SListNode *phead) //phead为链表头指针{ SListNode *head = phead; SListNode *tail = head; if (phead == NULL) //链表为空 {原创 2018-03-26 21:53:07 · 377 阅读 · 0 评论 -
时间复杂度与空间复杂度
本文部分取自搜狗百科 在求算法效率时,通常有事前分析和事后分析两种方法,事后分析因为必须实际检验过后才能得出答案,且可能由于硬件方面等外部原因影响结果而不被推广,事前分析的主要就是在考量一个算法的基本执行次数,这就是时间复杂度。时间复杂度:一般情况下,算法中基本操作重复执行的次数是问题规模n的某个函数,用T(n)表示,若有某个辅助函数f(n),记作T(n)=O(f(n)),称O(f(n))为算法的原创 2018-03-21 13:33:12 · 267 阅读 · 0 评论 -
链表 增删查改
#include<stdio.h>#include<Windows.h>#include<assert.h>typedef int DataType;typedef struct SListNode{ DataType data; struct SListNode *next;}SListNode;SListNode*原创 2018-03-19 21:12:07 · 325 阅读 · 0 评论 -
顺序表 增删查改
#include<stdio.h>#include<windows.h>#include<assert.h>#include<stdlib.h>#define len 3typedef int Datatype;typedef struct SeqList{ Datatype *a; s原创 2018-03-18 22:02:23 · 390 阅读 · 0 评论 -
通讯录1 动态开辟内存
define _CRT_SECURE_NO_WARNINGS 1includeincludeincludeinclude原创 2018-03-17 17:10:20 · 216 阅读 · 0 评论 -
通讯录
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<windows.h>#include<assert.h>struct stu{ char name[5]; char sex[2]; int age;原创 2018-03-17 17:00:47 · 260 阅读 · 0 评论 -
数据结构:各类迷宫问题详解(c语言版)
第一类 简单迷宫(不含多条出路,不带环)(0代表墙,1代表通路)思路分析:1.以入口为起点,寻找出口(除了起点以外的边缘上的点)2.判定当前点坐标是否可以走。(坐标合法且不为0)3.如果合法则将当前点标记成走过的并入栈(维护一个栈可以记录走过的路径,栈的长度就是路径的长度)4.判断当前点是否是出口,是出口就return(该迷宫不存在别的出口),如果不是出口,...原创 2018-04-01 23:40:33 · 31694 阅读 · 1 评论 -
栈与对列 练习题
1.实现一个栈,要求实现Push(出栈)、Pop(入栈)、Min(返回最小值)的时间 复杂度为O(1)创建2个栈 s 和 min ,入栈时,先入栈s,在判断是否出栈时,如果s栈的top元素与min栈的top元素相等,则两个都出栈,否则只出s栈的top取min值时直接返回min栈top元素即可function.h#pragma once#include"stack.h"原创 2018-04-08 21:54:19 · 348 阅读 · 0 评论 -
哈希表--开散列(哈希桶,拉链法)
functions.h#include<stdio.h>#include<assert.h>#include<windows.h>typedef int KeyType;//关键字类型typedef int ValueType;//个数类型原创 2018-06-01 16:09:30 · 421 阅读 · 0 评论 -
排序思想,代码实现和优缺点比较
void insert_sort(int *a, int size){ //插入排序: //每一步将一个待排序的元素,插入到前面已经有序的一组元素中, //直到元素排完为止。 assert(a); assert(size>0); for (int i = 1;i < size;i++) {原创 2018-06-14 23:59:53 · 633 阅读 · 0 评论 -
贪吃蛇
UI.h#pragma oncestruct UI{ int margintop;//墙离上窗口的距离 int marginleft;//墙离左窗口的距离 int gamewidth;//游戏里宽度上显示块个数 int gameheight;//游戏里高度上显示块个数 int windowWidth;//整个窗口的宽度 int win...原创 2018-05-17 20:24:14 · 257 阅读 · 0 评论 -
哈希表--开放定制法 练习
functions.h#include<stdio.h>#include<windows.h>#include<assert.h>typedef int KeyType; //关键字类型typedef int ValueType;//个数类型typedef enum type //类型{ _EMPTY, _EXIS原创 2018-05-14 20:01:37 · 474 阅读 · 0 评论 -
二叉搜索树 练习
binary_search_tree.h#pragma once #include<stdio.h>#include<windows.h>#include<assert.h>typedef int DataType;typedef struct BSTreeNode{ struct BSTreeNode* _left; struct BSTreeNode* _right;原创 2018-05-05 23:40:43 · 374 阅读 · 0 评论 -
堆 练习
以大堆为例:heap.h#pragma once#include&lt;stdio.h&gt;#include&lt;windows.h&gt;#include&lt;assert.h&gt;typedef int HeapDataType;typedef struct heap//堆在物理结构上看就是一个数组,只是我们把他抽象成树状结构{ HeapD原创 2018-04-25 17:24:41 · 324 阅读 · 0 评论 -
时间复杂度与空间复杂度
算法的时间复杂度和空间复杂度-总结&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 通常,对于一个给定的算法,我们要做 两项分析。第一是从数学上证明算法的正确性,这一步主要用到形式化证明的方法及相关推理模式,如循环不变式、数学归纳法等。而在证明算法是正确的基础上,第二部就是分析算法的转载 2018-04-14 14:18:14 · 230 阅读 · 0 评论 -
用逆波兰表达式完成简单计算器
definition.h#pragma once#include&lt;stdio.h&gt;#include&lt;windows.h&gt;#include&lt;assert.h&gt;#define len 10#define Stack_size 20typedef enum comput //运算{ OP_NUM=1,//操作数 OP_SYMBO原创 2018-04-12 23:10:35 · 514 阅读 · 0 评论