Practice ยท 1 of 1
The Search Tree
Implement the BST core. The boilerplate declares:
``c
typedef struct TNode { int value; struct TNode *left, *right; } TNode;
int bst_insert(TNode **root, int v); /* 0 inserted, 1 duplicate, -1 oom */
int bst_find(const TNode *root, int v); /* 1 found, 0 absent */
size_t bst_height(const TNode *root); /* empty tree = 0 */
long bst_min(const TNode *root); /* LLONG_MIN if empty */
/* fills out with the in-order traversal, returns the count
(out must have room for the node count) */
size_t bst_inorder(const TNode *root, int *out);
void bst_destroy(TNode *root);
``
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: BST Gym