PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of binary tree properties and traversal techniques, testing competency in data structures and algorithmic reasoning related to tree completeness.

  • medium
  • Snapchat
  • Coding & Algorithms
  • Software Engineer

Check if a binary tree is complete

Company: Snapchat

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given the root of a binary tree. Determine whether the tree is a **complete binary tree**. A binary tree is complete if: - Every level, except possibly the last, is completely filled. - All nodes in the last level are as far left as possible. ### Input - `root`: root node of a binary tree (or `null`). ### Output - Return `true` if the tree is complete; otherwise return `false`. ### Constraints - Number of nodes: `0..10^5` - Node values are irrelevant to completeness. ### Notes - Aim for an algorithm that is correct for large trees; discuss time complexity and space usage (e.g., typical BFS approach vs. any space optimizations).

Quick Answer: This question evaluates understanding of binary tree properties and traversal techniques, testing competency in data structures and algorithmic reasoning related to tree completeness.

Given level-order values with None holes, return whether the tree is complete.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,2,3,4,5,6],)

Expected Output: True

Explanation: Complete tree.

Input: ([1,2,3,4,None,6,7],)

Expected Output: False

Explanation: Node after gap.

Input: ([],)

Expected Output: True

Explanation: Empty tree complete.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Determine Whether Courses Can Be Completed - Snapchat (medium)
  • Solve Decimal Coin Change - Snapchat (medium)
  • Find Maximum Island Perimeter - Snapchat (medium)
  • Solve Three Algorithmic Tasks - Snapchat (hard)
  • Implement a Timestamped Counter - Snapchat (medium)