Wyszukiwanie drzewo
define BST_TREE_SEARCH (Node, Key):
if (Node == NULL) or (Node->Key == Key)
return Node
if Key < Node->Key
return BST_TREE_SEARCH (Node->Left, Key)
return BST_TREE_SEARCH (Node->Right, Key)
wstawianie drzewo
define BST_TREE_INSERT_NODE(Tree, InsertNode)
y = NULL
x = Tree->Root
while (x != NULL)
y = x
if (InsertNode->Key < x->Key)
x = x->left
else
x = x->right
InsertNode->Parent = y
Zdejmowanie liczby ze stosu:
void pop(stack **stos)
{
stack *e;
if (*stos == NULL) return;
e = (*stos)->next;
delete *stos;
*stos = e;
}
// Wrzucanie liczby na stos:
void push(stack **stos, int y)
{
stack *e;
e = new stack;
e->x = y;
e->next = *stos;
*stos = e;
}