GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 1995

91 questions

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

03:00:00
1 mark · MCQ
Report issue

Clearing the low nibble

Instructions & Addressing Modes

Question 1.1, GATE 1995: Which 8085 instruction clears the accumulator’s lower four bits while retaining the upper four: XRI 0FH, ANI F0H, XRI F0H, or ANI 0FH?
Tap to enlarge
Your answer
Answer & solution

Answer: B: ANI F0H (no official key was published)

F0H is binary 11110000. AND with its four high ones preserves the corresponding accumulator bits; AND with its four low zeros clears those bits. Thus ANI F0H performs the required masking. XOR would toggle selected bits instead of necessarily clearing them. ANI 0FH does the opposite mask, preserving the low nibble and clearing the high nibble. The operation is independent of the accumulator’s initial value.

Original paper, page 1

1 mark · MCQ
Report issue

A true machine organization statement

Other / Mixed Topics

Question 1.2, GATE 1995: Choose the true statement: ROM is read/write; PC points to the last executed instruction; stack is LIFO; all instructions affect flags.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

A stack removes the most recently pushed item first, which is last-in-first-out. Ordinary ROM is not general read/write memory. A program counter conventionally identifies the next instruction to fetch or the current fetch position, not a record of the last completed instruction. Instructions such as data moves can leave flags unchanged, so not every instruction affects them. Therefore only the stack statement C is a reliable general description among these alternatives.

Original paper, page 1

1 mark · MCQ
Report issue

Vectored interrupt information

Input/Output, DMA & Interrupts

Question 1.3, GATE 1995: In a vectored interrupt, is the branch address fixed, supplied via an interrupt vector by the source, obtained from a processor register, or none?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

A vectored interrupt provides an identifying vector that selects the appropriate service routine, avoiding software polling of all sources. In the model described by B, the interrupting device or controller supplies this vector and the CPU uses it to obtain the branch target. Some architectures instead assign fixed vectors internally, such as fixed-priority vectored inputs, so source-supplied information is not a universal definition. A fixed-vector interpretation can also fit A. Thus B is the intended external-vector model, with that architectural assumption made explicit.

Original paper, page 1

1 mark · MCQ
Report issue

A dangling else under a false outer test

Parsing & Syntax Analysis

Question 1.4, GATE 1995: Pascal executes X:=−10; Y:=20; if X>Y then if X<0 then X:=abs(X) else X:=2*X. What is X?
Tap to enlarge
Your answer
Answer & solution

Answer: C: −10 (no official key was published)

The outer condition X>Y evaluates as −10>20, which is false. Its entire then statement, including the nested if and its else, is skipped. Therefore neither abs(X) nor doubling executes, and X stays −10. Pascal associates the else with the nearest unmatched if, namely the inner X<0 test. Treating that else as belonging to the outer test would incorrectly execute the doubling branch and obtain −20.

Original paper, page 1

1 mark · MCQ
Report issue

Merge-sort paradigm

Divide & Conquer

Question 1.5, GATE 1995: Does merge sort use divide and conquer, backtracking, heuristic search, or a greedy approach?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Merge sort divides an input into smaller portions, recursively sorts each portion, then combines the sorted results using a merge. This division into subproblems and combination of their solutions is divide and conquer. It does not search and undo candidate choices as backtracking does, and it is not a sequence of locally optimal choices justified by a greedy exchange property. The merge step is linear, leading to the familiar Θ(n log n) recurrence for balanced splits.

Original paper, page 1

1 mark · MCQ
Report issue

Locality and the memory hierarchy

Cache Memory

Question 1.6, GATE 1995: Which mechanism is directly justified by locality: interrupts, DMA, polling, or cache memory?
Question 1.6, GATE 1995: Which mechanism is directly justified by locality: interrupts, DMA, polling, or cache memory?
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Temporal locality means a recently accessed item is likely to be accessed again. Spatial locality means nearby addresses are likely to be accessed soon. A cache retains recent blocks in fast storage, exploiting both kinds of locality to avoid slower memory accesses. Interrupts and polling concern detecting events; DMA concerns moving data without the CPU handling every transfer. None depends on locality in the same direct way, so cache memory is the relevant mechanism.

Original paper, page 1

1 mark · MCQ
Report issue

Paging a segment table

Virtual Memory & Paging

Question 1.7, GATE 1995: Why might a paged-segmented memory scheme give the segment table itself a page table?
Tap to enlarge
Your answer
Answer & solution

Answer: A: the segment table can be too large for one page (no official key was published)

A large segment table can span multiple pages. Paging that table lets its pieces be placed in separate physical frames and, where supported, brought in on demand. A page table is then needed to translate addresses of the segment-table pages themselves. This is distinct from the page tables belonging to individual program segments. The wording “must” is architecture dependent: a small segment table or an architecture requiring contiguous resident tables need not use this extra paging level. A describes the motivation within the assumed paged-table design.

Original paper, page 1

1 mark · MCQ
Report issue

Belady’s anomaly

Virtual Memory & Paging

Question 1.8, GATE 1995: Which replacement policy can have more page faults after increasing the frame count: OPT, LRU, FIFO, or OPT and FIFO?
Tap to enlarge
Your answer
Answer & solution

Answer: C: FIFO (no official key was published)

FIFO removes the page that has been resident longest, independent of recent use or future demand. Its resident sets with different frame counts need not be nested, so adding a frame can alter the eviction order disadvantageously. The classic string 1,2,3,4,1,2,5,1,2,3,4,5 gives nine FIFO faults with three frames and ten with four. LRU and OPT have the stack-inclusion property and do not suffer this anomaly. Therefore C is the correct policy.

Original paper, page 1

1 mark · MCQ
Report issue

Regular expression for identifiers

Regular Expressions & Languages

Question 1.9, GATE 1995: An identifier is one letter followed by zero or more letters or digits. With letter set L and digit set D, choose its expression.
Tap to enlarge
Your answer
Answer & solution

Answer: B: L(L∪D)* (no official key was published)

The initial L enforces exactly one initial letter. Every subsequent character may independently be a letter or digit, represented by L∪D, and the star allows zero or more such characters. Thus a one-letter identifier is allowed, but an empty identifier or one beginning with a digit is not. Expressions that star an alternating letter-digit pair impose an unjustified pattern, while starring or plussing L∪D alone permits a digit first. The concatenation L(L∪D)* captures precisely the requirement.

Original paper, page 1

1 mark · MCQ
Report issue

A damaged grammar classification

Context-Free Grammars & Languages

Question 1.10, GATE 1995: Classify the reproduced grammar as context-free, regular, context-sensitive or LR(k). Its final GFG line reads bα→bdb|b; other nonterminal labels and the alternate differ.
Question 1.10, GATE 1995: Classify the reproduced grammar as context-free, regular, context-sensitive or LR(k). Its final GFG line reads bα→bdb|b; other nonterminal labels and the alternate differ.
Tap to enlarge
Your answer
Answer & solution

Answer: No listed classification can be justified: the printed grammar has a contracting rule (no official key was published)

A context-free production must have one nonterminal on its left side; the visible bα left side has multiple symbols. A context-sensitive grammar in the usual noncontracting form cannot contain bα→b, which shortens a nonempty string. Regular and LR(k) grammars are context-free and therefore fail the same left-side condition. Moreover, the reproductions disagree on labels and contain undeclared-looking symbols, so even a valid unrestricted grammar cannot be reconstructed confidently. If the contraction or labels are typographic errors, classification might change. No option is asserted without a trustworthy correction of the source.

Original paper, page 1

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Macro definition parameters

Compiler Phases, Linking & Loading

Question 1.11, GATE 1995: In macro Add x,y with body Load y; Mul x; Store y, are x,y variables, identifiers, actual parameters or formal parameters?
Tap to enlarge
Your answer
Answer & solution

Answer: D: formal parameters (no official key was published)

The names x and y appear in the macro definition and stand for values or text supplied by each invocation. They are therefore formal parameters. An invocation such as Add A,B supplies actual parameters A and B, which replace the corresponding formals during expansion. Although formal names are also identifiers in a broad lexical sense, “formal parameters” is the specific role asked here. They need not denote runtime storage variables of the expanded program.

Original paper, page 2

1 mark · MCQ
Report issue

Minimum distance of a binary code

Data Link, Framing, Error Control & ARQ

Question 1.12, GATE 1995: Find minimum Hamming distance of {000000,010101,101010,000111,011001,111111}; GateForum omits 101010.
Tap to enlarge
Your answer
Answer & solution

Answer: A: 2 (no official key was published)

Hamming distance counts differing bit positions. For example 010101 and 000111 differ in exactly two positions, so the minimum is at most two. Checking the other distinct pairs finds no pair differing in one position; their distances are two, three, four or six. Hence the minimum is two. The additional the paper codeword 101010 has distances three or six to some words and does not introduce a distance-one pair.

Original paper, page 2

1 mark · MCQ
Report issue

Recognizing a Pascal token without lookahead

Lexical Analysis

Question 1.13, GATE 1995: Which can definitely be recognized as a whole token without reading the next character: I begin, II program, III <>?
Tap to enlarge
Your answer
Answer & solution

Answer: C: III (no official key was published)

The characters begin may be followed by another identifier character, producing an identifier such as beginning rather than the keyword begin. The same issue applies to program. The lexer therefore needs to determine the word boundary before deciding those tokens. Pascal’s <> is a complete relational operator with no longer operator having it as a prefix, so it can be recognized immediately after the second character. This is the longest-token principle, not a claim that keywords cannot ever be recognized.

Original paper, page 2

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Information not required in a relocatable object

Compiler Phases, Linking & Loading

Question 1.14, GATE 1995: GFG asks what need NOT be included: object code, relocation bits, exported-symbol names and locations, or absolute addresses of internal symbols. GateForum omits NOT.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

A relocatable object contains machine code plus information allowing its addresses to be adjusted and its external definitions and references resolved. Internal symbol locations can be encoded relative to the module; their final absolute addresses are not known until placement. Therefore absolute addresses of all internal symbols need not be included, D. Object code and relocation/symbol information are the conventional inputs to linking.

Original paper, page 2

1 mark · MCQ
Report issue

Scheduling for time sharing

CPU Scheduling

Question 1.15, GATE 1995: Which policy is most suitable for a time-shared OS: shortest job first, round robin, FCFS or elevator?
Tap to enlarge
Your answer
Answer & solution

Answer: B: round robin (no official key was published)

Round robin gives each ready process a bounded time slice and cycles through the queue. This prevents one long CPU-bound job from monopolizing the processor and supports responsive interactive use. FCFS can make short interactive requests wait behind a long job. SJF requires burst predictions and can disadvantage long jobs; elevator is chiefly a disk-head scheduling rule. Round robin is therefore the standard choice here, with quantum size balancing response time against context-switch overhead.

Original paper, page 2

1 mark · MCQ
Report issue

Merging sorted lists

Searching, Sorting & Selection

Question 1.16, GATE 1995: How many comparisons asymptotically suffice to merge sorted lists of sizes m and n into one sorted list?
Question 1.16, GATE 1995: How many comparisons asymptotically suffice to merge sorted lists of sizes m and n into one sorted list?
Tap to enlarge
Your answer
Answer & solution

Answer: C: O(m+n) (no official key was published)

Compare the two current front items, emit the smaller and advance that list. Every comparison emits one item, and once one list is exhausted the remaining items can be copied without further comparisons. At most m+n−1 comparisons are therefore needed when both lists are nonempty. Balanced interleavings can attain this bound, giving linear worst-case work. Merely searching in logarithmic time would not output the entire merged list; the standard merge exploits the existing order of both inputs.

Original paper, page 2

1 mark · MCQ
Report issue

Leaves and binary branching nodes

Tree Properties & Traversals

Question 1.17, GATE 1995: A nonempty rooted binary tree has n leaves. How many nodes have two children?
Tap to enlarge
Your answer
Answer & solution

Answer: B: n−1 (no official key was published)

Let n0,n1,n2 count nodes with zero, one and two children. The tree has n0+n1+n2−1 edges because it is connected and acyclic. Counting edges by parents gives n1+2n2. Equating the two expressions yields n2=n0−1=n−1. Unary nodes cancel and therefore do not alter the relationship. Here degree two means two children, the rooted-tree convention; interpreting it as undirected graph degree would be a different question.

Original paper, page 2

1 mark · MCQ
Report issue

Three-digit numbers avoiding seven

Probability & Random Variables

Question 1.18, GATE 1995: A number is selected uniformly from 100 through 999. Find the probability it contains no digit 7.
Tap to enlarge
Your answer
Answer & solution

Answer: D: 18/25 (no official key was published)

There are 900 equally likely three-digit numbers. The hundreds position has eight allowed choices: 1 through 9 except 7. Each remaining position has nine choices: 0 through 9 except 7. Thus 8·9·9=648 numbers avoid 7, and 648/900=18/25. Using (9/10)³ would wrongly allow zero in the hundreds position and assume all three positions have the same distribution.

Original paper, page 2

1 mark · MCQ
Report issue

Symmetric and transitive need not mean reflexive

Sets, Relations & Functions

Question 1.19, GATE 1995: Given a symmetric and transitive relation R on A, must it be an equivalence, a partial order, nonreflexive, or none? The alternate changes the negation in C.
Tap to enlarge
Your answer
Answer & solution

Answer: D: none of the asserted necessities (no official key was published)

Reflexivity is independent of the two stated properties on the entire underlying set. On a nonempty A, the empty relation is symmetric and transitive but not reflexive. Conversely the identity relation is reflexive, symmetric and transitive, so nonreflexivity is not forced either. Symmetry also does not imply the antisymmetry required for a partial order. Thus none of A,B,C is a necessary conclusion, giving D.

Original paper, page 2

1 mark · MCQ
Report issue

Power set of a set containing sets

Sets, Relations & Functions

Question 1.20, GATE 1995: For S={∅,1,{2,3}}, find |P(S)|.
Tap to enlarge
Your answer
Answer & solution

Answer: C: 8 (no official key was published)

The outer set S has three elements: the empty set, the number 1, and the set {2,3}. The last is one element of S, not two separate elements. A subset independently includes or omits each of the three elements, yielding 2³=8 subsets. For example ∅ and {∅} are distinct subsets; the latter contains the empty set as an element. Flattening nested braces would change the given set and produce an incorrect count.

Original paper, page 2

1 mark · MCQ
Report issue

Roots of x=cos x

Calculus

Question 1.21, GATE 1995: How many solutions does x=cos x have on [0,π]?
Tap to enlarge
Your answer
Answer & solution

Answer: B: exactly one (no official key was published)

Define g(x)=x−cos x, a continuous function. It satisfies g(0)=−1 and g(π)=π+1>0, so the intermediate value theorem gives at least one zero. On [0,π], g′(x)=1+sin x≥1, so g is strictly increasing and can have at most one zero. Combining existence and uniqueness proves exactly one solution. A graph can suggest this result, but the derivative and endpoint signs establish it rigorously.

Original paper, page 2

1 mark · MCQ
Report issue

Curve from its tangent slope

Calculus

Question 1.22, GATE 1995: A curve has dy/dx=−2x/y wherever the slope is defined. Is it a line, parabola, circle or ellipse?
Tap to enlarge
Your answer
Answer & solution

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

Multiply by y and separate variables: y dy=−2x dx. Integration gives y²/2=−x²+C, or 2x²+y²=C′. For a nondegenerate real curve C′>0, this is an ellipse with unequal axis coefficients, not a circle. C′=0 would give only a point, and C′<0 no real curve; the premise of an actual smooth curve excludes these degeneracies. At points with y=0 the displayed slope is undefined, corresponding to the ellipse’s vertical tangents.

Original paper, page 2

1 mark · MCQ
Report issue

When a quadratic is not two real lines

Other / Mixed Topics

Question 1.23, GATE 1995: For which listed k∈{0,2,9,3} does 4x²−8xy+ky²=0 fail to represent two real lines through the origin?
Tap to enlarge
Your answer
Answer & solution

Answer: C: 9 (no official key was published)

View the homogeneous quadratic as a quadratic in x/y. Its discriminant is (−8)²−4·4·k=16(4−k). Real line factors exist when k≤4. The choices 0,2,3 all satisfy that condition, while 9 does not. In fact 4x²−8xy+9y²=4(x−y)²+5y² vanishes only at the origin, not along a pair of real lines. The qualification “real” is important because complex factors exist even for a negative discriminant.

Original paper, page 3

1 mark · MCQ
Report issue

Rank with repeated rows

Linear Algebra

Question 1.24, GATE 1995: Every row of an (n+1)×(n+1) matrix is (1,a,a²,…,a^n), for real a. Find its rank.
Tap to enlarge
Your answer
Answer & solution

Answer: A: 1 (no official key was published)

All rows are identical, so the row space is spanned by a single vector and its dimension is at most one. That vector is nonzero for every a because its first coordinate is 1. Hence the dimension is at least one, proving rank exactly one. In particular a=0 does not make the matrix zero: its first column remains all ones. The result is independent of a and of the number of repeated rows.

Original paper, page 3

1 mark · MCQ
Report issue

Fewest edges in a connected cyclic graph

Graph Theory

Question 1.25, GATE 1995: What is the minimum number of edges in a connected graph on n vertices containing a cycle?
Tap to enlarge
Your answer
Answer & solution

Answer: B: n (no official key was published)

Every connected graph contains a spanning tree with n−1 edges. A tree has no cycle, so at least one further edge is necessary. Adding one non-tree edge to a spanning tree creates a cycle while retaining connectivity, attaining n edges. Thus n is both a lower bound and achievable for a simple graph with n≥3. If “cycle graph” means precisely the graph Cn, it likewise has exactly n edges.

Original paper, page 3

2 marks · MCQ
Report issue

Doubling a register pair

Instructions & Addressing Modes

Question 2.1, GATE 1995: Which two 8085 instructions double DE and leave the result in HL: XCHG/DAD B, XTHL/DAD H, PCHL/DAD D, or XCHG/DAD H?
Tap to enlarge
Your answer
Answer & solution

Answer: D: XCHG; DAD H (no official key was published)

XCHG exchanges the DE and HL register pairs, so HL receives the original DE. DAD H then adds HL to itself and stores the 16-bit result in HL. Thus the pair produces twice the original DE, modulo 216, with carry recording overflow. DAD B would add BC rather than double HL; XTHL exchanges with stack memory; PCHL changes control flow. These different effects rule out the other sequences.

Original paper, page 3

2 marks · MCQ
Report issue

Address and data wires

Memory Organization & Address Translation

Question 2.2, GATE 1995: A memory stores 4K words of 16 bits each. How many separate address and data lines are needed?
Tap to enlarge
Your answer
Answer & solution

Answer: C: 12 address,16 data (no official key was published)

With K=1024, 4K=4096=212 distinct words, so selecting one requires 12 address bits. Each selected word contains 16 bits, transferred over 16 parallel data lines in the stated separate-bus model. Multiplying words by bits gives total capacity, but not the address-line count: addresses select words, not individual bits here. The answer assumes no address multiplexing or serial data interface, consistent with the requested separate lines.

Original paper, page 3

2 marks · MCQ
Report issue

Repeated subtraction algorithm

Correctness, Invariants & Design

Question 2.3, GATE 1995: For positive integers X,Y, repeatedly replace the larger by its difference from the smaller until X=Y, then print X. What is computed?
Tap to enlarge
Your answer
Answer & solution

Answer: C: gcd of the original integers (no official key was published)

For X>Y, gcd(X,Y)=gcd(X−Y,Y), because the common divisors are unchanged by subtraction. The symmetric identity holds when Y>X. Thus every loop preserves the original gcd. Both variables remain positive, and their sum strictly decreases on each iteration, so the process terminates. At termination X=Y, whose gcd is that common value. The printed result is therefore the original gcd, not their lcm or the quotient of a single division.

Original paper, page 3

2 marks · MCQ
Report issue

A value parameter shadows a global

Runtime Environments & Parameter Passing

Question 2.4, GATE 1995: Pascal has global integer X=2 and procedure FIND(X:real) assigning X:=sqrt(X). After FIND(X), what does printing global X produce?
Tap to enlarge
Your answer
Answer & solution

Answer: A: 2 under the intended Pascal value-parameter program (no official key was published)

Without the keyword var, the procedure parameter is passed by value. Its local X receives a real copy of the argument and shadows the global name inside FIND. Assigning sqrt(X) changes only that local copy; it does not assign to the global integer. On return the global X is still 2, so printing it yields 2. The the paper omits some statement separators; this analysis uses the intended syntactically separated program rather than treating formatting omissions as executable Pascal.

Original paper, page 3

2 marks · MCQ
Report issue

Boolean equations and complement scope

Boolean Algebra & Logic Gates

Question 2.5, GATE 1995: Solve ¬A+AB=0, AB=AC, AB+A¬C+CD=¬C·D in GFG. GateForum instead appears to print ¬(CD) on the last right side.
Tap to enlarge
Your answer
Answer & solution

Answer: A: (1,0,0,1) (no official key was published)

The first equation is an OR equal to zero, forcing ¬A=0 and AB=0. Hence A=1 and B=0. The second equation then forces C=0. Substituting into the third leaves 1=D under the reading ¬C·D, so D=1. Complement scope is therefore a material the paper difference, not a cosmetic notation choice.

Original paper, page 3

2 marks · MCQ
Report issue

Intentional idling for a scheduling objective

CPU Scheduling

Question 2.6, GATE 1995: Nonpreemptive jobs (arrival,burst) are 1:(0,9),2:(0.6,5),3:(1,1). Which listed sequence is optimal, with how much idle time?
Tap to enlarge
Your answer
Answer & solution

Answer: A: [3,2,1],idle 1, for minimum total completion/turnaround time (no official key was published)

Wait until time 1, run job 3 to time 2, job 2 to time 7 and job 1 to time 16. Completion times sum to 25. For each of the six orders, starting each job as early as its order permits gives sums 38,34,27.8,35.8,25,29 respectively for 123,132,231,213,321,312. Thus 321 minimizes their sum and leaves the CPU idle for one initial time unit. Subtracting fixed arrival times shows the same order minimizes mean turnaround and waiting time. The source says “optimal” without specifying this objective; minimizing makespan alone would instead avoid initial idling.

Original paper, page 3

2 marks · MCQ
Report issue

Page faults with a single frame

Virtual Memory & Paging

Question 2.7, GATE 1995: With 100 records per page and one initially free frame, access 0100,0200,0430,0499,0510,0530,0560,0120,0220,0240,0260,0320,0370. How many faults?
Question 2.7, GATE 1995: With 100 records per page and one initially free frame, access 0100,0200,0430,0499,0510,0530,0560,0120,0220,0240,0260,0320,0370. How many faults?
Tap to enlarge
Your answer
Answer & solution

Answer: C: 7 (no official key was published)

Treating addresses as the stated decimal record numbers, integer division by 100 gives pages 1,2,4,4,5,5,5,1,2,2,2,3,3. With just one frame, a fault occurs on the first reference and each change of page. The seven consecutive runs are 1 | 2 | 4,4 | 5,5,5 | 1 | 2,2,2 | 3,3. Thus there are seven faults. Leading zeros are address formatting here, not C octal literals; interpreting them as octal would be incompatible with the printed digit 9.

Original paper, page 3

2 marks · MCQ
Report issue

Using cube roots of unity

Other / Mixed Topics

Question 2.8, GATE 1995: If 1,ω,ω² are cube roots of unity, find roots of (x−1)³+8=0.
Tap to enlarge
Your answer
Answer & solution

Answer: C: −1,1−2ω,1−2ω² (no official key was published)

