Skip to content

What if i want to find the height of the BST ? #1

@rittamdebnath

Description

@rittamdebnath

Is this the right approach ?

class node:
    def getHeight(self):
        if self is None:
            return -1
        return 1 + max(self.leftChild.getHeight(), self.rightChild.getHeight())

class Tree:
    def getHeight(self):
        if self.root:
            return self.root.getHeight()
        else:
            return -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions