网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

写出下面算法的功能。voidfunction(Bitree*t){if(p!=NULL){function(p->lchild);function(p->rchild);printf(“%d”,p->data);}}


参考答案

更多 “写出下面算法的功能。voidfunction(Bitree*t){if(p!=NULL){function(p-lchild);function(p-rchild);printf(“%d”,p-data);}}” 相关考题
考题 设计递归算法,判断二叉树t是否满足小根堆的特点。二叉链表的类型定义如下: typedef int datatype;//结点的数据类型,假设为inttypedef struct NODE *pointer;//结点指针类型struct NODE {datatype data;pointer lchild,rchild;};typedef pointer bitree;//根指针类型

考题 已知一棵二叉树用二叉链表存储,t指向根节点,P指向树中任一节点。下列算法为输出从t到P之问路径上的节点。[C程序]define MaxSize 1000typedef struct node {TelemType data ;struct node *ichiid,*rchiid;}BiNode,*BiTree;void Path(BiTree t,BiNode *P){BiTree *stack[Maxsize],*stackl[Maxsize],*q;int tag[Maxsize],top=0,topl;q=t;/*通过先序遍历发现P*/do{while(q!=NULL &&q!=p)/*扫描左孩子,_日.相应的节点不为P*/{ (1) ;stack[top]=q;tag[top]=0;(2) ;}if(top>0){ if(stack[top]=P) break; /*找到P,栈底到栈顶为t到P*/if(tag[top]==1)top--;else { q=stack[top];q=q->rchiid;tag[top]=1;}}} (3) ;top--;topl=0;while(top>0) {q=stack[top]; /*反向打印准备*/topl++;(4) ;top--;}while( (5) ){ /*打印栈的内容*/q=stackl[topl]jprintf(q->data);topl--;}}

考题 阅读分析本题程序段后回答问题:(1)程序实现了什么功能?(2)写出程序的输出结果 阅读分析本题程序段后回答问题:(1)程序实现了什么功能?(3分)(2)写出程序的输出结果;(4分)(3)写出算法的时间复杂度。(3分)#include stdio.h#define N 7typedef int datatype;void main(void){ int 1,j,t;datatype data[N]={1,2,3, 4,5,6, 7}; /*处理的数据*/i=0;j=N-1;while (ij){ t=data[i];data[i++ ]=data[j];data[j--]=t;}printf(”运行结果为: \n);for(i= =0;iN-1;i++)printf(%d; ,data[i]);}

考题 函数原型语句正确的是()。A、intFunction(voida)B、voidFunction(int);C、intFunction(a);D、voidint(doublea);

考题 试写出折半查找的递归算法。

考题 设目标为t=“abcaabbabcabaacbacba”,模式为p=“abcabaa” ① 计算模式p的naxtval函数值; ② 不写出算法,只画出利用KMP算法进行模式匹配时每一趟的匹配过程。

考题 编写算法,实现下面函数的功能。函数void insert(char*s,char*t,int pos)将字符串t插入到字符串s中,插入位置为pos。假设分配给字符串s的空间足够让字符串t插入。(说明:不得使用任何库函数)

考题 阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。[说明]已知一棵二叉树用二叉链表存储,t指向根结点,p指向树中任一结点。下列算法为输出从t到P之间路径上的结点。[C程序]define Maxsize 1000typedef struct node{TelemType data;struct node*1child,*rchild;}BiNode,*BiTree;void Path(BiTree t,BiNode*P){ BiTree*stack[Maxsize],*stackl[Maxsize],*q;int tag[Maxsize],top=0,topl;q=t;/*通过先序遍历发现P*/do(while(q!=NULL q!=p)/*扫描左孩子,且相应的结点不为P*/{ (1);stack[top]=q;tag[top]=0;(2);}if(top>0){ if(stack[top]==P) break; /*找到P,栈底到栈顶为t到P*/if(tag[top]==1)top--;else{q=stack[top];q=q->rchild;tag[top]=1;}}} (3);top--; topl=0;while(top>0){q=stack[top]; /*反向打印准备*/topl++;(4);top--;}while((5)){ /*打印栈的内容*/q=stackl[topl];printf(q->data);topl--;}}

考题 写出两个排序算法,问哪个好?(威盛)

