Let us create following BST 50 / \ / \ 30 70 / \ / \ / \ / \ 20 40 60 80
Node * root = NULL ; root = insert ( root , 50 ) ; insert ( root , 30 ) ; insert ( root , 20 ) ; insert ( root , 40 ) ; insert ( root , 70 ) ; insert ( root , 60 ) ; insert ( root , 80 ) ; Node * pre = NULL , * suc = NULL ; findPreSuc ( root , pre , suc , key ) ; if ( pre != NULL ) cout << " Predecessor ▁ is ▁ " << pre -> key << endl ; else cout << " - 1" ; if ( suc != NULL ) cout << " Successor ▁ is ▁ " << suc -> key ; else cout << " - 1" ; return 0 ; }