数据结构与算法
文章平均质量分 68
guoguo6138
这个作者很懒,什么都没留下…
展开
-
翻转一个单向链表的c语言代码
# include # include # include typedef struct Node { int data; struct Node * pNext; }NODE, * PNODE; PNODE creat_list(void); voi原创 2011-08-22 23:19:07 · 470 阅读 · 0 评论 -
排序算法--冒泡排序
1.简单冒泡排序算法 # include void main() { int i, j, arr[] = {23, 90, 9, 25, 16}; for(i=0; i { for(j=0; j printf("%5d", arr[j]); printf("\n"); for(j=4; j>i; j--) { if(arr[j]原创 2011-12-13 20:49:32 · 341 阅读 · 0 评论 -
排序算法--选择排序
1.简单选择排序算法 # include void main() { int i,j, arr[] = {23, 90, 9, 25, 16}; for(i=0; i { for(j=0; j printf("%5d", arr[j]); printf("\n"); for (j=i+1; j { if(arr[i] > arr[原创 2011-12-13 20:28:37 · 378 阅读 · 0 评论 -
堆存储串的实现(c语言)
1.str.h # ifndef _STR_H # define _STR_H typedef struct { char * ch; int len; }STR; STR *NewStr(char * str); void DestroyStr(STR *s); void ClearStr(STR *s); int StrCompare(STR * s, STR * t);原创 2011-12-11 22:28:08 · 685 阅读 · 0 评论 -
希尔排序算法的实现及复杂度分析
希尔排序算法第一次实现了复杂度小于O(n2)的算法, 使得以后有更好的算法的出现. 1. 希尔排序算法的实现 1.seqlist.h # define MAXSIZE 10 typedef struct { int r[MAXSIZE + 1]; int length; }SqList; void ShellSort(SqList *l); # endi原创 2011-12-19 14:54:44 · 1105 阅读 · 0 评论 -
双队列的两种实现方式
1.输入限制性双队列代码实现 # include # include typedef struct queue_node { int data; struct queue_node * next; }QUEUE; QUEUE * rear = NULL; QUEUE * front = NULL; int InQueueRear(int value) { QUEU原创 2011-12-07 22:51:14 · 1015 阅读 · 0 评论 -
简单队列和循环队列的实现--数组实现
1.源代码如下 # include # define MAX_SIZE 10 int queue[MAX_SIZE]; int rear = -1; int front = -1; int InQueue(int value) { if(rear >= MAX_SIZE) return 0; rear++; queue[rear] = value; retur原创 2011-12-05 21:28:16 · 627 阅读 · 0 评论 -
队列的实现--链表实现
1.链表实现的简单算法 # include # include typedef struct queue_node { int data; struct queue_node * next; }QUEUE; QUEUE * rear = NULL; QUEUE * front = NULL; int InQueue(int value) { QUEUE * q =原创 2011-12-05 22:05:42 · 450 阅读 · 0 评论 -
栈的引用--迷宫算法(c语言实现)
1.data.h # ifndef _DATA_H # define _DATA_H typedef struct { int y; int x; }POS; typedef struct { int sno; POS seat; int di; }ElemType; # endif 2.stack.h # ifndef _STACK_H原创 2011-11-30 22:51:55 · 994 阅读 · 0 评论 -
单链表数据存储结构(c语言实现)
1.list.h # ifndef _LIST_H # define _LIST_H typedef struct _node { void * data; struct _node * next; }NODE; typedef struct { NODE * head; NODE * last; int length; }LIST; LIST * InitL原创 2011-11-24 23:14:27 · 1338 阅读 · 0 评论 -
双向链表的操作实现(c语言)
1.list.h # ifndef _LIST_H # define _LIST_H typedef struct node { void * data; struct node * pior; struct node * next; }NODE; typedef struct { NODE * head; NODE * last; int length;原创 2011-11-28 21:26:57 · 588 阅读 · 0 评论 -
栈的应用-用栈实现八进制的顺序输出(c语言实现)
1.data.h # ifndef _DATA_H # define _DATA_H typedef int ElemType; # endif 2.stack.h # ifndef _STACK_H # define _STACK_H # include "data.h" # define STACK_INIT_SIZE 10 # define STACK_INCREM原创 2011-11-29 21:45:42 · 756 阅读 · 0 评论 -
一步一步写算法(算法总结)
自10月初编写算法系列的博客以来,陆陆续续以来写了几十篇。按照计划,还有三个部分的内容没有介绍,主要是(Dijkstra算法、二叉平衡树、红黑树)。这部分会在后面的博客补充完整。这里主要是做一个总结,有兴趣的朋友可以好好看看,欢迎大家提出宝贵意见。 (1) 排序算法 快速排序 合并排序 堆排序 选择排序 基数排序转载 2011-11-22 17:32:22 · 360 阅读 · 0 评论 -
线性表顺序存储结构
1.list.h # ifndef _LIST_H # define _LIST_H # define LIST_INIT_SIZE 10 # define LIST_INCREME 10 typedef struct { ElemType * elem; int length; int size; }LIST; LIST * InitList(); voi原创 2011-11-22 21:03:17 · 315 阅读 · 0 评论 -
排序算法--插入排序
1.简单插入排序的算法实现 # include void main() { int i, j, arr[] = {23, 90, 9, 25, 16}; for(i=1; i { for(j=0; j { if(arr[i] { int temp = arr[i]; for(int k=i;k>j; k--) {原创 2011-12-13 21:03:50 · 332 阅读 · 0 评论