Closed eytan-c closed 5 years ago
According to the project specifications, we don't need to insert a node if one already exists with its key. We just return -1 and do nothing.
@Onoam Let's decide on what functions to use for the finding.
Lot's of functions to go over. Some logic: For the actual inserting and deleting, wrote private functions that do the work (for readability). Also added some helper functions for different cases of delete. Regarding the search etc, I decided to go with what was in the slides, but let's discuss what to keep out of all the options. #5 #7 #6
also, I assumed the signature for rebalance
would be private int rebalance(WAVLNode node)
This tons of code! I can't actually read all of it in detail, but from what I read it looks good, I'm just gonna assume that it all is. ;)
Both are similar functions, but with different uses. 1) Select, finds the node in the tree, and returns an external node if the node doesn't exist. 2) findInsertParent - finds the node underwhich to insert a new node. The only issue that might arise in insert is if we want to insert a node with a key that is already in the tree. If we could return a tuple in Java that would solve it (and we can just have 1 function) but I don't know if that is possible.