You are viewing a single comment's thread. Return to all comments →
Node x = new Node(); x.data=value; if(root==null){ root = x; } else{ Node prev=null; while(root!=null){ prev=root; if(value<=root.data){ root=root.left; } else root=root.right; } if(value>prev.data) prev.right=x; else prev.left=x; } return root;
Hey, my code is almost same as your code, but I am getting Null Pointer Exception.Can you help me out with this?
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 →
Hey, my code is almost same as your code, but I am getting Null Pointer Exception.Can you help me out with this?