Question bank › Binary Search Tree
Dsa Binary Search Tree Easy

Binary Search Tree Height

Given a binary search tree (BST), calculate its height. The height of a tree is the number of edges in the longest path from the root node to a leaf node. If the tree is empty, the height is -1. Input Format: The first line contains an integer n, the number of nodes in the BST. The next n lines contain integers, each representing a node's value to be inserted into the BST. Output Format: Print a single integer, the height of the tree. Example: Input: 5 10 5 15 3 7 Output: 3

Key concepts

binary_search_treetree_heightdepth

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.