Question bank › Trees
Dsa Trees Medium

Visible Nodes in Binary Tree

Given a binary tree, you need to determine how many nodes are 'visible' from the left side of the tree. A node is considered visible if it is the leftmost node at its level when viewed from the left side. Write a function that reads the binary tree from standard input in level-order format (where '#' denotes a null node) and prints the count of visible nodes. Input format: - The first line contains a space-separated list of values representing the binary tree in level-order. Output format: - A single integer representing the count of visible nodes. Example: Input: 1 2 3 # 5 # # Output: 2

Key concepts

treesdepth-first searchvisibility

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.