#=====================================================================
# Author: Isai Damier
# Title: Is Empty
# Project: geekviewpoint
# Package: algorithms
#
# Time Complexity of Solution:
# Best = Average = Worst = const.
#
#=====================================================================
class BST( object ):
def __init__( self ):
self.root = None
def getRoot( self ):
return self.root
def isEmpty( self ):
return self.root is None
import unittest
from algorithms.BST import BST
from cStringIO import StringIO
import sys
class Test( unittest.TestCase ):
#=====================================================================
# Test of isEmpty method, of class BST.
#=====================================================================
def testIsEmpty( self ):
bst = BST()
expResult = True
result = bst.isEmpty()
self.assertEquals( expResult, result )
bst.add( 5 )
result = bst.isEmpty()
expResult = False
self.assertEquals( expResult, result )