
Computer Science Fundamentals for Technical Interviews: OS, DBMS, Networks & OOP
What You'll Learn in This Masterclass
Core CS Fundamentals Quick Reference Matrix
| Core Subject | Highest-Yield Topics | Common Interview Question | Key Concept / Mechanism |
|---|---|---|---|
| Operating Systems | Process vs Thread, Deadlocks, Paging, Virtual Memory | What actually happens during a process context switch? | CPU registers and PC are saved; kernel switches page table pointer; TLB is flushed. |
| DBMS | ACID, B+ Tree Indexing, Isolation Levels, Normalization | Why are B+ Trees preferred over Binary Search Trees for disk storage? | High fan-out minimizes disk I/O seeks; leaf nodes form a linked list for rapid range scans. |
| Computer Networks | TCP Handshake, DNS Flow, HTTP/1.1 vs 2 vs 3, Subnetting | Explain step-by-step what happens when you type google.com into your browser. | DNS query -> TCP 3-way handshake -> TLS negotiation -> HTTP GET -> Server processing -> DOM rendering. |
| OOP & Clean Code | Inheritance vs Composition, Polymorphism, SOLID principles | Explain Liskov Substitution Principle with a real-world code violation. | A derived class must be completely substitutable for its parent without breaking program correctness (e.g., Square inheriting from Rectangle). |
Visual Architecture & Process Diagrams
Visual synthesis of Operating Systems, DBMS, Computer Networks, and Object-Oriented Programming interview topics.
1. Operating Systems: Memory, Concurrency & Deadlocks
Operating systems govern hardware allocation. Technical interviewers focus on what happens beneath user-space code.
Processes vs. Threads
- Process: An executing instance of a program with its own independent, isolated virtual memory address space (Text, Data, Heap, Stack). Inter-Process Communication (IPC) requires OS primitives: Pipes, Shared Memory, or Sockets.
- Thread: A lightweight unit of execution within a process. Threads of the same process share the same code, heap, and open file descriptors, but maintain their own private Stack and Program Counter (PC).
The 4 Coffman Conditions for Deadlock
A deadlock occurs when a set of concurrent processes are blocked because each process is holding a resource and waiting for another resource held by some other process. All 4 conditions must hold simultaneously:
- 1Mutual Exclusion: At least one resource must be held in a non-shareable mode.
- 2Hold and Wait: A process is holding at least one resource and waiting to acquire additional resources held by others.
- 3No Preemption: Resources cannot be forcibly confiscated; they can only be released voluntarily.
- 4Circular Wait: A closed chain of processes exists such that each process holds a resource needed by the next.
Eliminating Circular Wait by enforcing a strict global numerical ordering on all system resources is the most practical deadlock prevention strategy in modern software.
2. DBMS: ACID Guarantees, B+ Tree Indexing & Isolation Levels
Why B+ Trees Rule Disk-Based Databases
Binary Search Trees (BSTs) and Red-Black trees have low fan-out (2 children per node). For 1 million records, a BST requires ~20 levels of depth. If each node lookup requires a disk read, traversing the tree takes 20 expensive disk I/O operations.
In contrast, a B+ Tree has a high fan-out (e.g., 100 to 1,000 children per node). A 3-level B+ Tree can store 1 billion keys with only 3 disk I/O operations! Furthermore, all data records are stored exclusively in the leaf nodes, which are linked together in a doubly-linked list, allowing blazing-fast range queries (WHERE age BETWEEN 25 AND 35).
The 4 Transaction Isolation Levels (SQL-92 Standard)
- Read Uncommitted: Allows Dirty Reads (reading uncommitted changes of another transaction).
- Read Committed: Prevents Dirty Reads, but allows Non-Repeatable Reads (rereading the same row produces different values).
- Repeatable Read: Prevents Dirty and Non-Repeatable Reads, but may allow Phantom Reads (new rows inserted by another transaction matching the query filter). Default in MySQL InnoDB.
- Serializable: Strict isolation simulating serial execution; locks ranges of rows or uses Snapshot Isolation with conflict detection.
3. Computer Networks: TCP/IP, DNS & HTTP Evolution
The TCP 3-Way Handshake
- 1Client -> Server (SYN): Client chooses an Initial Sequence Number (ISN_c) and sends a TCP segment with SYN flag set. State:
SYN-SENT. - 2Server -> Client (SYN-ACK): Server acknowledges client ISN (
ACK = ISN_c + 1), chooses its own ISN_s, and sets SYN and ACK flags. State:SYN-RECEIVED. - 3Client -> Server (ACK): Client acknowledges server ISN (
ACK = ISN_s + 1). State:ESTABLISHED. Data transmission can now begin.
HTTP/1.1 vs HTTP/2 vs HTTP/3
- HTTP/1.1: Persistent TCP connections, but suffers from application-layer Head-of-Line (HoL) blocking (requests on a single connection must be served in strict FIFO order).
- HTTP/2: Introduces binary framing and multiplexing over a single TCP stream. Multiple concurrent request-response streams share one connection. However, transport-layer packet loss still blocks all streams (TCP-level HoL blocking).
- HTTP/3: Replaces TCP with QUIC (built on top of UDP). Each stream is truly independent; packet loss on one stream does not stall data on other streams.
4. Object-Oriented Design & The SOLID Principles
The 5 SOLID principles guide clean software development and code maintainability:
- S - Single Responsibility: Every module or class should be responsible for only one actor or reason to change.
- O - Open/Closed: Classes should be open for extension (via polymorphism and interfaces) but closed for modification.
- L - Liskov Substitution: Derived classes must be substitutable for base classes without altering correct behavior.
- I - Interface Segregation: Clients should not be forced to depend on interfaces they do not use (prefer small, role-specific interfaces).
- D - Dependency Inversion: Depend upon abstractions (interfaces), not concrete implementations. Inversion of Control (IoC) frameworks inject dependencies at runtime.
High-Frequency Interview Questions & Frameworks
What is the fundamental difference between a Mutex and a Counting Semaphore in kernel-level programming?
Explain what happens under the hood when a database executes a query on an indexed column vs an unindexed column.
Costly Mistakes to Avoid
- ✕Confusing processes with threads and claiming threads have separate virtual memory address spaces.
- ✕Overlooking that B+ Tree leaf nodes are connected via a linked list for range queries.
- ✕Assuming HTTPS encrypts the IP address and port (only the HTTP payload, URL path, and headers are encrypted; destination IP is visible for routing).
- ✕Violating Liskov Substitution by throwing NotImplementedException in subclasses.
- ✕Believing garbage collection eliminates all memory leaks (dangling references in static collections still leak memory).
Key Takeaways
- •CS fundamentals separate code monkeys from true software engineers who can debug production systems.
- •B+ Trees minimize disk I/O fan-out, making them the optimal data structure for database storage engines.
- •TCP guarantees reliable, ordered byte streams via sequence numbers, checksums, and sliding windows.
- •The SOLID principles ensure that software remains adaptable and maintainable over years of codebase growth.
Final Interview Checklist
- Be able to trace the 4 Coffman conditions and explain circular wait prevention on a whiteboard.
- Understand virtual memory, page faults, and how the TLB cache accelerates address translation.
- Know all 4 SQL isolation levels and their corresponding concurrency anomalies (Dirty, Non-repeatable, Phantom).
- Be able to draw the TCP 3-way handshake and 4-way connection teardown with state diagrams.
- Explain how TLS 1.3 optimizes the handshake down to 1-RTT compared to 2-RTT in TLS 1.2.
- Be able to write clean code illustrating each of the 5 SOLID principles.
Frequently Asked Questions (FAQs)
What is the difference between synchronous and asynchronous I/O?
In synchronous I/O, the calling thread is blocked until the I/O operation (such as reading a file or network socket) completes and data is transferred to the user buffer. In asynchronous I/O (e.g., epoll, kqueue, io_uring), the thread initiates the request and immediately continues execution; the kernel notifies the application via callbacks or event loops when the I/O operation finishes.
What is a race condition, and how is it prevented?
A race condition occurs when multiple threads concurrently read and write shared data, and the final outcome depends on the non-deterministic order of thread execution. Prevent it using mutual exclusion locks (Mutex), atomic operations (CAS - Compare-And-Swap), or thread-safe data structures.
What is the purpose of database normalization, and why do companies denormalize?
Normalization (1NF, 2NF, 3NF, BCNF) organizes tables to eliminate data redundancy and prevent update/insertion anomalies. However, normalized schemas require expensive multi-table JOIN operations at scale. Companies intentionally denormalize read-heavy tables to store precomputed join data, trading disk space for query speed.
How does DNS lookup work from start to finish?
When resolving a domain name: 1. Browser checks local cache. 2. OS resolver queries local DNS Resolver (ISP/Router). 3. Resolver queries Root Nameserver (.), which returns the TLD Nameserver (.com). 4. Resolver queries TLD Nameserver, which returns the Authoritative Nameserver. 5. Authoritative Nameserver returns the IP address record (A/AAAA). 6. Resolver caches the record based on TTL.
What is the difference between overloading and overriding in OOP?
Method Overloading (Compile-time Polymorphism) occurs when multiple methods in the same class share the same name with different parameter signatures. Method Overriding (Runtime Polymorphism) occurs when a subclass provides a specific implementation of a method already defined in its superclass, resolved at runtime via virtual method tables (vtables).
What is the difference between TCP and UDP?
TCP is connection-oriented, reliable, and ordered (handles packet retransmissions, flow control, and congestion control). UDP is connectionless, lightweight, and unordered (sends datagrams with minimal header overhead, ideal for live video streaming, DNS, and online gaming where low latency beats perfect reliability).
What is a memory leak, and how does it happen in garbage-collected languages?
A memory leak occurs when memory allocated by a program is no longer needed but cannot be freed. In garbage-collected languages (like Java, Python, Go), memory leaks occur when unused objects are inadvertently retained by active references (e.g., static collections, unclosed streams, or unremoved event listeners).
What is the difference between optimistic and pessimistic locking in databases?
Pessimistic locking assumes conflicts will happen and locks rows immediately on read (SELECT ... FOR UPDATE), blocking other transactions. Optimistic locking assumes conflicts are rare; it does not lock rows on read, but records a version number. On write, it checks if the version has changed; if yes, the transaction aborts and retries.
Authoritative References & Standards
The standard academic authority on OS kernel architecture, scheduling, and concurrency.
The premier university textbook on relational storage engines, transaction isolation, and query processing.
Authoritative text on the Internet protocol stack, transport protocols, and socket programming.