Closed happy-san closed 3 years ago
@code-shoily can i ask questions about implementation?
Since the avlNode and simple node just differ in avlNode having a balance factor, would it be good for AvlNode class to extend Node? Or should I just repeat the members?
Similarly, the AvlTree class has same methods for searching and traversal, can it extend BinaryTree and just implement insertion and deletion?
Or perhaps create an abstract BinaryTree class and have it be implemented by BinarySearchTree, AvlTree and RedBlackTree since they all will have similar structure ?
I would say go for the abstract class way.
On Wed., Sep. 2, 2020, 1:21 p.m. Harpreet Sangar, notifications@github.com wrote:
Or perhaps create an abstract BinaryTree class and have it be implemented by BinarySearchTree, AvlTree and RedBlackTree since they all will have similar structure ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/code-shoily/algorithms-in-dart/issues/8#issuecomment-685881842, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLQEC2C3ZPVRVDRUH465FDSDZ5JBANCNFSM4QTC6BTQ .
Maybe try something like this:
class BinarySearchTree<T extends Comparable> implements BinaryTree<T> {
@override
void add(T value) {}
}
Implement AVL tree algorithm.