Driver program to test above functions
var root = null , temp = null , suc = null , min = null ; root = insert ( root , 20 ) ; root = insert ( root , 8 ) ; root = insert ( root , 22 ) ; root = insert ( root , 4 ) ; root = insert ( root , 12 ) ; root = insert ( root , 10 ) ; root = insert ( root , 14 ) ; temp = root . left . right . right ; suc = inOrderSuccessor ( root , temp ) ; if ( suc != null ) { document . write ( " " + temp . data + " " + suc . data ) ; } else { document . write ( " " ) ; }