
数据结构
SuilandCoder
just a coder;
展开
-
循环队列逆置
#include "stdio.h" #include "malloc.h"#include "stdlib.h"#define MAXSIZE 11/*** 实现循环队列的逆转*/typedef struct{ int data[MAXSIZE]; int front ,rear;}CQueue; //初始化队列CQueue *InitQ() { CQueue *原创 2017-11-14 15:36:28 · 2971 阅读 · 0 评论 -
前序,中序序列建立二叉树
#include "stdio.h" #include "malloc.h"/*** 根据前序pre[n],中序pin[n]序列 建立二叉树, n为结点数 */typedef struct TNode{ char c; struct TNode *lchild,*rchild;}TNode,Tree;Tree *createTree(char pre[],char pin[]原创 2017-11-14 19:24:52 · 917 阅读 · 0 评论 -
使用单链表统计英文文本单词个数
#include "stdio.h" #include "malloc.h"#include "string.h"/*** 注意下面三个*********************************************中的内容* 都是容易出错的地方! */ //统计字符串中单词个数及每个单词出现次数typedef struct WordsNode{ int tim原创 2017-11-17 23:06:16 · 3001 阅读 · 0 评论 -
使用至多4种颜色给多区域着色问题
因为时间问题,没有详细描述算法思路。#include "stdio.h"//4种颜色着N个区域//使用无向连通图表示区域,邻接矩阵存储图信息--因为偷懒,并没建立对应的数据结构 #define N 9int adj[N][N]={{0,1,0,1,0,0,0,0,0}, {1,0,1,1,1,1,0,0,0}, {0,1,0,0,1,1,0,0,0},原创 2017-11-24 20:41:50 · 2699 阅读 · 0 评论 -
位图排序案例
题目:文件A.txt中存储了N个整数(N大于100万),要求仅占用4K内存,对该文件中的整数进行排序,结果输出到B.txt。先说明下位图排序的思路:假设我们要对0-7内的5个元素(4,7,2,5,3)排序(这里假设这些元素没有重复)。那么我们就可以采用Bit-map的方法来达到排序的目的。要表示8个数,我们就只需要8个Bit(1Bytes),首先我们开辟1Byte的空间,将这些原创 2017-12-04 19:07:28 · 771 阅读 · 0 评论 -
双向起泡算法
#include "stdio.h" //交换数字 void swap(int *a,int *b){ int temp; temp=*a; *a=*b; *b=temp;}//双向起泡排序 void bubbleSort(int a[],int n){ int low=0,high=n-1; int i,j; int flag=1;//一趟排序结束是否有交换 whi原创 2017-12-06 17:26:58 · 2179 阅读 · 0 评论