How to delete the largest node in Binary search Tree -


i trying delete largest node in binary search tree, thougth these code below should able reason not. please!

public void remove() {             node current = root;              while(true){                 node parent = current;                 current = current.getrighchild();                  if (current == null){                     parent.setrighchild(null);                     return;                 }             }         }        

public void remove()           {         root = deletemax(root);         }           private node deletemax(node x ) {     if (x.getrighchild() == null)         {         return x.getleftchild();          }     x.setrighchild(deletemax(x.getrighchild()));     return x; 

}


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -