Question bank › Binary Search Tree
Dsa Binary Search Tree Medium

Highest Subtree Density

In a BST, the 'Density' of a node is defined as the sum of all node values in its subtree divided by the number of nodes in that subtree. Build a BST from a sequence of unique integers. Find the node with the highest Density. If multiple nodes have the same density, output the one with the largest value. Input Format: - A space-separated list of integers. Output Format: - The value of the node with the maximum density (rounded to 2 decimal places if it were a float, but here just print the integer value of the node itself). Example: Input: 10 5 15 Output: 15 Explanation: Node 10: (10+5+15)/3 = 10. Node 5: 5/1 = 5. Node 15: 15/1 = 15. Max is 15.

Key concepts

binary_search_treetraversalmath

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.