The equation says (x−1)³=−8. Since (−2)³=−8, all three cube roots are −2 times the cube roots of unity: −2,−2ω,−2ω². Adding 1 yields −1,1−2ω,1−2ω². Each substitution cubes back to −8 because ω³=1. Changing the sign to plus 2 would solve the equation with +8 on the other side instead, so the negative sign is essential.

Original paper, page 4

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

String head and tail operations

Other / Mixed Topics

Question 2.9, GATE 1995: For s=acbc, head returns the first character, tail removes it, and concat joins strings. Evaluate concat(head(s),head(tail(tail(s)))).
Tap to enlarge
Your answer
Answer & solution

Answer: C: ab (no official key was published)

Starting with s=acbc, the first tail is cbc and the second is bc. The head of that second tail is b. Separately head(s)=a. Concatenating a and b gives ab. This follows the nesting from the inside outward; taking only one tail would produce c instead. Among ac,bc,ab,cc, this is option C.

Original paper, page 4

2 marks · MCQ
Report issue

Reduction-time translation

Semantic Analysis & Type Checking

Question 2.10, GATE 1995: Grammar S→xxW {print1}, S→y {print2}, W→Sz {print3}. What is printed by a shift-reduce parse of xxxxyzz?
Tap to enlarge
Your answer
Answer & solution

Answer: A: 23131 (no official key was published)

Step through it (14 steps)

The innermost y reduces to S first, printing 2. That S followed by z reduces to W, printing 3. The preceding xx and this W reduce to S, printing 1. The remaining outer z then permits W→Sz, printing another 3, and the remaining outer xxW reduces to S, printing the last 1. Thus the output is 23131. Actions occur after reductions, giving inside-out order rather than the order of productions in a top-down derivation.

Original paper, page 4

2 marks · MCQ
Report issue

Storage of a Pascal variant record

Runtime Environments & Parameter Passing

Question 2.11, GATE 1995: A record has one integer number and alternative fields (x,y:integer) or (p,q:real). With 4-byte integers and 8-byte reals, how much storage for 100 records?
Question 2.11, GATE 1995: A record has one integer number and alternative fields (x,y:integer) or (p,q:real). With 4-byte integers and 8-byte reals, how much storage for 100 records?
Tap to enlarge
Your answer
Answer & solution

Answer: C: 2000 bytes without padding or a stored tag (no official key was published)

Alternative fields share the same region; the record does not store both variants simultaneously. The integer pair needs 8 bytes and the real pair 16, so the variant region must reserve their maximum, 16. Add the common integer field’s 4 bytes to get 20 per record, or 2000 for 100. This assumes the abstract packed/no-padding model and no separately stored discriminant, as the intended choices do. An implementation aligning 8-byte real fields might use 24 bytes per record instead; byte sizes alone do not determine actual ABI padding.

Original paper, page 4

2 marks · MCQ
Report issue

Counting set bits using hexadecimal

Number Systems & Computer Arithmetic

Question 2.12, GATE 1995: Count ones in the binary representation of 3·4096+15·256+5·16−3 in GFG; the alternate prints +3.
Tap to enlarge
Your answer
Answer & solution

Answer: C: 10 (no official key was published)

Before subtracting three, the number is hexadecimal 3F50. Subtracting gives 3F4D, whose nibbles 0011,1111,0100,1101 contain 2+4+1+3=10 ones. Thus the answer happens to agree despite the different arithmetic expressions. The subtraction borrows from the previous nibble; treating its low digit as an independent negative digit would not give a binary representation.

Original paper, page 4

2 marks · MCQ
Report issue

A unit vector orthogonal to two vectors

Linear Algebra

Question 2.13, GATE 1995: Find a unit vector perpendicular to a=2i−3j+k and b=i+j−2k.
Tap to enlarge
Your answer
Answer & solution

Answer: A: (i+j+k)/sqrt(3) (no official key was published)

Their cross product is (5,5,5): its components are (−3)(−2)−1·1, 1·1−2(−2), and 2·1−(−3)·1. Its length is 5sqrt(3), so normalization gives (1,1,1)/sqrt(3). Direct checks give a·(1,1,1)=0 and b·(1,1,1)=0. The negative vector is also a valid unit normal, but among the listed alternatives the positive normalized one is A. A divisor of 3 would not give unit length. The answer A therefore follows the the paper −3 coefficient, not that alternate variant.

Original paper, page 4

2 marks · MCQ
Report issue

Drawing opposite colors

Probability & Random Variables

Question 2.14, GATE 1995: A bag holds 10 white and 15 black balls. Two are drawn successively. Find the probability of one of each color.
Tap to enlarge
Your answer
Answer & solution

Answer: C: 1/2 (no official key was published)

The disjoint orders are white then black and black then white. Their probabilities are (10/25)(15/24) and (15/25)(10/24). Adding gives 300/600=1/2. Equivalently there are 10·15 mixed unordered pairs among C(25,2)=300 pairs. The calculation assumes the first ball is not replaced, the usual interpretation of successive draws from the bag; with replacement the answer would instead be 12/25, which is not the listed value.

Original paper, page 4

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Newton square-root iteration

Numerical Methods

Question 2.15, GATE 1995: What is the Newton–Raphson iteration for the positive square root of b?
Tap to enlarge
Your answer
Answer & solution

Answer: B: x_next=(x²+b)/(2x) (no official key was published)

Set f(x)=x²−b and f′(x)=2x. Newton’s formula gives x_next=x−f(x)/f′(x)=x−(x²−b)/(2x)=(x²+b)/(2x). Starting with positive x and b keeps the iterates positive and approaches the positive root. The denominator must not be zero. The alternative form (x+b/x)/2 makes clear that each step averages the current estimate with the reciprocal-scaled estimate b/x.

Original paper, page 4

2 marks · MCQ
Report issue

Address space versus installed storage

Virtual Memory & Paging

Question 2.16, GATE 1995: Must the CPU-addressable virtual space be smaller or larger than physical memory and secondary storage?
Tap to enlarge
Your answer
Answer & solution

Answer: C under the textbook larger-than-RAM/smaller-than-backing-store model; no universal “must” (no official key was published)

Virtual memory commonly lets a process use an address space larger than the currently installed RAM, with inactive pages backed by secondary storage. Under a simple fully backed textbook model, this motivates larger than physical memory and smaller than backing storage, choice C. But address-bit width defines a possible address space, not a promise that every possible address is allocated or backed simultaneously. Sparse mappings, demand-zero pages and reservation policies break the claimed universal inequality. Thus the word “must” is too strong without the fully allocated/backed model, and actual capacity ratios are architecture and configuration dependent.

Original paper, page 4

2 marks · MCQ
Report issue

Invertible matrices as a group

Algebraic Structures

Question 2.17, GATE 1995: For nonsingular real matrices under multiplication, are they merely closed, a semigroup, a monoid, or a nonabelian group?
Tap to enlarge
Your answer
Answer & solution

Answer: D for a fixed square dimension n≥2 (no official key was published)

For fixed n, the product of invertible matrices is invertible because (AB)⁻¹=B⁻¹A⁻¹. Matrix multiplication is associative, the identity matrix is present, and every member has an inverse, so this is a group. For n≥2 it is noncommutative: diagonal scaling diag(2,1) and the coordinate-swap matrix have different products in the two orders. Thus D holds under that convention. The question omits dimension: all sizes together do not form a multiplication group, while n=1 gives an abelian group of nonzero reals.

Original paper, page 5

2 marks · MCQ
Report issue

Solving a constant-coefficient ODE

Calculus

Question 2.18, GATE 1995: Find the general solution of y″+3y′+2y=0.
Tap to enlarge
Your answer
Answer & solution

Answer: C: C1e^−x+C2e^−2x (no official key was published)

Try y=erx. Substitution gives the characteristic equation r²+3r+2=0, which factors as (r+1)(r+2)=0. The two distinct roots are −1 and −2, giving independent solutions e−x and e−2x. Linearity yields their arbitrary linear combination C1e−x+C2e−2x. Positive exponential roots would not satisfy the characteristic equation, and an x multiplier is needed only for a repeated root, which is absent here.

Original paper, page 5

2 marks · MCQ
Report issue

Truth value under an implication premise

Propositional & Predicate Logic

Question 2.19, GATE 1995: Given ¬p→q is true, determine ¬p∨(p→q).
Tap to enlarge
Your answer
Answer & solution

Answer: D: cannot be determined (no official key was published)

The premise ¬p→q simplifies to p∨q. The requested expression simplifies to ¬p∨(¬p∨q)=¬p∨q, which is p→q. Set p=true,q=false: the premise is true but the requested expression is false. Set p=false,q=true: both are true. Thus the premise permits both truth values, so D is correct.

Original paper, page 5

2 marks · MCQ
Report issue

A grammar versus regular expressions for equal counts

Regular Expressions & Languages

Question 2.20, GATE 1995: For L={x^n y^n:n≥1}, compare I E→xEy|xy; II xy | x⁺xyy⁺; III x⁺y⁺. Which define L?
Tap to enlarge
Your answer
Answer & solution

Answer: A: I only (no official key was published)

Grammar I starts with xy and each recursive wrapping adds one x to the front and one y to the end. It therefore generates exactly equal positive block counts. Expression III permits unequal counts, for example xyy. Expression II permits independently sized positive runs before its extra x and after its first y; for example xxyyy is accepted but has unequal counts. Hence neither regular expression enforces equality. Only I defines L, in agreement with the fact that the equal-count language is not regular.

Original paper, page 5

2 marks · MCQ
Report issue

Postfix and addition association

Intermediate Code

Question 2.21, GATE 1995: Convert A+B*(C+D)/F+D*E to postfix using ordinary precedence and left associativity.
Tap to enlarge
Your answer
Answer & solution

Answer: Exact: ABCD+*F/+DE*+; listed B reassociates the additions (no official key was published)

First convert C+D to CD+, multiply by B to obtain BCD+*, and divide by F to obtain BCD+*F/. Ordinary left-associative addition then combines A with that term, before adding DE*, yielding ABCD+*F/+DE*+. Listed B is ABCD+*F/DE*++, which instead parses A+(B*(C+D)/F+D*E). These have the same value over exact arithmetic because addition is associative, explaining the intended B, but they are not identical parse-tree conversions and can differ with floating-point rounding. The distinction is retained rather than labeling the printed postfix exactly left associative.

Original paper, page 5

2 marks · MCQ
Report issue

Hashing, recursion and search efficiency

Searching, Sorting & Selection

Question 2.22, GATE 1995: Evaluate I more hash entries increase collisions; II recursive programs are efficient; III quicksort worst case O(n²); IV binary search on a linear linked list is efficient.
Question 2.22, GATE 1995: Evaluate I more hash entries increase collisions; II recursive programs are efficient; III quicksort worst case O(n²); IV binary search on a linear linked list is efficient.
Tap to enlarge
Your answer
Answer & solution

Answer: D: I and III under the usual fixed-table expected-collision interpretation (no official key was published)

Quicksort can repeatedly split off only one pivot, giving (n−1)+(n−2)+…+1=Θ(n²), so III holds. In a fixed-size table under uniform hashing, adding keys increases expected collision pressure, supporting I in the conventional sense. Recursion alone guarantees no efficiency bound, and a linked list lacks constant-time midpoint access, so II and IV are not general truths. Strictly, a particular inserted key can land in an empty bucket without adding a collision; “increases” in I is an expected trend or nondecreasing count, not a guaranteed strict increase at every insertion.

Original paper, page 5

2 marks · MCQ
Report issue

Synchronizing an unknown machine state

Finite-State Machine Design

Question 2.23, GATE 1995: A four-state machine has next states under input 1 of A→D, B→B, C→B, D→B, and under input 0 of A→B, B→C, C→D, D→C. Starting from an unknown state, find the shortest input sequence that guarantees state C. Options: (A) 01, (B) 10, (C) 101, (D) 110.
Tap to enlarge
Your answer
Answer & solution

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

