Question bank › Binary Search Tree
Dsa Binary Search Tree Easy

Verify BST Properties

Write a program that verifies whether a given binary tree satisfies the properties of a binary search tree (BST). Implement the following functions: 1. `insert(root: Optional[Node], value: int) -> Node`: Insert a value into the BST. 2. `is_bst(root: Optional[Node], min_value: int, max_value: int) -> bool`: Check if the tree is a valid BST. Input format: - The first line contains an integer N (1 <= N <= 100) - the number of elements in the tree. - The next N lines contain one integer each, the value to be inserted into the BST. Output format: - Output a single boolean (true/false) indicating whether the tree is a valid BST. Example: Input: 5 10 5 15 1 8 Output: true

Key concepts

binary_search_treepropertiesvalidation

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.