Question bank › Trees
Dsa Trees Easy

Sum of All Nodes

Given a binary tree, compute the sum of all its node values. The tree is described by a level-order traversal where 'null' represents an empty node. Input format: - The first line contains an integer N, the number of nodes. - The next N lines each contain the values of the nodes. Output format: - A single integer which is the sum of all node values in the tree. Example: Input: 5 1 2 3 null null 4 5 Output: 15

Key concepts

treessumrecursion

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.