For nonzero coefficients a₀,…,a₃, consider p(x)=a₀+a₁x+a₂x²+a₃x³. What is the minimum multiplication count for evaluating p at x? This is the GFG cubic reading; GateForum prints a₃x² instead, and neither source explicitly says generic coefficients. Options: (A) 3 (B) 4 (C) 6 (D) 9
Your answer
Answer & solution
Answer: A for generic cubic coefficients (no official key was published)
1. The the paper displays a cubic: p=a0+x(a1+x(a2+a3x)). Horner evaluation uses three multiplications and three additions, giving A under the conventional generic-coefficient evaluation model.
2. Nonzero coefficients alone also do not rule out special simplifications, for example (x+1)3 uses two multiplications after forming x+1.
3. Thus three is the standard generic cubic cost, not a universal lower bound for every coefficient choice. Original official wording and key remain unavailable.
4. Teaching check: Evaluate the nested form from the inside: t=a₃x+a₂, then t=tx+a₁, then p=tx+a₀. Each stage contributes one multiplication. The answer depends on treating the cubic as a generic polynomial; it is not a theorem about every particular nonzero coefficient tuple.
Sets X,Y,Z have cardinalities x,y,z. Let W=X×Y and E be the power set of W. How many functions Z→E exist? The reproduced options use uppercase Z where the cardinality z is intended. Options: (A) z^(2^(xy)) (B) z·2^(xy) (C) z^(2^(x+y)) (D) 2^(xyz)
Your answer
Answer & solution
Answer: D (no official key was published)
1. The Cartesian product has xy elements, so its power set has 2xy elements. For each of the z domain elements, independently choose one image.
2. This gives(2xy)z=2xyz, option D, with the usual empty-domain convention.
3. Teaching check: For one argument in Z there are 2xy possible output subsets, including the empty subset. Choosing images for different arguments does not impose injectivity or surjectivity. This is the general counting rule |codomain|^|domain|, not |domain|^|codomain|.
The set {1,2,3,5,7,8,9} with multiplication modulo 10 is not a group. Which proposed reason is false? Options: (A) The set is not closed (B) 2 has no inverse (C) 3 has no inverse (D) 8 has no inverse
Your answer
Answer & solution
Answer: C (no official key was published)
1. The claim that 3 has no inverse is false:3×7≡1 modulo 10 and 7 belongs to the set. The set is not closed, since 2×2≡4 is absent.
2. Neither2 nor 8 is a unit modulo 10 because each shares a factor 2 with 10. Thus C is the false reason.
3. Teaching check: A multiplicative inverse of k modulo 10 must solve kt≡1. Such a t exists exactly when gcd(k,10)=1. In particular 3·7=21 has remainder 1, whereas every product involving 2 or 8 is even and cannot have remainder 1.
On ordered pairs of integers define (x,y)R(u,v) iff x<u and y>v. Classify R, with partial order understood in the usual reflexive sense. Options: (A) Neither a partial order nor an equivalence relation (B) A partial order but not a total order (C) A total order (D) An equivalence relation
Your answer
Answer & solution
Answer: A under the reflexive partial-order convention (no official key was published)
1. For every pair(x,y), x<x is false, so the relation is not reflexive. It is therefore neither an equivalence relation nor a reflexive partial order, A.
2. It is transitive and irreflexive, hence a strict partial order in terminology that explicitly distinguishes strict orders; it is not total because pairs with equal first coordinate are incomparable.
3. Teaching check: To test reflexivity, substitute the very same pair on both sides. The required inequalities become x<x and y>y, both false. Although transitivity holds by chaining strict inequalities, transitivity alone does not meet the definition of a reflexive partial order.
Similar questions1 more → · asked again: GATE 2010, Q15
Purpose of IPv4 TTL
IP Addressing, Fragmentation & Address Resolution
Tap to enlarge
Why does IP put a Time-to-Live (TTL) field in the datagram header? Options: (A) Ensure delivery within that time (B) Discard packets that reach the destination later than that time (C) Prevent packets looping indefinitely (D) Limit the time spent queued in intermediate routers
Your answer
Answer & solution
Answer: C (no official key was published)
1. Every forwarding router decreases TTL, and a datagram is discarded when it expires. This bounds forwarding through a routing loop rather than promising delivery within a deadline.
2. Therefore C, preventing indefinite looping.
3. Teaching check: A routing loop may keep forwarding a datagram without delivering it. Decrementing a finite counter at each router eventually destroys that datagram even if the routing error persists. TTL does not reserve network resources or provide an end-to-end latency guarantee.
Three CPU-bound processes arrive at times 0,2,6 and need 10,20,30 time units respectively. With shortest-remaining-time-first scheduling, how many context switches occur, excluding initial dispatch at time 0 and final termination? Options: (A) 1 (B) 2 (C) 3 (D) 4
Your answer
Answer & solution
Answer: B (no official key was published)
1. At time 2 the first process has 8 units remaining, less than the new 20. At time 6 it has 4 remaining, less than 30.
2. It therefore runs 0–10, followed by the 20-unit process 10–30 and the 30-unit process 30–60. Excluding initial dispatch and final exit leaves two process switches, B.
3. Teaching check: Draw the CPU timeline 0–10:P1, 10–30:P2, 30–60:P3. An arrival is not automatically a preemption: compare its burst with the current remaining time. Only the changes P1→P2 and P2→P3 count under the exclusions in the question.
Grammar: S→S*E | E; E→F+E | F; F→id. Consider LR(0) items 1: S→S*·E; 2: E→F·+E; 3: E→F+·E. Which pair appears together in a canonical item set? Options: (A) 1 and 2 (B) 2 and 3 (C) 1 and 3 (D) None of these pairs
Your answer
Answer & solution
Answer: D (no official key was published)
Step through it (12 steps)
1. The state after recognizing S* contains S→S*·E plus closure items E→·F+E,E→·F,F→·id. The item E→F·+E occurs after a transition on F, together with E→F·.
2. The item E→F+·E occurs after a further transition on +, again with the initial E/F closure. These three kernels are different states; closure does not introduce either of the other listed advanced items.
3. Thus none of the listed pairs coexist, D.
4. Teaching check: LR closure inserts productions with the dot at their beginning when a nonterminal follows the dot. It never advances an existing dot. Thus an item beginning E→·F can coexist with item 1, but the advanced E→F·+E requires a GOTO on F, producing another state.
A free-running clock has 50% duty cycle; waveform f changes only at its falling edges. Which two-stage clocked-D circuit delays f by 180°? Textual circuit options specify (stage-1 D input, stage-1 clock, stage-1 output wired to stage-2 D, stage-2 clock); every final output is stage-2 Q. The source does not resolve whether “clocked D flip-flops” means level-sensitive stages or edge-triggered devices. Options: (A) (¬f, ¬clk, Q̄, clk) (B) (¬f, clk, Q, ¬clk) (C) (f, clk, Q, ¬clk) (D) (f, ¬clk, Q̄, clk)
Your answer
Answer & solution
Answer: A under the intended two-phase storage model (no official key was published)
1. In A the first D storage stage is enabled by inverted clock, receives ¬f, and exposes its complemented output, restoring f. The second stage is driven by the original clock.
2. Under a level-sensitive two-phase interpretation, a change of f at the falling edge propagates through the first stage during the low half-cycle and becomes visible through the second at the next rising edge: delay T/2, or 180 degrees of the clock. D gives the wrong polarity; B and C use the opposite phase order.
3. If these are literal falling-edge-triggered flip-flops, f changes at the sampling edge and setup/hold timing is unspecified, so reliable half-cycle delay is not guaranteed. The the paper says clocked D flip-flops without resolving this distinction.
4. Teaching check: Distinguish signal inversion from delay: feeding ¬f and then using Q̄ restores f’s polarity. The complementary clocks create the intended half-period separation. Reliable edge-triggered sampling additionally requires setup/hold margins, which the statement does not supply for f changing exactly at a clock edge.
A CPU has fixed 24-bit instructions and a program beginning at decimal address 300. Which listed decimal value is a legal program counter in that instruction stream? The conventional byte-addressing assumption is implicit in the reproduction. Options: (A) 400 (B) 500 (C) 600 (D) 700
Your answer
Answer & solution
Answer: C under byte addressing (no official key was published)
1. With byte-addressed memory and fixed 24-bit instructions, each instruction occupies 3 bytes. Addresses in this instruction stream are 300+3k.
2. Only600 among the listed values differs from 300 by a multiple of 3, so C. Instruction width alone does not establish byte addressing or prohibit other instruction streams; those are the conventional implicit assumptions.
3. Teaching check: Convert instruction width from bits to bytes before testing alignment: 24/8=3. The differences from the starting address are 100,200,300,400; only 300 is divisible by three. This checks positions in the given instruction stream, not all arbitrary code addresses in memory.
What is the worst-case asymptotic time for finding the smallest of n numbers stored in a binary max-heap? Options: (A) Θ(n) (B) Θ(log n) (C) Θ(log log n) (D) Θ(1)
Your answer
Answer & solution
Answer: A (no official key was published)
1. A minimum occurs among the leaves. There are Θ(n) leaves and their values have no guaranteed mutual ordering.
2. Scanning them gives O(n) time; arbitrary leaf values require Ω(n) comparisons in the worst case. Therefore Θ(n), A.
3. Teaching check: A max-heap constrains each parent to be at least its children, so following children can only decrease values. Every internal node has some leaf descendant no larger than itself. However the roughly n/2 leaves have no ordering among themselves, so binary-search reasoning does not apply.
Similar questions2 more → · asked again: GATE 2020, Q49
Minimum spanning tree on indexed vertices
Graph Algorithms
Tap to enlarge
A weighted complete graph has vertices v₁,…,vₙ and edge weight w(vᵢ,vⱼ)=2|i−j|. What is the minimum spanning-tree weight? Options: (A) n−1 (B) 2n−2 (C) C(n,2) (D) n²
Your answer
Answer & solution
Answer: B (no official key was published)
1. Every edge has weight 2|i−j|≥2, so every spanning tree costs at least 2(n−1). The path v1,v2,...,vn uses n−1 edges of weight 2 and attains the bound.
2. Hence2n−2, B.
3. Teaching check: This is a lower-bound-plus-construction proof. Every spanning tree has exactly n−1 edges and every available edge costs at least two. Connecting consecutive indices achieves that lower bound; no search over all spanning trees is necessary.
Which data structure lets the shortest-path method on an unweighted graph run in linear time, as the unweighted specialization of Dijkstra’s algorithm? Options: (A) Queue (B) Stack (C) Heap (D) B-tree
Your answer
Answer & solution
Answer: A (no official key was published)
1. All edges have equal unit cost, so increasing distance order is breadth-first order. A FIFO queue processes each vertex and scans each adjacency list once, in O(V+E) time.
2. Thus A; a priority heap is unnecessary.
3. Teaching check: In an unweighted graph, every discovered neighbor is exactly one hop farther than its predecessor. A FIFO queue keeps frontier layers in nondecreasing distance order, which is the priority rule Dijkstra needs here. With adjacency lists the total scan cost is the sum of degrees, O(V+E).
Store any n-node binary tree in a one-based array: root at X[1], left child of X[i] at X[2i], right child at X[2i+1]. What minimum array capacity guarantees room for every possible n-node tree? Options: (A) log₂n (B) n (C) 2n+1 (D) 2^n−1
Your answer
Answer & solution
Answer: D (no official key was published)
1. Following right children produces indices 1,3,7,...,2n−1 for an n-node chain. No n-node tree has depth beyond n−1, whose largest possible index is 2n−1.
2. Therefore an array indexed from 1 must provide that many positions, D. This counts logical one-based entries, not an extra unused C array index 0.
3. Teaching check: A chain of only right children is the worst case, not a balanced tree. Repeatedly applying i↦2i+1 from i=1 gives iₖ=2k+1−1 at depth k. The last of n nodes therefore occupies index 2n−1, although only n positions contain actual nodes.
Among the standard in-place sorting algorithms listed, which needs the fewest swaps under the conventional worst-case exchange-count comparison? Options: (A) Quicksort (B) Insertion sort (C) Selection sort (D) Heapsort
Your answer
Answer & solution
Answer: C under the standard swap-based comparison (no official key was published)
1. Selection sort places the minimum remaining item in its final location with at most one exchange per pass, hence at most n−1 swaps. Standard swap-based insertion sort, quicksort and heapsort can use more.
2. Thus selection sort, C, in the conventional worst-case exchange-count comparison. A shift-based insertion implementation can avoid an explicit swap operation, so literal source-code swap counts are implementation-dependent.
3. Teaching check: Selection sort can inspect the entire unsorted suffix without moving any item, then exchange its minimum with the first unsorted position. This separates comparison count, Θ(n²), from exchange count, O(n). The question asks about swaps, not fastest running time.
For positive integer n, the C fragment is: for (i=n,j=0; i>0; i/=2,j+=i); . Here i,j,n are integer variables and the loop body is empty. Which is the asymptotic value of j after termination, rather than the running time? Options: (A) Θ(log n) (B) Θ(√n) (C) Θ(n) (D) Θ(n log n)
Your answer
Answer & solution
Answer: C (no official key was published)
1. The update uses the comma operator: first integer-divide i by 2, then add the new i to j. For positive n, j=floor(n/2)+floor(n/4)+...=n−popcount(n).
2. It is at least floor(n/2) and less than n, hence Θ(n), C. This is the value accumulated, not the Θ(log n) iteration count.
3. Its value remains below n, so no positive signed overflow is needed when n is representable.
4. Teaching check: For n=13 the updates add 6,3,1,0, yielding j=10 even though there are only four iterations. Generally the sum lies between floor(n/2) and n, which supplies matching linear bounds without needing the exact popcount identity.
S is NP-complete. Q and R are problems not initially known to belong to NP. Q is polynomial-time reducible to S and S is polynomial-time reducible to R. Which statement necessarily follows? Options: (A) R is NP-complete (B) R is NP-hard (C) Q is NP-complete (D) Q is NP-hard
Your answer
Answer & solution
Answer: B (no official key was published)
1. Every NP language reduces to S, and S reduces to R, so transitivity makes R NP-hard. R need not belong to NP and therefore need not be NP-complete.
2. Q reducing to S does place Q in NP, but does not make Q NP-hard. Thus B.
3. Teaching check: Reduction direction matters: if A reduces to B, a solver for B can solve A. Thus hardness flows from S toward R. Membership in NP does not automatically flow in that direction, which is why NP-hard is justified but NP-complete is not.
An array element is a leader if it exceeds every element to its right. Which description gives the best algorithm for finding all leaders? No auxiliary-space restriction is stated, which affects whether the options are exclusive. Options: (A) Linear time with a left-to-right pass (B) Linear time with a right-to-left pass (C) Divide and conquer in Θ(n log n) (D) Θ(n²) time
Your answer
Answer & solution
Answer: B with constant extra space; A also possible with a stack (no official key was published)
1. Scanning right to left while retaining the largest value seen reports exactly the elements strictly larger than every element to their right. This is Θ(n) time and O(1) extra working space, yielding the usual B.
2. However A is also achievable in linear time if extra storage is allowed: scan left to right, keep candidate leaders in a decreasing stack, and pop every prior candidate≤the new value before pushing it. Each entry is pushed/popped at most once; the final stack contains the leaders.
3. Since the prompt does not require constant space, traversal direction alone does not make B uniquely correct.
4. Teaching check: Right-to-left scanning initializes the current maximum with the rightmost element and reports a new element only when it is strictly greater. Equal values do not become leaders if an equal value occurs later. A left-to-right monotone stack is a separate linear-time possibility, explaining the nonunique direction-only options.
Let X={2¹,2²,…,2ⁿ}. Form S⊆X by independently selecting each element with probability 1/2. What is the expected smallest element of S? The reproduced question does not specify what to do when S is empty. Options: (A) 1/n (B) 2 (C) √n (D) n
Your answer
Answer & solution
Answer: D only if the empty sample is assigned value 0 (no official key was published)
1. The event that 2i is the minimum requires excluding the i−1 smaller values and including 2i, with probability 2-i. Summing2i×2-i over i=1,...,n gives n.
2. But the empty sample occurs with probability 2-n and has no smallest element. Thus the expectation as literally stated is undefined.
3. Setting the empty-sample value to 0 gives n, D; conditioning on a nonempty sample instead gives n/(1−2-n). No official answer is inferred.
4. Teaching check: There are n disjoint events “2i is the minimum,” each contributing exactly one to the unconditioned sum when the empty case is assigned zero. Their probabilities sum to 1−2−n, not one. Dividing by that nonempty probability produces the conditional expectation.
For n,m≥0 define L₁={0^(n+m)1^n0^m}, L₂={0^(n+m)1^(n+m)0^m}, and L₃={0^(n+m)1^(n+m)0^(n+m)}. Which languages are not context-free? Options: (A) L₁ only (B) L₃ only (C) L₁ and L₂ (D) L₂ and L₃
Your answer
Answer & solution
Answer: D (no official key was published)
1. L1={0n+m1n0m} is context-free: S→0S0|T and T→0T1|ε generates it. Write L2={0k1k0m:0≤m≤k}.
2. It is not context-free: apply the CFL pumping lemma to 0p1p0p. A pump confined to one block breaks either equality of the first two block lengths or the last≤first inequality (choose pumping direction accordingly).
3. A pump crossing one boundary cannot touch all three blocks; preserving the first two lengths while pumping down makes the third too long, while other changes break equality or block order. L3 is{0k1k0k:k≥0}, also non-context-free by the usual three-block pumping argument.
4. Hence L2 and L3, D.
5. Teaching check: For L₂ the two equal leading block lengths and the upper bound on the final block are linked. A pumping window of length p cannot span all three p-length blocks in 0p1p0p. Even if it changes the first two blocks equally, pumping down leaves the untouched third block too long.
A bank account initially has balance 12000. A transaction transfers 2000 to mortgage M, then another applies 5% interest. Log records are: 1 T1 start 2 T1 B old=1200 new=10000 3 T1 M old=0 new=2000 4 T1 commit 5 T2 start 6 T2 B old=10000 new=10500 7 T2 commit The old value 1200 in record 2 is printed despite the narrative's 12000. The system crashes just before record 7 is written. Which recovery assertion is true? Options: (A) Redo record 6, setting B=10500 (B) Undo record 6 to B=10000, then redo records 2 and 3 (C) Records 2 and 3 need not be redone because T1 committed (D) Redo and undo can be performed in arbitrary order because they are idempotent
Your answer
Answer & solution
Answer: B under undo-redo logging (no official key was published)
1. T1 has a commit record, whereas T2 does not. Undo T2’s balance change to 10000 and ensure T1’s balance/mortgage changes 10000 and 2000 are redone, B.
2. Commit does not necessarily force all modified pages to disk in undo-redo logging; idempotence does not allow arbitrary ordering of conflicting log actions. The printed old balance in record 2 is 1200 although the narrative says 12000.
3. That inconsistency does not change the committed new balance or this recovery conclusion, but it is not silently corrected.
4. Teaching check: Recovery distinguishes a transaction whose commit record reached the log from one whose commit record never did. Redo protects committed effects that may not yet be on disk; undo removes effects from incomplete transactions that may already have reached disk. A commit record is therefore not proof that every data page was forced.
Independently toss a fair coin for each of 2n elements and select the element on heads. What is the probability that exactly n elements are selected? Options: (A) C(2n,n)/4^n (B) C(2n,n)/2^n (C) 1/C(2n,n) (D) 1/2
Your answer
Answer & solution
Answer: A (no official key was published)
1. Each subset of the 2n elements has probability 2-2n. There are binomial(2n,n) subsets with exactly n elements, so the desired probability is binomial(2n,n)/4n, A.
2. Teaching check: Every particular size-n subset corresponds to one pattern of n heads and n tails, with probability (1/2)2n. The number of such patterns is C(2n,n). Multiplying count by per-pattern probability gives the result; the expected subset size n does not imply probability 1/2 of exactly that size.
For finite sets E,F,G, put X=(E∩F)−(F∩G) and Y=(E−(E∩G))−(E−F). Which relation holds? Strict containment is intended in A and B. Options: (A) X⊂Y (B) X⊃Y (C) X=Y (D) Both X−Y and Y−X are nonempty
Your answer
Answer & solution
Answer: C (no official key was published)
1. X=(E∩F)∖(F∩G)=E∩F∩Gᶜ. Also E∖(E∩G)=E∩Gᶜ; subtracting E∖F then retains exactly its elements in F.
2. Thus Y=E∩F∩Gᶜ=X, C. The strict-containment alternatives do not apply.
3. Teaching check: An element belongs to X precisely when it is in E and F but not G. For Y, first discard from E everything in G, then discard everything outside F. Both constructions retain the same three simultaneous membership conditions.
F is an n×n real matrix, b an n×1 real vector. Distinct vectors u,v satisfy Fu=b and Fv=b. Which is not necessarily true? Options: (A) det(F)=0 (B) Fx=b has infinitely many solutions (C) A nonzero x satisfies Fx=0 (D) F must have two identical rows
Your answer
Answer & solution
Answer: D (no official key was published)
1. Since u≠v and Fu=Fv, the nonzero vector u−v lies in the null space. Hence F is singular and det F=0.
2. Every u+t(v−u), t real, is another solution, yielding infinitely many. Singularity does not force identical rows: F=[[1,2],[2,4]] is a counterexample.
3. Therefore D is false as a necessary assertion.
4. Teaching check: Subtract the two equations to obtain F(u−v)=0, with u−v nonzero. Linearity then lets any scalar multiple of this null vector be added to one solution. Dependent rows need not be identical rows, so determinant zero does not establish option D.
Let N={1,…,n} and A,B⊆N. How many permutations π of N satisfy min(π(A))=min(π(B)), where π(S)={π(s):s∈S}? The minimum requires nonempty A and B, although the reproduction says arbitrary subsets. Options: (A) (n−|A∪B|)|A||B| (B) (|A|²+|B|²)n² (C) n!·|A∩B|/|A∪B| (D) |A∩B|²/C(n,|A∪B|)
Your answer
Answer & solution
Answer: C for nonempty A and B (no official key was published)
1. The minima of π(A) and π(B) agree exactly when the smallest image among A∪B belongs to A∩B. By symmetry every member of A∪B is equally likely to have that image, so the fraction is |A∩B|/|A∪B|.
2. Multiply by n! to get C. The statement allows arbitrary subsets, but min of an empty set is undefined; nonempty A,B are required for this calculation.
3. If they are disjoint and nonempty the answer is 0.
4. Teaching check: Only the relative order of images of A∪B matters. If its earliest image comes from an element outside the intersection, one subset has a strictly earlier minimum than the other. Uniform permutations make each union element equally likely to be earliest, giving the intersection-to-union ratio.
Let S={1,…,m}, m>3. Let X₁,…,Xₙ be subsets of S, each containing exactly three elements. Define f(i)=|{j:i∈Xⱼ}|. Evaluate Σᵢ₌₁ᵐ f(i). Options: (A) 3m (B) 3n (C) 2m+1 (D) 2n+1
Your answer
Answer & solution
Answer: B (no official key was published)
1. Sum f(i) over all elements i. Each of the n three-element subsets contributes exactly 3 incidences, so the total is 3n, B.
2. This remains true if some of the listed subsets coincide.
3. Teaching check: Count the same incidence pairs (i,j) with i∈Xⱼ in two ways. Counting by elements gives Σf(i); counting by subsets gives three incidences per Xⱼ. The parameter m controls the universe, but the total depends on n, the number of triples.
Which first-order formula expresses “Tigers and lions attack if they are hungry or threatened”? Abbreviate tiger(x), lion(x), hungry(x), threatened(x), attacks(x) as T,L,H,R,A; all formulas are universally quantified over x. Options: (A) (T∧L)→((H∨R)→A) (B) (T∨L)→((H∨R)∧A) (C) (T∨L)→(A→(H∨R)) (D) (T∨L)→((H∨R)→A)
Your answer
Answer & solution
Answer: D (no official key was published)
1. The statement applies to an animal that is either a tiger or a lion, and hunger or threat is sufficient for attacking. Its form is ∀x[(tiger(x)∨lion(x))→((hungry(x)∨threatened(x))→attacks(x))], D.
2. It neither requires both species simultaneously nor reverses the sufficient-condition implication.
3. Teaching check: “Tigers and lions” names the union of two categories, not animals belonging to both species. The word “if” makes hunger or threat a sufficient condition for attack, not a necessary one. Both logical distinctions are needed to choose D.
Consider equivalences P1: ((A∧B)→C)≡((A→C)∧(B→C)); P2: ((A∨B)→C)≡((A→C)∨(B→C)). Which are tautologies? Options: (A) P1 only (B) P2 only (C) Both (D) Neither
Your answer
Answer & solution
Answer: D (no official key was published)
1. Take A=true,B=false,C=false. In P1, (A∧B)→C is true, while(A→C)∧(B→C) is false.
2. In P2, (A∨B)→C is false, while(A→C)∨(B→C) is true. Thus neither equivalence is a tautology, D.
3. Teaching check: For A=true,B=false,C=false, P1 has true on its left and false on its right. P2 has false on its left and true on its right. One counterexample per formula is enough to refute tautology; neither formula needs to be false on every assignment.
Expressing conjunction using a truth-table operator
Propositional & Predicate Logic
Tap to enlarge
Define A⊙B by truth table (A,B,result): (T,T,T),(T,F,T),(F,T,F),(F,F,T). Negation has higher precedence than ⊙. Which expression equals A∧B? Options: (A) (¬A)⊙B (B) ¬(A⊙(¬B)) (C) ¬((¬A)⊙(¬B)) (D) ¬((¬A)⊙B)
Your answer
Answer & solution
Answer: D (no official key was published)
1. The table gives A⊙B=A∨¬B. Therefore ¬(¬A⊙B)=¬(¬A∨¬B)=A∧B, option D.
2. The negation applies to the whole inner expression.
3. Teaching check: The only false table row is A=false,B=true, exactly the falsifying row of B→A. Hence ⊙ implements A∨¬B. Replacing A by ¬A and negating the whole result yields De Morgan’s formula ¬(¬A∨¬B)=A∧B.
For binary string s, let n₀(s),n₁(s) count zeros and ones. Which language is not regular? Options: (A) {s:n₀(s) is a three-digit prime} (B) {s:for every prefix t of s, |n₀(t)−n₁(t)|≤2} (C) {s:|n₀(s)−n₁(s)|≤4} (D) {s:n₀(s) mod 7=0 and n₁(s) mod 5=0}
Your answer
Answer & solution
Answer: C (no official key was published)
1. A is regular because the permitted zero counts are finitely many three-digit primes; count zeros up to the maximum with an overflow state. B tracks prefix imbalance in{−2,−1,0,1,2}, rejecting immediately outside that range.
2. D tracks zero count modulo 7 and one count modulo 5. C only bounds the final imbalance and allows arbitrarily large intermediate imbalance.
3. Intersect C with 0*1* and pump 0p1p: pumping a nonempty block of initial zeros sufficiently many times makes the final difference exceed 4. Hence C is not regular.
4. Teaching check: A bound on every prefix permits a finite-state machine to reject immediately when its imbalance leaves a fixed range. A bound only on the final string allows arbitrarily large positive imbalance followed by enough ones to cancel it. Tracking this unbounded debt cannot be done with finitely many states.
For a binary string s let d(s) be its numerical value, for example d(101)=5. Classify L={s:d(s) mod 5=2 and d(s) mod 7≠4}. Options: (A) Recursively enumerable but not recursive (B) Recursive but not context-free (C) Context-free but not regular (D) Regular
Your answer
Answer & solution
Answer: D (no official key was published)
1. A finite automaton stores the current binary value modulo 35. Reading bit b replaces residue r by(2r+b) mod35.
2. Accept precisely residues r with r mod5=2 and r mod7≠4. This recognizes the language, so it is regular, D; leading zeros do not affect the construction.
3. Teaching check: The joint modulus 35 suffices because both congruence tests depend only on the value modulo 35. Starting at residue zero, scan bits left to right and update r←(2r+b) mod 35. A 35-state DFA with appropriate accepting residues is a constructive regularity proof.
Hamiltonian cycles on a multiple of three vertices
Complexity & Reductions
Tap to enlarge
Restrict undirected graphs G=(V,E) to |V| divisible by 3. SHAM₃ is the problem of finding a Hamiltonian cycle; DHAM₃ asks whether one exists. Which statement is true? Options: (A) Both DHAM₃ and SHAM₃ are NP-hard (B) SHAM₃ is NP-hard but DHAM₃ is not (C) DHAM₃ is NP-hard but SHAM₃ is not (D) Neither is NP-hard
Your answer
Answer & solution
Answer: A (no official key was published)
1. The vertex-count restriction does not remove NP-hardness. Reduce an undirected Hamiltonian-cycle instance by replacing each original vertex with a three-vertex path.
2. For each original edge uv, connect each endpoint of u’s path to each endpoint of v’s path. The middle vertices have degree 2, so any Hamiltonian cycle must traverse each replacement path; contracting the paths recovers a Hamiltonian cycle of the original graph.
3. Conversely any original cycle expands through all paths. The new graph has 3|V| vertices.
4. Therefore decision DHAM3 is NP-hard; a polynomial search algorithm that returns a cycle or reports none would decide it, so SHAM3 is NP-hard as well, A.
5. Teaching check: The middle vertex in each three-vertex replacement path has degree two, forcing both its incident edges into any Hamiltonian cycle. Hence the whole path acts as one original vertex when contracted. This gives an explicit polynomial reduction rather than assuming a divisibility restriction preserves hardness.
Grammar G has productions S→SS | ab | ba | ε. Consider I: G is ambiguous; II: G generates every string with equal counts of a and b; III: the language of G can be accepted by a deterministic PDA. Which statements are true? Options: (A) I only (B) I and III only (C) II and III only (D) I, II and III
Your answer
Answer & solution
Answer: B (no official key was published)
1. The grammar generates exactly(ab+ba)*: SS concatenates its two-letter blocks and ε contributes nothing. It is ambiguous, for example ab has both S→ab and S→SS→abS→ab, with different parse trees.
2. It does not generate aabb, although that string has equal a/b counts. The generated language is regular and therefore accepted by a deterministic PDA (even a DFA).
3. Statements1 and 3 hold, B; the PDA accepts the language, not the grammar object.
4. Teaching check: Equal counts are necessary for this grammar but not sufficient: concatenating ab and ba blocks cannot produce aabb. The ε production together with S→SS also allows redundant decompositions, so even a very short generated word has multiple parse trees.
L₁ is regular, L₂ is deterministic context-free, and L₃ is recursively enumerable but not recursive. Which universal closure assertion is false? Options: (A) L₁∩L₂ is deterministic context-free (B) L₃∩L₁ is recursive (C) L₁∪L₂ is context-free (D) L₁∩L₂∩L₃ is recursively enumerable
Your answer
Answer & solution
Answer: B as a non-guaranteed assertion (no official key was published)
1. Regular∩deterministic-CFL is deterministic context-free; regular∪CFL is context-free. Intersecting the two decidable languages with a recursively enumerable language remains recursively enumerable.
2. But L3∩L1 need not be recursive: take L1=Σ*, giving L3 itself. Thus B is the false universal closure assertion.
3. It can nevertheless be recursive for some choices, such as L1=∅; it is not false for every instance.
4. Teaching check: To refute a universal closure claim, choose an extreme regular language. Taking L₁=Σ* preserves all of L₃ under intersection, so undecidability remains. Taking L₁=∅ illustrates why the false assertion is “always recursive,” not “never recursive.”
Over the unary alphabet {1}, what is the smallest number of states in a DFA for (111+11111)*, where + denotes union? Options: (A) 3 (B) 5 (C) 8 (D) 9
Your answer
Answer & solution
Answer: D over the unary alphabet (no official key was published)
Step through it (2 parts)
1. The possible lengths are 3a+5b, a,b≥0:0,3,5,6 and all integers≥8. The missing nonnegative lengths are 1,2,4,7.
2. A unary DFA counts lengths 0 through 7, then enters an accepting sink at 8, using 9 states. For any 0≤i<j≤8, append 7−i symbols: the first length becomes 7 and is rejected, while the second exceeds 7 and is accepted.
3. Thus all nine states are distinguishable and D is minimal. This treats the stated expression as a language over{1}; a larger alphabet would require a rejecting sink for other symbols.
4. Teaching check: Lengths 0,3,5,6 and all lengths at least eight are accepted; 1,2,4,7 are rejected. Build states recording exact lengths below eight, followed by one accepting sink. Distinguishability proves this nine-state construction minimal, rather than merely establishing an upper bound.
Two 2:1 multiplexers are cascaded. The first has input 0=x, input 1=¬y and select=z. Its output drives input 0 of the second; second input 1=x and select=y. A select value of 0 chooses input 0. Which expression represents output f(x,y,z)? Here + means OR and juxtaposition AND. Options: (A) x¬z+xy+¬yz (B) x¬z+xy+¬(yz) (C) xz+xy+¬(yz) (D) xz+x¬y+¬yz
Your answer
Answer & solution
Answer: A (no official key was published)
1. The first mux outputs x¬z+¬yz. The second selects that output when y=0 and x when y=1, giving f=¬y(x¬z+¬yz)+xy=x¬y¬z+¬yz+xy.
2. By absorption/consensus this equals x¬z+xy+¬yz, option A. The first mux’s lower input is complemented y, not y.
3. Teaching check: For a 2:1 mux use output=¬select·input 0+select·input 1. Apply this formula first to z, then to y. Keeping the complemented lower input of the first mux is essential; overlooking that inversion changes the truth table.
Two three-bit unsigned words a₂a₁a₀ and b₂b₁b₀ are added with carry-in c. Which Boolean expression is the block carry-generate function (outgoing carry generated independently of c)? Here + means OR, juxtaposition AND, and ⊕ XOR. The expanded alternatives below follow the clearer GateForum typesetting. Options: (A) a₂b₂+a₂a₁b₁+a₂a₁a₀b₀+a₂a₀b₁b₀+a₁b₂b₁+a₁a₀b₂b₀+a₀b₂b₁b₀ (B) a₂b₂+a₂b₁b₀+a₂a₁b₁b₀+a₁a₀b₂b₁+a₁a₀b₂+a₁a₀b₂b₀+a₂a₀b₁b₀ (C) a₂+b₂+(a₂⊕b₂)(a₁+b₁+(a₁⊕b₁)(a₀+b₀)) (D) a₂b₂+¬a₂a₁b₁+¬(a₂a₁)a₀b₀+¬a₂a₀¬b₁b₀+a₁¬b₂b₁+¬a₁a₀¬b₂b₀+a₀¬(b₂b₁)b₀
Your answer
Answer & solution
Answer: A (no official key was published)
1. Let gi=ai bi and pi=ai+bi. The carry generated independently of c0 is G=g2+p2g1+p2p1g0.
2. Expanding gives a2b2+a2a1b1+b2a1b1+a2a1a0b0+a2b1a0b0+b2a1a0b0+b2b1a0b0, the seven terms of A. This tests whether the three-bit sum generates an outgoing carry when c0=0, not whether an incoming carry propagates.
3. Teaching check: At one bit, carry-out is gᵢ+pᵢ·carry-in, where gᵢ=aᵢbᵢ and the OR-based propagation pᵢ=aᵢ+bᵢ is sufficient. Substitute this recurrence across bits 0,1,2 and collect the terms independent of the external carry. Those terms form the block generate function.
Three D flip-flops q₂,q₁,q₀ start at 000 and share a clock. Wiring: D₂=q₁, D₁=q₀⊕q₂, D₀=data. Feed the bits 100110000, left to right, one per clock. What is the final q₂q₁q₀? Options: (A) 000 (B) 001 (C) 010 (D) 101
Your answer
Answer & solution
Answer: C (no official key was published)
1. On each clock, update simultaneously(q2,q1,q0)←(q1,q0⊕q2,data). Starting000 and feeding 100110000 left to right gives 001,010,100,011,111,100,010,100,010.
2. The final state is 010, C. All right-hand-side register values are from before the clock edge.
3. Teaching check: Simultaneous updates mean q₂ receives the old q₁, not a value just calculated in the same cycle. Keep two state triples, old and new, when tracing. The supplied nine-bit string includes four trailing zero inputs; those clocks still shift and feed back state.
For f(w,x,y,z)=Σm(5,7,11,12,13,15), only one input changes at a time. A transition between adjacent ON minterms must never cause a momentary zero. Which cube cover avoids such static-1 hazards? The options below explicitly use GateForum p11; its D begins wzy, while the corresponding GFG term is too blurred to establish. This question therefore retains a source discrepancy rather than silently repairing an option. Options: (A) {¬wxz, wx¬y, x¬yz, xyz, wyz} (B) {wxy, ¬wxz, wyz} (C) {wx·overline(yz), xz, w¬xyz}; the printed bar spans yz, retaining the source bar-scope ambiguity (D) {wzy, wyz, wxz, ¬wxz, x¬yz, xyz}
Your answer
Answer & solution
Answer: Proven cover given; option letter unresolved (no official key was published)
1. For a two-level AND-OR cover to avoid static-1 hazards on single-input changes, every adjacent pair of ON minterms must share a cube. The adjacent pairs are(5,7),(5,13),(7,15),(11,15),(12,13),(13,15).
2. The cover{xz,wyz,wx¬y} covers all six and exactly the ON set. Equivalently, the six edge cubes are{¬wxz,x¬yz,xyz,wyz,wx¬y,wxz}.
3. Option A lacks a cube spanning 13↔15; option C leaves 12↔13 unbridged if its first term is read as wx¬y¬z.
4. Neither reading makes C valid.
5. Thus a corrected D containing wx¬y would work, but the paper warrants silently claiming that printed D is correct. Original wording/key are needed to resolve the letter.
6. Teaching check: Ordinary truth-table equivalence does not by itself guarantee hazard freedom. For every adjacent ON pair, one product term must remain asserted throughout the changing input. The independently derived valid cover {xz,wyz,wx¬y} can be verified by checking both its ON set and its coverage of all six ON edges.
An ordinary binary adder adds two n-bit two’s-complement numbers aₙ₋₁…a₀ and bₙ₋₁…b₀. Its result bits are cₙ₋₁…c₀ and carry-out is c_out. Which expression detects signed overflow? Let a=aₙ₋₁,b=bₙ₋₁,c=cₙ₋₁. Both reproductions print a continuous bar over ab in the second term of B; its scope must not be silently normalized. Options: (A) c_out·¬(a⊕b) (B) ab¬c+overline(ab)c [continuous source bar; intended separate-literal reading: ab¬c+¬a¬bc] (C) c_out⊕c (D) a⊕b⊕c
Your answer
Answer & solution
Answer: B only under separate-literal complement reading; printed grouped bar is ambiguous (no official key was published)
1. Signed overflow occurs when both operand sign bits agree and the result sign differs: V=ab¬c+¬a¬bc. For example, two positive operands overflowing the positive range give a=b=0,c=1.
2. Read literally as a grouped complement, the printed expression is ab¬c+¬(ab)c, not the standard overflow expression.
3. A counterexample is four-bit −8+1=−7: a=1,b=0,c=1, with no signed overflow, but ¬(ab)c=1. Therefore printed B works only if its spanning bar is intended to mean separately complemented literals. That intended reading must be stated explicitly; the original official wording and key are unavailable.
4. The other expressions are not general overflow detectors. With four-bit −1+1=0, c_out=1,c=0 and C incorrectly signals overflow. D fails on −8+(−1), whose sign bits are a=b=1,c=0: D=0 although overflow occurs. A misses positive overflow 7+1 because c_out=0.
5. Teaching check: Compute overflow from operand and result signs, then check the scope of every complement. Carry-out is an unsigned carry indicator, not signed overflow. The retained B answer is conditional on the separate-literal reading, not a verified literal-source or official-key answer.
Let h₃h₂h₁h₀ be the four-bit reflected Gray code of n, and g₃g₂g₁g₀ the Gray code of (n+1) mod 16. Minterm indices refer to the current Gray word h. Which next-bit function is correct? GateForum A includes minterm 3; GFG appears to print 5 in that position. Options: (A) g₀=Σm(1,2,3,6,10,13,14,15) [GateForum; GFG: 1,2,5,6,10,13,14,15] (B) g₁=Σm(4,9,10,11,12,13,14,15) (C) g₂=Σm(2,4,5,6,7,12,13,15) (D) g₃=Σm(0,1,6,7,10,11,12,13)
Your answer
Answer & solution
Answer: C (no official key was published)
1. Use h(n)=n⊕(n>>1) and g=h((n+1) mod16). Enumerating n=0,...,15 gives the ON-set for g2, indexed by the present Gray word h, as{2,4,5,6,7,12,13,15}, exactly C.
2. As cross-checks, g0 has{0,1,6,7,10,11,12,13}, g1 has{1,2,3,6,10,13,14,15}, and g3 has{4,9,10,11,12,13,14,15}; the other options attach these sets to wrong output bits.
3. Teaching check: Gray-code minterm indices are the current Gray words, not the underlying binary n values. For example n=0 gives h=0000 and next g=0001, so the present-state index zero belongs to g₀’s ON set. This immediately distinguishes some mislabeled alternatives.
A cache block is 64 bytes. Main memory has k banks of width c bytes; consecutive c-byte chunks map cyclically onto consecutive banks. All banks can be read in parallel, but repeated accesses to one bank are serialized. Every parallel round takes k/2 ns of decoding plus 80 ns for the bank access. For c=2,k=24, how long does fetching the block starting at address 0 take? Options: (A) 92 ns (B) 104 ns (C) 172 ns (D) 184 ns
Your answer
Answer & solution
Answer: D (no official key was published)
1. Each parallel round transfers at most 24×2=48 bytes. A 64-byte block starting at zero needs 32 bank-width chunks and hence two rounds.
2. Each round costs 24/2+80=92 ns, including the stated decoding cost. Total latency is 184 ns (D).
3. Teaching check: The block contains 64/2=32 chunks. The first 24 can be read together, but the remaining eight return to banks already used and require a second round. The stated model charges decoding again for that round even though not all 24 banks supply another chunk.
A 1 GHz CPU has five pipeline stages; fetch is stage 1. Conditional branches compute their target and condition in stage 3. After fetching a branch, no further instruction is fetched until the outcome is known. A program has 10⁹ instructions, 20% conditional branches. With base CPI 1 before branch stalls, what approximate execution time results? Options: (A) 1.0 s (B) 1.2 s (C) 1.4 s (D) 1.6 s
Your answer
Answer & solution
Answer: C (no official key was published)
1. A branch fetched in stage 1 resolves at the end of stage 3, so two subsequent fetch slots are lost. The ideal CPI is 1 and branch frequency is 0.2, giving CPI=1+2(0.2)=1.4.
2. At 1 GHz, 109 instructions take approximately 1.4 seconds (C); constant pipeline fill/drain time is ignored as in the options. The statement that instructions take one cycle on average must mean the base CPI before these stalls.
3. Teaching check: The two idle fetch slots are the cycles while the branch passes stages 2 and 3. Since one fifth of instructions causes this penalty, average overhead is 0.4 cycles per instruction. The five-stage depth does not mean five cycles of throughput cost for every ordinary instruction.
The instruction bbs reg,pos,label branches if bit pos of a 32-bit register is 1; positions 0…31 start at the least-significant bit. Emulate it by temp←reg & mask, then branch if temp≠0. How should mask be computed? Options: (A) 0x1 << pos (B) 0xffffffff >> pos (C) pos (D) 0xf
Your answer
Answer & solution
Answer: A (no official key was published)
1. The mask must contain exactly one set bit at position pos: mask=0x1 << pos. AND with the register is nonzero exactly when that bit is set.
2. Thus A. These are register-level pseudocode shifts; a literal C implementation should use an unsigned 32-bit 1 to handle position 31 safely.
3. Teaching check: A one-hot mask isolates exactly the requested bit; an all-ones mask shifted right would generally retain several bits. If implemented in C rather than register pseudocode, use a suitably wide unsigned constant to avoid undefined signed left-shift behavior at the top bit.
A sends 32-byte packets to B with a sliding-window protocol. Round-trip delay is 80 ms and bottleneck bandwidth is 128 kbps. Which window size is optimal under the conventional bandwidth-delay-product model? Options: (A) 20 packets (B) 40 packets (C) 160 packets (D) 320 packets
Your answer
Answer & solution
Answer: B (no official key was published)
1. The bandwidth-delay product is 128000×0.080=10240 bits. A packet carries 32×8=256 bits, so 10240/256=40 packets fill the round-trip pipe (B).
2. This uses the problem's conventional bandwidth-delay-product interpretation of round-trip delay. If the given delay excludes serialization and ACK turnaround is measured from the last bit, a strict no-idle bound can require one additional packet; that convention is not represented in the options.
3. Teaching check: Convert bytes to bits and milliseconds to seconds consistently. The bandwidth-delay product measures the amount of data that must remain outstanding to keep the channel busy. Divide this bit count by packet size; do not use 32 directly as a bit count.
C1 has IP address 203.197.2.53 and mask 255.255.128.0. C2 has 203.197.75.201 and mask 255.255.192.0. What does each infer about the other’s network? Options: (A) Both consider the other local (B) C2 considers C1 local, but C1 considers C2 remote (C) C1 considers C2 local, but C2 considers C1 remote (D) Both consider the other remote
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (4 steps)
1. C1 uses /17, so both 203.197.2.53 and 203.197.75.201 map to 203.197.0.0. C2 uses /18, mapping itself to 203.197.64.0 and C1 to 203.197.0.0.
2. Therefore C1 treats C2 as local while C2 treats C1 as remote: C.
3. Teaching check: Each machine applies its own mask to both addresses. C1’s /17 groups third octets 0–127; C2’s /18 separates 0–63 from 64–127. Because the masks differ, being “on the same subnet” need not be a symmetric belief between these misconfigured hosts.
A sends nine immediately available packets to B using go-back-N and window size 3. Every fifth transmission attempt by A is lost, counting retransmissions; acknowledgments are never lost. Under the standard full-window go-back-N interpretation, how many packet transmissions complete delivery? Options: (A) 12 (B) 14 (C) 16 (D) 18
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (21 steps)
1. Number transmission attempts, including retransmissions. The transmitted packet labels are 1,2,3,4,5,6,7,5,6,7,8,9,7,8,9,9.
2. Attempts 5,10,15 are lost. After each loss the later in-window packets are discarded, and the sender retransmits from the missing packet.
3. All nine packets arrive in order after attempt 16 (C). This is the standard full-window, cumulative-ACK go-back-N model used by the question.
4. Teaching check: Lost attempts are numbered globally, not separately for each packet. After losing packet 5, later out-of-order packets are discarded by go-back-N even if physically received. Replaying packet labels while marking attempt numbers 5,10,15 avoids confusing packet identity with loss periodicity.
An undirected graph has vertices a,b,c,d,e,f and weighted edges ab:1, ac:6, bc:3, bd:4, bf:2, cd:2, ce:4, cf:7, de:3, df:1, ef:5. Which sequence cannot be the edges added, in order, by Kruskal’s minimum-spanning-tree algorithm? GFG A prints af, an edge absent from the graph; GateForum A instead prints df. Both readings are retained. Options: (A) ab, af, bf, dc, de [GFG]; ab, df, bf, dc, de [GateForum] (B) ab, df, dc, bf, de (C) df, ab, dc, bf, de (D) df, ab, bf, de, dc
Your answer
Answer & solution
Answer: A, D (no official key was published)
1. The graph has ab=df=1, bf=dc=2, and de=bc=3. Kruskal first adds ab and df in either order, then bf and dc in either order, then de.
2. B and C are legal. D adds de of weight 3 before dc of weight 2, although dc still joins distinct components, so D is impossible.
3. However, the paper prints (a-f) as the second edge of A; no such edge exists, making A impossible too. Replacing that entry with (d-f) would make A legal and yield the intended unique answer D.
4. This is a the paper-specific ambiguity, not an established defect in the original exam.
6. Teaching check: Kruskal processes available edges in nondecreasing weight and only skips an edge when its endpoints are already connected. Tie order can vary for equal weights, but it cannot justify selecting weight 3 while a useful weight-2 edge remains. The absent af edge is a separate transcription defect.
T is a depth-first-search tree of an undirected graph G. Distinct u and v are leaves of T and both have graph degree at least 2. Which statement must hold? Options: (A) Some vertex w is adjacent to both u and v (B) Some vertex w has removal disconnecting u from v (C) Some cycle contains both u and v (D) Some cycle contains u and every neighbor of u
Your answer
Answer & solution
Answer: D (no official key was published)
1. In an undirected DFS, every non-tree edge joins a vertex to an ancestor. Since u is a DFS leaf, all its neighbors lie on its single root-to-u tree path.
2. Let w be its highest ancestor-neighbor. The tree path w to u plus the edge uw forms a cycle containing every neighbor of u, since all those neighbors lie between w and u.
3. Degree at least two ensures a genuine cycle. Thus D.
4. Two distinct cycles sharing only a root refute the asserted common cycle; other DFS graphs refute the universal common neighbor and separator assertions.
5. Teaching check: DFS in an undirected graph has no cross edge joining separate finished subtrees. A leaf’s non-parent neighbors must therefore be ancestors. The path from its highest such neighbor to the leaf contains every other neighbor along that ancestor chain, and the closing back edge creates the required cycle.
An initially empty queue is implemented using stacks S1,S2: insert(Q,x): push(S1,x). delete(Q): if S2 is empty, then if S1 is empty report empty and return; otherwise repeatedly pop S1 and push that item onto S2 until S1 is empty. Finally pop S2. Perform n inserts and m≤n delete calls in arbitrary order. Let x be the total pushes and y the total pops on both stacks. Which printed bound holds for every n,m? Both reproductions use the strict upper bound x<2n; successful deletions are not explicitly guaranteed. Options: (A) n+m≤x<2n and 2m≤y≤n+m (B) n+m≤x<2n and 2m≤y≤2n (C) 2m≤x<2n and 2m≤y≤n+m (D) 2m≤x<2n and 2m≤y≤2n
Your answer
Answer & solution
Answer: No universally correct printed option (no official key was published)
1. Let t be the number of items moved from S1 to S2 and d the number of successful deletes. Then x=n+t pushes and y=t+d pops, with d≤t≤n.
2. If all m deletes succeed, d=m, so n+m≤x≤2n and 2m≤y≤n+m. These are the tight intended bounds.
3. The paper prints x<2n in all four options, which fails when all n inserts precede a delete: t=n and x=2n. Furthermore arbitrary ordering permits deletes on an empty queue; then d need not equal m and the printed lower bounds can fail.
4. If < were repaired to ≤ and successful deletions assumed, A states the tight bounds, but other looser options would also be true. Do not treat this the paper as a sound unique-answer MCQ without checking a better source.
6. A minimal counterexample is one insert followed by one delete: n=m=1 and x=y=2. This does not establish what the official original printed.
7. Teaching check: Every inserted item is pushed onto S1 exactly once and transferred to S2 at most once. A successful deletion adds one S2 pop. Counting these lifecycle events gives exact formulas before bounds are imposed; testing n=m=1 immediately exposes the printed strict inequality.
Represent X,Y⊆{0,…,n−1} with Boolean membership arrays x,y. For each i set z[i]=(x[i]∧¬y[i])∨(¬x[i]∧y[i]). Which set does z represent? Options: (A) X∪Y (B) X∩Y (C) (X−Y)∩(Y−X) (D) (X−Y)∪(Y−X)
Your answer
Answer & solution
Answer: D (no official key was published)
1. The assignment is z[i]=(x[i] AND NOT y[i]) OR (NOT x[i] AND y[i]). It is true exactly when i belongs to one of X and Y but not both.
2. Hence Z=(X−Y)∪(Y−X), option D.
3. Teaching check: The two terms are disjoint: one means membership in X only, the other membership in Y only. If both input bits are zero or both are one, z is zero. This is Boolean exclusive-or and set symmetric difference, not ordinary union.
For integers n>1, T(n)=2T(⌊√n⌋)+1 and T(1)=1. What is the asymptotic growth? Options: (A) Θ(log log n) (B) Θ(log n) (C) Θ(√n) (D) Θ(n)
Your answer
Answer & solution
Answer: B (no official key was published)
1. After h repeated floor-square-root steps, the subproblem size is floor(n1/2^h). For n≥2 it first reaches 1 when n<22^h, so h=floor(log₂(log₂ n))+1.
2. The recurrence tree is a full binary tree of height h. Every node contributes one, including the T(1)=1 leaves, so T(n)=2h+1−1. Because log₂ n<2h≤2 log₂ n, this is Θ(log n), option B.
3. Teaching check: The depth is Θ(log log n), but exponentiating that Θ statement alone would not justify Θ(log n). The sharper h=log₂(log₂ n)+O(1) bound controls the number of leaves within constant factors. Floor rounding is included explicitly and ensures termination at the stated base case.
The median of n elements can be selected in O(n) time. What is quicksort’s complexity if the median is always chosen as pivot, with balanced partitioning? Options: (A) Θ(n) (B) Θ(n log n) (C) Θ(n²) (D) Θ(n³)
Your answer
Answer & solution
Answer: B (no official key was published)
1. Select the median in Θ(n) time and partition in Θ(n) time, producing two subproblems of approximately n/2 elements. The recurrence T(n)=2T(n/2)+Θ(n) gives Θ(n log n), option B, including the median-selection cost.
2. This assumes standard balanced handling of duplicate keys or distinct keys; a two-way partition that mishandles equal keys can defeat that guarantee.
3. Teaching check: Finding the median is not free, but its linear cost can be absorbed into the same Θ(n) term as partitioning. Each recursion level processes a total of Θ(n) elements, and balanced halves give Θ(log n) levels. Thus median selection does not make quicksort linear overall.
Sorted integer arrays a[0…n−1],b[0…m−1] have positive lengths. Array c has capacity n+m. Execute: i=j=k=0; while (i<n && j<m) { if (a[i]<b[j]) c[k++]=a[i++]; else c[k++]=b[j++]; } Which printed postcondition is valid? I: if i=n, then j<m, k=n+j−1, and a[n−1]<b[j]. II: if j=m, then i<n, k=m+i−1, and b[m−1]≤a[i]. The −1 terms are retained exactly as reproduced in both sources. Options: (A) Only I (B) Only II (C) Either I or II, but not both (D) Neither I nor II
Your answer
Answer & solution
Answer: D (no official key was published)
1. The loop starts i=j=k=0. Each iteration increments exactly one of i,j and also k, preserving k=i+j.
2. At termination, if i=n then j<m and k=n+j; the final extraction from a implies a[n−1]<b[j]. If j=m then i<n and k=m+i; the final extraction from b implies b[m−1]≤a[i].
3. Both printed assertions instead give k one less than these values. Hence neither assertion is correct: D.
4. This uses positive array lengths and defined array accesses, as intended by the example.
6. Teaching check: Initially k=i+j=0. Every loop iteration increments k and exactly one of i,j, so k=i+j remains true. At exit, replacing i by n or j by m yields k=n+j or k=m+i, directly contradicting the printed −1 regardless of the final comparison.
Given two length-n binary arrays a,b, find the longest interval [i,j] on which Σₖ₌ᵢʲaₖ=Σₖ₌ᵢʲbₖ, or report none. Which complexity describes the fastest method? Options: (A) O(3^n) and Ω(2^n) time if hashing is allowed (B) O(n³) and Ω(n^2.5) time in the key-comparison model (C) Θ(n) time and space (D) O(√n) time only if the sum of all 2n entries is even
Your answer
Answer & solution
Answer: C (no official key was published)
1. Set prefix differences D[0]=0 and D[k]=sum(a[1..k])−sum(b[1..k]). A span (i,j) has equal sums iff D[i−1]=D[j].
2. Every D[k] lies in [−n,n], so an array of 2n+1 entries can store the earliest index of each difference. Scan once and maximize the distance to its first occurrence.
3. Time and space are Θ(n), option C; hashing is unnecessary. Reading the inputs already takes Ω(n) time.
4. Teaching check: Store the earliest occurrence of each prefix difference because that maximizes the length to a later equal difference. A binary-array prefix difference stays between −n and n, so direct indexing gives worst-case linear performance rather than relying on average-case hash-table behavior.
Consider C functions: int work 1(int *a,int i,int j) { int x=a[i+2]; a[j]=x+1; return a[i+2]-3; } int work 2(int *a,int i,int j) { int t1=i+2; int t2=a[t1]; a[j]=t2+1; return t2-3; } S1: work 2 always gives the same output and effect on state as work 1. S2: the transformations always reduce CPU time. Which truth values apply? Options: (A) S1 false, S2 false (B) S1 false, S2 true (C) S1 true, S2 false (D) S1 true, S2 true
Your answer
Answer & solution
Answer: A (no official key was published)
1. work 1 reads a[i+2], writes a[j], then reads a[i+2] again in its return expression. work 2 saves the first value and reuses it after the store. If j=i+2, the store changes the location that work 1 rereads, so the functions need not return the same value; S1 is false.
2. Compiler transformations also do not universally improve runtime on every target/input, and this transformation is not even semantics-preserving without a non-alias condition. S2 is false.
3. Thus A.
4. For i=0, j=2, initial a[2]=5, work 1 returns 3 whereas work 2 returns 2.
5. Teaching check: Take i=0,j=2,a[2]=5. Both functions store 6 into a[2], but work 1 then rereads 6 and returns 3, while work 2 reuses saved 5 and returns 2. Reusing a load across a potentially aliasing store is not a valid unconditional common-subexpression transformation.
A pedagogical pass-by-reference language executes: subroutine swap(ix,iy) it=ix L1: ix=iy L2: iy=it end ia=3; ib=8; call swap(ia,ib+5); print ia,ib. Statements: S1 an unnamed temporary initialized to 13 is allocated and its address passed for the second argument; S2 runtime error at L1; S3 runtime error at L2; S4 prints 13,8; S5 prints 13,−2. Which stated set is correct under the expression-to-temporary model? Options: (A) S1 and S2 (B) S1 and S4 (C) S3 (D) S1 and S5
Your answer
Answer & solution
Answer: B (no official key was published)
1. Initially ia=3 and ib=8; the expression ib+5 evaluates to 13. Under the stated expression-to-temporary reference model, the compiler passes the address of a temporary containing 13, not the address of ib. swap sets ia to 13 and the temporary to 3; ib remains 8.
2. S1 and S4 hold, so B. This is the pedagogical model specified by the options, not a guarantee that every actual FORTRAN standard/compiler permits defining an expression-associated dummy argument.
3. Teaching check: The expression ib+5 has a value but is not the storage cell ib. Passing a temporary permits swap to overwrite the argument without overwriting ib. Trace the two addressed cells separately: ia changes 3→13, temporary changes 13→3, and ib stays 8.
C code: void swap(int *px,int *py) { *px=*px-*py; *py=*px+*py; *px=*py-*px; } Statements: S1 compilation error; S2 may cause a segmentation fault for some arguments; S3 correctly swaps for all pointers to accessible integers; S4 correctly swaps for some but not all valid input pointers; S5 may add/subtract integers and pointers. Which statements are intended to be true? Options: (A) S1 (B) S2 and S3 (C) S2 and S4 (D) S2 and S5
Your answer
Answer & solution
Answer: C (no official key was published)
1. The code uses *px=*px−*py; *py=*px+*py; *px=*py−*px. For distinct valid integer objects and arithmetic without signed overflow, initial values x,y become x−y,y then x−y,x then y,x, correctly swapping.
2. If px=py, the first assignment zeroes the shared object and the result is not a swap unless it was zero. Invalid pointers may cause a segmentation fault.
3. Thus S2 and S4 are the intended statements: C. No pointer arithmetic occurs, and there is no intrinsic compilation error.
4. Signed overflow is an additional undefined-behavior limitation even with distinct accessible objects.
5. Teaching check: Aliasing is decisive: if px and py point to the same nonzero integer, the first subtraction writes zero and destroys the original value. With distinct valid cells the algebraic swap works only when each intermediate signed operation is representable. Dereferencing an invalid pointer is a further separate risk.
For grammar S→FR, R→*S|ε, F→id, what are predictive-table entries M[S,id] and M[R,$], respectively? Options: (A) {S→FR}, {R→ε} (B) {S→FR}, empty (C) {S→FR}, {R→*S} (D) {F→id}, {R→ε}
Your answer
Answer & solution
Answer: A (no official key was published)
Step through it (2 parts)
1. For S→FR, R→*S|ε, F→id, FIRST(FR)={id}; hence M[S,id]={S→FR}. Since S is the start symbol and R occurs at the end of S→FR, $ belongs to FOLLOW(R).
2. Therefore M[R,$]={R→ε}. Option A.
3. Teaching check: An LL(1) table uses FIRST of a nonempty production; ε productions use FOLLOW of their left-hand side. Since id begins FR, the S/id cell receives S→FR. Since R can end the start-symbol derivation, end marker $ belongs to FOLLOW(R).
A syntax-directed translation has productions: S→ER R→*E {print('*')} R | ε E→F+E {print('+')} | F F→(S) | id {print(id.value)} Here id denotes an integer. What is printed on input 2*3+4? Options: (A) 2*3+4 (B) 2*+34 (C) 23*4+ (D) 234+*
Your answer
Answer & solution
Answer: D (no official key was published)
1. S→ER and R→*E{print(*)}R|ε put multiplication below the expression E; E→F+E{print(+)}|F groups the addition on the right. For 2*3+4, first print 2, then parse E for 3+4, printing 3,4,+, then print * when that E finishes.
2. The output is 234+*, option D. Applying ordinary arithmetic precedence would incorrectly give 23*4+.
3. Teaching check: Semantic print actions fire at their positions in the grammar, not according to the usual arithmetic-precedence rules. The E nonterminal consumes the whole 3+4 before R’s multiplication-print action runs. The result is therefore postfix for 2*(3+4).
Consider C code (with defined arithmetic and x,y live after the fragment): for (i=0;i<n;i++) { for (j=0;j<n;j++) { if (i%2) { x+=(4*j+5*i); y+=(7+4*j); } } } Which optimization claim is not supported by this fragment? Options: (A) It contains loop-invariant computation (B) Common-subexpression elimination is possible (C) Strength reduction is possible (D) Dead-code elimination is possible
Your answer
Answer & solution
Answer: D (no official key was published)
1. Within the inner j loop, i%2 and 5*i are invariant. The expression 4*j occurs in both updates and can be shared.
2. The products by loop indices can use strength reduction through induction-variable increments. However x and y are updated and may be used later; nothing in the snippet establishes that those results are dead.
3. Therefore the claim of available dead-code elimination is unsupported and is the intended false statement, D. This uses the ordinary compiler-question assumption that program behavior is defined and x,y remain live afterward.
4. Teaching check: An expression can be expensive and still necessary. Dead-code elimination requires showing that its computed value never affects observable behavior, which is not established for x or y. In contrast, the repeated arithmetic patterns are visible directly within the loops.
Atomic fetch-and-set(x,y) sets shared location x to 1 and returns its old value in y, without an intervening access. Binary semaphore code is: P(S): do { fetch-and-set(S.value,y); } while(y); V(S): S.value=0; Which statement is true? Options: (A) P may fail to work if context switching is disabled inside it (B) A normal load/store pair can replace atomic fetch-and-set (C) V is incorrectly implemented (D) The code does not implement a binary semaphore
Your answer
Answer & solution
Answer: A (no official key was published)
1. P repeatedly atomically exchanges S.value with 1 and succeeds only when the previous value was 0. V releases it by storing 0.
2. On a uniprocessor, a process spinning in P with context switching disabled can prevent the lock owner from running V, so progress can fail. Separate load/store instructions are not atomic and allow two contenders to enter.
3. Thus A is true. This is a busy-wait semaphore using 0 for available and 1 for held; assume the intended atomic shared-memory model.
4. Teaching check: Atomicity prevents two contenders from both observing an available semaphore and entering. It does not guarantee progress if the spinning contender prevents the holder from being scheduled. Thus mutual-exclusion correctness and scheduling/liveness assumptions must be considered separately.
A CPU has 32-bit virtual addresses, 4 KB pages, and a 128-entry TLB that is four-way set associative. What is the minimum tag width, excluding any address-space identifier? Options: (A) 11 bits (B) 13 bits (C) 15 bits (D) 20 bits
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (6 steps)
1. A 4 KB page requires 12 offset bits, leaving 32−12=20 virtual-page-number bits. There are 128/4=32 TLB sets, requiring 5 index bits.
2. The minimum tag is the remaining 20−5=15 bits, option C. Additional address-space identifiers are not included in the stated minimum.
3. Teaching check: Partition the virtual address into offset, set index and tag. Page offsets require log₂4096=12 bits. Four-way associativity means only 128/4=32 sets, so five more bits select the set and the remaining fifteen distinguish pages within that set.
A system has both 32-bit virtual and 32-bit physical addresses. Its designers remove virtual memory because the address-space sizes are equal. Which claimed consequence is true? Options: (A) Efficient multiuser support becomes impossible (B) The cache organization can be made more efficient (C) Hardware memory-management support is no longer needed (D) CPU scheduling can be made more efficient
Your answer
Answer & solution
Answer: B (no official key was published)
1. Equal virtual and physical address widths do not make virtual memory redundant: address-space isolation, relocation, and protection still matter. Nevertheless removing address translation can simplify cache lookup, avoid translation-related latency and virtual alias issues, and thus permit a more efficient cache organization (B says can, not must).
2. Multi-user operation remains possible with other protection mechanisms; memory-management hardware can still be needed, and CPU scheduling does not automatically improve.
3. Teaching check: Equal address widths do not imply an identity mapping or a single shared address space. Different processes can map the same virtual address to different physical pages. The question’s true claim is only that cache organization can become simpler without translation, not that deleting virtual memory is generally desirable.
Processes with IDs 0,1,2 all arrive at time zero and need 2,4,8 compute units respectively. Use longest-remaining-time-first, reevaluated each time unit, with ties favoring the lower ID. What is average turnaround time? Options: (A) 13 (B) 14 (C) 15 (D) 16
Your answer
Answer & solution
Answer: A (no official key was published)
1. Using one-unit scheduling steps and breaking ties by the lower process ID, the running process IDs for times 0 through 13 are 2,2,2,2,1,2,1,2,0,1,2,0,1,2. Completion times are 12,13,14 for IDs 0,1,2.
2. Since arrivals are all zero, mean turnaround=(12+13+14)/3=13 units, A. This uses the intended discrete time-unit model; ideal continuous reevaluation at every instant would require a separate tie-sharing convention.
3. Teaching check: Turnaround equals completion time because every arrival is zero. LRTF initially favors the eight-unit process, but its remaining time eventually ties the four-unit process and the tie rule changes the schedule. Computing each completion time is safer than averaging burst lengths or waiting times alone.
Three processes arrive at time zero with total activity durations 10,20,30. Each spends its first 20% in I/O, next 70% computing, and last 10% in I/O. I/O overlaps as much as possible. The CPU chooses the shortest remaining compute burst when its current process blocks or completes its burst. What percentage of the entire elapsed interval is CPU-idle? Options: (A) 0% (B) 10.6% (C) 30.0% (D) 89.4%
Your answer
Answer & solution
Answer: B (no official key was published)
1. The three initial I/O bursts last 2,4,6; compute bursts last 7,14,21; final I/O bursts last 1,2,3. CPU is idle 0–2, executes process 1 during 2–9, process 2 during 9–23, and process 3 during 23–44.
2. Their final I/O finishes at 10,25,47. Over the complete 47-unit elapsed interval, CPU idle time is 2+3=5, hence 100×5/47≈10.6%, B.
3. The question continues on physical page 10.
4. Teaching check: The initial I/O phases overlap, so their elapsed cost is not 2+4+6 in series. While the first process computes, the other initial I/Os finish. The final three-unit I/O of the last process extends the completion horizon beyond the final CPU burst, producing additional CPU-idle time.
There are n processes; process i holds xᵢ instances of a resource and requests yᵢ additional instances. All resource instances are allocated. Exactly two processes p,q have yₚ=y_q=0. Which can be a necessary condition for avoiding impending deadlock? Max/min below range over k≠p,q. GFG prints max in B; GateForum prints min, a materially different condition. Options: (A) min(xₚ,x_q)<max yₖ (B) xₚ+x_q≥max yₖ [GFG]; xₚ+x_q≥min yₖ [GateForum] (C) max(xₚ,x_q)>1 (D) min(xₚ,x_q)>1
Your answer
Answer & solution
Answer: As printed, no listed condition is universally necessary (no official key was published)
1. Only p and q can initially finish without another allocation. After both finish, available resources equal W=xp+xq.
2. To make any further progress, at least one remaining process must have yk≤W; therefore W≥mink≠p,qyk is necessary (not sufficient for eventual completion of all processes).
3. The paper instead prints max in B: W≥max yk is sufficient, assuming these are remaining completion needs, but is not necessary. Counterexample: allocations (1,1,2,1), additional requests (0,0,1,3) have a safe sequence p,q,r,s: W grows 2→4→5, yet initial W=2<3.
4. No other the paper option is universally necessary: with all four allocations 1 and remaining requests (0,0,1,1), a safe sequence exists while A (1<1), C (1>1), and D (1>1) are false.
5. Teaching check: A necessary condition need not guarantee full completion. Once p and q release their holdings, at least one remaining process must be able to obtain its requested resources. Requiring enough for the largest request is stronger than necessary; a smaller request may finish first and release more resources.
Relation account(customer,balance) has customer as primary key and no nulls. Rank by decreasing balance, starting at 1, tying equal balances and skipping ranks (two tied maxima both rank 1, next rank 3). Q1: SELECT A.customer,COUNT(B.customer) FROM account A,account B WHERE A.balance<=B.balance GROUP BY A.customer; Q2: SELECT A.customer,1+COUNT(B.customer) FROM account A,account B WHERE A.balance<B.balance GROUP BY A.customer; Statements: 1 Q1 and Q2 agree for some but not all databases; 2 both implement the rank specification; 3 Q1 is correct but Q2 is not; 4 neither is correct; 5 pure relational ranking is faster than scanning in decreasing balance order and assigning ranks through ODBC. Which pair is correct? Options: (A) 2 and 5 (B) 1 and 3 (C) 1 and 4 (D) 3 and 5
Your answer
Answer & solution
Answer: C (no official key was published)
1. Query1 counts B rows with A.balance≤B.balance, so a customer tied with t customers at its balance receives the count of higher-balance customers plus t, instead of plus 1. For two tied maximum balances it gives 2, not 1.
2. Query2 uses A.balance<B.balance and adds 1 to the count, but its inner join produces no group for maximum-balance customers; those customers disappear. Thus neither query is correct (statement 4).
3. They agree on the empty database but differ on every nonempty database because Query1 includes the maximum group and Query2 does not, establishing statement 1 under the allowed empty-database case. Hence statements 1 and 4, option C.
4. Statement 5 is not a general performance guarantee.
5. Teaching check: The intended rank is 1 plus the number of strictly higher balances. Q1 instead counts all tied customers along with higher ones. Q2 uses the correct comparison but an inner join removes maxima, so adding one to its count does not restore the missing rows.
Schemas enrolled(student,course), key (student,course), and paid(student,amount), key student; no nulls, foreign keys or additional constraints. Q1: SELECT student FROM enrolled WHERE student IN (SELECT student FROM paid); Q2: SELECT student FROM paid WHERE student IN (SELECT student FROM enrolled); Q3: SELECT E.student FROM enrolled E,paid P WHERE E.student=P.student; Q4: SELECT student FROM paid WHERE EXISTS (SELECT * FROM enrolled WHERE enrolled.student=paid.student); Which statement holds under SQL result-bag semantics (no DISTINCT)? Options: (A) All four return identical rows for every database (B) Q2 and Q4 always agree, but Q1 and Q2 can differ (C) Q3 can return strictly fewer rows than Q2 (D) Q4 can encounter a runtime integrity violation
Your answer
Answer & solution
Answer: B (no official key was published)
1. Query2 and Query4 each scan paid, whose student key is unique, and keep exactly students with an enrolled match. They therefore return identical bags with one row per matching student.
2. Query1 scans enrolled and returns one student occurrence for each matching enrollment; Query3 has the same multiplicities because paid has at most one matching row. A paid student enrolled in two courses appears twice in Query1/3 but once in Query2/4.
3. Thus B. SELECT alone does not eliminate duplicate rows; the phrase row sets must be interpreted as SQL result rows/bags.
4. Teaching check: A membership predicate filters each outer row but does not collapse duplicates already present in the outer projection. The paid key guarantees one outer row per student for Q2/Q4, whereas enrolled can contain several courses per student for Q1/Q3. Relational set intuition must not erase SQL multiplicities.
Schemas enrolled(student,course), key (student,course), and paid(student,amount), key student, have no nulls, foreign keys or additional constraints. Amounts 6000,7000,8000,9000,10000 are each paid by 20% of students. Both plans list courses of students paying more than x. Plan 1 sequentially scans paid, selects amount>x, probes enrolled's student index for an indexed nested-loop join, then projects course. Plan 2 scans all paid and performs the same indexed join first, then selects amount>x and projects course. Projection does not request DISTINCT. A disk seek costs 4 ms, transfer rate is 300 MB/s, and checking amount>x costs 10 μs per tuple. Which statement holds? Options: (A) The plans do not return identical rows for every database (B) Plan 1 may list a course more than once (C) At x=5000 Plan 1 is faster for every database (D) At x=9000 Plan 1 is slower for every database
Your answer
Answer & solution
Answer: B (no official key was published)
1. Both plans select the same matching paid/enrolled tuples: pushing a predicate on paid.amount below the join preserves the result. Projection without DISTINCT can output the same course for two different qualifying students, so B is true under SQL bag semantics.
2. The enrolled key is (student,course), not course. C is not universal: at x=5000 all paid rows pass, and with no enrollments Plan 2 has no joined rows to test while Plan 1 still tests paid rows.
3. D is not universal either: at x=9000 Plan 1 can avoid 80% of index probes, making it faster on ordinary populated instances. Seek and transfer constants do not turn either universal performance claim into a theorem.
4. The plans/options continue on page 11.
5. Teaching check: Pushing a filter before a join can reduce work, but a universal speed claim needs more than a selectivity estimate. Course is not a key of the join output, so two qualifying students in the same course produce repeated course values after projection without DISTINCT.
Given dependencies AB→CD, AF→D, DE→F, C→G, F→E, G→A, which claimed attribute closure is false? Both reproductions contain the following options, including F in D. Options: (A) (CF)⁺={A,C,D,E,F,G} (B) (BG)⁺={A,B,C,D,G} (C) (AF)⁺={A,C,D,E,F,G} (D) (AB)⁺={A,B,C,D,F,G}
Your answer
Answer & solution
Answer: C, D (no official key was published)
1. Apply AB→CD, AF→D, DE→F, C→G, F→E, G→A until closure stops. (CF)+={A,C,D,E,F,G}: C gives G then A; F gives E; AF gives D.
2. (BG)+={A,B,C,D,G}: G gives A then AB gives C,D; neither E nor F is derivable. (AF)+={A,D,E,F}: AF gives D and F gives E, but nothing yields C or G.
3. (AB)+={A,B,C,D,G}: AB gives C,D, C gives G; no E or F follows. Thus C is false and D is also false because its printed right side includes F.
4. A and B are true. There is no unique single false option in these reproductions.
5. Teaching check: Begin each closure with the attributes on the left, then repeatedly add a dependency’s right side only when its entire left side is present. In particular DE→F cannot fire with D alone. This is why AB cannot acquire E or F and why AF cannot acquire C or G.
A simple undirected graph G has one vertex for each of the 2^n subsets of an n-element set, n≥6. Two distinct vertices are adjacent iff their subsets intersect in exactly two elements. How many vertices have degree zero? Options: (A) 1 (B) n (C) n+1 (D) 2^n
Your answer
Answer & solution
Answer: C (no official key was published)
1. The empty set and all n singleton subsets cannot intersect any subset in exactly two elements, so all n+1 are isolated. Every set S of size at least 3 is adjacent to any two-element subset of S.
2. Every two-element S is adjacent to a proper superset S∪{x}, available because n≥6. No other isolated vertices exist.
3. Answer n+1, C.
4. Teaching check: A set with fewer than two elements cannot share two elements with any other set. Conversely, every larger set has a two-element intersection partner: use a contained pair when its size exceeds two, or a proper superset when its size is exactly two.
A simple undirected graph G has one vertex for each of the 2^n subsets of an n-element set, n≥6. Two distinct vertices are adjacent iff their subsets intersect in exactly two elements. What is the maximum vertex degree? Options: (A) C(n/2,2)·2^(n/2) (B) 2^(n−2) (C) 3·2^(n−3) (D) 2^(n−1)
Your answer
Answer & solution
Answer: C (no official key was published)
1. For a vertex S with |S|=k, choose the two intersection elements from S and any subset outside S, giving C(k,2)·2n−k candidate neighbors. When k=2 subtract one to exclude S itself; for k=0,1 degree is zero.
2. For k≥3, the ratio of successive degrees is (k+1)/(2(k−1)), equal to 1 at k=3 and less than 1 for k>3. The maximum is therefore attained at k=3 and k=4, with degree 3·2n−3.
3. This exceeds the k=2 degree 2n−2−1. Thus C.
4. Teaching check: For a size-k set, choose which two of its k elements are in the neighbor; no other element of the set may be in that neighbor. Every outside element is freely included or excluded. Exclude a self-neighbor only when k=2, then compare successive k values rather than assuming k=n/2 maximizes the degree.
A simple undirected graph G has one vertex for each of the 2^n subsets of an n-element set, n≥6. Two distinct vertices are adjacent iff their subsets intersect in exactly two elements. How many connected components are there? Options: (A) n (B) n+2 (C) 2^(n/2) (D) 2^n/n
Your answer
Answer & solution
Answer: B (no official key was published)
1. There are n+1 isolated vertices from Q71. All vertices of size at least two are in one additional component.
2. Any larger set S is adjacent to a two-element subset T⊂S. Any two distinct two-element subsets T,U are both adjacent to their union T∪U, since its intersection with each is that two-element subset.
3. Hence all nonisolated vertices are connected. Total components=n+1+1=n+2, B.
4. Teaching check: Connectivity does not require every two nonisolated vertices to be directly adjacent. Any two pairs connect through their union; every larger set attaches to one of its own pairs. These short paths prove there is exactly one component besides the n+1 isolated vertices.
Compare two 32 KB caches with 32-byte blocks and 32-bit addresses: one is two-way set associative, the other direct mapped. A 2:1 multiplexer takes 0.6 ns; a k-bit comparator takes k/10 ns. The hit-latency model counts comparator and way-selection delays. Find two-way cache hit latency h₁. Options: (A) 2.4 ns (B) 2.3 ns (C) 1.8 ns (D) 1.7 ns
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: 32 KB / 32 B=1024 cache lines. Two ways give 512 sets, so index=9 bits and block offset=5 bits.
Step 2: The tag is 32−9−5=18 bits. Two tag comparisons proceed in parallel, taking 18/10=1.8 ns; selecting the matching way adds 0.6 ns.
Step 3: Thus h1=2.4 ns, A, within the stated model that counts comparator and multiplexer latency.
Step 4: Teaching check: Two-way associativity halves the number of sets relative to direct mapping, increasing the tag by one bit. Both way tags are compared in parallel, so do not double comparator latency. The selected data then passes through one 2:1 multiplexer.
Compare two 32 KB caches with 32-byte blocks and 32-bit addresses: one is two-way set associative, the other direct mapped. A 2:1 multiplexer takes 0.6 ns; a k-bit comparator takes k/10 ns. The hit-latency model counts comparator and way-selection delays. Find direct-mapped hit latency h₂. Options: (A) 2.4 ns (B) 2.3 ns (C) 1.8 ns (D) 1.7 ns
Your answer
Answer & solution
Answer: D (no official key was published)
1. A direct-mapped 32 KB cache with 32-byte blocks has 1024 lines, requiring 10 index bits and 5 offset bits. The tag has 32−10−5=17 bits.
2. Its comparison takes 17/10=1.7 ns and no way-selection multiplexer is needed. Thus h2=1.7 ns, D, using the problem’s comparator/multiplexer-only timing model.
3. Teaching check: Direct mapping determines the only candidate line from the index bits, so no way selection is needed. There are 1024 lines rather than 512 sets, giving a 17-bit rather than 18-bit tag. The difference in hit time comes from both the tag size and the absent multiplexer.
A ternary max-heap is stored level-by-level, left-to-right, in a zero-based array. Root is a[0]; children of i are 3i+1,3i+2,3i+3. Insert by appending then moving upward until the parent is at least as large. Which array is a valid heap? Options: (A) [1,3,5,6,8,9] (B) [9,6,3,1,8,5] (C) [9,3,6,8,5,1] (D) [9,5,6,8,3,1]
Your answer
Answer & solution
Answer: D (no official key was published)
1. In a zero-based ternary heap, children of i are 3i+1,3i+2,3i+3. For D=[9,5,6,8,3,1], root 9 dominates 5,6,8 and node 5 dominates children 3,1.
2. A fails at the root; B has parent 6 with child 8; C has parent 3 with child 5. Only D is a valid max-heap.
3. Teaching check: Heap order is a parent-child condition, not full sorting. For six entries only root 0 and node 1 have children; checking these is sufficient. Option D’s 8 may exceed node 1’s 5 because they are siblings, so that comparison imposes no restriction.
A ternary max-heap is stored level-by-level, left-to-right, in a zero-based array. Root is a[0]; children of i are 3i+1,3i+2,3i+3. Insert by appending then moving upward until the parent is at least as large. Start from the valid heap [9,5,6,8,3,1] and insert 7,2,10,4 in that order. What final array results? Options: (A) [10,7,9,8,3,1,5,2,6,4] (B) [10,9,8,7,6,5,4,3,2,1] (C) [10,9,4,5,7,6,8,2,1,3] (D) [10,8,6,9,7,2,3,4,1,5]
Your answer
Answer & solution
Answer: A (no official key was published)
Step through it (9 steps)
1. Start with [9,5,6,8,3,1]. Insert 7 at index 6 and exchange with parent index 1, obtaining [9,7,6,8,3,1,5].
2. Insert 2 at index 7, whose parent 6 is already larger: [9,7,6,8,3,1,5,2]. Insert 10 at index 8, exchange with parent index 2 (6), then root 9, obtaining [10,7,9,8,3,1,5,2,6].
3. Insert 4 at index 9 under parent 9, with no exchange. Final array [10,7,9,8,3,1,5,2,6,4], A.
4. Teaching check: The parent index is floor((i−1)/3). After appending 10 at index 8, its parent is index 2, then the root, so two upward swaps occur. Appending 4 at index 9 places it under the current 9 and requires no swap.
Three processes repeatedly synchronize at a barrier. Shared process_arrived and process_left start at 0. S is a binary semaphore, initially available; P acquires and V releases it. Each process calls: void barrier(void) { 1: P(S); 2: process_arrived++; 3: V(S); 4: while (process_arrived != 3); 5: P(S); 6: process_left++; 7: if (process_left == 3) { 8: process_arrived=0; 9: process_left=0; 10: } 11: V(S); } Use the intended shared-memory pseudocode model, not a claim of data-race-safe modern C. Why is the implementation incorrect? Options: (A) The use of binary semaphore S makes it wrong (B) Two consecutive barrier invocations can deadlock (C) Lines 6–10 do not need a critical section (D) It is correct with two processes instead of three
Your answer
Answer & solution
Answer: B (no official key was published)
1. Once all three arrive, process_arrived=3. Let P leave the first barrier, increment process_left to 1, and immediately enter its next barrier before Q and R have finished the first.
2. It increments process_arrived to 4. If Q and R have not passed the first barrier’s while test, they now wait for process_arrived==3, and P also waits in its second invocation.
3. No one can perform the final reset: deadlock. Binary semaphores correctly protect the updates and are not the cause; the missing separation between barrier generations is.
4. The same issue can occur with two processes. Hence B.
5. Teaching check: The first invocation opens when arrival count reaches three, but the code does not close entry to the next generation. An early returning process can raise the count to four while another still tests for equality with three. A protected increment alone does not prevent mixing generations.
Three processes repeatedly synchronize at a barrier. Shared process_arrived and process_left start at 0. S is a binary semaphore, initially available; P acquires and V releases it. Each process calls: void barrier(void) { 1: P(S); 2: process_arrived++; 3: V(S); 4: while (process_arrived != 3); 5: P(S); 6: process_left++; 7: if (process_left == 3) { 8: process_arrived=0; 9: process_left=0; 10: } 11: V(S); } Use the intended shared-memory pseudocode model, not a claim of data-race-safe modern C. Which proposed repair addresses its reuse problem? The phrase “first process” in B is only a conceptual generation gate and needs a concrete synchronization implementation. Options: (A) Replace lines 6–10 by process_arrived-- (B) At barrier entry, the first process waits for process_arrived to become zero before executing P(S) (C) Disable context switching throughout the barrier (D) Make process_left private instead of shared
Your answer
Answer & solution
Answer: B, with generation-entry qualification (no official key was published)
1. The intended repair is to prevent a process from incrementing the next generation’s arrival count until the previous generation has reset process_arrived to zero, corresponding to B. It must wait before acquiring S, leaving S available to the final departing process that performs the reset.
2. A lets an early departure lower process_arrived while others still need to observe 3; C prevents necessary scheduling on a uniprocessor; D prevents the shared departure count reaching 3. However the phrase first process to enter is a conceptual generation gate, not complete executable synchronization.
3. Merely adding an unconditional while(process_arrived!=0) to every invocation blocks the second arrival of the same generation; waiting only one vaguely designated process while allowing another new-generation entrant through is also insufficient. A concrete reusable barrier needs a correctly synchronized generation flag or two-turnstile design.
4. Teaching check: Waiting while holding S would prevent the final departing process from acquiring S to reset the counters. Waiting must therefore occur outside that critical section, and it must distinguish generations correctly. A two-turnstile or generation-counter barrier is a concrete way to enforce this separation.
A CPU has a 32 KB direct-mapped cache with 128-byte blocks. C array A[512][512] uses 8-byte elements. The two programs execute separately from the same initially cold cache; i,j,x are in registers. P1: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[i][j]; P2: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[j][i]; Let M1,M2 be their cache-miss counts. Use the conventional block-aligned base address assumed by the listed answers. Find M1. Options: (A) 0 (B) 2048 (C) 16384 (D) 262144
Your answer
Answer & solution
Answer: C (no official key was published)
1. In C, A is row-major. Each 128-byte cache block holds 128/8=16 elements.
2. P1 visits all 512×512 elements sequentially, so one compulsory miss serves each group of 16 elements. For a block-aligned A, M1=512×512/16=16384, C; each later element in the same block hits.
3. Teaching check: C’s rightmost subscript varies over contiguous elements. Each cache block supplies sixteen consecutive doubles, causing one miss followed by fifteen hits in a sequential scan. The whole array is much larger than the cache, but immediate within-block reuse still occurs.
A CPU has a 32 KB direct-mapped cache with 128-byte blocks. C array A[512][512] uses 8-byte elements. The two programs execute separately from the same initially cold cache; i,j,x are in registers. P1: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[i][j]; P2: for(i=0;i<512;i++) for(j=0;j<512;j++) x+=A[j][i]; Let M1,M2 be their cache-miss counts. Use the conventional block-aligned base address assumed by the listed answers. Find M1/M2. Options: (A) 0 (B) 1/16 (C) 1/8 (D) 16
Your answer
Answer & solution
Answer: B (no official key was published)
1. P1 has 16384 misses under the block-aligned assumption. P2 accesses A[j][i] with stride 512×8=4096 bytes=32 cache lines.
2. The cache has 32768/128=256 lines, so successive row accesses cycle through only 256/gcd(256,32)=8 cache indices. With 512 rows, every would-be reused block is evicted before the next column accesses it.
3. All 512²=262144 P2 accesses miss. M1/M2=16384/262144=1/16, B.
4. The last options are on physical page 13.
5. Teaching check: A 4096-byte stride advances by 32 cache indices modulo 256. Only eight indices participate in a column, repeatedly overwriting each other. Thus the next column cannot reuse the previous column’s blocks, even though adjacent elements within a row occupy the same block.
Transparent bridges B1,…,B5 connect six LANs. The following connection list fully specifies the figure; Bk:p denotes port p of bridge k: LAN H1,H2: B1:1, B5:2, B3:4. LAN H3,H4: B1:2, B5:3, B3:3. LAN H5,H6: B5:1, B3:1, B4:1, B2:2. LAN H7,H8: B5:4, B3:2, B4:2, B2:1. LAN H9,H10: B4:3. LAN H11,H12: B2:3. The bridge with lowest serial number is root. Every bridge selects a shortest path to the root; equal root-port choices prefer lower port index. For forwarding onto a LAN, bridges closer to the root win, then lower bridge serial number. Which listed order is a depth-first traversal of the resulting bridge spanning tree? Options: (A) B1,B5,B3,B4,B2 (B) B1,B3,B5,B2,B4 (C) B1,B5,B2,B3,B4 (D) B1,B3,B4,B5,B2
Your answer
Answer & solution
Answer: A (no official key was published)
1. B1 is the root (lowest serial number). B5 and B3 both connect directly to the two top LANs: B5 chooses root port 2 over 3, while B3 chooses root port 3 over 4.
2. On each middle LAN B3 wins the designated-bridge tie against B5 because 3<5. B4 chooses its root port 1 via the H5/H6 LAN; B2 chooses root port 1 via the H7/H8 LAN.
3. Thus the bridge tree has edges B1–B5, B1–B3, B3–B4, B3–B2. Among listed sequences only B1,B5,B3,B4,B2 is a depth-first traversal, A.
4. (Other child orders can give other valid DFS sequences, but the other listed sequences leave B3’s subtree prematurely.)
5. Teaching check: After choosing root ports, compare B3 and B5 on the middle LANs: both are one bridge-hop from B1, so B3’s smaller ID wins. B4 and B2 consequently attach under B3. A depth-first traversal must finish B3’s children before returning to visit sibling B5.
Transparent bridges B1,…,B5 connect six LANs. The following connection list fully specifies the figure; Bk:p denotes port p of bridge k: LAN H1,H2: B1:1, B5:2, B3:4. LAN H3,H4: B1:2, B5:3, B3:3. LAN H5,H6: B5:1, B3:1, B4:1, B2:2. LAN H7,H8: B5:4, B3:2, B4:2, B2:1. LAN H9,H10: B4:3. LAN H11,H12: B2:3. The bridge with lowest serial number is root. Every bridge selects a shortest path to the root; equal root-port choices prefer lower port index. For forwarding onto a LAN, bridges closer to the root win, then lower bridge serial number. For the resulting tree, after H1 sends a broadcast ping, which listed forwarding table describes B3? Tables list destination groups and outgoing port. D retains the reproduced H7 duplication. Options: (A) H1,H2,H3,H4→3; H5,H6,H9,H10→1; H7,H8,H11,H12→2 (B) H1,H2→4; H3,H4→3; H5,H6→1; H7,H8,H9,H10,H11,H12→2 (C) H3,H4→3; H5,H6,H9,H10→1; H1,H2→4; H7,H8,H11,H12→2 (D) H1,H2,H3,H4→3; H5,H7,H9,H10→1; H7,H8,H11,H12→4
Your answer
Answer & solution
Answer: A, as complete topology-consistent forwarding table (no official key was published)
1. Using Q82’s spanning tree, B3 reaches both top LANs through root port 3: H1,H2,H3,H4→3. Its port 1 connects the H5/H6 LAN and B4 leading to H9/H10: H5,H6,H9,H10→1.
2. Port 2 connects the H7/H8 LAN and B2 leading to H11/H12: H7,H8,H11,H12→2. This is A; B3 port 4 is blocked.
3. A broadcast from H1 arrives at B3 on port 3.
4. Teaching check: Interpret the table as the forwarding directions implied by the converged spanning tree. A single broadcast frame teaches a learning bridge only the source’s direction, not every destination entry by itself. The full table in the options therefore describes the tree-based routes, rather than a complete table learned solely from that one frame.
1. In D, C→aCb|ε generates balanced ak bk. A→aA|a adds a positive number of a symbols, so S→AC generates all i>j.
2. B→Bb|b adds a positive number of b symbols, so S→CB generates all j>i. Together these are precisely ai bj with i≠j.
3. A permits cancellation of C’s ±1 imbalance by the other nonterminal: for example S⇒AC⇒aC⇒ab. B also generates ab.
4. C allows A/B→ε and therefore generates equal counts, including ε. Only D excludes every equal-count string while covering every unequal-count string.
5. Teaching check: C supplies equal counts, while A supplies at least one extra a or B at least one extra b. Because A and B cannot derive ε in D, every generated string has unequal counts. Conversely any unequal pair of nonnegative counts decomposes into a common balanced part and one positive excess.
Using grammar S→AC|CB, C→aCb|ε, A→aA|a, B→Bb|b, count the production applications in a derivation from S of a^l b^m, with l,m≥0 and l≠m. GFG prints the same expression in A and D; GateForum D instead has +3. Options: (A) max(l,m)+2 (B) l+m+2 (C) l+m+3 (D) max(l,m)+2 [GFG]; max(l,m)+3 [GateForum]
Your answer
Answer & solution
Answer: max(l,m)+2 (options A and D are printed identically) (no official key was published)
1. For l>m use S→AC (1 step), expand C by C→aCb exactly m times and then C→ε (m+1 steps), and derive al−m from A using l−m productions (l−m−1 recursive steps and one terminal step). Total=1+(m+1)+(l−m)=l+2.
2. For m>l the CB branch gives m+2. Thus the length is max(l,m)+2, regardless of the order in which independent nonterminals are expanded.
3. Both A and D visibly print this same expression, so no unique option letter is supported.
4. Teaching check: Count production applications, including C→ε and the initial S choice. For l=3,m=1, use S→AC, A→aA→aa, C→aCb→ab: five applications, equal to max(3,1)+2. Interleaving A and C expansions does not alter the number of productions used.