CS Fundamentals 1-Page Printable Cheat Sheet (OS, DBMS, CN, OOP)
High-Yield Formulae, Key Trade-offs, and Canonical Questions across OS, DBMS, CN, and OOP
Operating Systems (OS) Essentials 1-Page Cheatsheet
Process vs Thread
When to use: Process: Separate memory space, heavyweight context switch. Thread: Shared heap & code, own stack & registers, lightweight.
Choose Process for fault-isolation; Thread for fast shared-memory concurrency.
Mutex vs Semaphore
When to use: Mutex has ownership & binary lock. Semaphore is a counting signaling primitive; any thread can post/signal.
Use Mutex to protect critical section; Semaphore to throttle N concurrent resource units.
Paging vs Segmentation
When to use: Paging divides memory into fixed-size physical frames (internal fragmentation). Segmentation divides into variable logical segments (external fragmentation).
Modern OS (Linux/x86) uses hardware paging with flat segmentation.
Thrashing & Working Set
When to use: Excessive paging where CPU spends more time swapping pages to disk than executing code.
Fix: Reduce degree of multiprogramming or allocate frames matching the process working set.
Database Management Systems (DBMS) Essentials 1-Page Cheatsheet
ACID Properties
When to use: Atomicity (all-or-nothing), Consistency (integrity constraints), Isolation (concurrency control), Durability (WAL / persistent log).
Bank transfer example: Debiting Account A and crediting Account B must either both commit or both abort.
Normal Forms (1NF to BCNF)
When to use: 1NF: Atomic values. 2NF: No partial dependency on candidate key. 3NF: No transitive dependency. BCNF: Determinant must be super key.
BCNF guarantees zero redundancy from functional dependencies but may sacrifice dependency preservation.
Clustered vs Non-Clustered Index
When to use: Clustered determines actual physical ordering of rows on disk (only 1 per table). Non-clustered is a secondary B+ tree index pointing to row IDs.
Use Clustered index on primary key or frequent range scan column; Non-clustered on lookup filters.
Transaction Isolation Levels
When to use: Read Uncommitted (allows dirty reads) < Read Committed (prevents dirty reads) < Repeatable Read (prevents non-repeatable reads) < Serializable (prevents phantoms).
Higher isolation guarantees strict correctness at the cost of lower throughput and higher lock contention.
Computer Networks (CN) Essentials 1-Page Cheatsheet
OSI 7 Layers (Top to Bottom)
When to use: 7. Application (HTTP/DNS), 6. Presentation (TLS), 5. Session, 4. Transport (TCP/UDP), 3. Network (IP/Router), 2. Data Link (MAC/Switch), 1. Physical (Bits/Cable).
Mnemonic: "All People Seem To Need Data Processing" (or bottom-up: "Please Do Not Throw Sausage Pizza Away").
TCP vs UDP
When to use: TCP: Connection-oriented, reliable 3-way handshake, ordered byte stream, flow & congestion control. UDP: Connectionless, zero overhead, fast best-effort.
TCP for Web/API/Databases; UDP for live streaming, VoIP, DNS lookups, multiplayer gaming.
URL to Page Render Flow
When to use: 1. Browser cache check -> 2. DNS lookup (recursive/authoritative) -> 3. TCP 3-way handshake -> 4. TLS handshake -> 5. HTTP GET -> 6. Server response -> 7. DOM/CSSOM render.
Ultimate breadth question: demonstrate deep understanding at each layer from socket to rendering engine.
Subnetting Cheat Sheet (/24 to /30)
When to use: /24 = 254 hosts | /25 = 126 hosts | /26 = 62 hosts | /27 = 30 hosts | /28 = 14 hosts | /29 = 6 hosts | /30 = 2 hosts.
Formula: Usable hosts = 2^(32 - prefix) - 2 (subtract Network ID and Broadcast IP).
Object-Oriented Programming (OOP) & Design 1-Page Cheatsheet
The 4 Pillars
When to use: Encapsulation (data hiding), Abstraction (exposing what, hiding how), Inheritance (is-a reuse), Polymorphism (one interface, multiple implementations).
Always accompany definitions with a concrete code example from an actual project you built.
Abstract Class vs Interface
When to use: Abstract class: Partial implementation, internal state, single inheritance hierarchy. Interface: Pure behavior contract, multiple implementation, can-do capability.
Use interface for capabilities across unrelated classes (e.g. Comparable); abstract class for shared base state.
Overloading vs Overriding
When to use: Overloading: Same method name, different parameter types/count, resolved at compile-time. Overriding: Same method signature in subclass, resolved dynamically at runtime.
Cannot overload by changing return type alone; must differ in parameter types or count.
SOLID Principles Summary
When to use: S: Single Responsibility | O: Open-Closed | L: Liskov Substitution | I: Interface Segregation | D: Dependency Inversion.
Design test: "Depend on abstractions, not concretions; classes should be open for extension, closed for modification."