Trees
•	Chapter 8: starts with description of a general tree. Similar to the one from MAT 305
•	Trees are used to represent different hierarchies (Figure 8.1-8.4)
•	Terminology
•	Nodes
•	root
•	leaves: are nodes with no children
•	children
•	parent
•	siblings
•	ancestors
•	descendants
•	We are interested in a specific type of tree called binary tree
•	The following definition sets the tone for the whole chapter:
•	A binary tree T is either empty
•	consists of an item, called the root item, and two disjoint binary trees, called the left subtree and right subtree of T.

•	this definition of a binary tree is recursive
•	a node in the binary tree can have 0, 1, or 2 children
•	0 children means both subtrees are empty
•	1 child means one subtree is empty
•	2 children means both subtrees are not empty
•	The order of the subtrees is important
•	Inorder A,

	Ancestor. A is an ancestor of B if A is the root of a tree consisting of B.
•	The following recursive definition is easier to program
	A is an ancestor of B if
1.	A is parent of B
2.	There exists a C such that A is parent of C and C is ancestor of B.
•	Siblings
•	A is a sibling of B if A is not equal to B and there exists a C such that C is parent of A and C is parent of B.
•	First cousin
•	A is a first cousin of B if there exists C and D such that C is parent of A and D is parent of B, and C and D are siblings
•	Let us first understand all the concepts and then look at the ADT definition
•	Traversals
•	Inorder traversal
•	Traverse the left subtree
•	Visit the node (generally print the contents)
•	Traverse the right sub tree
•	Preorder traversal
•	Visit the node (generally print the contents)
•	Traverse the left subtree
•	Traverse the right sub tree
•	postorder traversal
•	Traverse the left subtree
•	Traverse the right sub tree
•	Visit the node (generally print the contents)
•	breadth first traversal
•	Start from level 1 and for every level visit the nodes from left to right
•	The actual algorithm is a bit more complicated
•	The convention used in this book is different from the one we used for search trees.
•	Empty subtree has a height of 0
•	Root is at level 1