Module 5 — University & GATE Exam Preparation Centre
Exam Preparation Centre
Prepare for technical university exams and competitive assessments: Topic-wise MCQs with instant explanations, revealable flashcards, full-length timed mock tests, and printable A4 revision sheets. 100% free, no login required.
Flashcards Mastered:
0 / 13
Mock Tests Completed:
0
Average Accuracy:
-
Relational Database Management Systems enforce structural invariants over tabular data collections using the relational algebra. Transactions execute as atomic logical units operating under strict consistency guarantees.
ACID Transaction Guarantees
• Atomicity: All-or-nothing execution. Achieved using Write-Ahead Logging (WAL) and undo logs.
• Consistency: The database transitions only between valid states satisfying all declared constraints (foreign keys, uniqueness, check).
• Isolation: Concurrent transactions execute without cross-contamination. Isolation levels: Read Uncommitted, Read Committed, Repeatable Read, Serializable.
• Durability: Once committed, state changes survive sudden hardware failure via non-volatile redo log flushes.
Normalization Hierarchy & Proofs
• 1NF: All attribute values must be atomic; no multi-valued or composite columns.
• 2NF: In 1NF and no non-prime attribute is partially dependent on any candidate key.
• 3NF: In 2NF and for every functional dependency $X \to Y$, either $X$ is a superkey or $Y$ is a prime attribute.
• BCNF: For every functional dependency $X \to Y$, $X$ must be a superkey. BCNF guarantees zero redundancy from functional dependencies but does not always preserve dependencies.
Lossless Join Decomposition Condition:
A decomposition of relation $R$ into $R_1$ and $R_2$ is guaranteed to be lossless if and only if the common attributes constitute a superkey for at least one of the decomposed relations:
$$(R_1 \cap R_2 \to R_1) \quad \text{or} \quad (R_1 \cap R_2 \to R_2)$$
Concurrency Control: Two-Phase Locking (2PL)
2PL ensures serializability through two distinct execution phases:
1. Growing Phase: The transaction may acquire locks (shared or exclusive) but cannot release any lock.
2. Shrinking Phase: The transaction may release locks but cannot acquire new locks.
• Strict 2PL: All exclusive (write) locks are held until commit/abort, preventing cascading rollbacks.
• Rigorous 2PL: Both shared (read) and exclusive locks are held until commit, enforcing strict serial order.
The operating system manages underlying hardware abstractions, process execution contexts, memory hierarchies, and concurrent resource allocations to prevent starvation and deadlock.
CPU Scheduling Metrics & Algorithms
• FCFS: Non-preemptive, simple, suffers from the Convoy Effect where long CPU bursts delay short processes.
• SJF / SRTF: Provably yields minimal average waiting time. Vulnerable to starvation of CPU-bound processes.
• Round Robin (RR): Preemptive using fixed time slice $q$. If $q \to \infty$, behaves as FCFS; if $q \to 0$, context switch overhead dominates.
• Priority with Aging: Dynamically increments priority of waiting jobs to eliminate starvation.
The 4 Coffman Deadlock Conditions
A deadlock state occurs if and only if all four conditions hold concurrently:
1. Mutual Exclusion: At least one resource is held in a non-shareable mode.
2. Hold and Wait: Processes hold allocated resources while requesting others.
3. No Preemption: Resources cannot be forcibly revoked before task completion.
4. Circular Wait: A closed chain $\{P_0, P_1, \dots, P_n\}$ exists where $P_i$ awaits a resource held by $P_{(i+1) \bmod n}$.
Effective Memory Access Time (EMAT) with TLB:
Let $h$ denote the Translation Lookaside Buffer hit ratio, $t$ the TLB access latency, and $m$ the physical RAM read latency:
$$\text{EMAT} = h \cdot (t + m) + (1 - h) \cdot (t + 2m)$$
When a TLB miss occurs, two consecutive RAM cycles are required: one to fetch the page table entry and another to fetch the actual target data operand.
Computer networking establishes robust, packet-switched communication over unreliable physical links using layered architectural abstractions.
TCP 3-Way Handshake & Teardown
• Step 1: Client sends SYN (seq=x).
• Step 2: Server allocates buffer and replies with SYN-ACK (seq=y, ack=x+1).
• Step 3: Client replies with ACK (seq=x+1, ack=y+1).
Connection Teardown: Uses 4-way FIN/ACK handshake. The closing endpoint enters TIME_WAIT state for $2 \times \text{MSL}$ (Maximum Segment Lifetime, typically 120s) to absorb stray delayed duplicates and ensure final ACK delivery.
TCP Congestion Control Pipeline
• Slow Start: $cwnd$ starts at $1 \text{ MSS}$ and doubles every RTT ($cwnd \gets cwnd \times 2$) exponentially until $cwnd \ge ssthresh$.
• Congestion Avoidance: Linear increase ($cwnd \gets cwnd + 1 \text{ MSS}$ per RTT).
• Packet Loss by Timeout: $ssthresh \gets cwnd / 2$, $cwnd \gets 1 \text{ MSS}$, revert to Slow Start.
• Triple Duplicate ACKs (Fast Retransmit): Retransmits immediately without awaiting timer expiry; enters Fast Recovery ($ssthresh \gets cwnd / 2$, $cwnd \gets ssthresh + 3$).
IPv4 Subnet Mask & Usable Host Derivation:
For a subnet with CIDR prefix $/p$, the number of host address bits is $32 - p$. The total possible IP addresses is $2^{32-p}$. The number of usable host configurations is:
$$\text{Usable Hosts} = 2^{32-p} - 2$$
The 2 reserved addresses correspond to the All-Zeros Network ID and the All-Ones Directed Broadcast Address.
Algorithmic analysis mathematically predicts resource utilization (time and memory) as input scale $N \to \infty$.
The Master Theorem for Divide-and-Conquer Recurrences:
For recurrences of the canonical form $T(n) = aT(n/b) + \Theta(n^d)$ with $a \ge 1, b > 1, d \ge 0$:
1. If $d < \log_b a$, then $T(n) = \Theta\bigl(n^{\log_b a}\bigr)$ (work at leaves dominates).
2. If $d = \log_b a$, then $T(n) = \Theta\bigl(n^d \log n\bigr)$ (work is distributed evenly across all $\log_b n$ tree levels).
3. If $d > \log_b a$, then $T(n) = \Theta\bigl(n^d\bigr)$ (work at the root dominates).
Linear-Time Build Heap Proof: Why O(N) instead of O(N log N)?
Inserting $N$ elements successively into a binary heap requires $N \times O(\log N) = O(N \log N)$ time. However, building a heap in-place by calling heapifyDown in reverse level order ($N/2 \dots 1$) runs in strictly $O(N)$ time.
Mathematical Proof: A binary tree of height $h$ has at most $\lceil N / 2^{k+1} \rceil$ nodes at height $k$. A node at height $k$ can sift down at most $k$ levels:
$$T(N) = \sum_{k=0}^{\lfloor \log_2 N \rfloor} \frac{N}{2^{k+1}} \cdot O(k) = O\left(N \sum_{k=0}^\infty \frac{k}{2^k}\right)$$
Since the infinite series $\sum_{k=0}^\infty k/2^k = 2$ (a convergent arithmetico-geometric series), $T(N) = O(2N) = O(N)$.
Model responses for the 12 most frequent technical questions asked in university CS vivas and core engineering placement interviews.
Q1: Why does BCNF not always preserve dependencies?
Answer: When decomposing relation $R(A,B,C)$ with functional dependencies $AB \to C$ and $C \to B$, candidate keys are $AB$ and $AC$. Since $C$ is not a superkey, decomposing into $R_1(B,C)$ and $R_2(A,C)$ achieves BCNF. However, the original dependency $AB \to C$ spans across both decomposed tables and cannot be validated without computing a costly relational join, resulting in loss of dependency preservation.
Q2: What is Belady's Anomaly?
Answer: Belady's Anomaly is the phenomenon where increasing the number of physical page frames allocated to a process results in an increase (rather than a decrease) in the total number of page faults. It occurs in First-In, First-Out (FIFO) page replacement because FIFO is not a "stack algorithm". Stack algorithms (like LRU and Optimal) satisfy the property that the set of pages in an $n$-frame memory is always a subset of the pages in an $(n+1)$-frame memory, immunizing them against Belady's Anomaly.
Q3: Why is TCP TIME_WAIT set to 2 MSL?
Answer: The Maximum Segment Lifetime (MSL) is the maximum time any IP packet can survive in the network before being dropped by routers. Setting TIME_WAIT to $2 \times \text{MSL}$ ensures: (1) if the final ACK is lost in transit, the retransmitted FIN from the remote server can arrive and be acknowledged; (2) all stray or delayed packets from the closed incarnation are completely flushed from the internet before the same socket pair (IP + Port) can be reallocated to a new connection.
Q4: Why is Quicksort practically faster than Mergesort?
Answer: Even though both algorithms exhibit average time complexity $O(N \log N)$, Quicksort operates strictly in-place with a small constant factor, minimal cache line thrashing, and exceptional spatial locality. Mergesort requires allocating an auxiliary array of size $O(N)$ and repeatedly copying elements between arrays, generating significant memory allocation overhead and cache eviction penalties.
Q5: What is Thrashing and how is it resolved?
Answer: Thrashing occurs when a computer spends more CPU cycles swapping pages between RAM and swap space than executing active application code. It arises when the sum of the working sets of all active processes exceeds available physical memory ($\sum WSS_i > D$). The OS mitigates thrashing by suspending one or more low-priority processes, freeing their physical frames to allow remaining processes to complete their memory working sets without faulting.
Q6: Why are B+ Trees favored over BSTs in disk storage?
Answer: Binary Search Trees have a branching factor of 2, resulting in tree height $O(\log_2 N)$ and requiring many disk seeks to reach a node. B+ Trees have a high fan-out (branching factor 100 to 1000+), reducing tree depth to 3 or 4 levels and minimizing disk I/O operations. Furthermore, B+ Trees store all actual record pointers strictly in leaf nodes and link them horizontally, enabling $O(K)$ sequential range scans without backtracking up the tree hierarchy.