Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

what is the purpose of red and back colors in Red-Black tree?

I have read a good amount of Red-Black tree (wikipedia, …) but still don’t understand what are those colors back and red for.
What is the key purpose of those colors? Why do need need to mark our nodes with such colors?. What happens if we skip that part for a Red-Black tree? Please help.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The purpose of the colors is to ensure the tree remains roughly balanced. With no colors or other invariant to ensure that, in the worst case, you could end up with degenerate trees that are basically just less efficient linked lists.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading