GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 1991

71 questions

Paper analysis: marks by subject, top topics and repeated questions →

03:00:00
2 marks · Other
Report issue

Complementary switch paths

Boolean Algebra & Logic Gates

Question 1(i), GATE 1991: The GFG figure connects x through controls ¬a, b and y through controls a, ¬b, joining at f. Upper a and lower b have inversion bubbles; Forum omits these bubbles. Find f.
Question 1(i), GATE 1991: The GFG figure connects x through controls ¬a, b and y through controls a, ¬b, joining at f. Upper a and lower b have inversion bubbles; Forum omits these bubbles. Find f.
Tap to enlarge
Answer & solution

Answer: x¬ab+ya¬b in the Boolean switching model; no driven output for a=b without an additional convention (no official key was published)

The upper a-controlled switch has an inversion bubble while its b switch does not. This path conducts when a=0, b=1, passing x. The lower path has the opposite control polarities, so it conducts when a=1, b=0 and passes y. Combining those path contributions gives f=x¬ab+ya¬b. The paths are never simultaneously enabled, so this the reading avoids conflicting input drivers. However, when a=b neither path conducts: a physical pass-transistor output is floating or retains charge unless a pull device or storage convention is specified. Thus treating disabled paths as Boolean zero is a switching-algebra convention.

Original paper, page 1

2 marks · Other
Report issue

Memory interleaving address bits

Memory Organization & Address Translation

Question 1(ii), GATE 1991: Which interleaving stores consecutive words in consecutive modules, and which stores them within one module?
Question 1(ii), GATE 1991: Which interleaving stores consecutive words in consecutive modules, and which stores them within one module?
Tap to enlarge
Answer & solution

Answer: Low-order; high-order (no official key was published)

For M banks, low-order interleaving uses the low address bits as bank number: address j selects bank j mod M. Consecutive addresses consequently cycle through the banks, allowing overlap of sequential accesses. High-order interleaving selects the bank with high bits, leaving the low bits as the location within that bank. A consecutive run then stays in the same bank until it crosses that bank’s address range. These names describe address mapping, not whether the memory cells themselves are physically adjacent.

Original paper, page 1

2 marks · Other
Report issue

Population count of a hexadecimal expression

Number Systems & Computer Arithmetic

Question 1(iii), GATE 1991: Count binary ones in the number. Forum prints 9×16³+7×16²+5×16+3; GFG instead appears to use plus signs between every displayed term.
Question 1(iii), GATE 1991: Count binary ones in the number. Forum prints 9×16³+7×16²+5×16+3; GFG instead appears to use plus signs between every displayed term.
Tap to enlarge
Answer & solution

Answer: 4 ones, reading the printed + signs as addition (no official key was published)

Convert its digits independently: 9→1001, 7→0111, 5→0101, 3→0011. Their one counts are 2+3+2+2=9; concatenation introduces no carries. If the plus signs are taken literally, the sum is 16³+9+16²+7+16+5+3=4392=0x1128, whose binary representation has four ones. The arithmetic results are therefore source-dependent.

Original paper, page 1

2 marks · Other
Report issue

8086 mode with an 8087

Input/Output, DMA & Interrupts

Question 1(iv), GATE 1991: Which operating mode is required when the 8086 CPU works with an 8087 arithmetic coprocessor? Forum misprints the CPU as 8087.
Question 1(iv), GATE 1991: Which operating mode is required when the 8086 CPU works with an 8087 arithmetic coprocessor? Forum misprints the CPU as 8087.
Tap to enlarge
Answer & solution

Answer: Maximum mode (no official key was published)

The 8086 supports minimum mode for a simpler single-processor system and maximum mode for systems requiring multiprocessor/coprocessor bus coordination. The 8087 participates in the latter environment using the relevant status and request/grant signals. Therefore the 8086 must be configured for maximum mode, with MN/MX driven low.

Original paper, page 1

2 marks · Other
Report issue

Second bit of a binary product

Number Systems & Computer Arithmetic

Question 1(v), GATE 1991: A=a3a2a1a0 and B=b3b2b1b0 are unsigned four-bit numbers. Express product bit c1.
Question 1(v), GATE 1991: A=a3a2a1a0 and B=b3b2b1b0 are unsigned four-bit numbers. Express product bit c1.
Tap to enlarge
Answer & solution

Answer: c1=(a1b0) XOR (a0b1) (no official key was published)

The column of weight 1 contains only a0b0, so it produces c0 and no carry into the weight-2 column. That next column contains a1b0 and a0b1. Adding two bits gives their XOR as the low result bit and their AND as carry to weight 4. Hence c1 is the XOR of the two partial products. Higher input bits cannot contribute to this column because their positional weights are at least four. Ordinary OR would be wrong when both partial products are one.

Original paper, page 1

2 marks · Other
Report issue

Evenness as a loop invariant

Correctness, Invariants & Design

Question 1(vi), GATE 1991: Pascal enters the loop only if i mod 2=0. While i≥0, it replaces i by i div 2, then subtracts 1 if the new i is odd, otherwise subtracts 2. Give an invariant.
Question 1(vi), GATE 1991: Pascal enters the loop only if i mod 2=0. While i≥0, it replaces i by i div 2, then subtracts 1 if the new i is odd, otherwise subtracts 2. Give an invariant.
Tap to enlarge
Answer & solution

Answer: i is even at each loop test (no official key was published)

The outer test establishes evenness before the first loop test. Let j be the quotient after the division in an iteration. If j is odd, j−1 is even; if j is even, j−2 is even. Thus either branch reestablishes the invariant regardless of the parity produced by division. Nonnegativity is the loop guard, not an invariant after the body: for i=0 the body produces −2 and terminates. An even negative initial value skips the loop altogether. The invariant states a preserved property, not a complete description of all reachable values.

Original paper, page 1

2 marks · Other
Report issue

Optimal comparisons for five keys

Searching, Sorting & Selection

Question 1(vii), GATE 1991: What minimum number of comparisons suffices to sort five arbitrary distinct keys?
Question 1(vii), GATE 1991: What minimum number of comparisons suffices to sort five arbitrary distinct keys?
Tap to enlarge
Answer & solution

Answer: 7 in the optimal worst case (no official key was published)

There are 5!=120 possible strict orders, and a binary comparison tree of height six distinguishes at most 64 outcomes. Thus at least seven comparisons are necessary in the worst case. For sufficiency, sort two pairs (two comparisons), compare their larger elements (one), and rename them so a≤b≤d with c≤d. Insert the fifth key into a, b, d in at most two comparisons. Insert c into the prefix preceding d: at most three elements precede d, giving at most four possible positions and two further comparisons. Total: seven. This is a worst-case guarantee; a best-case successful path can be shorter.

Original paper, page 1

2 marks · Other
Report issue

Weighted external path length

Tree Properties & Traversals

Question 1(viii), GATE 1991: Leaves of weights 2, 4, 5, 7 have depth 4; weights 9, 10 have depth 3; weight 15 has depth 1 in the source binary tree. Find its weighted external path length.
Question 1(viii), GATE 1991: Leaves of weights 2, 4, 5, 7 have depth 4; weights 9, 10 have depth 3; weight 15 has depth 1 in the source binary tree. Find its weighted external path length.
Tap to enlarge
Answer & solution

Answer: 144 (no official key was published)

External path length weights each leaf by the number of edges from the root, with root depth zero. Grouping equal depths gives 4(2+4+5+7)+3(9+10)+1(15). The sums are 4×18=72, 3×19=57, and 15, totaling 144. Internal unlabeled nodes contribute nothing to this external measure. Counting vertices instead of edges would add the sum of leaf weights, so the conventional edge-depth definition is essential. The supplied depth list is a transcription of the inspected tree, not a newly constructed tree.

Original paper, page 1

2 marks · Other
Report issue

Inorder traversal of the displayed tree

Tree Properties & Traversals

Question 1(ix), GATE 1991: Root 7 has left child 1 with children 4, 6 and right child 3 with right child 5; node 5 has children 2, 8. Give inorder traversal.
Question 1(ix), GATE 1991: Root 7 has left child 1 with children 4, 6 and right child 3 with right child 5; node 5 has children 2, 8. Give inorder traversal.
Tap to enlarge
Answer & solution

Answer: 4, 1, 6, 7, 3, 2, 5, 8 (no official key was published)

Inorder recursively visits left subtree, node, then right subtree. The subtree rooted at 1 therefore gives 4, 1, 6. Next visit root 7. Node 3 has no left child, so visit 3 immediately, then traverse its right child 5 as 2, 5, 8. Concatenating gives 4, 1, 6, 7, 3, 2, 5, 8. The numeric labels are merely node names; this is not a binary search tree, and sorting the labels would not be a traversal. Every node appears exactly once.

Original paper, page 1

2 marks · Other
Report issue

Recursive Fibonacci call count

Asymptotic Analysis & Recurrences

Question 1(x), GATE 1991: fib(0)=fib(1)=1; for n≥2, fib(n)=fib(n−1)+fib(n−2), using ordinary recursive calls. Count all calls evaluating fib(7), including the initial call.
Question 1(x), GATE 1991: fib(0)=fib(1)=1; for n≥2, fib(n)=fib(n−1)+fib(n−2), using ordinary recursive calls. Count all calls evaluating fib(7), including the initial call.
Tap to enlarge
Answer & solution

Answer: 41 (no official key was published)

Step through it (23 steps)

Let C(n) count function invocations. Each base case requires one call, so C(0)=C(1)=1. A nonbase invocation counts itself plus both recursive subtrees: C(n)=1+C(n−1)+C(n−2). Successive values for n=2, …, 7 are 3, 5, 9, 15, 25, 41. This count includes repeated evaluation of identical arguments, as the supplied recursion does not memoize them. It is different from the numeric return value fib(7)=21; counting only leaves or only additions would also answer a different question.

Original paper, page 1

2 marks · Other
Not in GATE 2027 syllabusReport issue

Registers with minimum operand-memory traffic

Code Generation & Register Allocation

Question 1(xi), GATE 1991: Evaluate (a+b)*c−d/e**f on a two-address machine whose operands may be registers or memory. Minimize operand memory accesses and give the required registers. ** denotes exponentiation.
Question 1(xi), GATE 1991: Evaluate (a+b)*c−d/e**f on a two-address machine whose operands may be registers or memory. Minimize operand memory accesses and give the required registers. ** denotes exponentiation.
Question 1(xi), GATE 1991: Evaluate (a+b)*c−d/e**f on a two-address machine whose operands may be registers or memory. Minimize operand memory accesses and give the required registers. ** denotes exponentiation.
Tap to enlarge
Answer & solution

Answer: 2 registers and 6 input reads, excluding final result storage (no official key was published)

Assume six independent input values initially reside in memory, arithmetic allows a memory source and register destination, and exponentiation is an available operation. Read e into R1 and compute R1:=R1**f; read d into R2 and compute R2:=R2/R1. Reuse R1 for a, then add b and multiply by c; finish R1:=R1−R2. Each of a, b, c, d, e, f is read once, achieving the six-read lower bound. Two registers retain one partial result while forming the other; one register would require a spill or destructive memory temporary and extra traffic. A required final output store adds one access; instruction fetches are not operand accesses.

Original paper, page 1

2 marks · Other
Report issue

Precedence graphs expressible by nested fork/join

Synchronization & Concurrency

Question 1(xii), GATE 1991: What property must a process precedence graph have to be expressed using only properly nested parbegin/parend and sequential composition?
Question 1(xii), GATE 1991: What property must a process precedence graph have to be expressed using only properly nested parbegin/parend and sequential composition?
Tap to enlarge
Answer & solution

Answer: It must admit a series-parallel decomposition (no official key was published)

A sequential composition places every process in one component before every process in the next. A parbegin/parend composition runs its child components independently and joins after all finish. Starting from individual processes and repeatedly applying these two constructions yields the series-parallel class of precedence structures. Conversely, its recursive decomposition directly supplies a nested program. An arbitrary acyclic graph can contain cross-dependencies that cannot be represented by these nested constructs alone without extra synchronization or unnecessary ordering. The statement concerns the precedence relation, allowing omission of redundant transitive edges.

Original paper, page 2

2 marks · Other
Report issue

Triples with sum divisible by three

Combinatorics & Counting

Question 1(xiii), GATE 1991: Count ordered integer triples (i, j, k) with 1≤i, j, k≤300 and i+j+k divisible by 3.
Question 1(xiii), GATE 1991: Count ordered integer triples (i, j, k) with 1≤i, j, k≤300 and i+j+k divisible by 3.
Tap to enlarge
Answer & solution

Answer: 9, 000, 000 (no official key was published)

The interval 1, …, 300 contains exactly 100 representatives of each residue modulo 3. For each ordered pair (i, j), the required residue of k is uniquely −i−j modulo 3, and precisely 100 values of k realize it. There are 300² ordered pairs, so the total is 300²×100=9, 000, 000. Repetitions and different orderings are permitted because these are triples, not three-element subsets. Equivalently, exactly one third of the 300³ triples have residue sum zero. Both bounds are inclusive.

Original paper, page 2

2 marks · Other
Report issue

Partitioning a finite partial order by height

Partial Orders & Lattices

Question 1(xiv), GATE 1991: If a finite partial order has longest chain of n elements, into how many antichains can it be partitioned?
Question 1(xiv), GATE 1991: If a finite partial order has longest chain of n elements, into how many antichains can it be partitioned?
Tap to enlarge
Answer & solution

Answer: n antichains (no official key was published)

Assign each element the maximum number of elements in a chain ending there. Each rank lies between 1 and n. If x<y, appending y to a longest chain ending at x shows rank(y)>rank(x). Therefore elements with equal rank are incomparable and form an antichain; the n rank classes give the desired partition. Conversely, a chain of n elements meets any antichain in at most one element, so fewer than n classes cannot suffice. Here chain length counts elements; if it counted edges the numerical parameter would shift by one.

Original paper, page 2

2 marks · Other
Report issue

Most edges with a fixed component count

Graph Theory

Question 1(xv), GATE 1991: Find the maximum number of edges in an undirected graph with n vertices and k components.
Question 1(xv), GATE 1991: Find the maximum number of edges in an undirected graph with n vertices and k components.
Tap to enlarge
Answer & solution

Answer: (n−k+1)(n−k)/2 for a simple graph (no official key was published)

For component sizes n1, …, nk, simplicity permits at most Σ C(ni, 2) edges, attained by making each component complete. If two component sizes a≥b≥2 occur, transferring a vertex from the smaller to the larger changes the sum by a−b+1>0. Repeating leaves one component of size n−k+1 and k−1 isolated vertices, giving C(n−k+1, 2). This assumes 1≤k≤n and a simple loopless graph. If parallel edges are unrestricted, no finite maximum follows merely from n and k.

Original paper, page 2

2 marks · Other
Report issue

Matching interface standards

Input/Output, DMA & Interrupts

Question 2(i), GATE 1991: Match IEEE488, IEEE796, IEEE696, RS232C to: P single-device connection; Q computer-device interconnection; R instrumentation bus; S Multibus.
Question 2(i), GATE 1991: Match IEEE488, IEEE796, IEEE696, RS232C to: P single-device connection; Q computer-device interconnection; R instrumentation bus; S Multibus.
Tap to enlarge
Answer & solution

Answer: IEEE488–R; IEEE796–S; IEEE696–Q; RS232C–P (no official key was published)

IEEE488 is the general-purpose instrumentation bus used to connect and control measurement equipment. IEEE796 standardizes the Multibus system bus. IEEE696 is the S-100 bus standard, giving the remaining computer-device interconnection association Q. RS232C defines a serial interface conventionally used for a point-to-point connection to one device, giving P. These are historical standard names rather than claims that each phrase is a unique exhaustive definition. Matching the two specific named buses first removes the otherwise broad wording of Q and P.

Original paper, page 2

2 marks · Other
Report issue

Matching 8086 control signals

Input/Output, DMA & Interrupts

Question 2(ii), GATE 1991: Match RQ/GT, LOCK, HOLD, READY with: P retain bus ownership during a critical sequence; Q insert wait states; R maximum-mode bus request/grant; S minimum-mode bus request.
Question 2(ii), GATE 1991: Match RQ/GT, LOCK, HOLD, READY with: P retain bus ownership during a critical sequence; Q insert wait states; R maximum-mode bus request/grant; S minimum-mode bus request.
Question 2(ii), GATE 1991: Match RQ/GT, LOCK, HOLD, READY with: P retain bus ownership during a critical sequence; Q insert wait states; R maximum-mode bus request/grant; S minimum-mode bus request.
Tap to enlarge
Answer & solution

Answer: RQ/GT–R; LOCK–P; HOLD–S; READY–Q (no official key was published)

RQ/GT pins perform the maximum-mode request/grant handshake with another bus master. LOCK indicates that a protected sequence must not be interrupted by granting the bus away. In minimum mode, HOLD requests the bus and the CPU responds with its hold-acknowledge signal. READY lets slower memory or peripherals extend a bus cycle through wait states until data can be transferred safely. Thus ownership negotiation and transfer timing are distinct: READY delays a transaction but does not itself request control of the bus.

Original paper, page 2

2 marks · Other
Report issue

Matching implementation associations

Other / Mixed Topics

Question 2(iii), GATE 1991: Match buddy system, interpretation, virtual memory, pointer with P runtime type checking; Q segmentation; R memory allocation; S garbage collection.
Question 2(iii), GATE 1991: Match buddy system, interpretation, virtual memory, pointer with P runtime type checking; Q segmentation; R memory allocation; S garbage collection.
Tap to enlarge
Answer & solution

Answer: Buddy–R; interpretation–P; virtual memory–Q; pointer–S as the intended associations (no official key was published)

Buddy allocation splits power-of-two blocks and merges free buddies, so R is direct. Segmentation is one way to implement a virtual address space, making Q the intended virtual-memory association. Dynamically typed interpreters commonly check types during execution, suggesting P. Pointer reachability underlies tracing garbage collection, suggesting S. The last three are associations, not necessities: interpreters can execute statically typed languages, virtual memory can use paging rather than segmentation, and pointer-supporting languages need not provide garbage collection. The matching should not be promoted into universal implementation laws.

Original paper, page 2

2 marks · Other
Report issue

Matching combinatorial counts

Combinatorics & Counting

Question 2(iv), GATE 1991: Match A binary trees with n nodes; B length 2n binary strings with n zeros; C even permutations of n objects; D length 6n palindromes with exactly 2n zeros. Choices P=n!/2, Q=C(3n, n), R=C(2n, n), S=C(2n, n)/(n+1).
Question 2(iv), GATE 1991: Match A binary trees with n nodes; B length 2n binary strings with n zeros; C even permutations of n objects; D length 6n palindromes with exactly 2n zeros. Choices P=n!/2, Q=C(3n, n), R=C(2n, n), S=C(2n, n)/(n+1).
Tap to enlarge
Answer & solution

Answer: A–S; B–R; C–P; D–Q under ordered binary-tree and n≥2 conventions (no official key was published)

Ordered binary trees with n nodes satisfy the Catalan recurrence from choosing left and right subtree sizes; its solution is C(2n, n)/(n+1). For B, choose the n zero positions among 2n positions. For C, composing with a fixed transposition pairs even and odd permutations, so each class has n!/2 members when n≥2. An even-length palindrome is determined by its first half. Exactly 2n zeros in length 6n requires n zeros among the first 3n positions, giving C(3n, n). Unordered-tree counting and n=0 or 1 permutation cases require separate conventions.

Original paper, page 2

2 marks · MSQ
Not in GATE 2027 syllabusReport issue

Historical advantage of CMOS

Other / Mixed Topics

Question 3(i), GATE 1991: Which listed advantage does CMOS have over nMOS: lower power, greater speed, smaller chip, fewer masks, none?
Question 3(i), GATE 1991: Which listed advantage does CMOS have over nMOS: lower power, greater speed, smaller chip, fewer masks, none?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A: lower power dissipation in the conventional static comparison (no official key was published)

A static CMOS gate ideally has no direct DC path from supply to ground in a stable logic state: one complementary network is off. Conventional nMOS load logic can draw steady current in one state. This explains the standard lower-static-power advantage. CMOS still consumes dynamic switching power and leakage, so zero real power is not asserted. Speed, area and fabrication-mask count depend on process and circuit design; the other listed claims are not universal advantages established merely by choosing CMOS. The comparison is historical logic-family behavior, not a ranking of every modern implementation.

Original paper, page 3

2 marks · MSQ
Report issue

Clocking and logic hazards

Flip-Flops, Registers & Sequential Circuits

Question 3(ii), GATE 1991: Choose the advantage of synchronous over asynchronous sequential circuits: faster operation, easier hazard avoidance, less hardware, better noise immunity, none.
Question 3(ii), GATE 1991: Choose the advantage of synchronous over asynchronous sequential circuits: faster operation, easier hazard avoidance, less hardware, better noise immunity, none.
Tap to enlarge
Select all that apply
Answer & solution

Answer: B: easier avoidance of hazard-related errors (no official key was published)

A synchronous design samples state on designated clock events. If combinational signals settle and setup/hold constraints are met before those events, intermediate glitches need not become incorrect stored states. This makes hazard management more systematic than in an asynchronous network whose transitions can directly trigger further state changes. The clock does not eliminate glitches or metastability automatically. Nor does synchrony inherently guarantee greater speed, smaller hardware or electrical noise immunity. The advantage is controlled observation time, subject to correct timing design.

Original paper, page 3

2 marks · MSQ
Report issue

What limits a virtual address space

Memory Organization & Address Translation

Question 3(iii), GATE 1991: Which limits total address-space size: MAR width, available secondary storage, main memory, all, none?
Question 3(iii), GATE 1991: Which limits total address-space size: MAR width, available secondary storage, main memory, all, none?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A if MAR means the virtual-address register; terminology needs qualification (no official key was published)

With v virtual-address bits, at most 2v distinct addressable units can be named. Thus the architectural virtual-address width bounds the address space independently of how many pages are resident. Main memory limits residence, while backing storage can limit the amount of committed data, not necessarily the range of legal virtual addresses. The traditional answer A treats MAR as the register carrying that virtual address. If MAR instead denotes the post-translation physical memory-address register, its width bounds physical memory and need not equal the virtual-address width. The source does not make that distinction explicit.

Original paper, page 3

2 marks · MSQ
Report issue

8085 TRAP behavior with differing options

Input/Output, DMA & Interrupts

Question 3(iv), GATE 1991: GFG choices: A hardware RST; B external instruction via INTA; C execute from 20H; D NOP; E none. Forum omits A and relabels the rest. What does TRAP do?
Question 3(iv), GATE 1991: GFG choices: A hardware RST; B external instruction via INTA; C execute from 20H; D NOP; E none. Forum omits A and relabels the rest. What does TRAP do?
Tap to enlarge
Select all that apply
Answer & solution

Answer: A (hardware-vectored restart) (no official key was published)

TRAP is a nonmaskable vectored interrupt. The processor saves the return address and transfers control to its fixed vector 0024H, rather than fetching an instruction supplied by an external device via INTA. Thus 20H and NOP are wrong. The the phrase “executes an RST by hardware” describes that automatic restart-like transfer; it should not be confused with an external RST opcode or the normal software RST vector 20H.

Original paper, page 3

2 marks · MSQ
Report issue

8085 ALE purpose

Input/Output, DMA & Interrupts

Question 3(v), GATE 1991: What does ALE do: latch I/O output, disable chip select, latch address bits AD7–AD0, report TRAP enable status, none?
Question 3(v), GATE 1991: What does ALE do: latch I/O output, disable chip select, latch address bits AD7–AD0, report TRAP enable status, none?
Question 3(v), GATE 1991: What does ALE do: latch I/O output, disable chip select, latch address bits AD7–AD0, report TRAP enable status, none?
Tap to enlarge
Select all that apply
Answer & solution

Answer: C: enable latching of the low-order address (no official key was published)

The 8085 multiplexes the low eight address bits and data on AD7–AD0. Early in a bus cycle those pins carry address bits; afterward they carry data. ALE signals an external latch to capture the address during the address phase so that it remains available while the shared pins change function. It is therefore an address-demultiplexing control, not a general instruction-output latch or interrupt-status signal. The upper address bits have separate pins and do not require this same demultiplexing step.

Original paper, page 3

2 marks · MSQ
Report issue

Kruskal bounds in a multiple-answer question

Graph Algorithms

Question 3(vi), GATE 1991: For n vertices and m edges, choices are A O(n²), B O(mn), C O(m+n), D O(m log n), E O(m²). Identify Kruskal’s complexity.
Question 3(vi), GATE 1991: For n vertices and m edges, choices are A O(n²), B O(mn), C O(m+n), D O(m log n), E O(m²). Identify Kruskal’s complexity.
Tap to enlarge
Select all that apply
Answer & solution

Answer: D is the usual informative bound; B, D, E are valid upper bounds for connected simple graphs (no official key was published)

Comparison-sort Kruskal first sorts m edges in O(m log m), then processes them with disjoint-set operations. For a connected simple graph, n−1≤m≤n(n−1)/2, so log m=O(log n), yielding O(m log n). This supports D. Because big-O is an upper bound, the same algorithm is also O(mn) and O(m²), so B and E cannot be called false merely for being looser in a multiple-answer task. O(m+n) is not the generic comparison-sorting bound; O(n²) does not cover the usual sorting cost for dense arbitrary-weight inputs. Different integer-sorting or presorted-edge models can change the analysis.

Original paper, page 3

2 marks · MSQ
Report issue

Tracing stack operations

Stacks & Queues

Question 3(vii), GATE 1991: Execute PUSH 10, PUSH 20, POP, PUSH 10, PUSH 20, POP, POP, POP, PUSH 20, POP. Options include A20, 10, 20, 10, 20; B20, 20, 10, 10, 20; C10, 20, 20, 10, 20; D20, 20, 10, 20, 10.
Question 3(vii), GATE 1991: Execute PUSH 10, PUSH 20, POP, PUSH 10, PUSH 20, POP, POP, POP, PUSH 20, POP. Options include A20, 10, 20, 10, 20; B20, 20, 10, 10, 20; C10, 20, 20, 10, 20; D20, 20, 10, 20, 10.
Tap to enlarge
Select all that apply
Answer & solution

Answer: B: 20, 20, 10, 10, 20 (no official key was published)

Step through it (12 steps)

After the first two pushes, the stack from bottom to top is [10, 20], so the first pop yields 20. Pushing 10 then 20 leaves [10, 10, 20]; the next three pops yield 20, 10, 10 and empty the stack. The final push/pop yields 20. Concatenating these five outputs gives 20, 20, 10, 10, 20. No pop is attempted on an empty stack. The result follows last-in-first-out order, not the chronological order of pushes as a queue would use.

Original paper, page 3

2 marks · MSQ
Report issue

Integer square-root loop

Correctness, Invariants & Design

Question 3(viii), GATE 1991: GFG initializes i=0 and repeats i:=i+1 while i*i≤N, then returns i. Forum instead prints i*i<N. Determine the return for positive N.
Question 3(viii), GATE 1991: GFG initializes i=0 and repeats i:=i+1 while i*i≤N, then returns i. Forum instead prints i*i<N. Determine the return for positive N.
Question 3(viii), GATE 1991: GFG initializes i=0 and repeats i:=i+1 while i*i≤N, then returns i. Forum instead prints i*i<N. Determine the return for positive N.
Tap to enlarge
Select all that apply
Answer & solution

Answer: B: floor(√N)+1 (no official key was published)

For the non-strict the guard, the loop exits at the smallest integer i whose square exceeds N. That is floor(√N)+1, including a perfect square N=k², which returns k+1. For nonsquares both expressions coincide. For example, N=4 distinguishes 3 from 2. The source change therefore matters and is not a harmless formatting variation. This arithmetic analysis assumes i*i and the increment do not overflow the Pascal integer range.

Original paper, page 3

2 marks · MSQ
Not in GATE 2027 syllabusReport issue

Link-editor responsibility

Compiler Phases, Linking & Loading

Question 3(ix), GATE 1991: A link editor matches external names to definitions in other modules, macro arguments to parameters, subroutine parameters to arguments, or serves as an editor/compiler user interface?
Question 3(ix), GATE 1991: A link editor matches external names to definitions in other modules, macro arguments to parameters, subroutine parameters to arguments, or serves as an editor/compiler user interface?
Tap to enlarge
Select all that apply
Answer & solution

Answer: B: resolve external names across modules (no official key was published)

Separately compiled modules contain symbol definitions and unresolved references to symbols defined elsewhere. The linker combines modules, locates matching definitions, assigns final locations and adjusts references or relocation records. This is the external-name matching described by B. Macro-parameter substitution belongs to macro expansion, and runtime argument passing or compiler checking handles subroutine parameters. The tool’s name does not mean it is an interactive bridge to a text editor. Dynamic linking can defer some resolution, but the semantic task remains symbol binding across modules.

Original paper, page 4

2 marks · MSQ
Not in GATE 2027 syllabusReport issue

Compiler and language claims

Other / Mixed Topics

Question 3(x), GATE 1991: Assess A recursive descent cannot handle left recursion; B postfix is best for optimization; C without recursion/pointers dynamic allocation is unnecessary; D C can simulate call-by-name; E no Pascal feature violates strong typing.
Question 3(x), GATE 1991: Assess A recursive descent cannot handle left recursion; B postfix is best for optimization; C without recursion/pointers dynamic allocation is unnecessary; D C can simulate call-by-name; E no Pascal feature violates strong typing.
Tap to enlarge
Select all that apply
Answer & solution

Answer: A, D in the conventional parser model; C requires extra language restrictions (no official key was published)

Naive recursive descent expands a left-recursive nonterminal before consuming input and recurses indefinitely, so A is true for that standard algorithm; specialized modern techniques are outside this model. Optimization usually needs explicit dataflow such as three-address code or DAGs, not merely postfix order, so B is false. C is not guaranteed: runtime-sized arrays can require dynamic storage even without pointers or recursive calls. D is achievable with thunks, using a function plus captured environment to reevaluate an argument; writable parameters additionally need an lvalue-access mechanism. Historical Pascal variant records can bypass type discipline, refuting E. C is sometimes intended under a restricted static-allocation language model, but that restriction is not stated.

Original paper, page 4

2 marks · MSQ
Report issue

False operating-system claims

Other / Mixed Topics

Question 3(xi), GATE 1991: GFG asks false statements: A virtual memory limited by secondary storage; B critical sections require indivisible instructions such as test-and-set; C monitors ensure no deadlock; D LRU may thrash; E best fit prevents fragmentation. Forum omits C and misprints thrashing as hashing.
Question 3(xi), GATE 1991: GFG asks false statements: A virtual memory limited by secondary storage; B critical sections require indivisible instructions such as test-and-set; C monitors ensure no deadlock; D LRU may thrash; E best fit prevents fragmentation. Forum omits C and misprints thrashing as hashing.
Question 3(xi), GATE 1991: GFG asks false statements: A virtual memory limited by secondary storage; B critical sections require indivisible instructions such as test-and-set; C monitors ensure no deadlock; D LRU may thrash; E best fit prevents fragmentation. Forum omits C and misprints thrashing as hashing.
Tap to enlarge
Select all that apply
Answer & solution

Answer: C and E are false; B is false if it means a special atomic read-modify-write is required; A depends on the memory model (no official key was published)

Monitors enforce mutual exclusion but can still deadlock through circular waits, so C is false. Best fit may leave many tiny holes, so E is false. LRU can thrash when the working set exceeds available frames, so D is true. B needs care: Peterson-style algorithms use atomic reads/writes without test-and-set, refuting a requirement for a special read-modify-write instruction. Yet they still rely on indivisible basic accesses in the usual model, so the broader literal claim about any indivisible instruction is not refuted that way. A conventionally concerns committed backing capacity, not virtual-address-space width. The common intended false set B, C, E is conditional on those readings.

Original paper, page 4

2 marks · MSQ
Report issue

Two tautological implications

Propositional & Predicate Logic

Question 3(xii), GATE 1991: GFG states (F1∧F2)→F3 and (F1∧F2)→¬F3 are tautologies. Choices: both F1, F2 tautologies; their conjunction unsatisfiable; neither tautological; neither satisfiable; none. Forum alters the second formula.
Question 3(xii), GATE 1991: GFG states (F1∧F2)→F3 and (F1∧F2)→¬F3 are tautologies. Choices: both F1, F2 tautologies; their conjunction unsatisfiable; neither tautological; neither satisfiable; none. Forum alters the second formula.
Tap to enlarge
Select all that apply
Answer & solution

Answer: B: F1∧F2 is unsatisfiable (no official key was published)

Suppose a valuation made F1 and F2 both true. The first tautology would then force F3 true, and the second would force F3 false, an impossibility. Thus no such valuation exists and their conjunction is unsatisfiable. This does not require either individual formula to be unsatisfiable: F1=p, F2=¬p is a counterexample to that stronger claim. Nor must both fail to be tautologies; F1=true, F2=false satisfies the premises.

Original paper, page 4

2 marks · MSQ
Report issue

Regular-expression inclusions

Regular Expressions & Languages

Question 3(xiii), GATE 1991: Let r=1(1+0)*, s=11*0, t=1*0. Choose A L(s)⊆L(r) and L(s)⊆L(t); B reverse first inclusion; C L(s)=L(t); D L(t)⊆L(s); E none.
Question 3(xiii), GATE 1991: Let r=1(1+0)*, s=11*0, t=1*0. Choose A L(s)⊆L(r) and L(s)⊆L(t); B reverse first inclusion; C L(s)=L(t); D L(t)⊆L(s); E none.
Tap to enlarge
Select all that apply
Answer & solution

Answer: A (no official key was published)

Every s-word is one or more 1s followed by a single 0. It starts with 1 and has an arbitrary binary suffix, so it belongs to r. It also consists of zero or more 1s followed by 0, so it belongs to t. The inclusions are strict: 1 belongs to r but not s, and 0 belongs to t but not s. These witnesses refute the reverse inclusion and equality choices. Kleene star in 11*0 applies only to the second 1; the mandatory initial 1 is what excludes 0 from s.

Original paper, page 4

2 marks · MSQ
Report issue

Strongest classification of a finite language

Regular Expressions & Languages

Question 3(xiv), GATE 1991: For a finite language over a finite alphabet, choose strongest claim: possibly undecidable, TM-recognizable, context-sensitive, regular, none.
Question 3(xiv), GATE 1991: For a finite language over a finite alphabet, choose strongest claim: possibly undecidable, TM-recognizable, context-sensitive, regular, none.
Tap to enlarge
Select all that apply
Answer & solution

Answer: D: regular (no official key was published)

Write the finite language as{w1, …, wk}. Each fixed word has a regular expression obtained by concatenating its symbols, and their finite union is a regular expression for the whole language. The empty language and words containing ε also fit the regular class. Hence it is regular, which already implies decidability and TM recognizability. Those weaker true classifications are not the strongest requested answer. The proof is existential: it does not claim that an arbitrary description of an unknown finite language makes its entire list immediately computable.

Original paper, page 4

2 marks · Descriptive
Report issue

Replacing a Boolean conditional assignment

Control Flow & Loop Tracing

Question 4(i), GATE 1991: Replace Pascal if x>5 then y:=true else y:=false with one assignment.
Question 4(i), GATE 1991: Replace Pascal if x>5 then y:=true else y:=false with one assignment.
Tap to enlarge
Answer & solution

Answer: y := (x > 5); (no official key was published)

The comparison x>5 evaluates to a Boolean. In the true case, the original statement assigns true to y; in the false case, it assigns false. Assigning the comparison result therefore gives exactly the same value in both cases. At x=5, the result is false, so using ≥ instead would be incorrect. This simplification assumes y has Boolean type and the comparison has the ordinary Pascal semantics shown in the source. No branch or numeric Boolean encoding is needed.

Original paper, page 5

2 marks · Descriptive
Report issue

Converting repeat-until to while

Control Flow & Loop Tracing

Question 4(ii), GATE 1991: Rewrite Pascal repeat S until B using a while construct with equivalent behavior.
Question 4(ii), GATE 1991: Rewrite Pascal repeat S until B using a while construct with equivalent behavior.
Tap to enlarge
Answer & solution

Answer: begin S; while not B do S end (no official key was published)

A repeat loop executes S before checking B, so S runs at least once. Execute S once explicitly, then test not B in the while guard. Whenever B remains false, execute S again; stop immediately after an iteration makes B true. Merely writing while not B do S would incorrectly permit zero executions when B starts true. This transformation preserves the sequence of evaluations of B after executions of S, including ordinary side effects in the condition. If S is a multi-statement sequence, it must be grouped as a Pascal compound statement.

Original paper, page 5

2 marks · Descriptive
Report issue

Optimal search tree for three equally likely identifiers

Binary Search & Balanced Trees

Question 4(iii), GATE 1991: Construct an optimal binary search tree for ordered identifiers if, stop, while with equal successful-search probabilities.
Question 4(iii), GATE 1991: Construct an optimal binary search tree for ordered identifiers if, stop, while with equal successful-search probabilities.
Tap to enlarge
Answer & solution

Answer: Root stop; left child if; right child while (no official key was published)

The alphabetic order is if<stop<while. Placing the middle identifier at the root preserves search-tree ordering with the other two as its children. Successful search takes one comparison at the root and two at either child, for mean (1+2+2)/3=5/3. Any endpoint root forces the remaining two into one subtree, creating depths corresponding to comparison counts 1, 2, 3 and mean 2. Thus the balanced tree is optimal. The calculation uses equal successful-search probabilities; unspecified unequal unsuccessful-search gap weights would define a different optimization problem.

Original paper, page 5

2 marks · Descriptive
Report issue

Subsets of a complete consistent axiom system

Propositional & Predicate Logic

Question 4(iv), GATE 1991: If a finite axiom system A is complete and consistent for a theory, is every subsystem also complete and consistent? Explain.
Question 4(iv), GATE 1991: If a finite axiom system A is complete and consistent for a theory, is every subsystem also complete and consistent? Explain.
Tap to enlarge
Answer & solution

Answer: Consistency is inherited; completeness need not be (no official key was published)

Let B⊆A. Any proof from B is also a proof from A, since all its premises remain available. If B derived a contradiction, so would A; therefore every subsystem is consistent. Completeness does not follow because removing an essential axiom can remove the ability to decide a sentence. For example, in propositional logic over a single atom p, the axiom set{p} is consistent and complete for truth-functional formulas over p, whereas the empty subsystem proves neither p nor ¬p. Redundant-axiom removal may preserve completeness, but arbitrary removal need not. The claim does not require an impossible complete arithmetic theory.

Original paper, page 5

4 marks · Descriptive
Report issue

Feedback majority circuit

Flip-Flops, Registers & Sequential Circuits

Question 5(a), GATE 1991: Three two-input AND gates form aQ, ab and bQ; their outputs feed a three-input OR whose output Q is fed back to the first and third AND gates. Complete the output table for inputs ab=00,01,10,11, allowing for the prior stable output.
Tap to enlarge
Answer & solution

Answer: 00→0; 01→previous Q; 10→previous Q; 11→1. (no official key was published)

Denote the previously stable feedback value by Q_old. Reading each gate gives Q_new = aQ_old + ab + bQ_old. This is the majority function of a, b and Q_old, not a memoryless two-input gate.

For a=b=0 all three products vanish, so the circuit resets to 0. For a=0,b=1 only bQ_old remains, so the old output is retained. For a=1,b=0 only aQ_old remains, also retaining the old value. For a=b=1 the middle product ab forces 1 irrespective of the old state. Thus the requested table, in row order 00,01,10,11, is 0,Q_old,Q_old,1.

A connection schematic is: AND(a,Q) ┐; AND(a,b) ├→ OR → Q; AND(b,Q) ┘, with Q returned to the indicated inputs. This is a two-input Muller C-element: equal inputs update the state, unequal inputs hold it. Without an initial condition the held value cannot be replaced by a numerical zero or one. The table describes settled behavior and does not assert that arbitrary simultaneous input changes are hazard-free.

Original paper, page 5

4 marks · Descriptive
Report issue

Minimum sum of products with don’t-cares

Logic Minimization & Karnaugh Maps

Question 5(b), GATE 1991: Find a minimum SOP for f(A,B,C,D)=Σm(0,2,8,10,15)+Σd(3,11,12,14), with A the most significant bit.
Question 5(b), GATE 1991: Find a minimum SOP for f(A,B,C,D)=Σm(0,2,8,10,15)+Σd(3,11,12,14), with A the most significant bit.
Tap to enlarge
Answer & solution

Answer: f = B′D′ + AC (two products, four literals). (no official key was published)

Step through it (12 steps)

Place the mandatory ones at 0,2,8,10,15 in the four-variable Karnaugh map, mark 3,11,12,14 as optional, and treat all other cells as zeros. The group {0,2,8,10} fixes B=0,D=0 while A,C vary, producing B′D′. The group {10,11,14,15} fixes A=1,C=1, producing AC; its cells 11 and 14 are permitted don’t-cares. The union covers every mandatory one and no mandatory zero.

For minimality, a single implicant containing both 0=0000 and 15=1111 would leave all four bits free and cover forbidden zeros. Therefore at least two product terms are necessary. No one-literal implicant is legal: each half of the truth table contains at least one mandatory zero. Hence each nonzero product needs at least two literals, and two products need at least four literals. Our expression meets both lower bounds.

Don’t-cares are permissions to choose values that simplify the implementation, not required ones. For example this solution sets 3 and 12 to zero, which is allowed. Check the seven mandatory-zero cells as well as the five mandatory-one cells; checking only the specified ones would not establish equivalence.

Original paper, page 5

2 marks · Descriptive
Report issue

Synchronous counter timing path

Counters & Timing

Question 5(c), GATE 1991: Three JK flip-flops Q0,Q1,Q2 share a clock. J0=K0=1. Cascaded two-input ANDs compute C1=1·Q0, C2=C1·Q1, C3=C2·Q2; J1=K1=C1 and J2=K2=C2. C3 is an outgoing carry with no shown destination. Flip-flop and AND delays are each 10 ns; setup time is negligible. Find maximum counter clock frequency.
Tap to enlarge
Answer & solution

Answer: Shown register-to-register path: Tmin=30 ns, fmax≈33.33 MHz. Requiring final carry settlement adds a separate 40 ns/25 MHz condition. (no official key was published)

This is a synchronous counter, since all three flip-flops receive the same clock. It is not a three-stage ripple-clock chain. After an active edge, Q0 may change after 10 ns. Its new value reaches C1 after one AND delay and C2 after a second AND delay. The latest JK input of a shown flip-flop therefore settles after 10+10+10=30 ns. With negligible setup time the next active edge must be no earlier, giving fmax=1/(30 ns)=33⅓ MHz.

The path from Q1 to C2 takes only 20 ns. Q2 does not drive another displayed flip-flop. The third AND produces C3 only after as much as 40 ns from the clock, but that carry output is not connected to a register input in the displayed three-bit circuit. Counting it in the counter’s internal feedback constraint would assume an additional stage or external timing requirement.

If the question intends the outgoing carry to settle before every next edge, or the drawing is an expandable counter whose next stage samples C3, use Tmin=40 ns and fmax=25 MHz instead. State that additional condition explicitly. Clock skew, hold-time constraints and wire delays are outside the supplied delay model.

Original paper, page 5

5 marks · Descriptive
Report issue

Three-bit parallel-load shift register

Flip-Flops, Registers & Sequential Circuits

Question 6(a), GATE 1991: Using D flip-flops and gates, design a three-bit parallel-in/serial-out register shifting left to right. Inputs: CLK, parallel A,B,C; serial input S; LOAD/SHIFT control.
Tap to enlarge
Answer & solution

Answer: For L=1 load: D0=LA+L′S, D1=LB+L′Q0, D2=LC+L′Q1; serial output Q2. (no official key was published)

Let Q0,Q1,Q2 be the stored bits from left to right. Define L=1 as LOAD and L=0 as SHIFT, consistent with the uncomplemented LOAD and complemented SHIFT label. Place a 2:1 multiplexer before each D flip-flop and connect all three clock pins to CLK.

Connection schematic

A ─load─┐   B ─load─┐    C ─load─┐
S ─shift┴MUX→DFF Q0 ─shift┴MUX→DFF Q1 ─shift┴MUX→DFF Q2→OUT

Each MUX uses L as select; all DFFs use the same active clock edge.

The gate equations are D0=(L AND A) OR (NOT L AND S), D1=(L AND B) OR (NOT L AND Q0), D2=(L AND C) OR (NOT L AND Q1). Implement each mux with two AND gates and one OR gate, sharing an inverter for L.

On a load edge the state becomes (A,B,C). On successive shift edges it becomes (S1,A,B), then (S2,S1,A), then (S3,S2,S1). The bits shifted out, measured just before those edges, are C,B,A. All right-hand sides use the old state because the flip-flops update together; using the newly updated Q0 to compute Q1 would incorrectly move a bit through several stages in one clock. An asynchronous reset is optional, not required for loading.

Original paper, page 5

5 marks · Descriptive
Report issue

RAM-based 1024-bit serial delay

Flip-Flops, Registers & Sequential Circuits

Question 6(b), GATE 1991: Design a 1024-bit serial-in/serial-out unidirectional shift register using a 1K×1 RAM with Din,Dout and READ/WRITE control, plus standard gates, registers and counters.
Tap to enlarge
Answer & solution

Answer: Use a modulo-1024 address counter and read-before-write phases: capture old RAM[p] as output, overwrite RAM[p] with input, then advance p. (no official key was published)

A literal shift of all 1024 RAM cells on every bit would be wasteful. Instead, regard the RAM as a circular queue. Use a 10-bit binary counter p connected to RAM address A9..A0, an input holding flip-flop I, an output flip-flop O, and a two-phase controller.

Schematic

serial IN→I→RAM Din; counter p[9:0]→RAM address; RAM Dout→O→serial OUT.
Controller→{I clock, RAM READ/WRITE, O clock, counter enable}.

For each external shift event: (1) latch the incoming bit in I and keep p stable; (2) select READ, wait for RAM access time, and clock Dout into O; (3) select WRITE and store I at the same p, meeting write pulse/setup/hold timing; (4) return to READ and increment p modulo 1024. The output must be captured before the write, since the RAM’s read-during-write behavior is not specified.

After initialization, address p holds the oldest of the 1024 retained bits. Reading emits that bit, overwriting appends the new bit, and incrementing makes the next-oldest location the head. Inductively, input bit s[k] is emitted on shift event k+1024, where an event’s output means the bit removed on that event. The first 1024 outputs depend on the RAM’s initial contents. To emulate a reset-to-zero shift register, clear every RAM location during a separate initialization sweep. The external shift period must accommodate both the read and write phases.

Original paper, page 5

4 marks · Descriptive
Report issue

Fetch and indexed effective-address transfers

Datapath & Control Unit

Question 7(a), GATE 1991: A single-address CPU has 16-bit instructions; the low 8 bits are the operand-address field. Design a hardwired fetch cycle which also forms the effective address for an indexed instruction. The reproduction does not specify memory word size, address width, index-mode encoding, or a memory-ready protocol. Give register transfers.
Question 7(a), GATE 1991: A single-address CPU has 16-bit instructions; the low 8 bits are the operand-address field. Design a hardwired fetch cycle which also forms the effective address for an indexed instruction. The reproduction does not specify memory word size, address width, index-mode encoding, or a memory-ready protocol. Give register transfers.
Question 7(a), GATE 1991: A single-address CPU has 16-bit instructions; the low 8 bits are the operand-address field. Design a hardwired fetch cycle which also forms the effective address for an indexed instruction. The reproduction does not specify memory word size, address width, index-mode encoding, or a memory-ready protocol. Give register transfers.
Tap to enlarge
Answer & solution

Answer: MAR←PC; read instruction; IR←MDR, PC←PC+1; EA←zero_extend(IR[7:0])+(indexed?X:0), for word-addressed memory. (no official key was published)

Use a word-addressed memory returning one 16-bit instruction per access, an address-width w≥8, PC, MAR, MDR, IR, index register X and effective-address register EA. Let I be the decoded indexed-mode condition, and Z(IR[7:0]) the zero-extended address field. These are explicit implementation assumptions, not facts supplied by the question.

T0: MAR←PC.
T1: assert memory READ; wait until READY; MDR←M[MAR].
T2: IR←MDR; PC←PC+1.
T3: EA←Z(IR[7:0]) + (I ? X : 0), modulo 2w; finish fetch.

The operand field must come from the newly loaded IR, so effective-address formation follows T2. PC increment is independent of indexing: indexing modifies the operand address, not the address of the next instruction. The index flag is obtained from the instruction’s opcode/mode decoding; assigning it a particular bit without specification would be unjustified.

If memory is byte-addressed with an 8-bit data bus, use two reads, assemble the two bytes according to the selected endianness, and advance PC by two instead. If memory has a fixed guaranteed cycle, the READY self-loop can be replaced by the corresponding fixed number of timing states. These implementation variants do not change the essential separation of fetch, decode and address formation.

Original paper, page 5

6 marks · Descriptive
Report issue

Hardwired fetch controller and datapath

Datapath & Control Unit

Question 7(b), GATE 1991: A single-address CPU has 16-bit instructions; the low 8 bits are the operand-address field. Design a hardwired fetch cycle which also forms the effective address for an indexed instruction. The reproduction does not specify memory word size, address width, index-mode encoding, or a memory-ready protocol. Draw the controller logic and datapath.
Question 7(b), GATE 1991: A single-address CPU has 16-bit instructions; the low 8 bits are the operand-address field. Design a hardwired fetch cycle which also forms the effective address for an indexed instruction. The reproduction does not specify memory word size, address width, index-mode encoding, or a memory-ready protocol. Draw the controller logic and datapath.
Question 7(b), GATE 1991: A single-address CPU has 16-bit instructions; the low 8 bits are the operand-address field. Design a hardwired fetch cycle which also forms the effective address for an indexed instruction. The reproduction does not specify memory word size, address width, index-mode encoding, or a memory-ready protocol. Draw the controller logic and datapath.
Tap to enlarge
Answer & solution

Answer: A four-state hardwired sequencer drives PC/MAR/memory/MDR/IR and an indexed-address adder; READY holds the read state. (no official key was published)

Use a word-addressed memory returning one 16-bit instruction per access, an address-width w≥8, PC, MAR, MDR, IR, index register X and effective-address register EA. Let I be the decoded indexed-mode condition, and Z(IR[7:0]) the zero-extended address field. These are explicit implementation assumptions, not facts supplied by the question.

T0: MAR←PC.
T1: assert memory READ; wait until READY; MDR←M[MAR].
T2: IR←MDR; PC←PC+1.
T3: EA←Z(IR[7:0]) + (I ? X : 0), modulo 2w; finish fetch.

