
数据结构
文章平均质量分 62
BYD123
Linux, windows系统程序员,爱钻研。
展开
-
双向链表的实现1
这里介绍链表的打印输出,链表的反向和链表销毁。1)正向打印出所有的节点:int print_lst(list *head){ if (head == NULL) { perror("head is null !\n"); return -1; } list *p; int count; for(p = head, count = 0; p != NULL; +原创 2012-08-17 23:03:00 · 910 阅读 · 0 评论 -
双向链表的实现0
双向链表是数据结构中最常用的数据组织方式。下面介绍一些常见的操作。1) 一般会有如下定义://struct definitiontypedef struct __node list;struct __node{ struct __node *pre; struct __node *next; void *p_data;};这里pre和next分别指向前一个和后一个原创 2012-08-17 22:52:16 · 1237 阅读 · 0 评论 -
双向链表的实现2
这里介绍冒泡排序在链表中的实现。/** bubble sort for bi-linked list;* flag > 0, oreder from little to large, < 0 from large to little;*/#if 1int sort_lst(list *head, const int flag){ if (head == NULL) re原创 2012-08-17 23:07:46 · 804 阅读 · 0 评论 -
双向链表的实现3
这里进行链表的测试:1)测试函数:int lst_test(void){ int i; list *head, *new; printf("%s begin:\n", __func__); for (i = 0; i < LST_COUNT; i++) { if (i == 0) { head = create(); head->p_data原创 2012-08-17 23:22:06 · 878 阅读 · 0 评论 -
栈的链式实现1
本节给出测试代码及说明。int main(void){#define MAX_SIZE MAX_NODE#define VAL_RANGE 10000 int i, val; stack *pStack = NULL; printf("enter %s:\n", __func__); pStack = create(); if (pStack == NULL) {原创 2012-08-23 19:38:55 · 882 阅读 · 0 评论 -
栈的链式实现0
本节介绍基本的数据结构:栈。以链式栈为例:1)基本结构的定义:typedef struct __stack stack;typedef struct __node node;struct __stack{ node *pNode; int cursor; int size;};struct __node{ struct __node *next; void *原创 2012-08-23 19:26:36 · 876 阅读 · 0 评论 -
队列的实现0
本节介绍队列的定义及基本操作。1)队列定义:typedef struct __queue queue;typedef struct __node node;struct __queue{ struct __node *front; struct __node *rear; int size;};struct __node{ struct __node *pre;原创 2012-08-23 19:47:23 · 830 阅读 · 0 评论 -
队列的实现1
本节介绍测试代码及说明。测试代码:int main(){ queue *q; int i, value = 1; printf("enter main:\n"); q = create(&value); if (q == NULL) { perror("create queue failed!\n"); return -1; } printf("\n原创 2012-08-23 19:52:48 · 1028 阅读 · 0 评论