← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Meta technical phone screen, one question about BST deletion. Pretty straightforward topic but the details will trip you up if you haven't actually coded it recently.

Questions Asked (1)

Q1

Walk through how deletion works in a binary search tree, covering all the cases.

Algorithms & Data Structures
Author's notes

The leaf node case and the single-child case came out fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the BST property and the three deletion cases: leaf, one child, two children. For the two-child case, explain replacing the node with its in-order successor (or predecessor) and recursively deleting that successor. Emphasize maintaining BST invariants and discuss time complexity.

Pro tip: Mention that using the in-order predecessor instead of successor can reduce tree height in some cases, and note that deletion in a balanced BST is O(log n) but O(n) in the worst case.

1. Define BST and deletion goal

State that a BST maintains left < root < right, and deletion must preserve this property. The goal is to remove a node while keeping the tree valid.

2. Case 1: Node is a leaf

Simply remove the node by setting its parent's pointer to null. This is the simplest case.

3. Case 2: Node has one child

Replace the node with its only child by updating the parent's pointer to point to the child. The subtree remains valid.

4. Case 3: Node has two children

Find the in-order successor (smallest node in right subtree) or predecessor (largest in left subtree). Copy its value to the node, then recursively delete the successor/predecessor from its original position.

5. Analyze complexity and edge cases

Discuss time complexity: O(h) where h is height, O(log n) for balanced, O(n) for skewed. Mention edge cases like deleting root or node not found.

Key Points to Mention

  • BST property: left subtree < node < right subtree
  • Three cases: leaf, one child, two children
  • For two children, use in-order successor (or predecessor)
  • Recursive deletion of successor/predecessor
  • Time complexity: O(h), best O(log n), worst O(n)
  • Edge cases: deleting root, node with no children, node not present

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.