Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Red-Black Tree Implementation #38

Open
Kalkwst opened this issue Jan 14, 2023 · 0 comments
Open

✨ Add Red-Black Tree Implementation #38

Kalkwst opened this issue Jan 14, 2023 · 0 comments

Comments

@Kalkwst
Copy link
Owner

Kalkwst commented Jan 14, 2023

A red-black tree is a type of self-balancing binary search tree, which is used to efficiently store and retrieve data. It is similar to other types of self-balancing trees, such as AVL and AA trees, in that it automatically adjusts the structure of the tree to maintain a balance between its left and right branches. This ensures that the tree remains relatively balanced even as elements are added or removed, which improves the performance of search and insertion operations.

From a more technical perspective, a red-black tree is a self-balancing binary search tree that uses the concept of colour to ensure balance. Each node in the tree can be coloured either red or black, and the tree is balanced by enforcing certain constraints on the colour of the nodes. The constraints ensure that the number of black nodes on any path from the root to a leaf is the same for all paths and that no red node has a red child. When a new node is added to the tree, it is placed in the correct position based on its value and the tree is adjusted accordingly to maintain the balance and the constraints of the colour. The tree can be adjusted by performing rotations on the nodes and/or flipping the colour of the nodes. This way the tree can be adjusted to maintain the balance and ensure the constraints of the colour. The time complexity for search, insertion and deletion operations in a red-black tree is O(log n), which is faster than the O(n) time complexity of a typical unbalanced binary search tree.

@Kalkwst Kalkwst mentioned this issue Jan 14, 2023
26 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant