creating following BST * 5 / \ 2 12 / \ / \ 1 3 9 21 / \ 19 25
var root = null ; root = insert ( root , 25 ) ; insert ( root , 2 ) ; insert ( root , 1 ) ; insert ( root , 3 ) ; insert ( root , 12 ) ; insert ( root , 9 ) ; insert ( root , 21 ) ; insert ( root , 19 ) ; insert ( root , 25 ) ; document . write ( findMaxforN ( root , N ) ) ;