Initially the possible states are {A,B,C,D}. Applying input 1 reduces this set to {B,D}: A goes to D, while B,C,D go to B. Applying input 0 then sends both B and D to C, so 10 guarantees C. The four paths are A→D→C, B→B→C, C→B→C and D→B→C. No shorter word works: the empty word leaves the initial state unknown, input 0 yields {B,C,D}, and input 1 yields {B,D}. Therefore length two is minimal and option B, 10, is correct. The output labels z do not affect the target-state requirement.

Original paper, page 5

2 marks · MCQ
Report issue

Union with the universal binary language

Regular Expressions & Languages

Question 2.24, GATE 1995: Let Σ={0,1}, L=Σ*, R={0^n1^n:n>0}. Classify L∪R and R as regular or nonregular.
Tap to enlarge
Your answer
Answer & solution

Answer: C: regular,nonregular (no official key was published)

Every member of R is a binary word, so R⊆Σ*=L. Hence L∪R=L, which is regular. R itself is nonregular: if its pumping length were p, the word 0p1p would have a pumpable nonempty segment entirely among its first p zeros. Pumping that segment changes the number of zeros but not ones, leaving R and contradicting the lemma. Thus adjoining R to a universal regular language does not make the union nonregular.

Original paper, page 5

2 marks · MCQ
Report issue

Set and offset bits in a cache

Cache Memory

Question 2.25, GATE 1995: A 4K-word cache is four-way set associative with 64 words per block. Find SET and WORD field widths.
Tap to enlarge
Your answer
Answer & solution

Answer: D: 4 set bits,6 word bits (no official key was published)

Step through it (5 steps)

The cache contains 4096/64=64 blocks. Grouping four blocks per set gives 64/4=16 sets, requiring log₂16=4 set-index bits. A block contains 64 words, requiring log₂64=6 word-offset bits. Associativity changes the number of sets, not the within-block offset. No tag width can be computed without the total main-memory address width, but it is not requested. These counts use word addresses, as specified, rather than adding an unstated byte offset.

Original paper, page 5

Descriptive
Report issue

Evaluate unsigned byte arithmetic

Data Representation & Arithmetic

Question 3, GATE 1995: A and B are unsigned bytes with A=5CH and B=92H; W,X,Y are unsigned bytes and Z is a two-byte unsigned integer. Execute X:=A+B; Y:=abs(A−B); W:=A−B; Z:=A*B. Give the stored values and error conditions. GFG supplies this Y statement; GateForum prints malformed abs(bA-b).
Question 3, GATE 1995: A and B are unsigned bytes with A=5CH and B=92H; W,X,Y are unsigned bytes and Z is a two-byte unsigned integer. Execute X:=A+B; Y:=abs(A−B); W:=A−B; Z:=A*B. Give the stored values and error conditions. GFG supplies this Y statement; GateForum prints malformed abs(bA-b).
Tap to enlarge
Answer & solution

Answer: With widened intermediates: X=EEH, Y=36H, Z=3478H; W underflows (CAH if wrapping). (no official key was published)

Convert the hexadecimal operands first: A=92 and B=146. Their sum is 238=EEH, within the unsigned-byte range 0 through 255. Their mathematical difference is −54, so its absolute value is 54=36H. The product is 13432=3478H, within the unsigned 16-bit range. Thus X and Z fit their declared destinations and Y fits if abs receives the mathematical signed difference.

W cannot represent −54. A checked implementation reports a range/underflow error; an explicitly wrapping 8-bit implementation stores −54 modulo 256=202=CAH. These are distinct execution models, not two simultaneous outcomes. If execution traps at W, the subsequent assignment to Z is not reached.

There is also an intermediate-arithmetic ambiguity: if A−B is evaluated as an unsigned 8-bit operation before abs, it becomes CAH=202 and abs leaves it unchanged, giving Y=CAH instead of 36H. Similarly Z requires multiplication in a sufficiently wide type, not truncation to a byte before assignment. The pseudocode does not specify these rules or byte order. Report Z as the word 3478H, with bytes 34H and 78H in unspecified order.

Original paper, page 5

Descriptive
Report issue

Evaluate a binomial recurrence

Asymptotic Analysis & Recurrences

Question 4(a), GATE 1995: GET(A,B)=1 if B=0; otherwise GET(A,B)=0 if A<B; otherwise GET(A−1,B)+GET(A−1,B−1). Find GET(3,2).
Tap to enlarge
Answer & solution

Answer: 3 (no official key was published)

Step through it (23 steps)

The base case with B=0 represents the single way to choose no elements. The A<B case represents the impossibility of choosing more elements than are available. The recursive case separates choices according to whether the last element is excluded or included; it is Pascal’s binomial recurrence.

Expand the requested call rather than assuming a closed form: GET(3,2)=GET(2,2)+GET(2,1). The first term is GET(1,2)+GET(1,1)=0+[GET(0,1)+GET(0,0)]=0+0+1=1. The second is GET(1,1)+GET(1,0)=1+1=2. Hence the result is 3, agreeing with the binomial coefficient C(3,2). The ordering of the tests matters at (0,0): B=0 is tested first and returns 1.

Original paper, page 6

Descriptive
Report issue

Repair an in-place transpose

Arrays & Linked Lists

Question 4(b), GATE 1995: An N×N integer array A (1<N≤20) is transposed by: for I:=1 to N−1 do for J:=1 to N do begin TMP:=A[I,J]; A[I,J]:=A[J,I]; A[J,I]:=TMP end. Find and correct the error.
Tap to enlarge
Answer & solution

Answer: Change the inner loop to J:=I+1 to N. (no official key was published)

Transposition must exchange each off-diagonal pair A[i,j], A[j,i] exactly once. In the supplied code, when i and j are both below N, the pair is exchanged once on iteration (i,j) and again on (j,i). The second exchange undoes the first. Pairs involving N are treated differently because the outer loop never reaches N. This is therefore not a valid general transpose, even though special inputs or N=2 can hide the fault.

Keep I from 1 through N−1 and change the inner loop to J from I+1 through N. The three assignments in the swap body can remain unchanged. Every unordered off-diagonal pair has exactly one representative with i<j, so it is visited once; diagonal entries need no work. The algorithm performs N(N−1)/2 swaps, takes Θ(N²) time and uses one temporary integer. Afterward every old A[i,j] has moved to A[j,i].

Original paper, page 6

Descriptive
Report issue

Trace first fit and best fit

Memory Allocation & Segmentation

Question 5(a), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Draw both memory allocation sequences.
Question 5(a), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Draw both memory allocation sequences.
Tap to enlarge
Answer & solution

Answer: First fit admits all jobs; best fit cannot admit J6. (no official key was published)

Use half-open address intervals in K so that [0,200) has size 200. Both algorithms initially allocate J1=[0,200), J2=[200,550), J3=[550,850), leaving [850,1000) free. When J1 finishes, the holes are [0,200) and [850,1000).

First fit: J4 takes [0,120), leaving holes [120,200) of size 80 and [850,1000) of size 150. J5 cannot fit in 80, so it occupies [850,1000). J6 then exactly fills [120,200). Final low-to-high layout is J4:120 | J6:80 | J2:350 | J3:300 | J5:150.

Best fit: J4 takes the smaller adequate hole [850,1000), occupying [850,970) and leaving 30K. J5 takes [0,150), leaving [150,200) of size 50. J6 needs 80K but neither the 50K nor 30K hole suffices. Final layout is J5:150 | free:50 | J2:350 | J3:300 | J4:120 | free:30, with J6 waiting.

The total free space is 80K, equal to J6’s request, but it is split into nonadjacent holes. This is external fragmentation, not a shortage of aggregate space.

Original paper, page 6

Descriptive
Report issue

Compare allocation outcomes

Memory Allocation & Segmentation

Question 5(b), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Which policy performs better for this sequence?
Question 5(b), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Which policy performs better for this sequence?
Question 5(b), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Which policy performs better for this sequence?
Tap to enlarge
Answer & solution

Answer: First fit. (no official key was published)

First fit places the 120K job in the initial 200K hole, preserving an 80K remainder. It then puts the 150K job in the separate 150K hole and admits the final 80K job into the exact remainder. Consequently every arriving job is resident at the end, filling all 1000K.

Best fit uses the 150K hole for the 120K request, leaving 30K. The later 150K request takes 150K out of the 200K hole, leaving 50K. Although 50+30=80, the final 80K request requires one contiguous region and cannot be admitted without relocation or compaction. First fit therefore performs better on the stated admission/utilization criterion. This trace is a counterexample to the intuition that the locally smallest leftover always leads to the best future allocation. It is not a proof that first fit dominates best fit for every workload.

Original paper, page 6

Descriptive
Report issue

Enumerate postorder binary trees

Tree Properties & Traversals

Question 6, GATE 1995: How many ordered binary trees on three nodes have postorder A,B,C? Draw all of them.
Tap to enlarge
Answer & solution

Answer: 5 (no official key was published)

Postorder visits the left subtree, then the right subtree, then the root, so C must be the root. Partition the first two labels between its subtrees. If both subtrees are nonempty, each has one node: left A and right B. If only one subtree is nonempty, that subtree has postorder A,B, so its root is B and A can be either B’s left or right child. The two-node subtree itself can be C’s left or right child, giving four more trees.

A compact complete drawing uses node(left,right), with ∅ denoting an absent child:
1. C(A,B)
2. C(B(A,∅),∅)
3. C(B(∅,A),∅)
4. C(∅,B(A,∅))
5. C(∅,B(∅,A)).
Here A or B written without parentheses is a leaf. Each drawing emits A then B then C under postorder. The cases exhaust left-subtree sizes 0,1,2, giving the Catalan count C₃=C₀C₂+C₁C₁+C₂C₀=2+1+2=5. Left and right child positions are distinguished; these are not restricted to full binary trees.

Original paper, page 6

Descriptive
Report issue

Count positive divisors

Combinatorics & Counting

Question 7(a), GATE 1995: Determine the number of divisors of 600.
Tap to enlarge
Answer & solution

Answer: 24 positive divisors; 48 if signed integer divisors are requested. (no official key was published)

Prime-factorize 600=6×100=2³×3¹×5². Every positive divisor has a unique form 2ᵃ3ᵇ5ᶜ where a∈{0,1,2,3}, b∈{0,1} and c∈{0,1,2}. There are four choices for a, two for b and three for c. The choices are independent, so the multiplication principle gives 4×2×3=24.

The factorization also explains why adding these counts would be wrong: one divisor is determined by choosing all three exponents together. Both 1 (all exponents zero) and 600 (all exponents maximal) are included. In standard elementary-number-theory exam usage “number of divisors” counts positive divisors. If the question instead meant all nonzero integer divisors, every positive divisor has a distinct negative partner, giving 48.

Original paper, page 6

Descriptive
Report issue

Evaluate the sine limit

Calculus

Question 7(b), GATE 1995: Without power-series expansion, compute lim(x→0) sin(x)/x, with x in radians. GFG prints denominator x; GateForum prints denominator 0.
Tap to enlarge
Answer & solution

Answer: 1 (no official key was published)

For 0<x<π/2, the unit-circle area comparison gives sin x < x < tan x. Divide the first inequality by positive x, and rearrange the second to obtain cos x < sin x/x < 1. As x→0 from the right, both bounding functions tend to 1. The squeeze theorem therefore gives the right-hand limit 1 without a power series.

The quotient is even away from zero: sin(−x)/(−x)=sin x/x. Its left-hand limit equals the right-hand limit, so the two-sided limit is 1. The function need not be defined at x=0 for this limit to exist. Radian measure is essential to the value 1.

The answer 1 belongs to the denominator-x the paper; it is not an evaluation of division by zero.

Original paper, page 6

5 marks · Descriptive
Report issue

Construct a predictive parsing table

Parsing & Syntax Analysis

Question 8, GATE 1995: Construct the LL(1) table for productions: 1 E→−E; 2 E→(E); 3 E→V T; 4 T→−E; 5 T→ε; 6 V→id U; 7 U→(E); 8 U→ε; 9 G→E$. Here E=Expr,T=ExprTail,V=Var,U=VarTail,G=Goal; $ is the end marker.
Tap to enlarge
Answer & solution

