Question bank › Binary Search Tree
Dsa Binary Search Tree Medium

Binary Search Tree Validator

Implement a function that reads a list of integers representing a binary search tree's in-order traversal and checks whether they can represent a valid binary search tree. The integers can represent the nodes in any order. A valid binary search tree (BST) must have the property that for each node, all values in the left subtree are less than the node's value and all values in the right subtree are greater than the node's value. Input Format: - A single line of space-separated integers representing the in-order traversal of a BST. Output Format: - Print 'Valid' if the sequence can represent a valid BST, otherwise print 'Invalid'. Example: Input: 2 1 3 Output: Valid Input: 2 3 1 Output: Invalid

Key concepts

binary_search_treevalidationrecursion

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.