|
DSA Hacking Club Library
|
A simple binary search tree (BST) implementation in C. More...
#include <stdbool.h>
Go to the source code of this file.
Classes | |
| struct | treenode |
| A node in the binary search tree. More... | |
Typedefs | |
| typedef struct treenode | treenode |
| A node in the binary search tree. | |
Functions | |
| treenode * | createnode (int value) |
| Creates a new tree node. | |
| void | printtree (treenode *root) |
| Prints the tree in a structured format. | |
| bool | tree_insertnumber (treenode **rootptr, int value) |
| Inserts a number into the binary search tree. | |
| bool | tree_findnumber (treenode *root, int value) |
| Searches for a value in the binary search tree. | |
A simple binary search tree (BST) implementation in C.
This header provides the data structures and function prototypes for creating, inserting, searching, and printing a binary search tree.
| typedef struct treenode treenode |
A node in the binary search tree.
Each node stores an integer value and pointers to its left and right children.
| treenode * createnode | ( | int | value | ) |
Creates a new tree node.
| value | The integer value to store in the node. |
| void printtree | ( | treenode * | root | ) |
Prints the tree in a structured format.
This function is mainly for debugging and visualization.
| root | Pointer to the root node of the tree. |
| bool tree_findnumber | ( | treenode * | root, |
| int | value ) |
Searches for a value in the binary search tree.
| root | Pointer to the root of the tree. |
| value | The value to search for. |
| bool tree_insertnumber | ( | treenode ** | rootptr, |
| int | value ) |
Inserts a number into the binary search tree.
| rootptr | Pointer to the root pointer of the tree. |
| value | The value to insert. |