Wednesday, August 12, 2009

When to use b tree and when b+ tree

B trees are specifically used when we need to seek the data... In case of b trees, frequently seeked data can be moved up in the tree so that next time less number of access or look ups would be required.

B+ trees are used when we need to do full scan. Some other advantage of B+ trees is that high fanout, less seeks required as more pointers are available for data lookup which is in contrast to B tree where intermediate nodes stores data values which waste the look up pointer space.

In B+ tree, leaf nodes are connected as linked list which makes it easier to traverse.
Also in B+ tree, depth of the tree is small and a uniform implementation can be achieved as non-leaf nodes acts as indexes and leaf nodes acts as data holder...

Practically... indexes can be placed in the cache while actual data can be placed in the hard disk.

For detailed analysis:
http://stackoverflow.com/questions/870218/b-trees-b-trees-difference

Also look into wikipedia articles on addition, deletion of nodes...

No comments:

Post a Comment