If you want to make money online : Register now

What is the name of this size method calculating the size of a node?

, , No Comments
Problem Detail: 

My confusion is that if the recursive call calls the left nodes, and then adds with the right nodes, how are the nodes that are to to right of the left nodes and vice versa being called?

int size (BinaryNode t) {   if (t == null)      return 0;   else     return 1 + size(t.left) + size(t.right);    } 
Asked By : Mohamed Salad
Answered By : Luke Mathieson

Remember that to get the actual value of size(t.left), you have to evaluate the method size at the node t.left, i.e. assuming t.left has left and right children the algorithm with call size((t.left).left) and size((t.left).right).

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/39893

3200 people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback