World's most popular travel blog for travel bloggers.

[Solved]: Building a Red Black tree out of a sorted array

, , No Comments
Problem Detail: 

If I have a sorted array of size $n$, can I build a Red Black tree out of it in $O(n)$ time in a different algorithm rather than splitting the tree in half every time or the straightforward way that was mentioned in one of the answers?

Asked By : Trinarics

Answered By : FrankW

This can be done in a very straightforward way: Just build an almost complete tree and make the nodes on the lowest level red.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/26299

0 comments:

Post a Comment

Let us know your responses and feedback