java - Bst tree delete() method doesnt work -
i implementing binary search tree , wondering, why delete() method doesn't work... findmin() method work, have tested out far. type in key, doesn't exist in 3 , right exception, whenever type in key, existing, doesn't remove node three... here code far: import java.util.nosuchelementexception; public class bst { node root; node head; node tail; public bst(){ root = null; } public void insert (node root, int key){ node newnode=new node(key); if(root==null){ root=newnode; } if(key<=root.getkey()){ if (root.getleft()!=null){ insert(root.getleft(), key); } else{ root.setleft(newnode); } } if (key>=root.getkey()){ if (root.getright()!=null){ insert(root.getright(),key); } else{ root.setright(newnode); } } } public void printtree(node root){ if (root==null) return; printtree(root.getleft()); ...