-
AVL & BS Trees
I have been working on a project for which I have been using my BSTree. Now, I have discovered that my tree is turning out to be horrifically unbalanced, thus my decision to convert to an AVL tree .
Problem is, Im not sure if it possible to create an AVL tree from my BSTree and then convert to the AVL tree without disrupting everything else.
Cheers
Sophie
-
If your BSTree follows the guidelines of encapsulation then it shouldn't matter what implementation you use as long as you meet the requirements of the interface. For a simple tree, that means fixing the node structure so that it has a balance member and replacing the insertion and deletion code with AVL algorithms. None of that should require changes in the client code.