Is This a Binary Search Tree?

  • + 1 comment

    Inorder traversal of BST is always sorted. So you don't have to put elements into list. Store maximum element so far in a variable (say maxSoFar) and then just check if currentNode.data <= maxSoFar. It'll save you from iterating list.