Question bank › Binary Search Tree
Dsa Binary Search Tree Easy

The Parental Gap

In a unique ID management system, IDs are stored in a Binary Search Tree (BST). The 'Parental Gap' of a node is defined as the absolute difference between its value and the value of its parent node. Given a sequence of unique integers to build a BST (inserted in the order provided) and a target value, find the Parental Gap of the target node. If the target node is the root of the tree or does not exist in the tree, output -1. Example: Input: 8 3 10 1 6 14; 6 Output: 3 Explanation: 8 is root. 3 is left child of 8. 6 is right child of 3. |6 - 3| = 3.

Key concepts

binary_search_treetree_traversal

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.