Question

When storing a binary tree or a B-Tree on a secondary storage device such as a disk or tape, does a binary tree ever have an advantage over a B-tree?

I was asked on an assignment "When do B-Trees have an advantage over binary trees?"

What I have come up with is that a B-Tree is better because it requires less frequent disk access (reads more data per node access), and jumps to less nodes to get to the final node. But the way the question is worded, it implies there is a point where a binary tree actually does have the advantage over a B-tree. So, is there a point when a binary tree is better (more efficient) than a B-Tree when they are stored on secondary storage?

Était-ce utile?

La solution

It is not correct to compare sorted tree (B-tree) and simple binary tree, they are not equal. So i suppose that you mean binary search tree.

B-Tree was designed to be efficient when data are stored on relatively slow storage. For example when you load or save data from file system with cluster size 4kb it doesn't matter how much of data in this range 0..4kb you need, it will take same time to read 1 byte or 4kb and it will really take time. B-tree keeps in mind that fact and use it. So in all normal/general usage scenarios it will be more efficient to use B-tree (from point of view used space and performance).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top