Question: We've shown that you can represent a binary tree using an array. Would it be good to implement Red - Black trees as an array?
We've shown that you can represent a binary tree using an array. Would it be good to implement RedBlack trees as an array?
It's difficult to say, because even with a RedBlack tree, the tradeoff between wasted space due to unused array elements and space savings due to the absence of pointers depends on the specifics of the actual tree.
No because each rotation would cause a large amount of data movement, killing performance gains.
Yes, because an array representation obviates the need for both child pointers and expensive parent pointers.
Yes, because we know that the tree has height, so the amount of unused array elements would be limited
No because it would be difficult to recolor array elements red and black.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
