Name
bistree_init
Synopsis
void bistree_init(BisTree *tree
, void (*compare)(const void *key1, const void *key2), void (*destroy
)(void *data
));
Return Value
None.
Description
Initializes the binary search tree specified by
tree
. This operation must be called for
a binary search tree before the tree can be used with any other
operation. The function pointer compare
specifies a user-defined function to compare elements. This
function should return 1 if key1
>
key2
, if
key1
= key2
,
and -1 if key1
<
key2
. The
destroy
argument provides a way to free
dynamically allocated data when
bistree_destroy is called. It works in a
manner similar to that described for
bitree_destroy. For a binary search tree
containing data that should not be freed,
destroy
should be set to NULL.
Complexity
O (1)
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.