B-tree insertion

From , 3 Years ago, written in C, viewed 52 times.
URL https://pastebin.vip/view/bd5af7cd
  1. int InserBTree ( NodeType **t,KeyType kx,NodeType *q,int i )
  2. { /* 在m 阶B 树*t 上结点*q 的
  3. key[i],key[i+1]之间插入关键码kx*/ /*若引起结点过大,则沿双亲链进行必要的结点分裂调整,使*t
  4. 仍为m 阶B 树*/
  5.         x=kx;
  6.         ap=NULL;
  7.         finished=FALSE;
  8.         while ( q&&!finished )
  9.         {
  10.                 Insert ( q,i,x,ap ); /*将x 和ap 分别插入到q->key[i+1]和q->ptr[i+1]*/
  11.                 if ( q->keynum<m ) finished=TRUE; /*插入完成*/
  12.                 else
  13.                 { /*分裂结点*p*/
  14.                         s=m/2;
  15.                         split ( q,ap );
  16.                         x=q->key[s];
  17.                         /*将q->key[s+1…m],q->ptr[s…m]和q->recptr[s+1…m]移入新结点*ap*/
  18.                         q=q->parent;
  19.                         if ( q ) i=Search ( q,kx ); /*在双亲结点*q 中查找kx 的插入位置*/
  20.                 }/*else*/
  21.         }/*while*/
  22.         if ( !finished ) /*(*t)是空树或根结点已分裂为*q*和ap*/
  23.                 NewRoot ( t,q,x,ap ); /*生成含信息(t,x,ap)的新的根结点*t,原*t 和ap 为子树指针*/
  24. }

Reply to "B-tree insertion"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website