For n×n matrices, assess two possibility claims: two singular matrices may have a nonsingular sum; two nonsingular matrices may have a singular sum. Options A/B/C/D mean respectively both true, only the first true, only the second true, neither true.
Your answer
Answer & solution
Answer: A for n≥2; C if n=1 (no official key was published)
Step 1: Test the existential claims with examples. For n=2, diag(1,0) and diag(0,1) are singular but their sum I is nonsingular. For larger n, split the identity diagonal between two complementary nonempty blocks.
Step 2: I and −I are nonsingular, while I+(−I)=0 is singular. Thus both possibilities occur, giving A in the intended dimension range.
Qualification: For n=1 the only singular scalar matrix is zero, and adding two zeros remains singular. Then S1 is false and S2 true, giving C. The problem does not explicitly exclude this boundary case.
Which relations are equivalence relations? R1 on integers: a+b is even; R2 on integers: a+b is odd; R3 on nonzero rationals: ab>0; R4 on natural numbers: |a−b|≤2. Options select R1/R2, R1/R3, R1/R4, or all four.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: R1 means the integers have the same parity. Equality of parity is reflexive, symmetric and transitive, giving two equivalence classes. R3 means two nonzero rationals have the same sign, another equivalence relation.
Step 2: R2 is not reflexive because a+a is always even, never odd. R4 is not transitive: |1−3|≤2 and |3−5|≤2, but |1−5|>2.
Conclusion: Exactly R1 and R3 qualify, so B. Testing only symmetry would miss the failures in R2 and R4.
Classify F1=(P→¬P) and F2=(P→¬P)∨(¬P→P). Choices: A F1 satisfiable and F2 valid; B F1 unsatisfiable and F2 satisfiable; C F1 unsatisfiable and F2 valid; D both satisfiable.
Your answer
Answer & solution
Answer: A is strongest; D is also literally true (no official key was published)
Step 1: P→¬P simplifies to ¬P, so F1 is true when P is false and false when P is true. It is satisfiable but not valid.
Step 2: ¬P→P simplifies to P. Therefore F2=(¬P)∨P is a tautology, true for both valuations, so A states the precise classifications.
Option issue: Every valid formula is also satisfiable on this nonempty valuation space. Consequently D, saying both formulas are satisfiable, is also true. B and C incorrectly call F1 unsatisfiable. A is more informative, but the literal single-correct-option premise fails.
Assess regularity of L1={0^(2n):n≥1} and L2={0^m1^n0^(m+n):m,n≥1}. Choices A/B/C/D assert only L1, only L2, both, or neither is regular.
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: S1 contains positive even-length strings of zeros, described by regular expression 00(00)*, so it is regular.
Step 2: Suppose S2 were regular with pumping length p. Choose 0p1p02p. Any pumping segment in the first p symbols consists of k≥1 initial zeros. Pumping it out changes the first zero-block length to p−k while leaving the final zero block length 2p. That final block no longer equals the sum(p−k)+p. This contradicts the pumping lemma.
Therefore S2 is not regular and only S1 is correct, A.
Which statement about context-free languages is true: every CFL has a deterministic PDA; CFLs are closed under union; CFLs are closed under intersection; or CFLs are closed under complement?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Given grammars with disjoint renamed nonterminals and start symbols S1,S2, introduce a fresh start S→S1|S2. This grammar generates their union, proving B.
Step 2: The CFLs {an bn cm} and {am bn cn} have intersection{an bn cn}, which is not context-free. Thus C is false. If CFLs were closed under complement, their union closure and De Morgan would imply intersection closure, so D also fails.
Finally deterministic PDA languages form a strict subclass of CFLs; an arbitrary CFL need not have a deterministic PDA. Hence A is false.
For an N-state NFA, determine the maximum possible size of an equivalent minimized DFA. Listed expressions are N², 2^N, 2N, and N!. The reproduced wording uses “maximum … at least”; distinguish worst-case size from the size for every individual NFA.
Your answer
Answer & solution
Answer: B for the tight worst-case bound (no official key was published)
Step 1: Subset construction represents a DFA state by a subset of the N NFA states. There are at most 2N such subsets, and minimization cannot increase that number.
Step 2: This bound can be attained when the alphabet is unrestricted. Start at q0, make q0 accepting, and include symbols that map q0 to each chosen subset S. Include test symbols bi that map only qi to q0 and all other states to the empty set. Every subset is reachable, and bi distinguishes two subsets that differ in whether they contain qi. Thus all 2N subsets are inequivalent.
Conclusion: The maximum over N-state NFAs is 2N, B. This is not a claim that every particular NFA requires 2N states. The source phrase “maximum … at least” is imprecise; the tight worst-case reading is used.
Why does a cache block contain multiple words? Choices: temporal locality, spatial locality, reduced miss penalty, or none of these.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: A reference often predicts references to nearby addresses, for example successive array elements or adjacent instructions. Loading neighboring words with the requested word prepares for those accesses: spatial locality.
Step 2: Temporal locality concerns repeated use of the same location and already motivates retaining even a single cached word. A larger block can increase rather than reduce the transfer time of a miss.
Therefore spatial locality is the specific reason for grouping words, B.
Which virtual-memory claim is false? It translates program addresses to physical addresses; allows a program larger than primary memory; increases possible multiprogramming; or reduces context-switch overhead.
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: Virtual memory translates virtual addresses, permits only part of a program to be resident, and can accommodate more simultaneously active processes than whole-program residency allows. These explain the usual claims A–C.
Step 2: A context switch still saves/restores CPU state and may change page-table context or invalidate/repopulate translation caches. Virtual memory does not inherently remove that work and can add translation-related overhead.
Thus D is the false general claim. The benefit in multiprogramming is a capability, not a guarantee against thrashing under every workload.
Which 8085 signal supports connecting slow memory: INTR, RESET IN, HOLD, or READY?
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: Slow memory may not complete a read or write within the processor’s ordinary bus cycle. The processor needs a way to extend that transfer without treating it as a new operation.
Step 2: Deasserting READY inserts wait states until the device is ready, so D. INTR requests interrupt service, RESET IN resets execution, and HOLD requests bus ownership; none is the normal memory-cycle wait-state handshake.
A processor has no dedicated stack-pointer register. Does this prohibit subroutine calls, permit calls but not nesting, permit nesting but not interrupts, or still allow nested calls and interrupts?
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: A call must preserve a return address, but that address need not be pushed by a special hardware SP. A link register, a general-purpose register used as a software pointer, or explicit memory stores can preserve it.
Step 2: Before a nested call overwrites a link register, software saves the old value in a memory record and restores it on return. Interrupt context can be preserved by analogous hardware/software mechanisms.
Thus the absence of a dedicated stack-pointer register does not rule out nested calls or interrupts: D, assuming the processor otherwise provides the necessary control-transfer and storage operations.
Find a minimal SOP for the displayed four-variable map. Columns wx and rows yz both use Gray order 00,01,11,10. Rows are [0,X,0,X], [X,1,X,1], [0,X,1,0], [0,1,X,0], with X a don’t-care. Choices: A xy+y′z; B wx′y′+xy+xz; C w′x+y′z+xy; D xz+y.
Your answer
Answer & solution
Answer: A (no official key was published)
Step through it (13 steps)
Step 1: Read columns wx and rows yz in Gray order 00,01,11,10. The entire row yz=01 can be grouped using its don’t-care cells, producing y′z. The block with x=1,y=1 across rows 11/10 and columns 01/11 produces xy.
Step 2: These two four-cell groups cover all specified ones without covering a specified zero. One term cannot cover both required regions: enlarging to a common cube would include forbidden zero cells.
Conclusion: xy+y′z is a minimal two-term expression, A. Don’t-care cells are chosen only to enlarge legal groups, not to change specified zeros.
What is the principal system purpose of a software interrupt: testing interrupts, implementing coroutines, requesting system services needing privileged instructions, or returning from a subroutine?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: User-mode code cannot directly execute protected operations such as arbitrary device control. It must transfer control through an authorized entry point into the operating system.
Step 2: A software interrupt/trap provides that controlled transfer and lets the kernel execute the privileged instructions, so C. A normal subroutine return is not this transition, and coroutines can switch cooperatively without requiring a privileged trap. Testing interrupts is possible but is not their essential system-service purpose.
A CPU has privileged and nonprivileged modes. How does the conventional architecture return from privileged to nonprivileged execution? Choices are hardware interrupt, software interrupt, a privileged non-interrupting instruction, or a nonprivileged non-interrupting instruction.
Your answer
Answer & solution
Answer: C under the conventional mode-control architecture (no official key was published)
Step 1: Interrupts and traps normally enter privileged mode. The reverse transition occurs when the OS restores a user context and returns to its instruction stream.
Step 2: A privileged return-from-trap or mode-control instruction can perform that transition without generating a new interrupt, corresponding to C. It is executed while the processor is still privileged.
Qualification: The prompt does not specify an ISA. Some architectures may provide other controlled privilege-dropping mechanisms; the answer uses the standard textbook protection model, not a universal instruction-set theorem.
Quicksort selects each pivot randomly. What is its worst-case sorting complexity on n values: O(n), O(n log n), O(n²), or O(n!)?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Random pivot selection improves the expected split quality, but it does not make extreme pivots impossible. A sequence selecting the minimum or maximum at every partition still has nonzero probability.
Step 2: That sequence performs(n−1)+(n−2)+…+1=n(n−1)/2 partition comparisons, yielding Θ(n²).
Thus C is the tight worst-case bound. Θ(n log n) is the expected runtime over the random choices, not the maximum possible runtime of a particular execution.
A binary heap occupies array indices 1 through n. For an element at index i, choose the parent index from i−1, floor(i/2), ceil(i/2), and (i+1)/2. Account for the root boundary.
Your answer
Answer & solution
Answer: B for nonroot nodes (no official key was published)
Step 1: A node at index j has left child 2j and right child 2j+1. For an even child index i=2j, division gives i/2=j. For an odd child i=2j+1, floor(i/2)=j.
Step 2: Both cases are captured by floor(i/2), B. For example indices 6 and 7 both have parent 3; ceiling would incorrectly map 7 to 4.
Boundary: The root at i=1 has no parent. The formula returns sentinel index 0, outside the heap, rather than describing a genuine parent.
Compare f(n)=n² lg n and g(n)=n(lg n)^10. Which asymptotic relationship holds: only f=O(g), only g=O(f), neither, or both?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Divide f(n)=n² lg n by g(n)=n(lg n)10. The ratio is n/(lg n)9.
Step 2: Put t=lg n, so the ratio becomes 2t/t9, which tends to infinity because an exponential dominates every fixed power of t.
Therefore g=O(f), while f is not O(g), giving B. The logarithmic factor with exponent 10 cannot compensate asymptotically for the additional factor n in f.
What is the process of assigning actual load addresses and adjusting program address references: assembly, parsing, relocation, or symbol resolution?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Object code can contain address-dependent references expressed relative to an initially assumed location. Loading the program elsewhere requires assigning its actual locations.
Step 2: Address fields or relocation entries are adjusted to match those locations; this operation is relocation, C. Assembly translates symbolic instructions, parsing recognizes syntactic structure, and symbol resolution identifies which definition a name denotes. These can accompany linking/loading but are distinct tasks.
Which claim is false? An unambiguous grammar has identical leftmost and rightmost derivations; LL(1) parsing is top-down; LALR is more powerful than SLR; an ambiguous grammar cannot be LR(k) for any k.
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: Unambiguity means each generated string has one parse tree, hence one leftmost derivation and one rightmost derivation. It does not mean those two sequences of intermediate sentential forms are identical.
Step 2: For S→AB,A→a,B→b, the leftmost derivation is S⇒AB⇒aB⇒ab, while the rightmost one is S⇒AB⇒Ab⇒ab. The grammar is unambiguous, yet the derivations differ.
Thus A is false. LL(1) is top-down, LALR recognizes a strictly larger grammar class than SLR, and every LR(k) grammar is unambiguous.
Given n tasks with known runtimes r1,…,rn on one processor, which policy maximizes throughput: round robin, shortest-job-first, highest-response-ratio-next, or FCFS? Explain the throughput interpretation needed.
Your answer
Answer & solution
Answer: B under the finite-horizon completion interpretation (no official key was published)
Step 1: If all jobs are ready and their runtimes are known, the k shortest jobs have the minimum possible total runtime among all k-job subsets. Executing them first therefore completes as many jobs as possible by each time horizon, under zero overhead and no blocking. This favors SJF, B.
Step 2: However, if throughput means the entire fixed batch’s n completions divided by its total processing time, every work-conserving order gives n/(r1+…+rn). Under that definition no unique scheduler maximizes it.
The answer therefore needs the finite-horizon or average-completion interpretation; it must not claim SJF reduces the sum of all CPU bursts.
Where does conventional swap space reside: RAM, disk, ROM, or on-chip cache?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Swapping moves memory contents out of RAM so that physical frames become available for other uses. The displaced contents must survive while those RAM frames are reused.
Step 2: Conventional swap space is reserved secondary-storage space, typically a disk partition or file, so B. ROM is not a normal writable swap target; CPU cache and RAM do not provide the intended backing store. This historical answer includes modern disk-like secondary storage such as SSDs.
With FIFO page replacement, what can increasing the number of frames do for an arbitrary reference string: always decrease faults, always increase faults, sometimes increase faults, or never change faults?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: FIFO evicts the page loaded earliest, without maintaining the stack-inclusion property of LRU. Adding frames can change future FIFO victim order.
Step 2: For reference string 1,2,3,4,1,2,5,1,2,3,4,5 from empty memory, FIFO incurs 9 faults with 3 frames but 10 with 4. This is Belady’s anomaly. Other strings can benefit or show no change.
Therefore additional frames can sometimes increase faults, C; neither a universal decrease nor universal increase is valid.
Which component normally requires a device driver: a CPU register, cache, main memory, or disk?
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: A device driver translates OS requests into device-controller operations, handles completion/error reporting, and coordinates the peripheral’s interface. A disk has such an interface and requires a storage driver.
Step 2: CPU registers and ordinary cache are accessed or managed by processor mechanisms, while normal main-memory access is part of the memory architecture rather than a disk-style peripheral protocol.
Thus D is the intended distinction. Memory management software exists, but that does not make it the device driver meant in this question.
Relation R(A,B,C,D) has dependencies A→B and C→D and is decomposed into AB and CD. Classify the decomposition as dependency-preserving or not and lossless or not.
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (3 steps)
Step 1: A→B can be checked entirely in R1(AB), and C→D entirely in R2(CD). Thus the decomposition preserves both supplied dependencies.
Step 2: The two schemas have empty intersection. Their natural join is a Cartesian product, which can create spurious combinations. For instance tuples(a1,b1,c1,d1) and(a2,b2,c2,d2) satisfy the dependencies, but joining their projections also creates(a1,b1,c2,d2) and(a2,b2,c1,d1).
Hence the decomposition is dependency-preserving but not guaranteed lossless, C.
Given an adjacency relation Adj(X,Y), which query cannot be expressed by a fixed-length ordinary relational-algebra expression: neighbors of a vertex, vertices with self-loops, vertices in cycles with fewer than three vertices, or all vertices reachable from a vertex?
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: Adjacency and self-loops require selection/projection on Adj. A cycle of a fixed bounded length can be described by a fixed number of renamed joins and equality tests.
Step 2: Reachability permits paths of arbitrarily large length as the graph grows. Ordinary nonrecursive relational algebra has no transitive-closure operation; one fixed expression cannot supply an unbounded chain of joins.
Thus D cannot be expressed by a constant-length ordinary relational-algebra expression over all finite input graphs. Recursive query extensions or a fixed maximum graph size change that setting.
For relations r and s with A an attribute of r, simplify σ_(A=a)(r⋈s). Choices are σ_(A=a)(r), r, σ_(A=a)(r)⋈s, or none.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: The predicate A=a refers only to an attribute of r. A joined tuple survives the selection exactly when its r component has that value.
Step 2: Rejecting the failing r tuples before joining therefore removes exactly the same joined tuples: σ_(A=a)(r⋈s)=σ_(A=a)(r)⋈s. This is C.
Dropping s altogether can lose its attributes and its filtering effect, so neither r nor its selected subset alone is generally equal to the joined result.
Count four-digit even decimal numbers whose four digits are distinct. Options are 2240,2296,2620,4536.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Separate the final digit 0 from the other even digits. If the last digit is 0, the first digit has 9 choices and the middle positions have 8 and 7, giving 9·8·7=504.
Step 2: If the last digit is one of 2,4,6,8, there are 4 choices. The first digit can be any nonzero digit except that last digit:8 choices. The middle positions then have 8 and 7 choices, including zero if unused. This gives 4·8·8·7=1792.
Total 504+1792=2296, B. Counting all even last digits uniformly would mishandle leading zero.
Existence statements about infinite sets and irrationals
Sets, Relations & Functions
Tap to enlarge
Assess two existence claims: infinite sets A,B,C can have finite A∩(B∪C); irrational numbers x,y can have rational x+y. Choices distinguish only the first, only the second, both, or neither.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Let A be the nonnegative even integers and B=C the positive odd integers. All three sets are infinite, while A∩(B∪C)=∅ is finite. Thus S1 is possible. The problem does not require B and C to differ.
Step 2: Choose x=√2 and y=−√2. Both are irrational and their sum is the rational number 0. Thus S2 also holds.
Therefore both existence statements are true, C. Infinite input sets need not have an infinite intersection, and irrational numbers can cancel.
For any function f:A→B and subsets E,F⊆A, assess f(E∪F)=f(E)∪f(F) and f(E∩F)=f(E)∩f(F). Choices distinguish only the first, only the second, both, or neither.
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: A value lies in f(E∪F) exactly when it is f(x) for some x in E or F. This is exactly membership in f(E)∪f(F), proving S1 for every function.
Step 2: Intersection gives only f(E∩F)⊆f(E)∩f(F) in general. Take E={a},F={b},a≠b, and a constant function with f(a)=f(b)=0. The left side is empty, but the right side is{0}.
Thus S2 need not hold and only S1 is universally correct, A. Injectivity would make the intersection equality valid.
Seven distinct accidents occur during one week. Find the probability that all occur on one day, using and explicitly stating the conventional day-assignment model. Options: 1/7^7, 1/7^6, 1/2^7, 7/2^7.
Your answer
Answer & solution
Answer: B under independent uniform day assignments (no official key was published)
Step 1: Treat the seven distinct accidents as independent choices among seven equally likely days. There are 77 equally likely day assignments.
Step 2: Exactly seven assignments put every accident on the same day, one for each possible day. The probability is 7/77=1/76, B. Equivalently, leave the first accident’s day unrestricted and require each of the other six to match it.
The independence/uniformity model is not explicit in the source. Real accident rates or correlated events need not give this probability; seven events occurring in a week alone does not determine it.
Find the minimum DFA size over {a,b} accepting exactly strings whose a-count is divisible by 6 and b-count by 8. Options: 8,14,15,48.
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: Store a pair(i,j), where i is the number of a symbols modulo 6 and j the number of b symbols modulo 8. Reading a increments only i; reading b increments only j. Accept(0,0). This constructs 6·8=48 states.
Step 2: Every pair is reached by ai bj. For two distinct pairs, append a number of a and b symbols that brings the first pair to(0,0). The second pair retains a nonzero difference in at least one residue and rejects. Thus all pairs are distinguishable.
The construction is minimal, giving 48, D, not the sum 6+8.
Which languages are regular? L1={ww:w∈{a,b}*}; L2={ww^R:w∈{a,b}*}; L3={0^(2i)}; L4={0^(i²)}, interpreting valid nonnegative lengths. Choices: L1/L2; L2/L3/L4; L3/L4; only L3.
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: L3 contains even-length unary strings, recognized by a two-state parity machine. Interpreting only nonnegative string lengths, negative integer parameters do not add new words.
Step 2: L1={ww} is nonregular: prefixes an b are pairwise distinguishable, since suffix an b makes a square with that prefix but not with am b for m≠n. L2={wwR} is nonregular: prefixes an b are distinguished by suffix b an; the resulting word am bb an is an even palindrome exactly when m=n.
Step 3: L4 has square unary lengths. For pumping length p, pump a nonempty segment of length k≤p in 0p². Pumping once more gives length p²+k strictly between consecutive squares p² and(p+1)², contradiction.
Given a Turing machine M, input w, and state q, ask whether M’s computation on w ever visits q. Is this decidable, undecidable but partially decidable, not even partially decidable, or not a decision problem?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Simulate M on w and accept as soon as q is visited. Every yes instance is eventually accepted; a no instance may run forever. This proves partial decidability.
Step 2: Reduce the halting problem: construct a simulator that enters a fresh designated state q exactly when the simulated machine halts. A decider for state visitation would decide halting, impossible.
Hence X is undecidable but partially decidable, B. It is a decision problem because the required answer is yes/no, regardless of whether an algorithm always produces that answer.
Two positive-edge D flip-flops start at Q0=Q1=0. Their inputs are D0=X and D1=X·¬Q0; output Y=Q1. Setup time is 20 ns, hold time zero, and clock period at least 40 ns. The figure shows X rising after the first clock rising edge and falling before the sixth. Select the output trace: A one-cycle pulse from the second to third edge; B high from first to third; C first to second; D later sustained high. Exact timing drawing remains linked.
Your answer
Answer & solution
Answer: A under the ideal synchronous timing model (no official key was published)
Step 1: At each positive clock edge, Q0_next=X and Y_next=X·¬Q0_old. Both flip-flops sample old pre-edge signals, so the second stage cannot use the newly updated Q0 in the same sampling event.
Step 2: Initially Q0=Y=0. X rises after the first shown rising clock edge. At the next rising edge X=1 while old Q0=0, so Q0 becomes 1 and Y becomes 1. At the following rising edge X remains 1 but old Q0=1, so Y becomes 0. Later edges keep Y low, including after X falls.
Thus Y has one clock-period pulse starting at the second rising edge, plot A. The displayed separation is interpreted as meeting the 20 ns setup requirement, with negligible unprovided gate/clock-to-Q delays; period alone would not guarantee timing for an arbitrarily placed X transition.
Match indirect, indexed, and base-register addressing to passing an array as a parameter, implementing an array, and relocatable code. Option A pairs indirect with parameter passing, indexed with arrays, and base-register with relocation; the other choices permute these assignments.
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: Passing an array by address gives a pointer to its elements; indirect addressing accesses memory through that pointer, matching X with III.
Step 2: Indexed addressing combines an array base with an index/offset, matching Y with I. Base-register addressing expresses locations relative to a relocatable base; changing that base allows the same relative offsets to address relocated code/data, matching Z with II.
Choose the three-hex-digit two’s-complement representation of decimal −539 from ABE,DBC,DE5,9E7.
Your answer
Answer & solution
Answer: C for the displayed 12-bit width (no official key was published)
Step through it (5 steps)
Step 1: Convert 539 to hexadecimal:539=2·256+1·16+11=21B₁₆. The three-hex-digit answer options imply 12 bits.
Step 2: Complement each hex digit to F, giving DE4, then add one to obtain DE5. Independently,1000₁₆−021B₁₆=0DE5₁₆.
Thus C. A wider representation would sign-extend with leading F digits; two’s-complement representation is width-dependent, so DE5 is interpreted using the options’ width.
A 2:1 mux computes ac′+bc. First mux has a=1,b=0,c=x1. Its output supplies a of a second mux, whose b=x1 and c=x2. Choose f from x1′+x2; x1′x2+x1x2′; x1x2+x1′x2′; x1+x2′.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: The supplied mux equation is output=a·c′+b·c. In the first mux a=1,b=0,c=x1, so its output g=x1′.
Step 2: The second mux has a=g,b=x1,c=x2. Substitute to obtain f=x1′x2′+x1x2, an XNOR function.
Thus C. Its truth table is 1,0,0,1 for inputs 00,01,10,11, which also distinguishes it from XOR and the single-disjunction options.
A synchronous three-bit register starts Q0=1,Q1=Q2=0. Wiring gives D0=Q1 XOR Q2,D1=Q0,D2=Q1. State number is 4Q2+2Q1+Q0. Choose cycle A 1,3,4,6,7,5,2; B 1,2,5,3,7,6,4; C 1,2,7,3,5,6,4; D 1,6,5,7,2,3,4.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Read the wiring as Q0_next=Q1 XOR Q2, Q1_next=Q0, Q2_next=Q1, all using the old state. The displayed numeric state is 4Q2+2Q1+Q0.
Step 2: Starting 001, successive triples are 010,101,011,111,110,100, then 001 again. For example 010 gives new Q0=1 XOR 0=1,new Q1=0,new Q2=1, hence 101.
Thus the decimal cycle is 1,2,5,3,7,6,4, option B. Computing updates in place rather than simultaneously would produce a different, incorrect sequence.
An unpipelined CPU has an 8-bit bus, ALU, general registers and MDR, but 16-bit SP and MAR. Byte-select mux/demux connect SP and MAR to the bus; memory operations take two cycles; SP can decrement locally. For push r, perform M[SP]←r then SP←SP−1. How many execution cycles: 2,3,4,5? The complete datapath is linked.
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: The 16-bit SP must be copied to 16-bit MAR through an 8-bit bus. This requires two distinct bus transfers, one per byte, using the mux/demux controls.
Step 2: Copy the 8-bit register r to MDR in a third cycle. The memory write then uses two cycles with MAR supplying the address and MDR the byte. SP can be decremented locally in parallel after its old value has been transferred, so no additional bus cycle is needed for that decrement.
Total 2+1+2=5 cycles, D, in the standard clocked-transfer schedule with memory write starting after MAR/MDR are loaded. Instruction-fetch cycles are not part of this execution count.
In BFS from r in an undirected unweighted graph, vertex u is visited before v. Must d(r,u)<d(r,v), >, ≤, or none of these?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Breadth-first search’s FIFO queue processes all vertices at distance k before any vertex at distance k+1. Thus dequeue/discovery order is nondecreasing in distance from r.
Step 2: Two distinct vertices in the same layer can occur in either order, so visiting u first does not imply a strict inequality. A star centered at r supplies such an equal-distance example.
Therefore d(r,u)≤d(r,v), C, for vertices reached by this BFS. Unreachable vertices are not visited by the traversal from r.
How many undirected graphs can be formed on a fixed labeled set of n vertices, without requiring connectedness? Choices: n(n−1)/2, 2^n, n!, 2^[n(n−1)/2]. State the simple loop-free graph convention.
Your answer
Answer & solution
Answer: D under the simple loop-free convention (no official key was published)
Step 1: The fixed labeled vertex set has binomial(n,2)=n(n−1)/2 possible unordered pairs of distinct vertices. Each pair can independently be an edge or not.
Step 2: Multiplying these two choices for every pair gives 2^[n(n−1)/2], D. Connectedness is not imposed, so no edge subsets are excluded.
This is the conventional simple loop-free graph model. Permitting loops adds n binary choices, and permitting unrestricted parallel edges would remove this finite count. The fixed labels mean we are not quotienting by graph isomorphism.
Under the usual stack-only auxiliary-storage model, what is the minimum number of size-n stacks needed to implement a size-n queue: one, two, three, or four?
Your answer
Answer & solution
Answer: B under the standard auxiliary-storage model (no official key was published)
Step 1: Push new elements onto an input stack. To dequeue, pop from an output stack; when that stack is empty, move all input elements to it. The reversal places the oldest element on top, so two stacks suffice.
Step 2: With only one LIFO stack and O(1) other element storage, reaching the oldest of n elements requires removing and retaining n−1 newer elements somewhere, so the usual general implementation needs the second stack.
Hence B in this model. A recursive “one explicit stack” implementation uses the call stack as another unbounded stack; allowing an auxiliary array or such hidden storage changes what is being counted.
Caller variables begin x=10,y=3 and call func1(y,x,x) by reference, then print x,y. The callee’s formals are x,y,z and execute y=y+4; z=x+y+z. Choose 10,3; 31,3; 27,7; or none.
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Rename the caller variables X=10,Y=3 to avoid confusing them with formal names. The call func1(Y,X,X) makes formal x alias Y, while both y and z alias the same caller variable X.
Step 2: y=y+4 changes X from 10 to 14. Then z=x+y+z reads 3+14+14=31 and stores 31 in X. Y is never assigned and remains 3.
The caller prints 31 and 3, B. Treating y and z as separate copies would miss the aliasing effect; this is reference-passing pseudocode, not ordinary C scalar call-by-value.
Three C functions return int pointers. P1 returns &x for automatic local int x=10. P2 declares uninitialized int *px, stores *px=10, then returns px. P3 allocates sizeof(int) with malloc, stores 10 through the pointer, and returns it. Which have pointer problems: only P3; P1/P3; P1/P2; all three? Distinguish the intended successful-allocation model from failure handling.
Your answer
Answer & solution
Answer: C under successful allocation for P3 (no official key was published)
Step 1: P1 returns the address of an automatic local int. Its lifetime ends when the function returns, so the returned pointer cannot be used to access that former object.
Step 2: P2 declares an uninitialized pointer and immediately writes through it. No valid target object has been established, causing undefined behavior.
Step 3: P3 allocates sizeof(int), writes 10 into the allocated object, and returns its pointer. Successfully allocated storage remains alive until freed, even after the function returns. Thus the intended contrast is P1 and P2, C.
Practical qualification: P3 must check malloc’s result before dereferencing it and the caller must eventually free it. If allocation fails, the unchecked P3 is also erroneous; appropriate declarations/headers are assumed.
Program P2 has outer n=10. Procedure D declares local n=3 and calls W(n). W takes x by reference, increments x, and prints x. Under dynamic scoping, choose output 10,11,3, or none.
Your answer
Answer & solution
Answer: D; the value printed is 4 (no official key was published)
Step 1: The outer n is set to 10, but procedure D declares its own n and sets it to 3. At the call W(n), the actual argument is that active local variable.
Step 2: Reference passing binds W’s x to D’s n. Executing x=x+1 changes it from 3 to 4; print x therefore prints 4. The outer n remains 10.
Since the listed numeric choices are 10,11,3, the answer is none of these, D. The formal binding already identifies the object, so dynamic scope does not redirect x to the outer n.
Which is not itself an interrupt source for a running process: a device, a timer, the scheduler process, or a detectable power failure?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Devices and timers can raise hardware interrupts; some systems also signal impending power failure through an interrupt or exception mechanism. These events transfer control away from a running process.
Step 2: A scheduler is software invoked after the kernel receives control, for example following a timer interrupt, blocking operation, or termination. It chooses the next runnable process but is not itself the independent hardware interrupt source.
Thus C in the conventional uniprocessor model. A complete abrupt loss of power may stop execution without a graceful interrupt, so the power-failure option presumes a detectable failure signal.
A machine has 64 MiB physical memory, 32-bit virtual addresses, and 4 KiB pages. Estimate a flat page-table size from choices 16,8,2,24 MiB, and state the necessary page-entry-size assumption.
Your answer
Answer & solution
Answer: C under a two-byte-entry assumption (no official key was published)
Step 1: A 4 KiB page has 12 offset bits. A 32-bit virtual address therefore has 20 virtual-page bits, requiring 220 entries in a full single-level page table.
Step 2: Physical memory 64 MiB=226 bytes contains 214 frames, so a physical frame number needs 14 bits. Rounding that field to two bytes gives 220·2=2 MiB, option C, with only limited room for additional status bits.
Qualification: The entry size and organization are not specified. Four-byte entries would require 4 MiB, not listed; multilevel allocation can use a different amount. Therefore 2 MiB is a conventional estimate, not uniquely determined by the stated capacities alone.
In Peterson’s entry code for process i: set flag[i]=true; turn=j; while(P) wait; enter critical section; then clear flag[i]. Choose P: flag[j] AND turn=i; flag[j] AND turn=j; flag[i] AND turn=j; flag[i] AND turn=i. Distinguish progress from safety alone.
Your answer
Answer & solution
Answer: B for Peterson mutual exclusion with progress (no official key was published)
Step 1: Process i announces intent with flag[i]=true and sets turn=j, yielding priority to j. It should wait only while j also wants entry and j has priority: flag[j] AND turn=j, option B.
Step 2: If both flags are true, the last write to turn selects one waiting process and lets the other enter. If j leaves, it clears flag[j], immediately releasing i’s wait regardless of turn. Atomic reads/writes and sequentially consistent ordering are assumed.
Qualification: The literal question mentions only mutual exclusion. Option C, testing its own flag with turn=j, can preserve exclusion while blocking a lone entrant forever. It is not Peterson’s correct solution because progress fails. B is the predicate satisfying the intended full critical-section requirements.
Which FD set on R(A,B,C,D) does not admit a lossless, dependency-preserving BCNF decomposition? A: A→B,B→CD. B: A→B,B→C,C→D. C: AB→C,C→AD. D: A→BCD.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: For option C, AB→C and C→AD imply AB and BC are keys. Yet C alone does not determine B, so C→A and C→D violate BCNF. Decomposition into CAD and BC is lossless because their intersection C determines CAD, but it loses local enforcement of AB→C.
Step 2: Any relation containing A,B,C is not BCNF: it retains C→A while C is not a key. Without such a relation, projected dependencies cannot derive C from AB; no proper smaller attribute subset provides that dependency. Thus no dependency-preserving BCNF decomposition exists.
The other options admit lossless preserving choices: AB and BCD for A; AB,BC,CD for B; and the original already-BCNF relation for D. Hence C.
Which tuple-calculus expression is unsafe? A binds t[A] to an R1 value absent from R2. B says for every u∈R1, u[A]=constant x implies some s∈R2 has t[A]=s[A] and s[A]=u[A]. C is {t:¬(t∈R1)}. D binds t[A] to values present in both relations. Examine empty/unguarded cases as well as the obvious complement; exact formulas remain linked.
Your answer
Answer & solution
Answer: C is unsafe; B is also unsafe as literally printed (no official key was published)
Step 1: C returns all tuples outside R1. Over an unrestricted infinite domain and finite R1, this produces an unbounded complement, so it is unsafe. A and D bind the returned A-value to existing relation values, under the intended one-attribute result interpretation.
Step 2: B universally quantifies u in R1 and guards the existential restriction on t with u[A]=the constant x. If R1 is empty, or contains no tuple with that A-value, every implication is vacuously true. Then t is unconstrained and arbitrary outside-domain values satisfy the expression. Thus B is also not domain-independent.
This is a literal second-unsafe-option issue confirmed in the paper, not an official-key correction. Adding an existence requirement for the guarded R1 value would change the question.
Recursive deletion through a self-referencing foreign key
Database Models, Architecture & ER Diagrams
Tap to enlarge
Table geq has nonnull integer lb,ub, primary key lb, and self-referencing foreign key ub with ON DELETE CASCADE. Every row(x,y) obeys y≥x. On deleting(x,y), can a cascaded row(z,w) have z>y, z>x, or w<x, or must deletion be prohibited?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Deleting parent key x directly cascades to rows(z,w) with w=x. Since every row obeys w≥z, these direct children have z≤x. Cascades continue to their children, so keys along a deletion chain cannot increase. Options requiring z>x or z>y≥x are therefore impossible.
Step 2: A deeper descendant can have w<x. For example the legal rows(3,3),(2,3),(1,2) satisfy the ordering and foreign key. Deleting(3,3) cascades to(2,3) and then(1,2), whose upper value 2 is less than the original x=3.
Thus C is possible. ON DELETE CASCADE means the mere presence of dependent rows does not prohibit the deletion; self-reference is handled by the database’s cascade semantics.
Answer: h is injective. (no official key was published)
1. Assume h(a,b)=h(c,d). Adding 1 gives (2a+1)2b=(2c+1)2d, where both parenthesized factors are odd positive integers.
2. If b<d, divide by 2b. The left side is odd and the right side, (2c+1)2d−b, is even, a contradiction. The symmetric argument rules out d<b.
3. Thus b=d. Cancelling 2b gives 2a+1=2c+1, so a=c.
4. Equality of images has forced equality of both coordinates, exactly the definition of injectivity. The argument also covers zero coordinates, since 20=1 and 2·0+1 is odd.
Answer: For n≥0, write n+1=u2^b with u odd; its preimage is ((u−1)/2,b). (no official key was published)
1. Take an arbitrary target n∈N. The positive integer n+1 can be repeatedly divided by 2 until an odd number u remains. This terminates because positive integers strictly decrease at each division.
2. If b divisions were made, then n+1=u2b, with b≥0 and u≥1 odd. Define a=(u−1)/2, which is a nonnegative integer.
3. Then h(a,b)=(2a+1)2b−1=u2b−1=n. Thus every target has a preimage in N×N, establishing surjectivity.
4. For example n=11 gives n+1=12=3·2², so (a,b)=(1,2). For n=0 the preimage is (0,0). Combined with injectivity, h is a bijection.
Alphabet {a,b}; accept precisely strings containing baab as a contiguous substring.
Task: Construct a DFA for this language.
Shared context
Alphabet {a,b}; accept precisely strings containing baab as a contiguous substring.
Answer & solution
Answer: Start q0; accepting q4. Transitions on (a,b): q0→(q0,q1), q1→(q2,q1), q2→(q3,q1), q3→(q0,q4), q4→(q4,q4). (no official key was published)
Step through it (2 parts)
1. Use states to remember the longest suffix of the input read so far that is also a prefix of baab: q0 remembers ε, q1 remembers b, q2 remembers ba, and q3 remembers baa. q4 means the complete substring has already occurred.
2. From q0, a contributes no matching prefix and b starts one: δ(q0,a)=q0, δ(q0,b)=q1. From q1, a extends b to ba, while another b starts a fresh b: δ(q1,a)=q2, δ(q1,b)=q1.
3. From q2, a extends ba to baa; b leaves the suffix b. Thus δ(q2,a)=q3, δ(q2,b)=q1. From q3, b completes baab and a destroys every nonempty matching suffix: δ(q3,b)=q4, δ(q3,a)=q0.
4. Both transitions from q4 loop to q4, since later symbols cannot remove an occurrence already seen. Set start q0 and accepting set {q4}. The trace baab is q0→q1→q2→q3→q4; baa alone ends in nonaccepting q3.
Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.
Task: Construct a DFA for this language.
Shared context
Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.
Answer & solution
Answer: Four parity states EE, OE, EO, OO; start EE, sole accepting OO. a toggles first component, b toggles second. (no official key was published)
Step through it (2 parts)
1. Only the two parities matter, so use states (parity of a count, parity of b count). The empty string has counts zero and zero, making EE the start state.
2. Reading a increments only the a count and toggles its parity. Reading b toggles only the b parity. Complete transition table on (a,b): EE→(OE,EO); OE→(EE,OO); EO→(OO,EE); OO→(EO,OE).
3. Mark only OO accepting. By induction on the processed prefix, the stored pair equals its two actual count parities: the base is EE and every transition applies the correct single parity toggle.
4. Therefore a string is accepted exactly when both counts are odd. For instance ab ends in OO, whereas aab ends in EO and is rejected.
Answer: Push two X markers per a, consume one per b after c, accept only on exhaustion of markers and input. (no official key was published)
1. Use stack alphabet {Z,X} with bottom marker Z, and states q0 (start), qA (a phase), qB (b phase), qF (sole accepting state). Stack top is written at the left. A transition (q,s,T)→(p,γ) consumes s and replaces top T by γ.
2. Define δ(q0,a,Z)=(qA,XXZ); δ(qA,a,X)=(qA,XXX); δ(qA,c,X)=(qB,X); δ(qB,b,X)=(qB,ε); δ(qB,ε,Z)=(qF,Z). All unspecified transitions reject. Accept by final state only after all input is consumed.
3. The first a is required to leave q0, enforcing n≥1. Each subsequent a replaces one X with three, a net push of two; after n a symbols there are exactly 2n markers. The unique c switches irreversibly to qB.
4. Each b pops one X. Exactly 2n b symbols expose Z, allowing the ε-move to qF. Too few leave the PDA nonaccepting; extra input cannot be consumed from qF. Wrong symbol order has no transition.
5. Determinism holds because qB has a b transition only with top X and an ε-transition only with top Z; no fixed state/top pair offers both an ε-transition and an input transition.
X asks whether a Turing machine M loops forever on input w. The halting problem H is assumed undecidable but partially decidable.
Task: Prove that X is undecidable.
Shared context
X asks whether a Turing machine M loops forever on input w. The halting problem H is assumed undecidable but partially decidable.
Answer & solution
Answer: X is undecidable. (no official key was published)
1. For a fixed valid encoding ⟨M,w⟩, exactly one possibility holds: M halts on w, or it runs forever. Thus X is the complement of H on valid encodings.
2. Assume a decider D for X exists. A decider always terminates and correctly answers both yes and no instances.
3. Construct a halting decider by running D on ⟨M,w⟩ and reversing its answer. If D says loops forever, answer does not halt; if D says does not loop forever, answer halts.
4. This new algorithm terminates on every input because D does, contradicting the assumed undecidability of H. Therefore no such D exists. Mere simulation does not refute this result: observing a halt is possible, but waiting forever is not a terminating negative test.
X asks whether a Turing machine M loops forever on input w. The halting problem H is assumed undecidable but partially decidable.
Task: Prove that X is not even partially decidable.
Shared context
X asks whether a Turing machine M loops forever on input w. The halting problem H is assumed undecidable but partially decidable.
Answer & solution
Answer: X is not partially decidable (not recursively enumerable). (no official key was published)
1. Partial decidability means a recognizer must halt and accept every yes instance, but may run forever on no instances. Let R_H be the given recognizer for halting, and suppose a recognizer R_X for nonhalting also exists.
2. On the same encoding ⟨M,w⟩, dovetail the two recognizers: execute one step of R_H, then one step of R_X, repeatedly. Do not run either one to completion before starting the other.
3. If R_H accepts, answer halts; if R_X accepts, answer does not halt. Since H and X partition valid machine-input pairs, precisely the appropriate recognizer is guaranteed eventually to accept.
4. The combined computation therefore always terminates with a correct answer, deciding H. This contradicts undecidability. Hence X is not even partially decidable, although its complement H is.
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Task: Find the total capacity of the disk.
Shared context
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Answer & solution
Answer: 320,000 KB = 327,680,000 bytes = 312.5 MiB. (no official key was published)
1. Count all sectors: 20 surfaces × 1000 tracks per surface × 16 sectors per track = 320,000 sectors. The units cancel to sectors, so rotation speed is irrelevant to capacity.
2. Each sector stores 1 KB=1024 bytes. Total capacity is 320,000×1024=327,680,000 bytes.
3. Dividing by 1024² yields 312.5 MiB, often written 312.5 MB under the historical binary convention. Under modern decimal units it is 327.68 MB.
4. The result uses the stated formatted sector payload and does not add hypothetical gaps or disk-controller overhead absent from the problem.
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Task: Find the data transfer rate.
Shared context
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Answer & solution
Answer: 819,200 bytes/s = 800 KiB/s. (no official key was published)
2. A selected track contains 16 sectors ×1024 bytes =16,384 bytes per revolution. Streaming transfer rate is 16,384×50=819,200 bytes/second, or 800 KiB/second.
3. Do not multiply by 20 surfaces: the described single serial transfer channel reads the selected track, not every surface simultaneously.
4. The byte interval is 1/819,200 seconds≈1.220703 μs. This is the sustained transfer rate once positioned, not an average including unspecified seek and rotational waiting times.
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Task: Find the percentage of CPU time required for byte-wise interrupt-driven transfer.
Shared context
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Answer & solution
Answer: 40.96% of CPU time during sustained disk transfer. (no official key was published)
1. The sustained disk rate is 50×16×1024=819,200 bytes/s. Each byte causes its own interrupt, so there are 819,200 interrupts per second of streaming transfer.
2. For each byte the CPU pays both 0.4 μs interrupt overhead and 0.1 μs memory read/write time. Total CPU service is 0.5 μs/byte.
3. CPU busy time per elapsed second is 819,200×0.5 μs=409,600 μs=0.4096 seconds. Therefore utilization is 0.4096×100=40.96%.
4. Counting only the interrupt overhead would give 32.768% and omit the specified data transfer cost. The remaining time can be used for unrelated computation under the stated model.
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Task: Find the maximum percentage of CPU time held up by cycle-stealing DMA.
Shared context
Disk: 20 surfaces, 1000 tracks/surface, 16 sectors/track, 1 KB/sector, 3000 rpm; transfer one byte at a time. For CPU calculations memory transfer costs 0.1 μs/byte, interrupt overhead 0.4 μs/byte, DMA setup negligible and requests always granted. Use 1 KB=1024 bytes.
Answer & solution
Answer: Maximum CPU hold-up is 8.192% during sustained transfer. (no official key was published)
1. Cycle-stealing DMA transfers each byte directly between the device and memory. It does not invoke the CPU once per byte, so the 0.4 μs interrupt overhead does not apply.
2. The memory bus is taken for the specified 0.1 μs per byte. At 819,200 bytes/s, DMA occupies memory for 819,200×0.1 μs=81,920 μs per second.
3. If every stolen cycle would otherwise have been useful to the CPU, the CPU is held up for the full 0.08192 seconds per second: 8.192%. This is the requested maximum.
4. Actual processor slowdown can be lower if some stolen bus cycles overlap times when the CPU needs no memory service. Initialization and termination costs are excluded because the question explicitly makes them negligible.
32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.
Task: Find the tag-field width per block.
Shared context
32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.
Answer & solution
Answer: 16 tag bits per block. (no official key was published)
Step through it (7 steps)
1. An address separates into tag, set index, and byte offset. The 16-byte block needs log₂16=4 offset bits.
2. There are (256×1024)/(4×16)=4096 sets, so the set index needs log₂4096=12 bits.
3. The remaining bits are tag bits: 32−12−4=16. In bit positions, tag=A31…A16, set=A15…A4, byte offset=A3…A0.
4. Associativity affects the number of sets and hence the tag width. There is no address field selecting a way; the stored tags determine which of the four candidate ways matches.
32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.
Task: Find the number and size of comparators for tag matching.
Shared context
32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.
Answer & solution
Answer: Four 16-bit equality comparators for a parallel four-way lookup. (no official key was published)
1. The 12 index bits select one set containing four candidate cache blocks. The requested block may occupy any of those four ways.
2. The incoming 16-bit tag must be compared with each of the four stored 16-bit tags. A standard parallel lookup therefore uses four comparators, each comparing two 16-bit quantities.
3. Each comparator produces one match bit, normally qualified by the corresponding valid bit. The hit way selects its data.
4. Comparators for every cache block are unnecessary because the index has already selected one set. A serial implementation could reuse hardware with additional latency, but the conventional associative lookup requested here is parallel.
32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.
Task: Find total extra memory in bytes required for tag bits.
Shared context
32-bit byte addresses; cache data capacity 256 KB=2^18 bytes; 4-way set associative; 16-byte blocks.
Answer & solution
Answer: 32,768 bytes = 32 KiB for tags only. (no official key was published)
Step through it (8 steps)
1. Total cache blocks equal 256×1024/16=16,384. Every resident block requires its own tag even though blocks share a set index.
2. Each tag has 32−12−4=16 bits. Thus tag storage is 16,384×16=262,144 bits.
3. Convert bits to bytes by dividing by 8: 262,144/8=32,768 bytes, or 32 KiB.
4. This is only the requested tag-bit memory. Valid bits, dirty bits, and replacement metadata would add storage, but their costs are not part of the tag-only question and are not silently included.
f(x,y,z)=Σm(0,1,2,4). Determine whether f is self-dual.
Task: Decide whether f is self-dual and justify the answer.
Shared context
f(x,y,z)=Σm(0,1,2,4). Determine whether f is self-dual.
Answer & solution
Answer: Yes; f(x,y,z)=¬f(¬x,¬y,¬z). (no official key was published)
1. Self-duality requires complementary input vectors to produce complementary outputs. For three variables, complementing every input bit maps minterm index i to 7−i.
2. The complementary pairs are (0,7), (1,6), (2,5), and (3,4). The given on-set {0,1,2,4} contains exactly one member of each pair.
3. Thus whenever f is 1, its complementary input has value 0; and whenever f is 0, its complementary input has value 1. This proves the identity for all eight input vectors.
4. Having four ones alone would not prove self-duality: their distribution across complement pairs matters. Here all four pairs satisfy the required condition.
Input bits e8,e4,e2,e1 encode decimal d as d+3 (valid codes 3…12); output b4 is the weight-4 BCD bit. Diagram has four excess-3 input lines and four BCD outputs b8,b4,b2,b1. GFG explicitly requests b4; GateForum omits the subscript in its prose.
Task: Give a minimal product-of-sums expression for b4.
Shared context
Input bits e8,e4,e2,e1 encode decimal d as d+3 (valid codes 3…12); output b4 is the weight-4 BCD bit. Diagram has four excess-3 input lines and four BCD outputs b8,b4,b2,b1.
Answer & solution
Answer: b4=(¬e4+e1)(¬e4+e2)(e4+¬e2+¬e1). (no official key was published)
1. For decimal digits d=0…9, the weight-4 BCD bit is 1 exactly for d=4,5,6,7. Their excess-3 inputs are 7,8,9,10. Hence the on-set is {7,8,9,10}; the valid zero-set is {3,4,5,6,11,12}. Codes {0,1,2,13,14,15} are don’t-cares.
2. For a product-of-sums minimize groups of zeros, permitting invalid codes as don’t-cares. The group e4=1,e1=0 covers zero codes 4,6,12 and don’t-care 14, giving the clause ¬e4+e1.
3. The group e4=1,e2=0 covers 4,5,12 and don’t-care 13, giving ¬e4+e2. The pair 3,11 has e4=0,e2=1,e1=1 while e8 varies, giving e4+¬e2+¬e1.
4. Multiplying these clauses covers every required zero and no required one. The e8 input disappears because the chosen groups span both of its values.
5. To check minimality without claiming these groups are all essential, enumerate the maximal zero/don’t-care cubes (bit order e8,e4,e2,e1; dash means either value): -011, -1-0, -10-, 0--0, 0-0-, 00--, 1-11, 11--. Their covered required zeros are respectively {3,11}, {4,6,12}, {4,5,12}, {4,6}, {4,5}, {3}, {11}, {12}. This includes the legal alternative cube {0,1,2,3}; zero 3 is not restricted to pairing with 11.
6. Every clause must avoid all required one-codes. No single zero cube can cover any pair among required zeros 5,6,11: the smallest cube spanning each such pair contains code 7, a required one. At least three clauses are therefore necessary. The maximal cubes listed above have at most four cells, so every nonredundant clause has at least two literals. A cube covering zero 11 has at most two cells (the only choices are -011 and 1-11), so its clause needs at least three literals. Any POS consequently needs at least 3+2+2=7 literals; four or more clauses need at least eight. The displayed three-clause, seven-literal POS attains both lower bounds. Other minimum covers exist; its three chosen prime groups are not all essential.
Initially copy input bits. After two consecutive input zeros, complement following bits; after two consecutive input ones while complementing, return to copying. The triggering second bit still uses the old mode. Use J-K flip-flops.
Task: Give the state transition diagram (specified here by a complete labeled transition table).
Shared context
Initially copy input bits. After two consecutive input zeros, complement following bits; after two consecutive input ones while complementing, return to copying. The triggering second bit still uses the old mode. Use J-K flip-flops.
Answer & solution
Answer: Four-state Mealy machine A,B,C,D with transitions A:0/0→B,1/1→A; B:0/0→C,1/1→A; C:0/1→C,1/0→D; D:0/1→C,1/0→A. (no official key was published)
1. Define A as copy mode with no pending zero, B as copy mode after one zero, C as complement mode with no pending one, and D as complement mode after one one. Start at A. Edge labels are input/output.
2. In copy mode output equals input. Thus A on 0 emits 0 and moves to B; A on 1 emits 1 and stays A. B on 1 emits 1 and resets to A; B on 0 emits 0 and moves to C because the second zero has just occurred.
3. In complement mode output is inverted. Thus C on 0 emits 1 and stays C; C on 1 emits 0 and moves to D. D on 0 emits 1 and resets to C; D on 1 emits 0 and returns to A after the second one.
4. The transition-triggering symbol is processed using the old mode, matching the printed example: input 101100|01001011|0|11 gives output 101100|10110100|0|11.
5. These four states record exactly the information needed: the current mode and whether the first symbol of its switching pair has been seen. Runs of the nontriggering symbol reset the pending-pair state.
Initially copy input bits. After two consecutive input zeros, complement following bits; after two consecutive input ones while complementing, return to copying. The triggering second bit still uses the old mode. Use J-K flip-flops. Encode A=00, B=01, C=10, D=11 with mode bit M and pending-pair bit P. Input x; output y=x XOR M.
Task: Give minimized sum-of-products expressions for the J and K inputs of one state flip-flop.
Shared context
Initially copy input bits. After two consecutive input zeros, complement following bits; after two consecutive input ones while complementing, return to copying. The triggering second bit still uses the old mode. Use J-K flip-flops. Encode A=00, B=01, C=10, D=11 with mode bit M and pending-pair bit P. Input x; output y=x XOR M.
Answer & solution
Answer: For mode flip-flop: J_M=P¬x, K_M=Px. Optionally J_P=Mx+¬M¬x and K_P=1. (no official key was published)
1. Use the four-state transition table from part (a), encoding copy states A,B with M=0 and complement states C,D with M=1. P=1 denotes B or D, where a triggering first bit is pending.
2. A J-K flip-flop obeys Q⁺=J¬Q+¬KQ. To change 0→1 requires J=1 (K don’t-care); 0→0 requires J=0; 1→0 requires K=1 (J don’t-care); and 1→1 requires K=0.
3. When M=0, the mode changes to 1 only in B (P=1) on x=0. Therefore J_M=P¬x. For M=1, J_M is irrelevant and these excitation don’t-cares allow the M literal to be omitted.
4. When M=1, the mode changes to 0 only in D (P=1) on x=1. Therefore K_M=Px, likewise independent of M after using its don’t-cares. Each is a single two-literal product and is already minimized SOP.
5. For a complete implementation, P=0 changes to 1 precisely when x=M (A on 0 or C on 1), giving J_P=Mx+¬M¬x. From either P=1 state the next P is always 0, so K_P=1. Reset both bits to 0 and use y=x XOR M.
Five stages IF, ID, EX, MEM, WB; reads occur in second half of cycle, writes in first half. I1: sub r2,r3,r4; I2: sub r4,r2,r3; I3: sw r2,100(r1); I4: sub r3,r4,r2.
Task: Show all data dependencies among the four instructions.
Shared context
Five stages IF, ID, EX, MEM, WB; reads occur in second half of cycle, writes in first half. I1: sub r2,r3,r4; I2: sub r4,r2,r3; I3: sw r2,100(r1); I4: sub r3,r4,r2.
Answer & solution
Answer: RAW: I1→I2(r2), I1→I3(r2), I1→I4(r2), I2→I4(r4). WAR: I1→I2(r4), I1→I4(r3), I2→I4(r3). No WAW. (no official key was published)
1. List register accesses first: I1 reads r3,r4 and writes r2; I2 reads r2,r3 and writes r4; I3 reads r1,r2 and writes memory; I4 reads r4,r2 and writes r3.
2. A true (RAW) dependence connects an earlier writer to a later reader of that value. I1 supplies r2 to I2, I3 and I4. I2 supplies r4 to I4. These are the four true data dependencies.
3. For completeness, anti-dependencies (WAR) constrain later overwriting of earlier inputs: I1 reads r4 before I2 writes it; I1 and I2 read r3 before I4 writes it. These are I1→I2 on r4, I1→I4 on r3, and I2→I4 on r3.
4. No two instructions write the same register, so there are no output (WAW) dependencies. Only I3 accesses memory, so there is no inter-instruction memory dependence. WAR relations do not become hazards in this in-order five-stage pipeline, where reads precede later writes.
Five stages IF, ID, EX, MEM, WB; reads occur in second half of cycle, writes in first half. I1: sub r2,r3,r4; I2: sub r4,r2,r3; I3: sw r2,100(r1); I4: sub r3,r4,r2.
Task: Identify the data hazards.
Shared context
Five stages IF, ID, EX, MEM, WB; reads occur in second half of cycle, writes in first half. I1: sub r2,r3,r4; I2: sub r4,r2,r3; I3: sw r2,100(r1); I4: sub r3,r4,r2.
Answer & solution
Answer: Without forwarding, RAW hazards: I1→I2 on r2, I1→I3 on r2, I2→I4 on r4. I1→I4 is not a timing hazard. (no official key was published)
2. I1 writes r2 in cycle 5. I2 tries to read it in cycle 3 and I3 in cycle 4, both too early without forwarding. These two true dependencies create RAW hazards.
3. I2 writes r4 in cycle 6, while I4 reads r4 in cycle 5, producing the third RAW hazard.
4. I4 also depends on I1 for r2, but reads in the second half of cycle 5 after I1 writes in its first half. Therefore this dependency is safe under the explicit half-cycle timing.
5. WAR and WAW hazards do not arise in the given ordered pipeline. This list describes the original unstalled timing; adding stalls can incidentally eliminate later conflicts, so dependency and hazard should not be conflated.
Five stages IF, ID, EX, MEM, WB; reads occur in second half of cycle, writes in first half. I1: sub r2,r3,r4; I2: sub r4,r2,r3; I3: sw r2,100(r1); I4: sub r3,r4,r2.
Task: Determine whether forwarding can avoid all the hazards in this sequence.
Shared context
Five stages IF, ID, EX, MEM, WB; reads occur in second half of cycle, writes in first half. I1: sub r2,r3,r4; I2: sub r4,r2,r3; I3: sw r2,100(r1); I4: sub r3,r4,r2.
Answer & solution
Answer: Yes, with normal ALU forwarding and a forwarding path for the store data; no load-use stall is present. (no official key was published)
1. I1 computes its r2 result at the end of EX in cycle 3. I2 needs that value at EX in cycle 4, so forwarding from I1’s EX/MEM register to I2’s ALU input resolves the nearest RAW hazard.
2. I3 may have read a stale r2 during ID4, but its store value can be corrected by forwarding the I1 result from MEM/WB during I3’s EX5 into the store-data path. That corrected value is carried to MEM6 for the write. An equivalent appropriately staged store-data bypass also works.
3. I2 computes r4 at the end of EX4. I4 needs it during EX6; the value can be forwarded from I2’s MEM/WB register to I4’s ALU input. I4’s r2 operand is already correct from the same-cycle WB5/ID5 timing.
4. All producer results are available before their consumer execution or memory-use stages, so no bubble is required with these bypasses. None of the instructions is a load producing a value too late for an immediately following EX stage.
5. The qualification matters: an implementation forwarding only ALU inputs but not correcting the store-data path would not resolve I3’s stale store value. The yes answer assumes forwarding includes the needed store-data path, not an unspecified restricted implementation.
abc(s) returns at the null terminator; otherwise it calls abc(s+1) twice and then prints s[0]. main calls abc("123").
Answer & solution
Answer: 3323321 (no official key was published)
Step through it (33 steps)
Let F(s) be the string printed by a call. F(empty)=empty and F(cs)=F(s)F(s)c. Therefore F("3")="3", F("23")="3"+"3"+"2"="332", and F("123")="332"+"332"+"1"="3323321". The recursive calls finish before the current character is printed, so the initial character appears last. No spaces or newline are printed.
The preceding abc routine is called on a null-terminated string of n characters, excluding the terminator.
Answer & solution
Answer: 2^n − 1 characters (no official key was published)
For n=0 the function immediately returns and prints zero characters. For n>0 it makes two calls on length n−1 and prints one character itself. Thus C(0)=0 and C(n)=2C(n−1)+1. Expanding gives C(n)=1+2+4+…+2n−1=2n−1. Equivalently, induction substitutes C(n−1)=2n−1−1 to get 2n−1. The null-terminator calls contribute no output. For n=3 this predicts seven characters, agreeing with 3323321.
Insert 15,32,20,9,3,25,12,1 into an initially empty BST.
Answer & solution
Answer: Root 15; left subtree 9(3(1,∅),12); right subtree 32(20(∅,25),∅). (no official key was published)
Step through it (19 steps)
Use the rule smaller keys go left and larger keys go right. Insert 15 as root; 32 right of 15; 20 left of 32; 9 left of 15; 3 left of 9; 25 right of 20; 12 right of 9; 1 left of 3.
15
/ \
9 32
/ \ /
3 12 20
/ \
1 25
Accessible description: root 15 has children 9 and 32. Node 9 has children 3 and 12; node 3 has left child 1. Node 32 has left child 20, whose right child is 25. All other links are null. Inorder traversal 1,3,9,12,15,20,25,32 verifies the ordering.
Delete key 15 from the BST built by insertion order 15,32,20,9,3,25,12,1.
Answer & solution
Answer: Successor replacement yields root 20; predecessor replacement yields root 12. (no official key was published)
Choose inorder-successor replacement: the least key in the right subtree of 15 is 20. Copy 20 into the root and remove the old 20 node, reconnecting its right child 25 as the left child of 32.
20
/ \
9 32
/ \ /
3 12 25
/
1
Accessible description: root 20 has children 9 and 32; 9 has children 3 and 12; 3 has left child 1; 32 has left child 25. Alternatively, inorder-predecessor replacement uses 12 as root and removes the old leaf 12. That result is 12(9(3(1,∅),∅),32(20(∅,25),∅)). Both are valid because the question does not prescribe which replacement policy to use.
depth(t) returns 0 for NULL, sets x=depth(t->left), then needs S1, S2 and S3 to return the tree depth.
Answer & solution
Answer: S1: y=depth(t->right); S2: x+1; S3: y+1. (no official key was published)
The null-tree base case fixes depth as the number of nodes on a longest root-to-leaf path. Each nonempty tree contributes its root plus the larger child depth. Full compilable function:
#include <stddef.h>
typedef struct node {
int key;
struct node *left, *right;
} *Tree;
int depth(Tree t) {
int x, y;
if (t == NULL) return 0;
x = depth(t->left);
y = depth(t->right); /* S1 */
if (x > y) return x + 1; /* S2 */
else return y + 1; /* S3 */
}
A leaf returns 1. The preceding tree returns 4. Each node is visited once, giving O(n) time and O(h) recursive stack space; an edge-count definition would require a different base case and is not the convention of the supplied program.
Answer: {n1–n2,n1–n6,n2–n4,n3–n4,n4–n5}, weight 25. (no official key was published)
Step through it (10 steps)
Apply Kruskal in nondecreasing weight order. Take n1–n2 (2), then n1–n6 (3). The weight-4 edges n2–n4 and n4–n6 both connect n4 to the same component; take either, say n2–n4. Reject the other because it closes a cycle. Take n3–n4 (7), joining n3. Reject n1–n3 (8), which now closes a cycle. Take n4–n5 (9), joining the final vertex, and stop after five edges. Total weight is 2+3+4+7+9=25. The tree is connected and acyclic; Kruskal’s cut property establishes minimality.
The unique cheapest edge crossing cut {n2} is n1–n2 (2), so every MST contains it. Similarly cut {n6} forces n1–n6 (3), cut {n3} forces n3–n4 (7), and cut {n5} forces n4–n5 (9). These four edges leave two components, {n1,n2,n6} and {n3,n4,n5}. Their cheapest connecting edges are n2–n4 and n6–n4, both weight 4. Either one completes a tree of weight 25; choosing both would create a cycle and require losing a forced edge. Hence there are exactly two MSTs.
For a connected weighted undirected graph, compare the minimum edge weight present in different MSTs.
Answer & solution
Answer: Yes: every MST has minimum edge weight equal to the graph’s globally minimum edge weight. (no official key was published)
Let m be the minimum weight of any edge joining distinct vertices. Suppose an MST T had no edge of weight m. Add an edge e of weight m to T. A tree plus one edge contains a cycle, and every other edge on that cycle would be heavier than m. Removing any such edge yields a spanning tree lighter than T, a contradiction. Therefore every MST includes an edge of weight m. The identity of that edge need not be unique, but the numerical minimum is. For the given graph it is 2.
For a connected weighted undirected graph, compare the maximum edge weight present in different MSTs.
Answer & solution
Answer: Yes; for the given graph the invariant maximum is 9. (no official key was published)
Suppose MST T has maximum edge weight M, and another MST U has all edge weights less than M. Remove an edge of weight M from T, splitting its vertices into two components. Because U is connected, some U edge crosses this cut. Its weight is less than M; inserting it into T minus the removed edge produces a lighter spanning tree, contradicting minimality. Swapping T and U rules out either having a strictly larger maximum. This proves equality of the maximum value, not uniqueness of the heaviest edge or of the MST itself. In the supplied graph n5’s cheapest incident edge has weight 9, and the constructed MST’s largest weight is 9.
Answer: FIRST(E)={a,(}; FIRST(A)={+,*,ε}; FOLLOW(E)=FOLLOW(A)={),$}. (no official key was published)
E→aA begins with a; E→(E) begins with (, so FIRST(E)={a,(}. A’s alternatives begin with + and *, or are empty, giving FIRST(A)={+,*,ε}. Put end marker $ into FOLLOW(E) because E is the start symbol. E→(E) adds ) to FOLLOW(E). E→aA puts A at the end, so FOLLOW(E) is included in FOLLOW(A). A→+E and A→*E put E at the end, so FOLLOW(A) is included in FOLLOW(E). Iterating these inclusions reaches the fixed point FOLLOW(E)=FOLLOW(A)={),$}. Neither + nor * follows E in this grammar; those operators start A.
Every occupied cell has exactly one production, so this grammar is LL(1). For example, on a+a the parser selects E→aA, matches a, uses A→+E, matches +, selects E→aA, matches a, then uses A→ε at end of input. The end marker is a parser marker, not a terminal in the original alphabet.
S→repeat S1 until E. S1.code is body code; E.code computes a Boolean into E.varName (1=true,0=false). newlabel() returns a fresh label; gen(s) emits a code line.
Answer & solution
Answer: S.code = gen(L+":") || S1.code || E.code || gen("if "+E.varName+" == 0 goto "+L), where L=newlabel(). (no official key was published)
Here || denotes concatenation of generated code strings, not Boolean OR. The resulting three-address layout is:
L:
[body code]
[compute E into t]
if t == 0 goto L
[next statement]
The body is before the condition so it runs at least once. A false result repeats; a true result falls through. E.code must be inside the loop because the condition is recomputed after every iteration. A fresh label for each production application avoids collisions when repeats are nested. No explicit exit label is necessary because the successful path falls through.
Answer: S→aR | bR; R→aR | bR | ε. (no official key was published)
In the standard transformation S→Sα1 | Sα2 | β1 | β2, choose α1=a, α2=b and β1=a, β2=b. Introduce a new nonterminal R and write S→aR | bR, R→aR | bR | ε. The initial S production contributes one mandatory letter; R generates any remaining sequence of a’s and b’s, including the empty suffix. Thus both grammars generate exactly all nonempty strings over {a,b}. No production now begins with its own left-hand nonterminal, directly or indirectly. The empty string remains excluded from S, as it was in the original grammar.
Grammar S→aSbS | bSaS | ε; construct all parse trees of abab and determine ambiguity.
Answer & solution
Answer: Exactly two parse trees; grammar is ambiguous. (no official key was published)
Step through it (2 derivations)
The root must use S→aSbS because the yield begins with a. Its explicit b can be the b at position 2 or position 4. These exhaust the possibilities. Use S[children] for an ordered parse-tree node; S[ε] is an empty production.
Tree 1: S[a, S[ε], b, S[a, S[ε], b, S[ε]]] Tree 2: S[a, S[b, S[ε], a, S[ε]], b, S[ε]]
Accessible tree description: in tree 1 the root’s first S is empty and its final S generates ab. In tree 2 its first S generates ba and its final S is empty. Their leftmost derivations are: S⇒aSbS⇒abS⇒abaSbS⇒ababS⇒abab. S⇒aSbS⇒abSaSbS⇒abaSbS⇒ababS⇒abab. The inner two-letter strings ab and ba each have only their direct production with both S children empty. Consequently there are precisely two trees, not merely at least two. Distinct trees with the same terminal yield prove ambiguity.
GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation.
Answer & solution
Answer: Yes: with one-shot execution and atomic reads and writes, the opposite acquisition order prevents overlapping use (no official key was published)
Program, assume each individual flag read or write is atomic, but test-and-set is not, and each process executes its printed sequence once. Mutual exclusion of the actual use intervals S5 and Q5 is nevertheless guaranteed. Suppose the intervals overlapped. Neither process could yet have released a resource. P2 must therefore have passed its R1 test Q3 before P1 sets R1 at S2, giving Q3<S2. Similarly P1 must pass its R2 test S3 before P2 sets R2 at Q2, giving S3<Q2. Program order imposes S2<S3 and Q2<Q3. Combining yields the impossible strict cycle S2<S3<Q2<Q3<S2. Hence an overlapping execution is impossible. Separate tests and sets alone are not enough to prove a race in this particular opposite-order program.
The only possible intervening freeing operation is P1’s S6, which follows completion of S5. Therefore P2 cannot reach Q5 before P1 finishes its use. This is poor progress behavior, not an overlapping-use counterexample. These conclusions concern the printed one-shot programs; an unspecified outer repetition loop or non-atomic/memory-reordered implementation is a different model.
GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation.
Answer & solution
Answer: Yes: S1, S2, Q1, Q2, then P1 waits at S3 and P2 waits at Q3 (no official key was published)
Initially both flags are free. Let P1 pass S1 and execute S2, so R1 becomes busy. Let P2 pass Q1 and execute Q2, so R2 becomes busy. P1 now spins in S3 waiting for R2; P2 spins in Q3 waiting for R1. Neither can reach its use or release operations. The wait-for graph is P1→P2→P1: each holds its first resource while waiting for the other.
P2 then spins at Q3 on R1, the flag it set itself. P1 spins at S1 on R1. No process can reach a release. This is a self-wait plus a blocked competitor, rather than the intended two-resource circular wait.
GFG variant: P1 executes S1 wait until R1 free; S2 set R1 busy; S3 wait until R2 free; S4 set R2 busy; S5 use both; S6 free R1; S7 free R2. P2 executes Q1 wait until R2 free; Q2 set R2 busy; Q3 wait until R1 free; Q4 set R1 busy; Q5 use both; Q6 free R2; Q7 free R1. Initially both free. Each test and subsequent set is a separate operation. Exchange Q1 with Q3 and Q2 with Q4.
Answer & solution
Answer: Mutual exclusion fails after reordering, but there is no resource deadlock (no official key was published)
After swapping the the paper operations, both processes check/set R1 and then check/set R2. Name the new P2 order Q1′=test R1, Q2′=set R1, Q3′=test R2, Q4′=set R2, followed by use and the original releases. A violating interleaving is S1,Q1′,S2,Q2′,S3,Q3′,S4,Q4′, followed by overlapping S5 and Q5. Both tests of each free flag precede either write to that flag, so both reach their use intervals. This shows why a real atomic lock operation is required.
There is no resource deadlock in the reordered the paper protocol: a process waiting on R2 has already passed the R1 test. Any competing process that made R2 busy has also passed both tests and can finish and release; it cannot be waiting to acquire R1 afterward. This excludes a circular resource wait, assuming a runnable process eventually runs. It does not promise fairness or fix mutual exclusion.
Its one-shot nonoverlap and self-wait deadlock from parts (a),(b) remain.
Disk has tracks 0–99, rotates at 3000 rpm, has 100 sectors per track and takes 0.2 ms to move one track. Requests are tracks 32,7,45,5,10; head starts at 25 moving upward.
Answer & solution
Answer: SCAN: 33.6 ms; LOOK interpretation: 12 ms. (no official key was published)
Under strict SCAN, continue toward the physical end 99 before reversing. Requests are served in order 32,45,10,7,5, with traversal 25→32→45→99→10→7→5. Distance is (99−25)+(99−5)=74+94=168 tracks. Multiply by 0.2 ms/track to get 33.6 ms. Stop measuring once the final request at 5 is served; there is no need to continue to 0.
Some textbooks use “elevator” for LOOK, which reverses at the last pending request, 45, rather than at track 99. That traversal covers (45−25)+(45−5)=20+40=60 tracks, giving 12 ms. The source does not explicitly distinguish these conventions, so both are reported with their policies. Rotation rate and sector count do not enter a seek-time-only answer.
Disk has tracks 0–99, rotates at 3000 rpm, has 100 sectors per track and takes 0.2 ms to move one track. Initially 100 arbitrary requests, no new arrivals, head starts at track 0; determine worst-case completion time under elevator scheduling.
Answer & solution
Answer: Seek-only maximum 19.8 ms. Under a conventional one-sector/request bound, total ≤2039.8 ms (see assumptions). (no official key was published)
Starting at the lowest track, all requests can be served in one upward sweep. The maximum head travel is 99 tracks, so seek time is at most 99×0.2=19.8 ms, attained if a request is at track 99. A revolution takes 60/3000 seconds=20 ms, and a single sector transfer takes 20/100=0.2 ms.
If each request reads one sector and one charges a separate worst-case rotational wait of up to one full revolution to every request, an additive bound is 19.8+100×(20+0.2)=2039.8 ms. A uniform-random-phase average latency would be 10 ms, yielding a different, average-model value 1039.8 ms; it is not a worst-case answer. If a convention counts a complete revolution as covering both wait and the requested sector transfer, the bound is instead 19.8+100×20=2019.8 ms.
The printed request description does not specify bytes/sectors per request, sector ordering at one track, or a rotational-latency convention. Therefore it does not determine a unique exact total completion time. The 19.8 ms seek bound is unambiguous; any fuller time must state its service assumptions. Independent per-request latency maxima are a conservative additive bound, not a proof that a single finite queue attains every maximum simultaneously.
examinee(regno,name,score), with primary key regno. Use projection, selection, renaming and Cartesian product to find names appearing in multiple tuples.
Answer & solution
Answer: π_X.name σ_(X.name=Y.name ∧ X.regno≠Y.regno)(ρ_X(examinee) × ρ_Y(examinee)). (no official key was published)
Rename the relation twice so the two tuple occurrences are distinguishable: X=ρ_X(examinee), Y=ρ_Y(examinee). Form X×Y, retain equal names but different registration numbers, then project the name.
π_X.name(σ_(X.name=Y.name AND X.regno≠Y.regno)(X×Y)).
The equal-name condition identifies candidates; the unequal-key condition ensures two different examinees rather than pairing a row with itself. Because regno is a key, different regno values mean different rows. Standard relational algebra has set semantics, so projection returns each repeated name once even if it has many matching pairs. Example: (1,Asha,70),(2,Asha,80),(3,Bela,90) returns only Asha. Without the unequal-key predicate every name would incorrectly qualify.
examinee(regno,name,score), where regno is a primary key and score is real. List registration numbers with score above the relation-wide average.
Answer & solution
Answer: SELECT regno FROM examinee WHERE score > (SELECT AVG(score) FROM examinee); (no official key was published)
Use an uncorrelated scalar subquery to compute one average over all examinees:
SELECT e.regno FROM examinee AS e WHERE e.score > (SELECT AVG(x.score) FROM examinee AS x);
The outer query compares each score with the same global average. Strict > excludes scores exactly equal to that average. No GROUP BY is needed because the intended comparison is to the whole relation, not a separate average per person or centre. The primary key ensures no duplicate registration number in the result. In SQL, AVG ignores NULL scores and comparison with NULL is unknown, so NULL-score rows do not qualify; the stated mathematical real-number model normally excludes this extra case.
examinee(regno,name,score) and appears(regno,centr_code). List centre codes having an examinee whose score exceeds 80.
Answer & solution
Answer: SELECT DISTINCT a.centr_code FROM appears a JOIN examinee e ON e.regno=a.regno WHERE e.score>80; (no official key was published)
Join each appearance to its examinee using the shared registration number, keep scores strictly greater than 80, then project distinct centre codes:
SELECT DISTINCT a.centr_code FROM appears AS a JOIN examinee AS e ON e.regno = a.regno WHERE e.score > 80;
DISTINCT is important because several high-scoring examinees can share a centre. This is an existential requirement: one qualifying examinee is sufficient. It is not a condition on centre average, and it does not require every examinee at that centre to exceed 80. An equivalent SQL formulation selects DISTINCT centre codes from appears a WHERE EXISTS (SELECT 1 FROM examinee e WHERE e.regno=a.regno AND e.score>80).
B+ tree fan-out 3; insert 80,50,10,70,30,100,90, and show snapshots after 10,30,90.
Answer & solution
Answer: With left-heavy leaf splits: after 10 root[80]; after 30 root[70]; after 90 root[70] with internal children[50] and[80,100]. (no official key was published)
B+ tree fan-out 3, initially empty; insert 80,50,10,70,30,100,90. Use at most 3 child pointers (2 separators) per internal node and at most 2 records per leaf. Non-root internal nodes need ≥2 children; non-root leaves need ≥1 record. Policy: split an overflowing 3-record leaf as 2 records on the left and 1 on the right; copy the minimum key of the right leaf upward. Split an overflowing internal node with 4 children into two groups of 2 children, promoting the middle separator. Internal separators equal the minimum key of their right subtree. Leaf links run left-to-right.
After inserting 10:
[80]
/ \
[10,50] -> [80]
Insert 70: leaves become [10,50],[70],[80], root [70,80]. Inserting 30 splits the first leaf into [10,30] and [50], overflows the root to four children, and creates a new root:
[70]
/ \
[50] [80]
/ \ / \
[10,30] [50] [70] [80]
Insert 100 into the last leaf. Insert 90 there, split [80,90,100] into [80,90] and [100], and add separator 100 to its parent. Final tree after 90:
Accessible description: root separator 70; left internal separator 50 points to leaves [10,30] and [50]; right internal separators 80,100 point to [70],[80,90],[100]. All leaves have equal depth and are linked in the displayed order. Other consistently applied split policies can yield different valid trees; this is one fully specified construction.
B+ tree fan-out 3, initially empty; insert 80,50,10,70,30,100,90. Use at most 3 child pointers (2 separators) per internal node and at most 2 records per leaf. Non-root internal nodes need ≥2 children; non-root leaves need ≥1 record. Starting with the final tree of the preceding solution, delete 30 and then 10.
Answer & solution
Answer: After 30: leaf [10,30] becomes [10]. After 10: root [80], left internal[70] with [50],[70], right internal[100] with [80,90],[100]. (no official key was published)
Use the exact insertion policy and final tree in part (a). Deletion policy: remove a record, repair an empty leaf by borrowing from an adjacent same-parent sibling if it has spare records; otherwise merge. Repair an underfull internal node by borrowing one child from an adjacent same-parent sibling with spare children; otherwise merge. Update separators to right-subtree minima throughout.
After deleting 30, [10,30] becomes [10]. One record meets the minimum, so no redistribution occurs:
After deleting 10, the leftmost leaf is empty. Its sibling [50] cannot lend because it has the minimum one record. Merge into [50], remove the obsolete separator 50, and the left internal node temporarily has only one child. Its right internal sibling has three children and can lend its first child [70]. Move that child to the left internal node; update the root separator from 70 to 80. The final tree is:
Accessible description: root 80 has left internal node 70 with leaf children [50],[70], and right internal node 100 with leaf children [80,90],[100]. The linked leaf sequence is [50]→[70]→[80,90]→[100]. All capacity, occupancy, ordering and equal-depth invariants hold. A different valid policy in part (a) needs its own consistent deletion trace.