(Node root, int key)
| 37 | /* A recursive function to |
| 38 | insert a new key in BST */ |
| 39 | Node insertRec(Node root, int key) |
| 40 | { |
| 41 | |
| 42 | /* If the tree is empty, |
| 43 | return a new node */ |
| 44 | if (root == null) |
| 45 | { |
| 46 | root = new Node(key); |
| 47 | return root; |
| 48 | } |
| 49 | |
| 50 | /* Otherwise, recur |
| 51 | down the tree */ |
| 52 | if (key < root.key) |
| 53 | root.left = insertRec(root.left, key); |
| 54 | else if (key > root.key) |
| 55 | root.right = insertRec(root.right, key); |
| 56 | |
| 57 | /* return the root */ |
| 58 | return root; |
| 59 | } |
| 60 | |
| 61 | // A function to do |
| 62 | // inorder traversal of BST |