PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Snowflake

Compute height of tree with deleted nodes; minimize deletions

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of tree data structures, connectivity after node deletions, and optimization for minimizing additional removals, and is categorized under Coding & Algorithms. It is commonly asked to assess reasoning about tree pruning and height computation under constraints, testing both conceptual understanding of tree properties and practical algorithmic implementation.

  • hard
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Compute height of tree with deleted nodes; minimize deletions

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given a rooted tree (not necessarily binary). Each node has a list of children. Some nodes are marked as `deleted = true`. Define the **effective tree** as the tree after removing every deleted node and all edges incident to it; nodes that become disconnected from the root are not counted. 1) Compute the **height** of the effective tree (maximum number of nodes on any root-to-leaf path in the effective tree; if the root is deleted, the height is 0). 2) Follow-up: Given an integer `K`, delete the **minimum number of additional nodes** (you may choose any nodes to delete) so that the height of the effective tree is **at most `K`**. Return that minimum number of additional deletions. Clarify in your solution what “deleting a node” means (assume a deleted node is removed and you cannot traverse through it from the root).

Quick Answer: This question evaluates understanding of tree data structures, connectivity after node deletions, and optimization for minimizing additional removals, and is categorized under Coding & Algorithms. It is commonly asked to assess reasoning about tree pruning and height computation under constraints, testing both conceptual understanding of tree properties and practical algorithmic implementation.

Related Interview Questions

  • Solve Array Distance and Wiki Navigation - Snowflake (medium)
  • Implement Document Predicate APIs - Snowflake (medium)
  • Find Shortest Wiki Click Path - Snowflake (medium)
  • Schedule prerequisite classes with retakes - Snowflake (easy)
  • Solve three coding rounds - Snowflake (medium)
Snowflake logo
Snowflake
Jan 16, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0

You are given a rooted tree (not necessarily binary). Each node has a list of children. Some nodes are marked as deleted = true.

Define the effective tree as the tree after removing every deleted node and all edges incident to it; nodes that become disconnected from the root are not counted.

  1. Compute the height of the effective tree (maximum number of nodes on any root-to-leaf path in the effective tree; if the root is deleted, the height is 0).
  2. Follow-up: Given an integer K , delete the minimum number of additional nodes (you may choose any nodes to delete) so that the height of the effective tree is at most K . Return that minimum number of additional deletions.

Clarify in your solution what “deleting a node” means (assume a deleted node is removed and you cannot traverse through it from the root).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snowflake•More Software Engineer•Snowflake Software Engineer•Snowflake Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.