Trees Flashcards
What is a Node?
- The elements of the tree
- Each node contains a key which uniquely identifies that node
What is an Edge?
The link/connection between nodes
What is unique about the root node?
It has no parent
What are leaf nodes?
Nodes that have no child
What is a Path?
A sequence of nodes connected by edges
How is the length of a path determined?
Determined by the number of nodes in the path (including start and end nodes)
What is a Parent node?
The unique predecessor of every node
What is a Child node?
The successor to a parent node
What are Sibling nodes?
Nodes that have a common parent
What is the Level of a node?
- The number of nodes between this node and the root node
- Calculated using the shortest path to the root node
What is the height of a tree?
The height is determined by the highest level node
What are Sub-trees?
- A Sub-tree is formed using a parent node and all of it’s descendants.
- The parent node becomes the root node of the Sub-tree.
What is the difference between a Strictly Binary Tree and a Knuth Binary tree?
- Each node in a Strictly Binary tree has either 0 or 2 sub-trees
- Each node in a Knuth Binary Tree can have 0, 1 or 2 sub trees
What 3 qualities make Trees a recursive data structure?
- The data of the node itself
- A reference to the left child node (can be null)
- A reference to the right child node (can be null)
What makes a tree balanced?
All leaf nodes have the same level