Name
bistree_remove
Synopsis
int bistree_remove(BisTree *tree, const void *data);
Return Value
0 if removing the node is successful, or -1 otherwise.
Description
Removes the node matching data
from the binary search tree specified by
tree
. In actuality, this operation only
performs a lazy removal, in which the node is
simply marked as hidden. Thus, no pointer is returned to the data
matching data
. The data in the tree
must remain valid even after it has been removed. Consequently,
the size of the binary search tree, as returned by
bistree_size, does not decrease after
removing a node. This approach is explained further in the
implementation and analysis section.
Complexity
O (lg n), where n is the number of nodes in the binary search tree.
Get Mastering Algorithms with C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.