top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why B Trees are used to implement databases?

+3 votes
865 views

Why B Trees are used to implement databases? Please explain with example.

posted Oct 20, 2013 by Atul Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
B-Trees are used to implement indexes which, in turn, improve the performance of the databases. Theoretically you can implement a relational database without any B-Trees, but the performance would be bad.

1 Answer

+1 vote

There are two parts to this question -
1) Why/how tree are used
Trees are used to implement indexes which, in turn, improve the performance of the databases, without which performance would be a big issue.

2) Why B Tree
B Tree are used because it is a balanced tree so the searching is fast as compare of any other option available.

answer Oct 20, 2013 by Sanketi Garg
Similar Questions
+2 votes

I'm curious as to why libstdc++ is using a RB-tree to implement std::set (details here
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/set and here https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/include/bits/stl_tree.h ),
when there are faster alternatives?

I'm mainly curious, because from all the people I've asked there hasn't been a single answer in favor of RB-trees, other than "they're already popular" or "easy to implement".

If you'd like more details on that, here's a link to my question on stackexchange http://cs.stackexchange.com/questions/41969/why-are-red-black-trees-so-popular,
where nobody has yet answered as well.

Using a variant of B-tree (or (a,b)-tree) should be faster, and everyone seems to suggest so, which makes me wonder what is the reason for picking RB-trees? This is not a question about their theoretical speed, but about real world behavior on real hardware with respect to CPU caches, etc.

+3 votes

Say I want to convert email into the structured data so that it can be stored into Database, any clue how to achieve this?

...