Complete: Gauri said that she can play the keyboard ___ her sister. Options A as well as; B as better as; C as nicest as; D as worse as.
Your answer
Answer & solution
Official answer: A
The comparative construction as well as correctly expresses equal ability. The alternatives mix incompatible comparative forms. Thus A.
The construction is “as + adverb in its ordinary form + as.” Here well modifies play. Better and worse are comparative forms, which normally take than, while nicest is a superlative adjective and does not describe the verb play.
Fold the left half of the transparent square onto its right half along the central vertical dotted line. Choose the superposed pattern A–D. The embedded source figure supplies the curved strokes and small ticks exactly.
Your answer
Answer & solution
Official answer: B
Reflect every mark in the left half across the dashed vertical fold, leaving the right-half marks fixed. The reflection of the originally rising left-hand curve and the original falling right-hand curve enclose the lens-shaped region on the right. Each reflected vertical tick meets an original horizontal tick to form a corner rather than parallel bars. These features match B.
Model a vertical fold at x=c as reflection (x,y)↦(2c−x,y). Vertical heights are unchanged; slopes reverse. Do not rotate the sheet or reflect the already-right-hand portion. In particular the tiny marks are part of the test, not decoration: the correct curve alone is insufficient if the ticks disagree.
Find cos θ for the angle between a cube's longest (body) diagonal and any edge. A 1/2; B 1/√3; C 1/√2; D √3/2.
Your answer
Answer & solution
Official answer: B
Take an edge direction (1, 0, 0) and body-diagonal direction (1, 1, 1). Their angle satisfies cosθ=1/(1·√3)=1/√3, so θ=arccos(1/√3), B. The question specifies an edge and a body diagonal, not a face diagonal.
For a cube of side a, the body diagonal has length √(a²+a²+a²)=a√3. Projecting it onto an edge gives length a, so the angle cosine is projection/diagonal. Side length cancels. A face diagonal would instead give 1/√2 and is the distractor C.
Difference of squares gives (x−1/2)²−(x−3/2)²=[1][2x−2]. Thus 2x−2=x+2, so x=4, B.
A direct expansion checks the cancellation: x²−x+1/4−(x²−3x+9/4)=2x−2. Substituting x=4 gives 12.25−6.25=6, matching x+2. Difference-of-squares avoids a quadratic calculation because the x² terms cancel.
Complete the instrument/action analogy Pen:Write::Knife:___. A Vegetables; B Sharp; C Cut; D Blunt.
Your answer
Answer & solution
Official answer: C
A pen is used to write, and a knife is used to cut. This is the same instrument-to-action relationship, C.
Keep the direction of the relationship fixed: an object is followed by its characteristic action. Vegetables are something a knife might cut, while sharp and blunt describe properties. Neither type matches the verb write.
Music improves exercise performance and reduces discomfort. Learning research is inconclusive: students needing external stimulation fared worse with music; those not needing it benefited. Choose the supported inference: A no learning effect and positive exercise effect; B positive effects on exercise and learning generally; C positive exercise effect and learning benefits for only some students; D positive learning effect for all and exercise benefits for only some.
Your answer
Answer & solution
Official answer: C
The passage attributes positive effects to music during exercise, while qualifying learning benefits as applying only to some learners. C preserves that contrast without turning a qualified observation into a universal one.
Separate two claims rather than averaging them into one conclusion. Exercise benefits are stated positively. The learning statement divides students into two groups with different outcomes, so “all learners” and “no effect on learning” both overstate the evidence. No causal claim about why the groups differ is required.
Choose which missing piece A–D combines with the supplied jigsaw piece to form a rectangle. Translation, rotation and reflection are allowed. The embedded figure preserves all projections and recesses of the supplied piece and candidates.
Your answer
Answer & solution
Official answer: A
Rotate candidate A clockwise by 90 degrees so its straight side becomes the left outer boundary. Its stepped right boundary complements the supplied piece: the reentrant hook after the tallest step fits the corresponding projection, and the deep central recess fits the remaining ledge. Together the outside edges form a rectangle. The competing shapes differ at the hook, recess depth, or stepped profile and cannot give the same fit.
A useful verification is to trace the shared boundary after rotating A: every protrusion of one piece must fill a recess of the other, with no overlap or gap, and the four external boundaries must be straight. Matching the overall silhouette or merely counting teeth is not sufficient; their order and depths matter.
Three class sizes have ratio 3:13:6. Adding 18 students to each changes it to 15:35:21. Find their original total. A 22; B 66; C 88; D 110.
Your answer
Answer & solution
Official answer: C
Write the initial quantities as 3k, 13k, 6k. Adding18 to each gives ratio 15: 35: 21. The first two give 35(3k+18)=15(13k+18), hence 90k=360 and k=4. The third also gives 42/30=21/15. The initial total is 22k=88, C.
The common increase does not preserve the original ratios, so one cannot scale 3:13:6 directly to 15:35:21. With k=4, the initial sizes are 12,52,24 and the new sizes 30,70,42. Dividing the new sizes by 2 verifies every component of the target ratio.
Graph data (units sold, net profit): Year 1 (100,240), Year 2 (200,296), Year 3 (300,210). Year 3 cost/unit is 1, half Year 2 and one-third Year 1. Tax on selling price is respectively 10%,13%,15%. Net profit = selling price − cost − tax. Find Year 2:Year 3 total selling price. A 4:3; B 1:1; C 3:4; D 1:2.
Your answer
Answer & solution
Official answer: A
The graph gives units 200 and 300, and total net profits296 and 210, for Years2 and 3. Their unit costs are 2 and 1, giving total costs 400 and 300. If total selling prices are S2, S3, then 0.87S2−400=296 and 0.85S3−300=210. Thus S2=800 andS3=600, a 4: 3 ratio, A. This uses total selling price as in the graph accounting; unit selling prices would instead be 4 and 2.
For each year write profit=(1−tax rate)×total revenue−units×unit cost. Taxes are not percentages of profit or cost. Check Year 2: revenue 800 less tax 104 less cost 400 gives 296. Year 3: revenue 600 less tax 90 less cost 300 gives 210. Dividing by units answers a different question.
Six distinct heights P,Q,R,S,T,U satisfy S>R; Q shortest; U taller than only one; T>S but T not tallest. Number taller than R equals number shorter than whom? A T; B R; C S; D P.
Your answer
Answer & solution
Official answer: C
The unique increasing height order is Q<U<R<S<T<P: Q is shortest, U next, R<S<T, and T is not tallest. Three students exceed R, while three are shorter than S. Thus S, option C.
Assign ranks 1 through 6 in increasing height. Q occupies 1 and U occupies 2. The ordered chain R<S<T uses three of the remaining four ranks, and T cannot occupy 6, so it must be 5, leaving P at 6 and R,S at 3,4. This also shows why merely knowing S>R is not enough without the other conditions.
For connected undirected weighted G: S1 some minimum-weight edge belongs to every MST; S2 distinct edge weights imply a unique MST. A both true; B only S1; C only S2; D neither.
Your answer
Answer & solution
Official answer: C
An equal-weight triangle has three MSTs, each omitting a different minimum-weight edge, so no edge belongs to every MST. This refutes S1. Distinct edge weights ensure a unique MST by the cut/exchange property, so S2 is true. Thus C.
For S1 the quantifier “every MST” is crucial: a minimum edge is safe for some MST, but ties can let another edge replace it. For S2 suppose two MSTs differ and choose the lightest edge in their symmetric difference. Adding it to the other tree creates a cycle containing a heavier edge from that difference; exchanging them lowers the weight, a contradiction.
A binary min-heap of n elements is stored as an array. Find optimal worst-case time to find its maximum. A Θ(1); B Θ(log n); C Θ(n); D Θ(n log n).
Your answer
Answer & solution
Official answer: C
A maximum occurs among the heap leaves, of which there are ceil(n/2). Scan those leaves to find it in O(n). Their values have no heap-imposed relative order, so in the worst case each must be considered, yielding Ω(n). Hence Θ(n), C.
In a one-based heap array, indices floor(n/2)+1 through n are leaves. Initialize best to the first leaf and compare each remaining leaf once. Heap order says ancestors are no larger than descendants, so inspecting internal nodes is unnecessary. An adversary can assign distinct arbitrary values to leaves above all internal values; finding their maximum requires leaf-count−1 comparisons.
ANSI C program: int main(){ Integer x; return 0; }. No declaration of Integer is supplied. Which conceptual seven-phase compiler stage reports the error? A lexical analysis; B syntax analysis; C semantic analysis; D machine-dependent optimization.
Your answer
Answer & solution
Official answer: C
Our answer: C in the textbook phase model
Integer is an identifier rather than a built-in C type, and no typedef declaration introduces it. The intended seven-phase classification is an undeclared-type/name error detected by semantic analysis, C. Real C front ends can report a parse error because typedef-name classification interacts with parsing; the answer describes the conceptual phase classification rather than a guarantee about every compiler diagnostic.
Lexing can recognize Integer as a legal identifier, so its spelling is not itself a lexical error. Semantic analysis normally resolves declarations and type meanings. The conceptual answer should not be read as promising that a particular real C parser will proceed to a separately named semantic phase for this malformed declaration.
For IEEE 754 binary32, identify the smallest positive normalized number's exponent and fraction fields. A exponent 00000000/fraction all zero; B exponent 00000000/fraction integer 1; C exponent 00000001/fraction all zero; D exponent 00000001/fraction integer 1. Fraction width is 23 bits.
Your answer
Answer & solution
Official answer: C
A normalized binary32 number has a nonzero exponent field. The smallest positive one uses biased exponent 1 and fraction 0: exponent 00000001, fraction all zeros. Its value is 1.0·21−127=2−126, C. Exponent0 encodes zero or subnormals instead.
Binary32 uses sign 0 for positive, bias 127, and an implicit leading 1 for normal numbers. The least positive normal has the smallest allowed normal exponent and smallest significand. Option B is instead the smallest positive subnormal, 2−149; it is positive but fails the word normalized.
Implement f(x,y,z)=Σm(0,1,3,4,5,6), with x the most significant minterm bit, using a 4:1 mux with selectors S1=y,S0=z. Candidate input tuples (I0,I1,I2,I3): A (1,1,x,¬x); B (x,1,¬x,1); C (1,1,¬x,x); D (¬x,1,x,1).
Your answer
Answer & solution
Official answer: A
With selectors y, z, the paired minterms for yz=00 and 01 both produce 1 for either x. For yz=10 only x=1 is included, so input 2 is x. For yz=11 only x=0 is included, so input 3 is ¬x. Therefore the four mux inputs are 1, 1, x,¬x, exactly A.
List truth values in selector groups: yz=00 selects minterms 0,4; yz=01 selects 1,5; yz=10 selects 2,6; yz=11 selects 3,7. Their outputs versus x are (1,1),(1,1),(0,1),(1,0). This is Shannon expansion with two selection variables. A gate equivalent is ¬y∨(x∧¬z)∨(¬x∧z), with redundant coverage allowed.
Relational model statements: S1 a relation schema has at most one foreign key; S2 a foreign key in R cannot refer to tuples of R itself. A both; B only S1; C only S2; D neither.
Your answer
Answer & solution
Official answer: D
A relation can have several foreign keys, for example managerId and departmentId. It can also reference itself, as managerId referencing another employee in the same employee relation. Both proposed restrictions are false, D.
A concrete schema is Employee(id,managerId,deptId), where managerId references Employee(id) and deptId references Department(id). It simultaneously refutes both claims. A foreign key enforces referenced-key membership; it does not impose a one-foreign-key limit or require a different relation name.
TCP hosts P,Q choose initial sequence numbers X,Y. P sends SYN=1,SEQ=X,ACK=0; Q accepts. Select Q's response (SYN,SEQ,ACK,ACKnumber,FIN): A (1,X+1,0,Y,0); B (0,X+1,0,Y,1); C (1,Y,1,X+1,0); D (1,Y,1,X,0).
Your answer
Answer & solution
Official answer: C
Q sends SYN+ACK using its own initial sequence Y and acknowledging X+1 because SYN consumes one sequence number. Thus SYN=1, SEQ=Y, ACK=1, ACKnumber=X+1, FIN=0, C; sequence arithmetic is modulo 2³².
TCP sequence spaces are independent in the two directions. Q must announce Y, not X+1, as its own sequence number. The acknowledgment X+1 says that P's SYN was consumed and the next expected sequence is X+1. FIN is zero because the response establishes rather than closes the connection.
What is the worst-case number of arithmetic operations in recursive binary search on a sorted n-element array? A Θ(√n); B Θ(log₂ n); C Θ(n²); D Θ(n).
Your answer
Answer & solution
Official answer: B
Each binary-search call performs constant arithmetic and reduces the remaining interval by roughly one half. The worst-case recurrence is T(n)=T(n/2)+Θ(1), so Θ(log n), B, under the standard unit-cost arithmetic model.
After j unsuccessful comparisons, at most about n/2j candidates remain. Reaching one candidate needs j≈log₂n. A call computes a midpoint and adjusts bounds using a constant number of arithmetic operations. This counts operations, not bit complexity of arbitrary-precision index arithmetic.
A regular language L⊆{0,1}* has a minimal DFA with k states. Which language must also have a k-state minimal DFA? A L−{01}; B L∪{01}; C {0,1}*−L; D L·L.
Your answer
Answer & solution
Official answer: C
Complement a complete minimal DFA by exchanging accepting and nonaccepting states. Reachability is unchanged, and every distinguishing suffix still distinguishes the same pair with acceptance reversed. Consequently no states merge and the minimal state count remains k. Thus the complement language, C.
For any states p,q distinguished in L by suffix w, exactly one of their w-runs ends accepting. Flipping all final-state flags preserves that exclusive difference, proving minimality rather than merely giving an upper bound of k states. Completeness matters: a missing transition must first be represented by a dead state before taking a DFA complement.
ANSI C declares int arr[4][5] and initializes arr[i][j]=10*i+j for 0≤i<4,0≤j<5. It prints *(arr[1]+9) with %d. Offered outputs: A 14; B 20; C 24; D 30. Explain the intended result and the language-standard issue.
Your answer
Answer & solution
Official answer: C
Our answer: C under intended flattening; undefined in strict C
The intended contiguous-address calculation begins at row1, column 0, linear index 5; advancing 9 integers reaches index 14=row2, column 4, whose initialized value is 24, C. However arr[1] decays to a pointer into the five-element row subarray. Adding9 goes beyond that array and its one-past position, so the expression has undefined behavior under C pointer-arithmetic rules. Contiguous storage of the outer array does not legalize this cross-row pointer arithmetic. The official C is retained as the intended exam answer, not a portable guarantee.
The intended memory layout has rows 0–4,10–14,20–24,30–34. The desired element is arr[2][4], which is a portable way to express it. Do not run this original expression and treat one observed compiler output as a proof of defined behavior. The official option describes the conventional exam address calculation only.
For n≥2, S1 is all n×n matrices over {a,b,c}; S2 is all functions {0,1,…,n²−1}→{0,1,2}. Select: A no bijection S1→S2; B a surjection exists; C a bijection exists; D no injection exists.
Select all that apply
Answer & solution
Official answer: B; C
There are 3n² matrices because each of n² entries has 3 choices. There are also 3n² functions from an n²-element domain to a 3-element codomain. A direct bijection reads matrix entries in a fixed order and maps a, b, c to 0, 1, 2. A bijection is also a surjection and an injection, so B, C.
Explicitly index matrix position (i,j), for zero-based i,j, by i*n+j. Map its symbol a,b,c to the function value 0,1,2. The inverse reconstructs each entry from that value, proving both injectivity and surjectivity without relying only on equal counts. A and D negate properties that this construction supplies.
L1 is regular and L2 context-free. Which are necessarily context-free? A L1∩¬L2; B ¬(¬L1∪¬L2); C L1∪(L2∪¬L2); D (L1∩L2)∪(¬L1∩L2). Complements are relative to the common alphabet-star.
Select all that apply
Answer & solution
Official answer: B; C; D
Visually reading the overbars, B is the complement of (complement L1 union complement L2), hence L1 intersection L2, which is context-free. C contains L2 union complement L2 and equals the whole alphabet-star. D is (L1 intersection L2) union (complement L1 intersection L2), hence L2. A is L1 intersection complement L2; taking L1=Σ* shows that it need not be context-free, since CFLs are not closed under complement. Thus B, C, D.
The relevant closure theorem is intersection of a CFL with a regular language, not intersection of two arbitrary CFLs. A product construction combines the CFL's PDA control with the regular DFA state without adding another stack. C and D simplify by excluded middle, so no unsupported general CFL-complement closure is used.
Which is NOT an intermediate representation of source computation? A three-address code; B abstract syntax tree; C control-flow graph; D symbol table. Multiple selections are permitted.
Select all that apply
Answer & solution
Official answer: D
Three-address code, an abstract syntax tree, and a control-flow graph represent program computations or structure. A symbol table instead records information about names, types, scopes, and bindings. It supports analysis but is not an intermediate representation of the source computation. Thus D.
For an assignment x=a+b, three-address code records the operation, an AST records its expression structure, and a CFG records possible control transfers around it. The symbol table instead stores facts such as x's declared type or scope. A compiler may use all four structures; “used by a compiler” is broader than “intermediate representation.”
Select correct CPU scheduling statements: A turnaround includes waiting; B goal is only maximize CPU use and minimize throughput; C round robin works without advance CPU burst lengths; D preemption requires hardware support.
Select all that apply
Answer & solution
Official answer: A; C; D
Turnaround measures arrival-to-completion and includes waiting, so A. Throughput should ordinarily be increased, not minimized, refuting B. Round-robin only needs a time quantum, not advance knowledge of each burst, giving C. Preemption of an otherwise running process requires hardware interruption support, typically a timer interrupt, giving D in the standard OS model.
For an ordinary CPU-only job, turnaround=completion−arrival=waiting+CPU service; I/O time is also included if relevant. Round robin dispatches a ready job for at most a quantum, regardless of its remaining burst. A timer interrupt lets the OS regain control even if the process does not voluntarily yield.
S=((P∧Q)→R)→((P∧Q)→(Q→R)). Select A neither tautology nor contradiction; B tautology; C contradiction; D antecedent and consequent are equivalent.
Select all that apply
Answer & solution
Official answer: B; D
The antecedent simplifies to ¬P∨¬Q∨R. The consequent simplifies to ¬P∨¬Q∨(¬Q∨R), which is identical. Therefore S has the form E→E and is a tautology. Both B and D hold.
Using A→B≡¬A∨B, let E=¬P∨¬Q∨R. The outer statement is E→E=¬E∨E, true for all eight assignments of P,Q,R. Equivalence of antecedent and consequent establishes D separately from the overall tautology B; those are two selectable propositions, not competing single-choice answers.
A complete binary tree has 7 nodes. A is the first three BFS-discovered nodes from root; B is the first three DFS-discovered nodes from root. Find |A−B|.
Answer & solution
Official answer: 1
The complete seven-node tree has three levels. BFS first visits the root and both children. DFS discovery first visits the root, one child, and one grandchild. Therefore exactly one BFS member, the other child of the root, is absent from the first three DFS members, so |A−B|=1.
Name the root r, children l,u and grandchildren l1,l2,u1,u2. BFS gives {r,l,u}. A left-first DFS gives {r,l,l1}; right-first gives {r,u,u1}. In either case the intersection has two nodes and the BFS-only set has one. The result is independent of which child is explored first.
DFA has start q0, layer-one states u,v, layer-two states p,q and accepting f. Transitions: q0:0→u,1→v; u:0→p,1→q; v:0→p,1→q; p and q:0,1→f; f:0,1→f. Count accepted strings of length 8.
Answer & solution
Official answer: 256
Every input follows one edge through each of the first three layers, reaching the accepting state after exactly three symbols regardless of their values. That state loops on both 0 and 1. Hence every eight-bit string is accepted, giving 2⁸=256.
The machine recognizes all binary strings of length at least three: no earlier state is accepting, and after the third transition it cannot leave f. Thus for any length n≥3 the count is 2n. The two layer-two branches must not be mistaken for missing-input transitions; each accepts both bits on the next step.
Binary0.1101 equals 1/2+1/4+1/16=13/16=0.8125. Thus x=1, y=2 and x+y=3.
Weights to the right of the binary point are 2−1,2−2,2−3,2−4. Only the third bit is zero. Matching 0.8125 to 0.8xy5 identifies the digits individually before adding. The answer is an integer sum of digits, not the binary fraction's numerator.
A64-byte block needs 6 offset bits. The remaining index width is 32−22−6=4 bits, giving 16 sets. Capacity2048/64=32 cache lines means 32/16=2 lines per set, so two-way associativity.
Address format is [tag | set index | byte offset]. Capacity includes all ways, so number of sets is not total number of lines unless the cache is direct-mapped. Check reconstruction: 16 sets×2 ways×64 bytes=2048 bytes and 22+4+6=32 address bits.
Similar questions1 more → · asked again: GATE 2024 Set 2, Q11
Input/Output, DMA & Interrupts
Tap to enlarge
DMA cycle stealing moves one 8-bit character per stolen CPU cycle. CPU is 2MHz and 0.5% of cycles are stolen at regular intervals. Find device data rate in bits/s.
Answer & solution
Official answer: 80000
DMA uses 0.005·2, 000, 000=10, 000 CPU cycles per second. Each transfers 8 bits, giving 80, 000 bits per second.
Convert percentage before multiplication: 0.5%=0.005. A 2MHz clock supplies two million cycles each second, so stolen cycles transfer 10000 characters/s. Multiplying by 8 converts to bits/s; 10000 is the byte rate, not the requested bit rate.
150000 student records sorted by primary key RollNo. Secondary candidate key ANum uses 12 bytes; record pointers 7 bytes. Index records contain ANum and corresponding record pointer. Blocks are 4096 bytes and records cannot straddle blocks. Find index block count.
Answer & solution
Official answer: 698
The secondary candidate-key index is dense, with one entry per student. Each entry needs 12+7=19 bytes. With no split entries, each 4096-byte block holds floor(4096/19)=215 entries. Thus ceil(150000/215)=698 blocks.
ANum is not the ordering key of the data file, so a sparse primary index with one entry per data block is not applicable. Packing permits 215 complete 19-byte entries per block because 216 require 4104 bytes. There are 697 full blocks holding 149855 entries and 145 entries in a final block.
A coin independently gives heads with probability 0.4 on each of 1000 tosses. X counts heads. Find standard deviation of X to two decimals.
Answer & solution
Official answer: 15.00 to 16.00
Our answer: 15.49
For X~Binomial(1000, 0.4), variance is np(1−p)=1000·0.4·0.6=240. Standard deviation is√240≈15.4919, or 15.49 to two decimals, within the official 15.00–16.00 range.
Write X as the sum of 1000 independent Bernoulli indicators. Each has variance p(1−p)=0.24; independence makes variances add. Standard deviations do not add directly. Taking the square root only after the variance sum produces the requested units, number of heads.
SomeFunction(x,y): if x==1 or y==1 return 1; if x==y return x; if x>y recurse on (x−y,y); if y>x recurse on (x,y−x). Find SomeFunction(15,255).
Answer & solution
Official answer: 15
Step through it (19 steps)
Each recursive step subtracts the smaller positive argument from the larger, preserving their gcd. Starting at(15, 255), repeated subtraction reaches(15, 15), which returns 15. Neither argument reaches 1 on this input.
The invariant gcd(x,y)=gcd(x,y−x) explains correctness, while decreasing x+y proves termination for positive integers. Here y successively becomes 240,225,…,30,15, after sixteen subtractions of 15, and the equality branch returns 15. A modulo-based Euclidean algorithm would skip these repeated subtraction calls.
P is a 4×5 matrix and every solution of Px=0 is a scalar multiple of (2,5,4,3,1)ᵀ. Find rank(P).
Answer & solution
Official answer: 4
The nullspace is contained in the span of one nonzero vector, so its dimension is at most 1. A4×5 matrix has rank at most 4 and therefore nullity at least 1. Hence nullity=1 and rank=5−1=4.
Rank-nullity applies to the five-column linear map: rank+nullity=5. The statement only says every solution lies in the given line, not explicitly that every point on the line is a solution. Nevertheless the 4-row rank bound forces a nonzero nullspace, completing that missing direction and ruling out nullity zero.
f is continuous on [−3,3], differentiable on (−3,3), f′(x)≤2 everywhere inside, and f(−3)=7. Find the largest possible f(3).
Answer & solution
Official answer: 19
The mean value theorem gives f(3)−f(−3)=6f′(c)≤12 for some c∈(−3, 3). Since f(−3)=7, f(3)≤19. The linear function f(x)=2x+13 attains equality, so 19 is the tight upper bound.
The mean value theorem needs continuity on the closed interval and differentiability inside, both supplied. It provides an actual intermediate derivative equal to the secant slope. An upper derivative bound is not an absolute derivative bound, so the problem gives no analogous finite lower bound on f(3). The attaining linear function proves tightness.
Encode abbccddeee with a binary prefix code. Among equal-frequency letters, earlier dictionary letters must have code length no greater than later ones. Find minimum encoded length. A 21; B 23; C 25; D 30.
Your answer
Answer & solution
Official answer: B
The frequencies are 1, 2, 2, 2, 3. Huffman merging costs are 3, 4, 6, 10, totaling 23 bits, the optimal weighted path length. The dictionary tie rule can also be met: assign b=00, c=01, e=10, a=110, d=111. Then lengths of b, c, d are 2, 2, 3, and total length is 3+4+4+6+6=23. Thus B.
Huffman repeatedly merges the two smallest available weights: 1+2=3; 2+2=4; 3+3=6; 4+6=10. Each merge adds its weight once to the encoded length because all leaves below it gain one bit. The displayed code is prefix-free and satisfies the alphabetical tie restriction, so the unrestricted Huffman lower bound is attainable with the extra condition.
Inclusive two-level cache L1,L2 with L2 larger. S1 read misses in write-through L1 do not cause dirty writebacks to L2. S2 write-allocate must accompany write-through and no-write-allocate must accompany write-back. A only S1; B only S2; C both; D neither.
Your answer
Answer & solution
Official answer: A
Write-through propagates each L1 write to the next level, so an evicted L1 line does not need a dirty writeback to L2. S1 is true. Allocation on a write miss is a separate design choice, and the asserted mandatory policy pairing is false. Thus A; conventional write-back/write-allocate and write-through/no-write-allocate combinations already refute S2.
Separate write propagation from write-miss allocation. Write-through specifies when lower memory is updated; write-allocate specifies whether a missing block enters the cache. They are independent policy axes. Inclusion says L1-resident blocks also reside in L2; it does not reverse the normal dirty-state argument for write-through L1.
Two-state Mealy circuit replaces the first 1 of each maximal run of 1s by 0. Input 00100011000011100 produces 00000001000001100. Current state s starts at 0; current bit b; next state t; output y. A t=s+b,y=sb; B t=b,y=sb; C t=b,y=s¬b; D t=s+b,y=s¬b. Here + means OR.
Your answer
Answer & solution
Official answer: B
Step through it (4 options)
Use state s to remember the previous input bit, initialized 0. The next state is therefore t=b. Output1 is permitted only when both the previous and current bits are 1; the first 1 after 0 is suppressed. Thus y=s·b, giving B.
State/input table (s,b)→(t,y) is 00→00,01→10,10→00,11→11. A D flip-flop with D=b stores the preceding input and an AND gate computes y=Q∧b. The reset state Q=0 ensures a leading 1 is suppressed. No lookahead into future input is needed.
Independent questions A and B are correct with probabilities 0.8 and 0.5, worth 10 and 20 marks. A wrong first answer yields zero; a correct first and wrong second yields only first marks; both correct yield 30. Choose order and expectation: A A then B,14; B B then A,14; C B then A,22; D A then B,16.
Your answer
Answer & solution
Official answer: D
Attempting A first gives expected marks 0.8·10+(0.8·0.5)·20=16. Attempting B first gives 0.5·20+(0.5·0.8)·10=14. The product terms use the stated independence. Hence A then B maximizes the expectation at 16, D.
Alternatively enumerate outcomes for A first: probability 0.2 earns 0; probability 0.8×0.5 earns 10; probability 0.8×0.5 earns 30. Expectation is 4+12=16. For B first, 0.5 earns zero, 0.5×0.2 earns 20 and 0.5×0.8 earns 30, totaling 2+12=14. Expected individual question value alone does not determine the order.
Code: z=x+3+y->f1+y->f2; for(i=0;i<200;i=i+2){if(z>i){p=p+x+3;q=q+y->f1;}else{p=p+y->f2;q=q+x+3;}}. y points to a heap struct; x,y,z,p,q,i reside in registers. After common subexpression elimination, count additions and field dereferences. A (403,102); B (203,2); C (303,102); D (303,2).
Your answer
Answer & solution
Official answer: D
Compute and reuse x+3, y->f1, and y->f2. The initial expression then uses 3 additions and 2 dereferences. There are 100 loop iterations; either branch needs one addition for p and one for q, and the increment i=i+2 needs one more. Thus total additions 3+100·3=303, while both dereferenced fields remain reusable because the loop does not modify them. Answer D, under the specified CSE model.
An optimized schematic is u=x+3;v=y->f1;w=y->f2;z=u+v+w; followed by branches (p+=u;q+=v) or (p+=w;q+=u). There are 100 iterations because i runs 0,2,…,198. CSE does not erase the loop-counter addition or the two updates in either branch. The count assumes the problem's arithmetic regrouping/CSE model and no intervening field writes or aliasing stores.
Schema emp(empId,name,gender,salary,deptId), key empId, each employee in one department. Query: select deptId,count(*) from emp where gender="female" and salary>(select avg(salary) from emp) group by deptId. Counts female employees above which mean? A employees in department; B employees in company; C women in department; D women in company.
Your answer
Answer & solution
Official answer: B
The uncorrelated subquery averages salary across the entire emp relation, with no gender or department filter. The outer query counts female employees above that company-wide average, grouped by department. Thus B. Departments with no qualifying rows are omitted rather than returned with count 0. The printed double-quoted female is understood as an intended string literal; standard SQL uses single quotes, while double quotes ordinarily delimit identifiers.
The inner SELECT has no reference to the outer row, so its scalar mean is computed over all emp rows. The gender test is outside it and does not restrict that mean. GROUP BY affects the final count, not the subquery's population. This distinction separates all four options.
Schedule R1(Y),R1(X),R2(Z),R1(Y),W1(X),R2(Z),W2(Y),R3(X),W3(Z). P: conflict-serializable. Q: if T3 commits before T1 finishes, schedule is recoverable. A both; B only P; C only Q; D neither.
Your answer
Answer & solution
Official answer: B
Step through it (2 schedules)
On Y, R1(Y) precedes W2(Y), giving T1→T2. On X, W1(X) precedes R3(X), giving T1→T3. On Z, R2(Z) precedes W3(Z), giving T2→T3. This acyclic graph has serial orderT1, T2, T3, so P is true. T3 reads X written by T1; committing T3 before T1 finishes violates recoverability. Hence Q is false and B holds.
Conflicts require the same data item, distinct transactions, and at least one write. Repeated reads of Z do not introduce a reverse edge. Serializability and recoverability are distinct: an acyclic precedence graph controls equivalent ordering of operations, whereas a reads-from dependency requires the writer to commit before its reader commits.
Urn starts with r red,b black balls. Each trial draws uniformly, replaces the ball, and adds one more of that color. Four trials occur. Probability fourth draw is red? A r/(r+b); B r/(r+b+3); C (r+3)/(r+b+3); D product of (r+i)/(r+b+i) for i=0,1,2,3.
Your answer
Answer & solution
Official answer: A
Let Rk be the number of red balls after k draws and N=r+b. Given Rk, the expected red count after one more draw is Rk+Rk/(N+k). Therefore E[Rk+1/(N+k+1)|Rk]=Rk/(N+k). The expected red proportion remains r/N through all trials. The probability of red on trial 4 is E[R3/(N+3)]=r/(r+b), A.
A direct check on the second draw already shows the pattern: (r/N)((r+1)/(N+1))+(b/N)(r/(N+1))=r/N. Reinforcement makes successive colors dependent, but leaves the marginal probability unchanged. Option D is the probability that all four draws are red, which is stronger than only the fourth being red.
CRC generator x³+x+1; message 11000. Append three check bits to obtain a divisible transmitted polynomial over GF(2). Find check bits. A 101; B 110; C 100; D 111.
Your answer
Answer & solution
Official answer: C
Step through it (6 steps)
Append three zeros to 11000, obtaining 11000000. Divide over GF(2) by 1011. XOR at the leading positions gives 11000000 XOR10110000=01110000, then XOR01011000=00101000, then XOR00101100=00000100. The three-bit remainder is 100, so C. Appending100 makes the transmitted polynomial divisible by the generator.
In polynomial arithmetic coefficients are mod 2, so subtraction is XOR without borrows. Generator degree three fixes a three-bit remainder, including any leading zero. As a verification, 11000100 divided by 1011 has zero remainder. Dividing the unshifted message instead would generate the wrong checksum.
C Node has int value; Node *next. Allocate head=boxE, set value=0. For index=1..3 allocate boxN, set boxE->next=boxN, boxN->value=index, boxE=boxN. Then for index=0..3 print head->value, assign head=head->next, and print head->value again. No final next initialization occurs. A five nodes created; B infinite loop; C missing return causes compile error; D uninitialized pointer dereferenced, possibly runtime error.
Your answer
Answer & solution
Official answer: D
The initial allocation plus three loop allocations create four nodes with values 0, 1, 2, 3. The final node’s next field is never initialized. The second loop advances head and dereferences it again each iteration; on the fourth iteration it reads that uninitialized next pointer and uses it for head->value. This is undefined behavior and may cause a runtime error, D. The loops themselves have bounded iteration counts.
Before the second loop, the chain is 0→1→2→3→uninitialized. The first three iterations safely advance to nodes 1,2,3 if allocation succeeds. The last iteration prints 3, then follows the indeterminate pointer and dereferences it. Initializing next to NULL alone would still leave the unconditional extra dereference invalid; correct traversal tests the pointer before using it. Allocation failure is another issue, not needed for the intended diagnosis.
S1 every infinite regular language contains an undecidable subset. S2 every finite language is regular. A only S1; B only S2; C both; D neither.
Your answer
Answer & solution
Official answer: C
Every infinite language over a finite alphabet is countably infinite and has uncountably many subsets, whereas only countably many algorithms, hence decidable languages, exist. At least one subset is therefore undecidable, proving S1. Every finite language has a regular expression formed by union of its finitely many words, proving S2. Thus C.
The counting argument is nonconstructive: it proves an undecidable subset exists without requiring the regular language itself to encode a difficult membership test. For a finite language {w1,…,wm}, regex w1+…+wm recognizes it; the empty language is regular too. Being a subset of a decidable language does not imply decidability.
Define s(P,Q)=Σi P[i]Q[i] for real vectors. L consists of nonzero ten-dimensional vectors with s(P,Q)=0 for every distinct pair. Maximum |L|? A 9; B 10; C 11; D 100.
Your answer
Answer & solution
Official answer: B
The displayed operation is the standard inner product. Pairwise orthogonal nonzero vectors are linearly independent: dotting a zero linear combination with any member forces its coefficient to vanish. In dimension 10 there can be at most 10 such vectors. The ten standard basis vectors attain that bound, so 10, B.
If Σαi vi=0, dot with vj. Orthogonality removes every term except αj||vj||². Nonzero vj implies its squared norm is positive, hence αj=0. This is linear independence, so dimension bounds the set. Nonzero is essential: the zero vector is orthogonal to everything but would not contribute an independent direction.
USE(S) means variables used in S; IN(S),OUT(S) are live variables on entry/exit. Basic block is S1 followed by S2. A OUT(S1)=IN(S2); B OUT(S1)=IN(S1)∪USE(S1); C OUT(S1)=IN(S2)∪OUT(S2); D OUT(S1)=USE(S1)∪IN(S2).
Your answer
Answer & solution
Official answer: A
Inside a basic block S1 has S2 as its unique immediate successor. Values live just after S1 are exactly those live just before S2, so OUT(S1)=IN(S2), A. Uses at S1 do not automatically remain live afterward, and a definition in S2 can kill a value that is live after S2.
The general equations are OUT(S)=union of IN of immediate successors, and IN(S)=USE(S)∪(OUT(S)−DEF(S)). A basic block has no branch between S1 and S2, reducing the first equation to A. For example S1 reads x then S2 overwrites x: x can be used at S1 without needing to remain live after it, refuting formulas that force USE(S1) into OUT(S1).
T(n)=aT(n/b)+f(n), a>1,b>1. Let d=log_b a. A f=n log₂n implies T=Θ(n log₂n); B f=n/log₂n implies T=Θ(log₂n); C f=O(n^(d−ε)), ε>0 implies T=Θ(n^d); D f=Θ(n^d) implies T=Θ(n^d). Choose correct statement under usual running-time recurrence conventions.
Your answer
Answer & solution
Official answer: C
For the standard running-time recurrence with positive constant base cost, nonnegative work, and terminating integer-size conventions, write d=logb a. If f(n)=O(nd−ε) for ε>0, work per level increases geometrically toward the leaves and total cost is Θ(nd), Master Theorem case1, C. Equal-order work in D adds a logarithmic factor. A lacks a condition on a, b, and B is already smaller than its own n/log n root work.
At recursion depth j, there are aj nodes of size n/bj, and height logb n. Leaves number alogb n=nd. For polynomially smaller f, the sum is bounded by a geometric series of that order. At equal order every level instead costs Θ(nd), so D misses Θ(log n) levels. Taking a=b and f=n log n also refutes A, giving Θ(n log²n).
On U(P,Q,R,S,T), dependencies P→QR and RS→T hold. Which follow? A PS→T; B R→T; C P→R; D PS→Q.
Select all that apply
Answer & solution
Official answer: A; C; D
Step through it (4 parts)
P→QR gives P→R and P→Q by decomposition. With PS, derive R and retain S, then RS→T gives PS→T; also PS→Q follows by augmentation and decomposition. Starting only from R yields closure{R}, so R→T is not implied. Therefore A, C, D.
Attribute closure of PS starts {P,S}, then adds Q,R using P→QR, then T using RS→T, giving all five attributes. Closure of P is {P,Q,R}, and closure of R is only {R}. The latter is a complete test of nonimplication: no listed dependency can fire from R alone, so S cannot be conjured merely because it appears beside R in RS→T.
For w,x∈{0,1}*, w^R is reversal. Which languages are context-free? A {wxw^Rx}; B {ww^Rxx^R}; C {wxw^R}; D {wxx^Rw^R}. Empty w and x are allowed.
Select all that apply
Answer & solution
Official answer: B; C; D
B concatenates two even-palindrome languages and is context-free. C is all binary strings, since w may be empty. D is exactly the even palindromes: wx xR wR=(wx)(wx)R, and x may be empty. A is not context-free. Here is a pumping argument that accounts for empty w and x rather than merely calling the dependencies crossed. Its intersection with 0+1+0+1+ consists of 0a 1b0c1d satisfying either a=c and b-d is a nonnegative even integer, or b=d and c-a is a nonnegative even integer. This follows by examining where w and x split the first half: either w=0a 1k and x=1d, or w=0a and x=1b0k. The word 0p1p0p1p belongs. A pumping window of length at most p meets at most two adjacent blocks. Pumping a piece crossing a boundary creates extra runs when repeated. Otherwise pumping changes only those adjacent block lengths. If both change, use upward pumping for blocks 1/2 or 3/4 and downward pumping for blocks 2/3 to violate both conditions. If only one changes, increase block 1 or 4, or decrease block 2 or 3. Every possible pumping decomposition thus has a failing exponent. Closure under regular intersection proves A is not context-free. Answer B, C, D.
Constructive positive proofs: let E→0E0|1E1|ε generate even palindromes. For B use start H→EE, concatenating two such words. For C use H→0H|1H|ε, since taking w=ε yields arbitrary x. For D use E again, because the concatenated first half wx is arbitrary. These grammars establish membership instead of relying only on a visual impression of symmetry; A requires the non-CFL argument above.
Two separate processes each execute: global x=0 and global lock L1; main creates two threads running foo, joins both, prints x. foo has local y=0; acquire L1; x=x+1;y=y+1;release L1;print y. A both processes print x=2; B at least one prints x=4; C some thread prints y=2; D all four threads print y=1.
Select all that apply
Answer & solution
Official answer: A; D
Each process has its own address space, hence its own global x and lock. Within one process the lock serializes the two increments, giving x=2 after both threads finish. Each invocation has its own stack-local y, initialized to zero and incremented once, so every thread prints 1. The two processes do not share x merely because it is global. Thus A, D.
Threads share a process's global variables and synchronization objects, but ordinary separate processes do not share those objects without explicit shared-memory setup. Joining both threads ensures main prints after both increments. Each thread's y is an automatic local variable, so the lock is not needed to protect y, though it is needed for the shared x increment within each process.
One instance per resource type, exclusive ownership. OWNRESOURCE(R) acquires global lock L; if free, acquire R and release L; else if owned by another P, terminate P after freeing its resources, acquire R, restart P, release L. Select: A prevents deadlocks; B may livelock; C may starve; D violates mutual exclusion.
Select all that apply
Answer & solution
Official answer: A; B; C
Under the intended atomic termination/resource-release model, a requester never waits for another process to release its resource: it terminates that owner and takes the resource while holding L. Thus no circular resource wait develops, giving A. Two restarted processes can repeatedly take resources from and restart each other without completing, giving livelock B. An unfair execution can repeatedly kill the same process before it finishes, giving starvation C. The global lock and removal of the previous owner preserve exclusive ownership, so D is false. This assumes requests concern resources not already owned by the requester and that termination/restart do not themselves block on L; those implementation details are abstracted by the pseudocode.
For a livelock witness, let P hold A and Q hold B. P requests B, kills and restarts Q; later restarted Q requests a resource now held by P and kills/restarts P. Repeating such interference can prevent either from completing despite activity. A lock provides mutual exclusion, not fairness or progress. The answer depends on treating termination and resource release as atomic successful operations in the model.
The same two bytes represent an unsigned value 255 greater under little endian than big endian. Which little-endian hexadecimal values qualify? A 0x6665; B 0x0001; C 0x4243; D 0x0100.
Select all that apply
Answer & solution
Official answer: A; D
For bytes a, b in increasing address order, little-endian value is 256b+a and big-endian value is 256a+b. Their difference 255(b-a) equals 255 exactly when b=a+1. A little-endian numeral must therefore have its high-order byte one larger than its low-order byte. 0x6665 and 0x0100 satisfy this; 0x0001 and 0x4243 have the opposite sign of difference. Answer A, D.
Evaluate options numerically without decimal conversion: byte swap of 0x6665 is 0x6566, difference 0x00FF; swap of 0x0100 is 0x0001, also 0x00FF. The other two have differences −255. Unsigned means the ordinary nonnegative two-byte values, not a signed interpretation of either byte.
Distance-vector routing: R→X,Y,Z link costs 3,2,5. Advertised distances X,Y,Z→P are 7,6,5; to Q are 4,6,8. Update R. A P distance 10; B Q distance 7; C P next hop Y; D Q next hop Z.
Select all that apply
Answer & solution
Official answer: B; C
Bellman-Ford updates R-to-P with min(3+7, 2+6, 5+5)=8, reached through Y. For Q it uses min(3+4, 2+6, 5+8)=7, reached through X. Hence B, C, not A or D.
The update formula is D_R(v)=min_N(c(R,N)+D_N(v)). For P the three candidates are 10,8,10; for Q they are 7,8,13. Store both the minimum cost and its minimizing neighbor. Choosing the neighbor with the cheapest direct link alone would pick Y for both and be wrong for Q.
Directed graph is the 4×4 vertex grid in the embedded figure; S is bottom-left. A no topological order; B DFS from S classifies exactly three directed edges as back edges; C no strongly connected component; D every ordered pair is mutually reachable.
Select all that apply
Answer & solution
Official answer: A; B
Label grid positions (row, column), top to bottom and left to right. There are three nontrivial SCCs, each a directed four-cycle: {(3, 1),(4, 1),(4, 2),(3, 2)}, {(3, 3),(4, 3),(4, 4),(3, 4)}, and {(1, 2),(2, 2),(2, 3),(1, 3)}. Other vertices are singleton SCCs. Each directed cycle contributes exactly one DFS back edge; edges between SCCs cannot be back edges, since a back edge would make its endpoints mutually reachable. All vertices are reachable from S, so DFS finds exactly three back edges, B. The cycles preclude a topological order, A. C is false, and D is false because the top-right vertex is a sink and cannot reach S.
In each four-cycle, DFS follows the sole internal successor until the closing edge points to a gray ancestor, giving one back edge. Exploring outgoing edges to other components cannot create another such ancestor return, because that would imply a return path and merge the components. A graph always has SCCs, even if all were singletons; C is therefore also terminologically wrong.
Which regexes describe binary multiples of three, allowing leading zeros and ε? A (0+1(01*0)*1)*; B (0+11+10(1+00)*01)*; C (0*(1(01*0)*1)*)*; D (0+11+11(1+00)*00)*. + denotes union.
Select all that apply
Answer & solution
Official answer: A; B; C
Use the remainder automaton r→(2r+b) mod3, start/accept 0. A describes concatenated excursions from 0: a 0 stays at 0, while 1 enters remainder 1, any number of blocks 01*0 returns to 1 via remainder 2, and final 1 returns to 0. B describes the same excursions by separating 11 from 10(1+00)*01: at remainder 2, either 1 or 00 loops back to 2, then 01 exits to 0. C is equivalent to A because arbitrary concatenations of zeros and nonzero excursions can be grouped into runs of zeros followed by runs of excursions. D is wrong: it cannot generate 1001 (binary9); every nonempty D word beginning 1 begins 11. Thus A, B, C. Leading zeros and the empty string are allowed as stated.
The remainder transition table is 0:0→0,1→1; 1:0→2,1→0; 2:0→1,1→2. A complete path from 0 back to 0 can be decomposed at every visit to state 0. This yields the excursion regex used in A. The counterexample 1001 has numeric value 9, so rejecting it conclusively refutes D without needing exhaustive enumeration.
39-bit virtual address splits as 9-bit level1,9-bit level2,9-bit level3,12-bit offset. Pages are 4KB and all PTEs 8 bytes. Process maps 2GB virtual to 2GB physical. Find minimum total page-table memory in KB, with binary KB/GB.
Answer & solution
Official answer: 4108
Each page-table page holds 4096/8=512 entries. The2GB mapping needs 231/212=219 leaf entries, hence 1024 level3 pages. Packing these contiguously minimizes higher levels: 1024/512=2 level2 pages and one level1 root page. Total=(1024+2+1)*4KB=4108KB. This is the minimum with allocated whole page-table pages and a densely placed virtual mapping.
Each level-2 page indexes up to 512 level-3 pages, which collectively map 512×512×4KB=1GB. Thus the 2GB region can occupy two such subtrees under one root. Sparse placement could require more page-table pages; the word minimum permits contiguous, suitably aligned placement. Physical page contents consume 2GB but are not part of page-table overhead.
foo(x,y,q): if x≤0 and y≤0 return q; if x≤0 return foo(x,y−q,q); if y≤0 return foo(x−q,y,q); otherwise return foo(x,y−q,q)+foo(x−q,y,q). What does printing foo(15,15,10) yield?
Answer & solution
Official answer: 60
Step through it (33 steps)
With q=10, each initial coordinate 15 requires two decrements to become nonpositive. When both remain positive the recursion branches on which coordinate decreases; once one is nonpositive only the other can decrease. Thus leaves correspond to the six interleavings of two x decrements and two y decrements, binomial(4, 2)=6. Each leaf returns 10, so the output is 60. There are no side effects across recursive calls, so unspecified operand evaluation order does not affect this sum.
Let F(i,j) denote the return with i,j remaining decrements needed. Interior recurrence F(i,j)=F(i−1,j)+F(i,j−1), with F(i,0)=F(0,j)=10. Hence F(1,1)=20, F(1,2)=F(2,1)=30, F(2,2)=60. The base is reached at −5, not necessarily exactly zero, because tests are nonpositive.
S has ten elements. Count ordered pairs (A,B) with A⊆B⊆S. Equality is permitted.
Answer & solution
Official answer: 59049
For each of the 10 elements choose exactly one of three states: outside B, in B but not A, or in A (and therefore in B). Choices are independent, giving 310=59049 ordered pairs. The source symbol is subset-or-equal, so A=B is included.
A second derivation sums by |B|: for each k choose B in binomial(10,k) ways, then any of its 2k subsets A. Thus Σ binomial(10,k)2k=(1+2)10. Counting 410 would allow the forbidden state “in A but outside B”; subtracting equality would answer the strict-subset variant rather than this question.
Augmented grammar S′→S; S→S#cS | SS | S@ | <S> | a | b | c. I0=CLOSURE({S′→·S}). Count LR(0) items in GOTO(GOTO(I0,<),<).
Answer & solution
Official answer: 8
Step through it (4 steps)
On reading < from the initial closure the kernel is S→<·S>. Its closure adds all seven S productions with the dot at the beginning: S→·S#cS, ·SS, ·S@, ·<S>, ·a, ·b, ·c. Reading a second < reproduces exactly the same kernel and closure. Thus GOTO(GOTO(I0,<),<) has 1+7=8 items; the augmented S-prime item is not added because closure expands only S.
The resulting item set is {S→<·S>, S→·S#cS, S→·SS, S→·S@, S→·<S>, S→·a, S→·b, S→·c}. Recursive closure does not create infinitely many copies: items are set members. In particular, productions beginning with S are added once and their expansion adds no new productions beyond the seven already present.
Boolean f(w,x,y,z) satisfies f(w,0,0,z)=1; f(1,x,1,z)=x+z; f(w,1,y,z)=wz+y. Find minimum number of literals in an SOP, noting incompletely specified inputs. + means Boolean OR.
Answer & solution
Official answer: 6
The supplied cofactors force on-set minterms 0, 1, 6, 7, 8, 9, 11, 13, 14, 15 and off-set 4, 5, 10, 12. Minterms2, 3 are unspecified and may be used as dont-cares for minimization. One minimum SOP is (NOT x)(NOT y)+xy+wz, containing 6 literals. No one-literal implicant avoids all forced zeros. Moreover on-set points 0, 6, 13 cannot be covered pairwise by a single implicant: their covering cubes would include a forced zero. At least three terms, each with at least two literals, are required, proving the lower bound 6. Treating unspecified cofactors as dont-cares is the minimization convention used here. The supplied equations do not uniquely specify f: for example assigning f(0, 0, 1, 0)=1 and f(0, 0, 1, 1)=0 requires a separate three-literal implicant for minterm 2, while minterms 1, 14, 13 force the three essential prime implicants (NOT x)(NOT y), xy, wz respectively. That completion needs 9 literals, not 6. Thus the official 6 is the minimum over permissible completions, not a forced value for every function satisfying the three equations.
Shannon cofactor constraints leave only minterms 2 and 3 free. The three two-literal cubes ¬x¬y,xy,wz cover the forced on-set and avoid zeros 4,5,10,12. A literal count counts occurrences, so three terms with two literals cost six, not three. The witness completion that needs nine literals must remain disclosed because minimization over don't-cares is an assumption, not a logical consequence that f is uniquely fixed.
Five-stage IF,ID,EX,MEM,WB pipeline; stages each one cycle except MUL EX needs two; ADD EX needs one. ID only decodes; register read happens in EX. Eight instructions alternate ADD,MUL starting ADD, each dependent on previous. Ignore pipeline register delays. Find execution time without forwarding divided by time with forwarding, rounded to two decimals.
Answer & solution
Official answer: 1.87 to 1.88
Our answer: 1.88
With forwarding, dependent instructions enter EX immediately after the previous EX result is ready. EX occupies cycles 3; 4–5; 6; 7–8; 9; 10–11; 12; 13–14. The last WB is cycle 16. Without forwarding, register operands must wait for the previous instruction to finish WB: EX intervals 3; 6–7; 10; 13–14; 17; 20–21; 24; 27–28, and final WB30. Thus speedup=30/16=1.875, rounding to 1.88, inside official 1.87–1.88. This uses the intended cycle-boundary model: a WB result becomes available to an EX register read in the following cycle. Allowing same-cycle WB-to-EX visibility would require a different timing convention; the prompt does not explicitly specify subcycle register timing.
For any instruction with EX finishing in cycle c, MEM occurs c+1 and WB c+2. Forwarding allows the dependent EX to start c+1, whereas the adopted no-forwarding convention requires c+3. Initial IF,ID place first EX in cycle 3; the last instruction then needs two drain cycles after EX. Counting only EX work or omitting pipeline fill/drain produces an incorrect speedup.
Pure ALOHA frames are 1000 bits over 1Mbps. All attempts, including retries, are Poisson at 1000 frames/s. Find successful frames/s, rounded to nearest integer.
Answer & solution
Official answer: 130 to 140
Our answer: 135
A frame occupies 1000/106=0.001 seconds. For pure ALOHA the vulnerable period is twice that, 0.002 seconds. Given the stated Poisson attempt rate 1000 per second, the chance of no competing attempt in that interval is exp(-1000*0.002)=e-2. Successful throughput is 1000e-2=135.335 frames/second, rounding to 135, within the official 130–140 interval.
Let frame duration τ=0.001s and total offered load G=λτ=1. Pure ALOHA success probability is e−2G, unlike slotted ALOHA's e−G. Thus normalized throughput is Ge−2G frames per frame-time, or λe−2G frames/s. Retry attempts are already included in λ and must not be added again.
DAG vertices s,a,b,c,d,e,f,g,t. Edges with weights: s→a 9,s→c 1,a→b 1,a→d 1,c→d 1,c→f 9,d→e 9,d→g 9,b→e 1,f→g 1,g→t 1,e→t 9. Path score is edge-weight product; vertex score is largest path score from s; score(s)=1. Find sum of all vertex scores.
Answer & solution
Official answer: 929
Step through it (10 steps)
Process vertices topologically with Q(v)=max over predecessors u of Q(u)*weight(u, v), starting Q(s)=1. The diagram yields Q(a)=9, Q(c)=1, Q(b)=9, Q(d)=max(1, 9)=9, Q(f)=9, Q(e)=max(9, 81)=81, Q(g)=max(9, 81)=81, Q(t)=max(81, 729)=729. Sum=1+9+1+9+9+9+81+81+729=929.
A topological dynamic program initializes score(s)=1 and all other scores=0, then for each edge u→v sets score(v)=max(score(v),score(u)×weight). A predecessor ordering such as s,a,b,c,d,e,f,g,t suffices. It runs in O(V+E), since a DAG has no profitable cycle to revisit. Store parent pointers when maximizing if an actual maximizing path is also wanted.