Red Black Tree coloring bit

in python it’s quite difficult allocate  single bit for coloring a node as every thing in python is reference based. so it’s a nice practice to borrow a bit from the height of the red black tree, i.e just increment the height in 2’s and if the color is black just add one or else leave it. and we can retrieve the bit using height & 1 or height % 2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s