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

Binary Search Tree (BST) - Wrong count explanation #945

Open
marcopaivaf opened this issue Sep 10, 2020 · 0 comments
Open

Binary Search Tree (BST) - Wrong count explanation #945

marcopaivaf opened this issue Sep 10, 2020 · 0 comments

Comments

@marcopaivaf
Copy link

Hey!

Thank you so much for putting all this together. Really great stuff!
I just notice a small, minor typo in the BST readme that may confuse people.

In the Binary Search Tree (BST) readme, it describes the count variable as follow:

The count property determines how many nodes are in the subtree described by this node. This does not just count the node's immediate children but also their children and their children's children, and so on. If this particular object is the root node, then it counts how many nodes are in the entire tree. Initially, count = 0.

It says that initially, count = 0. Although, this is not true as the node always counts itself (+1):
(left?.count ?? 0) + 1 + (right?.count ?? 0)

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

1 participant