Hi, I'm in a data structures course, not very good with java, and I'm having issues with one of my assignments. I have to delete a node from this tree of animals, but my previous code doesn't seem to update the original tree with the new tree, I went ahead and deleted it and filled the deleteNode method with the professor's comments to help but I'm still very confused. Note that the method is required to be return a boolean so I really have no idea what to do.
BTNode<String> leaf = find(root,toDelete);
BTNode<String> grandparent;
BTNode<String> parent;
if (leaf != null)
{
//find grandparent of given node (leaf.getParent().getParent())
//is the original node to the left or right of grandparent?
//if leaf.getParent().getData().equals(grandparent.getLeft.getData()), then we are left, else we are right
//if parent.right.data = me, i am right, else I am left - sibling is the other
//set grandparent(branch l/r) = sibling (my parent.(other branch))
//set sibling.parent = grandparent
return true;
} else {
System.out.println("Animal not found");
return false;
}
}```