Why to prefer red-black trees over AVL trees?
(a) Because red-black is more rigidly balanced
(b) AVL tree store balance factor in every node which costs space
(c) AVL tree fails at scale
(d) Red black is more efficient
This key question is from AVL Tree topic in section Binary Trees of Data Structures & Algorithms I
The question was asked in an online interview.
The correct choice is (b) AVL tree store balance factor in every node which costs space
The explanation is: Every node in an AVL tree need to store the balance factor (-1, 0, 1) hence space costs to O(n), n being number of nodes. but in red-black we can use the sign of number (if numbers being stored are only positive) and hence save space for storing balancing information. there are even other reasons where redblack is mostly prefered.