package lintcode.bst;

import fundamentals.tree.TreeNode;

/**
 */
public class MyBst {

    // 85-Insert Node in a Binary Search Tree
    public TreeNode insertNode(TreeNode root, TreeNode node) {
        if (root == null) return node;
        if (node.val < root.val) {
            root.left = insertNode(root.left, node);
        } else {
            root.right = insertNode(root.right, node);
        }
        return root;
    }

    

}

@@ -432,12 +432,470 @@
  %7D%0A%0A    
+public TreeNode insertNode_iterative(TreeNode root, TreeNode node) %7B%0A        TreeNode cur = root, par = null;%0A        while (cur != null) %7B%0A            par = cur;%0A            cur = (node.val %3C cur.val) ? cur.left : cur.right;%0A        %7D%0A        if (par == null) %7B // root is empty%0A            root = node;%0A        %7D else if (node.val %3C par.val) %7B%0A            par.left = node;%0A        %7D else %7B%0A            par.right = node;%0A        %7D%0A        return root;%0A    %7D
 %0A%0A%7D%0A

Implement my binary search tree