DEV Community

Discussion on: Implementing a Basic Binary Search Tree in JavaScript

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

Just a minor note: you've overlooked the case where the value of the node you're trying to insert is equal to the current node, not strictly greater than or less than the node's value. Either the left or right subtree can be arbitrarily chosen for this, as long as you're consistent.

Collapse
 
seanwelshbrown profile image
Sean Welsh Brown

Thank you very much for the heads up, Aleksandr! I hadn't considered that case, although it seems quite obvious now that you mention it. I'll keep that in mind moving forward. 👍