tree_flashcards
What is a leaf node in a tree?
A node that has no children
What is a root node in a tree?
The top node in a tree that has no parent
What are siblings in a tree?
Nodes that share the same parent node
What are cousins in a tree?
Nodes that have parents who are siblings
What is the level/depth of a node?
The number of edges from the root to that node
`What is the height of a tree?
The number of edges in the longest path from root to any leaf
What is the degree of a node?
The number of children that node has
What is an edge in a tree?
The connection between two nodes
What is inorder traversal?
Visit left subtree, then root, then right subtree (LNR)
What is preorder traversal?
Visit root, then left subtree, then right subtree (NLR)
What is postorder traversal?
Visit left subtree, then right subtree, then root (LRN)
What is level-order traversal?
Visit nodes level by level, left to right
What makes a valid Binary Search Tree (BST)?
For every node: all values in left subtree are less than node’s value and all values in right subtree are greater
What makes a tree balanced?
the heights of left and right subtrees of any node differ by at most one (-1, 0, 1)
What is an AVL tree?
A self-balancing BST where heights of left and right subtrees differ by at most one for all nodes