考题 阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。[说明]二叉树的二叉链表存储结构描述如下:lypedef struct BiTNode{ datatype data;street BiTNode *lchiht, *rchild; /*左右孩子指针*/ } BiTNode, *BiTree;下列函数基于上述存储结构,实现了二叉树的几项基本操作:(1) BiTree Creale(elemtype x, BiTree lbt, BiTree rbt):建立并返回生成一棵以x为根结点的数据域值,以lbt和rbt为左右子树的二叉树;(2) BiTree InsertL(BiTree bt, elemtype x, BiTree parent):在二叉树bt中结点parent的左子树插入结点数据元素x;(3) BiTree DeleteL(BiTree bt, BiTree parent):在二叉树bt中删除结点parent的左子树,删除成功时返回根结点指针,否则返回空指针;(4) frceAll(BiTree p):释放二叉树全体结点空间。[函数]BiTree Create(elemtype x, BiTree lbt, BiTree rbt) { BiTree p;if ((p = (BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;p->data=x;p->lchild=lbt;p->rchild=rbt;(1);}BiTree InsertL(BiTree bt, elemtype x,BiTree parent){ BiTree p;if (parent= =NULL) return NULL;if ((p=(BiTNode *)malloc(sizeof(BiTNode)))= =NULL) return NULL;p->data=x;p->lchild= (2);p->rchild= (2);if(parent->lchild= =NULL) (3);else{p->lchild=(4);parent->lchild=p;}return bt;}BiTree DeleteL(BiTree bt, BiTree parent){ BiTree p;if (parent= =NULL||parent->lchild= =NULL) return NULL;p= parent->lchild;parent->lchild=NULL;freeAll((5));return bt;

考题 写出基于颜色的图像插值算法。

考题 用贪心算法设计0-1背包问题。要求:说明所使用的算法策略;写出算法实现的主要步骤;分析算法的时间。

考题 写出下面算法的功能。intfunction(SqString*s1,SqString*s2){inti;for(i=0;ilengthilength;i++)if(s-data[i]!=s2-data[i])returns1-data[i]-s2-data[i];returns1-length-s2-length;}

考题 写出算法的功能。intfun(sqstring*s,sqstring*t,intstart){inti=start-1,j=0;while(ilenjlen)if(s-data[i]==t-data[j]){i++;j++;}else{i=i-j+1;j=0;}if(j=t-len)returni-t-len+1;elsereturn-1;}

考题 写出下面算法的功能。Bitree*function(Bitree*bt){Bitree*t,*t1,*t2;if(bt==NULL)t=NULL;else{t=(Bitree*)malloc(sizeof(Bitree));t-data=bt-data;t1=function(bt-left);t2=function(bt-right);t-left=t2;t-right=t1;}return(t);}

考题 函数depth实现返回二叉树的高度,请在空格处将算法补充完整。intdepth(Bitree*t){if(t==NULL)return0;else{hl=depth(t-lchild);hr=());if(())returnhl+1;elsereturnhr+1;}}

考题 写出算法的功能。int L(head){ node * head; int n=0; node *p; p=head; while(p!=NULL) { p=p-next; n++; } return(n); }

考题 写出设计动态规划算法的主要步骤。

考题 写出定义16位的特殊功能寄存器T0的说明形式。

考题 问答题写出几种线裁剪算法;写出几种多边形裁剪算法。

考题 填空题写出下面算法的功能。Bitree*function(Bitree*bt){Bitree*t,*t1,*t2;if(bt==NULL)t=NULL;else{t=(Bitree*)malloc(sizeof(Bitree));t-data=bt-data;t1=function(bt-left);t2=function(bt-right);t-left=t2;t-right=t1;}return(t);}

考题 问答题用贪心算法设计0-1背包问题。要求:说明所使用的算法策略;写出算法实现的主要步骤;分析算法的时间。

考题 问答题写出算法的功能。intfun(sqstring*s,sqstring*t,intstart){inti=start-1,j=0;while(ilenjlen)if(s-data[i]==t-data[j]){i++;j++;}else{i=i-j+1;j=0;}if(j=t-len)returni-t-len+1;elsereturn-1;}

考题 填空题函数depth实现返回二叉树的高度,请在空格处将算法补充完整。intdepth(Bitree*t){if(t==NULL)return0;else{hl=depth(t-lchild);hr=());if(())returnhl+1;elsereturnhr+1;}}

考题 填空题写出下面算法的功能。voidfunction(Bitree*t){if(p!=NULL){function(p-lchild);function(p-rchild);printf(“%d”,p-data);}}

考题 问答题写出下面算法的功能。intfunction(SqString*s1,SqString*s2){inti;for(i=0;ilengthilength;i++)if(s-data[i]!=s2-data[i])returns1-data[i]-s2-data[i];returns1-length-s2-length;}

考题 填空题写出算法的功能。int L(head){ node * head; int n=0; node *p; p=head; while(p!=NULL) { p=p-next; n++; } return(n); }