Let us create following BST 50 / \ / \ 30 70 / \ / \ / \ / \ 20 40 60 80
root = None NEW_LINE root = insert ( root , 50 ) NEW_LINE insert ( root , 30 ) NEW_LINE insert ( root , 20 ) NEW_LINE insert ( root , 40 ) NEW_LINE insert ( root , 70 ) NEW_LINE insert ( root , 60 ) NEW_LINE insert ( root , 80 ) NEW_LINE pre , suc = [ None ] , [ None ] NEW_LINE findPreSuc ( root , pre , suc , key ) NEW_LINE if pre [ 0 ] != None : NEW_LINE INDENT print ( " Predecessor ▁ is " , pre [ 0 ] . key ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " - 1" ) NEW_LINE DEDENT if suc [ 0 ] != None : NEW_LINE INDENT print ( " Successor ▁ is " , suc [ 0 ] . key ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " - 1" ) NEW_LINE DEDENT