首页 > 试题广场 >

下列算法实现在二叉排序树上查找关键值k,请在下划线处填上正确

[填空题]

下列算法实现在二叉排序树上查找关键值k,请在下划线处填上正确的语句。

typedef struct node{int key; struct node *lchild; struct node *rchild;}bitree;

bitree  *bstsearch(bitree *t, int  k)

{

if (t==0 ) return(0);else  while (t!=0)

if (t->key==k)_______1______; else if (t->key>k) t=t->lchild; else_____2________;

}

 return t
 t=t->rchild
这也错了?!return  后面要加括号?  我对c不熟悉,请大佬指教

参考答案 
(1) return(t)
(2) t=t->rchild
编辑于 2017-07-16 13:29:22 回复(2)