AVL Tree (Module 8.3) Flashcards
What determines the cost of lookup?
how far down the tree needs to go
The number of nodes on the longest path from the root to a leaf is the ______ of the tree.
height
The lookup for a tree of height h has ALWAYS which complexity?
O(h)
A tree is balanced if ________, where h is its height and n is the number of nodes.
h - O(log n)
What are the 3 requirements for balanced trees?
1) the tree is a BST
2) all paths from the root to a leaf have height either h or h-1
3) the leaves at height h be on the left-hand side of the tree
Trees that remain balanced as inserting new nodes and continue to be a valid BST is known as?
self-balancing
What is it called when at every node, the heights of the left and right subtrees differ by at most 1?
height invariant
What is used when an imbalance occurs in a straight-line pattern?
Single Rotation
Which type of rotation occurs when a node is inserted into the left subtree of the left child?
LL (Left-Left) Rotation
Which type of rotation is performed on an unbalanced node for LL Rotation?
Right rotation
Which type of rotation occurs when a node is inserted into the right subtree of the right child?
RR (Right-Right) Rotation
Which type of rotation is performed on the unbalanced node for RR Rotation?
Left rotation