All puzzles › Computer Systems

Computer Systems Practice Problems

23 puzzles (4 easy, 11 medium, 8 hard), 8 free, in Python, JavaScript and C++.

What the machine is doing while your code runs. Walking a multi-level page table, detecting deadlock, mark-and-sweep collection, LRU page replacement, consistent hashing, and write-ahead recovery.

The puzzles, easiest first

  1. An Id That Sorts by Time (Easy, free): Many machines need to hand out unique ids at the same time without asking each other.
  2. Two Replicas, One Count (Easy, free): Two replicas count likes while disconnected from each other, and the counts must agree when they reconnect, without losing or double counting anything.
  3. What a Majority Has (Easy, free): In Raft, a leader copies its log to the other servers, and an entry is committed once a majority of the cluster has stored it.
  4. Which Version Can I See (Easy, free): A database with snapshot isolation never overwrites a row.
  5. Who Happened First (Medium, free): Machines in a distributed system cannot trust each other's wall clocks, so each event carries a vector clock: one counter per node.
  6. Count the Misses (Medium): Given the pages a program uses, in order, and how many frames of memory it has, return how many page faults happen under least recently used (LRU) replacement.
  7. How Deep Does It Go (Medium): Given a page table tree where a nonzero value is a real mapping and 0 is empty, return how many levels down the deepest mapping is.
  8. How Far Does the Head Travel (Medium): Given disk requests by cylinder, where the head is now, and the highest cylinder, return how far the head travels.
  9. Probably Yes, Definitely No (Medium): Given a Bloom filter's size, the bit positions each added key set, and the positions of a key you're checking, return true if the filter says it might be there.
  10. Replay What Was Committed (Medium): Given a write-ahead log as [transaction, kind] entries, where kind 0 is a write and 1 is a commit, return how many writes should be replayed after a crash.
  11. Short Jobs First (Medium): Given how long each job takes, return the total time all jobs spend waiting if you always run the shortest job first.
  12. The Tightest Budget Wins (Medium): Given a tree of resource groups where each node sets a limit, and a path down from the root (0 means left, 1 means right), return the limit that actually applies at the end of the path.
  13. What Else Goes Down With It (Medium): Given a list where deps[i] is the services that service i needs, and one service that just failed, return how many services end up down, counting the one that failed.
  14. What Nobody Is Holding (Medium): Given objects as an adjacency list of references and a list of root objects, return how many objects can't be reached from any root.
  15. Who Owns This Key (Medium): Given the sorted positions of servers on a hash ring and a key's position, return the position of the server that owns the key: the first server at or after the key.
  16. A Second Chance (Hard, free): Exact least-recently-used eviction is too expensive for an operating system, so most use CLOCK.
  17. Newest Wins, Deletions Vanish (Hard, free): A log-structured store never edits data in place.
  18. Stop Calling What Is Down (Hard, free): A service that keeps calling a broken dependency makes an outage worse.
  19. Can Everyone Finish (Hard): Given how many units of a resource are free, what each process still needs, and what each one already holds, return true if every process can finish in some order.
  20. Find the Corrupted Block (Hard): Given a tree where every parent should equal the sum of its two children, return how many parents don't.
  21. Nobody Can Move (Hard): Given a wait-for graph as an adjacency list, where an edge from A to B means A is waiting on B, return true if the system is deadlocked.
  22. Translate the Address (Hard): Given a page table as a tree and an address as one index per level (0 means left, 1 means right), return the physical frame number, or -1 for a page fault.
  23. What Starts First (Hard): Given a list where deps[i] is the services that must start before service i, return an order to start them all, or [] if the dependencies loop.

Practice another pattern

Or browse by subject

Browse all 676 puzzles