题目内容

设一棵完全二叉树共有699个结点,则在该二叉树中有_______个叶子结点。

查看答案
更多问题

请填空并实现循环对列删除队头元素的操作QElemTypeDeQueue(struct SqQueue *Q){//删除队头元素的函数QElemType e;if (1 ==2 )//判断栈是否为空{ printf("The queue is empty.");exit(ERROR); }e=Q->base[ 3];//将队头元素赋值给eQ->front=4 ;//队头指针后移一位return e;}

填空实现向队列中插入元素的功能Status EnQueue(struct SqQueue *Q,QElemType e){//向队列中插入元素e的函数if((Q->rear+1)1==Q->front)//判断队列是否为满return OVERFLOW;Q->base[2 ]=e;//向队尾插入元素,队尾指针后移一位Q->rear=3;return OK;}

填空实现将元素插入栈顶的操作Status Push(struct SqStack *S, SElemType e )//入栈函数:将元素e插入栈中{if(1 ==2 ) {//判断栈是否已满S->base=(SElemType*)realloc(S->base,(S->stacksize+STACKINCREMENT)*sizeof(SElemType));if(!S->base) exit(OVERFLOW);S->top=S->base+S->stacksize;S->stacksize+=STACKINCREMENT;}//栈满的处理3 ;//栈顶指针上移,将元素e插入栈顶return OK;}

请完成下列二叉树的递归遍历算法#include #include #define OK 1#define ERROR 0#define TRUE 1#define FALSE 0#define OVERFLOW -2typedef int status;/*二叉树的二叉链表存储表示*/typedef struct BiNode{char Data;struct BiNode* lChild;struct BiNode* rChild; //左右孩子指针}BiNode,*pBiNode;BiNode *pRoot=NULL;status Visit(char Data){printf("%c",Data);return OK;}/*建立二叉链表*/status CreateTree(BiNode** pTree){//按先序次序输入二叉树中结点值,空格表示空树//构造二叉链表表示的二叉树char ch;scanf("%c",&ch);if(ch==' '){(*pTree)=NULL;}else{(*pTree)=(BiNode*)malloc(sizeof(BiNode));(*pTree)->Data=ch;CreateTree(&((*pTree)->lChild));CreateTree(&((*pTree)->rChild));}return OK;}/*先序遍历二叉树,递归算法*/status PreOrderTraval(BiNode* pTree){if(pTree){if(Visit(pTree->Data)){if(PreOrderTraval(pTree->lChild)){if(PreOrderTraval(pTree->rChild)){return OK;}}}return ERROR;}else{return OK;}}/*中序遍历二叉树,递归算法*/status InOrderTraval(BiNode* pTree){if(pTree){if(InOrderTraval(1)){if(Visit(2)){if(InOrderTraval(3)){return OK;}}}return ERROR;}else{return OK;}}/*后序遍历二叉树,递归算法*/status PostOrderTraval(BiNode* pTree){if(pTree){if(4){if(PostOrderTraval(pTree->rChild)){if(Visit(pTree->Data)){return OK;}}}return ERROR;}else{return OK;}}main(){system("cls");CreateTree(&pRoot);printf("\nPreOrder:");PreOrderTraval(pRoot);printf("\n");printf("\nInOrder:");InOrderTraval(pRoot);printf("\n");printf("\nPostOrder:");PostOrderTraval(pRoot);printf("\n");getch();}

答案查题题库