【Note】数据结构题集
Thereisnospon
在校本科生,渣渣一枚,正在向成为一名大牛而努力~
展开
-
6_39_二叉树增加两个域不用栈进行递推后序遍历树
#include #include #include typedef struct node { int data; int mark; struct node*lchild,*rchild,*parent; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0原创 2015-04-25 16:13:38 · 393 阅读 · 0 评论 -
6_38_二叉树的后序遍历非递归算法(和先序有些许不一样)
#include #include #include typedef struct node { int data,tag; struct node*lchild,*rchild; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else原创 2015-04-25 16:13:06 · 388 阅读 · 0 评论 -
6_36_相似二叉树
#include #include #include typedef struct node { int data; struct node*lchild,*rchild; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else原创 2015-04-25 16:10:05 · 406 阅读 · 0 评论 -
6_42_二叉树递归求叶子节点个数
#include #include #include typedef struct node { int data; struct node*lchild,*rchild; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else原创 2015-04-25 16:15:30 · 408 阅读 · 0 评论 -
6_37_二叉树的先序遍历非递归算法
#include #include #include typedef struct node { int data; struct node*lchild,*rchild; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else原创 2015-04-25 16:10:57 · 428 阅读 · 0 评论 -
6_43_递归交换二叉树中所有节点的左右子树
#include #include #include typedef struct node { int data; struct node*lchild,*rchild; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else原创 2015-04-25 16:16:09 · 1419 阅读 · 0 评论 -
6_44_二叉树中值为x的节点为根的子树的深度
#include #include #include typedef struct node { int data; struct node*lchild,*rchild; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else原创 2015-04-25 16:15:56 · 730 阅读 · 0 评论 -
6_34_扩展判断u是否为v的子孙
#include int L[6+1]={0,2,4,0,6,0,0}; int R[6+1]={0,3,5,0,0,0,0}; int T[6+1]; int n=6; void TransTo() { int i; for(i=1;i<=n;i++) { T[L[i]]=i; T[R[i]]=i; } T[0]=0; }原创 2015-04-25 16:09:10 · 574 阅读 · 0 评论 -
6_33_两个一维数组判断u是否为v的子孙
#include int L[6+1]={0,2,4,0,6,0,0}; int R[6+1]={0,3,5,0,0,0,6}; int n=6; int IfSon(int u,int v) { if(u&&v){ if(L[v]==u||R[v]==u) return 1; else return(IfSon原创 2015-04-25 16:09:39 · 868 阅读 · 0 评论 -
6_41_递归求出二叉树先序遍历第k个节点的元素的值
#include #include #include typedef struct node { int data; struct node*lchild,*rchild; }tnode,*tree; tree creat() { int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else原创 2015-04-25 16:13:13 · 2711 阅读 · 0 评论