Question bank › Trees
Dsa Trees Medium

Count Nodes at Even Levels

You are given a binary tree, and you need to count the number of nodes that are located at even levels (0-indexed). Input format: The input starts with an integer n, the number of nodes (1 <= n <= 1000). Then, n lines follow, each containing the node value and the left and right children values (or -1 if no child). Output format: Print a single integer indicating the count of nodes at even levels. Example: Input: 5 1 2 3 2 -1 -1 3 4 5 4 -1 -1 5 -1 -1 Output: 3

Key concepts

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