2013年8月5日

从数组取出n个元素的所有组合

摘要: //在所给的数组中找n个数的排列。/*arr为原始数组,re为保存输出下标的一位数组,start为开始找的起始点,count是数组re的下标用于判断递归调用结束;假如:arr= 1,2,3,4,5;n=4。第一次调用:start=0,count=3;i=0;i<2;i++re[3]=0;re[3]= 阅读全文

posted @ 2013-08-05 10:29 随风浪子的博客 阅读(424) 评论(0) 推荐(0) 编辑

2013年8月3日

最小生成树

摘要: 1 /* 2 先对边进行排序保证从小的边开始找,如果不合法即构成回路, 3 是不加入统计的,可以画图直观的来看一下。 4 */ 5 #include<stdio.h> 6 #include<stdlib.h> 7 int bin[1000001]; 8 int find(int x) 9 { 10 阅读全文

posted @ 2013-08-03 11:43 随风浪子的博客 阅读(81) 评论(0) 推荐(0) 编辑

数据结构实验之二叉树的建立与遍历

摘要: 1 # include <stdio.h> 2 # include <malloc.h> 3 # include <string.h> 4 struct tree 5 { 6 char data; 7 struct tree *l; 8 struct tree *r; 9 }; 10 //构造二叉树 阅读全文

posted @ 2013-08-03 11:38 随风浪子的博客 阅读(121) 评论(0) 推荐(0) 编辑

层次遍历 && 由前序中序构造二叉树链式存储

摘要: 1 # include <stdio.h> 2 # include <stdlib.h> 3 # include <string.h> 4 # define MAX 200 5 typedef struct node 6 { 7 char data; 8 struct node *l; 9 stru 阅读全文

posted @ 2013-08-03 11:36 随风浪子的博客 阅读(127) 评论(0) 推荐(0) 编辑

由前序中序求后序 数组做法

摘要: /*前序遍历: 1.访问根节点 2.前序遍历左子树 3.前序遍历右子树 中序遍历: 1.中序遍历左子树 2.访问根节点 3.中序遍历右子树 后序遍历: 1.后序遍历左子树 2.后序遍历右子树 3.访问根节点*//*前序遍历: GDAFEMHZ中序遍历: ADEFGHMZ后序遍历: AEFDHZMG* 阅读全文

posted @ 2013-08-03 11:35 随风浪子的博客 阅读(264) 评论(0) 推荐(0) 编辑

导航