code-shoily / algorithms-in-dart

Implementation of data structures and algorithms in Dart programming language.
221 stars 76 forks source link

AVL tree. #8

Closed happy-san closed 3 years ago

happy-san commented 4 years ago

Implement AVL tree algorithm.

happy-san commented 4 years ago

@code-shoily can i ask questions about implementation?

happy-san commented 4 years ago

Or perhaps create an abstract BinaryTree class and have it be implemented by BinarySearchTree, AvlTree and RedBlackTree since they all will have similar structure ?

code-shoily commented 4 years ago

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 .

happy-san commented 4 years ago

well how to overcome this?

code-shoily commented 4 years ago

Maybe try something like this:

class BinarySearchTree<T extends Comparable> implements BinaryTree<T> {
  @override
  void add(T value) {}
}