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 ) ; for ( k = 1 ; k <= 7 ; k ++ ) document . write ( KSmallestUsingMorris ( root , k ) + " " ) ;