Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BinarySearchTree: wrong size() in example #10

Closed
art-in opened this issue Jul 16, 2017 · 1 comment
Closed

BinarySearchTree: wrong size() in example #10

art-in opened this issue Jul 16, 2017 · 1 comment

Comments

@art-in
Copy link
Contributor

art-in commented Jul 16, 2017

Original question

let tree = new BinarySearchTree
tree.add(1, 2, 3, 4)
tree.add(5)
tree.has(2)                           // true
tree.has(5)                           // true
tree.remove(3)                        // undefined
tree.size()                           // 3

Should be tree.size() // 4 (total number of nodes)

Or maybe tree.depth() // 3 (highest distance from root, in case it is not self-balancing BST)

@bcherny
Copy link
Owner

bcherny commented Jul 16, 2017

Typo - good catch @artin-phares!

@bcherny bcherny closed this as completed Jul 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants