Trees Flashcards
What is a Binary Tree?
A binary tree is a collection of nodes. Each node has a data value and references to two other nodes. Each node could have a left child and/or a right child.
What is a Tree Node?
A tree node typically has a data component and a reference to a left child and a reference to a right child.
When adding to a Binary Search Tree, how is the placement decided?
- The left child is less than the parent and the right child is greater.
- It’s always first compared to the root.
What are the four different orders?
1) In-Order
2) Pre-Order
3) Post-Order
4) Rev-Order
What’s the order for In-Order?
Left Data Right
What’s the order for Pre-Order?
Data Left Right
What’s the order for Post-Order?
Left Right Data
What’s the order for Rev-Order?
Right Data Left
What is the width in a Tree?
It’s the distance between two furthest leaves in the tree
does not have to do through the root
What is the height in a Tree?
It’s the longest part from root to a leaf number of links from root to farthest leaf
What is the level in a tree?
It’s a group of equal nodes
ex. root is level 0
(ex. the children of the root is level 1)
How can a Binary Tree be full?
- Every parent has exactly two children or no children at all.
- Any levels that are not full have all nodes shifted as far left as possible
What is a Expression Tree?
A binary expression tree is a binary tree in which each parent node contains an operator and each leaf contains a number.
What is a Threaded Tree?
A threaded binary tree is a binary tree with an additional reference in each node that is used to point from a child back to its parent.