The operand field must come from the newly loaded IR, so effective-address formation follows T2. PC increment is independent of indexing: indexing modifies the operand address, not the address of the next instruction. The index flag is obtained from the instruction’s opcode/mode decoding; assigning it a particular bit without specification would be unjustified.

If memory is byte-addressed with an 8-bit data bus, use two reads, assemble the two bytes according to the selected endianness, and advance PC by two instead. If memory has a fixed guaranteed cycle, the READY self-loop can be replaced by the corresponding fixed number of timing states. These implementation variants do not change the essential separation of fetch, decode and address formation.

Datapath schematic

PC ─→ MAR ─address→ MEMORY ─data→ MDR ─→ IR
PC ─→ incrementer(+1) ─→ PC
IR[7:0] ─→ zero extend ─→ ADDER ─→ EA
X ─→ MUX(X or 0, select I) ─→ ADDER
IR[15:8] ─→ opcode/mode decoder ─→ I

Implement a one-hot sequencer S0,S1,S2,S3 with reset S0=1. Its next-state equations during fetch are S1_next=S0 OR (S1 AND NOT READY), S2_next=S1 AND READY, S3_next=S2; S0_next is asserted on the next fetch request rather than during instruction execution. The final S3 pulse transfers control to execution. Reset and start gating should prevent simultaneous states.

Control outputs: LD_MAR=S0; MEM_READ=S1; LD_MDR=S1 AND READY; LD_IR=S2; INC_PC=S2; LD_EA=S3; FETCH_DONE=S3. Each state’s loads occur at its ending clock edge. The adder’s second input selects X only when I=1. A two-bit state register plus a decoder is an equivalent SSI/MSI implementation. No control ROM is needed: Boolean gates decode state and instruction bits. The READY condition must obey the controller clock’s synchronization requirements.

Original paper, page 5

Descriptive
Report issue

8085 immediate OR timing

Instructions & Addressing Modes

Question 8(a.i), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for printed “ORI A,22”.
Question 8(a.i), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for printed “ORI A,22”.
Question 8(a.i), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for printed “ORI A,22”.
Tap to enlarge
Answer & solution

Answer: 9 T-states = 3 μs, interpreting the printed mnemonic as 8085 ORI immediate. (no official key was published)

The 8085 divides the external crystal frequency by two, giving a 3 MHz processor clock. Therefore one T-state lasts 1/3 μs, not 1/6 μs.

8085 ORI immediate is a two-byte instruction: an opcode-fetch cycle of 4 T-states and an immediate-data memory-read cycle of 3 T-states. With PC=0200H, both bytes, at 0200H and 0201H, lie in ROM. Each access adds one wait state. Total time is (4+1)+(3+1)=9 T-states, or 9/(3 MHz)=3 μs.

The accumulator’s original value affects the logical result but not this timing. The other general-purpose registers and the stack pointer are unused. The printed “ORI A,22” is not the conventional 8085 syntax, which writes only the immediate operand, e.g. ORI 22H. The implicit destination is always A. Whether the literal 22 is decimal or hexadecimal does not alter the cycle count. Treating it as register ORA A would incorrectly discard the immediate-byte read.

Original paper, page 6

Descriptive
Report issue

8085 memory decrement timing

Instructions & Addressing Modes

Question 8(a.ii), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for DCR M.
Question 8(a.ii), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for DCR M.
Question 8(a.ii), GATE 1991: 8085 system: crystal 6 MHz; ROM 0000H–07FFH needs one wait state per access; RAM 1000H–17FFH needs none. Initially A=55H,B=AAH,C=F7H,D=10H,H=10H,L=FFH,PC=0200H,SP=17F0H, separately for each instruction. Find the instruction time for DCR M.
Tap to enlarge
Answer & solution

Answer: 11 T-states = 11/3 μs ≈3.667 μs. (no official key was published)

The processor clock is 6 MHz/2=3 MHz, so a T-state is 1/3 μs. DCR M decrements the memory byte addressed by HL. It performs a 4-T opcode fetch, a 3-T memory read, and a 3-T memory write, for a nominal 10 T-states.

The opcode address PC=0200H is in ROM, adding one wait state. The operand address is HL=10FFH, obtained by concatenating H=10H and L=FFH. This lies in RAM’s 1000H–17FFH range, so neither the operand read nor the write adds a wait. Thus the total is (4+1)+3+3=11 T-states, or 11/3 μs≈3.667 μs.

“M” does not mean an immediate byte following the opcode; it is the indirect-memory operand at HL. The byte’s value was not specified, but every value uses the same timing. Nor is the ROM wait charged to every machine cycle merely because the program executes from ROM: each cycle’s addressed memory device determines its own wait requirement. The instruction changes arithmetic flags except carry, which is immaterial to the timing calculation.

Original paper, page 6

6 marks · Descriptive
Report issue

8085 output handshake and block transfer

Input/Output, DMA & Interrupts

Question 8(b), GATE 1991: Design an SSI/MSI interface for an 8085 with demultiplexed addresses. OUT 40H writes an output byte; IN 40H reads INTERRUPT in bit 7 and BUFFULL in bit 0. In the supplied timing diagram active-low write assertion clears INTERRUPT; write completion latches new data and sets BUFFULL. Device active-low STROBE assertion clears BUFFULL; STROBE completion sets INTERRUPT. Supply a block schematic and program transferring 200H bytes starting at memory 3400H.
Question 8(b), GATE 1991: Design an SSI/MSI interface for an 8085 with demultiplexed addresses. OUT 40H writes an output byte; IN 40H reads INTERRUPT in bit 7 and BUFFULL in bit 0. In the supplied timing diagram active-low write assertion clears INTERRUPT; write completion latches new data and sets BUFFULL. Device active-low STROBE assertion clears BUFFULL; STROBE completion sets INTERRUPT. Supply a block schematic and program transferring 200H bytes starting at memory 3400H.
Tap to enlarge
Answer & solution

Answer: Decode I/O address 40H, use an output latch, handshake flags and status tri-state buffer; poll bit 7 before each of 512 OUT operations. (no official key was published)

Use an 8-bit equality decoder for address 40H gated by IO/M=1. Let SEL denote that I/O decode. Form /W=NOT(SEL AND NOT /WR) and /R=NOT(SEL AND NOT /RD). Thus memory access at 0040H cannot accidentally activate the port. The shared address is safe because read and write select different circuitry.

Schematic

A[7:0],IO/M → address decoder → SEL → /W, /R gating.
CPU D[7:0] → 8-bit latch (transparent while /W=0) → DEVICE DATA.
/W falling → clear INTERRUPT; /W rising → close data latch, set BUFFULL.
/STROBE falling → clear BUFFULL; /STROBE rising → set INTERRUPT.
{INTERRUPT,0,0,0,0,0,0,BUFFULL} → tri-state buffer, enabled only by /R=0 → CPU data bus.

One implementation uses a BUFFULL D flip-flop with D=1 clocked by rising /W and asynchronously cleared while /STROBE=0. INTERRUPT uses D=1 clocked by rising /STROBE and asynchronously cleared while /W=0. Initialize BUFFULL=0 and INTERRUPT=1 when the device is ready. The external handshake must avoid overlapping write/acknowledge pulses that violate the flip-flops’ recovery times. Device data is stable after write completion and held until a later write. The timing diagram’s arrows refer to these separate leading/trailing edges, not merely inverse full/empty flags.

8085 program (hexadecimal literals):
    LXI H,3400H
    LXI B,0200H
WAIT_READY:
    IN 40H
    ANI 80H
    JZ WAIT_READY
    MOV A,M
    OUT 40H
    INX H
    DCX B
    MOV A,B
    ORA C
    JNZ WAIT_READY
WAIT_LAST:
    IN 40H
    ANI 80H
    JZ WAIT_LAST

BC counts 512 bytes; HL visits 3400H through 35FFH. The source RAM region for this subproblem must exist; it is independent of the smaller RAM map specified in part (a). Testing bit 7 waits for completion of the device strobe, whereas bit 0 can clear earlier at strobe assertion. The final loop waits for the last acknowledgement rather than returning with the final byte merely buffered. There is no timeout in this minimal program, so a nonresponsive device blocks indefinitely. Reading the status port does not clear either flag.

Original paper, page 6

Descriptive
Report issue

Call by value with an expression argument

Runtime Environments & Parameter Passing

Question 9(a.i), GATE 1991: All variables are integers. Procedure P(a,b,c) executes a:=2; c:=a+b. Main executes x:=1; y:=5; z:=100; P(x,x*y,z); write(x,z). Determine the output for call by value.
Question 9(a.i), GATE 1991: All variables are integers. Procedure P(a,b,c) executes a:=2; c:=a+b. Main executes x:=1; y:=5; z:=100; P(x,x*y,z); write(x,z). Determine the output for call by value.
Tap to enlarge
Answer & solution

Answer: x=1, z=100. (no official key was published)

With call by value, evaluate the actual arguments in the caller before entering P: x yields 1, x*y yields 5, and z yields 100. Allocate independent local formals with values (a,b,c)=(1,5,100).

The assignment a:=2 changes only the local a. Next c:=a+b computes 2+5=7 and places it in the local c. Neither assignment targets the caller’s variables, so after return x remains 1, y remains 5, and z remains 100. The main program prints x=1,z=100.

The intermediate c=7 is not the value printed by the program: the print is outside P and names z. Ordinary call by value has no copy-out stage. Adding copy-out would change the parameter mechanism to value-result, which is a different question. Evaluating the expression x*y once at the call is crucial for distinguishing this case from call by name.

Original paper, page 6

Descriptive
Report issue

Reference parameters and expression actuals

Runtime Environments & Parameter Passing

Question 9(a.ii), GATE 1991: All variables are integers. Procedure P(a,b,c) executes a:=2; c:=a+b. Main executes x:=1; y:=5; z:=100; P(x,x*y,z); write(x,z). Determine the output for call by reference, stating any validity assumption.
Question 9(a.ii), GATE 1991: All variables are integers. Procedure P(a,b,c) executes a:=2; c:=a+b. Main executes x:=1; y:=5; z:=100; P(x,x*y,z); write(x,z). Determine the output for call by reference, stating any validity assumption.
Tap to enlarge
Answer & solution

Answer: Strict reference-only actuals: invalid call, no defined output. If expression actuals are materialized in a temporary: x=2,z=7. (no official key was published)

Pure call by reference binds each formal to an assignable storage location. The actuals x and z have such locations, but x*y is an arithmetic expression and has no variable location to which a conventional reference formal can bind. Thus in a language requiring variable actuals for reference parameters, this call is rejected and there is no output. This is an important qualification to the otherwise familiar textbook calculation.

If the intended pseudo-language permits an expression actual by evaluating it into a temporary, evaluate x*y=1·5=5 at call entry and bind b to that temporary. Bind a directly to x and c directly to z. Executing a:=2 sets x to 2. The temporary b remains 5; it is not a live expression. Then c:=a+b sets z=2+5=7. On return the program prints x=2,z=7.

The temporary convention is sufficient here because P never assigns to b. It is nevertheless an additional semantic rule, not inherent in reference passing. In particular, re-evaluating x*y after changing x would give 10 and would implement call by name rather than this temporary-backed reference convention.

Original paper, page 6

Descriptive
Report issue

Call by name re-evaluates the expression

Runtime Environments & Parameter Passing

Question 9(a.iii), GATE 1991: All variables are integers. Procedure P(a,b,c) executes a:=2; c:=a+b. Main executes x:=1; y:=5; z:=100; P(x,x*y,z); write(x,z). Determine the output for call by name.
Question 9(a.iii), GATE 1991: All variables are integers. Procedure P(a,b,c) executes a:=2; c:=a+b. Main executes x:=1; y:=5; z:=100; P(x,x*y,z); write(x,z). Determine the output for call by name.
Tap to enlarge
Answer & solution

Answer: x=2,z=12. (no official key was published)

Call by name delays evaluation of an actual argument until its formal is used, in the caller’s environment. Think of a as a getter/setter for x, b as a thunk returning x*y, and c as a getter/setter for z. The caller’s x and y, not unrelated locals inside P, are the names captured by b’s thunk.

The first statement a:=2 follows the location associated with x and changes x from 1 to 2. The next statement c:=a+b first obtains a=2 and evaluates b’s expression using the current caller state: x*y=2·5=10. It therefore writes 12 through c into z. After return, main prints x=2,z=12.

A textual substitution illustrates this particular collision-free example: x:=2; z:=x+x*y. General call-by-name implementations must preserve environments and avoid accidental name capture, so literal substitution is only an explanatory model. The difference from temporary-backed reference passing is that b is not frozen at its original value 5. The nonassignability of x*y does not prevent this example’s by-name use because b is only read, never assigned.

Original paper, page 6

Descriptive
Report issue

