Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Latest commit

 

History

History
25 lines (18 loc) · 643 Bytes

README.md

File metadata and controls

25 lines (18 loc) · 643 Bytes

Book Club Practice Problem

Write a function to see if a binary tree is "superbalanced" (a new tree property we just made up).

A tree is "superbalanced" if the difference between the depths of any two leaf nodes is no greater than one.

Here's a sample binary tree node class:

  class BinaryTreeNode(object):

    def __init__(self, value):
        self.value = value
        self.left  = None
        self.right = None

    def insert_left(self, value):
        self.left = BinaryTreeNode(value)
        return self.left

    def insert_right(self, value):
        self.right = BinaryTreeNode(value)
        return self.right