
数据结构
half-beast
关注全栈,喜欢寻根究底
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
二叉搜索树(c实现)
二叉检索树,并中序遍历#include #include typedef struct Node { int data; struct Node *left; struct Node *right;}Node ;void create_bst(Node **root,const int data){ if(root==NULL) { fprintf(stdout,"ro原创 2015-01-04 23:29:26 · 542 阅读 · 0 评论 -
栈(c实现)
#include #include int gError = 0;typedef struct Node {int data;struct Node* next;} Node ;int length(Node*);void push(Node** stack,const int a){if(*stack==NULL){*stack = (No原创 2015-01-03 21:13:15 · 483 阅读 · 0 评论 -
单链表逆序(c实现)
单链表逆序作为常见的数据操作,需要考虑输入结点为空、一个结点和多个结点的情况。#include #include typedef struct Node { int data; struct Node *next;} Node;Node* create_list(int *array,const int length){ if(array==NULL) { return原创 2015-01-05 22:09:15 · 889 阅读 · 0 评论 -
单链表合并(c实现)
两个顺序单链表合并#include #include typedef struct Node { int data; struct Node *next;} Node ;Node *create_list(int *array,const int length){ if(array==NULL||length<=0) { return NULL; } Node *he原创 2015-01-05 22:41:23 · 712 阅读 · 0 评论 -
AVL树(c实现)
最近阅读java的TreeMap源码,发觉是使用红黑树实现内部的数据管理,所以开始学习编写红黑树。然后发现要想理解红黑树还是要从基础的二叉平衡树的开始。于是,最终决定拿AVL树开刀。网络上有很多AVL树的各种语言实现版本,个人偏爱c的绝对控制性编程,所以选择了c实现。令人庆幸的是,一个非常简易的AVL树c实现被我找到。现在就在其基础上加上个人理解把AVL树实现描述如下:原创 2015-03-20 09:42:00 · 645 阅读 · 0 评论 -
红黑树(c实现)
学习红黑树原理,网络上有很多文章。学习红黑树的具体实现,个人推荐去看JDK中的TreeMap源码。因为该源码很简洁,并且很容易改为其它语言的实现,最重要的是该份实现得到世人的认可,可以保证是没问题的代码。下面是我根据其实现,使用c语言改写的红黑树实现,目前只有红黑树的插入实现。#include #include enum COLOR { red, black};typede原创 2015-04-03 21:57:21 · 466 阅读 · 0 评论