Driver code
if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT root = None NEW_LINE keys = [ 20 , 8 , 22 , 4 , 12 , 10 , 14 ] NEW_LINE for x in keys : NEW_LINE INDENT root = insert ( root , x ) NEW_LINE DEDENT k = 4 NEW_LINE res = kthSmallest ( root , k ) NEW_LINE if ( res == None ) : NEW_LINE INDENT print ( " There ▁ are ▁ less ▁ than ▁ k ▁ nodes ▁ in ▁ the ▁ BST " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " K - th ▁ Smallest ▁ Element ▁ is " , res . data ) NEW_LINE DEDENT DEDENT