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.
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?!
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
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.
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.
Great video , Thanks you !
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?!
Right because the currentSize++ established only at the end of the function , and its represent the number of all nodes in the tree.
thanks
Hammer time at 2:37
Can someone please confirm if this code compiles? Because it's a void return method, why are we returning a recursive add method? Thanks
Remove the return your code will run...
the add method returns null, so returning a add() call returns the return of it which is null when the recursive stack terminates.
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
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.
@@guillermoperez8250 no he is returning void not null