Write a method int size(Node tree) that returns the number of nodes in the binary tree whose root is tree.

What will be an ideal response?

Assuming a Node class

```
class Node
{
int element;
Node left, right;
Node(int el, Node left, Node right)
{
element = el;
this.left = left;
this.right = right;
}
}


```

```
int size(Node tree)
{
if (tree == null)
return 0;
else
return 1 + size(tree.left) + size(tree.right);
}

```

Computer Science & Information Technology

You might also like to view...

You must have a query open in Design view to launch the Expression Builder

Indicate whether the statement is true or false

Computer Science & Information Technology

A(n) ________learner is one who learns best by hearing information

Fill in the blank(s) with correct word

Computer Science & Information Technology