When to choose RB tree, B-Tree or AVL tree?

Palladin picture Palladin · Oct 19, 2009 · Viewed 28.8k times · Source

As a programmer when should I consider using a RB tree, B- tree or an AVL tree? What are the key points that needs to be considered before deciding on the choice?

Can someone please explain with a scenario for each tree structure why it is chosen over others with reference to the key points?

Answer

blwy10 picture blwy10 · Oct 19, 2009

Take this with a pinch of salt:

B-tree when you're managing more than thousands of items and you're paging them from a disk or some slow storage medium.

RB tree when you're doing fairly frequent inserts, deletes and retrievals on the tree.

AVL tree when your inserts and deletes are infrequent relative to your retrievals.