Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
318 B
2
Indexable
TreeNode<int>* insertionInBST(TreeNode<int>* root, int val)
{
    if(root==NULL){
        TreeNode<int>* tmp=new TreeNode<int>(val);
        return tmp;
    }
    if(val<root->val) root->left=insertionInBST(root->left,val);
    if(val>root->val) root->right=insertionInBST(root->right,val);
    return root;
}