Let us create following BST 50 / \ / \ 30 70 / \ / \ / \ / \ 20 40 60 80
var root = null ; root = insert ( root , 50 ) ; insert ( root , 30 ) ; insert ( root , 20 ) ; insert ( root , 40 ) ; insert ( root , 70 ) ; insert ( root , 60 ) ; insert ( root , 80 ) ; findPreSuc ( root , key ) ; if ( pre != null ) document . write ( " " + pre . key + " " ) ; else document . write ( " " ) ; if ( suc != null ) document . write ( " " + suc . key ) ; else document . write ( " " ) ;