2011年4月15日

二叉搜索树

摘要: 二叉搜索树百科名片二叉查找树(Binary Search Tree),或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉排序树。查找过程二叉排序树的查找过程和次优二叉树类似,通常采取二叉链表作为二叉排序树的存储结构。中序遍历二叉排序树可得到一个关键字的有序序列,一个无序序列可以通过构造一棵二叉排序树变成一个有序序列,构造树的过程即为对无序序列进行排序的过程。每次插入的新的结点都是二叉排序树上新的叶子结点,在进行插入操作时,不必移动其它结点,只需改 阅读全文

posted @ 2011-04-15 22:33 more think, more gains 阅读(148) 评论(0) 推荐(0) 编辑

二叉树的遍历

摘要: 二叉树 二叉树也是递归定义的,其结点有左右子树之分,逻辑上二叉树有五种基本形态: (1)空二叉树——(a); (2)只有一个根结点的二叉树——(b); (3)右子树为空的二叉树——(c); (4)左子树为空的二叉树——(d); (5)完全二叉树——(e)注意:尽管二叉树与树有许多相似之处,但二叉树不是树的特殊情形。(来自百度百科) 二叉树的遍历:#include<stdio.h>#include<string.h>#include<stdlib.h>#include<debug.h>typedef struct Bitree{ Bitree *r 阅读全文

posted @ 2011-04-15 22:07 more think, more gains 阅读(194) 评论(0) 推荐(0) 编辑

图的深度与广度遍历

摘要: 今天把图的遍历加强了下。。图的深度遍历::#include<stdio.h>#include<string.h>#include<stdlib.h>#include<debug.h>int visit[100],P[100];struct N{ int vex,num; int maps[100][100];}G;typedef struct node{ int data; node *next;}NODE;typedef struct Q{ NODE *pri; NODE *rear;}QE;QE *p;void init( ){ p=new 阅读全文

posted @ 2011-04-15 19:43 more think, more gains 阅读(251) 评论(0) 推荐(0) 编辑

hdu 1181 变形课

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>int map[27][27],visit[26];//const int inf=0x7fffffff;int main( ){ char ch[30]; int i,j,k,len; memset(visit,0,sizeof(visit)); for(i=0;i<27;i++) for(j=0;j<27;j++) map[i][j]=0; while(scanf("%s",ch)!=EOF) { while(ch[0 阅读全文

posted @ 2011-04-15 12:55 more think, more gains 阅读(255) 评论(0) 推荐(0) 编辑

hdu 1002 A+B problem

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>//#include<debug.h>int main( ){ //Debug(); char ch1[1010],ch2[1010]; int a[1010],b[1010],c[1010]; int N,k=0; scanf("%d",&N); while(N--) { scanf("%s%s",ch1,ch2); k++; int i,j,m=0,n=0,len1,len2,len,fla 阅读全文

posted @ 2011-04-15 01:50 more think, more gains 阅读(186) 评论(0) 推荐(0) 编辑

最短路

摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>const int inf=0x7fffffff;int map[100][100],visit[100],dis[100];int dij(int N){ int i; /* for(i=1;i<=N;i++) { dis[i]=map[i][N]; visit[i]=0; } */ for ( i = 1; i <= N; ++ i ) { dis[i] = inf; visit[i] = 0; } dis[1]=0; for(i=1;i 阅读全文

posted @ 2011-04-15 01:07 more think, more gains 阅读(172) 评论(0) 推荐(0) 编辑

hdu 3790

摘要: View CodeProblem :3790 ( 最短路径问题 )Judge Status :AcceptedRunId : 3819913Language : G++Author :tangcong506Code Render Status :Rendered By HDOJ G++ Code Render Version 0.01 Beta#include<stdio.h>#include<string.h>#include<stdlib.h>//#include<debug.h>struct node{ int i; int j;}map[ 阅读全文

posted @ 2011-04-15 01:02 more think, more gains 阅读(295) 评论(0) 推荐(0) 编辑

导航