•	The recursive algorithm for height
•	if(!r) return 0;
•	return max(height(r->leftchild),height(r->rightchild))
•	See the board for trace of the execution
•	The recursive algorithm for size
•	if(!r) return 0;
•	return (1+size(r->leftchild),size(r->rightchild))
•	See the board for trace of the execution
•	To write a Size function which does not use global variables, we will go like this
•	int Size(){return Size(root));}
template <class T>
int BinaryTree<T>::Size(BinaryTreeNode<T> *t) const
{
   if (!t) return 0;               // empty tree
   return(1+ Size(t->LeftChild) + Size(t->RightChild));
}
•	The only non-recursive algorithm in binary tree is levelorder
•	One can come up with a recursive algorithm, which takes O(n log n), it can be further improvd to give O(n), but it is more complicated than iteration
•	Iterative algorithm is the easiest to understand in this case.
•	Any recursive algorithm can be written iteratively and vice versa. The time requirements using Big Oh notations will be the same. The choice depends on which one is more readable.
•	We use a queue for level order, see the example on the board.
•	We haven’t seen applications of Binary tree so far.
•	Generally, application decide how a tree whould be built
Binary Expression Trees
•	9 + 8 * 7. Infix expression need to specify the operator precedence. If we want to override the precedence, we use brackets: (9+8)*7
•	Prefix and postfix notations

•	These trees correspond to the two different infix expressions we had on top of the page
•	The preorder traversals give us prefix expressions also known as Polish notations. Postorder traversals give us postfix expressions also known as reverse-polish notations. Inorder traversals don’t give us infix notations, because they will have to be modified by using parantheses.
•	We will look at:
1.	How to evaluate a binary expression tree?
2.	How to construct a binary expression tree from prefix expressions
•	These two will be sufficient to do the third assignment (we are not going to do part d and e of Exercise 33 on page 499).
3.	We will also look at how to use stack to evaluate postfix experssions
4.	How to use stack to create postfix expression from an infix expression
•	Steps 3 and 4 allow us to build an infix calculator
•	Step 3 by itself is the postfix calculator