Hello. Great videos first of all. Second: when you add a new node_Object, you increment the size of the tree(currentSize++) correct? So in this case the field variable currentSize represents the number of nodes in the tree and not the height right?!
@markforest60357 жыл бұрын
Right because the currentSize++ established only at the end of the function , and its represent the number of all nodes in the tree.
@guillermoperez82506 жыл бұрын
Awesome. Just one typo: the overloaded method should be private, otherwise the counter will never be run. Also, making the insert position public doesn't sound like a good idea because people would mess it up.
@markforest60357 жыл бұрын
Great video , Thanks you !
@tonysmiah5 жыл бұрын
Can someone please confirm if this code compiles? Because it's a void return method, why are we returning a recursive add method? Thanks
@Shu-gm2xx5 жыл бұрын
Remove the return your code will run...
@mtushar3 жыл бұрын
the add method returns null, so returning a add() call returns the return of it which is null when the recursive stack terminates.
@karenjang52016 жыл бұрын
why do you use return for either "return add(obj, node.right)" or "return add(obj, node.left) in the 2nd method? It is void method, so I thought you can call it without return
@guillermoperez82506 жыл бұрын
I think he uses return to prevent next lines to be executed. And eventually, you'll always be returning null. Because the actual insertion returns null. The calls you mention return what the recursive call returns... and that will always be null if the insertion succeded.
@ahmidahmid93035 жыл бұрын
@@guillermoperez8250 no he is returning void not null