You are viewing a single comment's thread. Return to all comments →
public static Node insert(Node root,int data) { Node current = root; if(current == null){ return new Node(data); } while((current.left != null && current.data > data) || (current.right != null && current.data < data)){ if(current.data < data){ current = current.right; }else{ current = current.left; } } Node temp = new Node(data); if(current.data < data){ current.right = temp; }else{ current.left = temp; } return root; }
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Search Tree : Insertion
You are viewing a single comment's thread. Return to all comments →