Trees Flashcards
What is a tree
A connected, undirected, non-cyclic graph
What is a rooted tree
One node is the root and all the other nodes branch away from the root
What is a binary tree
A tree where each node has a maximum of two children
How does a pre-order traversal work
Travel around the tree marking the node every time you pass the left of it
How does a in-order traversal work
Travel around the tree marking the node every time you pass below it
How does a post-order traversal work
Travel around the tree marking the node every time you pass the right of it
How do you implement a binary tree
Each node contains 3 parts: Data, left pointer to a child, right pointer to a child
When items are added to the tree the pointers will refer to the index position. If there is a -1 then the tree ends