Skip to content

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

Open
@marcopaivaf

Description

@marcopaivaf

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions