Free · 83 cards · spaced repetition
Core CS flashcards
DBMS, Operating Systems, Computer Networks and OOP, one line each. Do a few a day: a card you know comes back later, a card you miss comes back sooner. Each card links to its full answer.
Your cards are loading…
Keys: Space shows the answer, 1 is "Not yet", 2 is "I knew it". Saved on this device only.
All 83 cards
Tap a question to see its answer, and the lesson it comes from.
DBMS
What is a DBMS, and why not just store data in files?
Software that stores data and handles concurrency, crash recovery, constraints, queries and security, which plain files leave to every program.
From DBMS
What are the three levels of abstraction, and what is data independence?
Physical (storage), logical (tables), view (what a user sees). Data independence: change a lower level without breaking the one above.
From DBMS
SQL or NoSQL: how do you choose?
SQL: schema, joins, transactions (payments, orders). NoSQL: flexible schema and easy horizontal scale (sessions, feeds, logs). Decide by access pattern.
From DBMS
Explain super key, candidate key, primary key and foreign key.
Super key: identifies a row. Candidate: a minimal super key. Primary: the chosen candidate. Foreign: refers to another table's key.
From DBMS
Primary key vs unique key?
One primary key per table, never NULL; many unique keys, which allow NULL.
From DBMS
What is referential integrity?
A foreign key must match an existing row or be NULL; ON DELETE CASCADE / SET NULL / RESTRICT decides what happens to children.
From DBMS
How do 1:1, 1:N and M:N relationships become tables?
1:N: foreign key on the many side. 1:1: unique foreign key. M:N: a junction table with both foreign keys.
From DBMS
What is a weak entity?
An entity identified only through its owner: owner's key + its partial key (an employee's dependant).
From DBMS
What is normalisation, and what problem does it solve?
Store each fact once, to avoid update, insert and delete anomalies.
From DBMS
Explain 1NF, 2NF, 3NF and BCNF.
1NF: one value per cell. 2NF: no partial dependency on a composite key. 3NF: no transitive dependency. BCNF: every determinant is a super key.
From DBMS
What is a functional dependency?
X → Y: equal X values always mean equal Y values (roll_no → name).
From DBMS
What is denormalisation, and when is it right?
Storing data redundantly on purpose for faster reads; the cost is extra writes and possible inconsistency.
From DBMS
What are the ACID properties?
Atomicity (all or nothing), Consistency (rules hold), Isolation (no half-done views), Durability (committed survives crashes).
From DBMS
What can go wrong when transactions run at the same time?
Dirty read, non-repeatable read, phantom read, lost update.
From DBMS
What are the isolation levels?
Read Uncommitted < Read Committed (no dirty reads) < Repeatable Read (no non-repeatable reads) < Serializable (no phantoms).
From DBMS
What is two-phase locking?
Acquire locks (growing), then only release (shrinking): guarantees serializability; strict 2PL keeps write locks till commit.
From DBMS
How does a database deal with deadlocks?
Detect a cycle in the wait-for graph (or time out), roll back a victim; avoid by locking in a consistent order.
From DBMS
What is conflict serializability?
Equivalent to a serial schedule by swapping non-conflicting operations; test: the precedence graph has no cycle.
From DBMS
What is an index, and what does it cost?
A B+ tree from column values to rows: fast lookups (log n) at the cost of slower writes and more space.
From DBMS
Clustered vs non-clustered index?
Clustered: the rows themselves are stored in key order (one per table). Non-clustered: a separate structure pointing to rows (many).
From DBMS
Why do databases use B+ trees?
High fan-out (a node per disk page) keeps it 3–4 levels deep; linked leaves make range scans cheap.
From DBMS
DELETE vs TRUNCATE vs DROP?
DELETE: rows, filterable, logged per row. TRUNCATE: all rows, fast, no WHERE. DROP: the whole table.
From DBMS
WHERE vs HAVING?
WHERE filters rows before GROUP BY; HAVING filters groups after it and can use aggregates.
From DBMS
Explain the types of joins.
INNER: matches only. LEFT/RIGHT: all of one side + NULLs. FULL: everything. CROSS: every pair. Self join: a table with itself.
From DBMS
Write a query for the second-highest salary.
MAX(salary) WHERE salary < (SELECT MAX(salary)); or DENSE_RANK() = N for the Nth.
From DBMS
What is a view? And a materialised view?
View: a saved query, no data stored. Materialised view: stores the result, fast to read, needs refreshing.
From DBMS
Operating Systems
What is the kernel, and what are user mode and kernel mode?
The kernel runs with full hardware access (kernel mode); programs run in user mode and ask it for privileged work through system calls.
From Operating Systems
What is a system call? Give examples.
A request from a program to the kernel (trap into kernel mode): fork, exec, open, read, write, mmap…
From Operating Systems
Monolithic kernel vs microkernel?
Monolithic: all services in the kernel (fast, less isolated; Linux). Microkernel: minimal kernel, services in user space (robust, slower; QNX).
From Operating Systems
Process vs thread?
Process: own memory space, isolated, costly to create. Thread: shares its process's memory, own stack and registers, cheap.
From Operating Systems
What are the states of a process?
New → Ready → Running → Terminated; Running → Waiting on I/O (then back to Ready); preempted → Ready.
From Operating Systems
What is a PCB, and what happens in a context switch?
PCB: the kernel's record of a process (state, PC, registers, memory, files). Context switch: save one PCB, load another; pure overhead.
From Operating Systems
What does fork() return, and how many times does this print?
fork() returns 0 in the child, the child's PID in the parent, -1 on failure; n forks in a row make 2^n processes.
From Operating Systems
What are zombie and orphan processes?
Zombie: finished but not yet reaped by its parent's wait(). Orphan: still running after its parent died; adopted by init.
From Operating Systems
How do processes communicate (IPC)?
Pipes, message queues, shared memory (fastest, needs sync), sockets, signals.
From Operating Systems
Preemptive vs non-preemptive scheduling?
Non-preemptive: runs until it finishes or blocks (FCFS, SJF). Preemptive: the OS can take the CPU away (RR, SRTF).
From Operating Systems
What is starvation, and how does aging fix it?
A process waiting forever (long jobs in SJF, low priority); aging raises priority the longer it waits.
From Operating Systems
What does a scheduler try to optimise?
Max CPU utilisation and throughput; min turnaround (CT−AT), waiting (TAT−BT) and response time.
From Operating Systems
What is a race condition, and what is a critical section?
Race condition: the result depends on timing (lost count++). Critical section rules: mutual exclusion, progress, bounded waiting.
From Operating Systems
Mutex vs semaphore?
Mutex: a lock with an owner, one thread inside. Semaphore: a counter (wait/signal) with no owner; counting allows N.
From Operating Systems
Solve producer–consumer with semaphores.
empty = N, full = 0, mutex = 1. Producer: wait(empty), wait(mutex), add, signal(mutex), signal(full). Consumer: the mirror image.
From Operating Systems
What are the four conditions for deadlock?
Mutual exclusion, hold and wait, no preemption, circular wait: all four at once. Break one to prevent deadlock.
From Operating Systems
How do operating systems handle deadlocks?
Prevention (break a condition), avoidance (Banker's), detection + recovery, or ignore it (most desktop OSes).
From Operating Systems
Paging vs segmentation?
Paging: fixed-size pages, no external fragmentation. Segmentation: variable logical segments, external fragmentation.
From Operating Systems
What is virtual memory, and what happens on a page fault?
Each process gets a big address space with only used pages in RAM; page fault: trap, find on disk, get a frame (evict if needed), load, update table, retry.
From Operating Systems
What is thrashing?
Constant page faults because processes can't keep their working sets in RAM; CPU utilisation collapses.
From Operating Systems
What is a TLB?
A small CPU cache of page-table entries, so most address translations skip the page table in memory.
From Operating Systems
Internal vs external fragmentation?
Internal: waste inside fixed-size blocks. External: free memory split into pieces too small to use.
From Operating Systems
Computer Networks
Explain the OSI model.
Physical, Data link (MAC, frames), Network (IP, routing), Transport (TCP/UDP, ports), Session, Presentation, Application.
From Computer Networks
OSI vs the TCP/IP model?
TCP/IP: Application (OSI 5–7), Transport, Internet, Link (OSI 1–2); it's what the internet actually runs.
From Computer Networks
Hub vs switch vs router?
Hub: layer 1, repeats to all ports. Switch: layer 2, forwards by MAC. Router: layer 3, forwards between networks by IP.
From Computer Networks
TCP vs UDP?
TCP: connection, reliable, ordered, flow and congestion control (web, email). UDP: no connection, no guarantees, low latency (DNS, calls, games).
From Computer Networks
Explain the TCP three-way handshake.
SYN (seq x) → SYN-ACK (seq y, ack x+1) → ACK (ack y+1). Closing: FIN/ACK in each direction, four steps.
From Computer Networks
Flow control vs congestion control?
Flow control: don't overflow the receiver (receive window). Congestion control: don't overload the network (cwnd, slow start, AIMD).
From Computer Networks
What is a port? Name some well-known ones.
A 16-bit number picking the process on a host: HTTP 80, HTTPS 443, SSH 22, DNS 53, SMTP 25.
From Computer Networks
What is an IP address, and how do IPv4 and IPv6 differ?
IPv4: 32 bits (~4.3 billion, exhausted, NAT everywhere). IPv6: 128 bits, simpler header, no NAT needed.
From Computer Networks
What is subnetting, and how many hosts does a /26 have?
Moving the network/host boundary to make smaller networks. Usable hosts = 2^(32−prefix) − 2; a /26 has 62.
From Computer Networks
What is NAT?
The router maps many private addresses to one public IP (rewriting address and port, keeping a table).
From Computer Networks
What does ARP do?
Finds the MAC address for an IP on the local network (broadcast a request, cache the reply).
From Computer Networks
How does DHCP give a device its address?
DORA: Discover, Offer, Request, Acknowledge; the address is leased, then renewed.
From Computer Networks
How does ping work?
ICMP echo request and reply, measuring round-trip time; traceroute uses rising TTLs and "time exceeded" replies.
From Computer Networks
How does DNS resolve a name?
Caches first; then the recursive resolver asks root → TLD → authoritative server; answers are cached for their TTL.
From Computer Networks
HTTP vs HTTPS?
HTTPS = HTTP over TLS: the certificate proves the server's identity, then traffic is encrypted and tamper-proof (port 443).
From Computer Networks
Name the HTTP methods and the status code classes.
GET, POST, PUT, PATCH, DELETE (GET/PUT/DELETE idempotent). 2xx ok, 3xx redirect, 4xx client error, 5xx server error.
From Computer Networks
What happens when you type a URL and press Enter?
Parse the URL → caches → DNS → TCP handshake → TLS → HTTP request → server responds → browser fetches assets and renders.
From Computer Networks
Cookies vs sessions?
Cookie: data stored in the browser, sent back on every request. Session: data on the server, only its id in a cookie.
From Computer Networks
OOP
What are the four pillars of OOP?
Encapsulation (bundle and hide data), abstraction (what, not how), inheritance (reuse a parent), polymorphism (one call, many behaviours).
From OOP
Abstraction vs encapsulation?
Abstraction: what to show (the interface, a design idea). Encapsulation: hiding the internals (access modifiers, the mechanism).
From OOP
Class vs object?
Class: the blueprint. Object: an instance with its own state in memory.
From OOP
Overloading vs overriding?
Overloading: same name, different parameters, picked at compile time. Overriding: subclass redefines the same signature, picked at run time.
From OOP
How does run-time polymorphism work underneath?
Each object points to its class's vtable of method pointers; a call looks up the real class's version at run time.
From OOP
Abstract class vs interface?
Abstract class: state, constructors, shared code; extend one. Interface: a contract (can-do); implement many; no instance fields.
From OOP
What are the types of inheritance, and what is the diamond problem?
Single, multilevel, hierarchical, multiple, hybrid. Diamond: D gets A twice through B and C; Java bans multiple class inheritance, C++ uses virtual inheritance.
From OOP
Composition vs inheritance?
Inheritance: is-a. Composition: has-a. Prefer composition: looser coupling, swappable parts, no fragile hierarchies.
From OOP
Association vs aggregation vs composition?
Association: uses/knows. Aggregation: has-a, parts live on their own. Composition: has-a, parts die with the whole.
From OOP
What are constructors, and can one be private?
Sets up a new object (same name as the class, no return type): default, parameterised, copy. Private constructors make singletons.
From OOP
What do the access modifiers mean?
private: the class only. protected: plus subclasses (Java: plus package). public: everyone. Java default: same package.
From OOP
What does static mean?
Belongs to the class (one shared copy), callable without an object; can't use this or instance fields.
From OOP
this vs super?
this: the current object (fields, other constructors). super: the parent (its constructor, its overridden methods).
From OOP
Shallow copy vs deep copy?
Shallow: copies fields, shares nested objects. Deep: copies nested objects too, fully independent.
From OOP
What does final do in Java?
final variable: assigned once. final method: can't be overridden. final class: can't be extended (String).
From OOP
What are the SOLID principles?
Single responsibility, Open/closed, Liskov substitution, Interface segregation, Dependency inversion.
From OOP
Name a few design patterns and when you would use them.
Singleton (one instance), Factory (create without naming the class), Observer (notify subscribers), Strategy (swap algorithms), Builder (step by step).
From OOP