正在加载图片...
low= 1 high= L length;∥设 L length=fboK]-1 while (low<=high) mid=low +fiboK-1 if(X<Lelem mid)) high=mid-1 else if(x>L elem midD low-mid+1 return(mid) return(0) 17试编写一个判定二叉树是否二叉排序树的算法,设此二叉树以二叉链表作存储结构,且树中结点的 关键字均不同。 typedef struct( Key type key 3 ElemType typedef struct BTNode( Elem Type data struct bTNode *lchild. *rchild I BTNode, Bitree int process BiTree t, BTNode pre) if T) flag=process(T->lchild, pre if( pre &&(pre-data key >=t->data. key)) return(0) eIse flagR=process(T->rchild, pre) if flag & flag)low = 1; high = L.length ; //设 L.length=fibo[K]-1 while (low<=high) { mid =low +fibo[K-1] ; if ( x<L.elem[mid] ) high=mid-1; else if (x>L.elem[mid]) low=mid+1; else return(mid) ; } return(0); } ⒘试编写一个判定二叉树是否二叉排序树的算法,设此二叉树以二叉链表作存储结构,且树中结点的 关键字均不同。 typedef struct{ KeyType key; … }ElemType; typedef struct BTNode{ ElemType data ; struct BTNode *lchild, *rchild ; }BTNode ,*BiTree; int process(BiTree T ,BTNode *pre) { if (T) { flagL=process(T->lchild,pre) if ( pre && (pre->data.key>=t->data.key)) return (0); else pre=t; flagR=process(T->rchild,pre) if ( flagL && flagR)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有