Lexical scope selects declaration context

Runtime Environments & Parameter Passing

Question 9(b.i), GATE 1991: Global integers a,b; procedure P sets a:=5;b:=10. Procedure Q declares its own local integers a,b and calls P. Main sets global a:=1;b:=2, calls Q, then prints global a,b. Give output under static scope.
Question 9(b.i), GATE 1991: Global integers a,b; procedure P sets a:=5;b:=10. Procedure Q declares its own local integers a,b and calls P. Main sets global a:=1;b:=2, calls Q, then prints global a,b. Give output under static scope.
Tap to enlarge
Answer & solution

Answer: a=5,b=10. (no official key was published)

Under static, or lexical, scope, a nonlocal name is resolved by the source program’s nesting structure. P is declared at global level, alongside Q, rather than inside Q. The closest enclosing declarations for the a and b used in P are therefore the global variables.

Main first assigns those global variables (1,2). Q then creates a fresh activation containing its own local a,b. Although Q calls P, Q’s locals are not lexically enclosing declarations of P. P’s assignments update the globals to (5,10), leaving Q’s locals untouched. Q returns and its activation disappears. Main then prints the global values a=5,b=10.

A useful implementation view is that P’s static link identifies the global environment, independent of which procedure called it. The existence of same-spelled variables in the caller does not change this link. Their uninitialized values are irrelevant because P never reads or writes them under static scoping.

Original paper, page 6

Descriptive
Report issue

Dynamic scope selects the active caller

Runtime Environments & Parameter Passing

Question 9(b.ii), GATE 1991: Global integers a,b; procedure P sets a:=5;b:=10. Procedure Q declares its own local integers a,b and calls P. Main sets global a:=1;b:=2, calls Q, then prints global a,b. Give output under dynamic scope.
Question 9(b.ii), GATE 1991: Global integers a,b; procedure P sets a:=5;b:=10. Procedure Q declares its own local integers a,b and calls P. Main sets global a:=1;b:=2, calls Q, then prints global a,b. Give output under dynamic scope.
Tap to enlarge
Answer & solution

Answer: a=1,b=2. (no official key was published)

Dynamic scope resolves a free name by searching the active call chain from the current activation outward. During P, the chain is P→Q→main/global. P has no local a or b; the nearest active bindings are Q’s local a,b. Hence P’s assignments set Q’s variables to (5,10), rather than modifying the globals.

The globals were initialized to (1,2) by main and are still (1,2) when Q returns. Q’s locals disappear with its activation, and the final print in main uses the globals. The output is a=1,b=2.

No undefined read is caused by Q’s initially uninitialized locals: P overwrites them before they could be read, and the final print occurs after they are out of scope. Dynamic scoping must not be confused with dynamic memory allocation or call-by-reference parameter passing. It is a rule for selecting which binding an identifier denotes; the assignment operation itself is unchanged.

Original paper, page 6

2 marks · Descriptive
Report issue

Expression grammar precedence and ambiguity

Parsing & Syntax Analysis

Question 10(a), GATE 1991: For arithmetic expressions using binary, mathematically nonassociative operators minus and division, the start symbol is E and the grammar is E→E−T | T; T→T/F | F; F→(E) | id. Is it unambiguous? If so state relative precedence; otherwise provide an unambiguous grammar giving division higher precedence.
Question 10(a), GATE 1991: For arithmetic expressions using binary, mathematically nonassociative operators minus and division, the start symbol is E and the grammar is E→E−T | T; T→T/F | F; F→(E) | id. Is it unambiguous? If so state relative precedence; otherwise provide an unambiguous grammar giving division higher precedence.
Tap to enlarge
Answer & solution

Answer: Unambiguous; / has higher precedence than −, and each operator is parsed left-associatively. (no official key was published)

The grammar separates expression levels: E combines terms with minus, while T combines factors with division. Thus id−id/id parses as id−(id/id), never as (id−id)/id. Division has higher precedence than subtraction.

Both recursive productions are left-recursive, so unparenthesized chains group to the left. For example id−id−id has structure (id−id)−id, and id/id/id has structure (id/id)/id. This is a syntactic associativity convention; it does not claim the arithmetic operators obey an associative law.

For uniqueness, consider an expression outside its matched parentheses. If it has a top-level minus, the root must be E→E−T, split at its last such minus because T cannot contain an unparenthesized minus. If there is no such minus, use E→T. Similarly a top-level slash in a term forces T→T/F split at its last top-level slash, since F cannot contain an unparenthesized slash. At the factor level, either the token is id or the uniquely matched outer parentheses contain an expression, to which the same argument applies. Induction on expression length gives a unique parse. Redundant parentheses are allowed by the grammar, but do not create two parses for the same token string.

Original paper, page 7

4 marks · Descriptive
Report issue

Generate only necessary expression parentheses

Parsing & Syntax Analysis

Question 10(b), GATE 1991: For arithmetic expressions using binary, mathematically nonassociative operators minus and division, the start symbol is E and the grammar is E→E−T | T; T→T/F | F; F→(E) | id. Does it permit redundant parentheses such as (id/id) and id−(id/id)? Modify it to eliminate redundant parentheses, making minimal changes and adding at most one production rule.
Question 10(b), GATE 1991: For arithmetic expressions using binary, mathematically nonassociative operators minus and division, the start symbol is E and the grammar is E→E−T | T; T→T/F | F; F→(E) | id. Does it permit redundant parentheses such as (id/id) and id−(id/id)? Modify it to eliminate redundant parentheses, making minimal changes and adding at most one production rule.
Tap to enlarge
Answer & solution

Answer: Yes. E→T|S; S→E−T|E−(S); T→id|T/F|(S)/F; F→id|(S)|(T/F)|((S)/F). Only the production group S is added. (no official key was published)

The original grammar allows both examples through F→(E). Deleting parentheses must be judged by preservation of the parse tree under / precedence and left associativity, not accidental numerical identities for particular values. Parentheses are needed around a subtraction in either operand of division, around a division in the right operand of division, and around a subtraction in the right operand of subtraction. They are not needed around a whole expression, a single id, a left operand at equal precedence, or a division used as a subtraction operand.

Use the following four-nonterminal grammar:
E→T | S
S→E−T | E−(S)
T→id | T/F | (S)/F
F→id | (S) | (T/F) | ((S)/F)

S is exactly subtraction-rooted, while T/F and (S)/F together are exactly division-rooted. This grammar generates every binary expression tree with no removable parenthesis pair. F appears only after /, preventing redundant outer parentheses. Examples: it generates id−(id−(id−id)) and id/((id−id)/id), but rejects (id/id), id−(id/id), (id), and ((id−id))/id. The source’s “one more production rule” is interpreted in the common sense of one more nonterminal production group: only S is added to E,T,F. All three original groups must change to prevent the old whole-expression wrapping while preserving needed contexts. A global minimum in number of RHS alternatives is not claimed because the source does not define its edit metric.

Original paper, page 7

4 marks · Descriptive
Report issue

Eliminate direct and indirect left recursion

Parsing & Syntax Analysis

Question 10(c), GATE 1991: For arithmetic expressions using binary, mathematically nonassociative operators minus and division, the start symbol is E and the grammar is E→E−T | T; T→T/F | F; F→(E) | id. Part (b) requires necessary-parentheses-only expressions. For the grammar E→T|S; S→E−T|E−(S); T→id|T/F|(S)/F; F→id|(S)|(T/F)|((S)/F), remove left recursion.
Question 10(c), GATE 1991: For arithmetic expressions using binary, mathematically nonassociative operators minus and division, the start symbol is E and the grammar is E→E−T | T; T→T/F | F; F→(E) | id. Part (b) requires necessary-parentheses-only expressions. For the grammar E→T|S; S→E−T|E−(S); T→id|T/F|(S)/F; F→id|(S)|(T/F)|((S)/F), remove left recursion.
Question 10(c), GATE 1991: For arithmetic expressions using binary, mathematically nonassociative operators minus and division, the start symbol is E and the grammar is E→E−T | T; T→T/F | F; F→(E) | id. Part (b) requires necessary-parentheses-only expressions. For the grammar E→T|S; S→E−T|E−(S); T→id|T/F|(S)/F; F→id|(S)|(T/F)|((S)/F), remove left recursion.
Tap to enlarge
Answer & solution

Answer: E→TR; R→−TR|−(S)R|ε; S→T−TR|T−(S)R; T→idU|(S)/FU; U→/FU|ε; F→id|(S)|(T/F)|((S)/F). (no official key was published)

First notice the indirect cycle E→S→E−T or E−(S). Removing only the obvious T→T/F recursion is insufficient. Substitute S’s alternatives into E to obtain E→T | E−T | E−(S). Its recursive suffixes are −T and −(S); its base is T. Introduce a tail R:
E→T R
R→−T R | −(S) R | ε.

S must still mean a subtraction-rooted expression, not an arbitrary E. Substituting E=T R into S initially gives S→T R−T | T R−(S). This is valid, but an equivalent clearer form selects the first subtraction and then any remaining subtraction tail:
S→T−T R | T−(S) R.
Both describe a T followed by a nonempty sequence of subtraction suffixes. Their ordering is preserved; the rewrite is about syntax, not commuting arithmetic operations.

Remove T’s immediate recursion T→T/F | id | (S)/F using a new tail U:
T→id U | (S)/F U
U→/F U | ε.
Keep F→id | (S) | (T/F) | ((S)/F).

