Trees Flashcards
(5 cards)
What is a tree ?
A tree is a data structure that is made up of a collection of nodes,
One root node, each node has zero or more children,
Edges or links connect parent and child nodes.
What are the different tree properties ?
Depth of node - Number of edges between the root and that node,
Height of tree - Longest path from root to a leaf (node with no children),
Size - Total number of nodes.
What is a binary tree ?
Each node has at most two children,
Defined recursively - Either empty, or a root with two binary subtrees.
What are the types of binary trees ?
Full - Every node has 0 or 2 children,
Complete - All levels filled left to right except possibly the last,
Perfect - Complete tree with all leaves at the same depth,
Balanced - Height difference between left and right <= 1,
Degenerate - Each parent has only one child (linked list).
What are the two types of tree traversal ?
Depth first search,
Breadth first search.