Choose the words for: ___ bringing ___ books from ___. A Their/they’re/there; B They’re/their/there; C There/their/they’re; D They’re/there/there.
Your answer
Answer & solution
Official answer: B
Method
Identify the grammatical job of each blank before choosing a spelling. The first blank needs a subject plus auxiliary verb, the second modifies the noun books, and the last answers the question where. Expanding the contraction gives “They are bringing their books from there”, a complete sentence. Quotation marks around the offered words are not part of the answer.
Solution
They’re means they are, their marks possession, and there identifies the place. Thus They’re bringing their books from there, B.
An investigation that is ___ can occasionally reveal facts, but organized investigations usually succeed more. Choose A meandering; B timely; C consistent; D systematic.
Your answer
Answer & solution
Official answer: A
Method
The conjunction “but” introduces a contrast, not a synonym. An organized investigation follows a plan; a meandering one wanders from topic to topic. Timely describes when something happens, while consistent and systematic support rather than oppose organized work. Thus the contrast in the whole sentence, rather than the positive phrase “yield new facts” alone, determines the choice.
Solution
Meandering means wandering or lacking a direct plan, contrasting with the organized investigations described as more successful. Thus A.
A square has area d. A circle uses its diagonal as diameter. Find the circle area: A πd; B πd²; C πd²/4; D πd/2.
Your answer
Answer & solution
Official answer: D
Method
Let the side be s, so s²=d. Pythagoras applied to two adjacent sides gives diameter²=s²+s²=2d. A circle area is π times radius squared, not diameter squared: radius²=(diameter/2)²=2d/4. As a dimensional check, the result must be proportional to d; terms proportional to d² have the wrong area scaling.
Solution
A square of area d has side√d and diagonal√(2d). The circle radius is half that diagonal, so its area isπ(2d)/4=πd/2, D.
Find the smallest natural number leaving remainder 7 when divided by any of 20, 42, 76. Choices: A 3047; B 6047; C 7987; D 63847.
Your answer
Answer & solution
Official answer: C
Our answer: 7 literally; intended C=7987
Method
Subtracting the common remainder converts three congruences to divisibility conditions. Factor 20=2²·5, 42=2·3·7, and 76=2²·19. Take the highest exponent of each prime, not the product of all three divisors. All nonnegative solutions are 7+7980t for integers t≥0. The intended option uses t=1; checking the boundary t=0 exposes the wording defect rather than a calculation error.
Solution
The congruences say N−7 is divisible by 20, 42, 76. Their least common multiple is 2²·3·5·7·19=7980. The least solution with positive quotients is 7987, C. However7 itself is a natural number and leaves remainder 7 on division by all three divisors with quotient 0. The source omits a condition such as N greater than the divisors, so the literal smallest answer is 7, absent from the options.
Complete 2, 12, 60, 240, 720, 1440, ?, 0. Choices: A 2880; B 1440; C 720; D 0.
Your answer
Answer & solution
Official answer: B
Method
Check ratios of successive nonzero terms: 12/2=6, 60/12=5, 240/60=4, 720/240=3, and 1440/720=2. Continuing these integer multipliers with 1 then 0 accounts for both the blank and the supplied final term. Multiplying immediately by 0 would omit the next multiplier. As with finite sequence puzzles, this is the intended simple pattern, not a uniqueness theorem over arbitrary sequence rules.
Solution
Successive multipliers are 6, 5, 4, 3, 2, 1, 0. The missing term is 1440·1=1440, followed by 0, B. This uses the intended descending-multiplier sequence rule.
Among 300 eligible seniors, each man may claim Rs 750 and each woman Rs 1000. Fractions claiming are 8/9 of men and 2/3 of women. Find total rupees paid: A 150000; B 200000; C 175000; D 151000.
Your answer
Answer & solution
Official answer: B
Method
Do not assume 150 men and 150 women. Let their eligible counts be M and F. Multiplying each award by its claiming fraction gives the payout per eligible person of that category: 750·8/9=2000/3 and 1000·2/3=2000/3. These coefficients are equal, so the unknown split cancels. The fractions describe the recipients, not reductions in the individual award.
Solution
Let M+F=300. The payout is 750·(8M/9)+1000·(2F/3)=(2000/3)(M+F)=200000 rupees, B. Therefore the male/female split need not be known.
Given pqr≠0, p^(−x)=1/q, q^(−y)=1/r, r^(−z)=1/p, find xyz. Choices: A −1; B 1/(pqr); C 1; D pqr.
Your answer
Answer & solution
Official answer: C
Our answer: C under nonunit positive-base assumption
Method
Under the usual positive nonunit-base interpretation, taking reciprocals gives px=q, qy=r and rz=p. Logs therefore give x ln p=ln q, y ln q=ln r, z ln r=ln p. Multiplication cancels only when these logarithms are nonzero. That condition is not implied by pqr≠0. For example, choosing all bases 1 and x=y=z=2 satisfies the written equations but yields product 8.
Solution
For positive p, q, r different from 1, the equations give x=log q/log p, y=log r/log q, z=log p/log r. Multiplying cancels the logarithms and gives xyz=1, C. But the stated condition pqr≠0 allows p=q=r=1; then all three equations hold for arbitrary x, y, z, so the product is undetermined. The official answer needs a nonunit-base/domain qualification.
Invitations are 60% male and 40% female. Overall attendance is 80%, with every invited woman attending. What is the male:female attendance ratio? A 2:3; B 1:1; C 3:2; D 2:1.
Your answer
Answer & solution
Official answer: B
Method
Normalize invitations to 100 to avoid an unnecessary unknown. All 40 invited women attend; total attendance is 80, leaving 80−40=40 male attendees. The 20 nonattendees must all be men. The requested ratio concerns attendees, so using the invitation ratio 60:40 would answer a different question.
Solution
Out of 100 invited guests, 40 women attend and 80 people attend in total. Thus40 men attend, and the ratio is 40: 40=1: 1, B.
In the diagram, A,D,E lie in that order on one line; A,B,F on another; E,C,B are collinear; D,C,F are collinear. Find ∠DEC+∠BFC. Choices: A ∠BCD−∠BAD; B ∠BAD+∠BCF; C ∠BAD+∠BCD; D ∠CBA+∠ADC.
Your answer
Answer & solution
Official answer: A
Method
Use triangle angle sums together with supplementary angles on straight lines. Label α=∠BAD, β=∠DEC, γ=∠BFC. Because AD and AE are the same ray and EC and EB are the same ray, triangle AEB has angles α and β at A and E. At B, extending AB to BF changes its interior angle to its supplement. At C, extending DC to CF supplies the second supplementary-angle relation. No lengths or apparent angle sizes are needed.
Solution
Let α=angle BAD, β=angle DEC, γ=angle BFC. From triangle AEB, angle ABE=180°−α−β. Since BA and BF are opposite rays, angle CBF=α+β. Triangle BCF gives angle BCF=180°−α−β−γ. Since CD and CF are opposite rays, angle BCD=α+β+γ. Hence β+γ=angle BCD−angle BAD, A. Collinearities were checked in the original diagram.
A fair six-faced die has four green and two red faces. After seven independent rolls, which count is most likely? A 3 green/4 red; B 4/3; C 5/2; D 6/1.
Your answer
Answer & solution
Official answer: C
Method
The event specifies a count, not a particular ordering. Therefore include the binomial factor: P(K=k)=C(7,k)(2/3)k(1/3)7−k. For the four options, the numerators over the common denominator 37 are 280, 560, 672 and 448. Five greens has the largest numerator. Simply maximizing the probability of an individual ordered sequence would incorrectly ignore how many arrangements produce each count.
Solution
If K counts green faces, K is binomial with n=7, p=2/3. Its unique mode is floor((7+1)·2/3)=5. Equivalently consecutive probability ratios are P(K=k+1)/P(K=k)=2(7−k)/(k+1), above 1 through k=4 and below 1 at k=5. Five green and two red is most likely, C.
For a_n=2n+3, n≥0, find the ordinary generating function Σa_n x^n. Choices: A 3/(1−x)²; B 3x/(1−x)²; C (2−x)/(1−x)²; D (3−x)/(1−x)².
Your answer
Answer & solution
Official answer: D
Method
Start from Σxn=1/(1−x). Differentiate to obtain Σn xn−1=1/(1−x)² and multiply by x. Linearity now separates the 2n part from the constant 3 part. Combining over one denominator gives numerator 2x+3(1−x)=3−x. A quick constant-term check requires value a0=3 at x=0, already ruling out B and C.
Solution
The ordinary generating function is sum(2n+3)xn=2x/(1−x)²+3/(1−x)=(3−x)/(1−x)², D, as a formal power series or for |x|<1.
C declares struct Ournode { char x,y,z; }; initializes p={'1','0','a'+2}; sets q=&p; and prints printf("%c, %c", *((char*)q+1), *((char*)q+2)). Choices: A 0, c; B 0, a+2; C '0', 'a+2'; D '0', 'c'.
Your answer
Answer & solution
Official answer: A
Our answer: A under conventional layout and character encoding
Method
The cast occurs before pointer arithmetic: a char pointer advances by one byte, whereas adding 1 to a struct pointer would advance by a whole struct. Under the intended layout, offsets 1 and 2 select y and z. The expression 'a'+2 is evaluated numerically during initialization, not printed as source text. The %c conversion prints the represented character without surrounding quote marks. Keep the implementation assumptions below separate from the intended exam output.
Solution
With consecutive char members at byte offsets 0, 1, 2, the two dereferences read y and z. In an ASCII-compatible execution character set, y is the character 0 and z is c from a+2, giving 0, c, A. Strict ISO C permits internal struct padding and does not universally require contiguous alphabetic codes. The result therefore assumes the conventional padding-free char layout and character encoding used by the question.
A noncircular singly linked queue stores head and tail pointers. Enqueue inserts at head; dequeue removes tail. For n nodes, choose the optimal worst-case time pair: A Θ(1),Θ(1); B Θ(1),Θ(n); C Θ(n),Θ(1); D Θ(n),Θ(n).
Your answer
Answer & solution
Official answer: B
Method
Enqueue sets new.next=head and head=new, also initializing tail if previously empty. Tail removal must change the predecessor’s next pointer to null and make it the new tail. A tail pointer identifies the node to remove but not its predecessor, because links point only forward. Scanning from head is unavoidable with only these stored pointers. Reversing the operation orientation would allow constant-time deletion at head, but that is not this question’s data structure.
Solution
Inserting at the head updates a constant number of pointers, Θ(1). Removing the tail requires locating its predecessor, which a singly linked list with only head/tail pointers does not directly supply; traversing n nodes costsΘ(n) in the worst case. Thus B.
Let ⊕ be XOR and ⊙ XNOR. Which identity is false? A ¬(P⊕Q)=P⊙Q; B (¬P)⊕Q=P⊙Q; C (¬P)⊕(¬Q)=P⊕Q; D (P⊕¬P)⊕Q=(P⊙¬P)⊙¬Q.
Your answer
Answer & solution
Official answer: D
Method
XOR is 1 exactly when its inputs differ; XNOR is its complement. Complementing one input changes “different” to “equal”, proving B, while complementing both preserves whether they differ, proving C. In D simplify the inner gates first, rather than assuming associativity transfers between XOR and XNOR. A concrete counterexample is Q=0: the left evaluates to 1 and the right to 0, regardless of P.
Solution
In D, P XOR not-P=1, so the left side is not-Q. Meanwhile P XNOR not-P=0, and 0 XNOR not-Q=Q. The sides are opposite, so D is false. Complementing a single XOR input gives XNOR, while complementing both leaves XOR unchanged, validating the other identities.
Which characterize conventional RISC design? I arithmetic only register-to-register; II fixed-length instructions; III hardwired control. Choices: A I,II; B II,III; C I,III; D all three.
Your answer
Answer & solution
Official answer: D
Method
A load/store design keeps arithmetic operands in registers and uses separate instructions for memory transfers. Regular instruction lengths simplify fetching and decoding, while simple instruction semantics support direct hardwired control instead of a large microprogram. These properties work together to simplify pipelining. The question asks about the conventional design model; modern instruction-set families can have compressed encodings or other extensions without making the textbook characterization invalid.
Solution
The conventional RISC design combines register-to-register arithmetic, fixed-length instruction encoding and hardwired control. All three listed characteristics apply, D. These are textbook design characteristics, not a claim that every modern RISC extension has identical instruction lengths.
An NFA has n states. Its equivalent minimal DFA has k states. Which is always true? A k≥2^n; B k≥n; C k≤n²; D k≤2^n.
Your answer
Answer & solution
Official answer: D
Method
A DFA must remember the entire set of NFA states that could currently be active. There are 2n subsets of an n-element set. Some subsets may be unreachable and some reachable ones may be equivalent, so both reachability pruning and minimization can reduce this bound. There is no general lower bound k≥n: an NFA can contain many redundant states while accepting a language recognized by one DFA state. Some NFA families require exponentially many DFA states, ruling out a universal quadratic bound.
Solution
Subset construction represents each DFA state by a subset of the NFA’s n states, so at most 2n states are needed, including a possible empty subset. Minimization cannot increase that count. Thus k≤2n, D.
For recursively enumerable languages, choose the true statement: A closed under complement; B closed under intersection; C all are recursive; D there are uncountably many.
Your answer
Answer & solution
Official answer: B
Method
A recognizer may run forever when the input is not in its language. For intersection, sequential simulation is sufficient: run the first recognizer and, if it accepts, run the second and accept only if it also accepts. An input in both languages reaches both acceptances; if the first simulation loops, that input is outside the intersection, where looping is permitted. Dovetailing is another valid construction, not a requirement here. Unlike intersection, union requires avoiding a loop in one recognizer that hides acceptance by the other. Finite machine descriptions are countable, and recognizable but undecidable languages refute C.
Solution
To recognize the intersection of two recursively enumerable languages, dovetail their recognizers on the same input and accept when both accept. Hence intersection closure holds. Complement closure would make every recognizable language decidable, which is false; encodings of recognizers are countable. Thus B.
Choose the false claim: A CFGs can specify lexical and syntactic rules; B type checking precedes parsing; C high-level code can translate to different intermediate representations; D function arguments can be passed on the program stack.
Your answer
Answer & solution
Official answer: B
Method
Parsing identifies constructs such as expressions, declarations and function calls. Type checking applies rules to those constructs and their symbol-table information, so the conventional dependency is syntax before semantic type checking. A compiler may interleave actions during parsing, but that does not establish the blanket claim in B. Regular token languages are also context-free, which is why A is expressively valid even though practical lexers usually use regular expressions.
Solution
Parsing supplies the syntactic structure on which conventional type checking operates, so saying type checking is performed before parsing is false, B. CFGs can express regular lexical rules as well as syntax, multiple intermediate representations are possible, and stack argument passing is standard.
After an interrupt during process L: P saves L status on control stack; Q finishes current instruction; R executes ISR; S restores L status; T loads ISR PC. Choose A QPTRS; B PTRSQ; C TRPQS; D QTPRS.
Your answer
Answer & solution
Official answer: A
Method
At an instruction boundary the processor has a consistent state to save. Save that state before replacing the program counter, otherwise the return address and other status could be lost. Loading the interrupt-vector target transfers control to the handler; restoring saved state is meaningful only after the handler finishes. The model describes an ordinary precise interrupt, not an exception that aborts and restarts the current instruction.
Solution
Complete the current instruction(Q), save the interrupted process state(P), load the ISR entry PC(T), run the ISR(R), and restore the saved state(S). The order is QPTRS, A.
A memory access costs M when resident and total D when it faults. Observed mean is X. Find fault rate: A (D−M)/(X−M); B (X−M)/(D−M); C (D−X)/(D−M); D (X−M)/(D−X).
Your answer
Answer & solution
Official answer: B
Method
Partition accesses into the two mutually exclusive outcomes. With fault probability f, their probabilities are f and 1−f, not two independent rates. The weighted mean X=M+f(D−M) interpolates between M at f=0 and D at f=1. These endpoints immediately distinguish the fault probability from C, which is the hit probability. For ordinary D>M, valid observations satisfy M≤X≤D.
Solution
If f is the fault rate, X=(1−f)M+fD=M+f(D−M). Therefore f=(X−M)/(D−M), B, assuming the stated fault access time D is the total fault-case time and D≠M.
R is a many-to-one relation E1→E2. Both entity sets participate totally and |E1|>|E2|. Which holds? A each E1 entity has exactly one E2 partner; B some E1 entity has multiple E2 partners; C each E2 entity has exactly one E1 partner; D each E2 entity has at most one E1 partner.
Your answer
Answer & solution
Official answer: A
Method
Treat the relation as a mapping from E1 into E2. “Many-to-one” imposes an upper bound of one on each E1 entity’s partners, and “total participation” imposes a lower bound of one. Together they force exactly one. On the E2 side total participation makes the map surjective, while the larger source cardinality invokes the pigeonhole principle: at least one E2 entity receives two or more partners.
Solution
Many-to-one permits at most one E2 target per E1 entity. Total participation of E1 supplies at least one, hence exactly one. Total participation of E2 and |E1|>|E2| ensure some E2 target has multiple preimages, not exactly one each. Thus A.
For Book(isbn,bname) and Stock(isbn,copies), all queries select B.isbn,S.copies and join on equal isbn. Queries 1–4 respectively use INNER, LEFT OUTER, RIGHT OUTER and FULL OUTER JOIN. Which result necessarily contains the other three? A 1; B 2; C 3; D 4.
Your answer
Answer & solution
Official answer: D
Method
Divide possible output rows into matched pairs, unmatched Book rows and unmatched Stock rows. An inner join emits only the first group. A left join additionally emits unmatched Book rows with null Stock columns; a right join analogously preserves unmatched Stock rows. A full join includes all three groups. Even after the common projection, every row generated by a narrower join still occurs in the full join, with at least the same multiplicity.
Solution
The full outer join includes every matched pair plus all unmatched rows from each side padded by nulls. The inner and either one-sided outer join produce subsets of those rows after the same projection. Thus Query4, D; this remains a superset under SQL bag multiplicities.
Match P UDP port, Q Ethernet MAC address, R IPv6 Next Header, S TCP sequence number to I 48, II 8, III 32, IV 16 bits. Options: A P-III,Q-IV,R-II,S-I; B P-II,Q-I,R-IV,S-III; C P-IV,Q-I,R-II,S-III; D P-IV,Q-I,R-III,S-II.
Your answer
Answer & solution
Official answer: C
Method
A UDP source or destination port is a 16-bit field, allowing 65536 numeric values. A conventional Ethernet address is six octets, hence 48 bits. IPv6 Next Header is a one-octet protocol identifier, not a pointer-sized field. TCP’s sequence space has 232 byte positions. These independent facts yield the complete matching; confusing byte lengths with bit lengths is the main arithmetic trap.
Solution
UDP port numbers have 16 bits; Ethernet MAC addresses 48; IPv6 Next Header8; TCP sequence numbers 32. Therefore P-IV, Q-I, R-II, S-III, C.
During textbook slow start consider: i cwnd increases by 2 MSS per ACK; ii doubles per ACK; iii increases by 1 MSS per RTT; iv approximately doubles per RTT. Choose A ii,iii; B i,iii; C iv only; D i,iv.
Your answer
Answer & solution
Official answer: C
Method
Suppose cwnd is w MSS at the start of a round, so approximately w full segments are sent. Each successful ACK adds roughly one MSS, and the w acknowledgments add w MSS in total. The next round therefore starts near 2w MSS. This is exponential growth by rounds, not by individual ACKs. A one-MSS increase per RTT describes the rough congestion-avoidance behavior instead of slow start.
Solution
In textbook slow start, each ACK increases cwnd by approximately one MSS. With one ACK per segment in a full window, one RTT supplies about cwnd/MSS ACKs, approximately doubling the window. Only iv is true, C. Delayed ACKs and implementation details qualify the approximate doubling.
Each of two players independently rolls a fair six-faced die per trial; ties cause a retry. Find the probability that the game first has a winner on trial 3, rounded to three decimals.
Answer & solution
Official answer: 0.021 to 0.024
Our answer: 0.023
Method
Of the 36 equally likely ordered roll pairs, six are ties: (1,1) through (6,6). The other 30 yield a winner, regardless of which player wins. To reach trial 3, the first two trials must both tie; the third must be non-tied. Independence permits multiplying these three probabilities. Do not multiply by an extra factor 2 for the two players: the decisive probability already includes both possible winners.
Solution
A trial ties with probability 6/36=1/6 and is decisive with probability 5/6. Winning first on trial 3 requires two ties then a decisive roll, probability(1/6)²(5/6)=5/216≈0.023148, rounded 0.023.
Evaluate ∫ from 0 to π/4 of x cos(x²) dx, using π=3.14 and rounding to three decimals.
Answer & solution
Official answer: 0.27 to 0.30
Our answer: 0.289
Method
The derivative of the inner argument x² is 2x, so the factor x dx is half of du. The transformed upper bound is (3.14/4)²=0.616225, not 3.14/4. Thus the integral is one half of the sine of 0.616225 radians. The integrand is positive throughout this interval, consistent with a positive answer smaller than ∫x dx=0.3081125.
Solution
Substitute u=x², du=2x dx. The integral is(1/2)sin(x²) evaluated at 0 andπ/4, hence(1/2)sin((3.14/4)²)≈0.288979, rounded 0.289.
Let u=(1,2)^T, v=(1,1)^T and A=uv^T. Find the largest eigenvalue.
Answer & solution
Official answer: 3
Method
Write out the matrix to make the outer-product order explicit: A=[[1,1],[2,2]]. Its characteristic polynomial is (1−λ)(2−λ)−2=λ²−3λ=λ(λ−3), giving eigenvalues 0 and 3. This independently confirms the rank-one shortcut below. The scalar vTu is not the same matrix as uvT; it supplies the nonzero eigenvalue because applying A to u returns a scalar multiple of u.
Solution
A=uvT has rank 1. Its nonzero eigenvalue is vTu=1+2=3, since Au=u(vTu)=3u. The other eigenvalue is 0, so the largest is 3.
The undirected graph has vertices a,b,c,d,e,f and edges ab, ac, ae, bc, bd, bf, cd, ce, df, ef. Find its chromatic number.
Answer & solution
Official answer: 3
Method
A coloring result needs both a lower bound and a construction meeting it. The cycle a–b–c–a is a triangle, whose mutually adjacent vertices demand three different colors. Assign color 1 to a,d; color 2 to b,e; color 3 to c,f. Each of the ten listed edges connects different colors, so three suffice. Merely finding a triangle would not alone exclude a need for four or more colors elsewhere.
Solution
Vertices a, b, c form a triangle, so at least 3 colors are necessary. Thus the chromatic number is 3.
Similar questions2 more → · asked again: GATE 2020, Q18
Largest possible proper subgroup
Algebraic Structures
Tap to enlarge
A finite group has 84 elements. What is the largest possible order of a proper subgroup?
Answer & solution
Official answer: 42
Our answer: 42 as the largest possible order
Method
For H≤G, cosets partition G into equally sized sets, so |G|=[G:H]|H|. Properness means index [G:H]≥2, hence |H|≤42. To show that the upper bound is possible rather than just necessary, use the cyclic group of order 84: its subgroup generated by the square of a generator has order 84/gcd(84,2)=42. The word “possible” matters because Lagrange’s divisibility condition does not generally guarantee a subgroup for every divisor in every group.
Solution
Lagrange’s theorem requires a subgroup order to divide 84. The greatest proper divisor is 42, and this is achievable in the cyclic group C84. Thus the largest possible order is 42. This is an attainable bound over groups of order 84, not a guarantee that every such group has a subgroup of order 42.
Postorder is 8,9,6,7,4,5,2,3,1 and inorder is 8,6,9,4,7,2,5,1,3. Height counts edges on a longest root-to-leaf path. Find the height.
Answer & solution
Official answer: 4
Method
Postorder ends with the root, and inorder splits each subtree into left part, root, right part. Root 1 splits off right leaf 3. Its left subtree ends in 2, whose inorder split leaves right leaf 5 and left subtree rooted at 4. Continuing gives 4 with children 6 and 7, and 6 with children 8 and 9. There are five vertices but four edges on the longest path, so do not report the number of levels.
Solution
The final postorder element gives root1, with right child3 and left subtree rooted 2. In that left subtree, 5 is the right child, while 4 is the left child of 2; 4 has left child6 and right child7, and 6 has children 8, 9. A longest path is 1→2→4→6→8, four edges. Thus height 4.
Global int counter starts at 0. calc(a,b) increments counter, returns a*a*a if b==3, otherwise sets c=calc(a,b/3) and returns c*c*c. main calls calc(4,81), discards its return, then prints counter. Find the intended output.
Answer & solution
Official answer: 4
Our answer: 4 in intended call-count model; signed-overflow caveat
Method
Count activations on the descent separately from arithmetic on the return path. Calls occur at b=81,27,9,3; the last still increments counter before testing the base case. Unwinding produces mathematical values 4³,4⁹,4²⁷,4⁸¹. Already 4²⁷=2^54 exceeds a signed 32-bit range, and the final 2^162 exceeds signed 64-bit range. Thus counting gives the intended answer, but actual C execution is not guaranteed once signed overflow occurs.
Solution
The b arguments are 81, 27, 9, 3, so counter is incremented four times before the base return. The intended answer is 4. However the return computation then cubes repeatedly to 4^81=2^162, overflowing signed int on ordinary 32-bit or 64-bit implementations. Signed overflow is undefined behavior in C even if main discards the return value, so the printed result is not portable without sufficiently wide integer arithmetic or an explicit abstraction that ignores overflow.
Two positive-edge D flip-flops share a clock. External in feeds D1; Q1 feeds D2; output is Q2. How many states have a transition to themselves for at least one input?
Answer & solution
Official answer: 2
Method
Both flip-flops sample their inputs at the same edge, so Q2 receives the old Q1, not the newly sampled input. With states written q1q2, input 0/1 transitions are: 00→00/10; 01→00/10; 10→01/11; 11→01/11. Only 00 and 11 appear among their own successors. This explicit table also shows why the mixed states cannot remain unchanged for either input.
Solution
Let the state be(q1, q2). On a positive clock edge the next state is(in, q1), because both flip-flops sample old values simultaneously. A self-loop requires in=q1=q2, possible only for 00 with input 0 and 11 with input 1. Exactly2 states have self-loops.
A 1 GB, 32-bit-wide memory uses 256M×4-bit DRAMs. Each chip has 2^14 rows; refreshing a row takes 50 ns and all rows must refresh every 2 ms. Find the nearest-integer percentage available for reads/writes.
Answer & solution
Official answer: 59.0 to 60.0
Our answer: 59 percent
Method
Eight 4-bit chips operate in parallel to provide the 32-bit word. Since corresponding rows refresh together, the memory loses 16384 row-refresh slots per period, not eight times that number. Convert all durations to one unit: 2 ms=2000000 ns, and refresh consumes 819200 ns. Available time is 1180800 ns per period. Divide available time by total time, rather than reporting the refresh fraction.
Solution
The row refresh time per period is 214·50 ns=819200 ns=0.8192ms. The remaining fraction of the 2ms period is 1−0.8192/2=0.5904, or 59.04%, rounded 59%. The eight parallel 4-bit chips refresh a row together to form the 32-bit memory; their refresh times are not added serially.
Three processes share four identical resource instances. Each can need at most K, requesting and releasing one at a time. Find the largest K guaranteeing no deadlock.
Answer & solution
Official answer: 2
Method
If every unfinished process has fewer than its maximum requirement, each may hold at most K−1 while waiting for another instance. With K=2, three such waiting processes can hold at most three resources, leaving the fourth available to let one finish. Releasing its resources then enables the others. For K=3, a feasible allocation (2,1,1) consumes all resources while each process can still request one; no request can be granted. This supplies both safety and a tight counterexample.
Solution
For n=3 processes each requiring at most K identical resources, a sufficient and tight universal bound is R≥n(K−1)+1: for K=2, any allocation in which all three processes still need another instance leaves at least one of the four resources free; for K=3 the allocation (2,1,1) can instead exhaust all resources with all processes waiting. With R=4, K=2 satisfies 4≥4, while K=3 permits holdings2, 1, 1 and all waiting. Thus the largest guaranteed-safe K is 2, assuming completed processes release their resources.
A long-lived TCP connection sends at 10^9 bits/s and starts at sequence number 1234. Find the minimum time in seconds before that number can recur, rounded to an integer.
Answer & solution
Official answer: 34 to 35
Our answer: 34 seconds
Method
A TCP sequence number labels a byte, so a full modulo-2^32 cycle consumes 4294967296 bytes, or 34359738368 bits. Divide by the bit rate, maintaining consistent units. The initial value 1234 affects which label comes first, but not how many increments return to it. This is a sequence-space throughput calculation; it does not independently establish that reusing the number is safe from delayed old packets.
Solution
TCP sequence numbers count bytes modulo 232. At109 bits/s, consuming the full sequence space requires 232·8/109≈34.359738 seconds, rounded 34. The starting number 1234 only shifts the cycle and does not change its length.
A 2×2 matrix P has only eigenvectors parallel to (1,4)^T. Which statements are necessary? I P is singular; II its eigenvalue repeats; III P is not diagonalizable. A I,III; B II only; C I,II; D II,III.
Your answer
Answer & solution
Official answer: D
Method
Diagonalization in dimension two requires a basis of two linearly independent eigenvectors; the given one-dimensional eigenspace cannot provide it. Distinct eigenvalues would yield independent eigenvectors, so they must coincide. Repeated does not mean zero: take S=[[1,0],[4,1]] and J=[[1,1],[0,1]]. Then SJS−1=[[-3,1],[-16,5]] has determinant 1, while its eigenvectors satisfy y=4x. This explicit nonsingular example refutes I.
Solution
A2×2 matrix with only one eigenvector direction cannot be diagonalized, proving III. Two distinct eigenvalues would supply independent eigenvectors, so its eigenvalue must be repeated, II. Invertibility is not ruled out: any similarity transform of the nonsingular Jordan block [[1, 1],[0, 1]] with its first basis vector(1, 4) has exactly that eigenvector direction. Thus II and III, D.
Let P be the rationals; Q the functions {0,1}→N; R the functions N→{0,1}; S the finite subsets of N. Which are countable? A Q,S; B P,S; C P,R; D P,Q,S.
Your answer
Answer & solution
Official answer: D
Method
A function on two inputs is completely specified by the pair (f(0),f(1)), so Q is in bijection with N² and can be enumerated diagonally. A finite subset can be written as an increasing finite tuple; for each length these tuples are countable, and there are countably many lengths. In contrast a function in R specifies an infinite binary sequence. Cantor diagonalization constructs a sequence differing from the nth listed sequence at position n, defeating any proposed enumeration.
Solution
Rationals are countable. Functions from{0, 1} to N correspond to ordered pairs of naturals, a countable set. Finite subsets of N are a countable union over subset size of countable collections. Functions N→{0, 1} correspond to arbitrary subsets of N and are uncountable by Cantor’s theorem. Thus P, Q, S, D.
A sentence ∃s∃t∃u∀v∀w∀x∀y ψ uses only predicate symbols and possibly equality, no functions; ψ is quantifier-free. It has a seven-element model. Which follows? A a model of size at most 3 exists; B no such small model exists; C no model larger than 7 exists; D every model has size 7.
Your answer
Answer & solution
Official answer: A
Method
Choose the actual elements witnessing s,t,u in the given model; they need not be distinct. Use their set as a new nonempty universe and restrict each relation to tuples in that set. Atomic relations and equality on those elements retain exactly the same truth values. Boolean combinations, including negations, therefore retain their values too. Every assignment of universal variables in the smaller universe was already allowed in the original model, so the universal condition remains true.
Solution
Take witnesses s, t, u in the supplied 7-element model, and restrict the relational structure to those witnesses, at most 3 distinct elements. With no functions or constants to require closure, atomic predicate and equality truth on retained tuples is unchanged, hence so is every quantifier-free combination ψ. Its universal assertions still hold for the restricted domain. The same witnesses therefore yield a model of size≤3, A.
In C, str1="Hi", str2="Bye". fun1(char *s1,char *s2) swaps its local pointer variables using a temporary. fun2(char **s1,char **s2) swaps *s1 and *s2. main calls fun1(str1,str2), prints both strings, calls fun2(&str1,&str2), then prints both. Choices A Hi Bye Bye Hi; B Hi Bye Hi Bye; C Bye Hi Hi Bye; D Bye Hi Bye Hi.
Your answer
Answer & solution
Official answer: A
Method
C passes arguments by value in both calls. In fun1 the copied values happen to be addresses of characters, so replacing those local copies cannot replace main’s variables. In fun2 the copied values are addresses of main’s pointer variables; dereferencing them selects those actual variables, which the assignments can modify. Neither routine edits the string literals. This distinction is between swapping pointed-to pointers and swapping local pointer copies, not between two language-level parameter-passing modes.
Solution
fun1 swaps only local copies of the pointer values, leaving main’s strings unchanged: Hi Bye. fun2 receives their addresses and swaps the actual pointer variables, so the second output is Bye Hi. The whole output is Hi Bye Bye Hi, A.
For a simple undirected graph, I says DFS has no cross edge between unrelated vertices; II says every graph edge joins BFS depths differing by exactly 1. Which must hold? A I only; B II only; C both; D neither.
Your answer
Answer & solution
Official answer: A
Method
If an undirected DFS edge led to a still-unvisited vertex, DFS would explore it before returning, making that vertex a descendant. If the vertex is already on the recursion stack it is an ancestor; an edge to a completed unrelated subtree would have discovered the current vertex earlier. For BFS, shortest-path distances differ by at most 1 across an edge. A triangle rooted at one vertex places the other two at depth 1 and still has an edge between them, disproving “exactly”.
Solution
In undirected DFS, an edge to an undiscovered vertex is explored before the current DFS call completes, so every non-tree edge joins an ancestor and descendant; no cross edges, making I true. BFS edges can connect equal-depth vertices, for example the edge joining the two non-root vertices of a triangle. The necessary inequality is |i−j|≤1, not equality 1. Thus only I, A.
Matrices F1…F5 have dimensions 2×25,25×3,3×16,16×1,1×1000. Multiplying p×q by q×r costs pqr scalar operations. Which adjacent original pairs are directly multiplied in an optimal parenthesization? A F1F2 and F3F4; B F2F3; C F3F4; D F1F2 and F4F5.
Your answer
Answer & solution
Official answer: C
Step through it (12 steps)
Method
The dynamic-programming state M[i,j] is the minimum scalar cost of multiplying the consecutive subchain; a split k adds the costs of its two subchains and their final product. This systematically tests all parenthesizations without a local greedy assumption. In the winning chain, F3F4 first produces 3×1 at cost 48; F2 times that gives 25×1 at cost 75; F1 times that gives 2×1 at cost 50; multiplying F5 costs 2000. Only the first operation multiplies two original matrices directly.
Solution
Use matrix-chain DP: M[i, j]=mink(M[i, k]+M[k+1, j]+d[i−1]d[k]d[j]). Dimensions are 2, 25, 3, 16, 1, 1000. Pair costs are 150, 1200, 48, 16000; three-matrix optimal costs 246, 123, 3048; four-matrix costs 173, 25123. Splitting the full chain after F1, F2, F3, F4 costs 75123, 9198, 48246, 2173 respectively. The unique optimum is((F1(F2(F3F4)))F5), costing 48+75+50+2000=2173. Its only directly multiplied original pair is F3F4, C.
A 64-bit unsigned-long function initializes j=sum=0. It runs for(i=n;i>1;i=i/2) j++; then for(;j>1;j=j/2) sum++; returns sum. For n=2^40, choose A 4; B 5; C 6; D 40.
Your answer
Answer & solution
Official answer: B
Method
The first loop sees i=2^40,2^39,…,2 before stopping at i=1, so its body runs 40 times. The second loop then uses integer division: 40→20→10→5→2→1. It executes for the first five of these values, not for the final 1. The two loops are consecutive, not nested: multiplying their iteration counts would not describe the return value. The exponent in 2^40 is essential and can be lost in text extraction.
Solution
The first loop halves i until 1, performing 40 iterations, hence j=40. The second loop has j values 40, 20, 10, 5, 2 before stopping at 1, so sum=5, B.
An unsigned 8-bit fixed-point format is b7b6b5b4b3.b2b1b0. Values are i 31.500, ii 0.875, iii 12.100, iv 3.001. Which cannot be exact? A all; B ii only; C iii,iv only; D i,ii only.
Your answer
Answer & solution
Official answer: C
Method
The three fractional bit weights are 1/2,1/4,1/8. Thus every stored value is an integer multiple of 1/8 within [0,255/8]. Multiplying a proposed value by 8 must yield an integer between 0 and 255. As examples, 31.5=11111.100₂ and 0.875=00000.111₂. Values 12.1 and 3.001 satisfy the range constraint but fail the granularity constraint; being small enough does not make a decimal fraction exactly representable.
Solution
Three fractional bits give increments of 1/8 and maximum 31.875. Both31.500=252/8 and 0.875=7/8 are representable. But12.100·8=96.8 and 3.001·8=24.008 are not integers, so iii and iv are not exact, C.
Physical addresses span 2^P bytes, words have 2^W bytes, cache capacity is 2^N bytes, blocks hold 2^M words, and associativity is K. Choose tag bits: A P−N−log₂K; B P−N+log₂K; C P−N−M−W−log₂K; D P−N−M−W+log₂K.
Your answer
Answer & solution
Official answer: B
Method
A byte address has P bits. First convert block capacity from words to bytes, obtaining 2M+W. Cache blocks total 2N−M−W; grouping K per set divides this by K. Address bits split into tag, set index and byte-within-block offset. Increasing associativity at fixed capacity reduces index bits and therefore increases tag bits, a useful sign check on the log₂K term. The result assumes integral power-of-two field sizes.
Solution
A block contains 2M+W bytes. There are 2N−M−W/K sets, so index bits=N−M−W−log2K, and block-offset bits=M+W. Subtract both from P address bits: tag=P−N+log2K, B, under the conventional power-of-two cache parameters.
Over words a^m b^n c^p d^q, with all exponents nonnegative, define I m+p=n+q; II m=n and p=q; III m=n=p and p≠q; IV mn=p+q. Which are context-free? A I,IV; B I,II; C II,III; D II,IV.
Your answer
Answer & solution
Official answer: B
Method
One stack can track a single signed difference, so the crossed-looking equality in I is still manageable; a finite-state component checks block order. II has grammar S→AB, A→aAb|ε, B→cBd|ε. For III, restricting to positive a,b,c blocks and no d leaves the standard non-CFL equal-three-count language. For IV, the multiplication constraint cannot be reduced to one additive counter. The pumping argument below makes this precise, including decompositions that cross a block boundary rather than assuming where the pumped substrings lie.
Solution
I is context-free: a PDA tracks the signed running difference(#a+#c)−(#b+#d) with one stack symbol for positive excess and another for negative excess, canceling opposite contributions; finite control enforces a*b*c*d* order. II is the concatenation{an bn}{cp dp}, a CFL. For III, intersect with a+b+c+ (no d); the result is{an bn cn: n≥1}, not context-free. For IV, suppose pumping length p and take ap bp cp². Pumping up either disrupts block order or adds α a symbols, β b symbols and γ c symbols, with α+β+γ≤p and at least one added symbol. If α+β=0, the product stays p² but γ>0. Otherwise the required increase in c is p(α+β)+αβ≥p, while actual γ≤p−α−β<p. In every case the equality mn=p+q fails (here the fourth-block length remains 0). Thus only I and II are CFL, B.
Classify: I membership w∈L(G) for unrestricted G; II whether a TM language is regular; III equality of languages of two unrestricted/general grammars; IV whether an NFA language has an equivalent deterministic PDA. Options A only I,II undecidable; B only III; C only II,IV; D only I,II,III.
Your answer
Answer & solution
Official answer: D
Method
Rice’s theorem applies to nontrivial properties of the recognized language, not to arbitrary syntactic machine properties. Regularity is nontrivial because some recognizable languages are regular and some are not. Equivalence of general grammars includes comparing a grammar to one generating the empty language, already an undecidable emptiness problem. IV is different: every regular language has a DFA, and a deterministic PDA can simulate a DFA while leaving its stack unchanged. Therefore IV is a constant-yes decision problem.
Solution
I is the undecidable membership problem for unrestricted grammars/Turing-recognizable languages. II is a nontrivial semantic property of a TM language, hence undecidable by Rice’s theorem. III, equivalence of general grammars, is undecidable (even equivalence of CFGs is undecidable). IV always has answer yes: convert the NFA to a DFA and view that DFA as a DPDA that does not use its stack. Hence only I, II, III are undecidable, D. If III were restricted to regular grammars it would be decidable, but no such restriction is stated.
Tokens are T1=a?(b|c)*a, T2=b?(a|c)*b, T3=c?(b|a)*c, where ? is optional. Scan bbaacabc using longest-prefix matching. Choices A T1,T2,T3; B T1,T1,T3; C T2,T1,T3; D T3,T3.
Your answer
Answer & solution
Official answer: D
Method
At the first position T1 can consume bba: its final a ends the token before the next a. T2 can consume bb but cannot include both leading b symbols in its middle (a|c)*. T3 consumes bbaac; it cannot consume the entire input because its middle cannot contain the earlier c. Remove that five-character prefix and rescan abc, which T3 consumes completely. Longest match is decided afresh at each position, rather than choosing the earliest token pattern that can match anything.
Solution
On bbaacabc, the longest first token is bbaac, matching T3=(optional c)(a|b)*c. T1 matches only bba and T2 only bb at that position. The remaining abc also matches T3 in full, longer than the alternatives. Therefore the output is T3, T3, D.
For a#b$c$d#e#f, the supplied tree represents a#(((b$c)$d)#(e#f)). Choose A $ higher and left-associative, # right-associative; B # higher and left-associative, $ right-associative; C $ higher and left-associative, # left-associative; D # higher and right-associative, $ left-associative.
Your answer
Answer & solution
Official answer: A
Method
Read each internal node as an operation on its two child subtrees. The $ subtree first combines b,c and then combines that result with d, demonstrating left association. Treating this whole subtree as one operand gives a#(X#(e#f)), which nests # to the right. Because the dollar chain is grouped into an operand before surrounding hash operations, $ has higher precedence in the intended grammar. Do not infer precedence from the visual height of leaf letters.
Solution
The tree groups the expression as a#(((b$c)$d)#(e#f)). The two dollar operations group left, and their subtree is below the hash operations, showing higher precedence. The hash chain groups to the right. Thus A.
Available (E,F,G)=(3,3,0). Allocation rows P0…P3 are (1,0,1),(1,1,2),(1,0,3),(2,0,0); Max rows are (4,3,1),(2,1,4),(1,3,3),(5,4,1). Choose A safe already; B unsafe but safe with one extra E; C likewise extra F; D likewise extra G.
Your answer
Answer & solution
Official answer: A
Step through it (6 steps)
Method
Banker’s safety test asks whether there exists an order in which each process can obtain all its remaining need and release its allocation. Need=Max−Allocation, computed component by component. After hypothetically finishing a process, Work increases by its original Allocation, not by its Max: any temporary extra resources lent from Work are returned, cancelling out. Initially P0 and P2 are both eligible. Exhibiting one complete order suffices; the algorithm need not show that every arbitrary request order is safe.
Solution
Subtract Allocation from Max to obtain remaining needs P0=(3, 3, 0), P1=(1, 0, 2), P2=(0, 3, 0), P3=(3, 4, 1). Starting Work=(3, 3, 0), complete P0 to get(4, 3, 1), then P2 to get(5, 3, 4), then P1 to get(6, 4, 6), then P3. This safe sequence proves A.
A size-N buffer uses empty=0, full=N, mutex=1. Here empty counts readable items and full writable slots. Producer executes wait(P),wait(mutex),add,signal(mutex),signal(Q); consumer wait(R),wait(mutex),remove,signal(mutex),signal(S). Choose A full/full/empty/empty; B empty/empty/full/full; C full/empty/empty/full; D empty/full/full/empty.
Your answer
Answer & solution
Official answer: C
Method
Follow the definitions rather than familiar variable names. Before adding an item, the producer must reserve one writable slot, so it waits on the semaphore initially N. After insertion it creates a readable item, so it signals the semaphore initially 0. The consumer performs the reverse transfer. Waiting for a resource before taking mutex also avoids holding the buffer lock while blocked for another process to make progress. Each successful pair of operations preserves the bounded-buffer accounting.
Solution
Use the definitions supplied, which reverse the usual semaphore names. full starts N and counts producer-writeable slots; empty starts 0 and counts readable items. The producer waits(full) and signals(empty); the consumer waits(empty) and signals(full), each using mutex for buffer access. Thus P=full, Q=empty, R=empty, S=full, C.
Relations r(A,B),s(B,C) have no nulls; s.B is primary and r.B foreign key to s.B. Q=r⋈σ_(B<5)(s). Which differs? A σ_(B<5)(r⋈s); B σ_(B<5)(r LOJ s); C r LOJ σ_(B<5)(s); D σ_(B<5)(r) LOJ s.
Your answer
Answer & solution
Official answer: C
Method
An enforced non-null foreign key means each r tuple initially has exactly one matching s tuple. Consequently an unfiltered left outer join has no unmatched left tuples and behaves like an inner join. Applying the filter on r first also guarantees all its retained tuples match. Filtering only the right input before an outer join changes this: left tuples whose matches were filtered out still survive with null extension. This is why moving a predicate across an outer join requires more care than across an inner join.
Solution
Every r tuple has a matching s tuple by the non-null foreign key. Thus the unfiltered natural left join equals the inner join, and filtering B<5 before or after it gives the same matched rows. In C, filtering s first removes matches for r rows with B≥5, but the left join preserves those r rows with null-extended C. Q discards them instead. For example r={(a, 6)}, s={(6, c)} makes Q empty while option C retains(a, 6, NULL). Hence C alone is not equivalent.
Schemas: I R(rollno,courses), courses set-valued, rollno→courses; II R(rollno,courseid,email), rollno,courseid→email and email→rollno; III R(rollno,courseid,marks,grade), rollno,courseid→marks,grade and marks→grade; IV R(rollno,courseid,credit), rollno,courseid→credit and courseid→credit. Which is 3NF but not BCNF? A I; B II; C III; D IV.
Your answer
Answer & solution
Official answer: B
Step through it (4 parts)
Method
BCNF requires every nontrivial dependency’s determinant to be a superkey. 3NF allows a second possibility: its right-hand attribute is prime, meaning it belongs to some candidate key. For II, email together with courseid determines rollno and all attributes, while rollno together with courseid determines email. Neither email nor rollno alone determines courseid. Thus email→rollno violates BCNF but is permitted by 3NF because rollno is prime.
Solution
In schema II, candidate keys are {rollno, courseid} and {email, courseid}. All three attributes are prime, so each listed dependency satisfies 3NF. But email→rollno has a determinant that is not a superkey, violating BCNF. Schema I has a set-valued non-atomic attribute under the intended 1NF definition. Schema III has marks→grade with a non-superkey determinant and non-prime right side; schema IV has the analogous courseid→credit violation. Hence only schema II, B. The listed nontrivial dependencies are understood as a generating set, rather than literally excluding dependencies implied by them.
Vertices are all 100! permutations of 1…100. Two vertices are adjacent exactly when one swaps two adjacent positions of the other. If degree is y and connected-component count z, find y+10z.
Answer & solution
Official answer: 109
Method
There are 99 boundaries between consecutive positions, and swapping at distinct boundaries gives distinct neighboring permutations. To prove connectedness construct a path: repeatedly swap an adjacent inverted pair, as in bubble sort. Each move is an edge and reduces inversion count by one, so every permutation reaches the sorted permutation after finitely many steps. Connecting every vertex to a common vertex proves exactly one component. Parity alternates on each move, but bipartiteness does not imply disconnectedness.
Solution
There are 99 adjacent positions available for a swap. Each gives a different permutation, so every vertex has degree 99. Adjacent swaps can sort any permutation to the identity, proving that the graph is connected and z=1. Thus y+10z=99+10=109.
Guwahati H,M,L probabilities are .2,.5,.3. Delhi conditional H,M,L probabilities by Guwahati row are H:(.40,.48,.12), M:(.10,.65,.25), L:(.01,.50,.49). Find P(Guwahati H | Delhi H), to two decimals.
Answer & solution
Official answer: 0.60 to 0.62
Our answer: 0.60
Method
The table conditions on Guwahati, whereas the question conditions on Delhi, so reading .40 directly reverses the conditioning incorrectly. The denominator must include all three ways Delhi can be hot: Guwahati hot, medium or low. Their joint probabilities are .08,.05,.003. The desired event is just the first contribution divided by their sum .133. Columns of a conditional table need not sum to one before weighting by the row probabilities.
Solution
By total probability, P(H_D)=0.40*0.2+0.10*0.5+0.01*0.3=0.133. The joint probability P(H_G and H_D)=0.40*0.2=0.08. Bayes gives 0.08/0.133=80/133≈0.601504, which rounds to 0.60. The full accepted interval 0.60–0.62 is preserved.
Count(x,y) does nothing if y==1. Otherwise, if x!=1 it prints * and calls Count(x/2,y); if x==1 it calls Count(1024,y−1). Integers use truncating division. How many prints result from Count(1024,1024)?
Answer & solution
Official answer: 10230
Method
Separate the fast-changing variable x from the outer progress variable y. For each y>1, x halves ten times, since 1024=210. The x=1 call performs no print and starts the next y cycle with x reset. Values of y that produce prints are 1024 down through 2, a total of 1023, not 1024. The terminal y=1 call returns immediately, regardless of its x value. This counts executed print statements, not recursive invocations.
Solution
For a fixed y>1, x takes 1024, 512,..., 2, yielding 10 prints before reaching 1. Then y decreases by 1 and x resets to 1024. This occurs for y=1024, 1023,..., 2, namely 1023 rounds. At y=1 the function stops without printing. Therefore there are 10*1023=10230 prints in the abstract pseudocode model.
How many distinct min-heaps use each key 1,2,3,4,5,6,7 once? Use the standard complete binary heap shape.
Answer & solution
Official answer: 80
Method
The shape is fixed: a root with two three-node subtrees. Minimum key 1 must occupy the root. Select a three-element subset of the remaining six keys for the left subtree; the right gets the complement, giving C(6,3)=20 distinct assignments. Within each subtree its least key must be its root, but its two leaves can be swapped independently. Left and right positions are distinguished in a heap, so do not divide the count by 2 for mirror images.
Solution
The minimum 1 must be the root. The complete seven-node shape has three positions in each subtree. Choose which three of the other six keys go left in C(6, 3)=20 ways. In either three-node subtree its smallest key is the root and its two leaves can be ordered in 2 ways. Thus there are 20*2*2=80 heaps.
Name graph vertices top T, left L, bottom-left B, bottom-right C, right R. Edges: TL=4,LB=4,TB=1,BC=4,TC=3,TR=x,CR=5. Choose x to maximize the number of minimum-weight spanning trees; report that number.
Answer & solution
Official answer: 4
Method
The cut property forces a uniquely lightest edge across a cut into every MST. Across {B}, TB=1 is strictly less than LB=4 and BC=4; across {C}, TC=3 is less than BC=4 and CR=5. Contract these two forced edges to a central component. Connecting L has two tied cost-4 choices. Connecting R has two choices only when x=5. These choices are independent and each yields four edges with no cycle, so their product counts actual spanning trees, not merely edge subsets.
Solution
Name the top vertex T, bottom-left B, bottom-right C, left L and right R. Edge TB of weight 1 is uniquely cheapest across the cut {B}; TC of weight 3 is uniquely cheapest across {C}. Both must be in every MST, independently of x. Contract them. L can connect to that component by either of its two weight 4 edges. R can connect by TR of weight x or CR of weight 5. At x=5 both choices tie, giving 2*2=4 MSTs. Otherwise only one right edge is cheapest and there are 2. The remaining BC edge would form a cycle with the two mandatory edges and cannot be chosen. Thus the maximum count is 4.
Capacity is 11 kg. Single available items (weight,value) are 1:(10,60),2:(7,28),3:(4,20),4:(2,24). Items cannot split. Greedy scans descending value/weight, taking items that fit. Find optimal value minus greedy value.
Answer & solution
Official answer: 16
Step through it (2 tables)
Method
The ratio order is item 4 then 1 then 3 then 2. Taking item 4 leaves 9 kg, so item 1 no longer fits. Item 3 then fits and leaves 5 kg, too little for item 2. To verify optimality, item 1 alone gives 60 and cannot pair with even the smallest other item. Without item 1, feasible pairs (2,3),(2,4),(3,4) have values 48,52,44; all three weigh 13 and are infeasible. Thus exhaustive feasible alternatives confirm the optimum.
Solution
Value/weight ratios order the items as 4, 1, 3, 2, with ratios 12, 6, 5, 4. Greedy takes item4 (weight 2, value 24), skips item1 because it no longer fits, then takes item3 (weight 4, value 20), and skips item2. Its value is 44. The best feasible subset is item1 alone, value 60: pairs among 2, 3, 4 have maximum 52, all three weigh13, and item1 cannot accompany any other item under capacity 11. Hence60−44=16.
F(P,Q,R,S) has on-minterms {0,2,5,7,9,11} and don’t-cares {3,8,10,12,14}. All other minterms are off. How many essential prime implicants exist?
Answer & solution
Official answer: 3
Step through it (13 steps)
Method
A prime implicant is a maximal Boolean cube containing no off-cell; don’t-cares may enlarge it but need not be covered. Essential means at least one required on-cell has no alternative prime covering it. In dash notation, the five primes cover required cells as follows: 01-1→{5,7}; 0-11→{7}; 10--→{9,11}; -01-→{2,11}; -0-0→{0,2}. Therefore 5,9,0 respectively force three primes. A prime that covers only redundantly covered on-cells is not essential, even if it appears in a possible cover.
Solution
Enumerating maximal cubes that contain an on-minterm and no off-minterm gives five prime implicants: 01-1, 0-11, 10--, -01-, -0-0 in P, Q, R, S order, where a dash means that variable is absent. Minterm5 is covered only by 01-1; minterm 9 only by 10--; minterm 0 only by-0-0. These three primes are essential. The remaining on-minterms 2, 7, 11 each have more than one covering prime. Therefore exactly 3 prime implicants are essential. The enumeration checks all 81 four-variable cubes and treats only the listed d entries as don’t cares.
A pipeline is IF,ID,OF,PO,WB. Every stage except PO takes one cycle. Among 100 instructions PO takes 3 cycles for 40, 2 for 35, and 1 for 25. No data/control hazards. Find total cycles under single-occupancy PO operation.
Answer & solution
Official answer: 219
Method
Start with the ideal five-stage baseline: 100+5−1=104 cycles if every PO takes one cycle. The 40 three-cycle operations add 40·2=80 stall cycles; the 35 two-cycle operations add 35·1=35. Total is 104+80+35=219. This agrees with adding three fill cycles, all PO occupancies, and one final writeback cycle. It would be wrong to charge every instruction five separate nonoverlapped stages; most stage work overlaps.
Solution
The single PO stage is occupied for 40*3+35*2+25*1=215 clocks. The first instruction needs 3 clocks to reach PO through IF, ID, OF, and the final instruction needs 1 WB clock afterward. With no data/control hazards, earlier stages can supply the next instruction whenever PO becomes free, so total=3+215+1=219. This uses the intended non-overlapped PO-stage model; a separately internally pipelined execution unit would need an initiation-interval specification.
A 16-bit instruction set has 16 integer and 64 floating registers. Four type-1 instructions use 3 integer operands; eight type-2 use 2 floating operands; fourteen type-3 use 1 integer+1 floating; N type-4 use 1 floating. Find maximal N.
Answer & solution
Official answer: 32
Method
An integer register needs 4 bits and a floating register 6 bits. Operand bits are therefore 12,12,10,6 for the four categories, leaving variable opcode widths 4,4,6,10. Counting complete instruction words avoids assigning incompatible fixed-length opcodes. Each opcode must reserve all combinations of its operands. After subtracting the first three categories from the 65536 available words, divide the remaining words by 64 per type-4 instruction. The prefix construction below verifies that this counting bound can actually be encoded.
Solution
There are 216 instruction encodings. A three-integer-register instruction uses 212 encodings, as does a two-floating-register instruction. Each mixed register instruction uses 210 encodings. The remaining space is 65536−4*4096−8*4096−14*1024=2048. Each type4 opcode needs 64 encodings, so N≤2048/64=32. This bound is achievable with expanding opcodes: allocate 12 four-bit prefixes to types 1/2; the remaining 4 prefixes yield 16 six-bit prefixes, 14 for type3, leaving 2 prefixes expandable to 32 ten-bit type4 opcodes.
Define L^0={ε}, L^(i+1)=L^iL; order is least k with L^k=L^(k+1). The unary DFA has accepting start q0, accepting q1, rejecting q2, and transitions q0−0→q1, q1−0→q2, q2−0→q1. Find order of its language.
Answer & solution
Official answer: 2
Method
A path of length 0 accepts, and positive path lengths accept exactly when odd. Concatenation over a unary alphabet adds lengths. Every positive even length 2m can be decomposed as 1+(2m−1), both positive odd, so two language factors suffice for every even length as well. Zero and odd lengths use ε in one factor. To prove the least order, explicitly exclude k=0 and k=1: length 1 distinguishes L0 from L, and length 2 distinguishes L from L².
Solution
The start state is accepting. After one 0 the automaton enters an accepting state alternating with a nonaccepting state, so L1 contains epsilon and precisely the positive odd-length unary words. L1 squared contains every unary word: odd lengths use one odd word and epsilon, while any positive even length is the sum of two positive odd lengths. Hence L1²=0* and L1³=0*. But L10 differs from L1, and L1 differs from L1² because length 2 is absent from L1. The smallest equality index is therefore 2.
Disk has 4 platters, 200 cylinders and 256 sectors/track. Requests [sector,cylinder,platter]: [120,72,2],[180,134,1],[60,20,0],[212,86,3],[56,116,2],[118,16,1]. Head starts sector 100,cylinder 80 moving upward. SSTF movement costs are stated as 20 mW per 100 cylinders plus 15 mW per reversal; rotation/platter costs ignored. Find the intended total.
Answer & solution
Official answer: 85
Our answer: 85 under the stated additive-cost convention
Step through it (8 steps)
Method
SSTF chooses nearest pending cylinder, not the next request in the current direction. At 80 choose 86 (6 away), then 72 (14 away). From 72, 116 is 44 away versus 20 at 52; then 134 is nearest. The remaining requests are 20 and 16. Direction is up, down, up, up, down, down, so there are three reversals relative to the initially upward head. Sector and platter numbers do not affect the stipulated cost model.
Solution
SSTF chooses cylinders 80→86→72→116→134→20→16, with distances 6, 14, 44, 18, 114, 4 totaling 200. The head starts upward and reverses at 86, 72, 134, three times. Treating the supplied numbers as additive movement costs gives(200/100)*20+3*15=85, the official answer. Physical power in milliwatts cannot in general be added over sequential operations to obtain total consumption; energy or a time-based average would require durations and appropriate units. Thus85 is the intended numerical cost, not a dimensionally justified physical power calculation.
An IPv4 packet is 4500 bytes including a 20-byte IP header and 40-byte TCP header. Router MTU is 600 bytes; each fragment has a 20-byte IP header and the first offset is zero. Find the third fragment’s stored offset.
Answer & solution
Official answer: 144
Step through it (4 steps)
Method
Fragment offset is measured in eight-byte units from the original IP payload start, not from the original IP header. A full fragment may hold 580 payload bytes by MTU, but a nonfinal fragment must end on an eight-byte boundary, so round down to 576. The first occupies payload bytes 0–575, the second 576–1151, and the third starts at 1152. Their stored offsets are 0,72,144. The TCP header travels as part of the first payload, without a new TCP header in later fragments.
Solution
Each fragment has room for 600−20=580 payload bytes. Nonfinal payload lengths must be multiples of 8, so use 576 bytes per full fragment. The third fragment starts after 2*576=1152 bytes of original IP payload, giving stored offset 1152/8=144. The40-byte TCP header is part of the IP payload and is not repeated or subtracted from every fragment. Fragmentation is assumed permitted, as the question prescribes outgoing fragments.
Two nodes P,Q are d metres apart, propagation speed 10 m/time-unit. Nodes sense for 5 units then transmit next; on detecting another transmission they wait for it to end and sense again. Transmissions last 20 units without collision detection. P begins at t=0; Q begins sensing at t=0. Find largest collision-avoiding d, rounded to metres.
Answer & solution
Official answer: 50
Method
Q cannot sense P immediately at a distance: P’s leading signal arrives at t=d/10. To suppress Q’s pending transmission, that arrival must occur by the sensing decision at t=5 under the intended endpoint convention. At d=50 the signal reaches Q at the boundary and remains present for the next 20 units as P’s packet propagates past Q. A larger propagation delay leaves Q’s sensing interval apparently idle, so the protocol can launch an overlapping transmission. The limiting equation uses sensing time, not packet duration.
Solution
P’s signal reaches Q after propagation delay d/10 time units. To defer, Q must observe it during the five-unit sensing interval before Q starts transmission. Thus the intended boundary is d/10≤5, giving d≤50 metres. The answer 50 uses the convention that an arrival at the end of sensing is observed before the decision to transmit. If exact simultaneous-event ordering is not specified, 50 is the limiting distance; a strict-before model would use d<50, with the same rounded boundary. P transmits for 20 units, so its signal is still ongoing when first detected at this boundary.