A fair die is rolled independently three times. Find probability of exactly one odd result among 1/6, 3/8, 1/8, 1/2.
Your answer
Answer & solution
Answer: B: 3/8 (no official key was published)
Each roll is odd with probability 3/6=1/2 and even with probability 1/2. Choose the unique odd roll in three ways. For each choice, independence gives probability (1/2)3=1/8. The three cases are disjoint, so their total is 3/8. Counting only one ordering would give 1/8 and omit the other positions. This calculation uses a fair die and independent rolls, the conventional premises.
Solve the classification for x+2y=5, 4x+8y=12, 3x+6y+3z=15: unique, no solution, finitely many, or infinitely many?
Your answer
Answer & solution
Answer: B (no official key was published)
Multiply the first equation by 4 to obtain 4x+8y=20. The second requires the same left-hand side to equal 12, which is impossible. Hence the first two equations already contradict each other; adding the third cannot restore consistency. The system has no solution, B.
Which applies to bisection: few iterations guaranteed, all continuous functions guaranteed, always faster than Newton, or correct determination of function signs?
Your answer
Answer & solution
Answer: D (no official key was published)
Bisection maintains an interval whose endpoint values have opposite signs and replaces one endpoint by the midpoint. Selecting the correct half therefore depends on reliable sign determination; an erroneous sign can discard the root. This is D. Continuity alone is insufficient without a bracket containing a sign change, and the number of iterations grows with the logarithm of the requested accuracy. Newton may converge quadratically near a simple root, so bisection is not universally faster. These distinctions rule out A, B, C.
Similar questions1 more → · asked again: GATE 2007, Q1
Continuity of absolute value
Calculus
Tap to enlarge
For y=|x| on[−1, 1], classify continuity and differentiability.
Your answer
Answer & solution
Answer: B (no official key was published)
On each side of zero the function is linear: −x for x<0 and x for x>0. Both one-sided limits at zero equal 0, the function value, so it is continuous throughout the interval. But its left derivative at zero is−1 and its right derivative is+1. They disagree, so it is not differentiable at zero. Thus it is continuous but not differentiable everywhere, B. Differentiability away from zero does not remove the corner.
Find the converse of “I stay only if you go.” Options include “I stay if you go, ” the original implication, its contrapositive, and an unrelated negated antecedent.
Your answer
Answer & solution
Answer: A (no official key was published)
Let S mean I stay and G mean you go. “Only if” makes G necessary for S, so the original assertion is S→G. Its converse reverses antecedent and consequent: G→S, expressed as “I stay if you go, ” A. The statement ¬G→¬S is instead the contrapositive and is equivalent to the original, not its converse. Keeping these two transformations separate avoids confusing A with C.
A has n elements. How many ordered pairs can its largest equivalence relation contain: n, n², 1, n+1?
Your answer
Answer & solution
Answer: B (no official key was published)
Every relation on A is a subset of A×A, so its size is at most n². The whole product A×A is reflexive, symmetric and transitive: every pair is present. It is therefore an equivalence relation attaining that upper bound. Hence the largest has n² pairs, B. The diagonal identity relation contains only n pairs and is the smallest equivalence relation, not the largest.
Similar questions1 more → · asked again: GATE 2005, Q42
Union and intersection of equivalences
Sets, Relations & Functions
Tap to enlarge
For equivalence relations R1, R2 on one set, are their union and intersection necessarily equivalence relations?
Your answer
Answer & solution
Answer: C: intersection only (no official key was published)
Intersection preserves reflexivity because each diagonal pair belongs to both; it preserves symmetry and transitivity because the required reversed or composed pair belongs to each relation. Union need not be transitive. On{1, 2, 3}, use partitions{1, 2}|{3} and{1}|{2, 3}. Their union contains (1, 2) and (2, 3), but not (1, 3). Thus intersection is always an equivalence, whereas union is not necessarily one, giving C. Some particular unions are equivalences; the question asks a general guarantee.
Count functions from an m-element domain to an n-element codomain among m+n, m^n, n^m, mn.
Your answer
Answer & solution
Answer: C (no official key was published)
Each of the m domain elements independently chooses one of n images. Multiplying n choices m times yields nm. Different domain elements may share an image because injectivity is not required. Thus C, not mn, which would count functions in the reverse direction. With an empty domain there is one empty function; the usual counting formula is interpreted accordingly.
Compare A=(01+1)* and B=((01)*1*)*: proper inclusion, equality, or incomparable?
Your answer
Answer & solution
Answer: D: equality (no official key was published)
Every block in B is a sequence of 01 blocks followed by a sequence of 1 symbols, all of which are permitted individual blocks of A. Thus B⊆A. Conversely B can produce an individual 01 by selecting one occurrence in (01)* and none in 1*, and can produce an individual 1 by the reverse choice. Its outer star concatenates any sequence of these, so A⊆B. Both include the empty string. Therefore A=B, D.
Which is regular: powers of two written in binary, powers of two in unary, equal numbers of zeros and ones, or{1, 101, 11011, 1110111, …}?
Your answer
Answer & solution
Answer: A (no official key was published)
Binary powers of two are exactly 10*, a regular expression, so a DFA recognizes A. Unary powers of two have gaps that keep increasing and are not ultimately periodic, as every unary regular language must be. Equal zero/one counts would yield nonregular 0n1n after intersection with 0*1*. The displayed final pattern requires matching runs of ones on either side of a zero and is likewise nonregular by pumping or distinguishable prefixes. Hence A under the evident continuation of that example list; an ellipsis itself is not a formal language definition.
Which GFG claim is false: NFA=DFA, NPDA=DPDA, NTM=DTM, multitape TM=single-tape TM in recognized languages?
Your answer
Answer & solution
Answer: B (no official key was published)
Subset construction converts NFAs to DFAs. Turing-machine computation branches can be dovetailed, and tapes can be encoded on one tape, preserving recognized languages though not necessarily runtime. But deterministic PDAs recognize a proper subclass of CFLs: nondeterminism genuinely adds recognition power there. Thus the the paper false statement is B. That source error is disclosed rather than using its letters interchangeably.
Which does not contain 1101: A 110*(0+1), B1(0+1)*101, C(10)*(01)*(00+11)*, D(00+(11)*0)*?
Your answer
Answer & solution
Answer: C, D (no official key was published)
A accepts 1101 using one zero in 0* and final 1. B accepts it with an empty middle star:1·101. For C, the initial 10 block cannot be used because the word starts 11; neither can the next 01 block. The remaining (00+11)* cannot partition 1101 into equal-symbol pairs because its last pair is 01. Thus C rejects. Every nonempty block of D ends in 0, so every nonempty word of D ends in 0;1101 ends in 1 and is rejected too. The paper shows these expressions. A single-answer instruction therefore conflicts with the two rejecting choices.
A bitstring B is XORed with itself n times. What happens, with D saying unchanged for even n?
Your answer
Answer & solution
Answer: D if n counts XOR operations (no official key was published)
XOR satisfies B⊕B=0 and 0⊕B=B. Starting from B, one additional XOR produces 0, two produce B, and so on. Hence after n XOR operations the result is B for even n and 0 for odd n, supporting D. If the diagram’s “n times” instead counts the number of copies of B, the parity reverses: even copies give 0. Neither case complements B or divides it by 2. The operation-count versus operand-count ambiguity is retained.
A multiplexer has four select bits. Is it 4:1, 2:1, 16:1, or 8:1?
Your answer
Answer & solution
Answer: C (no official key was published)
Four binary select inputs encode 24=16 distinct combinations. A conventional fully populated multiplexer uses each combination to select one data input and forwards it to one output. Thus it is 16:1, C. The select width is logarithmic in the number of data inputs; it is not itself the input count. A partially populated design could leave codes unused, but that is not the usual mux designation.
The listed TTL logic 1 ranges are above 2.5 V, 0.8–5 V, below 5 V, and 2.8 V to Vcc. Identify the threshold.
Your answer
Answer & solution
Answer: No exact standard TTL input-high threshold is listed (no official key was published)
For standard 5 V TTL, the guaranteed input-high minimum VIH is 2.0 V and input-low maximum VIL is 0.8 V; the region between them is not guaranteed. Therefore neither 2.5 V nor 2.8 V is the actual specified input-high threshold. B includes the undefined range and C includes definite low voltages. A and D describe portions of the high region if voltages remain within operating limits, not the complete threshold criterion. A universal claim about any voltage above 2.5 V is also unsafe without upper limits. The source options do not provide an exact specification; no official correction is assumed.
Send 300 characters/s using 8 data bits, one parity bit, two stop bits. Choose 2400, 19200, 4800, 1200 baud.
Your answer
Answer & solution
Answer: C is the smallest listed adequate rate; literal minimum 3600 baud with a start bit (no official key was published)
Asynchronous framing also uses one start bit. Each character therefore occupies 1+8+1+2=12 binary symbols, requiring 300·12=3600 symbols/s. With one bit per symbol, that is 3600 baud. Of the listed choices, 2400 and 1200 are too slow;4800 is the smallest sufficient choice, C. The literal minimum is not listed. If no start bit were intended, the arithmetic would instead give 3300; it still would not equal 4800. The choice is therefore a standard/listed-rate selection, not an exact unconstrained minimum.
Octal 342 is treated as an eight-bit integer on an 8085. What decimal value does it represent? Forum options include 226 and−30.
Your answer
Answer & solution
Answer: 226 unsigned; −30 signed twos complement (no official key was published)
Convert 342₈=3·64+4·8+2=226, whose eight bits are 11100010. The 8085 architecture does not automatically attach one language-level signedness to every stored byte; the use determines interpretation. The source does not explicitly say signed. The paper’s faint/missing minus on its D further complicates the option mapping, so both interpretations are retained rather than asserting a unique official answer.
Which should receive higher interrupt priority: hard disk, printer, keyboard, floppy disk?
Your answer
Answer & solution
Answer: Policy-dependent; A in a conventional overrun-sensitive transfer model (no official key was published)
Interrupt priority normally reflects urgency and the cost of delayed service, not merely a device name. A fast unbuffered hard-disk transfer may lose data if not serviced promptly, motivating A in an older transfer-driven design. A buffered DMA disk may need little immediate CPU attention, while another device could have a stricter deadline. Keyboard responsiveness can matter in interactive systems but does not universally outrank data-loss deadlines. The source gives no controller buffering or timing assumptions, so a hardware-independent unique ordering cannot be proved.
Which addressing mode permits relocation without changing code: indirect, indexed, base-register, PC-relative?
Your answer
Answer & solution
Answer: C for general base relocation; D also supports relative references (no official key was published)
Base-register addressing forms effective address=base+stored displacement. Moving the program requires changing the base register, leaving its instruction displacements unchanged, which explains intended C. PC-relative addressing also preserves references within a uniformly moved block because both target and current PC increase by the same relocation amount; their difference stays fixed. Thus D has relocation capability too, though it is not a general replacement for every external/data reference. The scope of relocation is unstated, so C is the standard general mechanism rather than the only conceivable invariant addressing form.
Choose a true claim: all interrupts need enabling, loops cannot be interrupted, processor checks interrupts before a new instruction, only level-triggered interrupts exist.
Your answer
Answer & solution
Answer: C under the ordinary instruction-boundary model (no official key was published)
An eligible interrupt is normally recognized at an architectural instruction boundary, before starting the next instruction, so C expresses the conventional model. Nonmaskable interrupts refute a blanket requirement that every interrupt first be enabled. A software loop comprises instructions and can be interrupted between them. Both edge- and level-triggered interrupt mechanisms exist. Some complex/restartable instructions have additional interrupt points, but these do not rescue the false universal claims in A, B, D.
Which technique underlies the standard all-pairs shortest-path algorithm: dynamic programming, backtracking, greedy, divide-and-conquer?
Your answer
Answer & solution
Answer: A (no official key was published)
Floyd–Warshall defines Dk (i, j) as the best path using only the first k vertices as intermediates. It either avoids k or passes through it, yielding Dk (i, j)=min (Dk−1(i, j), Dk−1(i, k)+Dk−1(k, j)). Reusing these overlapping subproblem values is dynamic programming, A. The answer refers to this standard all-pairs algorithm; other algorithms can solve restricted graph classes, so the task name alone is not a proof that every possible implementation uses the same paradigm.
Match log n, n, n log n, n² to binary search, selection, merge sort, insertion sort.
Your answer
Answer & solution
Answer: B: 3, 1, 4, 2 (no official key was published)
Binary search halves a sorted interval each step, giving logarithmic search time. Selection of a specified rank can be done in linear worst-case time using median-of-medians. Merge sort has logarithmically many levels with linear work per level, giving n log n. Insertion sort can shift a quadratic number of elements on reverse-sorted input. Therefore the intended mapping is 3, 1, 4, 2, B. “Selection” means order-statistic selection, not selection sort, whose worst-case comparisons are quadratic.
How many nonempty substrings of all lengths can be formed from a length-n string? Choices include n, n², 2^n, n (n+1)/2.
Your answer
Answer & solution
Answer: D for positional occurrences (no official key was published)
A substring is determined by its starting and ending positions. For length k there are n−k+1 placements. Summing these counts from k=1 to n gives n+(n−1)+…+1=n (n+1)/2, D. This counts occurrences, even when their text is identical. If the phrase “different lengths” means counting length values alone, there are only n; if it means distinct substring contents, the answer depends on the string. The standard occurrence interpretation is explicitly used.
Which is false: n-node trees have n−1 edges; preorder plus postorder uniquely determine a labelled binary tree; full binary trees have leaves=internal+1; maximum nodes at edge-height h is 2^(h+1)−1?
Your answer
Answer & solution
Answer: B under the full-tree interpretation of complete (no official key was published)
Take a root r with only one child c. Making c the left child or the right child gives the same preorder r, c and postorder c, r, so uniqueness fails: B. A connected acyclic n-node graph has n−1 edges. A full binary tree satisfies 2I=I+L−1, hence L=I+1. Summing complete levels 0 through h gives 2h+1−1. The source says “complete” for the leaf formula; modern heap-complete trees may have a one-child node, invalidating that formula. Under that terminology C can fail too, so the intended full/proper definition is a qualification.
Similar questions1 more → · asked again: GATE 1993, Q7.7
Resident loading support
Processes, Threads & System Calls
Tap to enlarge
In a resident-OS model, which software must remain available in main memory: assembler, linker, loader, compiler?
Your answer
Answer & solution
Answer: C in the traditional resident-loader model (no official key was published)
A loader brings executable code into memory and prepares it for execution. In the traditional resident monitor model, this loading support must remain available to bring in subsequent programs, motivating C. Assemblers, linkers and compilers can be ordinary separately loaded programs and need not be continuously resident. The universal wording is model-dependent: modern systems can page portions of loading software or use firmware and other mechanisms. The answer identifies the conventional resident component, not a theorem about all possible OS designs.
Which is true about SLR, LALR, canonical LR power? C says canonical LR is more powerful than LALR.
Your answer
Answer & solution
Answer: C (no official key was published)
Canonical LR(1) retains separate lookahead contexts. LALR merges LR states with identical LR(0) cores; this can introduce reduce/reduce conflicts that did not exist before merging. SLR uses the still coarser FOLLOW-set reduction rule. Therefore the recognizable grammar classes satisfy SLR⊆LALR⊆canonical LR, with proper inclusions in general, giving C. This compares conflict-free grammar handling, not table compactness or parsing speed.
Choose lexical analysis, syntax analysis, syntax-directed translation, or code optimization as the normal type-checking mechanism.
Your answer
Answer & solution
Answer: C (no official key was published)
Lexical analysis identifies tokens, and parsing checks grammatical structure. Type checking instead propagates and compares semantic attributes: for example, an addition node checks operand types and computes the result type. Syntax-directed definitions or translation rules attach exactly these operations to grammar productions, making C the appropriate option. Optimization can use type information but is not the normal first stage responsible for establishing semantic type compatibility.
Modules of lengths 200, 800, 600, 500 words are loaded consecutively in that order from zero. Find their relocation constants.
Your answer
Answer & solution
Answer: B: 0, 200, 1000, 1600 (no official key was published)
The first module starts at 0. The next starts after its 200 words, at 200. The third begins after 200+800=1000 words, and the fourth after 200+800+600=1600. These starting addresses are the relocation constants for modules assembled relative to zero. Thus B. The final 500-word length determines the image’s end, not an additional start. A nonzero loading base would add the same base to all four constants.
Similar questions2 more → · asked again: GATE 1992, Q2(xii)
A spooled device
I/O & Disk Scheduling
Tap to enlarge
Which is a spooled device: interactive input terminal, printer serving multiple jobs, virtual-memory backing storage, or swap area?
Your answer
Answer & solution
Answer: B (no official key was published)
Spooling first records output in a queue, usually on disk, and a service process feeds one job at a time to a device. A printer shared by many jobs is the standard example, B: jobs can finish producing output without holding the printer throughout. Paging and swapping also use disk, but their purpose is memory management rather than queued job output. Interactive terminal input is not the listed spooling example.
What is a computation whose result depends on relative process speeds called: cycle stealing, race condition, time lock, deadlock?
Your answer
Answer & solution
Answer: B (no official key was published)
A race condition occurs when competing execution orders affect the result of shared operations. For example, two processes that each read, increment and write a counter may overwrite one another’s update depending on timing. Synchronization is needed when the intended result must not depend on such an interleaving. This is B. Deadlock instead means processes cannot make progress, while cycle stealing describes bus access by a device.
Similar questions1 more → · asked again: GATE 1992, Q2(x)
Net semaphore updates
Synchronization & Concurrency
Tap to enlarge
A counting semaphore starts at 10. Six completed P(wait) and four completed V(signal) operations occur. Find the final value among 0, 8, 10, 12.
Your answer
Answer & solution
Answer: B: 8 (no official key was published)
Each completed wait consumes one available unit, decreasing the count by 1. Each signal adds one unit. Thus the net change is−6+4=−2, and the final count is 10−2=8. Because all six waits are stated to complete and the initial count is sufficient even before signals, no blocking ambiguity affects this arithmetic. Hence B; counting only the signals would incorrectly increase the initial value.
Similar questions7 more → · asked again: GATE 1992, Q2(xi)
Deadlock-free tape-drive bound
Deadlocks
Tap to enlarge
Six identical tape drives are shared by n processes, each needing at most two. Find the largest n guaranteeing no resource deadlock among 6, 5, 4, 3.
Your answer
Answer & solution
Answer: B: 5 under unrestricted incremental allocation (no official key was published)
The dangerous state gives each process one drive while it waits for a second. With n≤5, at least one of six drives remains free, so some waiting process can receive its second, finish and release both; repeat to complete others. With n=6, all six can hold one and wait forever for a second, producing deadlock. Therefore the largest guaranteed-safe n is 5, B. This is a worst-case allocation guarantee, assuming eventual release and no other resources; an avoidance policy could safely serialize more processes.
For union-compatible R1(A, B), R2(C, D), interpret R1 join on A=C and B=D R2. Choices include union, product, difference, intersection.
Your answer
Answer & solution
Answer: D after projecting duplicate columns; raw theta join has four attributes (no official key was published)
A qualifying pair contains the same two values in both input relations. Thus each output is (a, b, a, b), one for each common tuple (a, b). Projecting onto A, B gives the intersection R1∩R2 after renaming, explaining D. But an ordinary theta join retains all four attributes A, B, C, D, whereas intersection has only two. They are not literally equal schemas without projection or a duplicate-column-eliminating join convention. This arity distinction is recorded rather than silently identifying the raw four-column relation with the two-column intersection.
Which normal form is conventionally adequate for ordinary relational design:2NF, 5NF, 4NF, 3NF?
Your answer
Answer & solution
Answer: D (no official key was published)
Third normal form addresses dependencies of nonkey attributes that produce common update anomalies while permitting dependency-preserving, lossless decompositions. It is therefore the conventional general design target among these choices, D. Second normal form only removes partial dependence on composite keys and can leave transitive problems. Fourth and fifth normal forms address additional multivalued or join dependencies and may be necessary for particular schemas, but are not implied as the routine minimum by the question.
Records 1–5 are Rama 27CON A, Abdul 22ENG A, Jennifer 28DOC B, Maya 32SER D, Dav 24MUS C. Index pointers are 1, 3, 2, 5, 4. Which field is sorted?
Your answer
Answer & solution
Answer: C: occupation (no official key was published)
Read occupations in pointer order: CON, DOC, ENG, MUS, SER. They are alphabetically increasing, so the index is on occupation. Ages in that order are 27, 28, 22, 24, 32 and are not sorted. Names start Rama, Jennifer, Abdul and likewise are not alphabetical; categories are A, B, A, C, D, also not ordered. Thus C is the matching field. The pointer sequence denotes record positions, not the index-key values themselves.
The fourth row is three times the first, so rank is at most 3. To show the remaining rows are independent, take their minor using the first three columns. Expansion along the second row gives determinant−3·det[[1, 4], [4, 2]]=−3·(2−16)=42, which is nonzero. Thus rank is at least 3. Combining the bounds proves rank 3, option A. A zero full determinant alone would only show rank below 4, not determine its exact value.
For determinant with rows (1, a, bc), (1, b, ca), (1, c, ab), choose a factor from a+b, a−b, a+b+c, abc.
Your answer
Answer & solution
Answer: B: a−b (no official key was published)
Set a=b. Then the first two rows become identical, so the determinant vanishes identically as a polynomial in the remaining variables. By the polynomial factor theorem, a−b divides it. More explicitly, subtract the first row from the other two and factor (b−a) and (c−a); the remaining 2×2 determinant is c−b, giving (b−a)(c−a)(c−b). This confirms the requested factor B. The argument does not require dividing by a possibly zero variable.
Answer: B: neither reflexive nor irreflexive, but transitive (no official key was published)
Reflexivity fails because (4, 4) is absent. Irreflexivity fails because (1, 1), (2, 2), (3, 3) are present. For transitivity, if the first element is 1, its only successor is 1, so any composition stays at (1, 1). Elements 2 and 3 already relate to every possible target, so any composable second step remains in R. Element 4 has no outgoing pair and creates no requirement. Hence R is transitive, giving B. It is neither symmetric nor antisymmetric: (2, 1) lacks its reverse while (2, 3), (3, 2) are both present.
In a room of 28, English 18, Hindi 15, Kannada 22; overlaps English–Hindi=9, Hindi–Kannada=11, Kannada–English=13. How many speak all three? Options 9, 8, 7, 6.
Your answer
Answer & solution
Answer: D: 6 if everyone speaks at least one; literal data allow 5 or 6 (no official key was published)
Let t be the triple overlap. Inclusion–exclusion gives union size 18+15+22−9−11−13+t=22+t. If all 28 people belong to at least one language group, t=6, option D. But that premise is not explicit. Nonnegative Hindi-only count gives 15−9−11+t=t−5≥0, while union≤28 gives t≤6. Thus integer t may be 5 or 6; t=5 leaves one person speaking none and has nonnegative counts in all seven regions. The textbook result 6 therefore relies on coverage, not solely on the stated headcount.
Over{0, 1}, accept exactly words whose last two symbols are equal. Find minimum states among 2, 5, 8, 3.
Your answer
Answer & solution
Answer: B: 5 (no official key was published)
Step through it (2 parts)
Use five states: start S; nonaccepting q0 for a last 0 without an equal final pair; nonaccepting q1 analogously; accepting a 0 for suffix 00; accepting a 1 for suffix 11. On0, S→q0, q0/a 0→a 0, q1/a 1→q0. On1 use the symmetric transitions. To prove minimality, accepting versus nonaccepting states differ on ε. a 0 and a 1 differ on suffix 0; q0 and q1 differ on 0; S differs from q0 on 0 and from q1 on 1. All five are reachable, so no merging is possible. Therefore B.
Which is false: finite subsets of nonregular languages are regular; every subset of a regular language is regular; finite subsets of regular languages are regular; intersection preserves regularity?
Your answer
Answer & solution
Answer: B (no official key was published)
Every finite language is regular: form a finite union of its individual words. Thus A and C hold regardless of the larger language. Regular languages are closed under intersection using a product DFA, so D holds. But the regular language{0, 1}* contains the nonregular subset{0n1n:n≥0}. Hence arbitrary subsets need not be regular, disproving B. Finite-subset closure must not be extrapolated to unrestricted infinite subsets.
The map has rows A=0, 1 and columns BC=00, 01, 10, 11. Both rows are 1, 0, 0, 1. Find its function; C is complement (B XOR C).
Your answer
Answer & solution
Answer: C: XNOR of B, C (no official key was published)
The identical rows show that A is irrelevant. The output is 1 exactly for BC=00 or 11, meaning B and C agree. Therefore F=B′C′+BC=¬(B⊕C), option C. The displayed columns are binary order 00, 01, 10, 11 rather than Gray order; treating adjacent columns as automatically differing in one bit would be invalid. Reading the labels as a truth table avoids that trap and gives the result directly. Its altered map is B′C′+BC+A′C, which is not any displayed option. The C answer follows the the paper map, not a claim that the paper agrees.
Similar questions3 more → · asked again: GATE 1992, Q2(i)
Commutative but nonassociative operator
Boolean Algebra & Logic Gates
Tap to enlarge
Which is commutative but not associative: AND, OR, NAND, XOR?
Your answer
Answer & solution
Answer: C (no official key was published)
NAND is symmetric in its arguments because ¬(ab)=¬(ba), so it is commutative. To test associativity, take a=0, b=1, c=1. Then (0 NAND 1) NAND 1=1 NAND 1=0, while 0 NAND(1 NAND 1)=0 NAND 0=1. The two groupings differ, proving nonassociativity. AND, OR and XOR are associative as well as commutative. Thus C; a single counterexample is enough to refute an asserted universal associative law.
Does floppy formatting arrange user data contiguously, write only a directory, erase the system area, or write track/sector identification?
Your answer
Answer & solution
Answer: D (no official key was published)
Low-level formatting establishes the physical organization used to locate sectors, including identification and control information on tracks and sectors. This is D. Writing a file-system directory is a higher-level formatting step, and arranging existing files contiguously is closer to allocation or defragmentation. Erasing only a system area does not establish a usable sector layout. The question uses the older physical-floppy meaning; modern operating-system “format” commands often refer to file-system initialization instead.
The 8086 produces 20-bit physical addresses. Therefore it can address 220 distinct byte locations, which is 1, 048, 576 bytes, conventionally called 1 MB in this historical context. This gives A. Its 16-bit offset does not by itself limit the whole physical address space to 64 KB because segmentation combines a segment value and an offset. Individual segment addressing and total physical reach are different quantities.
Every node has either 0 or n children. If x nodes are internal, how many leaves are there?
Your answer
Answer & solution
Answer: A: x (n−1)+1 (no official key was published)
Each internal node contributes exactly n child edges, so the tree has nx edges. If it has L leaves, its total vertices are x+L, and any tree has one fewer edge than vertices: nx=x+L−1. Rearranging yields L=x (n−1)+1, A. The explicit 0-or-n condition is essential; it prevents one-child or partially populated internal nodes from invalidating the count. For x=0 it correctly gives a single root leaf.
F(x)=x−10 for x>100, otherwise F(F(x+11)). Evaluate F(95) among 89, 90, 91, 92.
Your answer
Answer & solution
Answer: C: 91 (no official key was published)
Step through it (21 steps)
First F(100)=F(F(111))=F(101)=91. For x from 95 through 99, x+11 exceeds 100, so F(x+11)=x+1. Hence F(x)=F(x+1) for these five inputs. Chaining gives F(95)=F(96)=…=F(100)=91. Thus C. This local calculation proves the requested value without assuming the more general McCarthy 91 theorem for every input.
In Pascal-like code, f (var x) increments x and returns it. Starting x=5, result=f (x)*f (x). Options 5, 25, 36, 42.
Your answer
Answer & solution
Answer: D: 42 under sequential call evaluation (no official key was published)
The var parameter aliases the caller’s x, so the first completed call changes 5 to 6 and returns 6. The second then changes 6 to 7 and returns 7. Multiplication gives 6·7=42. Choosing the opposite operand first merely swaps these two returned values, leaving the product unchanged. Thus D in the ordinary sequential procedural evaluation model. This is not pass-by-value, which would give 6·6=36. The explanation does not import C’s unsequenced-expression rules into the displayed Pascal-like language.
A[1…10][1…15] is stored in row-major order, uses one memory location per integer, and A[1][1] is at 100. Find address A[i][j].
Your answer
Answer & solution
Answer: A: 15i+j+84 (no official key was published)
Before row i there are i−1 complete rows, each containing 15 entries, contributing 15(i−1) locations. Within row i, column j is j−1 locations beyond its start. Add the base:100+15(i−1)+(j−1)=15i+j+84. This is A. Check i=j=1 gives 100, and increasing j by 1 advances one location, whereas increasing i by 1 advances fifteen. Those checks distinguish row-major from column-major formulas.
An array of pointers to activation records used to speed nonlocal variable access is called stack, heap, display, or activation tree?
Your answer
Answer & solution
Answer: C (no official key was published)
A display stores the current activation-record pointer for each lexical nesting level. A nonlocal variable’s declaration level and fixed offset then identify its address through one indexed display lookup plus the offset. This avoids following a chain of static links through multiple records. The structure is called a display, C. A stack stores records themselves, a heap supports general dynamic allocation, and an activation tree describes call relationships rather than this direct-access table.
Overlay tree: root 2 KB; children A 4, B6, C8; A has D6, E8; B has F2; C has G4. Minimum partition size among 12, 14, 10, 8 KB?
Your answer
Answer & solution
Answer: B: 14 KB (no official key was published)
Only one sibling overlay branch needs to coexist at a time, but a descendant must coexist with its ancestors. Compute root-to-leaf sums: root-A-D=2+4+6=12; root-A-E=2+4+8=14; root-B-F=2+6+2=10; root-C-G=2+8+4=14 KB. The largest is 14 KB, so B. Summing every module would ignore overlay sharing; allocating only the largest individual module would omit resident ancestors. Module sizes were cross-checked in the clearer alternate diagram.
n processes share CPU; switches cost s seconds and quantum is q. Minimize overhead while each process gets a turn at least every t seconds. Options use q≤or≥(t−ns)/(n−1) or denominators n+1.
Your answer
Answer & solution
Answer: A for maximum off-CPU waiting; start-to-start wording differs (no official key was published)
After a process’s quantum ends, n−1 other quanta occur before it runs again. Including the n intervening switches gives waiting time (n−1)q+ns. Requiring this≤t yields q≤(t−ns)/(n−1), A, for n>1 and feasible t>ns. Switching overhead fraction decreases as q grows, so choose equality to minimize it within that constraint. If “every t seconds” instead measures successive start times, the interval includes the process’s own quantum: n (q+s)≤t, giving q≤t/n−s. The listed answer assumes off-CPU waiting, not literal start-to-start spacing.
An instruction takes i microseconds; one page fault per k instructions adds j microseconds. Find effective instruction time.
Your answer
Answer & solution
Answer: A: i+j/k (no official key was published)
Over k instructions, ordinary execution costs ki microseconds. The average one fault adds j, so the total for that block is ki+j. Divide by k to obtain i+j/k per instruction, option A. The word additional matters: the base instruction cost is already counted and must not be divided away or counted twice. This is an average-cost calculation and does not require faults to occur at perfectly periodic positions.
Which rewrite is not generally valid? A commuting selections; B moving a well-defined selection before projection; C distributing selection over union; D moving selection after projection without retaining predicate attributes.
Your answer
Answer & solution
Answer: D (no official key was published)
Selections commute because both predicates must hold, and selection distributes over union tuple by tuple. If selection after projection is already well typed, all predicate attributes survived, so pushing it down is safe. In the reverse direction, projecting first may delete an attribute needed by the predicate. For R(A, B), πA(σB=1(R)) is defined, but σB=1(πA(R)) is not. Thus D is not an unrestricted rule. Enlarged the paper B shows its right outer operator as σ with attribute subscript A 1 rather than a projection π, another literal typing defect; the coherent projection rule analyzed above is an explicitly stated reconstruction, not a silent transcription.
Signed four-digit values are stored as character strings or integers. Choose reduction 80%, 20%, 60%, 40%.
Your answer
Answer & solution
Answer: C: 60% under 5-byte text and 16-bit integer conventions (no official key was published)
A sign plus four decimal characters uses 5 bytes with one byte per character. Values from−9999 to 9999 fit in a 16-bit signed integer, using 2 bytes. The saving is 5−2=3 bytes, or 3/5·100%=60%, C. This assumes a fixed sign character and no text terminator or length metadata. A 32-bit integer would save only 20% under the same text layout, while other encodings change the comparison. Therefore the supplied result depends on the conventional storage widths rather than the numeric domain alone.
Two friends arrive between 4 and 5 p.m. Each waits ten minutes or until 5 p.m., whichever comes first. Find the probability they do not meet.
Answer & solution
Answer: 25/36, assuming independent uniform arrival times. (no official key was published)
Let X and Y be their arrival times in minutes after 4 p.m. The usual intended probability model is that X and Y are independent and uniformly distributed on [0,60]. The problem does not explicitly supply this distribution; a numerical probability requires it.
They meet precisely when |X−Y|≤10, apart from a zero-probability issue about departure at the exact arrival instant. Truncating the wait at 5 p.m. does not change this condition: both people arrive by then, so the earlier arrival must still be present if the gap is at most ten minutes.
All pairs (X,Y) are equally likely in a 60-by-60 square of area 3600. Failure to meet is the union of the regions Y>X+10 and X>Y+10. Each is a right triangle with legs 50 and area 50²/2. Hence P(no meeting)=2(50²/2)/60²=2500/3600=25/36. As a check, the complementary meeting probability is 11/36. The answer is not 5/6: that treats one person's ten-minute window as if it were the whole two-dimensional event. Nonuniform or correlated arrivals can give a different answer.
Give a regular expression for binary strings in which every 0 is immediately followed by exactly k consecutive 1s and preceded by at least k consecutive 1s, for fixed nonnegative integer k.
Answer & solution
Answer: 1* ∪ 1^k 1* 0 1^k (0 1^k)*. (no official key was published)
Interpret “exactly k” as the length of the entire run of consecutive 1s immediately after a 0. Write 1k for k copies of the symbol 1, not a variable exponent inside the regex. One expression is
1* ∪ 1k 1* 0 1k (0 1k)*.
The first branch handles strings with no zeros, including ε. Their condition is vacuously true; they must not be discarded merely because they contain fewer than k ones. In the second branch, the initial run 1k1* has at least k ones, so the first zero has the required predecessor run. Every zero then contributes the block 01k. Repeating that block gives exactly k ones between consecutive zeros, simultaneously satisfying the preceding and following requirements. The last zero is also followed by exactly k ones, with no extra trailing ones.
Conversely, any valid string containing a zero has an initial run of at least k ones. After its first zero, each run of ones has length exactly k, until the string ends or the next zero begins. It therefore has the displayed form. For k=2, 11011 and 111011011 are accepted, whereas 1011 lacks enough leading ones and 110111 has too many final ones. For k=0 the formula reduces to 1*0*: no one may occur after the first zero. If “followed by k ones” meant at least k rather than exactly k, a different language would result.
Design a minimum-state DFA for binary strings whose numeric value, ignoring leading zeros, is divisible by five.
Answer & solution
Answer: Five remainder states if ε represents 0; six if an empty representation is excluded. (no official key was published)
Maintain the remainder r of the binary prefix modulo 5. Appending bit b changes a value v into 2v+b, so the transition is δ(qr,b)=q_((2r+b) mod 5). The start and sole accepting state is q0, using the conventional value 0 for ε.
This transition table fully specifies the DFA. Leading zeros loop at q0, and zero is divisible by five. Induction on prefix length proves the invariant that state qr means the prefix value is congruent to r. Consequently the final state is accepting exactly for multiples of five.
For minimality, all five states are reachable: ε, 1, 10, 11 and 100 reach q0 through q4. Given distinct remainders r and s, choose v in {0,1,2,3,4} with 8r+v≡0 mod 5 and append its three-bit binary representation, including leading zeros. From qr the result is accepting. From qs its remainder differs by 8(s−r), which is nonzero modulo 5 because 8 is invertible modulo 5. Thus every pair is distinguishable, establishing a five-state lower bound.
The source says strings in {0,1}* but does not define the value of ε. If a binary numeral must contain at least one symbol, add a new nonaccepting start state s with 0→q0 and 1→q1. It is distinct from q0 by ε and from every other remainder state by the suffix argument, so this alternative language needs six states. The five-state answer uses the explicitly stated conventional interpretation.
For I(x,y)=¬x∨y, realize f=¬x·y+x·¬y using implication gates. Both the GFG and GateForum reproductions explicitly require four implication gates. Neither reproduction explicitly provides a constant-zero input.
Answer & solution
Answer: With constant 0: p=I(x,y), q=I(y,x), r=I(q,0), f=I(p,r). Without 0, impossible. (no official key was published)
The requested function is XOR. A four-gate construction satisfies that requirement if one input can be tied to Boolean 0:
G1: p = I(x,y) G2: q = I(y,x) G3: r = I(q,0) G4: f = I(p,r)
Wire x and y to G1 in that order and to G2 in the opposite order. Connect G2's output and a grounded input to G3. Connect G1's output and G3's output to G4, in that order. This netlist is an unambiguous gate-level schematic with fan-out allowed.
Since p=¬x∨y and q=¬y∨x, r=¬q. Therefore f=¬p∨r=¬(¬x∨y)∨¬(¬y∨x)=x¬y∨y¬x, as required. The truth table provides a direct check:
x y | p q r | f 0 0 | 1 1 0 | 0 0 1 | 1 0 1 | 1 1 0 | 0 1 0 | 1 1 1 | 1 1 0 | 0
The grounded input is essential, not an unmentioned extra implication gate. Without constant 0 or another non-1-preserving primitive, no finite acyclic circuit of implication gates can realize XOR. On x=y=1, every primary input is 1; every gate whose inputs are 1 outputs I(1,1)=1. Induction through the circuit makes its final output 1, contradicting XOR(1,1)=0. A constant 1 does not fix this problem. Thus the bare statement is impossible, while the conventional hardware interpretation allowing a ground connection admits the four-gate design above.
Show that the implication gate I(x,y)=¬x∨y is functionally complete. State any necessary extra resource.
Answer & solution
Answer: Implication alone is not complete; {implication,0} is complete. (no official key was published)
Taken literally, the claim is false. Implication preserves the Boolean value 1: I(1,1)=1. Any formula built from variables using only implication consequently outputs 1 when all its variables are 1, by structural induction. Such formulas cannot implement NOT, which sends 1 to 0, or the constant-zero function. Since functional completeness requires every Boolean function, implication alone fails. Producing constant 1 as I(x,x) does not remove this obstruction.
If a Boolean-zero input is supplied, completeness follows constructively. First implement NOT by ¬x=I(x,0). Then implement OR by x∨y=I(I(x,0),y). NOT and OR form a complete basis: for example x∧y=¬(¬x∨¬y), and any Boolean truth table can be expressed as a disjunction of conjunctions of literals. Therefore arbitrary Boolean functions can be realized using implication gates and the constant 0.
An equally direct complete primitive is NAND: I(x,I(y,0))=¬x∨¬y=¬(x∧y). Because NAND is functionally complete, this two-implication construction proves the same result. These are proofs of completeness of {I,0}, not of {I} alone. Both printed papers omit an explicit constant-zero assumption, so the necessary qualification must be retained rather than supplying a false proof of the literal claim.
Answer: x_n=2^(n−1)+1. (no official key was published)
The constant fixed point of the recurrence is 1, because 1=2·1−1. Subtract it by setting yn=xn−1. Then yn=2x_(n−1)−2=2y_(n−1), while y1=1. Iterating the resulting geometric recurrence gives yn=2n−1, so xn=2n−1+1 for all n≥1.
To verify rather than merely guess the formula, its first value is 20+1=2. Assuming xn−1=2n−2+1, substitution gives 2[2n−2+1]−1=2n−1+1, completing induction. Initial values 2,3,5,9,17 agree. The exponent is n−1 rather than n because the specified initial index is 1. The subtraction trick is useful for affine recurrences generally: shift by a fixed point to expose the homogeneous geometric part.
For S→Aa|b and A→Ac|Sd|ε, construct an equivalent grammar with no left recursion and the minimum number of productions. Count each alternative as a production.
Answer & solution
Answer: A valid six-alternative grammar is S→Ta|bdTa|b; T→cT|adT|ε. Global minimum among arbitrary CFGs is not certified. (no official key was published)
Substitute S→Aa|b into the occurrence S in A→Sd. Then A→Ac|Aad|bd|ε. Each recursive use appends either c or ad on the right; the base is either bd or ε. Thus L(A)=(ε∪{bd}){c,ad}*, and
L(S)={b} ∪ (ε∪{bd}){c,ad}*{a}.
Introduce T generating {c,ad}*. The following equivalent grammar has six individual alternatives:
S → Ta | bdTa | b T → cT | adT | ε
Every recursive T production starts with a terminal, so it cannot be left recursive. S is not reachable from T, and although S→Ta starts with a nonterminal, its nullable prefix cannot lead back to S. This also rules out indirect left recursion. The first two S alternatives select the two possible prefixes before a word from {c,ad}* and its final a; the third supplies the isolated word b. Conversely, each original derivation has exactly one of these forms, proving language equivalence.
For comparison, the usual mechanical elimination gives S→Aa|b, A→bdT|T, T→cT|adT|ε, with seven alternatives. Inlining A into S removes its two rules and replaces one S alternative by two, saving one production. The six-rule grammar is therefore smaller than that routine result.
The printed requirement “minimum number” needs care. This construction establishes an upper bound of six. It is not a proof that no differently structured, arbitrary CFG can use fewer alternatives. Counting a line with several bars as one “rule” would also give a different metric. The requested global minimum is left uncertified rather than asserted without a lower-bound proof; the equivalent non-left-recursive grammar itself is fully established.
Given FREQUENTS(student,parlor), SERVES(parlor,ice_cream), and LIKES(student,ice_cream), print students who frequent at least one parlor serving at least one ice cream they like. Each student likes an ice cream and frequents a parlor.
Answer & solution
Answer: Join FREQUENTS to SERVES by parlor and LIKES by both student and ice cream; select distinct students. (no official key was published)
A qualifying student needs one witness consisting of a frequented parlor and a flavor both served there and liked by that same student. Match those three facts with a join:
SELECT DISTINCT f.student
FROM FREQUENTS AS f
JOIN SERVES AS s
ON s.parlor = f.parlor
JOIN LIKES AS l
ON l.student = f.student
AND l.ice_cream = s.ice_cream;
The schema spells the attribute as “ice-cream”; ice_cream above is a SQL-friendly identifier for that same field. If the actual schema uses a hyphen, use the database's identifier quoting, for example l."ice-cream" in standard SQL. The query assumes the ordinary relational model with non-NULL identifying values.
The first join enumerates flavors served at every parlor a student frequents. The second retains only flavors liked by that student. Both equalities in the second join matter: omitting the student equality would incorrectly let somebody else's preference qualify the student. DISTINCT prints each qualifying student once even if several parlors or flavors witness qualification.
For example, if Ada frequents P, P serves vanilla, and Ada likes vanilla, the triple survives. If Bob also frequents P but only likes chocolate, Bob does not survive unless P serves chocolate as well. The request is existential, so it needs neither relational division nor a test that every frequented parlor serves every liked flavor. The assumptions that students have some likes and visits do not by themselves imply qualification.
Fixed partition sizes are 4,8,20,2 KB. Jobs in order have (size KB, execution time): (2,4),(14,10),(3,2),(6,1),(6,4),(10,1),(20,8),(2,6). With best-fit allocation, when does the 20 KB job finish?
Answer & solution
Answer: At time 19 under listed-order, nonpreemptive fixed-partition scheduling. (no official key was published)
Assume all jobs are available at time 0, listed order resolves admission priority, partitions are fixed and not split, runtimes are elapsed times while resident, and loading/switching costs are zero. Best fit places an admitted job in the smallest currently free partition that accommodates it. Call the listed jobs J1 through J8.
At time 0, J1 occupies 2 KB until t=4, J2 occupies 20 KB until t=10, J3 occupies 4 KB until t=2, and J4 occupies 8 KB until t=1. J5, J6 and J7 cannot yet fit. At t=1, J4 finishes and J5 enters the 8 KB partition for four units, finishing at t=5.
The critical resource is the 20 KB partition. J6 needs 10 KB, so it cannot use the 4,8 or 2 KB partitions. J7 needs the entire 20 KB partition. At t=10, J2 releases it. Listed-order priority admits J6 first for one unit, t=10 to 11. Then J7 runs for eight units, t=11 to 19. Thus the requested completion time is 10+1+8=19.
J8 may enter a smaller partition earlier if the allocator bypasses blocked jobs, or later under strict head-of-line waiting; this does not change the listed-order use of the 20 KB partition. Best fit alone specifies a partition choice, not a scheduling discipline or arrival times. If arbitrary priority allowed J7 ahead of J6 at t=10, it would finish at 18. Therefore 19 is the conventional answer with the stated order assumptions, not a consequence of the phrase “best fit” alone.
Find local maxima and minima on 0≤x≤6 for f(x)=x³−6x²+9x+C. GFG prints C=−15; GateForum prints C=+15.
Answer & solution
Answer: Interior maximum at x=1 and minimum at x=3. Values are C+4 and C; endpoints are one-sided local extrema relative to [0,6]. (no official key was published)
Keep the disputed constant as C. Since differentiation removes it, the paper have identical stationary positions: f′(x)=3x²−12x+9=3(x−1)(x−3). Hence f′=0 at x=1 and x=3. The second derivative f″(x)=6x−12 is negative at 1 and positive at 3, so the interior local maximum is (1,C+4) and the interior local minimum is (3,C).
The derivative signs give the complete explanation: f increases on (0,1), decreases on (1,3), and increases on (3,6). Thus these are genuine turning points, not just horizontal tangencies. With the paper's constant −15, they are (1,−11) and (3,−15). The disagreement shifts the whole graph vertically by 30 and does not change its shape.
Because the stated domain is closed, endpoints deserve explicit treatment. Under the relative-domain definition of a local extremum, x=0 is a one-sided local minimum and x=6 a one-sided local maximum. Their values are f(0)=C and f(6)=C+54. Under the classroom convention that “local extrema” refers only to interior stationary points, report just x=1 and x=3, while still recording the endpoint behavior.
For global extrema on the closed interval, compare all four candidates: values C, C+4, C, C+54 at x=0,1,3,6. The global minimum C occurs at both 0 and 3, and the global maximum C+54 occurs at 6. This endpoint check prevents incorrectly treating the interior local maximum as the absolute maximum.
Evaluate the definite integral of x cos x from −π to π.
Answer & solution
Answer: 0. (no official key was published)
Let g(x)=x cos x. Since cosine is even, g(−x)=−x cos(−x)=−x cos x=−g(x), so g is odd. Its integral over the symmetric interval [−π,π] therefore cancels pairwise and equals zero.
Integration by parts provides an independent derivation. Take u=x and dv=cos x dx, giving du=dx and v=sin x. Then ∫x cos x dx=x sin x−∫sin x dx=x sin x+cos x+C. At π this antiderivative has value π·0+(−1)=−1; at −π it has value (−π)·0+(−1)=−1. Subtracting lower from upper again gives 0.
The printed bounds are −π and π, not an indefinite integral or the interval [0,π]. On [0,π] the value would be −2. The sign and symmetry of the lower bound are consequently essential to the result.
Derive the number of operations to solve n linear equations in n unknowns by Gaussian elimination, counting one multiplication followed by an addition as one operation.
Answer & solution
Answer: n(n−1)(2n+5)/6 paired multiply-add operations including RHS updates and back substitution; leading term n³/3. (no official key was published)
Assume a dense nonsingular system Ax=b, successful pivots, ordinary forward elimination followed by back substitution, and no work saved by special structure. Count an update u←u−m·v as one multiplication-addition pair. Divisions and pivot search/comparison are separate because the question's paired-operation definition does not explicitly include them.
At pivot k, for k=1,...,n−1, there are n−k rows below the pivot. Each needs n−k updates to its remaining coefficient entries and one update to its right-hand-side value. Thus this stage uses (n−k)(n−k+1) paired operations. Summing with j=n−k gives
In back substitution, solving row i subtracts the contributions from the n−i already known variables. This contributes B=Σ_(i=1)n(n−i)=n(n−1)/2 paired updates. Consequently
E+B=n(n−1)(2n+5)/6
= n³/3+n²/2−5n/6.
For n=2 there are two elimination updates, one to the remaining coefficient and one to the right-hand side, followed by one back-substitution update: three in total, matching the formula. For n=1 there are no such pairs, although one division is still necessary.
The elimination multipliers require n(n−1)/2 divisions, and back substitution requires n more, totaling n(n+1)/2 divisions. If a convention counts each division as one extra operation, the combined count becomes (n³+3n²−n)/3. If only the coefficient-matrix elimination is requested, its pair count is Σj² rather than the full solve count. Actual floating-point operation counts often count multiplication and addition separately, producing leading cost 2n³/3. Under the printed paired-operation convention, the leading cost is n³/3, with the exact lower-order terms dependent on which phases and divisions are included.
Prove by induction that an n-sided polygon has n(n−3)/2 diagonals.
Answer & solution
Answer: D_n=n(n−3)/2 for n≥3. (no official key was published)
A diagonal joins two nonadjacent vertices; count all such vertex pairs, regardless of where segments lie for a nonconvex polygon. Let Dn be their number. A triangle has no diagonals, and 3(3−3)/2=0, establishing the base case.
Assume Dn=n(n−3)/2 for an n-gon. Insert a new vertex v between two formerly adjacent vertices u and w, replacing the boundary edge uw by the two boundary edges uv and vw. All old diagonals remain diagonals. The former edge uw becomes one additional diagonal. The new vertex v can be joined by diagonals to the n−2 old vertices other than its two neighbors u and w. Thus the increase is 1+(n−2)=n−1, not merely n−2.
Therefore Dn+1=Dn+n−1=n(n−3)/2+n−1=(n²−n−2)/2=(n+1)(n−2)/2. This is the required formula with n replaced by n+1, completing induction.
As a consistency check, choosing any pair of vertices gives n(n−1)/2 segments; subtract the n boundary edges to obtain n(n−3)/2. For n=4 the count is 2 and for n=5 it is 5, agreeing with the recurrence. The insertion argument's old-edge contribution is the usual subtle point in this induction.
R consists of directed cycles a→b→c→a and d→e→f→g→h→d. Find the smallest integers m<n with R^m=R^n.
Answer & solution
Answer: For positive powers: m=1,n=16. If R^0 is allowed: m=0,n=15. (no official key was published)
Each vertex has exactly one outgoing edge, so R is a permutation: a 3-cycle and a disjoint 5-cycle. Rt sends each vertex t positions forward around its component, because composition corresponds to a path of length t.
On the 3-cycle, Rm and Rn agree exactly when n−m is divisible by 3. On the 5-cycle, they agree exactly when n−m is divisible by 5. Both requirements hold precisely when 15=lcm(3,5) divides n−m. Necessity follows by inspecting even one vertex in each component; sufficiency follows because a multiple of a cycle's length returns every vertex to its starting position.
Thus R15 is the identity relation on the eight vertices, and R16=R. If powers are numbered from 1, the smallest first exponent is m=1 and the smallest later matching exponent is n=16. If the standard zeroth power R0=I is permitted, the earliest pair is instead (0,15). The printed wording says “integers” without explicitly restricting them to positive powers, so both conventions must be disclosed.
If one extends this permutation relation to negative powers and allows all integers, there is no smallest pair: (m,m+15) works for arbitrarily negative m. Ordinary relation-power questions use nonnegative or positive exponents.
It is incorrect to use 3+5=8 as the period: both components must return simultaneously, which requires a common multiple rather than a sum. Neither cycle contains a self-loop, and there are no cross-component edges; adding either would change the relation being analyzed.
For A={a,b,c,d} and partition Π1={{a,b,c},{d}}, list the induced equivalence relation.
Answer & solution
Answer: {(a,a),(a,b),(a,c),(b,a),(b,b),(b,c),(c,a),(c,b),(c,c),(d,d)}. (no official key was published)
The equivalence relation induced by a partition relates x to y exactly when they belong to the same block. Therefore take the Cartesian square of each block and unite the results:
There are 3²+1²=10 ordered pairs. In particular, (a,b) and (b,a) are different pairs and both must appear. The isolated singleton block still contributes (d,d); reflexivity does not disappear for a singleton. No pair with one endpoint d and the other in {a,b,c} is present, because that would merge the two equivalence classes.
Reflexivity follows because each element shares its block with itself. Symmetry follows because “in the same block” is symmetric. Transitivity follows because if x shares a block with y and y shares a block with z, disjointness of partition blocks forces all three into that one block. Thus the listed relation indeed has exactly the required equivalence classes.
Draw the graph of the equivalence relation induced by {{a,b,c},{d}} on {a,b,c,d}.
Answer & solution
Answer: A complete directed graph with loops on {a,b,c}, plus the isolated looped vertex d. (no official key was published)
Use one vertex for each element and an arrow x→y for every ordered pair in the relation. Within {a,b,c}, put arrows in both directions between each pair of distinct vertices, and add a self-loop to each vertex. Add vertex d with its self-loop only; no arrows join it to the other component.
a ↺ d ↺
↙ ↖ ↘ ↗
b ↺ ⇄ c ↺
The arrow layout is schematic. The precise edge specification, resolving any drawing ambiguity, is loops: a→a, b→b, c→c, d→d; other arrows: a→b, b→a, a→c, c→a, b→c, c→b.
An adjacency-matrix version in row/column order a,b,c,d is 1 1 1 0 1 1 1 0 1 1 1 0 0 0 0 1.
The block-diagonal matrix emphasizes the two equivalence classes. A triangle drawn with undirected edges is acceptable only if it is explicitly understood to stand for arrows in both directions and the reflexive loops are stated. Omitting d's loop or drawing a connection between d and the triangle would describe a different relation.
Similar questions1 more → · asked again: GATE 2007, Q26
Partition refinement Hasse diagram
Partial Orders & Lattices
Tap to enlarge
Let Π1={{a,b,c},{d}}, Π2={{a},{b},{c},{d}}, Π3={{a,b,c,d}}, Π4={{a,b},{c,d}}. Draw the poset diagram under refinement.
Answer & solution
Answer: A diamond: Π2 below incomparable Π1,Π4, both below Π3. (no official key was published)
Define Π≤Σ when Π refines Σ: every block of Π is contained in some block of Σ. Under this convention the finest partition is at the bottom and the coarsest at the top.
Π3
/ \
Π1 Π4
\ /
Π2
Π2 refines both Π1 and Π4 because each of its singleton blocks lies in a block of either partition. Both Π1 and Π4 refine Π3, whose only block is the whole set. These give the four displayed cover edges in the induced four-element poset.
Π1 and Π4 are incomparable. The Π1 block {a,b,c} is not contained in either {a,b} or {c,d}, so Π1 does not refine Π4. Conversely, the Π4 block {c,d} is not contained in either {a,b,c} or {d}, so Π4 does not refine Π1. A line joining these middle vertices would therefore be wrong.
Π2 also refines Π3, but their comparison is implied transitively by either two-edge path and is omitted from a Hasse diagram. Reflexive comparisons are likewise omitted. This diagram is for the specified set of four partitions, not for the entire partition lattice of a four-element set, which contains additional vertices.
In associative (A,*), suppose distinct a,b always satisfy a*b≠b*a. Prove a*a=a for every a.
Answer & solution
Answer: Every element is idempotent. (no official key was published)
Use the contrapositive of the hypothesis: if two elements x and y commute, meaning x*y=y*x, then x=y. This is a restriction on distinct elements commuting, not cancellation and not commutativity of the entire operation.
Fix a∈A. Closure puts a*a in A, so the hypothesis can be applied to the pair a and a*a. Associativity gives a*(a*a)=(a*a)*a. Hence these two elements commute, and the contrapositive forces a=a*a.
This proves idempotence for every element. No identity element, inverse or cancellation law is needed; a semigroup supplies only associativity and closure. The special case a=a*a is already the desired conclusion, while assuming they were distinct would directly contradict the equal products above.
Under associativity and a≠b ⇒ a*b≠b*a, prove a*b*a=a for all a,b.
Answer & solution
Answer: a*b*a=a. (no official key was published)
From part (a), every element is idempotent: a*a=a. As before, the premise's contrapositive says that commuting elements must be equal.
Fix a,b and let c=a*b*a. Associativity allows us to omit parentheses, but it does not allow rearranging factors. Compute
a*c=a*(a*b*a)=(a*a)*b*a=a*b*a=c,
and
c*a=(a*b*a)*a=a*b*(a*a)=a*b*a=c.
Thus a*c=c*a. Applying the contrapositive to the two elements a and c yields a=c=a*b*a, as required.
The argument does not cancel b, assume a*b=b*a, or invoke an identity element. Its key move is to exhibit a composite element that necessarily commutes with a, then use the unusually strong hypothesis to identify the two. The calculation also covers a=b; no separate distinctness assumption is needed for the elements in the claimed identity.
Under associativity and a≠b ⇒ a*b≠b*a, prove a*b*c=a*c for every a,b,c.
Answer & solution
Answer: a*b*c=a*c. (no official key was published)
Part (b) established x*y*x=x for every pair of elements x,y. Apply it first to x=c,y=a, obtaining c*a*c=c. Substitute this equal expression for the final c in a*b*c, and then reassociate:
a*b*c = a*b*(c*a*c) = [a*(b*c)*a]*c = a*c.
The last equality uses the same sandwich identity with x=a and y=b*c, which is an element of A by closure. Every step preserves the order of factors, so no forbidden commutativity assumption is being made.
This proves the desired middle-factor elimination for arbitrary a,b,c. Iterating it shows any product of at least two factors reduces to its first factor multiplied by its last. The identity is compatible with noncommutativity; for example the left-zero operation x*y=x is associative and satisfies the premise because x*y=x and y*x=y differ whenever x≠y. Thus the proof does not imply that all elements of A are equal or that the operation is commutative.
For the displayed PDA on states q0,q1, alphabet {0,1}, stack {Z0,X}, start (q0,Z0), and empty-store acceptance, determine its language. Common transitions: (q0,1,Z0)→(q0,XZ0), (q0,ε,Z0)→(q0,ε), (q0,1,X)→(q0,XX), (q1,1,X)→(q1,ε). GFG has (q0,0,Z0)→(q1,X) and (q1,0,Z0)→(q0,Z0); GateForum instead has (q0,0,X)→(q1,X) and (q0,0,Z0)→(q0,Z0).
Answer & solution
Answer: As printed: {ε, 01}. A plausible repaired PDA accepts (⋃_(n≥1)1^n01^n0)*. (no official key was published)
Empty-store acceptance requires both the entire input to be consumed and the stack to be empty. Merely reaching Z0, or emptying the stack while unread input remains, is not sufficient. The two printed transition sets differ materially, so there is no source-independent single language.
The paper literal version: at (q0,Z0), ε can pop Z0 and accept ε. Reading 0 uses its printed transition (q0,0,Z0)→(q1,X), replacing Z0 rather than preserving it. One subsequent 1 pops X and accepts 01 with an empty stack. No further input can then be consumed. Reading any 1 first puts X above Z0 in q0; that state can only push more X on further 1s, because the paper's zero transition tests Z0, not X. It can never enter its popping phase from such a stack. Thus L={ε,01}. The printed q1,0,Z0 return transition is unreachable from the start in this literal machine.
It cannot empty Z0. Hence no string containing a 1 is accepted and L_GF=0*.
It pushes n≥1 Xs on 1s, reads 0 to switch phase, pops n Xs on 1s, then reads another 0 to return to q0. It can repeat such blocks and finally pop Z0 by ε. Conditional on exactly those repairs, the language is (⋃_(n≥1){1^n01^n0})*. The choice n≥1 is necessary because no q0,0,Z0 transition remains in this repair. This reconstructed answer is useful but not verified as the original question; silently substituting it would conceal different literal answers.
For the displayed PDA on states q0,q1, alphabet {0,1}, stack {Z0,X}, start (q0,Z0), and empty-store acceptance, describe its operation informally. Common transitions: (q0,1,Z0)→(q0,XZ0), (q0,ε,Z0)→(q0,ε), (q0,1,X)→(q0,XX), (q1,1,X)→(q1,ε). GFG has (q0,0,Z0)→(q1,X) and (q1,0,Z0)→(q0,Z0); GateForum instead has (q0,0,X)→(q1,X) and (q0,0,Z0)→(q0,Z0).
Answer & solution
Answer: See the solution below (no official key was published)
A transition (q,a,T)→(p,γ) consumes a when a≠ε, changes state to p, and replaces the top stack symbol T by γ. Take the leftmost stack symbol as the top. Thus replacing X by XX pushes one extra counter symbol, while replacing X by ε pops one.
In the plausible reconstruction specified in part (a), q0 is a counting-up phase and q1 a counting-down phase. Start with Z0. Each leading 1 pushes one X. A 0 with X on top switches q0→q1 without changing the stack. Each following 1 in q1 pops one X. Once only Z0 remains, another 0 returns to q0 without removing Z0. The machine may process another block in the same way. Only at q0 with top Z0 may ε remove the bottom marker, accepting if input is exhausted.
For reconstructed input 110110, the configurations (state, unread input, stack) are (q0,110110,Z0) →(q0,10110,XZ0) →(q0,0110,XXZ0) →(q1,110,XXZ0) →(q1,10,XZ0) →(q1,0,Z0) →(q0,ε,Z0) →(q0,ε,ε).
An extra 1 in the popping phase has no transition once Z0 is reached; too few 1s leave X on top when the closing 0 is encountered, also blocking the run. These restrictions enforce equal positive counts within every block. The four-phase explanation applies only to the explicitly repaired transition set, not literally to both printed versions.
Literal machine the special input 01 instead replaces Z0 by X on its first step, then pops X, so that machine accepts only ε and 01. These observations explain why the attractive counting-machine interpretation cannot be presented without disclosing the source repairs. All unspecified transitions are treated as absent, not guessed.
Answer: {a^i b^j : i,j≥1 and i≠j}. (no official key was published)
A generates exactly ar with r≥1: each recursive step adds one a and the final A→a supplies the last. Similarly B generates exactly bs with s≥1. The left recursion in B changes derivation direction, not its generated language or uniqueness for a fixed length.
After t≥0 uses of S1→aS1b, choosing S1→aAb and A⇒ar produces at+r+1bt+1. Both exponents are positive and the number of a's exceeds the number of b's by r≥1. Choosing S1→aBb instead gives at+1bt+s+1, whose b-count exceeds its a-count by s≥1. These are the only terminating choices, so equality of the counts is impossible.
Conversely, for any i>j≥1, choose t=j−1 and r=i−j, yielding ai bj through the A branch. For j>i≥1, choose t=i−1 and s=j−i through the B branch. Therefore every positive unequal pair occurs, proving L(G1)={ai bj:i,j≥1,i≠j}.
This grammar is also unambiguous. The comparison between i and j forces the A or B branch; the smaller exponent forces t; the difference forces r or s. The unary A or B derivation of that length is unique. This fact will be useful when answering the inherent-ambiguity question, but does not need to be assumed to establish the language.
Using G1 from part (a), construct a CFG for L2={a^i b^j a^k b^l : i,j,k,l≥1 and (i=j or k=l)} by adding no more than five productions.
Answer & solution
Answer: Add S2→TAB|S1T and T→aTb|ab, taking S2 as the new start symbol: four added alternatives. (no official key was published)
Keep every production of G1. Introduce new nonterminals S2 and T, take S2 as the new start symbol, and add exactly four individual productions:
S2 → TAB S2 → S1T T → aTb T → ab
T generates precisely {an bn:n≥1}. Existing A and B generate a+ and b+, so AB generates all ak bl with k,l≥1. Consequently the first new start production TAB generates exactly the words with i=j and arbitrary positive k,l. The second production S1T generates exactly those with i≠j and k=l, because part (a) established the unequal-count language of S1.
These two cases together are equivalent to i=j or k=l. If the first equality holds, the first branch handles the word whether or not the second equality also holds. If the first equality fails, the language condition forces k=l, so the second branch handles it. Conversely every generated word satisfies one of those required equalities. Positive lengths of all four runs are guaranteed by T,A,B and S1.
The extension uses four alternatives, within the stated limit of five, even when each bar-separated alternative is counted separately. Reusing the unequal-count grammar is deliberate: the simpler-looking union “balanced first or balanced second” would have overlapping branches when both pairs are balanced. Here the two branches are disjoint, which also supplies a clean unambiguity proof for part (c).
For L2={a^i b^j a^k b^l : i,j,k,l≥1 and (i=j or k=l)}, decide whether it is inherently ambiguous. Use the grammar extension from part (b) if helpful.
Answer & solution
Answer: No. The four-rule extension gives an unambiguous CFG. (no official key was published)
A context-free language is inherently ambiguous only if every CFG generating it is ambiguous. It is therefore enough to exhibit and prove one unambiguous grammar. Use the extension from part (b): S2→TAB|S1T, T→aTb|ab, retaining the unambiguous unequal-count grammar G1.
Every word of L2 has four nonempty runs ai,bj,ak,bl. The boundaries between the runs are determined by changes of symbol, particularly the middle b-to-a change, so a derivation cannot shift the split between its two a*b* components.
If i=j, only S2→TAB can apply, since S1 generates unequal first counts. The exponent i fixes the unique derivation in T. The remaining exponents k and l fix the unique unary derivations in A and B. If i≠j, only S2→S1T can apply. Then membership requires k=l. Part (a)'s proof gives a unique derivation of ai bj in S1, and the common value k=l gives a unique derivation in T. Hence each word has exactly one parse tree.
Words satisfying both equalities still use only the first branch, so they do not create an intersection ambiguity. A different grammar with productions for “first pair equal” and “second pair equal” may generate those words twice, but ambiguity of one grammar does not establish inherent ambiguity of its language. This four-run language also should not be confused with classical three-run examples whose equality conditions share the middle count. The explicit disjoint grammar here proves that L2 is not inherently ambiguous.
Draw an 8085-based system to measure the width of a TTL-compatible pulse. State necessary assumptions.
Answer & solution
Answer: Use a gated hardware timer and read its frozen count. (no official key was published)
One valid design uses an 8253 programmable interval timer rather than relying on uncertain software polling time. Configure counter 0 in binary mode 0, initially load N0=65535, and feed it a known clock f. Connect the measured pulse to GATE0. While GATE0 is high the counter decrements; when it falls, counting stops and the retained value N is read. Width is approximately (N0−N)/f, with one-clock quantization and gate synchronization uncertainty.
8085 AD0–AD7 ↔ shared data bus ↔ 8253 D0–D7
└─ ALE latch → low address bus
latched address, upper address, IO/M → port decoder → /CS
8085 /RD,/WR → 8253 /RD,/WR
latched A0,A1 → timer A0,A1
known oscillator f → CLK0
TTL pulse → GATE0 and a separate readable input-port bit 0
Map counter ports to 80h–82h and control to 83h; map the pulse input latch/buffer to 90h. The input buffer must be enabled only for reads of its port. Supply the usual clock, reset, power and bus support circuitry. Gate and clock levels must meet the timer's electrical/timing specifications; synchronize an asynchronous input if required, accounting for the resulting edge uncertainty.
Require the timer to be armed while the pulse is low. The 8253 count load is not complete merely when the second byte is written: allow a complete CLK rising-and-falling sequence after that write before the measured pulse may rise. After the pulse falls, allow the gate synchronization and counter propagation to settle before latching the result. Use a suitable guard interval or ready handshake based on the chosen timer clock and device timing. Require one isolated pulse, and fewer than 65535 counted clocks. Polling must detect the high interval before its falling edge; a separate edge latch can remove that minimum-width limitation. The hardware gate, not the polling latency, determines the count. No unique numerical width follows without the input waveform and f. Other valid designs include calibrated software loops, but their instruction timing and missed-edge error must be stated.
Write an 8085 assembly program to measure a TTL pulse width, stating hardware and timing assumptions. Use the counter/port design of original Q15(a).
Answer & solution
Answer: HL = number of gated clocks; width ≈ HL/f. (no official key was published)
Use the 8253 design in part (a), with pulse bit 0 readable at port 90h. Control byte 30h selects counter 0, low-byte then high-byte access, mode 0 and binary counting. Load FFFFh. After the falling edge, control byte 00h latches counter 0 without changing its mode; read low byte first.
WAITLOW: IN 90H
ANI 01H
JNZ WAITLOW
MVI A,30H
OUT 83H
MVI A,0FFH
OUT 80H
OUT 80H
WAITHIGH:IN 90H
ANI 01H
JZ WAITHIGH
WAITEND: IN 90H
ANI 01H
JNZ WAITEND
MVI A,00H
OUT 83H
IN 80H
MOV E,A
IN 80H
MOV D,A
MVI A,0FFH
SUB E
MOV L,A
MVI A,0FFH
SBB D
MOV H,A
HLT
DE receives the frozen count N. SUB/SBB perform the 16-bit subtraction FFFFh−DE, leaving the elapsed clock count in HL. The SUB's borrow is retained across MOV and MVI, so SBB correctly handles the high byte. Divide this integer by the known clock frequency to obtain seconds; for f=1 MHz each count represents roughly 1 μs.
This is not an unrestricted pulse-capture instrument: the pulse must start only after both count bytes are written and the subsequent complete CLK rising-and-falling loading sequence has occurred. A source-side guard/ready handshake enforces this requirement; the software does not issue a timer-ready signal. Also allow at least one clock period plus the specified propagation margin after the falling edge before the latch command. Choose the external clock relative to the 8085 clock so the displayed polling/readout path already provides that settling interval, or insert a calibrated delay before OUT 83H. The pulse must last long enough to be seen by WAITHIGH, remain low during readout, and not exhaust the initial counter value. Otherwise missed pulses or wrap/terminal-count behavior invalidate the result. A ready handshake, external trigger latch and overflow indication are appropriate extensions. The answer explicitly uses a timer peripheral, whose gate capture avoids treating variable software latency as measured time.
Design a synchronous counter producing 1,4,2,3,1,4,... .
Answer & solution
Answer: Three common-clock D flip-flops with state sequence 001→100→010→011→001. (no official key was published)
Represent the displayed numbers by Q2Q1Q0. The required transitions are 001→100, 100→010, 010→011 and 011→001. Use three D flip-flops sharing one clock, with each D input equal to the corresponding next-state bit. Reset to 001 before normal counting.
A complete, self-starting design sends every unused state to 001:
Let mi denote the three-variable minterm for binary i. Then D2=m1=¬Q2·¬Q1·Q0; D1=m2+m4=¬Q0(¬Q2·Q1+Q2·¬Q1); D0=m0+m2+m3+m5+m6+m7. Wire these sum-of-products functions to D2,D1,D0. Notice D0 is 1 also for state 010, whose successor is 011. These equations directly implement every row of the table, so no unspecified-state behavior is hidden by don't-care minimization.
All bits update together on the active clock edge; a ripple counter would not implement this arbitrary sequence directly. Four internal states require only two bits if an output decoder is allowed, but three state flip-flops give the requested binary numbers directly and make unused-state recovery explicit.
Read 35 sectors on a soft-sectored, two-sided floppy, 8 sectors/track, 8 ms track step, 300 rpm, starting sector 3 of track 10 with head initially on track 10. Controller has one-sector buffer. Find total time.
Answer & solution
Answer: 875 ms transfer time; a unique total needs rotational phase, layout/skew and servicing assumptions. (no official key was published)
One revolution takes 60/300=0.2 s=200 ms, so a sector takes 200/8=25 ms. Reading the 35 payload sectors therefore needs 35×25=875 ms of on-media transfer. Starting at sector 3, the track portions contain 6,8,8,8,5 sectors, so five surface-tracks are visited and four surface-track boundaries crossed.
A two-sided disk does not necessarily seek at all four boundaries. With cylinder-major allocation starting on side 0, the order is cylinder 10 side 0, cylinder 10 side 1, cylinder 11 side 0, cylinder 11 side 1, cylinder 12 side 0. Ignoring head-switch time, this requires two radial steps, totaling 16 ms. A simplified additive estimate with no initial or boundary rotational waiting is then 891 ms. If 'track' instead means successive tracks of one surface requiring four steps, the corresponding estimate is 907 ms.
Neither estimate is an unconditional exact answer. The initial angular position is not specified. Without track skew, an 8 ms seek after sector 8 can miss the start of sector 1, requiring a wait for its next revolution. Under the cylinder-major example, zero initial wait, aligned sector numbering and instantaneous head switches, each of the two step boundaries costs an entire 200 ms including seek plus rotational wait, giving 875+400=1275 ms. A suitably skewed layout changes that boundary cost.
Finally, a one-sector buffer does not specify how quickly the host drains it. Missing the next sector while transferring a buffer can add whole rotations. A defensible expression is 875 ms + initial rotational wait + radial-step time + head-switch time + boundary/buffer waiting. The supplied facts fix only some terms, so report assumptions rather than invent an exact total.
A cache has l sets, block size b, k blocks per set, cache/main-memory times tc,tm. A loop of size nb executes 100 times, with n=km and 1<m≤l. Find hit ratio and discuss l=1.
Answer & solution
Answer: Under cold, aligned contiguous block-level accesses: 99%; l=1 contradicts 1<m≤l. (no official key was published)
The loop contains n blocks and total cache capacity is kl blocks. Assume contiguous aligned loop blocks, ordinary block-number modulo-l indexing, no competing data/code, an initially empty cache and one counted access per loop block per pass. Since n≤kl, each set receives at most ceil(n/l)≤k loop blocks. Thus no loop block must evict another after the first pass.
The first traversal incurs n compulsory misses. The remaining 99 traversals hit on all n blocks. Out of 100n block references, 99n hit, so H=0.99. Neither tc nor tm affects this count; they would enter effective access-time calculations instead.
If b denotes b separately referenced words/instructions per block, the denominator changes: there are 100nb references, still n misses, giving H=1−1/(100b). If b is bytes while instructions have unspecified lengths, that word-reference formula cannot be asserted numerically. The definition of an access must be explicit.
The separate request l=1 is incompatible with the earlier constraint 1<m≤l. If it means keep m>1 while replacing the cache by one fully associative k-block set, then n=km>k. Under LRU and repeated cyclic scanning, every block-level access misses: by the time a block is revisited, at least k distinct blocks have intervened. H=0 at block granularity, or 1−1/b for b consecutive word references per block. This is conditional on LRU; an unspecified replacement policy can produce a different ratio. If the intended comparison instead keeps the entire loop fitting, its warmed-up behavior remains 99%. The source does not resolve these alternatives.
Initially p points to node i in i→i+1→i+2→i+3→suffix. Execute q=p.next; p.next=q.next; q.next=(q.next).next; (p.next).next=q. GateForum instead prints p.next, not q.next, on the third line. Explain both.
Answer & solution
Answer: It swaps nodes i+1 and i+2 (no official key was published)
Write P=i, A=i+1, B=i+2 and C=i+3. Initially P→A→B→C→suffix. Third line, step 1 sets q=A. Step 2 bypasses A by setting P.next=B. Step 3 sets A.next=C, preserving the link to the suffix. Step 4 sets B.next=A. The resulting chain is P→B→A→C→suffix: the two adjacent nodes after p have been exchanged without copying their payloads. This requires those nodes and the next fields used in the expressions to exist.
After the first two steps, q=A, P.next=B, A.next=B and B.next=C. Its third line sets P.next=C instead of changing A.next. Its last line then sets C.next=A. Thus from P the chain becomes P→C→A→B→C→..., a three-node cycle; the original suffix after C is detached from this chain. It is not an adjacent swap.
The correct algorithmic explanation cannot establish which version appeared in the official original.
Answer: 3 x 1 + log * a 2 / − (no official key was published)
Step through it (14 steps)
First parenthesize by the usual precedence and the unary function call: (3*log(x+1))−(a/2). A postfix traversal writes operands before their operator. The subtree x+1 becomes x 1 +; applying the unary log appends log, giving x 1 + log. Multiplication by 3 becomes 3 x 1 + log *. Independently, a/2 becomes a 2 /. Finally append subtraction after both subexpressions:
3 x 1 + log * a 2 / −
The spaces separate tokens, and log is one unary operator rather than three operands. Evaluating this stack form pushes 3, forms log(x+1), multiplies, forms a/2, then subtracts the right value from the left. Reversing the final operands would change the expression.
Construct the tree with inorder a f b c d g e and postorder a f c g e d b.
Answer & solution
Answer: Root b; left f with left a; right d with left c and right e with left g. (no official key was published)
The final postorder symbol b is the root. Split inorder around b: left subtree has a,f and right subtree has c,d,g,e. The corresponding postorder chunks are a,f and c,g,e,d.
For the left subtree, final f is its root and a lies to its left, so f has left child a and no right child. For the right subtree, final d is its root. Inorder splits into c on its left and g,e on its right. The left child is c. The right chunk has postorder g,e, hence root e with left child g.
b
/ \
f d
/ / \
a c e
/
g
Checking inorder yields a,f,b,c,d,g,e. Checking postorder yields a,f,c,g,e,d,b. The labels are distinct, so the recursive splits uniquely determine the tree. A different shape that merely shares the root would not suffice.
Derive the minimum number N(h) of nodes in an AVL tree of height h. State the height convention.
Answer & solution
Answer: N(h)=1+N(h−1)+N(h−2); edge-height bases N(−1)=0,N(0)=1. (no official key was published)
Take height to count edges on a longest root-to-leaf path; an empty tree has height −1 and a leaf height 0. A tree of height h must have at least one child subtree of height h−1. AVL balance permits the other to be no shorter than h−2. To minimize nodes, choose exactly those two heights and make both subtrees themselves minimum-size AVL trees. Counting the root gives N(h)=1+N(h−1)+N(h−2), with N(−1)=0,N(0)=1.
This is both a lower bound and attainable: recursively attach extremal subtrees of heights h−1 and h−2 to a root. The height difference is one, so the construction is AVL. Writing M(h)=N(h)+1 gives M(h)=M(h−1)+M(h−2), and the bases imply N(h)=Fh+3−1 when F0=0,F1=1.
If height instead counts levels, the empty tree is height 0 and a leaf height 1, so the same recurrence has bases N(0)=0,N(1)=1 and formula Fh+2−1. The recurrence is structural; the indexing convention must not be mixed between parts.
Answer: 88 nodes for edge height; 54 for level height. (no official key was published)
Using the edge-height convention from part (a), start N(−1)=0,N(0)=1 and apply N(h)=1+N(h−1)+N(h−2). The values at heights 1 through 8 are 2,4,7,12,20,33,54,88. Thus the smallest tree at edge height 8 has 88 nodes. Equivalently, F11−1=89−1=88.
If the source's unstated height convention counts levels, the same physical tree's level height is one larger. A level-height-8 minimum tree therefore has edge height 7 and 54 nodes. This is not a disagreement in AVL structure, only an indexing ambiguity. Specify the convention rather than asserting both numbers describe the same notion of height. The printed empty '(c)' after this question contains no task text and is not invented as another solution item.
An identifier has one through six letters/digits, with a letter first. Give a regular expression.
Answer & solution
Answer: L(ε|A|A²|A³|A⁴|A⁵), A=L∪D. (no official key was published)
Let L denote the finite union of permitted letters and D the union of decimal digits. Let A=L|D. The first character must be from L. It can be followed by zero through five alphanumeric characters, giving
L(ε | A | AA | AAA | AAAA | AAAAA).
With repetition shorthand this is L A{0,5}. The expanded expression above uses only ordinary regular-expression union, concatenation and ε; braces are not essential notation.
A one-letter identifier follows the ε branch; a six-character one follows AAAAA. No branch accepts an empty identifier or a first digit, and none permits a seventh character. Conversely any permitted identifier can be decomposed into its initial letter and its remaining zero to five alphanumeric symbols, so it is accepted. The actual letter alphabet, such as upper/lowercase distinctions, is a language-design input; underscores are not included because the question permits only letters and digits.
Construct the LL(1) table for Program→begin d semi X end; X→d semi X | sY; Y→semi sY | ε. Treat begin,d,semi,s,end as terminals.
Answer & solution
Answer: Nonempty table entries: Program/begin; X/d,X/s; Y/semi,Y/end. (no official key was published)
Step through it (2 parts)
FIRST(Program)={begin}; FIRST(X)={d,s}; FIRST(Y)={semi,ε}. Program is the start symbol, so FOLLOW(Program)={$}. In Program's production, X is followed by end, hence FOLLOW(X)={end}. The occurrence Y at the end of X→sY gives FOLLOW(Y)={end}; its recursive production adds no new follower.
Fill a production in columns belonging to the FIRST set of its right side. For the ε production, use FOLLOW(Y). The complete non-error entries are:
Nonterminal | lookahead | production
Program | begin | Program→begin d semi X end
X | d | X→d semi X
X | s | X→sY
Y | semi | Y→semi sY
Y | end | Y→ε
Every other cell, including all cells under $, is an error for these nonterminals. The parsing stack accepts only when both its end marker and the input end marker match after Program is fully processed. There is no conflict: X's alternatives start with different terminals, and FIRST(semi sY)={semi} is disjoint from FOLLOW(Y)={end}. That establishes LL(1), rather than merely presenting a table without explaining why it works.
Similar questions1 more → · asked again: GATE 1999, Q9
Fractional binary attributes
Semantic Analysis & Type Checking
Tap to enlarge
Give synthesized semantic rules for S→L.L|L; L→LB|B; B→0|1, with 101.101=5.625. The dot is visible in the GateForum raster but faint/lost in some extraction.
Answer & solution
Answer: Use integer value and length attributes for the supplied fractional grammar. (no official key was published)
This production parses the fractional example; replacing it by dotless S→LL would describe a different grammar.
Use L.val for the integer represented by its bit string and L.len for its number of bits. All attributes are synthesized: S→L1 . L2: S.val=L1.val+L2.val/2L2.len S→L: S.val=L.val L→L1 B: L.val=2*L1.val+B.val; L.len=L1.len+1 L→B: L.val=B.val; L.len=1 B→0: B.val=0 B→1: B.val=1
Appending a bit shifts the prior number left by one, hence multiplication by two. A fractional bit string of length k represents its integer value divided by 2k. For each 101, (val,len) grows (1,1),(2,2),(5,3); S.val=5+5/8=5.625. The length attribute is necessary: .001 and .1 have the same integer value 1 but represent 1/8 and 1/2 respectively. Every semantic expression uses only child attributes, meeting the synthesized-only requirement. Original official wording has not been established by these secondary copies.
Four jobs with expected run times 6,3,5,x are waiting. In what order should they run to minimize average response time?
Answer & solution
Answer: Shortest expected processing time first, subject to standard all-arrived nonpreemptive assumptions. (no official key was published)
Assume one processor, all four jobs ready at time zero, no scheduling overhead, and response interpreted as time to completion (or waiting time to first execution under nonpreemptive execution). Consider adjacent jobs of lengths a>b starting at time t. Their completion-time sum in order a,b is (t+a)+(t+a+b)=2t+2a+b. Reversing them gives 2t+2b+a, smaller by a−b. Other jobs' completion times do not change, because the pair's total length is unchanged. Repeatedly removing inversions proves ascending processing time is optimal.
Thus for x≥0: if x≤3, use x,3,5,6; if 3≤x≤5, use 3,x,5,6; if 5≤x≤6, use 3,5,x,6; if x≥6, use 3,5,6,x. Ties can be broken either way. For random run times the same exchange proof minimizes expected mean completion using their expected durations, when the decision is a fixed order and those expectations are known.
The answer is not a universal interactive-response policy: different release times, preemption or defining response as first service with arbitrarily small time slices changes the optimization problem. These are not specified, so the conventional nonpreemptive model is stated.
Represent the graph with edges S1→S2,S1→S3,S1→S4,S1→S5,S2→S4,S4→S5,S3→S5 using parbegin/parend.
Answer & solution
Answer: S1; parbegin {S2;S4} || {S3} parend; S5. (no official key was published)
S1 must finish first. Afterward S3 can run independently of the chain S2 then S4. S5 must wait for both branches. A structured program is:
begin
S1;
parbegin
begin
S2;
S4;
end
S3;
parend;
S5;
end
Here parbegin starts its two child statements concurrently, and parend joins them. The first child is a sequential block, so S2 precedes S4. The second child is S3. The final join guarantees both S3 and S4 finish before S5. Edges S1→S4 and S1→S5 are already implied by the paths through S2/S4, but are still satisfied. There is no imposed order between S3 and S2 or between S3 and S4, so the program preserves the graph's available parallelism rather than unnecessarily serializing it.
Disk addresses take d bits; a disk has B blocks, F free. When does a free list occupy less storage than a bitmap?
Answer & solution
Answer: Fd<B in the conventional address-list accounting. (no official key was published)
A bitmap uses one bit for every disk block, allocated or free, so its size is B bits. An explicit list storing one d-bit address per free block uses Fd bits. Thus the list is smaller precisely when Fd<B, or F/B<1/d. Equality is a tie, not a reduction. For example d=32 means the list wins below a free-block fraction of 1/32 under this model.
This compares payload metadata. An additional list-head pointer, count or alignment changes the inequality by the corresponding overhead, for example (F+1)d<B if one extra d-bit head is counted only for the list. A linked free list may store next pointers inside otherwise free blocks; in that implementation physical placement and reserved-memory costs differ from an external address array. The simple condition requested assumes the conventional one-address-per-free-block versus one-bit-per-total-block accounting.
A disk has C cylinders,t tracks/cylinder,s sectors/track, sector length sl. A contiguous file begins at (cL,tL,sL), with record length rl=sl. Derive cylinder,track,sector of logical record n.
Answer & solution
Answer: For zero-based disk coordinates and one-based n, j=((cL*t+tL)*s+sL)+(n−1); decode j by division. (no official key was published)
Assume disk coordinates cL,tL,sL are zero-based, records are numbered from 1, and the file starts at a sector boundary. Since each record equals one sector, record n is n−1 sectors beyond the initial address. Linearize the starting location as j0=(cL*t+tL)*s+sL and set j=j0+n−1.
Then cylinder=floor(j/(t*s)); within-cylinder remainder r=j mod(t*s); track=floor(r/s); sector=r mod s. These divisions automatically carry across track and cylinder boundaries. For n=1, quotient/remainder reconstruction returns exactly the starting triple. Crossing a sector boundary from s−1 adds one track; crossing track t−1 adds one cylinder.
Require 0≤j<C*t*s so the record fits on the disk. If sector labels are one-based, replace the starting sL by sL−1 before linearization and add 1 to the final sector result. If all three disk labels are one-based, first subtract 1 from each and then add 1 to each output. If records themselves are numbered from zero, use n rather than n−1. Without these conventions an off-by-one ambiguity remains; the physical addressing rule is otherwise the same.
Relation(Book-id,Subject-Category,Author-Name,Author-Nationality) has Book-id primary key. What is its highest normal form?
Answer & solution
Answer: 2NF under intended Author-Name→Nationality; key alone does not establish that dependency. (no official key was published)
Under the usual semantic assumption that an author name uniquely identifies one author with one nationality, the dependencies include Book-id→all attributes and Author-Name→Author-Nationality. The key is a single attribute, so there is no nonempty proper subset of it on which a nonprime attribute can partially depend. With atomic values, this gives 2NF in the conventional setting.
However Author-Name is not a superkey when an author can write several books, and Author-Nationality is nonprime. The dependency Author-Name→Author-Nationality therefore violates 3NF, and also BCNF. Thus the intended highest form is 2NF.
The premise formally states only the primary key, not all functional dependencies or candidate keys. If the only nontrivial dependencies were those forced by Book-id, the relation would be BCNF instead. Names need not uniquely identify authors in a real database, and multiple nationalities may require a separate modeling choice. Hence 2NF is a conditional semantic answer, not a theorem from the primary-key declaration alone. Constant-valued attributes with empty determinants would introduce additional exceptional dependencies not assumed by the textbook model.
Add Book-title and Author-address to the preceding book relation, with primary key(Author-Name,Book-title). What is its highest normal form?
Answer & solution
Answer: 1NF under intended author→nationality,address dependencies; otherwise underdetermined. (no official key was published)
Assume all values are atomic and that each author identifier determines one nationality and one address. The declared key is now K={Author-Name,Book-title}, but the nonprime attributes Author-Nationality and Author-address depend on Author-Name alone, a proper subset of K. These are partial dependencies, violating 2NF. The intended highest normal form is therefore 1NF.
The contrast with part (a) is important: the same author dependency was transitive from a one-attribute book key there, but becomes partial when author is itself one component of the composite key. A decomposition into Author(Author-Name,Nationality,Address) and Book(Author-Name,Book-title,...) removes that particular partial dependency, subject to the remaining domain dependencies.
As before, the key declaration alone does not logically imply the semantic FDs. Author homonyms, multiple addresses or other candidate keys change the analysis. If no such non-key dependencies are imposed, one cannot infer a 2NF violation solely from the displayed attribute names. The conditional answer and its assumptions are retained because no official original/key has been verified.
COURSES(Cno,name), PRE-REQ(Cno,pre-Cno), COMPLETED(student-no,Cno). Use relational algebra to list courses for which student 2310 has completed every prerequisite.
Answer & solution
Answer: Return courses minus those with a missing prerequisite, including courses having no prerequisites. (no official key was published)
First collect completed course numbers for the selected student and rename the attribute to match the prerequisite column: D=ρ_(pre-Cno←Cno)(π_Cno(σ_(student-no=2310)(COMPLETED))). Let P=PRE-REQ. A natural join P⋈D contains exactly those prerequisite pairs whose prerequisite was completed. Hence Missing=P−(P⋈D) contains pairs identifying at least one uncompleted prerequisite. Project these to obtain Bad=π_Cno(Missing).
Let All=π_Cno(COURSES). Then Eligible=All−Bad, and the requested full course listing is COURSES⋈Eligible. The join uses Cno and returns each eligible course's number and name.
This construction implements 'all' by excluding counterexamples. If a course has three prerequisites and one is missing, that missing pair places it in Bad and removes it. A course with no prerequisites has no missing pair, so it remains eligible by vacuous truth. A naive division over only existing prerequisite pairs can accidentally omit such courses. Nothing in the question excludes courses already completed by the student; add that exclusion only if explicitly requested. The expression uses set relational algebra, so duplicate completion records have no effect.