// e. to delete all leaves from a binary tree
public static void delete(BSTNode test) {
if ((test.left == null) && (test.right == null))
delete(test = null); ...
|
Building a tribunary tree in Java and my delete functionality doesn't seem to be working. Can anyone help me understand why won't delete variable node?
node = null;
My Code, just compile and ... |
My Binary Search Tree program doesn't seem to be deleting anything when I call the deleteNode method. The BST is built perfectly, its just deleting the node part that doesn't work. ... |
public void deleteLeaves(BSTNode<T> p){ //deletes leaves
if(p.left != ...
|
I've been working on this homework for the last week or so and I've been caught on this (hopefully) last hiccup all day. Just so you know, it's a binary search ... |
ok, i know one is not supposed to subclass a java class unless it adds new and useful functionality, so forgive me, I am still learning. This class saves a list of actor (String) names in my application. It works well for this purpose and I can add a new actor name. I want to be able to delete a name, ... |
Hi all, I'm not sure how to go about asking this... I need to delete a node. What I have works on a specific data set, but not another. I read in two data sets as follows; A 28 A 19 A 34 A 2 R 2 A 51 A 28 R 16 R 19 P This returns: 2 this is ... |
|
Hi again, I've got something that's been bugging me. For this binary tree deleteNode function, when a node is found, the method deleteFromTree is called on it. I understand everything, except: this may sound silly, but it seems that the method passes the target node on in a roundabout way. As you see, when found == true, we don't simply pass ... |
I've got something that's been bugging me. For this binary tree deleteNode function, when a node is found, the method deleteFromTree is called on it. I understand everything, except: this may sound silly, but it seems that the method passes the target node on in a roundabout way. As you see, when found == true, we don't simply pass current as ... |
Josh Haverford wrote: // e. to delete all leaves from a binary tree public static void delete(BSTNode test) { if ((test.left == null) && (test.right == null)) delete(test = null); ///test.current element??? not whole test tree } i am having trouble doing this - any suggestions? I guess I'm having trouble understanding what this is supposed to do. The ... |
I read elsewhere that the primary way to remove a node with one child is to take the pointer of the current node and point it instead to the current node's child, but we're not allowed a compareTo, remove() or findParent() method on the final exam. The whole thing has to be from scratch. |
|
|
bug, For a start you need to break out of the static mentality. A Tree is-an object... and what does a Tree contain? Why TreeNode's of course. Also WTF is "root" doing in a tree node? Did you mean "item", or "value", or "data" or something like that? I think you did. The Tree has a "root" element (which is-a TreeNode) ... |
|
|
/** * Deletes the node passed in as an argument to this method. If this node has non-null data, then both the node and the data will be deleted. * Also deletes any other nodes in the tree that are no longer needed after the deletion of the node first passed in as an argument to this method. */ |
|