The complete grammar is the six displayed groups E,R,S,T,U,F. Every nonempty derivation of T begins with id or “(”. E and S begin through T; F directly begins with id or “(”; R begins with “−” or ε, and U with “/” or ε. No nonterminal can derive itself as the leftmost symbol, so neither direct nor indirect left recursion remains. The language is unchanged by the standard tail transformation. When constructing semantic actions, fold each R or U sequence leftward to retain the original left-associative parse: right-recursive grammar tails must not accidentally change subtraction or division evaluation order. The at-most-one-extra-production restriction belongs to part (b); part (c) requires the additional tail nonterminals.

Original paper, page 7

5 marks · Descriptive
Report issue

Mutual exclusion of the three-process flag scheme

Synchronization & Concurrency

Question 11(a), GATE 1991: Shared atomic variables: flag[0..2] initially false; turn in {0,1,2}. For process i let j=(i+1) mod 3 and k=(i+2) mod 3. Repeat:
  flag[i] := true
  while flag[j] or flag[k]:
    case turn:
      j: if flag[j]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
      k: if flag[k]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
  critical section
  if turn == i: turn := j
  flag[i] := false
  noncritical section
Does this scheme ensure mutual exclusion? Explain.
Question 11(a), GATE 1991: Shared atomic variables: flag[0..2] initially false; turn in {0,1,2}. For process i let j=(i+1) mod 3 and k=(i+2) mod 3. Repeat:
  flag[i] := true
  while flag[j] or flag[k]:
    case turn:
      j: if flag[j]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
      k: if flag[k]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
  critical section
  if turn == i: turn := j
  flag[i] := false
  noncritical section
Does this scheme ensure mutual exclusion? Explain.
Tap to enlarge
Answer & solution

Answer: Yes, under atomic reads/writes and sequential consistency; this does not guarantee progress. (no official key was published)

First separate safety from liveness. A process sets its flag true before testing the outer while condition, and a process admitted to its critical section keeps that flag true until after leaving the critical section. Withdrawing its flag happens only inside the entry loop, never while it is in the critical section.

Suppose two distinct processes p and q were simultaneously in their critical sections. Consider the final assignments flag[p]=true and flag[q]=true preceding these particular admissions. Assume p's assignment occurred first. Its flag remains true from that assignment through its critical section: if it had withdrawn and raised the flag again, the assignment chosen was not final. Process q performs its successful outer test after its own final assignment, hence after p's final assignment. If q enters while p is still inside, q must encounter flag[p]=true and cannot pass the test. If p has already left when q reads false, the two critical sections do not overlap. This contradiction proves mutual exclusion. The argument works with separate atomic flag reads as well: a continuously true competing flag cannot be read as false.

The turn variable controls who backs off, but the persistent true flag is the safety invariant. No fairness assumption is needed for this safety proof. Atomic coherent shared-memory operations are needed; the bare pseudocode is not automatically a correct implementation on a weak-memory machine without suitable synchronization.

Original paper, page 7

5 marks · Descriptive
Report issue

Repairing starvation and inactive-turn deadlock

Synchronization & Concurrency

Question 11(b), GATE 1991: Shared atomic variables: flag[0..2] initially false; turn in {0,1,2}. For process i let j=(i+1) mod 3 and k=(i+2) mod 3. Repeat:
  flag[i] := true
  while flag[j] or flag[k]:
    case turn:
      j: if flag[j]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
      k: if flag[k]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
  critical section
  if turn == i: turn := j
  flag[i] := false
  noncritical section
Can a waiting process fail forever to enter? Give an execution and a corrected algorithm.
Question 11(b), GATE 1991: Shared atomic variables: flag[0..2] initially false; turn in {0,1,2}. For process i let j=(i+1) mod 3 and k=(i+2) mod 3. Repeat:
  flag[i] := true
  while flag[j] or flag[k]:
    case turn:
      j: if flag[j]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
      k: if flag[k]:
           flag[i] := false
           while turn != i: skip
           flag[i] := true
  critical section
  if turn == i: turn := j
  flag[i] := false
  noncritical section
Can a waiting process fail forever to enter? Give an execution and a corrected algorithm.
Tap to enlarge
Answer & solution

Answer: Yes. Two contenders can spin forever when turn names an inactive third process. A three-process bakery lock is a correct replacement. (no official key was published)

Take turn=2, with process 2 remaining in its noncritical section and flag[2]=false. Let processes 0 and 1 both set their flags true before either completes its outer test. Each sees the other's true flag. Its case selects process 2, but the guarded branch sees flag[2]=false, so neither process withdraws or changes turn. They repeat forever, even under fair scheduling of all active processes. Only a critical-section exit changes turn, and neither contender can reach such an exit. Thus progress fails, not merely a timing bound. An inner waiter can also be stranded when turn is handed to an inactive process.

A safe repair is to replace the entire entry/exit protocol with Lamport's bakery algorithm, rather than merely skipping a false flag: false can mean a temporarily withdrawn waiter, not an uninterested process. Use separate choosing and ticket arrays, initially false and zero. Atomic reads/writes and sequential consistency are assumed, and mathematical tickets are unbounded integers.

For process i:
  choosing[i] := true
  ticket[i] := 1 + max(ticket[0], ticket[1], ticket[2])
  choosing[i] := false
  for r := 0 to 2, r != i:
    while choosing[r]: skip
    while ticket[r] != 0 and (ticket[r],r) < (ticket[i],i): skip
  critical section
  ticket[i] := 0
  noncritical section
  repeat

Pairs are compared lexicographically, first by ticket and then process number. The choosing flag prevents observing a half-completed ticket selection as if the process were absent. If two processes competed to enter, the one with larger pair must wait for the smaller pair's nonzero ticket; both cannot be inside together. A process which starts choosing after i has published its ticket obtains a larger ticket and cannot overtake i. Only finitely many already competing choices can precede i. Under fair scheduling, finite ticket-selection and critical-section execution, and no process failures, those predecessors finish, so i eventually enters. An inactive process has choosing=false and ticket=0 and is ignored. These assumptions are necessary: no software lock can promise entry if its current owner stops forever.

Original paper, page 7

Descriptive
Report issue

Parts supplied within Delhi

SQL & Queries

Question 12(a.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning part codes supplied to a Delhi project by a Delhi supplier.
Question 12(a.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning part codes supplied to a Delhi project by a Delhi supplier.
Question 12(a.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning part codes supplied to a Delhi project by a Delhi supplier.
Tap to enlarge
Answer & solution

Answer: SELECT DISTINCT X.PCODE from the shipment/supplier/project join where both cities are DELHI. (no official key was published)

The shipment relation provides the association among a supplier, a part and a project. Join it to SUPPLIER on SCODE and to PROJECTS on PRCODE. The two city restrictions apply independently to supplier and project, not to PART.CITY.

SELECT DISTINCT X.PCODE
FROM SPPR AS X
JOIN SUPPLIER AS S ON S.SCODE = X.SCODE
JOIN PROJECTS AS P ON P.PRCODE = X.PRCODE
WHERE S.CITY = 'DELHI' AND P.CITY = 'DELHI';

A qualifying shipment is a witness that the part satisfies the request. DISTINCT ensures each code appears once even if multiple suppliers or projects witness it, or several shipment records exist. No join to PART is necessary because the requested code is already present in SPPR, under the usual foreign-key consistency assumption. If parts must also exist despite unenforced references, add JOIN PART AS T ON T.PCODE=X.PCODE. SQL string comparison follows the database's collation; DELHI is the source's city literal.

Original paper, page 7

Descriptive
Report issue

Intercity shipment triples

SQL & Queries

Question 12(a.ii), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning distinct triples (supplier city, part code, project city), excluding equal cities.
Question 12(a.ii), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning distinct triples (supplier city, part code, project city), excluding equal cities.
Question 12(a.ii), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning distinct triples (supplier city, part code, project city), excluding equal cities.
Tap to enlarge
Answer & solution

Answer: Join shipments to suppliers and projects, filter S.CITY <> P.CITY, and select the distinct three requested attributes. (no official key was published)

A row must describe an actual shipment rather than an arbitrary supplier/project combination. Use SPPR as the central relation and join the endpoint relations by their code keys. The supplier city is the first component; the destination project's city is the third.

SELECT DISTINCT S.CITY AS SUPPLIER_CITY,
                X.PCODE,
                P.CITY AS PROJECT_CITY
FROM SPPR AS X
JOIN SUPPLIER AS S ON S.SCODE = X.SCODE
JOIN PROJECTS AS P ON P.PRCODE = X.PRCODE
WHERE S.CITY <> P.CITY;

The predicate removes local shipments, and DISTINCT collapses repeated triples caused by different suppliers, projects or shipment rows. PART.CITY is irrelevant: it is neither endpoint requested in the result. Aliases make the two CITY columns distinguishable. Classical relational problems normally assume nonnull attributes. In SQL, if a city is NULL, the inequality is UNKNOWN and the row is excluded; a different policy for unknown cities would require an explicit requirement and predicate.

Original paper, page 7

Descriptive
Report issue

Suppliers serving both named projects

Relational Algebra & Calculus

Question 12(b.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for supplier codes supplying both projects PR1 and PR2.
Question 12(b.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for supplier codes supplying both projects PR1 and PR2.
Question 12(b.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for supplier codes supplying both projects PR1 and PR2.
Tap to enlarge
Answer & solution

Answer: π_SCODE(σ_PRCODE='PR1'(SPPR)) ∩ π_SCODE(σ_PRCODE='PR2'(SPPR)). (no official key was published)

First select shipments to PR1 and project their supplier codes: A=π_SCODE(σ_PRCODE='PR1'(SPPR)). Separately form B=π_SCODE(σ_PRCODE='PR2'(SPPR)). Both expressions have the same one-attribute schema, so set intersection is defined. The answer is A∩B.

Membership in the intersection requires a shipment witness to each project. The witnesses need not have the same part, quantity or shipment record. Selecting PRCODE='PR1' AND PRCODE='PR2' on a single tuple would be wrong because one shipment tuple cannot have two different project codes. Selecting with OR and projecting without intersection would also be wrong: it admits suppliers serving only one project. Under standard relational-algebra set semantics projection automatically eliminates duplicate supplier codes.

Original paper, page 7

Descriptive
Report issue

Projects with an outside-city supplier

Relational Algebra & Calculus

Question 12(b.ii), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for project codes supplied by at least one supplier in a different city.
Question 12(b.ii), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for project codes supplied by at least one supplier in a different city.
Question 12(b.ii), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for project codes supplied by at least one supplier in a different city.
Tap to enlarge
Answer & solution

Answer: π_P.PRCODE(σ_S.CITY≠P.CITY((ρ_S SUPPLIER) ⋈_S.SCODE=X.SCODE (ρ_X SPPR) ⋈_X.PRCODE=P.PRCODE (ρ_P PROJECTS))). (no official key was published)

Rename SUPPLIER as S, SPPR as X and PROJECTS as P so that both CITY attributes can be referenced explicitly. Form J=(S ⋈_{S.SCODE=X.SCODE} X) ⋈_{X.PRCODE=P.PRCODE} P. Then return π_{P.PRCODE}(σ_{S.CITY≠P.CITY}(J)).

The joins establish that S actually supplies P through a shipment row. The selection keeps witnesses whose endpoint cities differ, and the projection returns the set of project codes having at least one such witness. A project may also have local suppliers and must still appear: the condition is existential, not a requirement that every supplier be out of town. A natural join over unrenamed relations would wrongly equate the two CITY attributes and suppress precisely the rows sought, so use explicit theta joins or rename the city columns before joining.

Original paper, page 7

10 marks · Descriptive
Report issue

Sorting with an unknown number of distinct keys

Searching, Sorting & Selection

Question 13, GATE 1991: Give an optimal comparison-based algorithm, with pseudocode and analysis, to sort n numbers containing k distinct values; k is not known in advance.
Question 13, GATE 1991: Give an optimal comparison-based algorithm, with pseudocode and analysis, to sort n numbers containing k distinct values; k is not known in advance.
Tap to enlarge
Answer & solution

Answer: Use a balanced search tree of distinct values and counts, then inorder expansion: O(n log(k+1)) time and O(k) auxiliary space; worst-case optimal in the comparison model. (no official key was published)

Maintain one node per distinct key in a balanced binary search tree, storing a frequency counter. Unlike a simple unbalanced BST, an AVL or red-black tree guarantees height O(log(d+1)) when d distinct values have been encountered. The algorithm discovers k automatically.

SORT_FEW_DISTINCT(A):
  T := empty balanced search tree
  for x in A:
    node := FIND(T,x)
    if node exists: node.count := node.count + 1
    else: INSERT_BALANCED(T, key=x, count=1)
  output := empty sequence
  for node in INORDER(T):
    repeat node.count times: append node.key to output
  return output

After each insertion, the tree contains exactly the distinct input values seen so far, with their correct multiplicities. Inorder traversal visits keys in increasing order, and expanding each count preserves all occurrences. Thus the output is a sorted permutation of the input.

Each of n updates costs O(log(k+1)); inorder traversal costs O(k), and emitting n values costs O(n). Total time is O(n log(k+1)), commonly written O(n log k) for k≥2. The +1 handles k=1, where the algorithm is linear. Auxiliary tree storage is O(k), excluding the n-element output; an array can be overwritten during the final traversal if the input need not be retained.

For worst-case comparison optimality at fixed n and k, consider balanced multiplicities among k ordered values. There are n!/(n1!…nk!) distinguishable orderings, where each ni is approximately n/k. A constant-branching comparison decision tree requires Ω(log(n!/(n1!…nk!)))=Ω(n log k) comparisons in the worst case for k≥2. Reading or writing the input/output also costs Ω(n), giving Ω(n log(k+1)) overall. This is a worst-case statement over multiplicities, not a claim of distribution-sensitive optimality for every frequency pattern. With bounded integer keys, counting/radix methods may bypass the comparison lower bound; without a key-universe assumption they are not a general replacement.

Original paper, page 7

1 mark · Descriptive
Report issue

Identifying the tree structure

Heaps & Priority Queues

Question 14(a), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Identify the data structure.
Question 14(a), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Identify the data structure.
Question 14(a), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Identify the data structure.
Tap to enlarge
Answer & solution

Answer: A binary min-heap. (no official key was published)

Two separate conditions identify this tree. First, its shape is complete: all levels above the last are full and the last level fills from left to right. Second, every parent is no greater than either child: for example 1≤5,18; 5≤7,13; 18≤25,20; and 7≤11,9. The minimum element is therefore at the root, and the tree is a binary min-heap.

It is not a binary search tree. For instance, the root's left subtree contains 5 even though 5>1, and the left child 25 of node 18 exceeds its parent. A heap imposes parent-child order but imposes no sorted order between siblings or across unrelated subtrees. The level-order array in the prompt fully specifies the source figure and provides the customary compact heap representation.

Original paper, page 8

2 marks · Descriptive
Report issue

Deleting key five from the min-heap

Heaps & Priority Queues

Question 14(b), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Show the steps deleting key 5 while retaining the structure.
Question 14(b), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Show the steps deleting key 5 while retaining the structure.
Question 14(b), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Show the steps deleting key 5 while retaining the structure.
Tap to enlarge
Answer & solution

Answer: Replace 5 with last key 27, remove the last leaf, then swap 27 with 7 and with 9. Final array [1,7,18,9,13,25,20,11,27,15,17]. (no official key was published)

Use one-based array indexing. Key 5 is at index 2 and the last node, key 27, is at index 12. Delete the last node and place its value at index 2. Taking the last leaf preserves the complete-tree shape; simply removing node 5 would leave a hole.

After replacement:
[1,27,18,7,13,25,20,11,9,15,17]

The new key is greater than both children 7 and 13. Swap with the smaller child 7 (index 4), not an arbitrary child:
[1,7,18,27,13,25,20,11,9,15,17]

At index 4, children are 11 and 9. Swap 27 with the smaller, 9 (index 9):
[1,7,18,9,13,25,20,11,27,15,17]

Index 9 is a leaf, so stop. Each swap makes the parent of the affected subtree its minimum, and only the downward path can remain out of order. The final tree has levels [1], [7,18], [9,13,25,20], [11,27,15,17]; every parent-child inequality and the complete shape are preserved.

Original paper, page 8

3 marks · Descriptive
Report issue

Deleting any min-heap node

Heaps & Priority Queues

Question 14(c), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Give pseudocode to delete an arbitrary node of an n-node min-heap, with worst-case complexity. Distinguish a supplied node index from a supplied key.
Question 14(c), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Give pseudocode to delete an arbitrary node of an n-node min-heap, with worst-case complexity. Distinguish a supplied node index from a supplied key.
Question 14(c), GATE 1991: The complete binary tree has level-order array [1,5,18,7,13,25,20,11,9,15,17,27]. Its edges are 1→(5,18), 5→(7,13), 18→(25,20), 7→(11,9), 13→(15,17), and 25→(27,left only). Give pseudocode to delete an arbitrary node of an n-node min-heap, with worst-case complexity. Distinguish a supplied node index from a supplied key.
Tap to enlarge
Answer & solution

Answer: Replace the node by the last key and sift up or down as needed. Known-index deletion costs O(log n); locating an arbitrary key can add Θ(n). (no official key was published)

Assume a one-based array H[1..n] and a valid index p. Replacing H[p] by H[n] and shortening the array preserves completeness. The replacement may be smaller than its parent or larger than a child, so a general deletion cannot always use only sift-down.

DELETE_AT(H,n,p):
  require 1 <= p <= n
  if p == n: return n-1
  H[p] := H[n]
  n := n-1
  if p > 1 and H[p] < H[floor(p/2)]:
    while p > 1 and H[p] < H[floor(p/2)]:
      swap H[p], H[floor(p/2)]
      p := floor(p/2)
  else:
    while 2*p <= n:
      c := 2*p
      if c+1 <= n and H[c+1] < H[c]: c := c+1
      if H[p] <= H[c]: break
      swap H[p], H[c]
      p := c
  return n

Only inequalities incident to the replaced node can initially fail. If the replacement is less than its parent, it is also less than the old children, since those children were at least the old value, which was at least the parent. Thus only upward repair is needed. Otherwise the parent relation holds, and downward repair with the smaller child fixes each level without creating a violation above. Equal values need no swap.

A complete binary tree has height floor(log2 n). Either repair traverses at most that many levels and uses O(1) extra space, so a supplied-index deletion is O(log n) worst case. If only a key is supplied and no key-to-index directory exists, a heap is not a search tree: finding the occurrence can cost Θ(n), making the entire deletion Θ(n) worst case. A maintained locator can remove that search cost but must be updated on swaps and handle duplicates explicitly.

Original paper, page 8

5 marks · Descriptive
Report issue

Product identity for gcd and lcm

Proof Techniques & Number Theory

Question 15(a), GATE 1991: For positive integers a and b, prove gcd(a,b)·lcm(a,b)=ab.
Tap to enlarge
Answer & solution

Answer: gcd(a,b)·lcm(a,b)=ab. (no official key was published)

By unique prime factorization, write a=∏p pαp and b=∏p pβp, using exponent zero for a prime absent from either factorization. Only finitely many exponents are nonzero.

A common divisor cannot contain more copies of p than either number, so the largest possible exponent of p in the gcd is min(αp,βp). Conversely these minimum exponents do divide both numbers, proving gcd(a,b)=∏p pmin(αp,βp).

A common multiple must contain at least as many copies of p as each number, so the smallest possible exponent in the lcm is max(αp,βp). These maximum exponents form a multiple of both, proving lcm(a,b)=∏p pmax(αp,βp).

Multiplying adds exponents. Since min(u,v)+max(u,v)=u+v for any u,v, the product is ∏p pαp+βp=ab. This also covers a=1 or b=1 by the empty-product convention. Positivity avoids sign conventions and zero-related lcm special cases.

Original paper, page 8

5 marks · Descriptive
Report issue

Infinite models of a strict successor relation

Propositional & Predicate Logic

Question 15(b), GATE 1991: Over a nonempty domain, consider (∀x∃y R(x,y)) ∧ (∀x∀y(R(x,y)→¬R(y,x))) ∧ (∀x∀y∀z((R(x,y)∧R(y,z))→R(x,z))) ∧ (∀x ¬R(x,x)). Does this formula have finite models? Is it satisfiable? Give a countable model if so.
Question 15(b), GATE 1991: Over a nonempty domain, consider (∀x∃y R(x,y)) ∧ (∀x∀y(R(x,y)→¬R(y,x))) ∧ (∀x∀y∀z((R(x,y)∧R(y,z))→R(x,z))) ∧ (∀x ¬R(x,x)). Does this formula have finite models? Is it satisfiable? Give a countable model if so.
Tap to enlarge
Answer & solution

Answer: No nonempty finite models. It is satisfiable in the countably infinite structure (ℕ,<). (no official key was published)

The conjuncts say respectively that every element has a strict successor in R, the relation is asymmetric, it is transitive, and it is irreflexive. In particular the first clause prevents a maximal element. The negation in the asymmetry clause is essential and is visibly present in the sources.

Suppose a finite model had m≥1 elements. Choose any x0. By the first clause choose x1 with R(x0,x1), then x2 with R(x1,x2), continuing to xm. Among these m+1 elements some xi=xj with i<j. Repeated application of transitivity to the nonempty chain from xi to xj yields R(xi,xj), hence R(xi,xi). This contradicts irreflexivity. Thus there is no finite nonempty model. One can equivalently say that a finite strict partial order has a maximal element, contrary to the successor clause.

For satisfiability, take the domain ℕ={0,1,2,…} and interpret R(x,y) as x<y. Every x has witness y=x+1. If x<y then not y<x, so asymmetry holds. From x<y and y<z follows x<z, so transitivity holds; x<x is always false. All four conjuncts therefore hold. The domain is countably infinite, giving the requested countable model. Ordinary first-order semantics requires a nonempty domain; if empty domains were unusually permitted, the universally quantified formula would also hold vacuously there.

Original paper, page 8

5 marks · Descriptive
Report issue

Balanced binary prefixes and Catalan numbers

Combinatorics & Counting

Question 16(a), GATE 1991: How many length-2n binary strings have n zeros and n ones and every prefix contains at least as many zeros as ones?
Tap to enlarge
Answer & solution

Answer: C_n = binom(2n,n) − binom(2n,n−1) = binom(2n,n)/(n+1). (no official key was published)

Interpret a zero as a +1 step and a one as a −1 step. A balanced string gives a walk from height 0 to height 0 in 2n steps. The prefix restriction asks that the height never become negative. There are binom(2n,n) balanced strings before imposing the restriction.

Count the bad strings by reflection. A bad walk has a first step reaching height −1. Swap zeros and ones in the segment from the beginning through that first visit. Originally that segment has one more one than zero; after the swap it has one more zero than one. Consequently the transformed entire string has n+1 zeros and n−1 ones and ends at height +2.

Conversely, any string with n+1 zeros and n−1 ones must first reach height +1. Reflect its prefix through that first visit. The resulting balanced walk first reaches −1 there, so it is bad. These two operations invert each other, establishing a bijection. The number of bad strings is therefore binom(2n,n−1), choosing the positions of its n−1 ones after reflection.

Subtracting gives binom(2n,n)−binom(2n,n−1). Since binom(2n,n−1)=n·binom(2n,n)/(n+1), the result is Cn=binom(2n,n)/(n+1), the nth Catalan number. For n=0, the empty string contributes one; for n=2, the valid strings are 0011 and 0101, agreeing with C2=2.

Original paper, page 8

5 marks · Descriptive
Report issue

Repeated vertex degrees in a finite graph

Graph Theory

Question 16(b), GATE 1991: Prove that a finite undirected simple graph with at least two vertices has two vertices of equal degree.
Tap to enlarge
Answer & solution

Answer: Two vertices must share a degree, since degrees 0 and n−1 cannot both occur. (no official key was published)

Let the graph have n≥2 vertices. In a simple undirected graph each degree is an integer in {0,1,…,n−1}. Merely counting n possible degrees and n vertices does not yet prove a repetition; the key is that the extreme values cannot coexist.

If a vertex has degree n−1, it is adjacent to every other vertex, so every other vertex has degree at least 1. Thus no degree-0 vertex exists. Conversely, if an isolated vertex exists, no vertex can be adjacent to all n−1 others, so degree n−1 is absent.

There are therefore at most n−1 possible degrees in the graph: if there is an isolated vertex, use {0,…,n−2}; if not, use {1,…,n−1}. Assigning n vertices to at most n−1 degree values forces two into the same value by the pigeonhole principle.

The simple-graph convention matters. If parallel edges or loops were allowed, the bound n−1 would fail and so can the conclusion. For example, on three vertices put one edge between a and b, two parallel edges between a and c, and none between b and c. The degrees are 3,1,2, all distinct. The source's unqualified graph is interpreted in the standard simple-graph setting.

Original paper, page 8

5 marks · Descriptive
Report issue

Constant-workspace machines recognize regular languages

Turing Machines

Question 17(a), GATE 1991: Prove that Turing machines with a read-only input tape and constant-size work tape recognize exactly the regular languages. Use the standard single input-head model with endmarkers.
Tap to enlarge
Answer & solution

Answer: Exactly the regular languages: finite workspace folds into finite control, giving a two-way finite automaton, and two-way finite automata recognize regular languages. (no official key was published)

For the easy direction, let L be regular and choose a DFA for L. A Turing machine stores the DFA state in its finite control, scans the read-only input from left to right, and accepts exactly when the simulated DFA ends in an accepting state. It needs no growing work tape, hence satisfies the constant-space requirement.

For the other direction, let the machine use at most c work cells, where c is independent of input length. If the work alphabet is Γ and the finite control has q states, the work contents and work-head location together have at most |Γ|^c·O(c) possibilities. Fold these possibilities into the control state. This gives a finite-state device whose only unbounded feature is the position of its single head on the read-only input. It is a two-way finite automaton, not immediately an ordinary one-way DFA: treating input-head position as a fixed finite state would be an error.

Here is why two-way motion does not add language power. For any finite input block, summarize its behavior by a finite relation recording which control state and side can enter the block and which control state and side can next exit it, together with whether acceptance can be reached before exit. There are finitely many such boundary-state combinations, so only finitely many possible block summaries, regardless of block length. Infinite internal loops yield no exit or acceptance in the summary.

The summary of a concatenation uv is determined solely by the summaries of u and v: connect their touching boundaries and compute reachability through the finite interface graph, allowing repeated crossings. Each symbol has its own summary. A one-way DFA can therefore read symbols from left to right, retaining the accumulated block summary as its state and updating it by this finite composition. With the endmarkers included, its accepting states are exactly the summaries allowing the original initial state to reach acceptance. This constructs a finite recognizer for the same language. For nondeterministic machines use existential reachability in the same summaries; a finite relation still suffices.

Thus the constant-workspace machine cannot recognize any nonregular language, and both containments establish equality. The standard assumptions exclude multiple independent input heads or writable unbounded input cells, which would invalidate this reduction.

Original paper, page 8

5 marks · Descriptive
Report issue

Third-from-last bit: NFA and minimum DFA

Finite Automata

Question 17(b), GATE 1991: Let L be the set of binary strings whose third symbol from the right is 1. Construct an NFA for L and justify the number of states in its minimized equivalent DFA.
Tap to enlarge
Answer & solution

Answer: A four-state NFA suffices; the minimum DFA has exactly 8 states. (no official key was published)

The language is {0,1}*1{0,1}{0,1}. An NFA can guess which 1 will be third from last, then require exactly two more symbols before acceptance. Use states q0,q1,q2,q3; q0 is initial and q3 is the only accepting state. Missing transitions go to the empty set.

Transition table

State | on 0 | on 1
q0    | {q0} | {q0,q1}
q1    | {q2} | {q2}
q2    | {q3} | {q3}
q3    | {}   | {}

Equivalently, q0 has a loop labeled 0,1 and an additional edge labeled 1 to q1; q1→q2 and q2→q3 are labeled 0,1. A successful path stays at q0 through an arbitrary prefix, takes the guessing edge on a 1, and reads exactly two additional symbols. It ends in q3 precisely for the required strings.

For a DFA upper bound, store the most recent three bits, padding on the left with zeros before three bits have arrived. Use the eight states abc∈{0,1}^3, initial state 000, transition δ(abc,d)=bcd, and accepting states 100,101,110,111. After at least three inputs the first stored bit is exactly third from last; shorter strings remain nonaccepting because their padded first bit is zero. Every state is reachable by reading its three-bit label.

For minimality, take two different length-three strings x and y, differing at position r counted from the left, with 1≤r≤3. Append 0r−1 to both. In each resulting string, the third symbol from the right is precisely the old position r, so exactly one extension is accepted. Thus all eight three-bit strings have pairwise distinct right languages. By Myhill–Nerode, every DFA needs at least eight states. The construction meets this bound, proving that its minimized size is exactly 8.

Original paper, page 8