假设二叉树采用链式方式存储,t为其根结点,请选择正确的选项将函数int Depth(bintree t) 补充完整,该函数功能为求树t的高度。二叉链表定义如下:typedef struct node{datatype data;struct node *lchild,*rchild;}bintnodetypedef bintnode *bintree;函数定义如下:int depth(bintree t) {int height,leftTreeHeight,rightTreeHeight; if (t==NULL) (1) ; else { (2) ; rightTreeHeight =depth(t->rchild); if ( (3) ) height=leftTreeHeight+1; else height= rightTreeHeight +1; } return height;}
假设二叉树采用链式方式存储,t为其根结点,请选择正确的选项将函数int Depth(bintree t) 补充完整,该函数功能为求树t的高度。二叉链表定义如下:typedef struct node{datatype data;struct node *lchild,*rchild;}bintnodetypedef bintnode *bintree;函数定义如下:int depth(bintree t) {int height,leftTreeHeight,rightTreeHeight; if (t==NULL) (1) ; else { (2) ; rightTreeHeight =depth(t->rchild); if ( (3) ) height=leftTreeHeight+1; else height= rightTreeHeight +1; } return height;}
下面是二叉树的中序遍历算法,对空白处填空()void InOrder_Recursion(BinTree bt) //递归中序遍历{ if( ) return; InOrder_Recursion(bt->leftchild); printf("%c",bt->data); InOrder_Recursion(bt->rightchild);}? 以上答案都不对|bt==NULL|bt!=NULL|bt=NULL
下面是二叉树的中序遍历算法,对空白处填空()void InOrder_Recursion(BinTree bt) //递归中序遍历{ if( ) return; InOrder_Recursion(bt->leftchild); printf("%c",bt->data); InOrder_Recursion(bt->rightchild);}? 以上答案都不对|bt==NULL|bt!=NULL|bt=NULL
void PreOrder(BinTree bt)//递归先序遍历算法{ if(bt==NULL) return; //递归出口visit(bt); //访问根结点 InOrder (leftchild(bt)); //中序遍历左子树 InOrder (rightchild(bt)); //中序遍历右子树 }void InOrder(BinTree bt)//递归中序遍历算法{ if(bt==NULL) return; //递归出口 PreOrder (leftchild(bt)); //先序遍历左子树 visit(bt); //访问根结点 PreOrder (rightchild(bt)); //先序遍历右子树 }void main(){ bt = CreateBinTree();//创建一棵二叉树 Preorder(bt); //入口}对下面二叉树执行以上程序,则输出序列是()[img=94x192]1803078d93c9821.png[/img] A: 1,2,3,4,5 B: 1,3,5,4,2 C: 5,4,3,2,1 D: 1,3,4,5,2
void PreOrder(BinTree bt)//递归先序遍历算法{ if(bt==NULL) return; //递归出口visit(bt); //访问根结点 InOrder (leftchild(bt)); //中序遍历左子树 InOrder (rightchild(bt)); //中序遍历右子树 }void InOrder(BinTree bt)//递归中序遍历算法{ if(bt==NULL) return; //递归出口 PreOrder (leftchild(bt)); //先序遍历左子树 visit(bt); //访问根结点 PreOrder (rightchild(bt)); //先序遍历右子树 }void main(){ bt = CreateBinTree();//创建一棵二叉树 Preorder(bt); //入口}对下面二叉树执行以上程序,则输出序列是()[img=94x192]1803078d93c9821.png[/img] A: 1,2,3,4,5 B: 1,3,5,4,2 C: 5,4,3,2,1 D: 1,3,4,5,2
void PreOrder(BinTree bt)//递归先序遍历算法{ if(bt==NULL) return; //递归出口 visit(bt); //访问根结点 InOrder (leftchild(bt)); //中序遍历左子树 InOrder (rightchild(bt)); //中序遍历右子树 }void InOrder(BinTree bt)//递归中序遍历算法{ if(bt==NULL) return; //递归出口 PreOrder (leftchild(bt)); //先序遍历左子树 visit(bt); //访问根结点 PreOrder (rightchild(bt)); //先序遍历右子树 }void main(){ bt = CreateBinTree(); //创建一棵二叉树 Preorder(bt); //入口}对下面二叉树执行以上程序,则输出序列是()[img=94x192]18031cb3c2815d5.png[/img] A: 1,3,5,4,2 B: 1,2,3,4,5 C: 5,4,3,2,1 D: 1,3,4,5,2
void PreOrder(BinTree bt)//递归先序遍历算法{ if(bt==NULL) return; //递归出口 visit(bt); //访问根结点 InOrder (leftchild(bt)); //中序遍历左子树 InOrder (rightchild(bt)); //中序遍历右子树 }void InOrder(BinTree bt)//递归中序遍历算法{ if(bt==NULL) return; //递归出口 PreOrder (leftchild(bt)); //先序遍历左子树 visit(bt); //访问根结点 PreOrder (rightchild(bt)); //先序遍历右子树 }void main(){ bt = CreateBinTree(); //创建一棵二叉树 Preorder(bt); //入口}对下面二叉树执行以上程序,则输出序列是()[img=94x192]18031cb3c2815d5.png[/img] A: 1,3,5,4,2 B: 1,2,3,4,5 C: 5,4,3,2,1 D: 1,3,4,5,2
下面是统计叶子结点数的递归算法,对空白处填空()int CountLeafNode(BinTree bt) //统计叶子结点数{ if (bt==NULL) return (); else if((bt->leftchild==NULL)&&(bt->rightchild==NULL)) return ( ); else return(CountLeafNode(bt->leftchild)+CountLeafNode(bt->rightchild)); A: 1,0 B: 1,1 C: 0,1 D: 0,0
下面是统计叶子结点数的递归算法,对空白处填空()int CountLeafNode(BinTree bt) //统计叶子结点数{ if (bt==NULL) return (); else if((bt->leftchild==NULL)&&(bt->rightchild==NULL)) return ( ); else return(CountLeafNode(bt->leftchild)+CountLeafNode(bt->rightchild)); A: 1,0 B: 1,1 C: 0,1 D: 0,0