Abstract
A red–black tree (RBT) is a type of Binary Search Tree where a new parameter – color for each node – has been defined (Figure 12-1). We learned that after some insert and delete operations, the binary search trees become unbalanced which creates a linked list. Red–black trees solve this problem by balancing elements. Each node has a color which can be black or red. Thus, when declaring a node for the RBT, it must contain a key/value, a color, the reference to a parent node, and the references for the children nodes. RBTs are very useful for worst-case scenarios when processing search, insertion, and deletion operations.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsAuthor information
Authors and Affiliations
Rights and permissions
Copyright information
© 2020 Elshad Karimov
About this chapter
Cite this chapter
Karimov, E. (2020). Red–Black Tree. In: Data Structures and Algorithms in Swift. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5769-2_12
Download citation
DOI: https://doi.org/10.1007/978-1-4842-5769-2_12
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-5768-5
Online ISBN: 978-1-4842-5769-2
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)