Trees Flashcards
1
Q
What is a binary search tree (BST)?
A
Left subtree < root < right subtree.
2
Q
What is the difference between a BST and a heap?
A
BST supports ordered access, Heap is optimized for min/max extraction.
3
Q
What is an AVL tree?
A
Self-balancing BST
4
Q
What is the purpose of tree rotations in AVL trees?
A
Used in AVL trees to maintain balance.
5
Q
What is the difference between a B-tree and a BST?
A
B-Trees allow multiple children per node (good for databases).
6
Q
What is a Trie? What are its use cases?
A
Prefix tree for fast word lookup.
7
Q
How does a segment tree work?
A
Fast range queries (O(log n) updates and queries).
8
Q
What is the purpose of an interval tree?
A
Efficiently handles interval-based queries.