数据结构基础
BooM十五亿船长
这个作者很懒,什么都没留下…
展开
-
数据结构1.1顺序表的基础操作
对顺序表的基础操作,后续在此基础上升级望早日出山。#include <stdio.h>#include <stdbool.h>#include <stdlib.h>struct Arr{int *pBase;int len;//最大长度int cnt; //当前有效长度};void init_arr(struct Arr * array...原创 2019-08-06 07:29:24 · 209 阅读 · 0 评论 -
数据结构2.0链表基础操作
#include <stdio.h>#include <stdlib.h>#include <stdbool.h>typedef struct Node{int data;struct Node *pNext;}NODE, *PNODE;//创建链表;PNODE creat_list(void);void traverse_list(PNOD...原创 2019-08-06 11:29:42 · 132 阅读 · 0 评论 -
数据结构工具之冒泡、选择排序
#include <stdio.h>void sort2_maopao(int *arr,int n){int i, j;int tmp;//外循环记录循环比较次数,循环n-1次//内循环是元素下标,满足条件移动//注意,j<n-i,每一轮比完的元素放到一侧不用管了//即第一轮找到最大的或最小的放到一边,第二轮只要找第二大的,且不用和最大的比较for ( i =...原创 2019-08-09 12:07:39 · 70 阅读 · 0 评论 -
数据结构3.0顺序栈的push,pop
#include <stdio.h>#include <stdlib.h>#include <stdbool.h>typedef struct SNODE{int *data;int top;int MAXSIZE;}*stack, node;stack initi_stack(int n);bool is_full(stack plist)...原创 2019-08-10 21:54:20 · 1176 阅读 · 0 评论 -
数据结构4.0链表的应用--多项式加法与乘法
#include <stdio.h>#include <stdlib.h>/读入的话才用尾插法,头部保留空结点,插入读入完成后释放头部结点//主要结构是:读入,相加(判别相加是否系数为零),相乘(第一项先乘,后续在此基础上按指数大小顺序插入,如果指数大小一样系数相加为零,删除该点/typedef struct PSTNODE * polynomial;struct...原创 2019-08-15 08:09:54 · 187 阅读 · 0 评论 -
数据结构5.0二叉树的非递归遍历先序、中序
/**创建以下结果的二叉树,此二叉树结构是上面二叉树遍历的例子,可对比结果是否正确A/ B C/ \ D E F/ \ \ / G H I J k*///还差一个后序遍历和层次遍历#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#defin...原创 2019-08-15 11:17:22 · 131 阅读 · 0 评论 -
数据结构3.0栈的链表操作
#include <stdio.h>#include <stdlib.h>#include <stdbool.h>typedef struct SLNode{int data;struct SLNode * next;}*Lstack, Node;/*//为方便操作而生成一个头,一个尾指针//其实没有必要struct stack{Lst...原创 2019-08-11 16:33:53 · 73 阅读 · 0 评论 -
5.1增加二叉树非递归后续遍历
//感谢MOOC里的大神,选了一种最为方便的写法//另外还可以在树结构中增加一个记录访问次数的选项//那个更容易理解,但是麻烦,也贴在后面typedef struct TREE{int data;int visit; //用来记录节点的访问次数struct TREE * left;struct TREE * right;}*BinTree , Tnode;void postr...原创 2019-08-17 09:00:14 · 87 阅读 · 0 评论