Question bank › Binary Search Tree
Dsa Binary Search Tree Medium

Validate Binary Search Tree

Write a program that validates whether a binary tree is a binary search tree (BST). A binary search tree must satisfy that all left subtree nodes are less than the root node and all right subtree nodes are greater than the root node. The input will consist of a series of node values indicating a level order traversal. The program should determine and print 'True' if it is a valid BST, otherwise print 'False'. Input Format: - The first line contains an integer N, the number of nodes in the binary tree. - The next N lines each contain an integer representing the node value (use -1 for null). Output Format: - Print 'True' or 'False'. Example: Input: 5 2 1 3 -1 -1 Output: True

Key concepts

binary_search_treevalidationrecursive

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.