Serve Reads and Deletions Through a Tree of Vdisk Snapshots

Last updated: November 29, 2026

Quick Overview

Implement a snapshot tree supporting create_vdisk, write(vdisk, block, data), read(vdisk, block), snapshot(vdisk), clone(snapshot) and delete_snapshot(snapshot), where snapshots are read-only, reads fall through to ancestors, and deleting a snapshot must preserve what every descendant reads.

Nutanix
Coding & Algorithms
Software Engineer
Nutanix
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Implement a snapshot tree supporting create_vdisk, write(vdisk, block, data), read(vdisk, block), snapshot(vdisk), clone(snapshot) and delete_snapshot(snapshot), where snapshots are read-only, reads fall through to ancestors, and deleting a snapshot must preserve what every descendant reads.

Nutanix snapshots and clones use redirect-on-write: new writes go to a fresh layer and unchanged blocks are read from parents, which creates snapshot chains that must later be collapsed when old snapshots expire. This onsite problem tests pointer-heavy design, the merge semantics on delete, and awareness of read amplification from deep chains.

What the Interviewer Expects
  • Models live vdisks as leaves and snapshots as immutable interior nodes
  • Makes snapshot O(1) by handing the current layer to the new snapshot node
  • Reads walk the parent chain and return zeros for never-written blocks
  • On delete, pushes the snapshot's blocks only into descendants that do not override them
  • Uses merge-smaller-into-larger when there is a single child
  • Discusses chain depth and read amplification
Key Topics to Cover
redirect-on-write
trees
hash maps
snapshot chains
copy semantics
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Chains grow to hundreds of levels. How do you bound read latency?
  • How would you garbage collect data blocks no longer referenced by any node?
  • How do you make delete_snapshot crash safe if it is interrupted midway?
  • How does this change if layers are on disk rather than in memory?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

A live vdisk accepts writes. snapshot(v) captures v's current view as an immutable node and v keeps going. clone(s) creates a new writable vdisk whose initial view equals s. delete_snapshot(s) r...

High-Level Design

Each node stores only the blocks written at its level plus a parent pointer. Reading walks up until a layer contains the block. Snapshotting a live vdisk v inserts a new frozen node between v and its ...


Submit Your Answer
Markdown supported

Related Questions