正在加载图片...
return(t->lchild, K); else return(t->rchild, K) 12假设哈希表长为皿,哈希函数为H(key),用链地址法处理冲突。试编写输入一组关键字并建立哈 希表的算法。 typedef struct( Key type ke JElemType typedef struct NOde ElemType data; struct NOde nex 3 Anode, List; void CreateHList(List LmD for(1=0; 1<m; 1++) LI-NULL cin>>X while(x!=#) snew node S->data key=x s->next=LIh cin>>X return: 13已知一棵二叉排序树上所有关键字中的最小值为一max,最大值为max,又知-max<x<max。编写 递归算法,求该二叉排序树上的小于x且最靠近x的值a和大于x且最靠近x的值b。 typedef struct BTNode struct int key datareturn(t->lchild,K); else return(t->rchild,K); } ⒓假设哈希表长为 m,哈希函数为 H(key),用链地址法处理冲突。试编写输入一组关键字并建立哈 希表的算法。 typedef struct{ KeyType key; … }ElemType; typedef struct HNode{ ElemType data; struct HNode *next; }Hnode ,*Hlist; void CreateHList (Hlist L[m]) { for ( i=0; i<m; i++ ) L[i]=NULL; cin>>x; while (x!=’#’) { h=H(x); s=new Hnode; s->data.key=x; s->next=L[h]; L[h] = s; cin>>x; } return; } ⒔已知一棵二叉排序树上所有关键字中的最小值为-max,最大值为 max,又知-max<x<max。编写 递归算法,求该二叉排序树上的小于 x 且最靠近 x 的值 a 和大于 x 且最靠近 x 的值 b。 typedef struct BTNode{ struct{ int key; … }data;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有