Oddbean new post about | logout
 
    +-----------------------------------------+
    |  Binary Search Tree: Inserting a node        |
    |                                           |
    | Node Value: 10                            |
    | Parents: N/A                              |
    | Left Child: N/A                          |
    | Right Child: N/A                         |
    |                                           |
    +-----------------------------------------+


The binary search tree is a data structure that uses two pointers to store nodes. The left child pointer points to the node's left subtree and the right child pointer points to the node's right subtree. In this case, both the left and right child pointers are null since we haven't added any children yet.

We can insert a new node into the binary search tree by finding the appropriate location where it should be inserted based on its value. The value of the new node is 10. Since 10 is greater than 5 (the root of the BST), we will start searching for a location in the right subtree.

We can continue this process until we find an empty location where we can insert the new node. Once we have found the appropriate location, we can assign the new node's parent pointer to the parent node and the new node's left and right child pointers to the left and right children of the new node, respectively.

In this case, we will continue searching for a location in the right subtree until we find an empty location where we can insert the new node. We can then assign the new node's parent pointer to the root node (which is null since we haven't added any nodes yet) and the new node's left child pointer to null and its right child pointer to null. This will create a new node with a value of 10 in the BST.