Basic
B+樹(shù)和B樹(shù)類似(有關(guān)B樹(shù):http://www.cnblogs.com/YuNanlong/p/6354029.html,區(qū)別主要在于葉節(jié)點(diǎn),如果在父節(jié)點(diǎn)的Child
數(shù)組中指向某一葉節(jié)點(diǎn)指針的下標(biāo)為Index,則該葉節(jié)點(diǎn)中的最大數(shù)據(jù)值與其父節(jié)點(diǎn)中Key[Index]
的值相等,并且除最右側(cè)的葉節(jié)點(diǎn)之外所有葉節(jié)點(diǎn)都有一個(gè)指針指向其右邊的兄弟節(jié)點(diǎn),因此所有非葉節(jié)點(diǎn)中數(shù)據(jù)值都在葉節(jié)點(diǎn)中有相同的值與之對(duì)應(yīng)。
下面是一些聲明和定義:
typedef int ElementType;typedef int* PtrElementType;typedef enum Bool BoolType;enum Bool{ False = 0, True = 1};typedef struct TreeNode *PtrBpNode;typedef struct TreeNode BpNode;struct TreeNode{ int Num; BoolType IsLeaf; PtrElementType Key; PtrBpNode *Child; PtrBpNode Next; };typedef struct Tree *PtrBp;struct Tree{ PtrBpNode Root; };void ShiftKey(Pt