Hey guys. Last week I programmed a AVL tree. This week i am trying to build a Btree. Can someone explain the differences between a AVL tree and a Btree. They seem kind of similar in the sense that both need balancing, but how different are they when it comes to coding them? Can I possibly just modify my AVL tree code and make it a Btree? Any suggestion would be much appreciated. Thanks.
Well, Btrees can have more than two paths spanning from each node, so I think you could generally use your AVL tree, and do some modifications to it. Why not do some reading on how to balance your Btree http://en.wikipedia.org/wiki/Btree
>They seem kind of similar in the sense that both need balancing,
>but how different are they when it comes to coding them?
Barring the fact that they're both trees and they're both balanced, AVL and B-Trees are quite different. The biggest difference is that B-Trees usually have a higher order than AVL trees (which are generally strictly binary). B-Trees are generally external data structures rather than internal because the node structure is well-suited to more expensive access of secondary storage.
The balancing algorithms are very different as well. Rather than storing balance factors and rotating, B-Trees use a fill-factor (how much of the node is full) and then split or merge adjacent nodes accordingly.
>Can I possibly just modify my AVL tree code and make it a Btree?
Not really. You'll find it easier to start from scratch with a B-Tree rather than convert an AVL tree to a B-Tree...