AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

Grade 10 AI & Computer Science Practice Questions — Set 7

20 questions from the Grade 10 bank, each with its answer and a full explanation. Set 7 of 11 · 221 questions in this grade.

Reading is revision; testing is practice. Take the same questions as a timed quiz →

Question 121 · Neural ODEs: Learning Continuous-Time Dynamics with Neural Networks · hard

A researcher at an Indian robotics lab models the hidden state h(t) of a drone-trajectory-smoothing neural network as a Neural ODE, dh/dt = f(h(t)), where the learned dynamics is f(h) = −h — the continuous-time analogue of a residual block with weight −1, so the state is continually pulled toward zero rather than updated in discrete jumps. The initial hidden state is h(0) = 2. To evaluate the network, the ODE solver takes two Euler steps of size Δt = 0.5, updating h ← h + Δt·f(h) at each step using the current value of h. What is the Euler-method estimate of h(1)?

  1. h(1) ≈ 0.5, obtained by taking two Euler steps of size Δt = 0.5, updating h ← h + Δt·f(h) at each step using the current h value.
  2. h(1) = 0, obtained by adding the full slope f(h) at each of the two steps without scaling it by Δt = 0.5, effectively treating each step as a full unit of time.
  3. h(1) ≈ 0.74, obtained by evaluating the exact analytic solution h(t) = 2e^(−t) of the ODE at t = 1, instead of running the discrete Euler approximation.
  4. h(1) = 4.5, obtained by using the dynamics f(h) = h instead of f(h) = −h, flipping decay into growth across the two Euler steps.

Answer: A. h(1) ≈ 0.5, obtained by taking two Euler steps of size Δt = 0.5, updating h ← h + Δt·f(h) at each step using the current h value.

ExplanationA Neural ODE replaces the discrete residual update h_{k+1} = h_k + f(h_k) of a ResNet with a continuous rule dh/dt = f(h(t)), and numerically integrating that rule with Euler's method and step size Δt exactly recovers a ResNet whose layers each apply h ← h + Δt·f(h). Here f(h) = −h and h(0) = 2, with Δt = 0.5. First step, from t = 0 to t = 0.5: the slope is f(h(0)) = f(2) = −2, so h(0.5) = h(0) + Δt·f(h(0)) = 2 + 0.5×(−2) = 2 − 1 = 1. Second step, from t = 0.5 to t = 1: the slope must be recomputed at the new state, f(h(0.5)) = f(1) = −1, so h(1) = h(0.5) + Δt·f(h(0.5)) = 1 + 0.5×(−1) = 1 − 0.5 = 0.5. So the Euler-method estimate is h(1) = 0.5. Getting h(1) = 0 comes from forgetting that Euler's method scales the slope by the step size Δt before adding it — adding f(h) directly at each of the two steps (2 + (−2) = 0, then 0 + f(0) = 0) silently turns two half-steps into two full unit-time jumps, which is not what Δt = 0.5 specifies. Getting h(1) ≈ 0.74 confuses the discrete numerical approximation with the true continuous solution: solving dh/dt = −h analytically gives h(t) = h(0)e^(−t) = 2e^(−t), so the exact value at t = 1 is 2/e ≈ 0.736. Euler's method with a finite step size only approximates this curve — with just two steps it overshoots the decay and lands at 0.5, not 0.74; the two values coincide only in the limit Δt → 0, which is the same limit that turns a very deep ResNet into a genuine ODE. Getting h(1) = 4.5 comes from a sign error in the dynamics: using f(h) = h (unstable growth) instead of the learned f(h) = −h (stable decay toward zero) turns the drone's hidden state into an exponentially blowing-up quantity rather than one settling smoothly to zero, the opposite of what a decay-type residual block computes.

Question 122 · Spectral Graph Theory: Eigenstructure of Network Adjacency and Laplacian Matrices · hard

An Indian fintech company builds a ring backup network linking its 4 regional UPI settlement data-centres — Mumbai, Delhi, Chennai, and Kolkata — where each centre has a direct fibre link only to its two neighbours around the ring (so the network is the 4-cycle graph C₄). Labelling the centres 1–4 in ring order, the network's Laplacian matrix is ``` L = | 2 -1 0 -1 | |-1 2 -1 0 | | 0 -1 2 -1 | |-1 0 -1 2 | ``` Its four eigenvalues are 0, 2, 2, and 4 (the single 0 confirms the network is connected, since the multiplicity of the 0 eigenvalue equals the number of connected components). Applying Kirchhoff's Matrix-Tree Theorem, how many distinct spanning trees does this ring network have?

  1. Exactly 4 spanning trees, since the nonzero Laplacian eigenvalues 2, 2, and 4 multiply to 16, and dividing by the vertex count n = 4 (Kirchhoff's Matrix-Tree Theorem) gives 16/4 = 4.
  2. Exactly 0 spanning trees, since the Laplacian eigenvalue 0 must be included in the product 0 × 2 × 2 × 4, which collapses the spanning-tree count to zero for every graph.
  3. Exactly 16 spanning trees, since multiplying the three nonzero Laplacian eigenvalues 2 × 2 × 4 already gives the spanning-tree count directly, with no further normalization needed.
  4. Exactly 1 spanning tree, since Kirchhoff's theorem requires dividing the product of nonzero eigenvalues by n squared (16), giving 16/16 = 1, rather than by n alone.

Answer: A. Exactly 4 spanning trees, since the nonzero Laplacian eigenvalues 2, 2, and 4 multiply to 16, and dividing by the vertex count n = 4 (Kirchhoff's Matrix-Tree Theorem) gives 16/4 = 4.

ExplanationKirchhoff's Matrix-Tree Theorem states that for a connected graph on n vertices, the number of spanning trees τ(G) equals (1/n) times the product of the n − 1 nonzero eigenvalues of the Laplacian matrix L (equivalently, any (n−1)×(n−1) cofactor of L gives the same value). Here the nonzero eigenvalues are 2, 2, and 4, whose product is 2 × 2 × 4 = 16. Dividing by n = 4 gives τ(C₄) = 16/4 = 4. This matches a direct combinatorial check: C₄ has exactly 4 edges, and removing any single edge from a cycle always leaves the remaining 3 edges connecting all 4 vertices in a path — so every one of the 4 possible single-edge removals produces a valid spanning tree, and no other 3-edge subset exists to check. Four spanning trees is correct. The zero eigenvalue must always be excluded from the product — it exists for every graph because Laplacian rows sum to zero by construction (its eigenvector is the all-ones vector), and its multiplicity counts connected components, not spanning trees. Including it forces the product to 0 regardless of the graph's actual structure, which cannot be right since a connected ring obviously has spanning trees. The normalization is division by n, not by n². This follows from the algebraic fact that L's rows and columns each sum to zero, which makes the product of the nonzero eigenvalues equal to n·τ(G) exactly — so dividing by n² would systematically undercount by a factor of n, and taking the raw product with no normalization at all would overcount by a factor of n. This generalizes cleanly: the cycle graph Cₙ always has exactly n spanning trees, each obtained by deleting one of its n edges, and the Laplacian eigenvalues 2 − 2cos(2πk/n) for k = 0, …, n−1 always reproduce this count through the same (1/n)·(product of nonzero eigenvalues) computation.

Question 123 · Topological Data Analysis: Persistent Homology and Shape Discovery · hard

A precision-agriculture pilot (of the kind ISRO's Bhuvan-linked farm networks run in Punjab and Maharashtra) places four soil-moisture sensor nodes at the corners of a perfectly square 1 km × 1 km plot: A(0,0), B(1,0), C(1,1), D(0,1), with all coordinates in kilometres. You build a Vietoris–Rips filtration on these 4 points: for a filtration value ε ≥ 0, a k-simplex on a set of vertices is included in the complex the moment ε is at least as large as the LARGEST pairwise distance among those vertices (equivalently, the edge {u,v} enters when ε ≥ d(u,v), and the triangle {u,v,w} enters when ε is at least the largest of the three side-lengths of that triangle). Tracking the 1-dimensional homology class corresponding to the loop A–B–C–D–A that encloses the plot's interior, at what ε (in km) is this loop born, at what ε does it die, and what is its persistence (death − birth), rounded to two decimal places?

  1. Persistence equals 1 km: birth occurs at ε = 1 km when the four sides close the square, and death occurs at ε = 2 km, the length obtained by summing two adjacent sides rather than using the diagonal directly.
  2. The four points form a complete graph only once ε = √2 km, so the loop is born there rather than at ε = 1 km, and it dies at ε = 2 km, giving a persistence of 2 − √2 ≈ 0.59 km.
  3. Birth occurs at ε = 1 km, when the four unit sides close the boundary into a cycle, and death occurs at ε = √2 km, when both diagonals simultaneously fill all four triangles, giving a persistence of √2 − 1 ≈ 0.41 km.
  4. Since the four corner points already outline the square's boundary at ε = 0 km, the loop exists from the very start of the filtration and dies at ε = √2 km, giving a persistence of √2 ≈ 1.41 km.

Answer: C. Birth occurs at ε = 1 km, when the four unit sides close the boundary into a cycle, and death occurs at ε = √2 km, when both diagonals simultaneously fill all four triangles, giving a persistence of √2 − 1 ≈ 0.41 km.

ExplanationStart by listing every pairwise distance among the 4 sensors. The four plot sides AB, BC, CD, DA each have length 1 km. The two diagonals AC and BD each have length √(1²+1²) = √2 km ≈ 1.4142 km. These are the only two distinct distance values in the point cloud, so they are the only two filtration values at which anything new can happen. Birth of the loop: a k-simplex enters the Vietoris–Rips complex at ε equal to the largest pairwise distance among its vertices. The four side-edges all have length 1, so all four enter simultaneously at ε = 1 km, closing the boundary A–B–C–D–A into a 4-cycle. At this exact ε, no diagonal edge exists yet (√2 > 1), so no triangle can exist either (a 2-simplex needs all three of its edges present). With edges but no 2-simplices, this 4-cycle is not the boundary of any 2-chain, so it represents a genuinely new, nonzero class in H₁. Hence birth = 1 km. Death of the loop: the class dies once some 2-chain appears whose boundary fills it in. Consider triangle ABC: its three edges are AB = 1, BC = 1, AC = √2, so its largest side is √2, meaning this triangle enters the complex exactly when ε = √2. The same holds for triangles ABD, ACD, and BCD — each contains exactly one diagonal (length √2) and two sides (length 1), so each has largest side √2 and enters at ε = √2. So at ε = √2 km, both diagonals AC and BD appear together with all four triangles at once, and these triangles jointly tile the entire square, filling the hole completely. The rank of H₁ drops from 1 to 0 at this instant, so death = √2 km. Persistence = death − birth = √2 − 1 ≈ 1.4142 − 1 = 0.4142 km ≈ 0.41 km. The distractors correspond to real errors: treating the "sum of two adjacent sides" (1+1=2) as the relevant threshold instead of the true Euclidean diagonal √2; conflating the birth of the loop with the later moment the graph becomes complete (which is actually when it dies, not when it's born); and forgetting that at ε = 0 the complex consists of four isolated points with no edges at all, so no cycle can exist until ε reaches the side length.

Question 124 · Causal Discovery: Learning Causal Graphs from Observational and Interventional Data · hard

During IRCTC's Tatkal booking window, engineers log three variables every second: server CPU load L (%), queue wait time Q (seconds), and a booking-failure indicator F (0/1). Observational data show L and F are dependent (correlation ρ(L,F) = 0.62, significant), but conditioning on Q kills that dependence: the partial correlation ρ(L,F∣Q) ≈ 0.02 (not significant), so L ⊥ F ∣ Q holds while L ⊥̸ F does not. This exact pattern — dependent marginally, independent given the middle variable — is produced by three different DAGs on {L, Q, F} that share the same skeleton (edges L–Q and Q–F, no L–F edge) and are Markov-equivalent, since Q is a non-collider in all three: (i) L → Q → F, (ii) F → Q → L, (iii) L ← Q → F. No observational conditional-independence test can tell these apart. To break the tie, engineers throttle the server directly via a load balancer, setting L to fixed values do(L = l) independent of any natural dynamics, and measure the resulting distribution of Q. They find P(Q ∣ do(L = l)) shifts systematically as l increases — forced higher load produces longer queues. Given this interventional result, which causal structure is confirmed, and why does the experiment rule out the other two?

  1. L ← Q → F (queue wait time is the common cause of both server load and booking failure) is confirmed, because an external experiment that changes L and is followed by a change in Q is fully consistent with Q being the upstream cause of L.
  2. F → Q → L (a chain running backward, from booking failure to server load) is confirmed, because failure events are the natural starting point of any operational post-mortem, so causal direction should be read from effect back to cause.
  3. No structure can be confirmed: since all three DAGs induce the identical conditional-independence pattern L ⊥̸ F and L ⊥ F ∣ Q on observational data, they remain in the same Markov equivalence class no matter what experiment is performed on the system.
  4. L → Q → F (server load causes queue wait time, which causes booking failure) is confirmed, because only this DAG predicts that P(Q ∣ do(L=l)) changes with l; in the other two structures L has no outgoing edge into Q, so the do-operator's removal of edges into L leaves Q's distribution unchanged, contradicting the observed shift.

Answer: D. L → Q → F (server load causes queue wait time, which causes booking failure) is confirmed, because only this DAG predicts that P(Q ∣ do(L=l)) changes with l; in the other two structures L has no outgoing edge into Q, so the do-operator's removal of edges into L leaves Q's distribution unchanged, contradicting the observed shift.

ExplanationThe do-operator do(L=l) mutilates the causal graph by deleting every edge pointing INTO L, while leaving edges that point OUT of L untouched — this is exactly what a physical intervention (a load balancer forcing CPU load regardless of anything else) does: it severs L from its natural causes without touching what L itself causes. Apply this to each candidate DAG. In L → Q → F, the edge L→Q points out of L, so it survives the intervention; Q's distribution is mechanically driven by whatever value l the load balancer sets, so P(Q ∣ do(L=l)) must vary with l — exactly the systematic shift the engineers observed. In L ← Q → F, the only edge touching L is Q→L, which points INTO L and is therefore deleted by do(L=l); L then has zero causal influence on Q, so P(Q ∣ do(L=l)) = P(Q) for every l, predicting no shift at all. In F → Q → L, the edge touching L is again Q→L (into L), deleted the same way, giving the same false prediction of no shift. So two of the three Markov-equivalent structures make a testable prediction that the actual experiment falsifies, and only L → Q → F survives: it is confirmed. This is precisely why the ρ(L,F)=0.62 vs ρ(L,F∣Q)≈0.02 pattern in the question, on its own, could never settle the direction — all three DAGs are indistinguishable under any observational conditional-independence test, since Q is a non-collider (not a common effect of L and F) in every one of them. Distinguishing them requires exactly the kind of interventional data the engineers collected, which is the central idea separating causal discovery from mere correlation analysis: observational data pins down the Markov equivalence class (the skeleton plus which nodes are colliders), while interventions are needed to orient the remaining edges.

Question 125 · Equivariant Neural Networks: Incorporating Symmetry into Deep Learning · hard

An ISRO ground-station pipeline treats a satellite's repeating telemetry burst as a cyclic sequence of length 4, x = (x0, x1, x2, x3), with indices taken mod 4. A translation-equivariant 1-D layer applies the shared kernel w = (w0, w1) = (1, -1) by cross-correlation: y_i = w0·x_i + w1·x_{(i+1) mod 4}, for i = 0,1,2,3. For x = (1, 2, 3, 4), this gives y = (-1, -1, -1, 3). One time-slot later the ground station receives the same burst cyclically shifted, x' = (4, 1, 2, 3) — that is, x'_i = x_{(i-1) mod 4} — and feeds it into the identical layer (same weights w, same formula). What is y' = w * x', and how does it relate to y in a way that demonstrates equivariance (rather than invariance) of this layer under the cyclic-shift group Z4?

  1. y' = (-1, -1, -1, 3), identical to y, which would mean the layer's output stays completely unchanged despite the shifted input
  2. y' = (1, -3, 1, 1), obtained by flipping the kernel around its center (true convolution) instead of applying the cross-correlation formula the layer actually uses
  3. y' = (3, -1, -1, -1), matching y cyclically shifted by one position in the same direction as x was shifted, so f(Tx) = T(f(x))
  4. y' = (-1, -1, 3, -1), matching y cyclically shifted by one position in the direction opposite to the shift applied to x

Answer: C. y' = (3, -1, -1, -1), matching y cyclically shifted by one position in the same direction as x was shifted, so f(Tx) = T(f(x))

ExplanationApply the layer's cross-correlation formula y'_i = x'_i − x'_{(i+1) mod 4} directly to x' = (4, 1, 2, 3): y'_0 = 4 − 1 = 3, y'_1 = 1 − 2 = −1, y'_2 = 2 − 3 = −1, y'_3 = 3 − 4 = −1, giving y' = (3, −1, −1, −1). Now compare this to y = (−1, −1, −1, 3) shifted by the same cyclic operator T that turned x into x' (each entry moves to the next higher index, and the entry that falls off the end wraps to the front): T(y) = (y_3, y_0, y_1, y_2) = (3, −1, −1, −1). This is exactly y'. That equality, f(Tx) = T(f(x)), is the defining condition for equivariance under a symmetry group — here the cyclic-shift group Z4 acting on length-4 sequences. It is a strictly stronger and more useful property than invariance (which would require f(Tx) = f(x), i.e. y' = y unchanged, the claim in the first option): equivariance guarantees that the location of a feature detected by the kernel moves correctly with the input, which is essential when the layer's output feeds into later stages that must localize events in the shifted signal. The kernel-flipped computation (1, −3, 1, 1) illustrates a separate, common confusion in the equivariance literature: deep learning frameworks label their operation "convolution" while actually implementing cross-correlation (no kernel flip), and silently switching to the true, flipped convolution changes which neighbor is subtracted from which, breaking the clean shift relationship demonstrated above. The remaining option shifts y one position in the wrong direction, which would only arise from misreading which way x was translated into x'.

Question 126 · Lie Groups and Symmetries: Continuous Groups in Deep Learning and Geometric Computing · hard

A rotation-equivariant neural network used for ISRO satellite imagery must rotate 2D feature vectors by angle θ while exactly preserving their magnitude. The Lie algebra generator for this SO(2) rotation is G = [[0, -1], [1, 0]], and direct computation confirms G² = -I (the 2×2 identity matrix, negated). Using the matrix exponential series exp(θG) = I + θG + (θ²/2!)G² + (θ³/3!)G³ + ⋯ and grouping terms by even and odd powers of θ, what is the closed-form expression for exp(θG), and why does this specific form guarantee that ‖exp(θG)v‖ = ‖v‖ for every vector v and every angle θ?

  1. exp(θG) = [[cosθ, -sinθ], [sinθ, cosθ]], and it preserves norms because G is skew-symmetric (Gᵀ = -G), which forces exp(θG) to be orthogonal for every value of θ.
  2. exp(θG) = [[cosθ, sinθ], [-sinθ, cosθ]], and it preserves norms because G² = I forces exp(θG) to be idempotent for every value of θ.
  3. exp(θG) = [[cosh θ, sinh θ], [sinh θ, cosh θ]], and it preserves norms because G is symmetric, so exp(θG) becomes a uniform scaling matrix that stretches every vector by the same factor.
  4. exp(θG) = [[1 - θ²/2, -θ], [θ, 1 - θ²/2]], and it preserves norms only approximately, since truncating the exponential series at quadratic order keeps ‖v‖ constant up to an error of order θ³.

Answer: A. exp(θG) = [[cosθ, -sinθ], [sinθ, cosθ]], and it preserves norms because G is skew-symmetric (Gᵀ = -G), which forces exp(θG) to be orthogonal for every value of θ.

ExplanationGroup the exponential series by powers of G. Since G² = -I, the powers cycle with period 4: G⁰ = I, G¹ = G, G² = -I, G³ = -G, G⁴ = I, and so on. Splitting the series into the coefficient of I (even powers of θ) and the coefficient of G (odd powers of θ) gives exp(θG) = (1 - θ²/2! + θ⁴/4! - ⋯)·I + (θ - θ³/3! + θ⁵/5! - ⋯)·G. The first bracket is exactly the Taylor series for cosθ and the second is exactly the Taylor series for sinθ, so exp(θG) = cosθ·I + sinθ·G = [[cosθ, -sinθ], [sinθ, cosθ]], the standard 2D rotation matrix. Norm preservation follows from a structural property of G, not from the specific angle: G is skew-symmetric, meaning Gᵀ = -G (transposing [[0,-1],[1,0]] moves the -1 and 1 to swap positions, giving [[0,1],[-1,0]], which is exactly -G). Taking the transpose of the exponential series term by term gives exp(θG)ᵀ = exp(θGᵀ) = exp(-θG). Because θG commutes with itself, exp(θG)·exp(-θG) = exp(θG - θG) = exp(0) = I, so exp(θG)ᵀ·exp(θG) = I for every θ — the matrix is orthogonal for all θ, not just approximately or for special angles. Orthogonality is exactly the condition ‖Rv‖² = vᵀRᵀRv = vᵀIv = vᵀv = ‖v‖², so magnitude is preserved exactly, not approximately. This is the general principle behind equivariant deep learning layers: any generator satisfying Gᵀ = -G exponentiates to an orthogonal, norm-preserving transformation, which is why skew-symmetric generators are the standard tool for building rotation-equivariant layers for tasks like detecting rotated objects in satellite imagery.

Question 127 · Algebraic Topology in Data: Homology, Cohomology, and Topological Data Analysis · hard

A team analyzing ISRO ground-station telemetry builds a simplicial complex from station-connectivity data using topological data analysis (TDA). At filtration radius ε, the resulting Vietoris–Rips complex has 10 vertices (0-simplices), 16 edges (1-simplices), and 4 filled triangular faces (2-simplices). The complex is connected (a single component, so b₀ = 1), and none of its 2-simplices enclose a three-dimensional void (so b₂ = 0). Using the Euler–Poincaré formula χ = b₀ − b₁ + b₂, where χ is computed directly from simplex counts as (vertices) − (edges) + (faces), what is the first Betti number b₁ of this complex?

  1. b₁ = 3, meaning the complex contains three independent unfilled one-dimensional loops
  2. b₁ = 7, obtained by computing the cyclomatic number of the bare connectivity graph alone and ignoring that the four filled triangles remove loops
  3. b₁ = 4, obtained by treating the four triangles as though they seal off a three-dimensional cavity (b₂ = 1) instead of the correct b₂ = 0
  4. b₁ = 2, obtained by misapplying the relation as χ = −b₁ and silently dropping the connected-component term b₀ = 1

Answer: A. b₁ = 3, meaning the complex contains three independent unfilled one-dimensional loops

ExplanationFor a simplicial complex, the Euler characteristic χ can be computed two ways: as an alternating sum of simplex counts, χ = (vertices) − (edges) + (triangular faces), and — by the Euler–Poincaré theorem — as an alternating sum of Betti numbers, χ = b₀ − b₁ + b₂ for a 2-dimensional complex. Here V = 10, E = 16, F = 4, so χ = 10 − 16 + 4 = −2. The complex is given as connected, so b₀ = 1, and since no triangle encloses a three-dimensional cavity, b₂ = 0. Substituting into the Euler–Poincaré relation: −2 = 1 − b₁ + 0, so b₁ = 1 − (−2) = 3. The complex therefore carries three independent, unfilled one-dimensional loops — three genuine topological gaps that no ground-station triangle patches over. The value 7 comes from computing the cyclomatic number of the bare connectivity graph alone (E − V + b₀ = 16 − 10 + 1 = 7) while forgetting that each filled triangle kills off one of those loops; the four filled 2-simplices are exactly what bring 7 down to 3. The value 4 comes from wrongly assuming the four filled triangles enclose a three-dimensional void (b₂ = 1) rather than lying flat with b₂ = 0, giving 1 − (−2) + 1 = 4. The value 2 comes from misremembering the Euler–Poincaré relation as χ = −b₁, which silently drops the b₀ = 1 term for connectedness and gives b₁ = −χ = 2.

Question 128 · AWS vs Azure vs Google Cloud Platform: Comprehensive Comparison · hard

A software team building a UPI payment gateway for Indian users deploys a failover-based architecture across two independent AWS regions — Mumbai (ap-south-1) and Hyderabad (ap-south-2). Each region independently offers a 99.9% monthly uptime SLA, and the system is designed so that a payment request succeeds as long as at least one region is operational. Assuming the two regions fail independently of each other, what is the theoretical availability of the combined two-region system, and how many "9s" does this correspond to?

  1. About 99.9999% (six nines) availability: since failover means the system is down only when both regions fail together, the joint downtime probability is 0.001 × 0.001 = 0.000001 (0.0001%).
  2. Still about 99.9% availability, unchanged from either single region alone, because averaging two identical 99.9% SLAs across independent regions produces no net improvement in guaranteed uptime.
  3. About 99.95% availability, because distributing traffic across two regions halves the effective downtime per user from 0.1% down to 0.05%.
  4. About 99.80% availability, because a failover deployment still requires both regions to stay operational simultaneously, giving combined uptime 0.999 × 0.999 = 0.998001.

Answer: A. About 99.9999% (six nines) availability: since failover means the system is down only when both regions fail together, the joint downtime probability is 0.001 × 0.001 = 0.000001 (0.0001%).

ExplanationEach region has a 0.1% (0.001) probability of being down in a given month, since 100% − 99.9% = 0.1%. Because the architecture fails over to whichever region is healthy, the combined system goes down only in the rare case that both regions are simultaneously down. For independent events, the probability of both failing together is the product of their individual failure probabilities: 0.001 × 0.001 = 0.000001, i.e., 0.0001%. Subtracting this joint failure probability from 100% gives the combined availability: 100% − 0.0001% = 99.9999%. Counting the digits in 99.9999% (two 9s before the decimal point plus four 9s after it) gives six nines total — three orders of magnitude better than either region alone. This is why AWS, Azure, and GCP all recommend multi-region failover for mission-critical systems like payment gateways: independent redundancy multiplies failure probabilities down (an OR-style rescue condition), whereas treating both regions as jointly required (an AND-style series dependency, as in the last option) or naively averaging or halving the single-region SLA figures both misrepresent how independent probabilities combine.

Question 129 · ETL Pipelines: Extract, Transform, Load Data Efficiently · hard

A fintech startup's nightly ETL pipeline extracts UPI transaction records from a partner bank's API in batches of n records, transforms them, and loads them into a warehouse. Every batch incurs a fixed overhead of 8 seconds (OAuth handshake with the bank API plus opening a warehouse transaction), a linear cost of 0.004 seconds per record (JSON parsing, currency-field casting, and the warehouse insert), and a deduplication pass — needed because network retries occasionally cause the same transaction to be extracted twice — that compares every pair of records in the batch and costs 0.000002n² seconds in total. What batch size n minimizes the average processing time per record, and what is that minimum average time?

  1. At n = 2000, the average processing time per record is minimized at 0.012 seconds/record, found by setting the derivative of f(n) = 8/n + 0.004 + 0.000002n equal to zero and solving n = √(8/0.000002).
  2. At n = 4,000,000, the average processing time per record is minimized at approximately 8.0 seconds/record, obtained by solving n² = 8/0.000002 for n without taking the square root of the right-hand side.
  3. There is no finite optimal batch size — average time per record keeps decreasing as n grows, so the batch size should be made as large as available memory permits to amortize the fixed 8-second overhead.
  4. Setting n = 1 (processing records one at a time) minimizes average time per record, since this eliminates the O(n²) deduplication cost that would otherwise dominate the pipeline's runtime.

Answer: A. At n = 2000, the average processing time per record is minimized at 0.012 seconds/record, found by setting the derivative of f(n) = 8/n + 0.004 + 0.000002n equal to zero and solving n = √(8/0.000002).

ExplanationThe total time to process one batch of n records is T(n) = 8 + 0.004n + 0.000002n², combining the fixed connection/transaction overhead, the linear per-record extract-transform-load cost, and the total cost of the pairwise deduplication scan (which grows as n² because every record must be compared against every other record in the batch). The quantity the pipeline actually wants to minimize is the average time per record, f(n) = T(n)/n = 8/n + 0.004 + 0.000002n. Differentiating with respect to n gives f'(n) = -8/n² + 0.000002. Setting f'(n) = 0 gives n² = 8/0.000002 = 4,000,000, so n = 2000 (the positive root, since a batch size can't be negative). Since f''(n) = 16/n³ > 0 for n > 0, this critical point is indeed a minimum, not a maximum. Substituting n = 2000 back in: f(2000) = 8/2000 + 0.004 + 0.000002(2000) = 0.004 + 0.004 + 0.004 = 0.012 seconds/record. Notice that at the optimum, the amortized fixed-overhead term (8/n) exactly equals the quadratic dedup term (0.000002n) — this is a general feature of minimizing any function of the form A/n + Cn: the minimum occurs where the two competing terms balance. The batch-size-4,000,000 answer comes from a common algebra slip: stopping at n² = 4,000,000 and mistaking the squared value itself for n, instead of taking the square root. The "no finite optimum" claim ignores that the deduplication term grows quadratically and will eventually overwhelm any savings from amortizing the fixed overhead — average time actually turns upward for large n. The n = 1 claim makes the opposite error: it correctly avoids the quadratic dedup cost but ignores that the fixed 8-second overhead then gets amortized over a single record, giving a per-record time of roughly 8.006 seconds — far worse than the true minimum.

Question 130 · Building a Portfolio and GitHub Profile: Showcase Your Skills · hard

Riya is preparing her GitHub profile for summer internship applications. She forks a popular open-source documentation repository and, over three months, pushes 45 commits directly to her fork, fixing typos and rewriting confusing sections — but she never opens a pull request back to the original repository. When she checks her profile afterward, her contribution graph is still almost completely empty. Which of the following correctly explains why her 45 commits are not showing up as green squares?

  1. Commits pushed only to a forked repository are excluded from the contribution graph; a commit counts only once it exists in the default branch of a non-fork repository, such as after the original project's maintainer merges a pull request built from that fork.
  2. Every commit authored using the email address linked to the account is counted on the graph regardless of whether the repository is a fork, since GitHub attributes contributions strictly by commit author email.
  3. The graph measures the net number of lines added and removed across all commits rather than the number of commits, so 45 small documentation commits register as very little activity compared to one large commit.
  4. The contribution graph only displays activity from public repositories because GitHub's servers cannot index the content of private repositories to verify authorship.

Answer: A. Commits pushed only to a forked repository are excluded from the contribution graph; a commit counts only once it exists in the default branch of a non-fork repository, such as after the original project's maintainer merges a pull request built from that fork.

ExplanationGitHub's contribution graph does not simply count "commits you authored" — it counts commits that satisfy a specific set of rules: the commit's email must be linked to the account, the commit must sit in a repository's default branch (or its gh-pages branch), and critically, that repository must not be a fork. Riya's 45 commits live only on her fork's branch, so they fail the "non-fork default branch" condition and none of them register, no matter how many she makes or how many months she works on them. The commits would start appearing only if the original repository's maintainer merged a pull request built from her fork's changes into that repository's own default branch — at that point the merged commits (still attributed to Riya as author) become part of a non-fork default branch and count. This is exactly why portfolio advice for students emphasizes opening pull requests rather than assuming that forking a repo and committing to it is, by itself, visible activity: a recruiter skimming a green contribution graph will never see work that sits unmerged on a personal fork. The lines-changed theory is wrong because the graph counts qualifying commits (and other events like issues, PRs, and reviews), not net lines of code, so volume of edits doesn't matter once the fork condition already disqualifies every commit. The private-repository theory is also wrong: GitHub does let users opt in to showing private contributions as anonymized squares, so private content is not invisible to the graph by design — it is simply hidden by a user setting, not a technical inability to index it.

Question 131 · Startup Technology Stacks: Building Companies from Ground Up · hard

PayEase, a Bengaluru-based fintech startup, is choosing a hosting architecture for its UPI payments API and expects to handle 50 million API calls per month. Option 1 (serverless cloud functions) charges ₹0.40 per 1,000 calls with no fixed monthly cost. Option 2 (a dedicated cloud server) charges a fixed ₹18,000 per month plus ₹0.10 per 1,000 calls for bandwidth. At this projected volume of 50 million calls per month, which option is cheaper, and by how much?

  1. The dedicated server is cheaper by ₹3,000/month, because once a startup crosses tens of millions of monthly calls, the fixed-cost plan always undercuts the pay-per-call plan regardless of the actual break-even volume.
  2. The serverless option is cheaper by ₹3,000/month: ₹20,000 (0.40 × 50,000) versus ₹23,000 (₹18,000 + 0.10 × 50,000) for the dedicated server, since 50 million calls is still below the ₹18,000-fixed-cost break-even of 60 million calls/month.
  3. Treating the dedicated server's cost as a flat ₹18,000 with no per-call charge, its break-even against serverless falls at 45 million calls, so at 50 million calls the dedicated server is cheaper by ₹2,000/month.
  4. Comparing only the marginal rates (₹0.10 vs ₹0.40 per 1,000 calls), the dedicated server saves ₹15,000/month at 50 million calls, since 0.30 × 50,000 = ₹15,000.

Answer: B. The serverless option is cheaper by ₹3,000/month: ₹20,000 (0.40 × 50,000) versus ₹23,000 (₹18,000 + 0.10 × 50,000) for the dedicated server, since 50 million calls is still below the ₹18,000-fixed-cost break-even of 60 million calls/month.

ExplanationModel each hosting plan as a linear cost function of call volume. Let x be the number of API calls in thousands. Serverless: C₁(x) = 0.40x. Dedicated server: C₂(x) = 18,000 + 0.10x. At x = 50,000 (50 million calls), C₁ = 0.40 × 50,000 = ₹20,000, and C₂ = 18,000 + 0.10 × 50,000 = 18,000 + 5,000 = ₹23,000. Serverless costs ₹3,000 less per month. This can be cross-checked with the break-even volume, found by setting C₁(x) = C₂(x): 0.40x = 18,000 + 0.10x, so 0.30x = 18,000, giving x = 60,000, i.e. 60 million calls/month. Below this break-even, the plan with zero fixed cost (serverless) wins even though its per-call rate is higher, because the fixed ₹18,000 hasn't yet been overcome by the marginal-rate savings (₹0.10 vs ₹0.40 per 1,000 calls) of the dedicated server. Above 60 million calls/month, the dedicated server becomes cheaper. Since PayEase's projected 50 million calls/month sits below the 60-million break-even, serverless remains the cheaper choice, by exactly ₹3,000/month. The distractors correspond to real modeling errors founders make when comparing infrastructure pricing: assuming a fixed-cost plan always wins at "large" volumes without solving for the actual break-even point; dropping a plan's fixed cost or its marginal cost entirely from the comparison; and comparing only per-unit rates while ignoring that total cost is the sum of a fixed term and a volume-dependent term.

Question 132 · Matrices and Linear Transformations: How AI Transforms Data · hard

While debugging a two-feature layer of a fraud-detection model trained on UPI transaction data, an engineer represents the layer's weights as the matrix A = [[4, 2], [1, 3]]. She notices that the input direction v = (2, 1) satisfies Av = (10, 5) = 5v exactly, so v is an eigenvector of A with eigenvalue 5. She concludes: "Since 5 is the largest eigenvalue of A and eigenvectors show how a matrix acts as pure scaling, no unit vector fed into this layer can be stretched by A by more than a factor of 5." Which statement correctly evaluates her conclusion?

  1. Her eigenvalue arithmetic is correct, but the conclusion itself is false. Because A is not symmetric, its eigenvalues do not bound the maximum stretch it applies to unit vectors. The true maximum stretch equals the largest singular value of A, found from the top eigenvalue of AᵀA = [[17, 11], [11, 13]], which is 15 + 5√5 ≈ 26.18 — giving a maximum stretch factor of √26.18 ≈ 5.12, strictly greater than 5.
  2. Her conclusion is correct: since Av = 5v holds exactly and 5 is the largest eigenvalue of A, eigenvalues always equal the maximum possible stretch factor a matrix applies to any unit vector, so no vector is stretched by more than a factor of 5.
  3. Her conclusion is false, but the maximum stretch factor is actually 26.18, since the eigenvalues of AᵀA give the stretch factors A applies to unit vectors directly, with no square root required.
  4. The eigenvector calculation itself is invalid here — because A is not symmetric, it cannot possess genuine real eigenvectors, so the equation Av = 5v cannot actually hold true for any real vector v.

Answer: A. Her eigenvalue arithmetic is correct, but the conclusion itself is false. Because A is not symmetric, its eigenvalues do not bound the maximum stretch it applies to unit vectors. The true maximum stretch equals the largest singular value of A, found from the top eigenvalue of AᵀA = [[17, 11], [11, 13]], which is 15 + 5√5 ≈ 26.18 — giving a maximum stretch factor of √26.18 ≈ 5.12, strictly greater than 5.

ExplanationThe eigenvalue computation itself is fine: A applied to (2,1) gives (4·2+2·1, 1·2+3·1) = (10,5) = 5·(2,1), so 5 is a genuine eigenvalue of A with eigenvector (2,1). But an eigenvalue only measures stretch along its own eigenvector's direction, and it equals the true maximum stretch (the operator norm) only when the matrix is symmetric — because only then are the eigenvectors orthogonal and the eigenvalues automatically equal to the singular values. Here A = [[4,2],[1,3]] is not symmetric (its off-diagonal entries, 2 and 1, differ), so this shortcut fails. The correct way to find the true maximum stretch factor of A over all unit vectors is the singular value decomposition: compute AᵀA = [[4,1],[2,3]]·[[4,2],[1,3]] = [[17,11],[11,13]]. Its eigenvalues solve λ² − 30λ + 100 = 0 (trace 30, determinant 100), giving λ = 15 ± 5√5, approximately 26.18 and 3.82. The largest singular value of A is the square root of the larger eigenvalue: σ_max = √26.18 ≈ 5.12. This is the true maximum factor by which A stretches a unit vector — larger than the eigenvalue-based estimate of 5.00 — and it occurs along the top eigenvector of AᵀA, a direction different from (2,1). This distinction — eigenvalues describe scaling only along special invariant directions, while singular values describe the true maximum (and minimum) stretch over all directions — is exactly why practical machine learning tools rely on singular values, not eigenvalues, to analyze how a general (non-symmetric) weight matrix reshapes data.

Question 133 · Probability and Bayes' Theorem: How AI Reasons Under Uncertainty · hard

An AI-based fraud-detection system used by a UPI payments app flags transactions as "suspicious" for manual review. Historical data shows that 0.5% of all UPI transactions are actually fraudulent. The system correctly flags 98% of truly fraudulent transactions as suspicious (its detection rate), but it also mistakenly flags 3% of genuine, legitimate transactions as suspicious (its false-alarm rate). If a transaction you just made gets flagged as suspicious, what is the probability that it is actually fraudulent?

  1. About 14.1%, since most flagged transactions turn out to be false alarms drawn from the far larger pool of genuine transactions, not true frauds
  2. 98%, because that is the AI's rate of correctly detecting actual fraud cases
  3. About 97.0%, calculated as 0.98 divided by the sum of the detection rate and the false alarm rate
  4. 0.5%, since being flagged does not change the transaction's underlying probability of being fraudulent

Answer: A. About 14.1%, since most flagged transactions turn out to be false alarms drawn from the far larger pool of genuine transactions, not true frauds

ExplanationLet F mean "the transaction is fraudulent" and S mean "the AI flags it as suspicious." The prior is P(F) = 0.005 (so P(¬F) = 0.995), the detection rate is P(S|F) = 0.98, and the false-alarm rate is P(S|¬F) = 0.03. By the law of total probability, P(S) = P(S|F)P(F) + P(S|¬F)P(¬F) = (0.98)(0.005) + (0.03)(0.995) = 0.0049 + 0.02985 = 0.03475. Bayes' theorem then gives P(F|S) = P(S|F)P(F) / P(S) = 0.0049 / 0.03475 ≈ 0.1410, i.e. about 14.1%. A natural-frequency check confirms this: imagine 100,000 transactions. Only 500 (0.5%) are fraudulent, and the AI catches 98% of these, giving 490 true positives. Among the 99,500 genuine transactions, 3% are wrongly flagged, giving 2,985 false positives. Of the 490 + 2,985 = 3,475 total flags, only 490 are real fraud, so 490/3,475 ≈ 14.1% — matching Bayes' theorem exactly. Because genuine transactions vastly outnumber fraudulent ones, even a small 3% false-alarm rate generates far more false flags than the 98% detection rate generates true ones — this base-rate effect is exactly how a well-built AI system must reason probabilistically instead of trusting raw accuracy figures. Treating the posterior as equal to the 98% detection rate commits the classic base-rate fallacy, ignoring how rare fraud actually is. Computing 0.98 ÷ (0.98 + 0.03) silently assumes fraud and legitimate transactions occur equally often, which contradicts the given 0.5% base rate. And answering with the 0.5% prior ignores that being flagged is real evidence that should shift the belief upward, even though it doesn't push it all the way to certainty.

Question 134 · Hypothesis Testing and Confidence Intervals: Making Decisions with Data · hard

A UPI payments startup claims that its gateway processes transactions with an average time of exactly 2.00 seconds. To verify this claim, a quality analyst draws a random sample of n = 36 transactions, obtaining a sample mean of 2.15 seconds and a sample standard deviation of 0.45 seconds. Testing H0: μ = 2.00 seconds against Ha: μ ≠ 2.00 seconds at the 5% significance level (using the sample standard deviation as an estimate of σ, valid since n ≥ 30), which of the following is the correct conclusion?

  1. Reject H0 at the 5% level: z = (2.15 − 2.00)/(0.45/√36) = 0.15/0.075 = 2.00, which exceeds the two-tailed critical value 1.96, so there is significant evidence the mean processing time differs from 2.00 seconds; consistently, the 95% confidence interval (2.003, 2.297) seconds excludes 2.00.
  2. Fail to reject H0, since a two-tailed test at the 5% level requires |z| to exceed 2.576 to count as significant, and the computed z = 2.00 falls short of that threshold, so the data do not show the mean differs from 2.00 seconds.
  3. Reject H0 with overwhelming confidence: using a standard error of s/n = 0.45/36 = 0.0125 seconds gives z = 0.15/0.0125 = 12.00, a value far beyond any conventional critical value, so the average time is decisively different from 2.00 seconds.
  4. Fail to reject H0, because the 0.15-second gap between the sample mean and the claimed mean is smaller than the sample standard deviation of 0.45 seconds, so the difference falls within ordinary data variability and is not statistically significant.

Answer: A. Reject H0 at the 5% level: z = (2.15 − 2.00)/(0.45/√36) = 0.15/0.075 = 2.00, which exceeds the two-tailed critical value 1.96, so there is significant evidence the mean processing time differs from 2.00 seconds; consistently, the 95% confidence interval (2.003, 2.297) seconds excludes 2.00.

ExplanationThe standard error of the sample mean is s/√n = 0.45/√36 = 0.45/6 = 0.075 seconds, so the test statistic is z = (x̄ − μ0)/SE = (2.15 − 2.00)/0.075 = 2.00. For a two-tailed test at α = 0.05, the outer 2.5% of the standard normal distribution on each side begins at z = ±1.96, so H0 is rejected whenever |z| exceeds 1.96. Since 2.00 > 1.96, the observed statistic falls in the rejection region: the data give statistically significant evidence that the true mean processing time differs from the claimed 2.00 seconds. This is confirmed by building the 95% confidence interval directly: x̄ ± 1.96·SE = 2.15 ± 1.96(0.075) = 2.15 ± 0.147, giving (2.003, 2.297) seconds — an interval that excludes 2.00, exactly the signature of a significant result at matching confidence. The fail-to-reject claims each rest on a genuine but distinct error: one confuses the 5% critical value (1.96) with the 1% critical value (2.576), silently demanding stronger evidence than the stated significance level requires; the other compares the 0.15-second gap to the sample standard deviation s = 0.45, which measures how spread out individual transactions are, instead of to the standard error 0.075, which measures how spread out the sample mean is and shrinks as √n grows — conflating those two very different quantities is one of the most common errors in this topic. The "overwhelming evidence" claim makes the reverse mistake, dividing by n = 36 instead of √n = 6, which artificially shrinks the standard error and inflates z to an implausible 12.00.

Question 135 · Calculus Intuition: Derivatives and Gradients for Machine Learning · hard

A data science team at an Indian fintech startup is training a tiny one-parameter model to flag suspicious UPI transactions, and the training loss as a function of the single weight w works out to L(w) = w⁴ − 4w³ + 4w². The team runs gradient descent from two different random initial values of w and is surprised to see it settle at two different final weights, both giving the same training loss. After computing L'(w) and using the second-derivative test to classify every critical point of L(w), which of the following correctly describes the shape of this loss landscape and what it implies for gradient descent?

  1. Critical points occur where L'(w) = 4w(w-1)(w-2) = 0, at w = 0, 1, 2, with w = 0 and w = 2 as local minima and w = 1 as a local maximum; but because gradient descent is guaranteed to converge to the global minimum of any differentiable loss function regardless of initialization, the choice of starting weight w does not affect the final trained value here.
  2. Evaluating L''(1) = 12(1)² − 24(1) + 8 = −4, which is negative, correctly identifies w = 1 as the global minimum of the loss, while the sign change of L' around w = 0 and w = 2 marks those points as saddle points rather than minima.
  3. Factoring the derivative as L'(w) = 4w(w-1)(w-2) shows critical points at w = 0, 1, 2; evaluating the second derivative gives L''(0) = 8 > 0 and L''(2) = 8 > 0, so both points are local minima, and since L(0) = L(2) = 0 while L(w) → ∞ as w → ±∞, they are tied global minima — gradient descent converges to whichever basin contains the initial weight.
  4. The same derivative factoring, L'(w) = 4w(w-1)(w-2), gives critical points at w = 0, 1, 2, but evaluating L''(w) = 12w² − 24w + 8 at all three points yields a positive value in every case, making w = 0, w = 1, and w = 2 all local minima that gradient descent could settle into.

Answer: C. Factoring the derivative as L'(w) = 4w(w-1)(w-2) shows critical points at w = 0, 1, 2; evaluating the second derivative gives L''(0) = 8 > 0 and L''(2) = 8 > 0, so both points are local minima, and since L(0) = L(2) = 0 while L(w) → ∞ as w → ±∞, they are tied global minima — gradient descent converges to whichever basin contains the initial weight.

ExplanationDifferentiating term by term, L'(w) = 4w³ − 12w² + 8w, which factors as 4w(w−1)(w−2), so the slope is zero exactly at w = 0, w = 1, and w = 2 — these are the only points where gradient descent can stop moving. The second derivative is L''(w) = 12w² − 24w + 8. At w = 0, L''(0) = 8 > 0, confirming a local minimum with L(0) = 0. At w = 1, L''(1) = 12 − 24 + 8 = −4 < 0, confirming a local maximum with L(1) = 1. At w = 2, L''(2) = 48 − 48 + 8 = 8 > 0, confirming another local minimum with L(2) = 16 − 32 + 16 = 0. Because the leading term w⁴ forces L(w) → ∞ as w → ±∞, no point outside these three can beat the two minima, so w = 0 and w = 2 are both global minima with identical loss value 0, separated by a local-maximum "hill" at w = 1. This is exactly why gradient descent's outcome here depends on where training starts: an initial weight below 1 slides down to w = 0, while an initial weight above 1 slides down to w = 2 — the algorithm has no way of preferring one basin over the other once both reach the same minimum loss, and it never crosses the hill at w = 1 on its own because the gradient always points away from that peak, not toward it.

Question 136 · Logistic Regression: The Foundation of Neural Network Classifiers · hard

A logistic regression model predicts whether a rider's IRCTC waitlisted ticket will get CONFIRMED, using one normalized feature x built from (days before departure, berth demand). It computes z = wx + b, then p = σ(z) = 1/(1 + e^(−z)). For one training example: x = 1.5, w = 2, b = −1, and true label y = 1 (the ticket was in fact confirmed). Training minimizes the binary cross-entropy loss L = −[y·ln(p) + (1−y)·ln(1−p)]. By the chain rule, ∂L/∂w = (∂L/∂p)·(∂p/∂z)·(∂z/∂w), and a well-known cancellation occurs: the 1/[p(1−p)] from the cross-entropy derivative exactly cancels the σ'(z) = p(1−p) from the sigmoid derivative, leaving ∂L/∂w = (p − y)·x. Computing z, then p, then this gradient for the given numbers, what is ∂L/∂w, rounded to three decimal places?

  1. -0.179, because z = 2, p = σ(2) ≈ 0.881, and the cross-entropy gradient (p − y)·x = (0.881 − 1)(1.5).
  2. 0.179, because using (y − p)·x instead of (p − y)·x gives (1 − 0.881)(1.5), the sign convention for gradient ascent on log-likelihood.
  3. -0.019, because multiplying in the extra sigmoid-derivative factor p(1 − p) ≈ 0.105 before the input gives (p − y)·p(1 − p)·x.
  4. 0.881, because the predicted probability p = σ(2) itself equals the gradient of the loss with respect to w for this example.

Answer: A. -0.179, because z = 2, p = σ(2) ≈ 0.881, and the cross-entropy gradient (p − y)·x = (0.881 − 1)(1.5).

ExplanationWorking forward step by step: z = wx + b = (2)(1.5) + (−1) = 3 − 1 = 2. So p = σ(2) = e²/(1 + e²) = 7.389/8.389 ≈ 0.881, meaning the model currently gives an 88.1% chance the waitlisted ticket confirms. Since y = 1, the "error signal" p − y = 0.881 − 1 = −0.119: the model is slightly under-confident, and the loss wants w to increase to push p toward 1. The full chain-rule computation is ∂L/∂p = (p−y)/[p(1−p)], and ∂p/∂z = p(1−p), so their product is exactly p − y — the p(1−p) terms cancel algebraically, not by coincidence. That's what makes ∂L/∂w = (p − y)·x = (−0.119)(1.5) ≈ −0.179 so clean. This cancellation is precisely why cross-entropy is paired with sigmoid (and softmax) throughout neural networks: every output-layer gradient in a deep classifier reduces to the same (prediction − label)·input form, regardless of how deep the network is, which is what makes logistic regression the literal output layer of most neural classifiers. The −0.179 gradient tells gradient descent to increase w (move opposite the negative gradient), correctly pushing p closer to 1. The second option comes from confusing two related but opposite conventions: (y − p)·x is the gradient of the log-likelihood used when doing gradient ASCENT to maximize likelihood, while (p − y)·x is the gradient of the loss (negative log-likelihood) used for gradient DESCENT — mixing them up flips the sign and would make the optimizer move the wrong way. The third option comes from forgetting the cancellation entirely and treating this like squared-error loss, where the chain rule genuinely does leave an uncancelled σ'(z) = p(1−p) factor; multiplying that in shrinks the gradient to roughly −0.019, which is why plain MSE trains logistic units much more slowly than cross-entropy does. The fourth option confuses the predicted probability itself with the loss gradient — p = 0.881 measures the model's current belief, not how the loss changes with w, and it never involves y or x at all, so it cannot be a gradient.

Question 137 · K-Means Clustering: Finding Hidden Groups in Data · hard

A Bengaluru last-mile delivery startup wants to place K = 2 micro-warehouses to serve five pincode zones. Zone coordinates (x, y) in km from Ekta Chowk are: Z1(2, 3), Z2(3, 3), Z3(6, 6), Z4(8, 5), Z5(2, 8). Running Lloyd's algorithm (standard K-means) with initial centroids C1 = Z1 = (2, 3) and C2 = Z4 = (8, 5), each zone is first assigned to its nearer centroid using squared Euclidean distance, and then each centroid is recomputed as the arithmetic mean of the zones assigned to it. What are the coordinates of the updated C1 after this first full iteration?

  1. (7/3, 14/3), i.e., approximately (2.33, 4.67) — the mean of the three zones (Z1, Z2, Z5) assigned to C1 in this round
  2. (7, 5.5) — the mean of Z3 and Z4, which is actually the updated position of C2, not C1
  3. (4.2, 5.0) — the mean of all five zones, ignoring the cluster-assignment step entirely
  4. (2, 3) — unchanged from its initial value, since Z1 was already located exactly at C1

Answer: A. (7/3, 14/3), i.e., approximately (2.33, 4.67) — the mean of the three zones (Z1, Z2, Z5) assigned to C1 in this round

ExplanationLloyd's algorithm alternates two steps every round: assign each point to its nearest centroid, then move each centroid to the mean of the points now assigned to it. Using squared Euclidean distance from C1 = (2, 3) and C2 = (8, 5): Z1(2,3): d²(C1)=0, d²(C2)=(2-8)²+(3-5)²=36+4=40 → nearer to C1 Z2(3,3): d²(C1)=(3-2)²+0²=1, d²(C2)=(3-8)²+(3-5)²=25+4=29 → nearer to C1 Z3(6,6): d²(C1)=(6-2)²+(6-3)²=16+9=25, d²(C2)=(6-8)²+(6-5)²=4+1=5 → nearer to C2 Z4(8,5): d²(C1)=(8-2)²+(5-3)²=36+4=40, d²(C2)=0 → nearer to C2 Z5(2,8): d²(C1)=0²+(8-3)²=25, d²(C2)=(2-8)²+(8-5)²=36+9=45 → nearer to C1 So Cluster 1 = {Z1, Z2, Z5} and Cluster 2 = {Z3, Z4}. The update step replaces C1 with the mean of exactly these three zones — not all five, and not the other cluster's members. This is not arbitrary: for a fixed cluster assignment, the mean is the unique minimizer of the within-cluster sum of squared distances J(c) = Σ(xᵢ − c)². Differentiating, dJ/dc = −2Σ(xᵢ − c), which equals zero precisely when c = (1/n)Σxᵢ, the mean — and since d²J/dc² = 2n > 0, this is a minimum, not just a stationary point. Applying that here: new C1 = ((2+3+2)/3, (3+3+8)/3) = (7/3, 14/3) ≈ (2.33 km, 4.67 km) from Ekta Chowk. Averaging all five zones conflates the two clusters into one point that minimizes nothing meaningful for K-means; reporting (7, 5.5) mixes up which cluster's mean is which; and leaving C1 at (2, 3) skips the update step altogether — a centroid coinciding with one data point initially is coincidental and does not exempt it from being recomputed once the assignment step redraws cluster membership.

Question 138 · Optimization Algorithms: How AI Learns Efficiently · hard

A gradient-descent script is minimizing the loss L(w) = 3w² using the update rule w_{t+1} = w_t − η·(dL/dw), implemented as: ```python def grad(w): return 6 * w # dL/dw for L(w) = 3w^2 w = 4.0 eta = 0.4 for step in range(3): w = w - eta * grad(w) ``` Starting from w0 = 4 with a fixed learning rate η = 0.4, what happens to w over these three update steps, and why?

  1. w converges monotonically toward the minimum at w = 0, since L(w) = 3w² is a convex function and gradient descent is guaranteed to converge to the global minimum for any positive learning rate.
  2. w shrinks toward 0 with alternating sign, following the rule w_{t+1} = −0.4·w_t, giving w1 = −1.6, w2 = 0.64, w3 = −0.256, since gradient descent scales the current weight directly by the learning rate.
  3. w oscillates in sign and grows in magnitude at every step -- w1 = −5.6, w2 = 7.84, w3 = −10.976 -- because η = 0.4 exceeds the stability threshold η < 1/3 for this loss, making the update multiplier (1 − 6η) = −1.4 exceed 1 in absolute value.
  4. w oscillates indefinitely between +4 and −4 with constant magnitude, because the learning rate exactly cancels the effect of the gradient at every step.

Answer: C. w oscillates in sign and grows in magnitude at every step -- w1 = −5.6, w2 = 7.84, w3 = −10.976 -- because η = 0.4 exceeds the stability threshold η < 1/3 for this loss, making the update multiplier (1 − 6η) = −1.4 exceed 1 in absolute value.

ExplanationDifferentiating L(w) = 3w² gives dL/dw = 6w, so the update becomes w_{t+1} = w_t − η(6w_t) = (1 − 6η)w_t. This is a linear recurrence with multiplier m = 1 − 6η, so after t steps w_t = m^t·w0: it shrinks toward zero if |m| < 1 and blows up if |m| > 1. With η = 0.4, m = 1 − 6(0.4) = 1 − 2.4 = −1.4, and |m| = 1.4 > 1, so the sequence diverges, flipping sign every step because m is negative. Tracing the loop by hand confirms this: w1 = (−1.4)(4) = −5.6, w2 = (−1.4)(−5.6) = 7.84, w3 = (−1.4)(7.84) = −10.976. For any quadratic loss L(w) = cw², the stability condition |1 − 2cη| < 1 reduces to 0 < η < 1/c; here c = 3, so the boundary is η < 1/3, and 0.4 sits well past it. This is why convexity alone (ruled out by the first distractor) does not guarantee convergence -- a convex loss with high curvature (a large second derivative) needs a correspondingly small learning rate, and the same η that converges smoothly on a flatter loss can explode on a steeper one. The idea that gradient descent simply rescales w by η each step ignores that the update depends on the gradient (which itself scales with w here), not on w alone, and the "constant-amplitude oscillation" scenario is what happens only at the exact boundary η = 1/3, not at η = 0.4.

Question 139 · Loss Functions: Teaching Neural Networks What to Learn · hard

A UPI fraud-detection neuron uses a sigmoid activation on its pre-activation score z. For one genuinely fraudulent transaction (true label y = 1), the network is badly miscalibrated: z = -3, giving predicted probability p = σ(z) ≈ 0.0474 that the transaction is fraud — a confident wrong answer. Using dp/dz = p(1-p), compute ∂L/∂z for mean-squared-error loss L_MSE = (y-p)² and for binary cross-entropy loss L_BCE = -[y ln p + (1-y) ln(1-p)], and determine which loss drives faster weight correction for this training example?

  1. Cross-entropy wins decisively: ∂L_BCE/∂z ≈ -0.953 versus ∂L_MSE/∂z ≈ -0.086, an 11× gap, because BCE's chain-rule terms cancel to the raw error (p − y) while MSE keeps an extra p(1−p) factor that shrinks near saturated outputs.
  2. MSE wins here: ∂L_MSE/∂z ≈ -0.953 versus ∂L_BCE/∂z ≈ -0.086, because squaring the error amplifies large mistakes, letting mean-squared error correct this confidently wrong prediction faster than cross-entropy.
  3. The two losses tie: both give ∂L/∂z = p − y ≈ -0.953, since the dp/dz = p(1−p) factor always cancels against the outer derivative regardless of which loss function was chosen.
  4. Cross-entropy still wins, but by more: ∂L_BCE/∂z ≈ -0.953 versus ∂L_MSE/∂z ≈ -0.043, a 22× gap, because the MSE gradient (y−p)·p(1−p) carries no leading factor of 2.

Answer: A. Cross-entropy wins decisively: ∂L_BCE/∂z ≈ -0.953 versus ∂L_MSE/∂z ≈ -0.086, an 11× gap, because BCE's chain-rule terms cancel to the raw error (p − y) while MSE keeps an extra p(1−p) factor that shrinks near saturated outputs.

ExplanationWith y = 1 and z = -3, the predicted probability is p = σ(-3) = 1/(1+e³) ≈ 0.0474, so the network is confidently wrong. For cross-entropy, L_BCE = -[y ln p + (1-y) ln(1-p)] gives dL/dp = -y/p + (1-y)/(1-p); multiplying by dp/dz = p(1-p) and simplifying, every p(1-p) term cancels, leaving the clean result ∂L_BCE/∂z = p - y = 0.0474 - 1 ≈ -0.953. For mean-squared error, L_MSE = (y-p)² gives dL/dp = -2(y-p); multiplying by dp/dz = p(1-p) = 0.0474 × 0.9526 ≈ 0.0452 (no cancellation happens this time), so ∂L_MSE/∂z = -2(1-0.0474)(0.0452) ≈ -0.086. The cross-entropy gradient is roughly 11 times larger in magnitude. This is precisely the vanishing-gradient problem MSE has with sigmoid outputs: when a prediction saturates near 0 or 1 while being badly wrong, the p(1-p) factor in the MSE gradient shrinks toward zero right when the network most needs a strong correction signal, so learning stalls. Cross-entropy avoids this because its gradient depends only on the raw error (p - y), staying large whenever the prediction is far from the true label — which is exactly why cross-entropy, not MSE, is the standard loss for classification networks with sigmoid or softmax outputs.

Question 140 · Model Evaluation: Beyond Accuracy — Precision, Recall, F1, and ROC · hard

A bank's AI system screens 10,000 UPI transactions in a day to flag possible fraud. Only 100 of these transactions are actually fraudulent. After running the model, the confusion matrix (treating "fraud" as the positive class) comes out as: True Positives = 70, False Negatives = 30, False Positives = 130, True Negatives = 9,770. What is the model's F1-score for the fraud class?

  1. F1-score ≈ 46.7%, computed as the harmonic mean of precision (35%) and recall (70%).
  2. F1-score ≈ 98.4%, which is actually the model's overall accuracy, not its F1-score.
  3. F1-score ≈ 52.5%, found by averaging precision and recall arithmetically instead of harmonically.
  4. F1-score ≈ 81.9%, obtained by mistakenly using specificity (TN/(TN+FP)) in place of precision.

Answer: A. F1-score ≈ 46.7%, computed as the harmonic mean of precision (35%) and recall (70%).

ExplanationFor the fraud (positive) class, Precision = TP/(TP+FP) = 70/200 = 0.35 and Recall = TP/(TP+FN) = 70/100 = 0.70. The F1-score is the harmonic mean of these two: F1 = 2·P·R/(P+R) = (2 × 0.35 × 0.70)/(0.35 + 0.70) = 0.49/1.05 ≈ 0.4667, about 46.7%. Compare this to the deceptively high accuracy, (TP+TN)/Total = (70+9770)/10000 = 98.4%: because fraud is rare (only 100 of 10,000 transactions), a model can call almost everything "not fraud" and still look accurate, even while catching fraud poorly — accuracy is not F1. The harmonic mean is also not the same as the arithmetic mean (0.35+0.70)/2 = 0.525: the harmonic mean always sits closer to the smaller of the two numbers, so it punishes an imbalance between precision and recall far more harshly. That gap matters in practice — with precision at just 35%, only 70 of the 200 transactions the model flags are genuinely fraudulent, meaning the bank's fraud team wastes most of its effort chasing false alarms, a weakness the arithmetic mean of 52.5% would understate. Finally, precision must not be confused with specificity, TN/(TN+FP) = 9770/9900 ≈ 98.7%, which measures how well the model avoids false alarms among genuine transactions, not how trustworthy a fraud flag is once it is raised — that confusion is what produces the inflated 81.9% figure.
← Set 6Set 8 →