Fill the three blanks in this sentence: Ravi had ___ younger brother who taught at ___ university and was regarded as ___ honorable man. Options: A a; a; an. B the; an; a. C a; an; a. D an; an; a.
Your answer
Answer & solution
Official answer: A
Approach: Choose an indefinite article from the first sound of the following word, rather than its first written letter. 1. “Younger” starts with the consonant sound /j/, like the beginning of “yes”. Therefore the first phrase is “a younger brother”. Nothing in the sentence calls for a previously identified brother, so the indefinite article is appropriate. 2. “University” also begins with /j/ despite starting with the vowel letter u. Its article is therefore “a”, not “an”. 3. In “honorable”, h is silent and the first pronounced sound is a vowel. Thus the final phrase is “an honorable man”. The required sequence is a; a; an, option A. Each of B, C and D uses “an university” and “a honorable”, which fail the sound-based rule.
A CEO cuts the workforce for short-term gains at the expense of long-term stability. Which replacement preserves the meaning of “myopic” in this criticism? A visionary; B shortsighted; C progressive; D innovative.
Your answer
Answer & solution
Official answer: B
Approach: Use the contrast between immediate gain and future damage to infer the intended figurative meaning. “Myopic” literally concerns limited distant vision. Applied to a decision, it means failing to consider sufficiently far into the future. Sacrificing long-term stability for an immediate benefit is therefore shortsighted, so B preserves the meaning. A, “visionary”, suggests unusually strong foresight and would reverse the criticism. C, “progressive”, describes a preference for change or reform, not inadequate planning. D, “innovative”, concerns novelty and does not establish whether the consequences were considered. A decision can be innovative and still be myopic, which is why those words are not interchangeable here.
A class average was recorded as 30.8. One mark had been entered as 24 instead of 42. Correcting that single mark changes the mean to 31.4. Find the number of students. A 25; B 28; C 30; D 32.
Your answer
Answer & solution
Official answer: C
Approach: Compare the change in total marks with the change in the average; the number of observations stays fixed. Let n be the class size and S the originally recorded total. Then S/n=30.8. Replacing 24 by 42 increases the total by 42−24=18, so (S+18)/n=31.4. Subtract the first equation from the second: 18/n=31.4−30.8=0.6. Consequently n=18/0.6=30, option C. As a check, the original total would be 30×30.8=924 and the corrected total 942. Dividing 942 by 30 indeed gives 31.4. The correction is positive, so an increased rather than decreased mean is consistent. The other proposed sizes would not make an 18-mark correction produce a 0.6-mark mean increase.
P is Q’s brother; S is Q’s daughter; T is S’s sister; R is Q’s mother. Assess: (1) R is S’s grandmother; (2) P is uncle to S and T; (3) R has only one son; (4) Q has only one daughter. Choices: A both 1 and 2; B both 1 and 3; C only 3; D only 4.
Your answer
Answer & solution
Official answer: A
Approach: Build the stated parent/sibling relationships and avoid inventing facts about gender or the total number of children. R is one generation above Q, and Q is one generation above S. Since R is female, this makes R the grandmother of S: statement 1 is true. P is Q’s male sibling, so under the ordinary family-tree convention he is uncle to Q’s children S and T. Statement 2 is true. That convention treats the stated sisters as sharing the indicated parent. Statement 3 does not follow. Q’s gender is unspecified, and the statements do not rule out further children of R. Statement 4 is false under the intended family relationships because S and T are two daughters of Q. Thus the supported pair is 1 and 2, option A. “Only” is a strong restriction and cannot be inferred merely because a description lists a few relatives.
The map has north up and east right. A north–south main road separates a western column from an eastern column. West, from north to south: Library, Physics Lab, then across an east–west cross road Hostels and Classrooms. East, from north to south: Canteen level with Library, Hospital level with Physics Lab, and Chemistry Lab below the cross road. Which statement holds? A Library is northwest of Canteen; B Hospital is east of Chemistry Lab; C Chemistry Lab is southeast of Physics Lab; D Classrooms and Canteen are adjacent.
Your answer
Answer & solution
Official answer: C
Approach: Translate each relative position into its horizontal and vertical components using the compass, not the direction of a road. Starting at Physics Lab, reaching Chemistry Lab requires moving right across the main road and down across the cross road. Right is east and down is south, so Chemistry Lab lies southeast of Physics Lab. Therefore C is correct. For A, Library and Canteen occupy the same upper row; Library is west, not northwest. For B, Hospital is above Chemistry Lab on the same eastern side, so the relevant direction is north rather than east. For D, Classrooms is in the lower western part while Canteen is in the upper eastern part, with other locations and roads between them; they are not next to one another. Its dimensions are representative, so no numerical distances should be inferred.
In a passage about everyday pocket contents, the narrator puts paper and chalk in a pocket, reflects on the ancient and poetic character of such objects, calls the pocket-knife “the infant of the sword”, and recalls abandoning a book of poems about pocket objects because it would be too long. Which claim is supported? A A mirror is carried for reflection; B the planned poem was about epics; C the pocket-knife is described as the infant of the sword; D epics are described as inconvenient to write.
Your answer
Answer & solution
Official answer: C
Approach: Distinguish a statement actually supported by the passage from a literal misreading or an added inference. C repeats the stated comparison between a pocket-knife and a sword, so it is directly supported. The question restricts us to the passage, and direct evidence suffices. A misreads “reflected” as looking into a mirror; the author means thinking about the objects and never supplies a mirror as a pocket item. B changes the proposed subject: the poems were to concern pocket contents, not epics. D substitutes “inconvenient” for the stated concern that the proposed work would be too long and that the age of great epics had passed. Therefore select C. The other statements may sound connected to words in the passage, but lexical overlap is not evidence that their claims follow.
In triangle PQR, S lies on PQ and T on PR, with ST parallel to QR. The perpendicular separation of ST and QR is half the perpendicular distance from P to QR. Find area(PST)/area(SQRT), where SQRT is the remaining trapezium. A 1/3; B 1/4; C 2/5; D 1/2.
Your answer
Answer & solution
Official answer: A
Approach: Use similarity to obtain the small triangle’s fraction of the whole, then subtract to obtain the trapezium’s fraction. Let P’s altitude above QR be h. Since ST is h/2 above QR, P’s altitude above ST is h−h/2=h/2. Parallelism gives equal corresponding angles, so triangles PST and PQR are similar with linear scale factor (h/2)/h=1/2. Areas scale as the square of a linear factor. If the large triangle has area A, then area(PST)=A/4. The trapezium occupies the remainder, A−A/4=3A/4. Their ratio is (A/4)/(3A/4)=1/3, option A. Option B, 1/4, is the small triangle’s ratio to the entire triangle, not the requested trapezium. Option D incorrectly treats area as scaling linearly with height. No right angle or symmetry of the sloping sides is required.
A fair six-sided die is rolled independently three times. Find the probability of exactly one result equal to 6. Options: A 75/216; B 1/6; C 1/18; D 25/216.
Your answer
Answer & solution
Official answer: A
Approach: Count the mutually exclusive possible positions of the sole six. If the first roll is the only six, the pattern is six, non-six, non-six. Its probability is (1/6)(5/6)(5/6)=25/216. The same probability applies when the unique six is second or third. These three events cannot occur together, so their probabilities add: 3×25/216=75/216, option A. Equivalently, among the 6³=216 equally likely ordered outcomes, choose the position of the six in 3 ways and the other two faces in 5 ways each, giving 3×5²=75 favorable outcomes. D counts just one fixed placement. B is the probability of a six on one specified roll, not exactly one across three rolls. Independence is what permits multiplication within each three-roll pattern.
A square is folded first along its top-left–bottom-right diagonal, leaving the upper-right triangular half, and then along the line from the upper-right corner to the midpoint of the first diagonal, producing a downward-pointing triangle. The final folded triangle has three black cut shapes: a small upward-pointing triangular notch at the midpoint of its horizontal top edge, a filled right-triangular cut against its left sloping edge, and a thin rectangular notch against its right sloping edge. Choose the unfolded pattern. A has four outward-pointing triangular edge notches, axis-aligned square holes near upper-left/lower-right and right-angle notches near upper-right/lower-left. B replaces the square holes by diamonds. C reverses the top/bottom triangular orientations. D places a square hole at the centre instead of the two opposite near-corner squares. Exact cut geometry and the four artwork options are on the linked original page.
Your answer
Answer & solution
Official answer: A
Approach: Reverse the last fold first. Every cut in a folded stack appears at its reflected position when that fold is opened; repeat for the first fold. The horizontal edge of the final triangle represents outer edges of the original square. Its triangular cut produces four edge notches on unfolding. Reflection preserves which side of each outer edge is removed, so their apices face outward; it does not turn the top and bottom triangles inward. The cut touching one diagonal is mirrored across that diagonal into a square. The square’s sides remain horizontal/vertical in the original square, not diagonal. Opening the other fold gives its companion near the opposite corner. The rectangular cut meeting the other folded edge produces paired right-angle shapes at the other two near-corner positions. These features together match A. B incorrectly rotates the square holes, C reverses the vertical triangles, and D introduces a central square unsupported by any cut at the fold intersection.
There are four distinct ice-cream flavours. Buy exactly three scoops, allowing repeats, and regard purchases differing only in scoop order as identical. How many purchases are possible? A 4; B 20; C 24; D 48.
Your answer
Answer & solution
Official answer: B
Approach: Represent a purchase by the number of scoops of each flavour, not by an ordered sequence. Let x1,x2,x3,x4 be the non-negative integer counts. Every purchase corresponds uniquely to x1+x2+x3+x4=3. With three stars for scoops and three separators for the four flavours, stars and bars gives C(3+4−1,4−1)=C(6,3)=20, option B. An independent case count checks this: three identical scoops give 4 choices; a pair of one flavour plus a different flavour gives 4×3=12 choices; three different flavours give C(4,3)=4 choices. Total 4+12+4=20. Using 4³ would count ordered selections and overcount many purchases. Using only C(4,3) would forbid repeated flavours, contrary to the question.
A non-pipelined single processor receives an asynchronous device interrupt while running a program. Order these steps: (i) save the program counter, (ii) load the ISR start address into the program counter, (iii) finish the current instruction. A iii,i,ii; B i,iii,ii; C i,ii,iii; D iii,ii,i. Options C and D continue on source page 11.
Your answer
Answer & solution
Official answer: A
Approach: Preserve a consistent return point before redirecting instruction execution. First finish the instruction already in progress: step iii. In the usual instruction-boundary interrupt model, this leaves the program’s architectural state consistent and determines the address at which it must resume. Interrupts are asynchronous arrivals, but service is begun at an instruction boundary. Next save the program counter containing that resume address: step i. Finally load the ISR entry address into the program counter: step ii. Fetching now begins in the interrupt routine, and the saved address remains available for return. The sequence is iii,i,ii, option A. B and C save before the current instruction has completed; D overwrites the return address with the ISR address before saving it. This ordering describes the stipulated simple processor, not an attempt to interrupt halfway through a partially completed instruction.
Which claim about a compiler symbol table is false? A It tracks variable scope. B It can use a binary search tree. C It is no longer needed after parsing. D It is created during lexical analysis.
Your answer
Answer & solution
Official answer: C
Approach: Follow identifier information through the compiler rather than treating parsing as the last compilation phase. A symbol table maps names to attributes such as type, declaration scope and storage location. Scope checking needs those associations, so A describes a normal role. A binary search tree can support lookup and insertion by identifier name, so B is a valid implementation possibility even though hash tables are also common. After parsing, semantic analysis still needs symbol information for declaration and type checks; later code generation may need storage and addressing attributes. Therefore C’s claim that the table is unnecessary after parsing is false, and C is the keyed answer. D reflects the conventional introductory pipeline in which lexical analysis begins identifier entries. Real implementations may create or enrich tables at other stages, so D should not be read as a universal requirement on every compiler architecture. The decisive false claim in the intended model is C.
Which compiler activity uses live-variable analysis? A runtime function-call management; B assigning registers to variables; C strength reduction; D constant folding.
Your answer
Answer & solution
Official answer: B
Approach: Ask which optimization needs to know whether an existing variable value can be used again. A variable is live at a program point if some execution path may read its current value before assigning a new value to that variable. Registers hold only a limited number of such values. If two values must remain available at the same time, allocating the same physical register to both can destroy a value that will be needed. Register allocation therefore uses live ranges, commonly creating an interference edge between values that are simultaneously live. Values whose live ranges do not overlap can reuse a register. This selects B. Strength reduction, C, replaces an expensive operation with an equivalent cheaper one, while constant folding, D, evaluates expressions with known constants. Neither is identified by the need for liveness in this question. Runtime call management concerns the calling convention and activation records rather than this particular analysis.
A byte-addressable demand-paged machine has 32-bit logical addresses, 20-bit physical addresses, and 2048-byte pages. What is the maximum number of entries in a conventional page table? A 2^21; B 2^20; C 2^22; D 2^24.
Your answer
Answer & solution
Official answer: A
Step through it (5 steps)
Approach: Count virtual pages, because a conventional page table has one possible entry per virtual page. The page size is 2048=211 bytes, so the low 11 bits of a logical address identify a byte within its page. The remaining 32−11=21 bits identify the virtual page. There are therefore 221 possible virtual-page numbers, selecting A. Equivalently, the virtual address space has 232 bytes and dividing by 211 bytes per page gives 221 pages. Physical-address width is not the numerator in this calculation. It determines that physical memory can contain 220−11=29 frames and that a frame number needs 9 bits. Demand paging may leave many entries invalid or pages absent from physical memory, but that does not reduce the maximum number of distinct virtual pages the table must represent.
A database schedule is R1(X), W1(Y), R2(X), R2(Y), R3(Y), followed by ABORT(T1). No intervening commit or write is shown. Which other transactions must roll back? A only T2; B only T3; C both T2 and T3; D neither.
Your answer
Answer & solution
Official answer: C
Step through it (8 steps)
Approach: Track reads of a value produced by an uncommitted transaction; read-read overlap alone is not a rollback dependency. W1(Y) installs T1’s new value of Y. R2(Y) occurs after that write and before T1 commits, so T2 reads an uncommitted value from T1. R3(Y) sees the same value because no intervening write to Y is shown; T3 also depends on T1. When T1 aborts, its write to Y must be undone. Both dependent transactions have computed using a value that cannot be retained, so both must roll back. This is a cascading rollback and gives C. The reads R1(X) and R2(X) do not establish a dirty-read dependency because neither transaction writes X in this schedule. The important issue is which transaction produced the value read, not simply whether two transactions access the same data item.
Match layers (a) network, (b) transport, (c) data link to functions (I) packet routing, (II) framing and error handling, (III) host-to-host communication. A a-I,b-II,c-III; B a-I,b-III,c-II; C a-II,b-I,c-III; D a-III,b-II,c-I.
Your answer
Answer & solution
Official answer: B
Approach: Identify the most specific layer functions before assigning the less precise phrase. The network layer handles packet routing across networks, so a must match I. The data-link layer groups bits into frames for a link and handles link-level error detection or control, so c matches II. Those two matches already identify B among the choices. The remaining b-III match is the question’s intended description of transport-layer end-to-end communication. More precisely, transport protocols provide process-to-process service using endpoint identifiers such as ports; “host-to-host” is broader wording than the usual precise definition. A misassigns framing to transport; C assigns framing to network; D assigns routing to data link. Thus B is correct in the supplied matching scheme. Error handling can also exist at other layers, but “framing and error handling” together points to the data-link layer here.
Let g:A→B and f:B→C. Both f and f∘g are surjective. Which property must g have? A surjective; B injective; C bijective; D neither injectivity nor surjectivity is required.
Your answer
Answer & solution
Official answer: D
Approach: Determine whether hitting every point of C requires hitting every point of B. Different points of B can share the same image under f, so it need not. Construct a counterexample: A={1,2}, B={u,v}, C={w}. Define g(1)=g(2)=u and f(u)=f(v)=w. The function f is onto C because w has a preimage. The composition sends both elements of A to w, so it is also onto C. However g is not injective, because its two inputs share the output u, and is not onto B, because v is missed. This single example refutes the necessary-property claims in A, B and C and establishes D. Conceptually, g only needs to hit enough points of B to cover all f-fibres over C. The conclusion would differ if extra assumptions, such as injectivity of f, were supplied; none is supplied here.
G is an undirected graph with positive edge weights and T is a minimum spanning tree. Let d1(u,v) be the shortest-path distance in G and d2(u,v) that in T. Which holds for all vertices and all such graphs? A d1=d2; B d1≤d2; C d1≥d2; D d1≠d2.
Your answer
Answer & solution
Official answer: B
Approach: Compare the sets of paths available in the graph and its spanning-tree subgraph. The unique u-to-v path in T uses only edges of G. Thus it is one candidate among the paths minimized over when defining d1. Minimizing over a set containing that candidate cannot give a larger value than its length: d1(u,v)≤d2(u,v). Therefore B always holds. Equality is possible, for example if G itself is a tree. Strict inequality is also possible: take a triangle with all edge weights 1 and a spanning tree consisting of two edges. Between the endpoints of the omitted edge, the graph distance is 1 but the tree distance is 2. These examples reject A and D as universal claims and reject C. An MST minimizes total chosen-edge weight, not every pairwise path distance. Indeed the inequality holds for any spanning tree; minimum total weight is unnecessary for this particular proof.
A grammar has start symbol S and productions S→aaB | Abb, A→a | aA, B→b | bB. Choose its language: A {a²b^n:n≥1}∪{a^nb²:n≥1}; B {a^nb^(2n):n≥1}∪{a^(2n)b^n:n≥1}; C {a^nb^n:n≥1}; D {a^(2n)b^(2n):n≥1}.
Your answer
Answer & solution
Official answer: A
Approach: First identify what each helper nonterminal can generate, then substitute into each start production. A→a is the base case. Each application of A→aA adds one a before eventually taking the base case, so A generates exactly an for n≥1. Similarly B generates exactly bn for n≥1. Neither can generate the empty string. Taking S→aaB fixes the number of a’s at two and allows any positive number of b’s. Taking S→Abb allows any positive number of a’s and fixes the number of b’s at two. The language is the union of these alternatives, which is A. For example aabbb is generated by the first branch, and ab b (the word abb) by the second. The grammar does not synchronize the two counts, so the equality and ratio conditions in B–D are unjustified. The common word aabb belongs to both branches but is counted just once in the language.
Solving an exponential recurrence by normalization
Asymptotic Analysis & Recurrences
Tap to enlarge
T(0)=1 and T(n)=2T(n−1)+n·2^n for n>0. Which asymptotic order is correct? A Θ(n²2^n); B Θ(n2^n); C Θ((log n)²2^n); D Θ(4^n).
Your answer
Answer & solution
Official answer: A
Approach: Divide out the homogeneous growth factor 2n so that the remaining recurrence becomes a simple cumulative sum. Define U(n)=T(n)/2n. Dividing the recurrence by 2n gives U(n)=T(n−1)/2n−1+n=U(n−1)+n, with U(0)=1. Repeated substitution yields U(n)=1+1+2+⋯+n=1+n(n+1)/2. Therefore T(n)=2n[1+n(n+1)/2]. The bracket is a quadratic polynomial with positive leading coefficient, so it is Θ(n²). Multiplication by 2n gives Θ(n²2n), option A. B overlooks the accumulation of n successive normalized contributions. C grows too slowly by replacing that quadratic sum with logarithms, and D is exponentially larger than the exact solution. A master theorem for T(n/b) is not the natural tool because this recurrence decreases n by one, rather than dividing it.
A pictured B+ tree has a root with keys [6,12,19] and four leaf children, shown left to right as [1,4,3], [7,9,10], [13,15,17], [20,21,22]. Each node holds at most three keys, and there are five nodes initially. Insert 23 using ordinary B+ tree insertion. Which statements hold? A no node splits; B at least one node splits and redistributes; C node count stays unchanged; D height increases. The unsorted first leaf [1,4,3] is reproduced literally, not silently repaired.
Select all that apply
Answer & solution
Official answer: B, D
Approach: Follow the insertion path and propagate any overflow upward. Because 23 exceeds the largest root separator, it routes to the rightmost leaf [20,21,22]. Adding it produces four keys in a node whose capacity is three. This leaf must split into two leaves under the ordinary insertion algorithm; for example its data can be distributed as [20,21] and [22,23]. A separator for the new leaf is inserted into the parent. The parent is the root and is already full with three keys. Its overflow requires an internal-node split and a new root above the split pieces. Thus the height increases by one. B and D are true, while A and C are false. The usual allocation adds one leaf, one internal node and one new root, raising five nodes to eight. the printed first leaf is unsorted, so the figure is not literally a valid B+ tree. Separator conventions also are not fully specified. The intended overflow argument uses the unaffected rightmost branch and assumes a valid initial tree apart from the diagram defect. The official B;D answer is preserved, with that limitation explicit.
Let P1,P2,P3 be the three successive packets of the ordinary TCP connection-establishment handshake. Select true claims: A P3 has SYN=1,ACK=1; B P2 has SYN=1,ACK=1; C P2 has SYN=0,ACK=1; D P1 has SYN=1.
Select all that apply
Answer & solution
Official answer: B, D
Approach: Separate the request to synchronize sequence numbers from the acknowledgment of the peer’s request. P1 is the initiating SYN: it starts synchronization with SYN=1 and, in the ordinary initial handshake, ACK=0. Hence D is true. P2 both acknowledges the first SYN and announces the responding endpoint’s own initial sequence number. Its flags are SYN=1 and ACK=1. This makes B true and C false. P3 acknowledges the responder’s SYN. It is an ACK with SYN=0,ACK=1, so A is false. The correct selection is B and D. The ACK flag indicates that the acknowledgment-number field is valid; it is not merely a generic statement that a packet arrived. This question is about the standard three-way establishment sequence, not simultaneous open or later connection teardown.
For real k, consider x+ky=1 and kx+y=−1. Select true claims: A exactly one k gives no solution; B infinitely many k give no solution; C exactly one k gives a unique solution; D exactly one k gives infinitely many solutions.
Select all that apply
Answer & solution
Official answer: A, D
Approach: Use the determinant to locate exceptional parameter values, then test consistency at those values. The coefficient matrix is [[1,k],[k,1]], with determinant 1−k². For every k other than 1 or −1, this determinant is nonzero, so the system has a unique solution. There are infinitely many such k, which disproves C. At k=1, the equations become x+y=1 and x+y=−1. Their left sides agree but their right sides do not, so no solution exists. At k=−1, the equations become x−y=1 and −x+y=−1. The second is the first multiplied by −1, leaving one equation in two variables. All pairs (x,y)=(1+t,t) solve it, so there are infinitely many solutions. There is exactly one inconsistent value and exactly one infinitely-solvable value, giving A and D. The record remains in its existing supplemental/excluded subject classification; the mathematics is included for paper completeness.
X(a,b,c)=1 precisely when at least two of a,b,c equal 1. Select identities valid for every Boolean input: A X(a,b,X(c,d,e))=X(X(a,b,c),d,e); B X(a,b,X(a,b,c))=X(a,b,c); C X(a,b,X(a,c,d))=X(a,b,a) AND X(c,d,c); D X(a,b,c)=X(a,X(a,b,c),X(a,c,c)).
Select all that apply
Answer & solution
Official answer: B, D
Approach: Use two basic majority rules: X(u,u,v)=u, and X(0,1,v)=v. Prove claimed identities by cases and reject others with one counterexample. For B, if a=b then both sides equal a. If a≠b, the outer X(a,b,z) returns z, so the left side becomes X(a,b,c), exactly the right side. Thus B holds. For D, X(a,c,c)=c. If a=c, both the left side and X(a,X(a,b,c),c) equal a. If a≠c, X(a,b,c)=b, and the right side becomes X(a,b,c)=b. Thus D also holds. A is not an associative law: choose (a,b,c,d,e)=(0,0,0,1,1). The left side is X(0,0,1)=0, whereas the right side is X(0,1,1)=1. C fails for (a,b,c,d)=(0,1,1,1). Its left side is X(0,1,1)=1; its right side is X(0,1,0) AND X(1,1,1)=0 AND 1=0. Therefore select B,D. Equality on a few examples cannot establish an identity, which is why the true cases require a complete case argument.
The four-bit two’s-complement encoding of −6 is 1010. Which wider encodings still represent −6? A eight-bit 10001010; B eight-bit 11111010; C sixteen-bit 1000000000001010; D sixteen-bit 1111111111111010.
Select all that apply
Answer & solution
Official answer: B, D
Step through it (10 steps)
Approach: Extend the sign bit, not zeros, when widening a signed two’s-complement representation. In w bits, a word with leading bit 1 represents its unsigned value minus 2w. The four-bit word 1010 has unsigned value 10, so 10−16=−6. To preserve that signed value when adding high-order bits, copy the leading 1 into every new position. For eight bits this gives 11111010, with unsigned value 250 and signed value 250−256=−6. For sixteen bits it gives 1111111111111010, with unsigned value 65530 and signed value 65530−65536=−6. Therefore B and D are correct. A has unsigned value 138 and thus signed value −118. C has unsigned value 32778 and thus signed value −32758. Merely retaining a single leading 1 and inserting zeros is not valid sign extension; it changes the negative weight of the leading bit without compensating through the new high bits.
Distinguishing BST guarantees from worst-case bounds
Binary Search & Balanced Trees
Tap to enlarge
For a BST storing n distinct integers, assess: A “The maximum length of a path from the root node to any other node is (n−1).” B inorder traversal is always sorted. C worst-case search takes O(log₂ n). D every BST is a Min-Heap. Select all true statements. A’s wording is retained because it has a material quantifier ambiguity.
Select all that apply
Answer & solution
Official answer: A, B
Our answer: A;B under upper-bound interpretation; B under literal per-tree equality
Approach: Separate guarantees for every individual tree from the largest possible height among all n-node BSTs. Inorder traversal visits the left subtree, root, then right subtree. By the BST ordering invariant all left keys are smaller and all right keys are larger. Applying that reasoning recursively produces sorted order, so B is unconditionally true. Any root-to-node path contains at most n nodes, hence at most n−1 edges. A completely skewed BST attains this bound. Under the intended “maximum possible over all BSTs” interpretation, A is true and the official answer is A,B. Literally, however, A says that each tree’s maximum root path IS n−1. A balanced three-node BST has height 1 rather than 2, so under that reading A is false and only B survives. C is false because search follows a root-to-node path and may take Θ(n) in a skewed BST; balancing is not promised. D is false because a BST need not be complete, and its left child can be smaller than its root, violating min-heap order. Keep the official A;B for scoring while explicitly warning about A’s wording. The mathematical distinction must not be hidden by replacing “is” with “at most”.
Two independent multiplexers feed an ALU. Mux_A selects either 32-bit register RA or a 32-bit immediate; Mux_B selects either 32-bit register RB or another 32-bit immediate. The ALU writes a 32-bit register RZ. Which are supported? A two register operands; B one register and one immediate; C two immediate operands; D only one-register/one-immediate operations.
Select all that apply
Answer & solution
Official answer: A, B, C
Approach: Enumerate independent multiplexer settings instead of assuming the instruction formats of a familiar processor. Selecting RA at Mux_A and RB at Mux_B gives two register operands, so A is supported. Selecting RA and the B-side immediate, or the A-side immediate and RB, gives one register and one immediate; B is supported. Selecting the immediate input at both multiplexers gives two immediate operands, so C is supported as well. All selected values are 32 bits and can be delivered simultaneously to the ALU, whose result goes to RZ. No data connection in the shown partial datapath forces a mux to choose a register merely because the other mux chose an immediate. Thus select A,B,C. D is false because its word “only” excludes the other two combinations. This is a claim about the available datapath connections, not proof that a particular instruction-set encoding actually exposes every such combination.
A regular language L is accepted by an n-state NFA. Which statements are false? A L may also have an NFA with fewer than n states; B L may have a DFA with fewer than n states; C some DFA for L has at most 2^n states; D every DFA for L has more than 2^n states.
Select all that apply
Answer & solution
Official answer: D
Approach: Apply subset construction and distinguish “may” from a guaranteed reduction. When determinizing an NFA, a DFA state records the set of NFA states that can currently be active. An n-element set has 2n subsets, so the construction uses at most 2n states, including the empty subset if needed. Unreachable subsets can be removed. This proves C and directly contradicts D, making D the false statement. The NFA in the premise is not required to be minimal. For example, an automaton for all strings can be padded with redundant states although a one-state accepting automaton already recognizes that language. Therefore A and B describe genuine possibilities for a nonminimal supplied NFA. They do not assert that every n-state NFA can be reduced, nor a strict reduction at n=1 in the conventional nonempty-state model. The exponential bound is an upper bound that can be necessary for some languages, not a claim that every language needs exponentially many DFA states.
A process executes one scanf, then twenty loop iterations, each doing x=x+20 and one printf. Every I/O operation sends it to an I/O queue; context switches occur both on I/O requests and on returns. Excluding initial admission, how many times does it enter the ready queue during this program? Use the question’s stipulated blocking-I/O model.
Answer & solution
Official answer: 21
Approach: Count the state transitions into Ready rather than all context switches. The scanf causes one I/O request. The loop has exactly twenty iterations, so its printf causes twenty more requests. There are 21 I/O operations in all. Each request takes the process from Running to Blocked (the I/O queue); that transition does not enter the ready queue. When each I/O operation completes, the blocked process becomes eligible to run again and enters Ready once. Thus 21 completions produce 21 ready-queue entries. The initially admitted Ready entry is explicitly excluded, giving the answer 21 rather than 22. There can be two stipulated context-switch events around an I/O episode, but they must not both be counted as Ready entries. The intended model assumes no additional time-slice or priority preemptions; such unspecified events could add entries. It also treats library I/O as blocking regardless of real-world stdio buffering.
Over alphabet {a,b,c}, count the length-five strings containing at least one adjacent equal pair aa, bb or cc.
Answer & solution
Official answer: 195
Approach: Count the complement, because counting each repeated-pair position directly would count some strings multiple times. There are three choices independently at each of five positions, so there are 35=243 strings in total. A string with no equal adjacent symbols has 3 choices for its first symbol. At each of its remaining four positions, the immediately previous symbol is forbidden and the other two are allowed. This gives 3×24=48 strings without adjacent repeats. Every string either has an adjacent equal pair or has none, and these categories are disjoint. Subtracting the latter from the total gives 243−48=195. For example aaaaa has four repeated-adjacency positions, but it must count as just one string. Complement counting handles such overlaps automatically. The condition is “at least one”, so strings with two, three or four equal adjacent pairs all remain included in 195.
Let f(x)=ax+b for x<1 and f(x)=x³+x²+1 for x≥1. If f is differentiable everywhere, find b to one decimal place.
Answer & solution
Official answer: -2.1 to -1.9
Our answer: -2.0
Approach: Both pieces are polynomials, so only the join x=1 can cause a problem. Differentiability requires both continuity and matching one-sided derivatives there. The right-hand value is f(1)=1+1+1=3. The left-hand limit is a+b. Continuity therefore requires a+b=3. The derivative on the left is a. The derivative on the right is 3x²+2x, whose value at 1 is 5. Matching the slopes gives a=5. Substituting into the continuity equation yields b=3−5=−2. Thus enter −2.0. Matching derivatives alone would determine a but leave b undetermined; the continuity condition is essential. Once both conditions hold, the polynomial pieces join differentiably and there are no other problematic points. The official accepted interval −2.1 to −1.9 remains unchanged. This supplemental calculus item retains its existing excluded subject label.
A box contains four fair coins and one coin that always produces heads. Choose one of the five coins uniformly and toss that same coin twice. Given two heads, find the probability the chosen coin is the fake coin, to two decimal places.
Answer & solution
Official answer: 0.49 to 0.51
Our answer: 0.50
Approach: Use Bayes’ rule because observing heads changes the relative plausibility of the two kinds of coin. Let F denote the fake coin and H denote the observed pair of heads. Before tossing, P(F)=1/5 and P(not F)=4/5. The fake always gives heads, so P(H|F)=1. With a fair coin, independent tosses give P(H|not F)=(1/2)²=1/4. The total probability of two heads is P(H)=(1/5)×1+(4/5)×(1/4)=2/5. Consequently P(F|H)=P(F and H)/P(H)=(1/5)/(2/5)=1/2=0.50. Two heads do not prove that the coin is fake: the combined four-coin fair alternative has exactly as much probability mass for this observation as the fake alternative. The official range 0.49–0.51 and the existing supplemental/excluded classification are retained.
For i=0,…,n−2, an algorithm scans j=0,…,n−i−2 and swaps A[j],A[j+1] whenever A[j]>A[j+1]. Its input is 30 distinct integers in descending order. How many swaps occur?
Answer & solution
Official answer: 435
Approach: An adjacent out-of-order swap removes exactly one inversion, so count the input’s inversions. An inversion is a pair of positions i<j with A[i]>A[j]. In descending order every pair of distinct positions is an inversion. There are C(30,2)=30×29/2=435 such pairs. When two adjacent inverted values are swapped, their mutual inversion disappears. Their order relative to every other element contributes the same total as before, because no other element lies between the two positions. Thus each swap reduces the inversion count by exactly one. The shown bubble-sort passes finish in ascending order, with zero inversions, so exactly 435 swaps are required. A pass-by-pass check gives the same result: the largest value moves right in 29 swaps, the next in 28, and so on down to 1. Summing 29+28+⋯+1 gives 435. Comparisons and swaps are different quantities in general, even though every comparison succeeds for this descending distinct input.
C function foo(int *p,int x) executes *p=x. In main, a=20,b=25, pointer z is assigned &a, then foo(z,b) is called and a is printed. What integer is printed?
Answer & solution
Official answer: 25
Approach: Distinguish copying an argument from modifying the object that a copied pointer designates. Initially a contains 20 and b contains 25. The assignment z=&a makes z hold the address of a. On calling foo(z,b), the parameter p receives a copy of that same address, while x receives the value 25. Inside foo, the expression *p is the integer object at p’s address, which is main’s a. Therefore *p=x stores 25 into a. Returning from foo discards its local parameter objects but does not undo the write to a. The subsequent printf of a prints 25. C still passes arguments by value: p itself is copied, but the copied address can be dereferenced to change an object owned by the caller. If the function had assigned only p or x, that would be a different operation; the dereferencing assignment is decisive.
Height is the largest number of edges on a root-to-leaf path. A Min-Heap stores 32 keys. Under the standard binary-heap convention, what is its height?
Answer & solution
Official answer: 5
Approach: Use the complete-binary-tree shape of a binary heap; key order does not determine its height. At depth d, a binary tree can contain at most 2d nodes. The completely filled levels from depth 0 through depth 4 contain 1+2+4+8+16=31 nodes. A 32nd node therefore cannot fit in those levels and must occupy depth 5. A heap is complete: all levels except possibly the last are full, with the last filled from left to right. Hence 32 keys create one node at depth 5 and none deeper. The height, measured in edges, is 5. Equivalently, an n-node complete binary tree has height floor(log₂ n), and floor(log₂32)=5. Counting occupied levels would give 6, but the question explicitly uses edges. The answer relies on the conventional binary meaning of Min-Heap; arbitrary heap-ordered trees need not have this shape.
A byte-addressable system has 1 MiB of main memory, 20-bit addresses, and a 16 KiB direct-mapped cache with 16-byte blocks. How many bits store the tag values for all lines, excluding other metadata? A 6×2^10; B 8×2^10; C 2^12; D 2^14. Here K=2^10 and M=2^20.
Your answer
Answer & solution
Official answer: A
Step through it (7 steps)
Approach: Split an address into tag, cache-line index and byte offset; then multiply tag width by the number of lines. A 16-byte block requires log₂16=4 offset bits. The cache contains 16 KiB/16 bytes=214/24=210 lines, so direct mapping requires 10 index bits to select a line. From the 20 address bits, the remaining tag width is 20−10−4=6 bits. Every line needs its own stored tag to distinguish the main-memory blocks that map to that line. Therefore total tag storage is 210×6=6144 bits, option A. This is a bit count, not a byte count. The 16 KiB cache size describes data capacity; valid bits, dirty bits and other control metadata are not part of the requested tag values. Ignoring the block offset or using the number of bytes instead of lines would produce the wrong tag width or multiplier.
A processor has 64 general-purpose registers, 50 instruction types, and fixed 32-bit instructions. For ADD R1,#25, meaning R1=R1+25, what is the maximum immediate field width in the conventional fixed-width opcode/register-field model? A 16; B 20; C 22; D 24 bits.
Your answer
Answer & solution
Official answer: B
Approach: Reserve the minimum bits needed for the opcode and the explicitly encoded register, then assign the remainder to the immediate. There must be at least 50 opcode patterns. Five bits provide only 32 patterns, while six provide 64, so the opcode requires ceil(log₂50)=6 bits. Selecting among 64 registers requires log₂64=6 bits. This two-address instruction uses R1 both as a source and as the destination; the same register is encoded once, not in two independent fields. Thus the immediate can occupy 32−6−6=20 bits, option B. The calculation assumes a uniform opcode field and no additional mode or reserved fields, as intended by the question. A 16-bit immediate would leave unused capacity under those assumptions, while 22 or 24 bits would not leave enough room for both required fields. An instruction-set design with variable-length opcodes would need additional specification before such a maximum could be established.
Four processes arrive at time 0 with CPU bursts P1=20, P2=16, P3=25, P4=10 ms. Scheduling is non-preemptive. M1 priority order is P1>P3>P2>P4; M2 order is P2>P3>P4>P1. A free processor chooses the highest-priority waiting process in its own order; a process runs on only one processor. Ignore switching overhead. Average waiting time? A 9.00; B 8.75; C 6.50; D 7.50 ms.
Your answer
Answer & solution
Official answer: A
Approach: Build a timeline of processor release events, selecting only among processes still waiting at each event. At t=0, M1 selects P1 and M2 selects P2. Neither process waits. Their completion times are 20 and 16 respectively. At t=16, M2 becomes free while P3 and P4 are waiting. M2 ranks P3 above P4, so P3 begins at 16 and finishes at 41. At t=20, M1 becomes free; P3 is already running and cannot be scheduled again, so M1 begins P4, which finishes at 30. Because all arrivals are at zero and scheduling is non-preemptive, waiting times equal start times: P1=0, P2=0, P3=16, P4=20. Their average is (0+0+16+20)/4=9.00 ms, option A. Completion times must not be averaged as waiting times, and priority orders are applied only to eligible waiting processes, not to processes already executing elsewhere.
Relations are teams(tid,tname) and players(pid,pname,tid). Return names of players on a team named MI. A {p.pname | p∈players ∧ ∃t(t∈teams ∧ p.tid=t.tid ∧ t.tname='MI')}; B the same expression but p∈teams and t∈players; C the expression in A without p.tid=t.tid; D the expression in B without p.tid=t.tid. Which is correct?
Your answer
Answer & solution
Official answer: A
Approach: Translate the desired result into tuple bindings, a join predicate, a selection predicate and a projected attribute. A returned name must come from a player tuple, so bind p to players. There must exist a team tuple t whose id equals the player’s team id, giving t∈teams and p.tid=t.tid. The selected team must have t.tname='MI'. Project p.pname from precisely those player tuples. These requirements combine exactly as A. B and D bind p to teams even though teams has no pname attribute, and bind t to players even though players has no tname attribute. They are not correctly typed for the supplied schemas. C has the right bindings but omits the join. If any team is called MI, its existential condition becomes true for every player, including players on other teams. That illustrates why a selection on team name does not replace the relationship connecting a player to that team.
Destination 145.36.109.70 arrives at a router with entries 145.36.0.0/16→E1; 145.36.128.0/17→E2; 145.36.64.0/18→E3; 145.36.255.0/24→E4; default→E5. Which outgoing interface is selected? A E3; B E1; C E2; D E5.
Your answer
Answer & solution
Official answer: A
Step through it (3 steps)
Approach: First find all matching network prefixes, then choose the most specific (longest) one. The first two destination octets are 145.36, so the /16 E1 entry matches. The /17 E2 entry additionally requires the high bit of the third octet to be 1, meaning a third octet from 128 through 255. The destination’s third octet is 109, so that entry does not match. The /18 E3 prefix fixes the first two bits of the third octet to 01, covering 64 through 127. Since 109 lies in that range, it matches. The /24 E4 entry requires third octet 255, so it does not match. Among E1’s /16, E3’s /18 and the default, /18 is longest. Thus forward to E3, option A. Routing is not a first-listed-match decision, and a longer prefix is relevant only if it actually matches.
Similar questions1 more → · asked again: GATE 2012, Q11
Finding eigenvalues of a matrix power
Linear Algebra
Tap to enlarge
Let A=[[1,1],[1,−1]]. What are the eigenvalues of A^13? A 1,−1; B 2√2,−2√2; C 4√2,−4√2; D 64√2,−64√2.
Your answer
Answer & solution
Official answer: D
Approach: Look for a simple low power of the matrix before attempting thirteen multiplications. Multiplying A by itself gives [[2,0],[0,2]]=2I. Therefore A13=(A²)6A=(2I)6A=64A. The characteristic equation of A is det(A−λI)=(1−λ)(−1−λ)−1=λ²−2=0, so its eigenvalues are √2 and −√2. Multiplying a matrix by 64 multiplies each eigenvalue by 64, giving 64√2 and −64√2 for A13. Thus D is correct. Equivalently, the eigenvalues of A13 are (±√2)13=±26√2. The negative eigenvalue remains negative because the exponent is odd. This gives a useful check on both sign and magnitude. Their sum is zero, consistent with trace(A13)=64 trace(A)=0. The linear-algebra question remains in the existing supplemental/excluded subject classification.
F(b3,b2,b1,b0)=Σm(0,2,4,8,10,11,12), with b3 most significant and no don’t-cares. Let ¬ denote NOT, juxtaposition AND and + OR. Choose the minimized expression: A ¬b1¬b0+¬b2¬b0+b1¬b2b3; B ¬b1¬b0+¬b2¬b0; C ¬b2¬b0+b1b2b3; D ¬b0¬b2+¬b3.
Your answer
Answer & solution
Official answer: A
Step through it (11 steps)
Approach: Group minterms differing only in free variables; each group must contain only listed 1-minterms because there are no don’t-cares. The four minterms {0,4,8,12} have b1=0,b0=0 while b3,b2 vary freely. They give implicant ¬b1¬b0. Similarly {0,2,8,10} have b2=0,b0=0 and give ¬b2¬b0. Minterm 11 (1011) is still uncovered; pair it with 10 (1010) to obtain b3¬b2b1. These groups cover exactly the seven specified minterms, producing A. Minimality also follows: minterm 12 needs the first maximal group, minterm 2 the second, and minterm 11 the third. Their essential coverage cannot be omitted. B misses minterm 11. C has a wrong uncomplemented b2 in its second term, misses required cases such as 4, and includes unwanted cases such as 14. D includes ¬b3, which would make F(0001)=1 despite minterm 1 not being listed.
An undirected unweighted graph has 100 vertices and maximum finite shortest-path distance 30 between vertices, in the usual connected-graph interpretation. T is any BFS tree. Which holds universally? A height exactly 15; B height exactly 30; C height at least 15; D height at least 30.
Your answer
Answer & solution
Official answer: C
Approach: A BFS tree preserves distance from its root; relate those root distances to two diameter endpoints. Let r be the BFS root and let h=maxv d(r,v), the tree height. Choose u,v with d(u,v)=30. A route from u to r and then from r to v has length d(u,r)+d(r,v), so the shortest u-to-v path obeys 30≤d(u,r)+d(r,v)≤h+h=2h. Therefore h≥15, giving C. Also h≤30 because no pair of vertices is farther apart than the diameter. The actual height depends on the chosen root, so neither exact value in A or B is guaranteed. A path of length 30 rooted at its centre has height 15, while rooting at an endpoint gives height 30. To meet the 100-vertex requirement, attach 69 extra leaves at the central vertex; the diameter remains 30 and the same two heights remain possible. Thus D’s stronger lower bound 30 is false. BFS preserves root distances, but it does not necessarily choose a central root.
Over {a,b}, define L1={αβα | α∈{a,b}+ and β∈{a,b}+}, and L2={αβα | α∈{a}+ and β∈{a,b}+}. Both α and β must be nonempty. Which is correct? A both regular; B only L1 regular; C only L2 regular; D neither regular.
Your answer
Answer & solution
Official answer: C
Approach: Simplify L2 directly, then prove L1 nonregular using intersection with a carefully chosen regular language. Every L2 word begins and ends in a and has length at least three. Conversely any such word can use α=a and the nonempty intervening substring as β. Hence L2=a(a|b)+a, which is regular. For L1 intersect with R={abr aabs:r,s≥1}. R is regular. A word in R has exactly three a’s. If it equals αβα, the two disjoint copies of α cannot each contain two a’s; because α starts at the initial a, it contains exactly one a. It also ends in b, and its suffix copy must start at the third a: starting at the second a would include two a’s. Thus α=abs. This is a prefix exactly when r≥s. The remaining β=br−sa is nonempty. Therefore L1∩R={abr aabs:r≥s≥1}. If this intersection were regular with pumping length p, choose w=abp aabp. Any pumpable nonempty substring within the first p positions either includes the initial a or consists only of b’s from the first block. Pumping it down in the first case destroys the required initial a; in the second case it reduces r below s. Every permitted decomposition fails, contradicting the pumping lemma. Regular languages are closed under intersection, so L1 cannot be regular. L2 is regular and L1 is not: C. A repeated substring does not automatically prove nonregularity; the explicit restriction and pumping argument supply the proof.
For m,n≥1, L1={a^m b^m c^(m+n)} and L2={a^m b^n c^(m+n)}. Which is true? A both context-free; B only L1 context-free; C only L2 context-free; D neither context-free.
Your answer
Answer & solution
Official answer: C
Approach: Give a constructive grammar for L2 and a pumping-lemma contradiction for L1. L2 is generated by S→aSc | aTc and T→bTc | bc. Each use of S adds one a and one trailing c, with at least one a forced before moving to T. Each T production similarly pairs a b with a c and forces at least one b. The derived words are exactly am bn cm+n, so L2 is context-free. Suppose L1 were context-free with pumping length p. Choose w=ap bp cp+1, which is in L1 with m=p,n=1. In a pumping decomposition w=uvxyz, |vxy|≤p and |vy|>0. The window cannot touch both the a and c blocks, because it would have to span all p b’s between them. Let Δa,Δb,Δc count those symbols in the pumped parts v and y. If pumping disrupts block order, it already leaves L1. Otherwise, if Δa≠Δb, pumping down or up breaks equality of a and b counts. If Δa=Δb>0, then Δc=0; pumping up makes the common count at least p+1 while c remains p+1, violating the strict requirement c>m. Finally if Δa=Δb=0, then Δc>0; pumping down leaves at most p c’s while a=b=p, again violating c>m. All possibilities fail. Thus L1 is not context-free, giving C. The unrestricted extra c’s in L1 do not eliminate the need to enforce both equality and a strict count comparison.
While computing FIRST and FOLLOW for top-down parsing, select true statements: A A→ε adds ε to FIRST(A); B the input end marker is added to FIRST(S), where S is the start symbol; C A→ε adds ε to FOLLOW(A); D the end marker is added to FOLLOW(S).
Select all that apply
Answer & solution
Official answer: A, D
Approach: Keep separate what a nonterminal can begin with and what can appear immediately after it. FIRST(A) contains terminals that can start a string derived from A, and includes ε when A can derive the empty string. Therefore the production A→ε makes A true. FOLLOW(A) contains terminals, or the designated end marker, that may occur immediately after A in a sentential form or completed parse. ε is not an input symbol and never belongs in FOLLOW merely because A is nullable, so C is false. Nullability instead causes FOLLOW information to propagate through nullable suffixes. The start symbol represents an entire accepted input, so the end marker follows it: D is true. That marker is not automatically the first symbol of any derivation from S, making B false. Thus select A,D. For an ε-production, a predictive parser uses FOLLOW(A) to decide when to take it; it does not put ε into FOLLOW(A).
Schema team(name,city,owner) has dependencies name→city and name→owner, and is decomposed into t1(name,city),t2(name,owner). Select true statements: A team is not BCNF; B both components are BCNF; C the join is lossless; D team is not 3NF.
Select all that apply
Answer & solution
Official answer: B, C
Step through it (4 parts)
Approach: Find the key, check the determinants of nontrivial dependencies, then use the binary lossless-join criterion. The closure of {name} contains name, city and owner, so name is a key of team. All nontrivial given dependencies, and their relevant nontrivial consequences, have a determinant containing that key. Therefore team is BCNF. Since BCNF implies 3NF, A and D are false. In t1, name determines city; in t2, name determines owner. Thus name is also a key of each component and both are BCNF, making B true. The common attribute set is t1∩t2={name}. It determines all attributes of t1 and also all attributes of t2. In particular it satisfies the binary lossless-join condition that the intersection determine one component. Therefore joining the projections cannot create spurious combinations for any original instance satisfying the dependencies, making C true. Select B,C. Decomposition is not needed to fix a normal-form violation here; it is nevertheless lossless, and the listed dependencies are also retained in the separate components.
mother(y,x) means y is x’s mother; noteq(x,y) means x≠y. Which formulae express that everyone has exactly one mother? A ∀x∃y∃z(mother(y,x) ∧ ¬mother(z,x)); B ∀x∃y[mother(y,x) ∧ ∀z(noteq(z,y)→¬mother(z,x))]; C ∀x∀y[mother(y,x)→∃z(mother(z,x)∧¬noteq(z,y))]; D ∀x∃y[mother(y,x) ∧ ¬∃z(noteq(z,y)∧mother(z,x))].
Select all that apply
Answer & solution
Official answer: B, D
Approach: “Exactly one” requires both existence and uniqueness for each x. B first supplies a witness y with mother(y,x). Its universal clause says every z different from y is not a mother of x, which excludes all second mothers. Hence B expresses both requirements. D has the same existence clause and says there is no different z that is also a mother. By negating an existential conjunction, that uniqueness clause is equivalent to B’s universal implication. Thus D is also correct. A only supplies one mother and one nonmother. It allows two or more mothers as long as somebody is not a mother, so it does not enforce uniqueness. C says that if y is a mother, an equal mother z exists; choosing z=y always satisfies it. It imposes no uniqueness and, when no mothers exist, is vacuously true, so it does not even enforce existence. Therefore choose B,D. The location of the quantifiers and the difference between a universal exclusion and one existential nonexample are decisive.
Let A={0,1,2,…} and F be all functions A→A. Define (f1⊙f2)(n)=f1(n)+f2(n) for every n. Classify (F,⊙): A Abelian group; B Abelian monoid; C non-Abelian group; D non-Abelian monoid.
Select all that apply
Answer & solution
Official answer: B
Approach: Check closure, associativity, identity, commutativity and inverses separately. The operation is pointwise addition, not function composition. For any n, the sum of two non-negative integers is non-negative, so f1⊙f2 is again a function A→A: closure holds. Ordinary addition is associative, so evaluating either (f1⊙f2)⊙f3 or f1⊙(f2⊙f3) at n gives the same sum of three values. The identically zero function e(n)=0 acts as a two-sided identity. Addition is commutative at every n, so the function operation is commutative. These facts make an Abelian monoid. To be a group every function would need an inverse in F. The constant function f(n)=1 would require an inverse g(n)=−1 for all n to obtain zero. Such a g does not map A to A. Therefore inverses do not exist for all elements and the structure is not a group. Select B; A and C fail the inverse requirement, and D fails commutativity.
A DFA over {a,b} has states q0,q1,q2,q3, start q0 and sole accepting state q3. Transitions on (a,b) are q0→(q0,q1), q1→(q2,q1), q2→(q0,q3), q3→(q2,q1). Which language does it recognize? A words with an even number of b’s; B words containing bab; C words ending in bab; D words avoiding aba.
Select all that apply
Answer & solution
Official answer: C
Approach: Assign each state the longest suffix of the input read so far that is also a prefix of the pattern bab. The prefixes are ε,b,ba,bab, corresponding respectively to q0,q1,q2,q3. At q0 an a leaves no nonempty matching suffix, while b starts the match. At q1 another b still leaves suffix b, while a extends it to ba. At q2, b completes bab, but a leaves no matching suffix and returns to q0. After reaching q3, an a leaves suffix ba and returns to q2; a b leaves suffix b and returns to q1. Therefore acceptance records that the current complete word ends in bab, not merely that bab appeared at some earlier position. This proves C. B fails because baba contains bab but ends at nonaccepting q2. A fails because the empty word has an even b-count but is rejected. D fails because a avoids aba yet is rejected.
Separating linked-allocation overhead from fragmentation
File Systems
Tap to enlarge
A 512 MiB disk uses 64 KiB blocks. Linked allocation reserves four bytes in every allocated block for a next-block pointer, including a four-byte NULL pointer in the last block. A file holds 1 MiB of data. With K=2^10 and M=2^20, how many bytes are unused because of internal fragmentation?
Answer & solution
Official answer: 65468
Approach: Subtract pointer storage from per-block data capacity before computing how many blocks are needed. A block is 64×1024=65536 bytes. Four bytes are reserved for the pointer, leaving 65532 bytes for file data. The file has 1048576 bytes. Sixteen blocks can hold only 16×65532=1048512 data bytes, which is 64 bytes too little. Therefore a seventeenth block is necessary. The first sixteen data regions are full and the last contains the remaining 64 file bytes. Its unused data area is 65532−64=65468 bytes. Equivalently, 17×65532−1048576=65468. The 17 pointer fields occupy 68 bytes, but those bytes are allocated structural overhead rather than unused data space. Counting total physical allocation minus file size would give 17×65536−1048576=65536; subtracting the pointer overhead leaves the required 65468. The last NULL pointer still consumes its specified four bytes.
Partition this three-address code into maximal basic blocks. 1001 i=1; 1002 j=1; 1003 t1=10*i; 1004 t2=t1+j; 1005 t3=8*t2; 1006 t4=t3−88; 1007 a[t4]=0.0; 1008 j=j+1; 1009 if j≤10 goto 1003; 1010 i=i+1; 1011 if i≤10 goto 1002; 1012 i=1; 1013 t5=i−1; 1014 t6=88*t5; 1015 a[t6]=1.0; 1016 i=i+1; 1017 if i≤10 goto 1013. How many blocks?
Answer & solution
Official answer: 6
Approach: Mark every leader: the first instruction, every jump target, and every instruction immediately following a jump when present in the supplied code. The first instruction makes 1001 a leader. Branch targets make 1003,1002,1013 leaders. The instructions following branches at 1009 and 1011 are 1010 and 1012, so they are leaders too. The branch at 1017 is the last supplied instruction; there is no following instruction to create an extra block. Sorting the distinct leaders gives 1001,1002,1003,1010,1012,1013. Each block extends to just before the next leader, or to the end: [1001], [1002], [1003–1009], [1010–1011], [1012], [1013–1017]. There are six blocks. A basic block has one entry and no internal branch out before its end. This explains why even a single assignment at 1002 or 1012 can form its own block: the next instruction is independently a branch target. Counting loops or conditionals alone would not identify the correct partition.
Memory is searched in order L1,L2,main memory. L1 has 95% hit rate and 10 ns access time. L2 has 85% hit rate conditional on an L1 miss; its 20 ns time already includes the L1 miss penalty. Main-memory access is 200 ns including both cache miss penalties. Find average access time in ns to two decimals.
Answer & solution
Official answer: 11.83 to 11.87
Our answer: 11.85
Approach: Partition accesses into mutually exclusive completion paths and weight the total time of each path. An L1 hit has probability 0.95 and total time 10 ns. An L1 miss followed by an L2 hit has probability 0.05×0.85=0.0425 and total time 20 ns. Missing both caches has probability 0.05×0.15=0.0075 and total time 200 ns. These probabilities sum to 1. The expected time is therefore 0.95×10+0.0425×20+0.0075×200=9.50+0.85+1.50=11.85 ns. The word “including” in the diagram is essential: adding 10 ns again to the L2 or memory path would double-count time already included. Likewise the 85% L2 hit rate applies only to accesses reaching L2, not to all processor requests.
Three page frames start empty. References are 1,3,2,4,2,3,1,2,4,3,1,4. A modified optimal replacement algorithm predicts only a window of four references including the current request, evicting the resident page used farthest in that window, or absent from it. Count page faults.
Answer & solution
Official answer: 6
Step through it (14 steps)
Approach: Simulate each request, and on a full-frame miss inspect only the allowed lookahead window. Requests 1,3,2 fill the empty frames and cause three faults, leaving {1,2,3}. At request 4 (position 4), the window is [4,2,3,1]. Among resident pages, 1 is used farthest away, so evict 1 and load 4: fault 4, frames {2,3,4}. The next requests 2 and 3 hit. At position 7, request 1 misses. The window [1,2,4,3] places resident 3 farthest in the future, so evict 3: fault 5, frames {1,2,4}. Requests 2 and 4 then hit. At position 10, request 3 misses. Only [3,1,4] remains. Resident 2 is absent from that window, so evict 2: fault 6, frames {1,3,4}. The last two requests, 1 and 4, hit. There are six faults, at positions 1,2,3,4,7,10. No replacement tie affects this trace. The current request is included in the four-reference horizon, so the prediction is of at most three additional future accesses, not four.
Tables: player(pid,pname,age) has (1,Jasprit,31),(2,Atharva,24),(3,Ishan,26),(4,Axar,30). coach(cid,cname) has (101,Ricky),(102,Mark),(103,Trevor). team(tid,tname,city,cid) has (10,MI,Mumbai,102),(20,DC,Delhi,101),(30,PK,Mohali,103). members(pid,tid) has (1,10),(2,30),(3,10),(4,20). Evaluate SELECT MIN(P.age) FROM player P WHERE P.pid IN (SELECT M.pid FROM team T,coach C,members M WHERE C.cname='Mark' AND T.cid=C.cid AND M.tid=T.tid).
Answer & solution
Official answer: 26
Approach: Evaluate the inner join and filter to get a set of player IDs, then apply the outer aggregate only to those players. The condition C.cname='Mark' selects coach row cid=102. Joining on T.cid=C.cid selects team tid=10, because that is the team coached by 102. Joining membership on M.tid=T.tid then selects the rows (1,10) and (3,10), so the subquery returns player IDs {1,3}. The outer WHERE P.pid IN (...) retains Jasprit, age 31, and Ishan, age 26. MIN over those two ages is 26, which is the returned value. Atharva’s age 24 is smaller overall but belongs to team 30 coached by Trevor; the predicate removes that row before MIN is computed. Axar likewise belongs to team 20 coached by Ricky. This demonstrates why aggregating over the entire player table before applying the team/coach restriction would be incorrect.
A five-bit message is sent through a channel that independently flips each bit with probability 0.01. What is the probability of receiving the entire message error-free, rounded to three decimal places?
Answer & solution
Official answer: 0.949 to 0.952
Our answer: 0.951
Approach: An error-free message requires all five separate “not flipped” events to occur. For each bit, P(no flip)=1−0.01=0.99. Since the bit-flip events are independent, their complements are independent as well, and the probability of all five correct bits is the product 0.995. Calculating gives 0.9509900499, which rounds to 0.951 at three decimal places. This lies in the official accepted interval 0.949–0.952. The expression 1−5×0.01=0.95 is only a first-order approximation: it treats the five error events as if they were disjoint, even though two or more bits may flip together. Alternatively, the number of errors is binomial with parameters 5 and 0.01, and its zero-error probability is C(5,0)(0.01)0(0.99)5, the same result.
A 15000-byte message travels Source→Router 1→Router 2→Destination. Router 1 has MTU 5000 bytes and Router 2 MTU 3000 bytes, each including its IPv4 header. How many fragments reach the destination? Use ordinary IPv4 fragmentation; no reassembly takes place at intermediate routers.
Answer & solution
Official answer: 7
Approach: Fragment at the first MTU, then split each existing fragment separately at the second MTU. Nonfinal IPv4 fragment payloads must be multiples of eight bytes. Using a standard 20-byte header, Router 1 can carry at most floor((5000−20)/8)×8=4976 payload bytes in a nonfinal fragment. Treating 15000 as payload gives fragment payloads 4976,4976,4976,72, so four fragments leave Router 1. At Router 2, the aligned maximum is floor((3000−20)/8)×8=2976. Each 4976-byte payload splits into 2976 and 2000 bytes, producing two fragments. The final 72-byte payload already fits and stays as one. Thus the destination receives 2+2+2+1=7 fragments. It would be wrong to divide the original payload by Router 2’s MTU as though all first-stage fragments were reassembled; IPv4 routers do not coalesce them. If the original 15000 bytes includes its header, the first-stage remainder becomes 52 instead of 72, with the same total count. The count also remains seven for ordinary legal IPv4 header lengths.
A continuous random variable has density p(x)=Cx² for 1≤x≤4 and p(x)=0 elsewhere. Find P(2≤X≤3) rounded to three decimal places.
Answer & solution
Official answer: 0.300 to 0.302
Our answer: 0.302
Approach: First determine C by total probability one, then integrate the normalized density over the desired interval. Normalization requires 1=∫₁⁴Cx² dx=C[x³/3]₁⁴=C(64−1)/3=21C, hence C=1/21. This positive constant also ensures that the density is non-negative throughout its support. Therefore P(2≤X≤3)=∫₂³x²/21 dx=[x³/63]₂³=(27−8)/63=19/63≈0.3015873016. To three decimal places this is 0.302, within the preserved official interval 0.300–0.302. Because this is a continuous distribution, including or excluding either endpoint does not change the probability. The density is not uniform, so dividing interval lengths, (3−2)/(4−1)=1/3, would be incorrect. The density weights larger x more heavily. This calculus/probability item is retained for paper completeness while preserving its existing supplemental/excluded subject classification.
Minimizing a Mealy machine by partition refinement
Finite-State Machine Design
Tap to enlarge
A Mealy FSM has input X∈{0,1}. Each row lists (next on 0,next on 1; output on 0,output on 1): A=(F,B;0,0), B=(D,C;0,0), C=(F,E;0,0), D=(G,A;1,0), E=(D,C;0,0), F=(F,B;1,1), G=(G,H;0,1), H=(G,A;1,0). Find the minimum number of equivalent states.
Answer & solution
Official answer: 5
Step through it (3 steps)
Approach: Equivalent Mealy states must produce the same immediate output for each input and lead to equivalent states. Refine partitions until stable. Group first by output pair: P0={{A,B,C,E},{D,H},{F},{G}}, corresponding to 00,10,11,01. States in different groups are already distinguishable by a single input. Within the 00 group, A and C go on input 0 to F, while B and E go to the 10 group {D,H}. Those destination groups differ, so split 00 into {A,C} and {B,E}. On input 1 they all initially went to the 00 group, which did not prevent the split required by input 0. Now check P1={{A,C},{B,E},{D,H},{F},{G}}. A,C both lead to {F} on 0 and {B,E} on 1. B,E both lead to {D,H} on 0 and {A,C} on 1. D,H both lead to {G} on 0 and {A,C} on 1. Thus every multi-state group has identical destination-group signatures and no further split is required. The stable equivalence classes are AC, BE, DH, F and G: five states. Partition refinement both constructs a five-state realization and proves that the distinguishable classes cannot be merged.
Finding the cycle length of a twisted-ring counter
Counters & Timing
Tap to enlarge
Four D flip-flops share a clock. Their outputs feed the next inputs as Q0→D1, Q1→D2, Q2→D3, and complemented Q3→D0. Starting from any four-bit initial state, how many distinct states occur before it returns? The wording may count or exclude the initial state; the official interval is 7–8.
Answer & solution
Official answer: 7 to 8
Our answer: 8
Approach: Derive the synchronous state update and show its period for every initial state, rather than checking only all-zero initialization. Write the state as (q0,q1,q2,q3). The next-state map is T(q0,q1,q2,q3)=(¬q3,q0,q1,q2), because a D flip-flop copies its input at a clock edge. After four clocks every original bit has shifted through the complemented feedback once, so T^4(q)=¬q. After eight clocks it has been complemented twice, so T^8(q)=q. The map is invertible, and each orbit’s period divides eight. Possible smaller divisors are 1,2,4, but any such period would make T^4(q)=q. That is impossible because no Boolean vector equals its bitwise complement. Hence every initial vector lies on an eight-state cycle. For example, 0000→1000→1100→1110→1111→0111→0011→0001→0000. Counting the initial state gives eight distinct cycle states; counting only new states visited after leaving it and before return gives seven. Preserve the official 7–8 range while distinguishing the conventions. The feedback was visually confirmed to use complemented Q3, not Q3.
In C, foo(S,size) returns 0 for size=0, 1 for size=1, otherwise returns 1+foo(S+1,size−1) if S[0]≠S[1], and foo(S+1,size−1) otherwise. main prints foo(A,9) for A={0,1,2,2,2,0,0,1,1}. What is printed?
Answer & solution
Official answer: 5
Step through it (17 steps)
Approach: Interpret each recursive step as testing one adjacent boundary, with the final single element supplying the first run count. For a nonempty array, every call with size greater than one advances the pointer by one and decreases size by one. It adds 1 exactly when the two currently adjacent values differ. The size-one base case returns 1, so the total is 1 plus the number of adjacent changes. Here the adjacent-change indicators are 1,1,0,0,1,0,1,0 for the pairs (0,1),(1,2),(2,2),(2,2),(2,0),(0,0),(0,1),(1,1). Their sum is 4; adding the base-case 1 yields 5. Equivalently, the maximal equal-value runs are [0], [1], [2,2,2], [0,0], [1,1]. There are five runs, so the program prints 5. It does not count distinct numerical values; although only 0,1,2 occur, repeated values separated into different runs contribute separately.
L1 is 1→7→12→3→9→5→11→15→8→NULL and L2 is 1→11→6→9→15→12→4→NULL. find(q,L2) returns whether q occurs in L2. Starting ptr1=L1, repeat while ptr1->next!=NULL: set query=ptr1->next->data; if find(query,L2), execute ptr1->next=ptr1->next->next; otherwise advance ptr1=ptr1->next. How many nodes remain reachable in L1?
Answer & solution
Official answer: 5
Approach: Notice that the tested node is ptr1’s successor, not ptr1 itself. On deletion the pointer stays still, so the replacement successor is tested next. Initially ptr1 points to the head value 1. Its successor 7 is not in L2, so advance to 7. The next value 12 is in L2, so bypass it, leaving 7 pointing to 3. Keep ptr1 at 7, test 3, and then advance to 3 because it is absent from L2. Delete successor 9, retain and advance to 5, then delete 11 and 15 in consecutive iterations while ptr1 remains at 5. Finally retain 8 and stop because its next pointer is NULL. The resulting list is 1→7→3→5→8, so five nodes remain. Although head value 1 also occurs in L2, it is never tested as a successor and is not removed. Advancing ptr1 after a deletion would incorrectly skip a candidate such as 15. The code unlinks nodes without calling free; the question asks reachability in L1, not the count of still-allocated memory objects.
Function gate(n) initializes newnum=turn=0,t=1; multiplies t by 10 while n≥t, then divides t by 10. While t>0 it sets d=n/t, n=n%t, t=t/10; if turn is 1 it appends d using newnum=10*newnum+d; then sets turn=(turn+1)%2. All divisions are integer divisions. What does gate(14362) print?
Answer & solution
Official answer: 46
Approach: The first loop finds the highest decimal place value. The second consumes digits from left to right and retains alternating positions. For n=14362, t grows through 1,10,100,1000,10000,100000. The condition then fails and t is divided by 10, giving 10000. The digit iterations are: d=1, remainder 4362, turn=0, so skip; d=4, remainder 362, turn=1, so newnum=4; d=3, remainder 62, turn=0, so skip; d=6, remainder 2, turn=1, so newnum=10×4+6=46; d=2, remainder 0, turn=0, so skip. The place value becomes zero and the loop ends. The program therefore prints 46, the digits in positions two and four from the left. The alternating flag is tested before it is toggled, so the first digit is skipped. For this concrete input all arithmetic fits in int; possible overflow for much larger arguments is irrelevant to this execution.
An undirected four-vertex graph has edges AB=7, AD=6, DC=8, BC=x, BD=1, AC=3. The crossing diagonals BD and AC are edges, not an extra intersection vertex. Find the largest integer x for which BC belongs to every minimum spanning tree.
Answer & solution
Official answer: 5
Approach: Find a cut on which BC is uniquely cheapest, then test the equality boundary because “every MST” is stronger than “some MST”. Consider cut {B,D}|{A,C}. Its crossing edges have weights BC=x, DA=6, BA=7 and DC=8. If x<6, BC is the unique lightest edge of this cut. By the cut property it must occur in every MST. In detail, any spanning tree omitting BC has another crossing edge on the path connecting B to C; adding BC and removing that heavier crossing edge lowers its weight, contradicting minimality. At x=6, the tree {BD,AC,AD} has weight 1+3+6=10 and omits BC. The tree {BD,AC,BC} also has weight 10, and no spanning tree can have smaller weight than the three globally smallest edge weights, which sum to 10. Thus BC is no longer mandatory. For x>6, BC is uniquely heaviest on cycle B-D-A-C-B, whose other weights are 1,6,3, so the cycle property excludes it from an MST. Therefore the required condition is x<6, and the largest integer is 5. Equality cannot be included just because a tie allows an MST containing BC.
An initially empty hash table has m=11 slots. h1(k)=k mod 11, h2(k)=1+(k mod 7), and probe i uses [h1(k)+i·h2(k)] mod 11, starting at i=0. Insert 63,50,25,79,67,24 in that order. In which slot does 24 end up? The formula yields a zero-based index; the official range also accepts the corresponding one-based slot number.
Answer & solution
Official answer: 10 to 11
Our answer: 10
Step through it (8 steps)
Approach: Insert the earlier keys first, because their occupied positions determine how many probes key 24 needs. For the first five keys the primary hash locations are 63 mod 11=8, 50 mod 11=6, 25 mod 11=3, 79 mod 11=2 and 67 mod 11=1. All differ, so each key is placed on its first probe. Occupied indices are therefore {1,2,3,6,8}. For 24, h1=24 mod 11=2 and h2=1+(24 mod 7)=1+3=4. Probe i=0 checks index 2, occupied by 79. Probe i=1 checks (2+4) mod 11=6, occupied by 50. Probe i=2 checks (2+8) mod 11=10, which is empty, so 24 is stored there. The derived index is 10. This is the eleventh slot if slots are described with one-based ordinal numbers. Preserve the official accepted interval 10–11, but use 10 when interpreting the given modulo formula literally. The second hash is the step size, not a replacement initial index.