Answer: Non-error entries: E: −→1, (→2, id→3; T: −→4, )/$→5; V: id→6; U: (→7, −/)/$→8; G: −/(/id→9. (no official key was published)

FIRST(E)={−,(,id}, FIRST(T)={−,ε}, FIRST(V)={id}, FIRST(U)={(,ε}, and FIRST(G)={−,(,id}. E can be followed by a closing parenthesis in productions 2 and 7, or by $ in production 9. Its appearances at the ends of productions 1 and 4 add no new terminals. Hence FOLLOW(E)=FOLLOW(T)={),$}. From E→VT, FOLLOW(V)={−,),$}; U is at the end of V→idU, so FOLLOW(U)={−,),$}.

Place each nonnullable production under the terminals in its right-hand FIRST set. Place each ε-production under FOLLOW of its left-hand side. The complete table, listing columns in the order −, (, id, ), $, is:
E: [1,2,3,error,error]
T: [4,error,error,5,5]
V: [error,error,6,error,error]
U: [8,7,error,8,8]
G: [9,9,9,error,error].

No cell has two productions, establishing the LL(1) property. Parentheses and the minus token are literal terminals; λ in the source denotes ε, not an input token. If $ is treated as an explicit grammar terminal, a separate meta-end marker follows it, without changing these table choices.

Original paper, page 6

Descriptive
Report issue

Build an arithmetic syntax tree

Intermediate Code

Question 9(a), GATE 1995: Translate a * −(b+c) into an abstract syntax tree.
Tap to enlarge
Answer & solution

Answer: mul(a, neg(add(b,c))) (no official key was published)

The parentheses force addition of b and c first. The minus sign immediately before the parentheses is unary negation, since it has only the parenthesized expression as operand. Multiplication then combines a with that negated result.

The tree is:
        *
       / \
      a  unary−
            |
            +
           / \
          b   c

Equivalently, its exact parenthesized representation is mul(a,neg(add(b,c))). Leaves are identifiers and internal nodes are operations. The abstract syntax tree need not contain separate parenthesis nodes because the tree structure already records grouping. It is important not to turn the unary minus into a binary subtraction with a missing left child. A code generator could evaluate add(b,c), negate its result, and finally multiply by a; the tree expresses that dependency regardless of the eventual instruction order.

Original paper, page 6

Descriptive
Report issue

Explain cycles and LL(1) parsing

Context-Free Grammars & Languages

Question 9(b), GATE 1995: A grammar has a cycle if A⇒⁺A for some nonterminal A. Show that a grammar with cycles cannot be LL(1), stating any necessary qualification.
Tap to enlarge
Answer & solution

Answer: A useful/productive cycle is incompatible with LL(1); the unrestricted claim needs a reduced-grammar assumption. (no official key was published)

Assume the cyclic nonterminal A is reachable in a successful derivation and can derive a terminal string w (possibly ε). Starting at A, one may derive w directly, or first traverse the nonempty cycle A⇒⁺A and then derive the same w. Inserting the cycle into a successful start-symbol derivation gives two distinct parse trees for the same terminal string. Every LL(1) grammar is unambiguous, so this useful cyclic grammar cannot be LL(1).

Operationally, a predictive parser cannot decide from the same next input symbol whether to begin another traversal of a nullable cycle or leave it to produce the terminal string. The proof concerns a cycle deriving A itself, not ordinary right recursion such as A→aA, which consumes input and can be LL(1).

The statement as printed omits the usual reduced-grammar qualification. As a literal counterexample, S→a with an unreachable rule A→A generates only a and has a conflict-free predictive table for all successful parses from S; the unreachable cycle contributes no competing table entry. A nonproductive cycle likewise cannot be inserted in a successful parse. Thus the intended theorem is valid for reduced grammars, or for cycles on useful nonterminals, rather than arbitrary added useless rules.

Original paper, page 6

Descriptive
Report issue

Resolve Pascal record scopes

Runtime Environments & Parameter Passing

Question 10(a), GATE 1995: procedure T(U,V,X,Y:integer); var A:record A,B:integer end; B:record B,A:integer end; begin with A do begin A:=4; B:=V end; with B do begin A:=X; B:=Y end end. Identify the declarations bound to each A and B occurrence.
Tap to enlarge
Answer & solution

Answer: First with assigns A.A=4 and A.B=V; second assigns B.A=X and B.B=Y. (no official key was published)

There are six distinct declarations with these spellings: two outer record variables, outer A and outer B, and two integer fields inside each record. A field name belongs to its record’s field namespace; declaring field A does not replace the surrounding record variable A.

In “with A do”, the selector A is resolved before entering the with environment, so it denotes the outer record variable A. Within that body, unqualified field identifiers take precedence: the assignment A:=4 means outer-A.A:=4, while B:=V means outer-A.B:=V. V remains the procedure parameter.

That with scope ends at its end. Therefore the selector in the following “with B do” denotes the outer record B, not the field B from the preceding block. Within the second body, A:=X means outer-B.A:=X and B:=Y means outer-B.B:=Y. X and Y are parameters. The field declarations in the first record define A.A and A.B; those in the second define B.B and B.A. Parameter U is unused in the displayed the paper.

Original paper, page 6

Descriptive
Report issue

Distinguish Pascal lexical and syntax errors

Lexical Analysis

Question 10(b), GATE 1995: Identify errors in: if A > 1, then B = 2.5A else read(C);
Tap to enlarge
Answer & solution

Answer: Remove the comma, use := for assignment, and replace the malformed/adjacent 2.5A with a valid expression such as 2.5*A if multiplication was intended. (no official key was published)

The comma after 1 is not allowed between an if condition and then. Delete it. The then branch needs a statement; B=... is a comparison expression, not Pascal assignment, so use B:=.... Neither comma nor = is an invalid token by itself: their placement/use is a syntactic error.

The character sequence 2.5A is not one valid Pascal numeric literal. A scanner may report an invalid numeric suffix, or tokenize it as the real literal 2.5 followed by identifier A, depending on its lexical rules. In the latter case the parser still rejects the adjacent operands because no operator connects them. Pascal has no implicit multiplication. If multiplication was intended, write 2.5*A; if the A was accidental, deleting it is a different possible repair.

Under the multiplication interpretation a corrected statement is “if A > 1 then B := 2.5*A else read(C);”. Whether assigning this real-valued expression to B is type-correct additionally depends on B’s declaration, which the question does not provide. Calling all three faults lexical is imprecise; the solution distinguishes token formation from grammar and typing.

Original paper, page 6

5 marks · Descriptive
Not in GATE 2027 syllabusReport issue

Certify the complement of a thin NP language

Complexity & Reductions

Question 11, GATE 1995: L⊆Σ* is in NP and contains exactly one string of each length n. Prove its complement is in NP.
Tap to enlarge
Answer & solution

Answer: For x, certify a different same-length y∈L using its NP witness. (no official key was published)

Since L is in NP, there is a polynomial-time verifier V(y,c) and a polynomial bound on certificates c such that y∈L exactly when some c makes V accept. To verify that x is in the complement, guess a pair (y,c), require |y|=|x| and y≠x, and run V(y,c). Accept precisely when all checks pass.

Completeness: if x∉L, the hypothesis guarantees a string y∈L of length |x|. It cannot equal x, and it has an accepting NP certificate, so the new verifier has an accepting guess. Soundness: if x∈L, uniqueness says no different same-length y lies in L. Therefore no proposed pair can pass all checks.

The guessed y has length n, its certificate has polynomial length in n, and both comparison and verification take polynomial time. This proves the complement is in NP without assuming NP=coNP. Both parts of “exactly one” matter: existence supplies a witness on complement instances, while uniqueness prevents false acceptance on member instances. At length zero the only word is ε, which is in L, and no different same-length word exists, so rejection is correct.

Original paper, page 7

5 marks · Descriptive
Report issue

Trace five bubble-sort passes

Searching, Sorting & Selection

Question 12, GATE 1995: Sort 92,37,52,12,11,25 in ascending order by bubble sort, giving the sequence after each of the first five passes. State traversal direction.
Tap to enlarge
Answer & solution

Answer: Left-to-right passes: 37 52 12 11 25 92; 37 12 11 25 52 92; 12 11 25 37 52 92; 11 12 25 37 52 92; 11 12 25 37 52 92. (no official key was published)

Use the usual left-to-right version: compare adjacent entries and swap whenever the left entry exceeds the right. After one full pass, the largest element of the active prefix has bubbled to its final rightmost position. Shorten the active prefix by one for the next pass.

Pass 1: 37,52,12,11,25,92.
Pass 2: 37,12,11,25,52,92.
Pass 3: 12,11,25,37,52,92.
Pass 4: 11,12,25,37,52,92.
Pass 5: 11,12,25,37,52,92.
For example, in pass 1, 92 is successively swapped with 37,52,12,11,25. In pass 2, 52 moves to the penultimate position. A no-swap early-exit implementation would detect completion on pass 5 in this trace.

The source does not specify pass direction. The equally valid right-to-left version bubbles minima left and gives: [11,92,37,52,12,25], [11,12,92,37,52,25], [11,12,25,92,37,52], [11,12,25,37,92,52], [11,12,25,37,52,92]. Both reach the same sorted list; intermediate pass answers depend on the convention.

Original paper, page 7

5 marks · Descriptive
Report issue

Derive canonical conjunctive normal form

Propositional & Predicate Logic

Question 13, GATE 1995: Find the principal/canonical CNF of (p∧q)∨(¬q∧r).
Tap to enlarge
Answer & solution

Answer: (p∨q∨r)∧(p∨¬q∨r)∧(p∨¬q∨¬r)∧(¬p∨q∨r). (no official key was published)

A canonical CNF contains one maxterm for each falsifying truth assignment, with all three variables appearing once in every clause. If q=0 the formula reduces to r, so it is false at (p,q,r)=(0,0,0) and (1,0,0). If q=1 it reduces to p, so it is false at (0,1,0) and (0,1,1). The four other rows are true.

To construct a clause false at a given row, write a variable positively when that row assigns it 0 and negatively when it assigns it 1. The false rows 000,010,011,100 therefore give respectively (p∨q∨r), (p∨¬q∨r), (p∨¬q∨¬r), and (¬p∨q∨r). Their conjunction is the answer, conventionally ΠM(0,2,3,4) with p as the most significant bit.

Each maxterm rules out exactly its own false row. Thus the conjunction excludes precisely the original formula’s four false rows and accepts all others, proving equivalence. A shorter equivalent CNF might be valid Boolean algebra, but would not satisfy the requested canonical form if its clauses omitted variables.

Original paper, page 7

Descriptive
Not in GATE 2027 syllabusReport issue

Calculate disk unformatted capacity

Secondary Storage

Question 14(a), GATE 1995: A disk has 8 surfaces, outer diameter 12cm, inner diameter 4cm, track spacing 0.1mm, 20 sectors per track, and 96 bytes formatting overhead per 4000-byte data sector. Find unformatted capacity.
Question 14(a), GATE 1995: A disk has 8 surfaces, outer diameter 12cm, inner diameter 4cm, track spacing 0.1mm, 20 sectors per track, and 96 bytes formatting overhead per 4000-byte data sector. Find unformatted capacity.
Tap to enlarge
Answer & solution

Answer: 262,144,000 bytes under the standard 400-tracks-per-surface model. (no official key was published)

Tracks occupy an annulus, so use the radial width, not the difference of diameters. The usable width is (12−4)/2=4cm=40mm. At a track pitch of 0.1mm, the standard capacity model gives 40/0.1=400 tracks per surface. Eight surfaces therefore have 3200 tracks, and with 20 sectors per track there are 64,000 sectors.

Each physical sector accounts for 4000 payload bytes plus 96 overhead bytes, or 4096 unformatted bytes. Multiplying gives 64,000×4096=262,144,000 bytes. This equals 250 MiB or 262.144 decimal MB. The formatted payload capacity is instead 64,000×4000=256,000,000 bytes, a useful cross-check; the difference 6,144,000 is exactly 96×64,000.

This conventional calculation treats the annular width as 400 track pitches. Counting both boundary centerlines as tracks would require a different geometrical endpoint convention not supplied by the question. It also assumes all surfaces are usable and every track has the stated 20 sectors.

Original paper, page 7

Descriptive
Not in GATE 2027 syllabusReport issue

Calculate effective disk transfer rate

Secondary Storage

Question 14(b), GATE 1995: For the disk in 14(a), each track has 20 sectors of 4000 payload bytes plus 96 overhead bytes each. Find bytes transferred per second between disk and memory at 3600 rpm (GFG), or 360 rpm (GateForum).
Question 14(b), GATE 1995: For the disk in 14(a), each track has 20 sectors of 4000 payload bytes plus 96 overhead bytes each. Find bytes transferred per second between disk and memory at 3600 rpm (GFG), or 360 rpm (GateForum).
Question 14(b), GATE 1995: For the disk in 14(a), each track has 20 sectors of 4000 payload bytes plus 96 overhead bytes each. Find bytes transferred per second between disk and memory at 3600 rpm (GFG), or 360 rpm (GateForum).
Tap to enlarge
Answer & solution

Answer: 4,800,000 payload bytes/s at 3600 rpm; 480,000 bytes/s at 360 rpm. (no official key was published)

Effective transfer rate counts payload delivered to memory, not sector formatting bytes. A complete revolution passes 20×4000=80,000 payload bytes under the active head. At 3600 revolutions per minute, the rotational rate is 3600/60=60 revolutions per second. Thus the sustained payload rate is 80,000×60=4,800,000 bytes/s, or 4.8 decimal MB/s.

Under that literal variant the rotation rate is 6 revolutions per second and the answer is 80,000×6=480,000 bytes/s. This factor-of-ten source discrepancy must not be hidden by treating the two reproductions as identical.

The model assumes a continuous transfer from one active surface, ignores seek and rotational-start latency, and treats formatting overhead as space already occupying part of each revolution. Do not multiply the rate by eight surfaces unless simultaneous transfer from eight heads is explicitly specified. The corresponding raw byte rates including formatting would be 4,915,200 and 491,520 bytes/s, but those are not the requested effective payload rates.

Original paper, page 7

Descriptive
Report issue

Implement complemented inputs with NAND

Boolean Algebra & Logic Gates

Question 15(a), GATE 1995: Implement Z=¬A+¬B+C using an inverter and a NAND gate. Here + means OR; both A and B carry complement bars.
Tap to enlarge
Answer & solution

Answer: Invert C; feed A,B,¬C to a three-input NAND. (no official key was published)

De Morgan’s law gives ¬(A·B·¬C)=¬A+¬B+¬¬C=¬A+¬B+C. Therefore make the intermediate wire N=NOT(C) with the inverter, and connect A, B and N to a three-input NAND whose output is Z.

An exact circuit netlist is N := NOT C; Z := NAND3(A,B,N). The inverter is on C, even though the displayed formula has bars on A and B: the NAND’s output inversion supplies those two complements and changes the complement of its third input back into C.

As a truth-table check, the required OR expression is zero only when A=1, B=1 and C=0. Then N=1, all three NAND inputs are 1, and the output is 0. For every other assignment at least one NAND input is 0 and the output is 1. This uses a three-input NAND; restricting the available NAND to two inputs would require a different multi-gate implementation, which the statement does not specify.

Original paper, page 7

Descriptive
Report issue

Minimize a four-variable Karnaugh map

Logic Minimization & Karnaugh Maps

Question 15(b), GATE 1995: K-map columns AB are 00,01,11,10; rows CD are 00,01,11,10. Row values in that order are [1,0,0,1], [0,1,1,0], [0,1,1,0], [1,0,0,1]. Blank source cells mean zero. Find minimal SOP.
Tap to enlarge
Answer & solution

Answer: ¬B¬D+BD (B XNOR D). (no official key was published)

Step through it (10 steps)

Use two groups of four cells. The four corner cells form one valid group because the first and last rows are adjacent in Gray-code order, as are the first and last columns. Within that group B=0 and D=0, while A and C each vary. Its product term is ¬B¬D.

The central 2×2 block forms the other group. Its columns AB=01,11 both have B=1; its rows CD=01,11 both have D=1. A and C again vary, so this group contributes BD. The resulting sum of products is ¬B¬D+BD, independent of A and C.

Each group covers four ones and no zeros, and together they cover all eight ones. No eight-cell group is possible: the zero cells separate the two B,D cases. Each isolated case B=D=0 and B=D=1 needs its own implicant, so two two-literal products are minimal. The output is 1 exactly when B and D agree, which supplies the equivalent description B XNOR D.

Original paper, page 7

Descriptive
Report issue

Explain an 8085 memory search

Instructions & Addressing Modes

Question 16(a), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What does this program do?
Question 16(a), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What does this program do?
Tap to enlarge
Answer & solution

Answer: Searches up to ten bytes at 1C40H–1C49H for the first 05H. (no official key was published)

B starts at decimal 10, A contains the search value 05H, and HL points to 1C40H. In 8085 notation M refers to the memory byte addressed by HL. CMP M computes flags as if subtracting that byte from A, without modifying A. If the byte equals 05H, the zero flag is set and RZ returns immediately to the caller.

On a mismatch, INX H advances the address, DCR B reduces the remaining count, and JNZ repeats while the count remains nonzero. Importantly, that JNZ tests the flags from DCR B, not the earlier comparison. After ten mismatches, B becomes zero and RET returns normally. HLT then stops the main program.

Thus the routine performs a bounded linear search, examining addresses 1C40H through 1C49H and stopping on the first match. On success HL addresses that match and B is the number of positions remaining including the matched position. On failure HL points one byte beyond the searched interval and B=0. A stays 05H throughout.

Original paper, page 7

Descriptive
Report issue

Read the initialized 8085 registers

Instructions & Addressing Modes

Question 16(b), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What are the initial contents of A and B for the search?
Question 16(b), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. What are the initial contents of A and B for the search?
Tap to enlarge
Answer & solution

Answer: A=05H and B=0AH (decimal 5 and 10). (no official key was published)

MVI means “move immediate”: it loads the byte written in the instruction directly into the named register. MVI B,0AH sets B to hexadecimal 0A, which is decimal 10. MVI A,05H then sets the accumulator to hexadecimal 05, which is decimal 5. These are the initialized values just before CALL SUB, not claims about unspecified power-on register contents.

LXI H,1C40H loads the separate HL pair and does not change either A or B. CALL changes control flow and the stack, not these initialized register values. During the routine A remains the search key 05H because CMP only changes flags. B is the loop counter and can subsequently decrease. The source asks for the initial values, so a final B value derived from an assumed memory image would answer a different question.

Original paper, page 7

Descriptive
Report issue

Determine the conditional final search address

Instructions & Addressing Modes

Question 16(c), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. Find HL after execution; no memory contents are supplied.
Question 16(c), GATE 1995: MVI B,0AH; MVI A,05H; LXI H,1C40H; CALL SUB; HLT; SUB: CMP M; RZ; INX H; DCR B; JNZ SUB; RET. Find HL after execution; no memory contents are supplied.
Tap to enlarge
Answer & solution

Answer: HL=1C40H+k for first match offset k∈{0,…,9}; if absent, HL=1C4AH. (no official key was published)

Let k be the offset of the first byte equal to 05H among the ten searched locations. For every preceding mismatch the program increments HL exactly once. It therefore reaches the matching address 1C40H+k after k increments. CMP sets zero and RZ returns before INX H, leaving HL pointing directly at the match. In particular, an immediate match leaves HL=1C40H; a match in the last tested byte leaves HL=1C49H.

If all ten comparisons fail, every iteration executes INX H, including the last one. Starting at 1C40H, ten increments give 1C4AH. DCR B then makes B=0 and the routine returns without testing that next address.

No single unconditional final address can be inferred because the source gives no values for memory 1C40H–1C49H. The no-match value 1C4AH is a conditional answer, not an established fact. This distinction also avoids the common off-by-one error of returning 1C49H after ten failures.

Original paper, page 7

Descriptive
Report issue

Frame a seven-bit serial string

Data Link, Framing, Error Control & ARQ

Question 17(a.i), GATE 1995: An asynchronous start-stop link uses seven data bits, one odd-parity bit and one stop bit at 1200 bits/s. Give the complete transmitted frame for data string 0110101. State bit-order convention.
Question 17(a.i), GATE 1995: An asynchronous start-stop link uses seven data bits, one odd-parity bit and one stop bit at 1200 bits/s. Give the complete transmitted frame for data string 0110101. State bit-order convention.
Tap to enlarge
Answer & solution

Answer: As-written data order: 0|0110101|1|1 = 0011010111; LSB-first numeric order: 0|1010110|1|1 = 0101011011. (no official key was published)

The data string 0110101 contains four ones. Odd parity requires the total number of ones in the data plus parity field to be odd, so the parity bit must be 1, giving five ones. In ordinary asynchronous binary framing, the line is idle high, the start bit is 0, and the stop bit is 1. The order is start, seven data bits, parity, stop.

If the supplied string lists the data in temporal transmission order, the frame is 0 | 0110101 | 1 | 1, or 0011010111. This is the direct as-written interpretation.

UARTs conventionally transmit the least significant data bit first. If 0110101 instead denotes a seven-bit numerical value written most-significant-bit first, reverse its data order to 1010110, producing 0 | 1010110 | 1 | 1, or 0101011011. Reversal does not change parity. The question does not explicitly specify how the written string maps to bit significance, so both interpretations are identified rather than silently choosing one. Neither idle time before the start nor voltage-level inversion is an additional data bit.

Original paper, page 7

Descriptive
Report issue

Compute framed serial throughput

Physical Layer & Transmission

Question 17(a.ii), GATE 1995: An asynchronous link transmits seven-bit strings with one start bit, one odd-parity bit and one stop bit, at 1200 bits/s. How many strings per second can it transmit?
Question 17(a.ii), GATE 1995: An asynchronous link transmits seven-bit strings with one start bit, one odd-parity bit and one stop bit, at 1200 bits/s. How many strings per second can it transmit?
Tap to enlarge
Answer & solution

Answer: 120 strings/s with consecutive frames and no extra idle gaps. (no official key was published)

Count every transmitted bit, not just payload. Each frame has one start bit, seven data bits, one parity bit and one stop bit: 1+7+1+1=10 bits. A rate of 1200 bits/s therefore supports 1200/10=120 complete strings per second, assuming frames are sent back-to-back.

Equivalently, one bit lasts 1/1200 second, so one frame lasts 10/1200=1/120 second, about 8.333ms. The reciprocal is again 120 frames/s. The payload rate is 7×120=840 data bits/s and framing efficiency is 7/10=70%.

The odd-parity value and the order of the seven data bits do not affect frame length. Asynchronous operation permits extra idle time between frames, so 120 is the maximum sustained count under the stated framing, not a guarantee if the sender inserts delays. Dividing 1200 by seven would ignore required framing and overstate throughput.

Original paper, page 7

Descriptive
Report issue

Size a monochrome graphics buffer

Memory Organization & Address Translation

Question 17(b), GATE 1995: A CRT has 80×25 character cells, each 9×12 pixels. Find video-buffer RAM for monochrome graphics at one bit per pixel.
Tap to enlarge
Answer & solution

Answer: 27,000 bytes (216,000 bits), about 26.367 KiB. (no official key was published)

Convert the character grid into pixel dimensions first. There are 80×9=720 horizontal pixels and 25×12=300 vertical pixels. The bitmap therefore contains 720×300=216,000 pixels. At one bit per pixel it requires 216,000 bits, which is 216,000/8=27,000 bytes.

The same result follows by counting 80×25=2000 cells, each covering 9×12=108 pixels: 2000×108=216,000. This cross-check shows that the cell dimensions are not merely font metadata; they determine the graphics resolution. The result is 27 decimal kB or 27,000/1024≈26.367 KiB.

This is a tightly packed one-bit framebuffer. A 720-pixel row occupies exactly 90 bytes, so no padding is needed to reach a whole-byte row boundary. A device might allocate a larger power-of-two RAM bank or impose extra row alignment, but neither is specified. Text-mode character/attribute storage is not the requested buffer: the problem explicitly asks for monochrome graphics mode.

Original paper, page 7

5 marks · Descriptive
Report issue

Completing a four-bit two’s-complement conversion

Control Flow & Loop Tracing

Question 18, GATE 1995: Complete blanks A, B, C in this Pascal-like function, for integer −8≤N≤7: if N<0 then N:=A; BINARY:=0; EXPONENT:=1; while N<>0 do begin REM:=N mod 2; BINARY:=BINARY+B*EXPONENT; EXPONENT:=EXPONENT*10; N:=C end; TWOSCOMP:=BINARY. REM, EXPONENT and BINARY are integer variables. The returned decimal integer has the binary digits as its decimal digits. GFG declares REM; GateForum declares RAM but uses REM.
Question 18, GATE 1995: Complete blanks A, B, C in this Pascal-like function, for integer −8≤N≤7: if N<0 then N:=A; BINARY:=0; EXPONENT:=1; while N<>0 do begin REM:=N mod 2; BINARY:=BINARY+B*EXPONENT; EXPONENT:=EXPONENT*10; N:=C end; TWOSCOMP:=BINARY. REM, EXPONENT and BINARY are integer variables. The returned decimal integer has the binary digits as its decimal digits. GFG declares REM; GateForum declares RAM but uses REM.
Tap to enlarge
Answer & solution

Answer: A=N+16; B=REM; C=N div 2. (no official key was published)

Four bits represent signed values from −8 to 7. A negative N has the same four-bit pattern as the unsigned residue N+24=N+16. Thus the first blank is N+16: −8 maps to 8 (1000), and −1 maps to 15 (1111). Nonnegative inputs need no conversion before digit extraction.

For a nonnegative integer, N mod 2 is its least significant binary digit. The current EXPONENT is 1,10,100,1000, so adding REM*EXPONENT puts that bit in the corresponding decimal digit position of the returned integer. Hence B is REM. Integer division N div 2 discards the extracted bit; hence C is N div 2, not real division. Each iteration reduces the nonzero quotient and the loop terminates.

For N=−3, convert to 13. The remainders are 1,0,1,1, the accumulating decimal result is 1,1,101,1101, and the quotients are 6,3,1,0. Thus the result 1101 denotes the correct four-bit pattern. N=0 skips the loop and returns 0; positive outputs omit leading zero digits because they are stored as integers. Displaying exactly four bits requires zero-padding separately. Outside the guarded range the printed function does not assign its return value.

Original paper, page 7

5 marks · Descriptive
Report issue

Semaphore precedence graph

Synchronization & Concurrency

Question 19, GATE 1995: Draw the precedence graph of nine concurrent branches (separated here by |): S1;V(a);V(b) | P(a);S2;V(c);V(d) | P(c);S4;V(e) | P(d);S5;V(f) | P(e);P(f);S7;V(k) | P(b);S3;V(g);V(h) | P(g);S6;V(i) | P(h);P(i);S8;V(j) | P(j);P(k);S9. All variables a through k are semaphores. This is the GFG version. GateForum instead has V(c) after S4 and P(j);P(j);P(k) before S9. Initial semaphore values are not explicitly supplied; state the synchronization assumption.
Tap to enlarge
Answer & solution

Answer: With semaphores initially zero: 1→2, 1→3, 2→4, 2→5, 4→7, 5→7, 3→6, 3→8, 6→8, 7→9, 8→9 (no official key was published)

Assume the usual precedence convention: every semaphore initially equals zero, P waits for and consumes one signal, and V supplies one signal. Initialization is essential: positive initial tokens would allow some statements to run before their supposed predecessors. With initially-zero semaphores, map each signal after a statement to the wait before another statement.

The labeled dependency edges are S1−a→S2, S1−b→S3; S2−c→S4, S2−d→S5; S4−e→S7, S5−f→S7; S3−g→S6, S3−h→S8; S6−i→S8; S8−j→S9 and S7−k→S9. This edge list is a complete exact specification of the requested graph. To draw it, put S1 at the top, S2 and S3 below it, S4/S5 below S2, S6 below S3, S7 below S4/S5, S8 below S6, and S9 below S7/S8; include the additional direct S3→S8 edge. That direct edge is transitively redundant because S3→S6→S8 already holds, but faithfully represents semaphore h.

S7 is a join: it cannot execute until both S4 and S5 have completed. Similarly S8 waits for both signals from S3 and S6, and S9 joins the two sides. Statements on different sides need not execute in a fixed order.

Its V(c) after S4 supplies no e token, so S7 is permanently blocked at P(e). Its final branch also waits twice on j, although S8 signals j only once, so S9 blocks at its second P(j), even independently of the missing k signal. Under fair execution, S1,S2,S3,S4,S5,S6,S8 may finish; S7 and S9 do not.

Original paper, page 8

5 marks · Descriptive
Report issue

Comparing FCFS and SSTF head travel

I/O & Disk Scheduling

Question 20, GATE 1995: A disk has tracks 0–99. Its head is at track 55, and the pending FIFO queue is 10,70,75,23,65. Calculate total head movement for FCFS and SSTF and say which is smaller.
Tap to enlarge
Answer & solution

Answer: FCFS:204 tracks. SSTF:85 tracks. SSTF saves 119 tracks. (no official key was published)

Step through it (2 schedules)

Head movement is the sum of absolute differences between consecutive serviced track numbers, including the initial position. FCFS must preserve arrival order: 55→10→70→75→23→65. Its successive movements are 45,60,5,52,42, totaling 204 tracks.

SSTF repeatedly chooses the nearest pending request from the current position, not the request nearest the original position. From55 the distances to 10,70,75,23,65 are 45,15,20,32,10, so choose 65. From65 choose 70 (distance 5), then 75 (distance 5). Of the remaining tracks 23 and 10, track 23 is 52 away and 10 is 65 away, so service 23 then 10. Thus the route is 55→65→70→75→23→10, and the total is 10+5+5+52+13=85. There are no distance ties in this instance.

SSTF therefore requires 119 fewer track movements, assuming seek effort is being compared by track distance. Neither algorithm requires a sweep to track 0 or 99; that would be a different scheduling policy. No return to the starting track is requested. The conclusion concerns this finite queue, not a claim that SSTF prevents starvation or always optimizes every possible workload.

Original paper, page 8

Descriptive
Report issue

Intersection of two subgroups

Algebraic Structures

Question 21(a), GATE 1995: Let G1 and G2 be subgroups of a group G. Prove that G1∩G2 is a subgroup of G.
Question 21(a), GATE 1995: Let G1 and G2 be subgroups of a group G. Prove that G1∩G2 is a subgroup of G.
Tap to enlarge
Answer & solution

Answer: G1∩G2 is nonempty and closed under xy⁻¹, hence a subgroup. (no official key was published)

Write H=G1∩G2. Both subgroups contain the identity e of G, so e belongs to H and H is nonempty. This step matters because an empty set cannot be a subgroup.

Take arbitrary x,y in H. By definition of intersection, both x and y belong to G1 and also to G2. Since each Gi is a subgroup, y⁻¹ lies in each Gi, and closure gives xy⁻¹ in each Gi. Consequently xy⁻¹ belongs to their intersection H. The nonempty-subset subgroup test now proves that H is a subgroup of G.

Alternatively, check the axioms separately: the common identity lies in H; for x,y in H, xy is in both groups and hence H; and for x in H, x⁻¹ is in both groups and hence H. Associativity is inherited from G because H uses the same operation. No commutativity, finiteness, or containment of one subgroup inside the other is needed. The essential distinction from a union is that every chosen element of the intersection is available in both subgroups, so a single subgroup's closure can always be applied.

Original paper, page 8

Descriptive
Report issue

Why a union of subgroups can fail

Algebraic Structures

Question 21(b), GATE 1995: Let G1,G2 be subgroups of G. Is G1∪G2 necessarily a subgroup? Justify the answer.
Question 21(b), GATE 1995: Let G1,G2 be subgroups of G. Is G1∪G2 necessarily a subgroup? Justify the answer.
Tap to enlarge
Answer & solution

Answer: No. In (Z,+), 2Z∪3Z contains 2 and 3 but not 5. The union is a subgroup exactly when one subgroup contains the other. (no official key was published)

Take the additive group of integers. Let G1=2Z, the even integers, and G2=3Z, the multiples of 3. Each is a subgroup: it contains 0 and is closed under subtraction. Their union contains 2 and 3. But 2+3=5 is neither even nor a multiple of 3, so it is outside the union. Closure fails, proving that the answer is no.

There is a useful exact characterization. If G1⊆G2, the union is simply G2 and is a subgroup; the reverse containment works too. Conversely suppose neither contains the other, and choose a∈G1 minus G2 and b∈G2 minus G1. If the union were closed, ab would lie in G1 or G2. If ab∈G1, then a⁻¹(ab)=b∈G1, a contradiction. If ab∈G2, then (ab)b⁻¹=a∈G2, again a contradiction. Therefore the union cannot be a subgroup.

This argument uses the inherited group operation and does not assume an abelian group. The reason the intersection proof does not extend to a union is that two union elements can come from different subgroups, whose individual closure properties say nothing about their mixed product.

Original paper, page 8

5 marks · Descriptive
Report issue

Enumerating all minimum spanning trees

Graph Algorithms

Question 22, GATE 1995: The weighted undirected graph has vertices A,B,C,D,E and edges AB=2, AE=3, BC=3, BD=4, CD=4, DE=5. Draw and count all minimum spanning trees. These are the edges visibly present in GFG p8. GateForum p15 omits the AB line while retaining a detached weight 2; also analyze that literal graph.
Tap to enlarge
Answer & solution

Answer: 2 minimum spanning trees, each of weight 12: {AB, AE, BC, BD} and {AB, AE, BC, CD} (no official key was published)

A spanning tree on five vertices has four edges. Graph, AB is the unique cheapest edge crossing the cut {A}, so it belongs to every MST. AE is the unique cheapest edge crossing {E}, and BC is the unique cheapest edge crossing {C}; these too are forced by the cut property. The three edges AB,AE,BC form a tree on A,B,C,E, with D still isolated. Connect D using either BD or CD, each of weight 4. Using DE of weight 5 instead would cost more. Thus the optimum total is 2+3+3+4=12 and there are exactly two choices.

Draw tree1 as E−(3)−A−(2)−B−(3)−C, with an additional B−(4)−D branch. Draw tree2 as the path E−(3)−A−(2)−B−(3)−C−(4)−D. The edge sets in the answer uniquely specify every diagram and show that both graphs are connected and acyclic. Forced edges plus the only two minimum connectors prove completeness, rather than merely exhibiting two examples.

If interpreted literally, A has only neighbor E, and {A,E} connects to the rest only through ED. Consequently AE=3 and ED=5 are forced. In the remaining BCD triangle, choose BC=3 and either BD=4 or CD=4. This gives exactly two spanning trees of minimum weight 15. The count happens to remain 2, but the trees and weights differ.

Original paper, page 8

5 marks · Descriptive
Report issue

Induction for exponential versus quadratic growth

Proof Techniques & Number Theory

Question 23, GATE 1995: Prove by mathematical induction that 2^n>n² for every integer n≥5.
Tap to enlarge
Answer & solution

Answer: Base32>25; induction follows from 2n²>(n+1)² for n≥5. (no official key was published)

Start at n=5: 25=32>25=5², so the claimed strict inequality holds. Now suppose it holds for some integer k≥5, namely 2k>k². Multiplying this strict inequality by 2 gives 2k+1>2k². To reach the desired conclusion, it remains to compare 2k² with (k+1)².

The difference is 2k²−(k+1)²=k²−2k−1=(k−1)²−2. Since k≥5, this is at least 16−2=14>0. Therefore 2k²>(k+1)², and chaining the two inequalities gives 2k+1>(k+1)². This proves the induction step. By mathematical induction the assertion holds for all integers n≥5.

The comparison in the middle is necessary: merely doubling both sides of the induction hypothesis does not automatically produce the next quadratic term. The starting value is also meaningful: at n=4 both sides equal 16, so the strict claim cannot start there. This proof covers the stated integer domain only; induction alone is not a proof for arbitrary real n.

Original paper, page 8

5 marks · Descriptive
Report issue

Even number of odd-degree vertices

Graph Theory

Question 24, GATE 1995: Prove that a finite undirected graph has an even number of vertices of odd degree.
Tap to enlarge
Answer & solution

Answer: The degree sum equals 2|E|, so the number of its odd summands is even. (no official key was published)

Each undirected edge contributes one incident end at each endpoint. Counting all incident ends first by edges and then by vertices yields the handshaking identity ∑v deg(v)=2|E|, an even integer. If loops are allowed, a loop contributes 2 to the degree of its vertex, so the same identity remains true under that standard convention.

Partition the vertices into those with even degree and those with odd degree. The sum over the even-degree vertices is even. Subtracting it from the even total shows that the sum over the odd-degree vertices is also even. A sum of m odd integers has parity m: write each degree as 2ki+1, so their sum is 2∑ki+m. It can be even only if m is even. Hence the number of odd-degree vertices is even.

The graph need not be connected, and isolated vertices have degree 0 and do not affect the argument. Finiteness ensures that these are ordinary finite sums. The assertion is about undirected degree; for a directed graph, odd outdegrees alone need not occur an even number of times. One must specify the appropriate total-degree convention rather than reuse this proof unaltered.

Original paper, page 8

Descriptive
Report issue

Minimum of a quadratic

Calculus

Question 25(a), GATE 1995: Find the minimum value of 3−4x+2x², taking x to range over the real numbers.
Tap to enlarge
Answer & solution

Answer: Minimum1, attained at x=1. (no official key was published)

Complete the square rather than guessing a stationary point: 3−4x+2x²=2(x²−2x)+3=2[(x−1)²−1]+3=2(x−1)²+1. For every real x, the square is nonnegative, so the expression is at least 1. At x=1 the square is zero, so the lower bound is attained. Thus1 is the global minimum, and x=1 is the unique minimizer.

As a check, differentiating gives f′(x)=4x−4, whose sole zero is x=1. The second derivative is 4>0 everywhere, confirming strict convexity and the minimum. The completed-square proof is stronger than simply solving f′=0: it directly establishes a lower bound over the full domain and proves attainment.

The source does not explicitly specify a domain for x; the conventional real-variable interpretation is used. If x were restricted to integers the same answer still holds because 1 is an allowed integer. A different restricted domain excluding 1 would need a separate analysis. The requested minimum value is 1, whereas x=1 is where that value occurs.

Original paper, page 8

Descriptive
Report issue

Counting integers coprime to30

Proof Techniques & Number Theory

Question 25(b), GATE 1995: How many positive integers at most 720 are divisible by none of 2,3,5?
Tap to enlarge
Answer & solution

Answer: 192. (no official key was published)

Let A,B,C be the subsets of {1,…,720} divisible by 2,3,5 respectively. Their sizes are 360,240,144. Because the divisors are pairwise coprime, the pair intersections count multiples of 6,10,15, giving 120,72,48; the triple intersection counts multiples of 30, giving 24.

Inclusion–exclusion gives |A∪B∪C|=360+240+144−120−72−48+24=528. These are exactly the integers disqualified by at least one divisibility condition. Subtract from all 720 positive integers to obtain 720−528=192. The subtraction of pair intersections corrects double counting, while adding the triple intersection restores numbers removed too many times.

An independent way to see the count is to use blocks of 30. In each block the allowed residue classes are 1,7,11,13,17,19,23,29 modulo 30, eight in total. There are 720/30=24 complete blocks, hence 24×8=192. The residue 0 is not allowed, and the positive-integer domain excludes 0 anyway.

Original paper, page 8

3 marks · Descriptive
Report issue

Third normal form without BCNF

Normalization & Decomposition

Question 26(a), GATE 1995: For R(A,B,C) with functional dependencies AB→C and C→A, show that R is in 3NF but not BCNF.
Question 26(a), GATE 1995: For R(A,B,C) with functional dependencies AB→C and C→A, show that R is in 3NF but not BCNF.
Tap to enlarge
Answer & solution

Answer: Candidate keys AB and BC make all attributes prime. C→A satisfies 3NF but violates BCNF since C is not a superkey. (no official key was published)

Step through it (7 steps)

Compute enough closures to identify the keys. (AB)+ contains A,B and gains C by AB→C, so AB is a superkey; neither A nor B alone determines all attributes, so it is minimal. (BC)+ gains A by C→A and is likewise a candidate key. Every candidate key must contain B because no dependency can introduce B. A key containing B must also include A or C, giving precisely AB and BC. Thus A,B,C are all prime attributes, meaning each occurs in at least one candidate key.

For 3NF, every nontrivial dependency X→Y with a single right-side attribute must have X a superkey or Y prime. The given AB→C has a superkey determinant. In C→A, C is not a superkey, but A is prime because it belongs to key AB. This is allowed in 3NF. In fact every attribute of R is prime, so any implied single-attribute dependency also meets that alternative of the definition. Hence R is in 3NF.

BCNF removes the prime-attribute exception: every nontrivial dependency must have a superkey on the left. Here C+={C,A}; it cannot acquire B, so C is not a superkey. The nontrivial dependency C→A therefore violates BCNF. Being in 3NF does not imply that every determinant is a key. This conclusion assumes the displayed dependencies generate the schema's constraints and that the relation is in first normal form, as is conventional for this normalization problem.

Original paper, page 8

Descriptive
Report issue

Finding all minimal keys

Functional Dependencies & Keys

Question 26(b), GATE 1995: For R(A,B,C), with AB→C and C→A, determine every minimal key.
Question 26(b), GATE 1995: For R(A,B,C), with AB→C and C→A, determine every minimal key.
Tap to enlarge
Answer & solution

Answer: AB and BC are exactly the candidate keys. (no official key was published)

Step through it (4 steps)

A candidate key must determine all three attributes, and none of its proper subsets may do so. Since B does not occur on the right side of either given functional dependency, starting from attributes that omit B can never derive B. Thus every key must contain B. The closure B+ is just {B}, so B by itself is not enough.

Add A: (AB)+ initially contains A,B and then AB→C adds C, so AB is a superkey. Removing A leaves B+, which lacks A,C; removing B leaves A+={A}. Therefore AB is minimal. Add C instead: (BC)+ contains B,C, then C→A adds A, so BC is a superkey. Removing B leaves C+={C,A}, and removing C leaves B+={B}; neither is all of R. Thus BC is minimal.

These are exhaustive. Any key must contain B and at least one of the other two attributes. Such a set therefore contains AB or BC. The only larger possibility ABC is a superkey but not a minimal key, because either of those proper subsets already determines R. Hence the complete candidate-key set is {AB,BC}, not just the first key suggested by the dependency AB→C. No extra dependencies are assumed.

Original paper, page 8

Descriptive
Report issue

Projecting publisher names

Relational Algebra & Calculus

Question 27(a), GATE 1995: AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain the names of all publishers.
Question 27(a), GATE 1995: AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain the names of all publishers.
Tap to enlarge
Answer & solution

Answer: π_PNAME(PUBLISHER). (no official key was published)

The requested output is a single attribute, PNAME, from every tuple of PUBLISHER. Projection selects columns, so the expression is π_PNAME(PUBLISHER). No selection predicate is needed because no publisher is to be filtered out, and no join is needed because the required data already reside in one relation.

Under classical relational algebra, relations are sets, so projection returns each distinct publisher name once. If two stored tuples happen to share a name, the output still contains that value once. The result schema consists only of PNAME, not PCITY.

It would be incorrect to obtain these names by projecting BOOK: that would return only publishers represented by at least one recorded book, whereas the query asks for all publishers. Similarly, joining PUBLISHER with BOOK first could incorrectly lose a publisher with no matching book. DIVIDE is also unnecessary: there is no requirement involving all members of another relation. This simple query tests matching the requested output columns and population directly to the base relation.

Original paper, page 8

Descriptive
Report issue

Selecting authors of a named publisher

Relational Algebra & Calculus

Question 27(b), GATE 1995: AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain all AUTHOR attributes of authors who have published a book with PNAME='TECHNICAL PUBLISHERS'.
Question 27(b), GATE 1995: AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain all AUTHOR attributes of authors who have published a book with PNAME='TECHNICAL PUBLISHERS'.
Tap to enlarge
Answer & solution

Answer: π_ANAME,INSTITUTION,ACITY,AGE(AUTHOR ⋈ σ_PNAME='TECHNICAL PUBLISHERS'(BOOK)). (no official key was published)

First identify the relevant books using selection: T=σ_PNAME='TECHNICAL PUBLISHERS'(BOOK). This keeps tuples whose publisher name matches the specified literal, while retaining TITLE and ANAME so that authors can be linked. Next compute AUTHOR⋈T. The only shared attribute name is ANAME, so this natural join matches each qualifying book to its author record. Finally project ANAME,INSTITUTION,ACITY,AGE to return exactly the attributes requested from AUTHOR.

Thus the complete expression is π_ANAME,INSTITUTION,ACITY,AGE(AUTHOR⋈σ_PNAME='TECHNICAL PUBLISHERS'(BOOK)). Equivalently, first project ANAME from the selected books, then join that name relation to AUTHOR; the result already has exactly the AUTHOR schema.

An author with several matching books still appears only once in classical set relational algebra after projection. An author with no such book is excluded because there is no matching join tuple. Joining PUBLISHER is not needed: the condition is already expressible using BOOK.PNAME. The expression uses the association specified by the schema, namely ANAME as the author link; it does not infer that names uniquely identify people outside this database model. DIVIDE would express a universal requirement and would be inappropriate for the existential condition 'has published a book'.

Original paper, page 8

Descriptive
Report issue

Authors with a publisher in Madras

Relational Algebra & Calculus

Question 27(c), GATE 1995: AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain the names of all authors who have published a book for any publisher located in Madras.
Question 27(c), GATE 1995: AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain the names of all authors who have published a book for any publisher located in Madras.
Tap to enlarge
Answer & solution

Answer: π_ANAME(AUTHOR ⋈ BOOK ⋈ σ_PCITY='Madras'(PUBLISHER)). (no official key was published)

Select publishers by their city: M=σ_PCITY='Madras'(PUBLISHER). Join BOOK to M on the common attribute PNAME. This keeps exactly books whose publisher is among the Madras publishers. Join the result to AUTHOR on ANAME, and finally project ANAME. A full expression is π_ANAME(AUTHOR⋈BOOK⋈σ_PCITY='Madras'(PUBLISHER)). Natural joins are unambiguous here: BOOK and PUBLISHER share PNAME, while AUTHOR and BOOK share ANAME. ACITY and PCITY are different attributes.

The test is on the publisher's city PCITY, not the author's city ACITY. An author outside Madras qualifies if at least one book has a Madras publisher. Conversely an author living in Madras does not qualify solely because of that residence. The word 'any' here is existential: one matching publisher is enough, so use selection and join rather than division.

Under an assumed foreign-key constraint BOOK.ANAME references AUTHOR.ANAME, the AUTHOR join can be omitted and π_ANAME(BOOK⋈M) is equivalent. Since that referential constraint is not explicitly stated, retaining AUTHOR is the safer literal expression for names of stored authors. Projection removes repetitions caused by multiple qualifying books or publishers under set semantics. Exact comparison uses the displayed city value 'Madras', not a silently substituted modern place-name string.

Original paper, page 8