Search code examples
binary-search-treered-black-tree

Isn't a Red-Black tree better than Binary Search Tree


Just as the title says, with account to scalability, it seems like Red-Black Tree is always better to choose as your data structure. Purely looking at the time complexity, it's either the same or always better.

Why would you even ever need to use a binary search tree? For very small scale searches?


Solution

  • In 'real' code you would likely never choose an unbalanced BST, but it is useful to introduce the BST concept before adding the complexity that self-balancing (whether RB, AVL or some other method) adds. It is also useful to introduce the pure BST because the search algorithm is then the same regardless of what method of balancing is used.