# Why to prefer red-black trees over AVL trees?

Category: QuestionsWhy to prefer red-black trees over AVL trees?
Editor">Editor Staff asked 5 months ago

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.

Editor">Editor Staff answered 5 months ago

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.

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40702