Smiljana Knezev wrote
> Dear all,
> 
> I've written about implementing binary search trees:
> https://pharokeepers.github.io/pharo/2019/07/07/SmiljanaBinarySearchTreeinPharo.html
> 
> Feedback and opinions is always welcome :)
> 
> Best regards,
> Smiljana Knezev

Your implementation is unnecesarily complicated. 

Remember, tree is a recursive data structure. You may have have reasons to
split tree and node into different classes, but at least delegate operations
to node.

For example, #depth and #size can be defined as following methods of Node
class:

depth
    self isLeaf ifTrue: [ ^ 0 ].
    ^ leftChild depth max: rightChild depth

size
    self isLeaf ifTrue: [ ^ 1 ].
    ^ leftChild size + rightChlid size

Most other operations can also be defined in similar fashion.




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Reply via email to