function to construct a BST from its level order traversal
def LevelOrder ( root , data ) : NEW_LINE INDENT if ( root == None ) : NEW_LINE INDENT root = getNode ( data ) NEW_LINE return root NEW_LINE DEDENT if ( data <= root . data ) : NEW_LINE INDENT root . left = LevelOrder ( root . left , data ) NEW_LINE DEDENT else : NEW_LINE INDENT root . right = LevelOrder ( root . right , data ) NEW_LINE DEDENT return root NEW_LINE DEDENT def constructBst ( arr , n ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return None NEW_LINE DEDENT root = None NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT root = LevelOrder ( root , arr [ i ] ) NEW_LINE DEDENT return root NEW_LINE DEDENT