data-structures Binary Search Tree Creating a Node in BST

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The Binary Search Tree (BST) is a hierarchical data structure with a single pointer to the root node.

The Node in the BST generally contains "items" (such as numbers or names) for fast look up. Each node has at-most two children (left and right). Every node is organized by some key data field. For every node in BST its key is greater than left child's key and less than right child's key

A typical structure of node (which stores an integer) would be

struct bst_node {
    int item; 
    bst_node* left;
    bst_node* right;
}; 

There will be only one root node of BST. The root node can be created by

bst_node* root = NULL;
root = (bst_node*) malloc(sizeof(bst_node));

To set item key of root to 10.

root->item = 10;


Got any data-structures Question?