Question bank › Binary Search Tree
Dsa Binary Search Tree Hard

Sum of All Leaf Nodes in BST

Given the root of a binary search tree, write a program to compute the sum of all the leaf nodes in the BST. A leaf node is a node that has no children. The input format is: First line: an integer N, the number of nodes in the BST. Next N lines: each line contains an integer value representing a node's value in the BST. Output the sum of all the leaf nodes in the BST. Example: Input: 4 3 1 4 2 Output: 3

Key concepts

binary_search_treeleaf_nodessummation

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