皮皮学,免费搜题
登录
搜题
【简答题】
阅读以下说明和C代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 二叉查找称为二叉排序树,它或者是一棵空树,或者是具有如下性质的二。 (1)若它的非空,则上所有结点的值均小于根结点的值。 (2)若它的右子空,则右子树上所有结点的值均大于根结点的值。 (3)左、右子树本身就是两棵二叉查找树。 二叉查找通过依次输入数据元素并把它们插入到二的适当位置上构造起来的,具体的过程是:每读入一个元素,建立一个新结点,若二叉查找空,则将新结点的值与根结点的值相比较,如果小于根结点的值,则插入到中,否则插入到右子;若二叉查找空,则新结点作为二叉查找树的根结点。 根据关键码序列{46,25,54,13,29,91}构造一个二叉查找树的过程如图4-1所示。 设二叉查找树采用二表存储,结点类型定义如下: typedef int KeyType; typedef struct BSTNode{ KeyType key; struct BSTNode *left,*right; }BSTNode,*BSTree; 图4-1(g)所示二叉查找树的二表表示如图4-2所示。 图4-2 函数int InsertBST(BSTree *rootptr,KeyType kword)功能是将关键码kword插入到由rootptr指示出根结点的二叉查找,若插入成功,函数返回1,否则返回0。 【C代码】 int lnsertBST(BSTree*rootptr,KeyType kword) /*在二叉查找插入一个键值为kword的结点,若插入成功返回1,否则返回0; *rootptr为二叉查找树根结点的指针 */ { BSTree p,father; (1) ; /*将father初始化为空指针*/ p=*rootptr; /*p指示二叉查找树的根节点*/ while(p&& (2) ){ /*在二叉查找查找键值kword的结点*/ father=p; if(kword<p->key) p=p->left; else p=p->right; } if( (3) )return 0; /*二叉查找已包含键值kword,插入失败*/ p=(BSTree)malloc( (4) ); /*创建新结点用来保存键值kword*/ If(!p)return 0; /*创建新结点失败*/ p->key=kword; p->left=NULL; p->right=NULL; If(!father) (5) =p; /*二叉查找空树时新结点作为树根插入*/ else if(kword<father->key) (6) ; /*作为结点插入*/ else (7) ; /*作右孩子结点插入*/ return 1; }/*InsertBST*/
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【简答题】食品添加剂使用的基本要求包括: ; ; ; 。
【判断题】箍筋和弯起钢筋通常也称为“腹筋”或“横向钢筋”。
A.
正确
B.
错误
【简答题】在模拟信道中,常用带宽表示信道传输信息的能力,带宽即传输信号的()与()之差。
【判断题】铁路运输作业中,若货物实际运到天数小于规定运到期限天数,则该批货物运到逾期。
A.
正确
B.
错误
【单选题】八股文考试中,( )是关键,这个环节做得好未必高中,但做不好肯定没戏。
A.
破题
B.
起讲
C.
入手
D.
中股
【单选题】听力原文:M: The University Bookstore opens at nine in the morning. W: Oh dear, I need a textbook for my eight o'clock class today. Q: What does the woman mean? (15)
A.
She won't be able to get the book before class.
B.
The books there are too expensive.
C.
She hopes to get a good deal on some second-hand books.
D.
The textbook she needs isn't in yet.
【单选题】听力原文:W: Oh dear, what an awful weekend! M: Couldn't be worse ! Q: What does the man mean? (16)
A.
They had a happy weekend.
B.
It was not so bad as the woman thought.
C.
The woman's health is getting worse.
D.
He agrees with the woman.
【简答题】箍筋和弯起钢筋称为 或 。
【简答题】箍筋和弯起钢筋统称为 或 。
【单选题】听力原文:W: Oh, dear! I'm exhausted. I can't walk any further. M: Let's go to the cafe opposite the China bank and have a rest. Q: Where does this conversation most probably take place? (13)
A.
At a bank.
B.
On the street.
C.
At home.
D.
In a cafe.
相关题目: