Is This a Binary Search Tree?

  • + 19 comments

    Well , I just did an inorder traversal, stored them in a list and checked if they are in ascending order. If yes, then its a BST , else it isn't.

    This would work for all values (signed or unsigned) a node can possess.

    When compared with recursion (which has stack depth), space complexity remains the same in worst case.

    Time complexity also remains O(n) , only difference being that mine is a 2-pass solution.