伸展树(1)
作者:
Drifter
,
2020-09-22 23:36:29
,
所有人可见
,
阅读 505
伸展树声明和初始化
//北京邮电大学 计算机学院 Spider
#ifndef _Splay_H
struct SplayNode;
typedef struct SplayNode *SplayTree;
SplayTree MakeEmpty(SplayTree T);
SplayTree Find(ElementType X, SplayTree T);
SplayTree FindMin(SplayTree T);
SplayTree FindMax(SplayTree T);
SplayTree Initialize(void);
SplayTree Insert(ElementType X, SplayTree T);
SplayTree Remove(ElementType X, SplayTree T);
ElementType Retrieve(SplayTree T);
#endif
struct SplayNode
{
ElementType Element;
SplayTree Left;
SplayTree Right;
};
typedef struct SplayNode *Position;
static Position NullNode = NULL;
SplayTree Initialize(void)
{
if(NullNode == NULL)
{
NullNode = malloc(sizeof(struct SplayNode);
if(NullNode == NULL)
FatalError("Out of space!!!");
NullNode->Left = NullNode->Right = NullNode;
}
return NullNode;
}