B树的定义与查找

来源:互联网 发布:cf玫瑰精灵数据 编辑:程序博客网 时间:2024/04/30 20:19
/*定义B树*/#define  m  10typedef   struct  node{int   keynum;KeyType  key[m];    struct  node  *parent;struct  node  *ptr[m];}BTNode;typedef  BTNode  *BTree;//定义B树-------------------------------------------------BTNode*   SearchBTree(BTree  T, KeyType  k,  int  *pos){    int  i;BTNode  *p = T;while(p != NULL){i = p->keynum;p->key[0] = k;while(k < p->key[i])    i--;if(k == p->key[i]  &&  i>0){    *pos = i;   return  p;}else{    p = p->ptr[i];}}return  NULL;} 

原创粉丝点击