Why to prefer red-black trees over AVL trees?

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
 
Answer: B
Explanation: 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.
 

Tìm kiếm

Back
Top