Dsa
Binary Search Tree
Warm-up
Sum of All Values
Given a binary search tree, compute the sum of all the values of the nodes in the tree. Input format: The first line contains an integer n (number of nodes). The next n lines each contain an integer value for the nodes in the BST. Output the sum of the values of all nodes. Example: Input: 3
3
1
4
Output: 8
Key concepts
binary_search_treesumtraversal
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