Unit 2: Trees Flashcards
n-trees
trees with more than two children
n-tree application
the linux ls command
Binary tree
Tree in which each node has at most two children
Binary Search Tree
Binary tree in which all nodes are ordered from left to right
leaf
node with no children
height
- length of longest path from root to leaf
- start from bottom when determining height
depth
length from root to specific node
max number of nodes formula
2^(h+1) - 1
when is a tree full?
when its at its maximum capacity for its height
when is a tree complete?
when each node has either zero or two children and the leaves are ordered from left to right with no gaps
PostOrder traversal
Left, Right, Print
InOrder traversal
Left, Print, Right
Sequential Trees
efficiently storing a tree onto a disc
Less efficient way of representing a BT as a sequential tree
PreOrder traversal while representing null links with a /
More efficient way of representing a BT as a sequential tree
PreOrder traversal with internal nodes being represented with a prime mark, all null links being represented by a / however a leaf’s null links are not represented at all.
- A’ = internal Node
- B = leaf
- / = null link