GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 2000

96 questions

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

03:00:00
1 mark · MCQ
Report issue

Guaranteeing three cards of one suit

Combinatorics & Counting

Question 1.1, GATE 2000: How many cards must be dealt from any shuffled standard 52-card deck to guarantee three of one suit? Options: 3,8,9,12.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: To avoid three of a suit, take at most two from each of the four suits. This allows 4·2=8 cards, so eight do not guarantee the required triple.

Step 2: A ninth card must belong to one of those four suits and raises its count to at least three. This is the pigeonhole principle.

Conclusion: Nine is sufficient and the eight-card construction proves minimality, so C.

Original paper, page 1

1 mark · MCQ
Report issue

Sum of a difference array

Combinatorics & Counting

Question 1.2, GATE 2000: For 1≤i,j≤n, define v[i,j]=i−j. Find the sum of all n² entries. Options include 0,n−1,n²−3n+2,n²(n+1)/2.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Pair entry(i,j) with entry(j,i). Their values i−j and j−i add to zero; diagonal entries are themselves zero.

Step 2: Equivalently, the double sum is n·sum_i i−n·sum_j j, whose terms cancel exactly.

Thus the total is zero for every positive n, option A. Counting only the positive triangular half would omit the equal negative half.

Original paper, page 1

1 mark · MCQ
Report issue

Determinant using sparse expansion

Linear Algebra

Question 1.3, GATE 2000: Find the determinant of the matrix with rows (2,0,0,0),(8,1,7,2),(2,0,2,0),(9,0,6,1). Options: 4,0,15,20.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Expand along the first row. Only its first entry contributes, so det=2·det[[1,7,2],[0,2,0],[0,6,1]].

Step 2: Expand this minor along its first column to obtain det[[2,0],[6,1]]=2·1−0·6=2.

Therefore the full determinant is 2·2=4, A. Entries below the first-column pivot do not contribute to the selected minor.

Original paper, page 1

1 mark · MCQ
Report issue

Equivalent starred regular expressions

Regular Expressions & Languages

Question 1.4, GATE 2000: Let S=(a+b*)* and T=(a+b)* over {a,b}. Are S and T in a proper-subset relation, equal, or disjoint?
Question 1.4, GATE 2000: Let S=(a+b*)* and T=(a+b)* over {a,b}. Are S and T in a proper-subset relation, equal, or disjoint?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Every block allowed inside S is either a or a finite run of b symbols. Concatenating such blocks can produce every word over {a,b}, since individual a and b symbols are both available.

Step 2: No other symbol can appear, so S⊆{a,b}*. The expression T also generates exactly {a,b}*, including ε.

Hence S=T, option C. The inner star on b does not restrict the outer star’s ability to concatenate individual symbols.

Original paper, page 1

1 mark · MCQ
Report issue

Language generated by symmetric zero insertion

Context-Free Grammars & Languages

Question 1.5, GATE 2000: For grammar S→0S0|00, decide whether L is 0+, regular but not 0+, context-free but not regular, or not context-free.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: The base production yields two zeros. Each use of 0S0 adds exactly two more, so every generated word has positive even length. Conversely, applying the recursive rule k times generates 02k+2.

Step 2: Therefore L={02m:m≥1}=00(00)*, a regular language. It excludes the one-symbol string 0, which belongs to 0+.

Thus B. A recursive-looking grammar does not imply a nonregular language.

Original paper, page 1

1 mark · MCQ
Report issue

Positive integer in twos-complement representation

Number Systems & Computer Arithmetic

Question 1.6, GATE 2000: Represent positive decimal 43 in the eight-bit two’s-complement options: 01010101,11010101,00101011,10101011.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step through it (3 steps)

Step 1: Decompose 43=32+8+2+1, giving binary 101011.

Step 2: Since the number is positive, two’s complement uses its ordinary binary representation with leading zero sign extension: 00101011.

Thus C.

Original paper, page 1

1 mark · MCQ
Report issue

Entering an 8085 wait state

Input/Output, DMA & Interrupts

Question 1.7, GATE 2000: Choose the signal action that inserts an 8085 wait state: lower HOLD, lower READY, raise HOLD, or raise READY.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: READY tells the processor whether the current memory or I/O transfer can finish. When READY is low at its sampling point, the processor inserts wait states.

Step 2: Raising READY permits the transfer to proceed. HOLD is for requesting bus control, not the ordinary slow-transfer extension.

Therefore lower READY, B.

Original paper, page 1

1 mark · MCQ
Report issue

Single-instruction pipeline latency

Pipelining & Hazards

Question 1.8, GATE 2000: Compare latency T1 for one instruction on a pipelined CPU with T2 on an otherwise identical nonpipelined CPU. Options: T1≤T2,T1≥T2,T1<T2,or T1=T2 plus one fetch cycle.
Tap to enlarge
Your answer
Answer & solution

Answer: B under the standard same-work comparison (no official key was published)

Step 1: Pipelining overlaps different instructions; one instruction still passes through all of its stages. If stage delays are d1,…,dk, the unpipelined combinational work is their sum.

Step 2: A clocked pipeline needs roughly k·max(di), plus register overhead, which is at least sum(di). Perfectly balanced ideal stages can match the unpipelined latency; real pipeline registers usually increase it.

Thus T1≥T2, B, in this standard comparison. Throughput improvement across many instructions must not be confused with reducing one instruction’s latency; no universal extra-fetch-cycle formula follows.

Original paper, page 1

1 mark · MCQ
Report issue

When an 8085 services an interrupt

Input/Output, DMA & Interrupts

Question 1.9, GATE 2000: When does the 8085 respond to an eligible TRAP request: immediately upon a high level, at the end of fetch, at instruction completion, or at unspecified regular intervals?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: The processor normally completes the current instruction before transferring to an interrupt service routine, preserving a well-defined instruction boundary.

Step 2: Thus the textbook choice is C, at the end of execution rather than merely at opcode fetch or immediately on signal assertion.

Qualification: TRAP has edge-and-level triggering requirements; an arbitrary static high level alone is not a complete description of a valid new request. The answer concerns service timing after an eligible request.

Original paper, page 1

1 mark · MCQ
Report issue

Addressing-mode applications

Instructions & Addressing Modes

Question 1.10, GATE 2000: Match X indirect,Y immediate,Z autodecrement addressing to 1 loops,2 pointers,3 constants. Options are permutations; C gives X2,Y3,Z1.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Indirect addressing follows a stored address, so it naturally implements pointer access: X→2. Immediate addressing embeds an operand value, so it is suited to constants: Y→3.

Step 2: Autodecrement combines a register decrement with addressing, useful when iterating backward through a sequence or maintaining a loop-related address: Z→1 among the supplied uses.

Therefore C. These are representative uses, not claims that each mode has only one application.

Original paper, page 2

1 mark · MCQ
Report issue

Reading an array-of-pointers declaration

Structures & Declarations

Question 1.11, GATE 2000: Given struct node with int i and float j, followed by struct node *s[10], what is s: array of structure pointers, two-field structure of arrays, three-field structure, or array of structures?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Read outward from s. The immediately attached [10] makes s an array of ten elements.

Step 2: The preceding * says each element is a pointer, and the base type struct node says what it points to. Thus s is an array of ten pointers to nodes, A.

The node’s two fields describe each pointed-to object, not extra fields inside s. Writing struct node s[10] without * would instead produce the array of structures in D.

Original paper, page 2

1 mark · MCQ
Report issue

Matching pointer errors to code

Pointers & Memory

Question 1.12, GATE 2000: Classify X: m=malloc(5);m=NULL; Y: free(n);n->value=5; Z: char *p;*p='a'. Categories: 1 dangling-pointer use,2 uninitialized-pointer use,3 lost memory.
Tap to enlarge
Your answer
Answer & solution

Answer: D: X3,Y1,Z2 (no official key was published)

Step 1: In X, assigning NULL over the sole saved address of a successful allocation loses the ability to free/access that block, creating lost memory or a leak:3.

Step 2: In Y, free ends the allocated object’s lifetime; the later dereference uses a dangling pointer:1. In Z, an uninitialized pointer has not been made to point at valid writable storage, so dereferencing it is an uninitialized-pointer error:2.

The mapping X3,Y1,Z2 is D. Successful allocation, no second saved reference, and initially valid n are the conventional premises for the first two examples.

Original paper, page 2

1 mark · MCQ
Report issue

Algorithm and data-structure matching

Stacks & Queues

Question 1.13, GATE 2000: Match X depth-first search,Y breadth-first search,Z sorting to 1 heap,2 queue,3 stack.
Question 1.13, GATE 2000: Match X depth-first search,Y breadth-first search,Z sorting to 1 heap,2 queue,3 stack.
Tap to enlarge
Your answer
Answer & solution

Answer: C: X3,Y2,Z1 (no official key was published)

Step 1: DFS must return to the latest unfinished branch, a last-in-first-out behavior implemented by an explicit stack or recursive call stack. Thus X→3.

Step 2: BFS processes older discovered vertices first, using a FIFO queue, so Y→2. A heap supports repeated minimum/maximum extraction for sorting, so Z→1.

Together these matches give C. The sorting match refers to heap sort, not to every possible sorting algorithm.

Original paper, page 2

1 mark · MCQ
Report issue

Well-formed nested binary-tree notation

Tree Properties & Traversals

Question 1.14, GATE 2000: A nonleaf is written (root left right), with leaves represented by labels and empty subtrees by NULL. Choose a valid expression: A (1 2 (4 5 6 7)); B (1 ((2 3 4) 5 6) 7); C (1 (2 3 4) (5 6 7)); D (1 (2 3 NULL) (4 5)).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Every parenthesized node must begin with a node label and have exactly two child descriptions. C has root 1, left subtree rooted 2 with leaves 3,4, and right subtree rooted 5 with leaves 6,7.

Step 2: A gives node 4 three children. B uses a whole subtree where a root label should be. D gives node 4 only one child without an explicit second subtree.

Only C consistently follows the notation.

Original paper, page 2

1 mark · MCQ
Report issue

Finding a small pair sum in a sorted array

Searching, Sorting & Selection

Question 1.15, GATE 2000: A sorted array s contains n integers. Determine whether two distinct elements sum to less than 1000. What is the most efficient asymptotic runtime, including choice O(1)?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: In ascending order, the smallest sum of two distinct positions is s[1]+s[2]. Every other pair replaces one or both elements by values at least as large.

Step 2: If that sum is below 1000, a qualifying pair exists; otherwise no pair can qualify. Only two accesses, an addition, and a comparison are needed.

Thus Θ(1), option A, for n≥2 with random-access storage. For n<2 return false immediately. Searching all pairs or applying a two-pointer scan is unnecessary for this inequality-existence question.

Original paper, page 2

1 mark · MCQ
Report issue

Meaning of aliasing

Runtime Environments & Parameter Passing

Question 1.16, GATE 2000: Does aliasing mean multiple names for one memory location, equal values, repeated identifiers, or repeated use of a variable?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Aliasing occurs when two accessible expressions designate the same storage object. For example, if p=&x, then x and *p refer to the same int.

Step 2: Assigning through either expression changes what the other observes. Two separate variables can hold equal values without aliasing, and the same identifier can name different objects in different scopes.

Thus A, not merely equal contents or repeated spelling.

Original paper, page 2

1 mark · MCQ
Report issue

Structure containing an array and a union

Structures & Declarations

Question 1.17, GATE 2000: A structure contains short s[5] and a union holding either float y or long z. short,float,long occupy 2,4,8 bytes. Ignoring alignment, choose size 22,14,18,10 bytes.
Question 1.17, GATE 2000: A structure contains short s[5] and a union holding either float y or long z. short,float,long occupy 2,4,8 bytes. Ignoring alignment, choose size 22,14,18,10 bytes.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: The array has five separate short objects, requiring 5·2=10 bytes.

Step 2: Union members share storage, so the union needs the maximum of 4 and 8 bytes, namely 8, rather than their sum. The enclosing structure stores its array and union separately.

Total size ignoring padding is 10+8=18 bytes, C. Adding both union members would incorrectly give 22; actual ABI alignment could add padding, explicitly excluded here.

Original paper, page 2

1 mark · MCQ
Report issue

Lexical tokens in a printf statement

Lexical Analysis

Question 1.18, GATE 2000: Count tokens in the statement printf("i=%d, &i=%x", i, &i);. Choices:3,26,10,21.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: The entire quoted format string is one string-literal token, regardless of its spaces, percent signs, commas or ampersand.

Step 2: The tokens are printf, (, the string literal, comma, i, comma, &, i, ), semicolon: ten in total.

Hence C. The count concerns lexical analysis, not characters or semantic correctness of the format specifier for a pointer; such a formatting issue does not split the string into more tokens.

Original paper, page 3

1 mark · MCQ
Report issue

Derivation used by a top-down parser

Parsing & Syntax Analysis

Question 1.19, GATE 2000: For input scanned left to right, does top-down parsing construct a leftmost derivation, its reverse, a rightmost derivation, or a reversed rightmost derivation?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: A top-down parser starts from the start symbol and expands grammar symbols to match the input prefix. It expands the leftmost unprocessed nonterminal to produce the next input symbols.

Step 2: These expansions run in the forward direction from start symbol to terminal string, giving a leftmost derivation, A.

A reversed rightmost derivation characterizes standard bottom-up shift-reduce parsing instead.

Original paper, page 3

1 mark · MCQ
Report issue

State that need not be saved on a context switch

Processes, Threads & System Calls

Question 1.20, GATE 2000: Which need not necessarily be saved: general-purpose registers, the TLB, the program counter, or all of these?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: The process’s program counter and live architectural registers determine where and how it resumes; their values must be preserved by the switching mechanism.

Step 2: A TLB is a cache of translations also represented in page tables. It may be invalidated and refilled, or entries may remain with address-space identifiers, without saving its entire contents in the process context.

Therefore B. Losing cached translations can hurt performance but does not inherently lose the process’s architectural execution state.

Original paper, page 3

1 mark · MCQ
Report issue

Circular acquisition of binary semaphores

Deadlocks

Question 1.21, GATE 2000: Processes P[0]…P[4] use mutexes m[0]…m[4]. Each waits on m[i], then m[(i+1) mod4], before releasing them. Can this cause thrashing, deadlock, starvation without deadlock, or none?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Schedule P0,P1,P2,P3 so each acquires its first mutex before any attempts the second. They now hold m0,m1,m2,m3 respectively.

Step 2: P0 waits for m1, P1 for m2, P2 for m3, and P3 for m0. Each resource is held by the next blocked process, creating a circular wait.

Thus deadlock is possible, B. The printed modulus is 4 even though five processes/mutexes are named; the four-process cycle already proves the result without silently changing it to 5. P4 does not remove this cycle.

Original paper, page 3

1 mark · MCQ
Report issue

Why database indexes use B-plus trees

Indexing, Storage & Query Processing

Question 1.22, GATE 2000: Why prefer B+-trees to binary trees for disk-resident databases: larger disk capacity, much slower disk access than memory, lower transfer rate alone, or greater disk reliability?
Question 1.22, GATE 2000: Why prefer B+-trees to binary trees for disk-resident databases: larger disk capacity, much slower disk access than memory, lower transfer rate alone, or greater disk reliability?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: A B+-tree node can fill a disk page and contain many keys and child pointers. Its high fanout sharply reduces the number of levels compared with a binary tree holding a similar number of keys.

Step 2: A search typically needs one page access per level, so reducing height reduces expensive random disk accesses. The latency difference between disk and memory is the decisive reason, B.

Capacity and reliability do not by themselves explain this branching-factor advantage; transfer rate is distinct from the random-access cost being minimized.

Original paper, page 3

1 mark · MCQ
Report issue

Aggregation outside basic relational algebra

Relational Algebra & Calculus

Question 1.23, GATE 2000: Given employee(name,salary,deptno) and department(deptno,deptname,address), which cannot be expressed with basic selection,projection,product,join,union,intersection,difference: department addresses, matching employee/department names, total salaries, or employees of a department?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Joining on deptno and projecting yields each employee’s department address. Selection can compare name with deptname or filter a particular department.

Step 2: Summing salaries across arbitrarily many tuples requires aggregation and produces a new arithmetic value. The listed basic relational-algebra operators select/combine existing tuple values but contain no aggregate-sum operation.

Therefore total salaries, C, needs an extended algebra or SQL aggregation.

Original paper, page 3

2 marks · MCQ
Report issue

Overlap of three unit intervals

Other / Mixed Topics

Question 2.1, GATE 2000: X, Y and Z are closed unit intervals. X and Z each overlap Y by length 1/2. If X∩Z has length k, must k=1, k=0, can it be every value in[0,1], or none of these?
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Translate Y to[0,1]. A unit interval overlapping it by exactly 1/2 must start at−1/2 or+1/2. Thus each of X and Z is one of those two intervals.

Step 2: If they choose the same interval, their overlap length is 1. If they choose opposite intervals, they touch at one point and their overlap length is 0. No intermediate length occurs.

Therefore k∈{0,1}, and none of A–C describes the full possibilities: D. The problem does not explicitly require X and Z to be distinct; imposing that would leave only k=0.

Original paper, page 3

2 marks · MCQ
Report issue

Independent equal-probability events covering the space

Probability & Random Variables

Question 2.2, GATE 2000: Events E1,E2 are independent, have equal probability, and P(E1∪E2)=1. Find P(E1) among 0,1/4,1/2,1.
Question 2.2, GATE 2000: Events E1,E2 are independent, have equal probability, and P(E1∪E2)=1. Find P(E1) among 0,1/4,1/2,1.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Write p=P(E1)=P(E2). Independence gives P(E1∩E2)=p².

Step 2: Inclusion-exclusion yields 1=2p−p², or(p−1)²=0. Therefore p=1.

Option D follows. Choosing 1/2 would give union probability 3/4, because independent events with probability 1/2 overlap with probability 1/4; they are not disjoint.

Original paper, page 3

2 marks · MCQ
Report issue

Comparing a sum with an integral

Calculus

Question 2.3, GATE 2000: Compare S=sum from i=3 to 100 of i log2 i and T=integral from 2 to 100 of x log2 x dx. Choices S>T,S=T,S<T with 2S>T,or 2S≤T.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: The function f(x)=x log2 x is strictly increasing on[2,100], since f′(x)=log2 x+1/ln2>0.

Step 2: On each interval[i−1,i], the integral of f is strictly less than the width-one rectangle of height f(i). Summing for i=3,…,100 gives T<S.

Thus A. The sum uses right endpoints, so no antiderivative calculation or numerical approximation is needed to establish the strict inequality.

Original paper, page 4

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Minimum degree interpolating alternating values

Numerical Methods

Question 2.4, GATE 2000: Find the least polynomial degree with p(1)=p(3)=p(5)=1 and p(2)=p(4)=−1. Choices1,2,3,4.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: The polynomial changes sign between each consecutive pair 1,2,3,4,5. By continuity, it has at least one distinct zero in each of the four open intervals, so its degree is at least 4.

Step 2: Five prescribed values at distinct points admit an interpolating polynomial of degree at most 4. An explicit one is p(x)=1−(8/3)(x−3)²+(2/3)(x−3)4: at x=3 it is 1, at x=2,4 it is−1, and at x=1,5 it is 1.

Therefore the minimum is 4, D.

Original paper, page 4

2 marks · MCQ
Report issue

Equivalence classes of parity

Sets, Relations & Functions

Question 2.5, GATE 2000: On integers, define xRy when x+y is even. Is R not an equivalence relation, or does it have one,two,or three equivalence classes?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: x+y is even exactly when x and y have the same parity. Every integer has its own parity, parity matching is symmetric, and matching parity is transitive.

Step 2: The two classes are all even integers and all odd integers. Neither is empty, and no even integer relates to an odd one.

Hence R is an equivalence relation with exactly two classes, C.

Original paper, page 4

2 marks · MCQ
Report issue

Powerset statements

Sets, Relations & Functions

Question 2.6, GATE 2000: Which is always true? A P(P(S))=P(S); B P(S)∩P(P(S))={∅}; C P(S)∩S=P(S); D S∉P(S). Both reproductions visibly use nonmembership in D.
Tap to enlarge
Your answer
Answer & solution

Answer: No listed option is universally true as printed (no official key was published)

Step 1: D is always false, because every set is a subset of itself and therefore S∈P(S). A is false by Cantor’s theorem, or simply take S=∅, giving P(S)={∅} but P(P(S))={∅,{∅}}.

Step 2: B is not universal: with S={∅}, both ∅ and {∅} belong to P(S) and P(P(S)), so their intersection has two elements. C also fails for S=∅, since its left side is empty and right side is{∅}.

Therefore none is always true. Replacing ∉ by ∈ in D would repair it, but that alteration is not silently made or attributed to an official key.

Original paper, page 4

2 marks · MCQ
Report issue

Implication under given equivalences

Propositional & Predicate Logic

Question 2.7, GATE 2000: Assume a↔(b∨¬b) and b↔c. Evaluate (a∧b)→((a∧c)∨d). Is it always true,false,equal to b,or equal to d?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: b∨¬b is a tautology, so the first premise forces a=true. The second premise makes c and b have the same value.

Step 2: The formula reduces to b→(b∨d). If b is false the implication is true; if b is true its consequent is true.

Thus the formula is always true, A, independently of d. This also follows directly because the antecedent guarantees the first disjunct in the consequent.

Original paper, page 4

2 marks · MCQ
Report issue

What a two-state unary DFA need not imply

Finite Automata

Question 2.8, GATE 2000: A unary regular language has a minimal two-state automaton. Must it be the odd-length language,the even-length language,a*,or one of the two parity languages?
Tap to enlarge
Your answer
Answer & solution

Answer: No listed conclusion follows without an additional restriction (no official key was published)

Step 1: Consider L=a+, the nonempty unary strings. A minimal complete DFA has a nonaccepting start state that transitions on a to an accepting state with an a self-loop. The two states are distinguishable by ε.

Step 2: This L contains both odd and positive even lengths but excludes ε, so it is neither parity language nor a*. It satisfies the two-state premise and refutes all four mandatory claims.

If the two reachable states were additionally required to form a cycle, exactly one would accept in a minimal two-state DFA, yielding parity and option D. The source does not state that restriction. Strong connectivity cannot be assumed from minimality.

Original paper, page 4

2 marks · MCQ
Report issue

Decidability of finite-state membership and CFG infiniteness

Decidability & Computability

Question 2.9, GATE 2000: Decide whether P1,finite-state-machine acceptance of a given string,and P2,infiniteness of a CFG language,are decidable. Options: both,neither,only P1,only P2.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: For P1, simulate the finite automaton on the finite input, tracking a set of states if it is nondeterministic, then inspect acceptance. This always terminates.

Step 2: For P2, convert the productive nonempty-word portion of the grammar to Chomsky normal form with m variables. Any parse tree without a repeated variable along a root-to-leaf path has bounded height and hence bounded word length. A sufficiently long word forces a repeat and pumping to infinitely many lengths.

One can effectively test whether the CFG generates a word exceeding that finite bound by intersection with the regular language of longer words and then CFG emptiness. Hence infiniteness is decidable too, giving A.

Original paper, page 4

2 marks · MCQ
Report issue

Solving simultaneous Boolean constraints

Boolean Algebra & Logic Gates

Question 2.10, GATE 2000: Find a listed solution(x,y,z,w) to x+y+z=1,xy=0,xz+w=1,xy+z′w′=0. Choices0100,1101,1011,1000; + means OR.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: xy=0 immediately rejects 1101. For 0100, xz+w=0, so it fails the third equation. The same third equation rejects 1000.

Step 2: For 1011, x+y+z=1,xy=0,xz+w=1, and xy+z′w′=0+0·0=0. It satisfies all four.

Thus C is the listed solution. The equations can have other solutions not listed, so this checks the requested candidate rather than asserting a unique solution over all sixteen assignments.

Original paper, page 4

2 marks · MCQ
Report issue

Comparing three implementations of a Karnaugh map

Logic Minimization & Karnaugh Maps

Question 2.11, GATE 2000: Map columns wz and rows xy are Gray-ordered 00,01,11,10. Rows are [0,X,0,0],[0,X,1,1],[1,1,1,1],[0,X,0,0]. Which does NOT implement it: A(w+x)y; Bxy+yw; C(w+x)(w′+y)(x′+y); D none?
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (15 steps)

Step 1: The specified ones occur when y=1 and at least one of w,x is 1. Thus F=(w+x)y, and distribution gives xy+yw, proving A and B equivalent and consistent with all specified cells.

Step 2: Simplify C: (w′+y)(x′+y)=y+w′x′. Multiplying by(w+x) gives y(w+x)+(w+x)w′x′=y(w+x), because the last product is zero.

Therefore C is equivalent as well, so none of A–C fails: D. The complement bars on both w and x in C are essential and were checked in the clearer alternate figure.

Original paper, page 4

2 marks · MCQ
Report issue

Master-slave flip-flop updates

Flip-Flops, Registers & Sequential Circuits

Question 2.12, GATE 2000: A JK master-slave flip-flop P has J=K=1; its output feeds a D master-slave flip-flop Q with the shared clock. Starting(P,Q)=(0,1), find the state after three cycles from choices(1,0),(1,1),(0,0),(0,1).
Question 2.12, GATE 2000: A JK master-slave flip-flop P has J=K=1; its output feeds a D master-slave flip-flop Q with the shared clock. Starting(P,Q)=(0,1), find the state after three cycles from choices(1,0),(1,1),(0,0),(0,1).
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: J=K=1 makes P toggle each cycle. Q captures the previous P through its D input; the master-slave arrangement prevents using the newly changed P as the same-cycle input.

Step 2: Apply(P_next,Q_next)=(¬P,P_old): (0,1)→(1,0)→(0,1)→(1,0).

After three cycles the state is(1,0), A. Sequentially updating Q from the new P would incorrectly erase the intended synchronous delay.

Original paper, page 4

2 marks · MCQ
Report issue

Frame-buffer capacity and color depth

Memory Organization & Address Translation

Question 2.13, GATE 2000: A graphics card has 1 MB on-board memory. Which mode cannot fit:1600×400 at 256 colors;1600×400 at 16 million colors;800×400 at 16 million colors;800×800 at 256 colors? Monitor physical size is also listed.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: A palette of 256 colors needs 8 bits=1 byte per pixel. About 16 million colors requires 24 bits=3 bytes per pixel in the conventional packed framebuffer.

Step 2: The four memory needs are 640,000;1,920,000;960,000;640,000 bytes respectively. Only the second exceeds either 1,000,000 or 1,048,576 bytes.

Thus B. Screen size in inches does not affect the number of stored pixels. The calculation assumes one packed buffer without extra padding, double buffering or 32-bit-per-pixel storage.

Original paper, page 5

2 marks · MCQ
Report issue

Floating-point loss of a small addend

Data Representation & Arithmetic

Question 2.14, GATE 2000: With 32-bit floating-point A=2·10^30,B=−2·10^30,C=1, perform X=A+B;Y=A+C;X=X+C;Y=Y+B. Choose(X,Y) from(1,1),(1,0),(0,1),(0,0).
Tap to enlarge
Your answer
Answer & solution

Answer: B under conventional single-precision rounding (no official key was published)

Step 1: Stored A and B are exact sign opposites, so A+B cancels to zero; subsequently X=0+1=1.

Step 2: Near magnitude 2·1030, single precision has a spacing vastly greater than 1. Thus A+1 rounds back to A, losing the small addend. Adding B afterward cancels to zero, giving Y=0.

Therefore B. This demonstrates nonassociativity of finite-precision addition. It assumes the stated 32-bit operations/rounding rather than an optimizer reassociating expressions or a wider intermediate format.

Original paper, page 5

2 marks · MCQ
Report issue

Array rotation by three reversals

Correctness, Invariants & Design

Question 2.15, GATE 2000: For array s[1…n] and 1≤k≤n, execute reverse(s,1,k),reverse(s,k+1,n),reverse(s,1,n). Does this rotate left by k,leave unchanged,reverse everything,or none?
Question 2.15, GATE 2000: For array s[1…n] and 1≤k≤n, execute reverse(s,1,k),reverse(s,k+1,n),reverse(s,1,n). Does this rotate left by k,leave unchanged,reverse everything,or none?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Split the original array into consecutive blocks A=s[1…k] and B=s[k+1…n], so it is AB. The first two operations produce AR BR.

Step 2: Reversing the whole concatenation reverses block order and each block: (AR BR)R=BA. This moves the first k entries to the end while preserving order within each block.

Thus A, a left rotation by k. For k=n, the second range is empty and must be treated as a no-op; the full rotation leaves the array unchanged.

Original paper, page 5

2 marks · MCQ
Report issue

Last visited vertices in binary-tree traversals

Tree Properties & Traversals

Question 2.16, GATE 2000: For a “complete binary tree,” compare the last vertices in postorder,inorder,preorder. Options equate inorder/postorder,inorder/preorder,preorder/postorder,or none.
Tap to enlarge
Your answer
Answer & solution

Answer: D for heap-complete trees; B for perfect/full-rightmost-path convention (no official key was published)

Step 1: Postorder ends at the root. Inorder ends at the rightmost node, while preorder ends at the last leaf visited after exploring subtrees.

Step 2: Under the modern complete-tree definition (last level filled left to right), take six heap-indexed nodes. Node 3 has left child 6 but no right child. Inorder ends at 3, preorder at 6, and postorder at 1. All three differ, so none of the proposed equalities is always true: D.

If “complete” is intended to mean perfect, the rightmost node is a leaf and is last in both inorder and preorder, giving B. The terminology ambiguity is retained rather than silently imposing the stronger shape.

Original paper, page 5

2 marks · MCQ
Report issue

Asymptotic comparison using logarithmic identities

Asymptotic Analysis & Recurrences

Question 2.17, GATE 2000: Let f(n)=3n^(√n),g(n)=2^(√n log2 n),h(n)=n!. Which is true: h=O(f),h=O(g),g is not O(f),or f=O(g)?
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Use 2log2 n=n to simplify g(n)=n√n. Hence f(n)=3g(n), so f and g are Θ-equivalent. This proves D and refutes the claim that g is not O(f).

Step 2: Factorial grows faster: n!≥(n/2)n/2, whose logarithm is(n/2)log(n/2), while log g=√n log n. Their ratio of logarithmic scales tends to infinity.

Thus h is neither O(f) nor O(g), leaving D.

Original paper, page 5

2 marks · MCQ
Report issue

Extremal edge weights in a spanning tree

Graph Algorithms

Question 2.18, GATE 2000: Connected undirected G has distinct edge weights. Which is false: every MST contains the minimum edge; if the maximum edge lies in an MST it is a bridge; no MST contains the maximum edge; G has a unique MST?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: The globally lightest edge is the unique lightest edge across a cut separating one endpoint from the other, so the cut property forces it into the MST. Distinct weights also give a unique MST.

Step 2: If the maximum edge lies on a cycle, it is the unique heaviest edge there and the cycle property excludes it. Thus if it appears in an MST, it must be a bridge. But a bridge is mandatory, even when globally heaviest.

A graph that is itself a weighted tree supplies a counterexample to C. Therefore C is false, while B correctly handles the bridge case.

Original paper, page 5

2 marks · MCQ
Report issue

Consecutive DFS discoveries

Graph Algorithms

Question 2.19, GATE 2000: In undirected DFS, u is discovered and v is the next newly discovered vertex. Which is always true? The options assert a direct edge with ancestry, or that absent edge implies u is a leaf, or that absent edge implies the same parent.
Question 2.19, GATE 2000: In undirected DFS, u is discovered and v is the next newly discovered vertex. Which is always true? The options assert a direct edge with ancestry, or that absent edge implies u is a leaf, or that absent edge implies the same parent.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: If u has an unvisited neighbor when its exploration begins, DFS immediately follows an edge to such a neighbor. Then the next discovery v is adjacent and becomes a child of u.

Step 2: If the next discovery is not adjacent to u, DFS must have exhausted u without discovering any child and backtracked to an ancestor before reaching v. Therefore u is a leaf in the DFS tree, proving C.

The backtrack may cross several ancestors, so u and v need not share a parent. The two options requiring adjacency in every case are also too strong.

Original paper, page 5

2 marks · MCQ
Report issue

Persistent local state across function calls

Scope, Lifetime & Storage Classes

Question 2.20, GATE 2000: Function incr(i) has static int count=0, executes count=count+i and returns count. main loops i=0 through 4 inclusive, assigning j=incr(i). Find final j among 10,4,6,7.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: A static local is initialized once and retains its value between calls. The successive arguments are 0,1,2,3,4.

Step 2: The retained count becomes 0,1,3,6,10. Each returned value is assigned to j, so the final assignment stores 10.

Thus A. Reinitializing count on every call would incorrectly yield 4; stopping the loop before i=4 would yield 6, but the printed condition is inclusive.

Original paper, page 6

2 marks · MCQ
Report issue

Precedence encoded in grammar levels

Parsing & Syntax Analysis

Question 2.21, GATE 2000: Given E→E*F|F+E|F and F→F−F|id, which operator-precedence claim is true: * above +; − above *; + and − equal; + above *?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: The only grammar productions introducing minus are inside F. Any operand F used by multiplication or addition is therefore formed before the surrounding E-level operation.

Step 2: For example id*id−id must have the minus within the right F, giving id*(id−id), rather than treating minus as an outer E-level operation. Thus minus binds more tightly than multiplication, B.

The E rules do not give a clean unambiguous ordering between + and *; some mixed expressions have multiple parses. F→F−F is itself associative-ambiguous. These ambiguities do not invalidate the separation placing minus at the tighter grammar level.

Original paper, page 6

2 marks · MCQ
Report issue

Effective memory time with rare page faults

Virtual Memory & Paging

Question 2.22, GATE 2000: Memory access takes 1 μs, average page-fault service 10 ms, and hit ratio is 99.99%. Choose effective time from 1.9999 ms,1 ms,9.999 μs,1.9999 μs.
Tap to enlarge
Your answer
Answer & solution

Answer: D under the inclusive fault-service convention (no official key was published)

Step 1: Convert 10 ms to 10,000 μs and use fault probability 1−0.9999=0.0001.

Step 2: If the fault-case time is the stated total service, expected time is 0.9999·1+0.0001·10,000=0.9999+1=1.9999 μs, D.

If “service” excludes the final retried access, add another 0.0001 μs to obtain 2 μs. This tiny convention difference is explicit; neither interpretation gives a millisecond-scale average.

Original paper, page 6

2 marks · MCQ
Report issue

A rule that fails to prevent deadlock

Deadlocks

Question 2.23, GATE 2000: Which is not a valid general prevention policy: release all before requesting a new resource; request only in increasing resource-number order; never request after releasing any resource; acquire all required resources before execution?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Releasing all held resources before a new request removes hold-and-wait. A global increasing order removes circular wait. Atomic acquisition of the full required set before running also avoids partial hold-and-wait.

Step 2: Merely forbidding requests after the first release does not prevent deadlock during the initial acquisition phase. Process P can hold A and request B while Q holds B and requests A; neither has released anything, so both obey that rule.

Thus C is insufficient. The prevention interpretation presumes the usual nonreentrant-resource model and an all-or-nothing initial acquisition policy in the last option.

Original paper, page 6

2 marks · MCQ
Report issue

Dependencies holding on a displayed instance

Functional Dependencies & Keys

Question 2.24, GATE 2000: Rows(X,Y,Z) are(1,4,2),(1,5,3),(1,6,3),(3,2,2). Which pair holds: XY→Z and Z→Y; YZ→X and Y→Z; YZ→X and X→Z; XZ→Y and Y→X?
Question 2.24, GATE 2000: Rows(X,Y,Z) are(1,4,2),(1,5,3),(1,6,3),(3,2,2). Which pair holds: XY→Z and Z→Y; YZ→X and Y→Z; YZ→X and X→Z; XZ→Y and Y→X?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Every Y value in the four rows is distinct. Hence Y uniquely identifies the entire row in this instance, so Y→Z and Y→X hold. Adding Z to Y cannot destroy uniqueness, so YZ→X also holds.

Step 2: Z→Y fails because Z=2 occurs with Y=4 and 2. X→Z fails because X=1 occurs with Z=2 and 3. XZ→Y fails because(X,Z)=(1,3) occurs with Y=5 and 6.

Thus only the conjunction in B holds. These are instance-level observations, not an inference that the same FDs constrain every possible future instance.

Original paper, page 6

2 marks · MCQ
Report issue

Projection of a Cartesian product in SQL

SQL & Queries

Question 2.25, GATE 2000: For r(w,x) and s(y,z), when is SELECT DISTINCT w,x FROM r,s guaranteed equal to r? Options: r duplicate-free and s nonempty; both duplicate-free; s duplicate-free and r nonempty; equal tuple counts.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: FROM r,s creates a Cartesian product. If s is nonempty, every row of r appears at least once in that product; projection onto w,x and DISTINCT then returns exactly the distinct rows of r.

Step 2: To preserve SQL bag multiplicities as well, r itself must have no duplicates. No duplicate restriction on s is needed because DISTINCT removes replication.

Hence A. If s is empty, the result is empty even for nonempty r. If r has duplicates, DISTINCT changes it. The other listed conditions do not rule out these failures.

Original paper, page 6

2 marks · MCQ
Report issue

Replacing SQL unknown comparisons with false

SQL & Queries

Question 2.26, GATE 2000: Suppose every comparison involving NULL returns FALSE rather than UNKNOWN. Which pair ceases to be equivalent: x=5 versus NOT NOT(x=5); x=5 versus x>4 AND x<6 for integer x; x≠5 versus NOT(x=5); or none?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: For an ordinary nonnull x, inequality x≠5 agrees with negated equality. But at x=NULL, the stipulated direct comparison x≠5 is FALSE, while x=5 is FALSE and its negation is TRUE. Thus C differs.

Step 2: Double negation still restores the original Boolean value, so A remains equivalent. In B, both comparisons on NULL are FALSE, making the conjunction FALSE just like equality; for nonnull integers the open interval(4,6) contains only 5.

Therefore only C among these pairs exposes the inconsistency. Standard SQL uses UNKNOWN precisely to avoid treating a negated unknown comparison as true.

Original paper, page 6

Descriptive
Report issue

Induction for a minimum recurrence

Proof Techniques & Number Theory

Question 3, GATE 2000: s₁=s₂=1 and sᵢ=1+min(sᵢ₋₁,sᵢ₋₂) for i>2.

Task: Prove sₙ=⌈n/2⌉ by induction.
Tap to enlarge
Shared context

s₁=s₂=1 and sᵢ=1+min(sᵢ₋₁,sᵢ₋₂) for i>2.

Answer & solution

Answer: sₙ=⌈n/2⌉ for n≥1. (no official key was published)

1. Use strong induction because the recurrence depends on two previous terms. The proposed formula gives 1 for n=1 and n=2, matching both initial conditions.

2. Assume the formula holds through n−1, with n≥3. Then sₙ=1+min(⌈(n−1)/2⌉,⌈(n−2)/2⌉). The second ceiling is no larger, so the minimum is ⌈(n−2)/2⌉.

3. Because subtracting an integer commutes with ceiling, ⌈(n−2)/2⌉=⌈n/2⌉−1. Therefore sₙ=⌈n/2⌉, completing induction.

4. Equivalently, n=2k gives 1+min(k,k−1)=k and n=2k+1 gives 1+min(k,k)=k+1. The first terms 1,1,2,2,3,3 check the ceiling rather than floor convention.

Original paper, page 6

Descriptive
Report issue

Why zero prevents a group

Algebraic Structures

Question 4(a), GATE 2000: S={0,1,2,3,4,5,6,7}; x⊗y=(xy) mod 8.

Task: Prove ({0,1},⊗) is not a group.
Question 4(a), GATE 2000: S={0,1,2,3,4,5,6,7}; x⊗y=(xy) mod 8.

Task: Prove ({0,1},⊗) is not a group.
Tap to enlarge
Shared context

S={0,1,2,3,4,5,6,7}; x⊗y=(xy) mod 8.

Answer & solution

Answer: 0 has no inverse relative to identity 1. (no official key was published)

1. The multiplication table is 0⊗0=0, 0⊗1=0, 1⊗0=0, 1⊗1=1. The set is closed, and associativity is inherited from integer multiplication modulo 8.

2. The identity is 1. Zero cannot be an identity because 0⊗1=0≠1.

3. For either candidate inverse y∈{0,1}, 0⊗y=0, never 1. Thus 0 has no inverse, violating a necessary group axiom. Closure and associativity alone do not establish a group.

Original paper, page 6

Descriptive
Report issue

Three order-two modular groups

Algebraic Structures

Question 4(b), GATE 2000: S={0,1,2,3,4,5,6,7}; x⊗y=(xy) mod 8.

Task: Give three distinct two-element subsets G such that (G,⊗) is a group.
Question 4(b), GATE 2000: S={0,1,2,3,4,5,6,7}; x⊗y=(xy) mod 8.

Task: Give three distinct two-element subsets G such that (G,⊗) is a group.
Tap to enlarge
Shared context

S={0,1,2,3,4,5,6,7}; x⊗y=(xy) mod 8.

Answer & solution

Answer: {1,3}, {1,5}, {1,7}. (no official key was published)

1. Choose a nonidentity element a with a²≡1 (mod 8). The odd residues 3,5,7 satisfy 9≡25≡49≡1 (mod 8).

2. For each a∈{3,5,7}, the entire table on {1,a} is 1⊗1=1, 1⊗a=a, a⊗1=a, a⊗a=1. This proves closure and identity 1.

3. Each element is its own inverse, and associativity is inherited from multiplication modulo 8. Hence all three subsets are groups, each isomorphic to the cyclic group of order 2.

Original paper, page 6

Descriptive
Report issue

Size-four multisets with a double

Combinatorics & Counting

Question 5(a), GATE 2000: A multiset is unordered; repetitions are allowed, and its size counts repetitions. Elements are chosen from n distinct types.

Task: Count size-four multisets in which at least one element occurs exactly twice.
Question 5(a), GATE 2000: A multiset is unordered; repetitions are allowed, and its size counts repetitions. Elements are chosen from n distinct types.

Task: Count size-four multisets in which at least one element occurs exactly twice.
Tap to enlarge
Shared context

A multiset is unordered; repetitions are allowed, and its size counts repetitions. Elements are chosen from n distinct types.

Answer & solution

Answer: n·C(n−1,2)+C(n,2)=n(n−1)²/2. (no official key was published)

1. The only multiplicity partitions of 4 containing a part equal to 2 are 2+1+1 and 2+2. The patterns 4, 3+1 and 1+1+1+1 do not qualify.

2. For 2+1+1 choose the repeated type in n ways and the two distinct singleton types in C(n−1,2) ways. The singleton order is irrelevant.

3. For 2+2 choose the two doubled types as an unordered pair: C(n,2). Do not designate one as the repeated type, which would double-count this case.

4. Add the disjoint cases to obtain n(n−1)(n−2)/2+n(n−1)/2=n(n−1)²/2. This is zero for n=1 and equals one for n=2, as direct enumeration confirms.

Original paper, page 7

Descriptive
Report issue

All finite multisets

Sets, Relations & Functions

Question 5(b), GATE 2000: A multiset is unordered; repetitions are allowed, and its size counts repetitions. Elements are chosen from n distinct types.

Task: How many multisets can be constructed, with no size bound stated?
Question 5(b), GATE 2000: A multiset is unordered; repetitions are allowed, and its size counts repetitions. Elements are chosen from n distinct types.

Task: How many multisets can be constructed, with no size bound stated?
Tap to enlarge
Shared context

A multiset is unordered; repetitions are allowed, and its size counts repetitions. Elements are chosen from n distinct types.

Answer & solution

Answer: Countably infinitely many for n≥1; one (the empty multiset) for n=0. (no official key was published)

1. A multiset is specified by its multiplicity vector (m₁,…,mₙ), each mᵢ a nonnegative integer. The question gives no upper bound on the sum.

2. For n≥1, using 0,1,2,… copies of the first type already gives infinitely many distinct multisets.

3. There are C(n+k−1,k) multisets of each fixed size k by stars and bars. A countable union over k≥0 of finite sets is countable, so the answer is countably infinite.

4. If size four had also been imposed here, the answer would instead be C(n+3,4). The printed part (b) does not impose that bound. With no element types, only the empty multiset exists.

Original paper, page 7

Descriptive
Report issue

Degree in the two-toggle graph

Graph Theory

Question 6(a), GATE 2000: G has one vertex for each of the 2ⁿ subsets of S={1,…,n}. Vertices A,B are adjacent iff |A△B|=2, where △ is symmetric difference.

Task: Find the common degree of each vertex.
Question 6(a), GATE 2000: G has one vertex for each of the 2ⁿ subsets of S={1,…,n}. Vertices A,B are adjacent iff |A△B|=2, where △ is symmetric difference.

Task: Find the common degree of each vertex.
Tap to enlarge
Shared context

G has one vertex for each of the 2ⁿ subsets of S={1,…,n}. Vertices A,B are adjacent iff |A△B|=2, where △ is symmetric difference.

Answer & solution

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

1. Fix any vertex A. A neighbor must be obtained by toggling membership of exactly two distinct elements of S.

2. For every unordered pair P⊆S, |P|=2, the vertex B=A△P is a neighbor. Different pairs give different B because A△B uniquely recovers P.

3. This is a bijection between neighbors and two-element subsets of S. Thus every vertex has degree C(n,2), independently of |A|. For n=0 or 1 there are no edges.

Original paper, page 7

Descriptive
Report issue

Parity components of the subset graph

Trees & Connectivity

Question 6(b), GATE 2000: G has one vertex for each of the 2ⁿ subsets of S={1,…,n}. Vertices A,B are adjacent iff |A△B|=2, where △ is symmetric difference.

Task: Find the number of connected components.
Question 6(b), GATE 2000: G has one vertex for each of the 2ⁿ subsets of S={1,…,n}. Vertices A,B are adjacent iff |A△B|=2, where △ is symmetric difference.

Task: Find the number of connected components.
Tap to enlarge
Shared context

G has one vertex for each of the 2ⁿ subsets of S={1,…,n}. Vertices A,B are adjacent iff |A△B|=2, where △ is symmetric difference.

Answer & solution

Answer: Two for n≥1: even-cardinality and odd-cardinality subsets; one if n=0. (no official key was published)

1. Toggling two memberships changes cardinality by −2, 0 or +2. Its parity cannot change, so no path joins an even subset to an odd subset.

2. Conversely, if A and B have the same parity, their symmetric difference has even size. Partition A△B into pairs P₁,…,Pₖ and successively toggle these pairs.

3. Every toggle is a legal edge and after k toggles the vertex is A△(A△B)=B. Thus each parity class is connected.

4. Both parity classes are nonempty when n≥1, giving exactly two components. When n=1 these are two isolated vertices. If the degenerate case n=0 is allowed, the graph has only ∅ and hence one component.

Original paper, page 7

Descriptive
Report issue

Minimal automaton for alternating bits

Finite Automata

Question 7(a), GATE 2000: Alphabet {0,1}; accept exactly the strings containing neither 00 nor 11 as a substring.

Task: Construct a minimal finite-state machine.
Question 7(a), GATE 2000: Alphabet {0,1}; accept exactly the strings containing neither 00 nor 11 as a substring.

Task: Construct a minimal finite-state machine.
Tap to enlarge
Shared context

Alphabet {0,1}; accept exactly the strings containing neither 00 nor 11 as a substring.

Answer & solution

Answer: Complete minimal DFA has four states: start, last-0, last-1, dead. (no official key was published)

1. Use states s (no symbol yet), z (valid prefix ending 0), o (valid prefix ending 1), and d (a forbidden equal adjacent pair has occurred). Start at s; accepting states are s,z,o, so ε is accepted.

2. Complete transition table, entries in input order 0,1: s→(z,o); z→(d,o); o→(z,d); d→(d,d). This is also a complete text specification of the requested machine.

3. Induction on the processed prefix proves the state invariant. Alternating bits move between z and o; a repeated bit enters d permanently. Thus precisely the required language is recognized.

4. All four states are reachable using ε,0,1,00. Dead d is distinguished from every accepting state by suffix ε. States s and z are distinguished by suffix 0, s and o by suffix 1, and z and o by suffix 0. Therefore no pair can merge and four states are minimal for a complete DFA. A partial drawing may omit the explicit dead state, but that is not a three-state complete DFA.

Original paper, page 7

Descriptive
Report issue

Exponents generated by a recursive grammar

Context-Free Grammars & Languages

Question 7(b), GATE 2000: Grammar S→aSAb | ε and A→bA | ε, with start S, generates strings aⁱbʲ, i,j≥0.

Task: Determine the exact condition on i,j.
Question 7(b), GATE 2000: Grammar S→aSAb | ε and A→bA | ε, with start S, generates strings aⁱbʲ, i,j≥0.

Task: Determine the exact condition on i,j.
Tap to enlarge
Shared context

Grammar S→aSAb | ε and A→bA | ε, with start S, generates strings aⁱbʲ, i,j≥0.

Answer & solution

Answer: (i,j)=(0,0), or i≥1 and j≥i. (no official key was published)

1. Every application of S→aSAb adds one a at the front and one mandatory b at the end, with an A that can generate any additional number of b symbols.

2. After i recursive applications and S→ε, the form is aⁱ(Ab)ⁱ. Thus j=i+k₁+⋯+kᵢ for arbitrary nonnegative integers k₁,…,kᵢ.

3. If i≥1, this gives j≥i. Every such j is attainable by assigning j−i extra b symbols to one A and zero to all the others.

4. If i=0, S goes directly to ε and there are no A symbols, so j must also be zero. The looser answer j≥i incorrectly includes nonempty strings consisting only of b.

Original paper, page 7

Descriptive
Report issue

Completing a reverse-matching PDA

Pushdown Automata

Question 8(a), GATE 2000: Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Task: Add two appropriately labeled edges to accept L by empty stack.
Question 8(a), GATE 2000: Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Task: Add two appropriately labeled edges to accept L by empty stack.
Question 8(a), GATE 2000: Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Task: Add two appropriately labeled edges to accept L by empty stack.
Tap to enlarge
Shared context

Two states q₀ (initial) and q₁. Existing edges: q₀→q₀ labeled 1,s/1s; q₀→q₁ labeled 2,s/s; q₁→q₁ labeled 1,1s/s. A label d,u/v consumes d and replaces entire stack u by v; s denotes the arbitrary remainder, top at left. Target L={x2xᴿ:x∈{0,1}*}.

Answer & solution

Answer: Add q₀→q₀: 0,s/0s and q₁→q₁: 0,0s/s. Exact formal acceptance requires the caveat below. (no official key was published)

1. The missing push edge is a q₀ self-loop labeled 0,s/0s. The missing matching-pop edge is a q₁ self-loop labeled 0,0s/s. Together with the existing 1 loops these handle both symbols.

2. Before the delimiter, q₀ pushes every input symbol. The sole 2 edge enters q₁ without changing the stack. After it, each input bit must match the top bit and pops it; mismatches have no move.

3. For x=01, the successive configurations are (q₀,01210,ε)→(q₀,1210,0)→(q₀,210,10)→(q₁,10,10)→(q₁,0,0)→(q₁,ε,ε). Thus the intended accepting condition is exhausted input, empty stack, and completed delimiter transition into q₁.

4. Formal defect: under ordinary acceptance by empty stack in ANY state, an initially empty stack accepts ε immediately, although ε∉L. The two requested edges cannot undo this existing accepting run. An initial bottom marker does not alone solve it: none of the displayed or added transitions removes that marker.

5. To formalize the intended construction, require q₁ together with empty stack at input end; alternatively start with bottom marker Z and additionally permit q₁→q₁ labeled ε,Z/ε. The latter is a third added edge and therefore exceeds the literal two-edge request. We report the intended pair without claiming it repairs the original formal specification.

Original paper, page 7

Descriptive
Report issue

Three-state PDA for bounded ratios

Pushdown Automata

Question 8(b), GATE 2000: Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Task: Describe a nondeterministic three-state PDA accepting by empty stack.
Question 8(b), GATE 2000: Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Task: Describe a nondeterministic three-state PDA accepting by empty stack.
Question 8(b), GATE 2000: Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Task: Describe a nondeterministic three-state PDA accepting by empty stack.
Tap to enlarge
Shared context

Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.

Answer & solution

Answer: Push one X per 0; nondeterministically consume either one or two 1s per X using three states. (no official key was published)

1. Use states p (initial zero-reading phase), q (one-reading phase), r (one more 1 required for the current X). Start with empty stack. Edges: p→p: 0,s/Xs; p→q: ε,s/s; q→q: 1,Xs/s; q→r: 1,Xs/Xs; r→q: 1,Xs/s. There are no other edges. Accept only when all input is consumed and the stack is empty, in any state.

2. The zero phase pushes n copies of X. After the ε transition to q, no transition reads a zero, so every accepted word has form 0ⁿ1ᵐ.

3. For each X, q may consume one 1 and pop immediately, or consume one 1 without popping, enter r, and require a second 1 to pop and return to q. State r cannot have an empty stack because its entry edge requires and retains an X.

4. If k of the n markers use the two-symbol option, total ones are m=n+k with 0≤k≤n. Conversely any m in [n,2n] is realized by selecting k=m−n markers for that option.

5. The empty word is correctly accepted for n=m=0. A nonempty all-zero word leaves markers, a leading 1 has no applicable pop, and extra 1s cannot be read after the last marker disappears. This verifies the boundary cases without a bottom-marker convention.

Original paper, page 7

Descriptive
Report issue

BCD modulo-six truth table

Binary Codes & Error Detection

Question 9(a), GATE 2000: Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected.

Task: Give the complete valid-input truth table, using 1 for truth.
Question 9(a), GATE 2000: Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected.

Task: Give the complete valid-input truth table, using 1 for truth.
Tap to enlarge
Shared context

Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected.

Answer & solution

Answer: Outputs for inputs 0…9: 000,001,010,011,100,101,000,001,010,011. (no official key was published)

1. For d=0,…,5 the output equals d. For d=6,…,9 subtract six once, giving 0,1,2,3.

2. Table (decimal d: I₄I₃I₂I₁ → R₃R₂R₁): 0:0000→000; 1:0001→001; 2:0010→010; 3:0011→011; 4:0100→100; 5:0101→101; 6:0110→000; 7:0111→001; 8:1000→010; 9:1001→011.

3. Inputs 1010,1011,1100,1101,1110,1111 may all be assigned XXX (don’t-care), not mandatory zero. No fourth output bit is needed because the maximum remainder is 5; if a four-bit interface is desired, R₄=0 for valid inputs.

4. In particular parity is unchanged by subtracting six, so the least significant bit is simply R₁=I₁. This provides a useful check on every row.

Original paper, page 7

Descriptive
Report issue

Gate-level modulo-six converter

Binary Codes & Error Detection

Question 9(b), GATE 2000: Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected. Available altogether: two two-input AND gates, one two-input OR gate, and two NOT gates (OR is explicit in GFG; omitted in GateForum).

Task: Specify one circuit for each output bit within the gate budget.
Question 9(b), GATE 2000: Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected. Available altogether: two two-input AND gates, one two-input OR gate, and two NOT gates (OR is explicit in GFG; omitted in GateForum).

Task: Specify one circuit for each output bit within the gate budget.
Question 9(b), GATE 2000: Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected. Available altogether: two two-input AND gates, one two-input OR gate, and two NOT gates (OR is explicit in GFG; omitted in GateForum).

Task: Specify one circuit for each output bit within the gate budget.
Tap to enlarge
Shared context

Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected.

Answer & solution

Answer: R₁=I₁; R₂=(I₂∧¬I₃)∨I₄; R₃=I₃∧¬I₂. (no official key was published)

1. R₃ must be one only for valid digits 4 and 5. Their I₃=1 and I₂=0, so R₃=I₃ AND NOT I₂. Illegal inputs are don’t-care, permitting this simple expression.

2. R₂ is one for 2,3,8,9. The term I₂ AND NOT I₃ covers 2,3; I₄ covers 8,9 among valid BCD digits. Therefore R₂=(I₂ AND NOT I₃) OR I₄.

3. Complete netlist: N₂=NOT(I₂); N₃=NOT(I₃); G₂=AND(I₂,N₃); G₃=AND(I₃,N₂); R₂=OR(G₂,I₄); R₃=G₃; R₁ is a wire from I₁. This explicitly identifies every gate input and output and uses exactly the allowed 2 NOT, 2 AND, 1 OR gates.

4. Checking d=6,7 gives I₃=I₂=1, so R₃=R₂=0 and only parity R₁ remains. Checking d=8,9 gives I₄=1 and I₃=I₂=0, so output is 010 or 011. These are the nontrivial modulo reductions.

5. R₃ is the weight-four bit, not R₄. If four output positions are drawn, tie R₄ to zero.

Original paper, page 7

Descriptive
Report issue

8085 input timing boxes

Input/Output, DMA & Interrupts

Question 10(a), GATE 2000: The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Task: Give A,B,C,D in hexadecimal.
Question 10(a), GATE 2000: The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Task: Give A,B,C,D in hexadecimal.
Tap to enlarge
Shared context

The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Answer & solution

Answer: Intended IN: A=DBH, B=09H, C=09H, D=51H. Copying the printed table gives A=DAH but is inconsistent with IN. (no official key was published)

1. Opcode fetch addresses 3050H, placing 30H on the high address bus and 50H on the multiplexed low bus during its address phase. During its data phase, box A is the opcode byte.

2. The next memory cycle addresses 3051H. High address stays 30H; low address box D is 51H. Memory then returns the immediate port number, so box B is 09H.

3. For the I/O-read cycle, the 8085 places the eight-bit port address on both halves of the address bus. Thus high-address box C is 09H; the low address is also 09H during that cycle’s address phase.

4. The reproductions print DAH at 3050H. A literal transcription therefore fills A=DAH, B=09H, C=09H, D=51H in the intended diagram. Architecturally, however, IN has opcode DBH; DAH is JC addr16 and would require another address byte rather than this I/O cycle. No single execution satisfies both the table and the stated instruction.

5. For a corrected executable IN 09H use DBH at 3050H and keep B,C,D as above. For the literal DAH program, the missing byte at 3052H and initial carry are needed to determine the jump; there is no intended peripheral read.

Original paper, page 7

Descriptive
Report issue

ALE and read control during fetch

Input/Output, DMA & Interrupts

Question 10(b), GATE 2000: The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Task: State ALE and active-low RD at T1,T2,T3,T4.
Question 10(b), GATE 2000: The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Task: State ALE and active-low RD at T1,T2,T3,T4.
Tap to enlarge
Shared context

The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Answer & solution

Answer: ALE: pulse high in T1, low in T2–T4. RD̅: high, low, low, high. (no official key was published)

1. T1 is the opcode-fetch address phase. ALE pulses high so an external latch can retain the low address before AD₇…AD₀ is reused as a data bus. RD̅ remains inactive high.

2. In T2 and T3 the memory read is active: RD̅ is low and the addressed memory drives the opcode. ALE is low because the low address has already been latched.

3. T4 is internal decoding, not an additional memory read, so RD̅ is high and ALE is low. State-level summary (T1,T2,T3,T4): ALE=(pulse,0,0,0); RD̅=(1,0,0,1). A pulse is not a claim that ALE is high for the entire T1 interval.

4. These first four states are an opcode fetch for either DAH or DBH; thus the opcode discrepancy does not alter this control-signal answer. Subsequent cycles do differ, as explained in part (a).

Original paper, page 7

Descriptive
Report issue

Generating the peripheral read strobe

Input/Output, DMA & Interrupts

Question 10(c), GATE 2000: The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Task: Which signals are combined to tell the peripheral to put data on the bus?
Question 10(c), GATE 2000: The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Task: Which signals are combined to tell the peripheral to put data on the bus?
Tap to enlarge
Shared context

The printed 8085 instruction is IN 09H at memory 3050H, with table [3050H]=DAH, [3051H]=09H. In the intended ten-T-state IN trace, opcode fetch uses T1–T4, operand memory read T5–T7, and I/O read T8–TA. Box A is opcode data on AD₇…AD₀, box D is low address for operand fetch, box B is operand data, and box C is high address A₁₅…A₈ during I/O read. The figure initially shows high address 30H and low address 50H.

Answer & solution

Answer: Combine IO/M and RD̅; active-low IOR̅=¬(IO/M)∨RD̅, gated with the decoded port select. (no official key was published)

1. IO/M=1 identifies an I/O cycle, while RD̅=0 requests a read. A peripheral may drive the bus only when both conditions hold.

2. The active-high read condition is (IO/M) AND NOT(RD̅). Complementing gives the usual active-low I/O-read strobe IOR̅=NOT(IO/M) OR RD̅.

3. Truth table in order (IO/M,RD̅)=(0,0),(0,1),(1,0),(1,1) gives IOR̅=1,1,0,1. Thus a memory read does not activate the peripheral.

4. The individual device must also be selected by decoding port 09H; for active-high select S, its active-low enable is NOT S OR IOR̅. The requested common bus-control signals are IO/M and RD̅, with address decoding selecting which peripheral responds.

Original paper, page 7

Descriptive
Report issue

BCD accumulator at the carry branch

Data Representation & Arithmetic

Question 11(a)(i), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: For (B,C)=(44,25) and (33,46), find A at S2.
Question 11(a)(i), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: For (B,C)=(44,25) and (33,46), find A at S2.
Question 11(a)(i), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: For (B,C)=(44,25) and (33,46), find A at S2.
Tap to enlarge
Shared context

B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . Interpret the latter as INR for the architectural analysis.

Answer & solution

Answer: A=18H (CY=1) and A=86H (CY=0), respectively. (no official key was published)

1. All shown register inputs are packed BCD, so decimal 44 means byte 44H, not byte 2CH. MVI D does not change the accumulator or arithmetic flags.

2. First pair: 99H−25H=74H. ADD 44H gives B8H, with no low-nibble auxiliary carry (4+4=8). DAA corrects the invalid high decimal digit by adding 60H, producing 118H: A=18H and CY=1 at S2.

3. Second pair: 99H−46H=53H. ADD 33H gives 86H, already valid BCD, with no carry or auxiliary carry. DAA makes no correction: A=86H and CY=0.

4. The decimal interpretation is 99−25+44=118, whose lower two digits are 18 with a carry, and 99−46+33=86 without a carry. This part ends before INR and the second DAA, so the later program defect does not change these answers.

Original paper, page 8

Descriptive
Report issue

Tracing BCD output registers

Data Representation & Arithmetic

Question 11(a)(ii), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: For (B,C)=(44,25) and (33,46), find D,E at S4.
Question 11(a)(ii), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: For (B,C)=(44,25) and (33,46), find D,E at S4.
Question 11(a)(ii), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: For (B,C)=(44,25) and (33,46), find D,E at S4.
Tap to enlarge
Shared context

B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . Interpret the latter as INR for the architectural analysis.

Answer & solution

Answer: Literal 8085: (D,E)=(00H,79H) and (FFH,13H). Intended subtraction output for first pair is (00H,19H), requiring a carry-clearing correction. (no official key was published)

1. For the first pair S2 has A=18H,CY=1. JC goes to S3 and D remains 00H. INR A makes A=19H but, on 8085, does not change carry. Therefore CY is still 1.

2. The following DAA uses that retained carry and adds 60H, producing 79H. MOV E,A therefore stores E=79H. It is incorrect to report literal E=19H while silently treating INR as a carry-clearing operation.

3. For the second pair S2 has A=86H,CY=0, so JC is not taken. MOV E,A stores 86H; then A=99H−86H=13H and MOV E,A stores 13H. The result is nonzero, so JZ is not taken and D becomes FFH. Final pair is (FFH,13H).

4. The apparent intent is a signed magnitude: D=00H for nonnegative B−C, FFH for negative, and E the BCD magnitude. That intended first result would be 19H. Replacing INR A by ADI 01H clears the inherited carry for these reachable values and gives the intended result after DAA; this is a proposed repair, not text present in the source.

5. The paper’s clear INR resolves the mnemonic but not the retained-carry defect. Both literal and intended interpretations must remain visible until an authoritative erratum is available.

Original paper, page 8

Descriptive
Report issue

General behavior of the BCD difference program

Data Representation & Arithmetic

Question 11(b), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: Express D and E at S4 as functions of the decimal values b,c represented by B,C.
Question 11(b), GATE 2000: B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . GFG prints INR A; GateForum prints INC A, which is not an 8085 mnemonic. Interpret the latter as INR for the architectural analysis.

Task: Express D and E at S4 as functions of the decimal values b,c represented by B,C.
Tap to enlarge
Shared context

B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . Interpret the latter as INR for the architectural analysis.

Answer & solution

Answer: If b≤c: E=BCD(c−b), D=FFH for b<c and 00H for equality. If b>c: D=00H, literal E=BCD(b−c)+60H (byte arithmetic), not the intended BCD(b−c). (no official key was published)

1. Define enc(t)=16⌊t/10⌋+(t mod 10) for 0≤t≤99. Since each digit of 99 exceeds or equals the corresponding digit of C, 99H−C is the packed-BCD nine’s complement enc(99−c).

2. ADD B followed by DAA computes 99−c+b. If b>c its decimal value is 100…198, so CY=1 and A=enc(b−c−1). If b≤c, CY=0 and A=enc(99−(c−b)).

3. When b≤c, the no-carry path subtracts this BCD nine’s complement from 99H, giving E=enc(c−b). Zero leaves D=00H; otherwise D becomes FFH. This branch correctly implements zero or a negative signed magnitude.

4. When b>c let d=b−c∈[1,99]. INR changes enc(d−1) by one and leaves CY=1. DAA performs the required low-digit correction, but also adds 60H because carry was preserved. Therefore the literal E is enc(d)+60H (mod 256), with D=00H. For example d=19 gives 79H and d=40 gives A0H, even an invalid BCD digit.

5. The intended function is D=00H if b≥c else FFH, E=enc(|b−c|). It becomes correct if S3 uses ADI 01H instead of INR A: the ordinary addition resets carry appropriately before the final DAA. Do not label the intended function as the unmodified program’s actual behavior.

Original paper, page 8

Descriptive
Report issue

Pipeline average with serialized branches

Pipelining & Hazards

Question 12(a), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead.

Task: Find average instruction execution time when every branch prevents overlap.
Question 12(a), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead.

Task: Find average instruction execution time when every branch prevents overlap.
Tap to enlarge
Shared context

An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead.

Answer & solution

Answer: 3.6 ns per instruction (CPI 1.8 at a 2 ns clock). (no official key was published)

1. Without branches, the pipeline accepts a new instruction every cycle, hence steady-state throughput time is 2 ns per instruction, not the individual instruction latency of 10 ns.

2. A branch fetched in cycle t completes at the end of t+4. The successor can be fetched in t+5, whereas normal overlap would fetch it in t+1. Thus each such branch adds four idle fetch cycles, or 8 ns.

3. The expected cycles per instruction are 1+0.20×4=1.8. Multiplying by 2 ns gives 3.6 ns per instruction.

4. Equivalently, 80% of inter-fetch intervals are 2 ns and 20% are 10 ns, so 0.8×2+0.2×10=3.6 ns. Finite programs have fill/drain effects; the question’s average uses the usual long-run idealization.

Original paper, page 8

Descriptive
Report issue

Pipeline average with conditional branches

Pipelining & Hazards

Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Question 12(b), GATE 2000: An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Task: Find the revised average instruction execution time.
Tap to enlarge
Shared context

An ideal five-stage pipeline has stage time 2 ns; every instruction uses all five stages. For a nonoverlapped branch, the following instruction is not fetched until the branch completes. Branches are 20% of all executed instructions. Compute steady-state average time, ignoring finite-stream fill/drain overhead. Of the branch instructions, 80% are conditional; half of those are taken. For a not-taken conditional branch the following instructions may overlap.

Answer & solution

Answer: 2.96 ns per instruction (CPI 1.48). (no official key was published)

1. Within the branch population, 20% are unconditional and always impose the no-overlap rule. Another 80%×50%=40% are taken conditional branches. Thus 60% of branches impose the four-cycle penalty.

2. As branches are 20% of all instructions, the fraction of all instructions causing the penalty is 0.20×0.60=0.12. The remaining 0.88 do not interrupt ideal overlap under the stated model.

3. Average CPI is 1+0.12×4=1.48, giving 1.48×2=2.96 ns. Equivalently 0.88×2+0.12×10=2.96 ns.

4. The 50% figure applies only to conditional branches, not to every branch. Ignoring the unconditional 20% of branches would incorrectly reduce the answer to 2.64 ns. No branch prediction or extra recovery penalty is introduced beyond the assumptions given.

Original paper, page 8

Descriptive
Report issue

Implement queue with reversible stack

Stacks & Queues

Question 13(a), GATE 2000: A stack supports PUSH, POP and REVERSE, which reverses all its elements. Implement ENQUEUE with one operation and DEQUEUE with three.
Question 13(a), GATE 2000: A stack supports PUSH, POP and REVERSE, which reverses all its elements. Implement ENQUEUE with one operation and DEQUEUE with three.
Tap to enlarge
Answer & solution

Answer: ENQUEUE(x): PUSH(x). DEQUEUE: REVERSE; x = POP(); REVERSE; return x. (no official key was published)

Maintain the queue front at the bottom of the stack and its rear at the top. If queue order is a,b,c (a oldest), the stack bottom-to-top is [a,b,c]. ENQUEUE(d) executes PUSH(d), producing [a,b,c,d], exactly the required FIFO order. To remove the oldest element, REVERSE changes the stack to [d,c,b,a], POP returns a, and the second REVERSE restores [b,c,d]. Thus the invariant is restored after each completed operation. The return statement is not an additional stack operation. On an empty queue, detect underflow rather than POP an absent item. The question counts interface operations, not their implementation costs: REVERSE may require linear time in an ordinary stack representation.

Original paper, page 8

Descriptive
Report issue

Trace first postfix prefix

Stacks & Queues

Question 13(b)(i), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack after prefix 5 2 * 3 4 +.
Question 13(b)(i), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack after prefix 5 2 * 3 4 +.
Question 13(b)(i), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack after prefix 5 2 * 3 4 +.
Tap to enlarge
Answer & solution

Answer: [10, 7], top = 7 (no official key was published)

Step through it (7 steps)

Read left to right. An operand is pushed; an operator pops the right operand first and then the left, computes left operator right, and pushes the result. The successive stacks are [5], [5,2], [10], [10,3], [10,3,4], [10,7]. The multiplication consumes 5 and 2 to produce 10; the addition consumes only 3 and 4 to produce 7. The earlier 10 remains below the new result. Therefore the requested stack is bottom [10,7] top.

Original paper, page 8

Descriptive
Report issue

Trace second postfix prefix

Stacks & Queues

Question 13(b)(ii), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack after prefix 5 2 * 3 4 + 5 2.
Question 13(b)(ii), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack after prefix 5 2 * 3 4 + 5 2.
Question 13(b)(ii), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack after prefix 5 2 * 3 4 + 5 2.
Tap to enlarge
Answer & solution

Answer: [10, 7, 5, 2], top = 2 (no official key was published)

Step through it (9 steps)

The prefix 5 2 * 3 4 + leaves [10,7]: 5*2=10 and 3+4=7 are two independent partial results. The next token 5 is an operand, so push it to obtain [10,7,5]. Push the next operand 2 to obtain [10,7,5,2]. Stop here: the following multiplication has not yet been read, so 5 and 2 must remain separate entries. The top is 2 and the bottom is 10.

Original paper, page 8

Descriptive
Report issue

Finish postfix evaluation

Stacks & Queues

Question 13(b)(iii), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack at the end.
Question 13(b)(iii), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack at the end.
Question 13(b)(iii), GATE 2000: Evaluate the postfix expression 5 2 * 3 4 + 5 2 * * + with single-digit operands, binary addition and multiplication. Stacks below are bottom-to-top. Give the stack at the end.
Tap to enlarge
Answer & solution

Answer: [80] (no official key was published)

Step through it (12 steps)

After 5 2 * 3 4 + 5 2 the stack is [10,7,5,2]. The next * replaces the top two entries 5,2 by 10, leaving [10,7,10]. The following * replaces 7,10 by 70, leaving [10,70]. Finally + replaces 10,70 by 80, leaving [80]. There are six operand tokens and five binary operators, so a valid complete evaluation must leave exactly one entry. In infix form the expression is (5*2)+((3+4)*(5*2))=10+7*10=80.

Original paper, page 8

Descriptive
Report issue

Locate point below line

Other / Mixed Topics

Question 14(a), GATE 2000: Let m,n be positive integers and let the line be y=(n/m)x. Define A=mq−np for endpoint (p,q), and B=ms−nr for endpoint (r,s). If A<0, is (p,q) above, below or on the line?
Question 14(a), GATE 2000: Let m,n be positive integers and let the line be y=(n/m)x. Define A=mq−np for endpoint (p,q), and B=ms−nr for endpoint (r,s). If A<0, is (p,q) above, below or on the line?
Tap to enlarge
Answer & solution

Answer: Below the line. (no official key was published)

Because m>0, dividing mq−np<0 by m preserves the inequality and gives q<(n/m)p. At horizontal coordinate p, the line has height (n/m)p, whereas the point has smaller height q. Therefore the point is below the line. Equality A=0 would mean on the line, and A>0 would mean above. The assumption m>0 is essential when converting the sign to this vertical interpretation.

Original paper, page 8

Descriptive
Report issue

Complete line intersection test

Correctness, Invariants & Design

Question 14(b), GATE 2000: Let m,n be positive integers and let the line be y=(n/m)x. Define A=mq−np for endpoint (p,q), and B=ms−nr for endpoint (r,s). Complete clash: initialize false; line4 tests A [box] 0; line5 tests B [box] 0; line6 tests A [box] 0 and B [box] 0; line7 tests A [box] 0 and B [box] 0. Each successful test sets clash=true.
Question 14(b), GATE 2000: Let m,n be positive integers and let the line be y=(n/m)x. Define A=mq−np for endpoint (p,q), and B=ms−nr for endpoint (r,s). Complete clash: initialize false; line4 tests A [box] 0; line5 tests B [box] 0; line6 tests A [box] 0 and B [box] 0; line7 tests A [box] 0 and B [box] 0. Each successful test sets clash=true.
Tap to enlarge
Answer & solution

Answer: Line4 =; line5 =; line6 < and >; line7 > and < (last two cases may be exchanged). (no official key was published)

A segment intersects the infinite line if either endpoint lies on it, or if its endpoints lie on opposite sides. The completed Pascal-style code is:

function clash(m,n,p,q,r,s: integer): Boolean;
begin
  clash := false;
  if (m*q-n*p) = 0 then clash := true;        {line 4}
  if (m*s-n*r) = 0 then clash := true;        {line 5}
  if (m*q-n*p) < 0 and (m*s-n*r) > 0 then clash := true; {6}
  if (m*q-n*p) > 0 and (m*s-n*r) < 0 then clash := true; {7}
end;

For a point interpolated along the segment with parameter t in [0,1], the signed expression is (1−t)A+tB. If A and B have opposite signs, this linear continuous function has a zero in the interval. If both have the same nonzero sign, every convex combination has that sign and there is no intersection. Endpoint equality also handles a zero-length segment lying on the line and a whole segment coincident with it. Avoid multiplying A*B merely to test the signs: that introduces extra overflow risk. As mathematical pseudocode, the original arithmetic assumes exact integer results.

Original paper, page 8

Descriptive
Report issue

Trace sparse-set initialization

Arrays & Linked Lists

Question 15(a), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. GateForum calls set(7); set(3); set(9). Find count, q[1..3], p[7],p[3],p[9].
Question 15(a), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. GateForum calls set(7); set(3); set(9). Find count, q[1..3], p[7],p[3],p[9].
Question 15(a), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. GateForum calls set(7); set(3); set(9). Find count, q[1..3], p[7],p[3],p[9].
Tap to enlarge
Answer & solution

Answer: count=3; q[1..3]=[7,3,9]; p[7]=1, p[3]=2, p[9]=3. (no official key was published)

Starting from count=0, set(7) increments count to 1, writes q[1]=7 and p[7]=1. Then set(3) increments count to 2, writes q[2]=3 and p[3]=2. Finally set(9) increments count to 3, writes q[3]=9 and p[9]=3. The other initially arbitrary array cells need not be initialized to answer these queries.
If that literal reading is used, the result is count=3, q=[7,8,9], p[7]=1, p[8]=2, p[9]=3, while p[3] remains arbitrary.

Original paper, page 8

Descriptive
Report issue

Identify initialized inverse-array prefix

Arrays & Linked Lists

Question 15(b), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. Fill: The first count elements of ____ contain values i such that set(____) has been called.
Question 15(b), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. Fill: The first count elements of ____ contain values i such that set(____) has been called.
Question 15(b), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. Fill: The first count elements of ____ contain values i such that set(____) has been called.
Tap to enlarge
Answer & solution

Answer: q; i (no official key was published)

The completed sentence is: The first count elements of q contain values i such that set(i) has been called. Each invocation appends its argument to q at the new count and records that position in p. Hence q[1..count] is a dense log of calls, in invocation order. It contains no uninitialized holes because count starts at zero and increases by exactly one before each write. Repeated set(i) calls may put repeated copies of i into q, while p[i] records the latest position. The claim is about values that have been set, not necessarily distinct values.

Original paper, page 8

Descriptive
Report issue

Prove sparse-set rejection

Arrays & Linked Lists

Question 15(c), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. Prove is_set(i) returns false if set(i) has never been called, regardless of the initial p[i].
Question 15(c), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. Prove is_set(i) returns false if set(i) has never been called, regardless of the initial p[i].
Question 15(c), GATE 2000: Arrays p[1..N] and q[1..N] initially contain arbitrary values; count=0. Pseudocode:
set(i) { count=count+1; q[count]=i; p[i]=count; }
is_set(i) { if (p[i]<=0 or p[i]>count) return false; if (q[p[i]]!=i) return false; return true; }
Assume valid indices and no capacity overflow. Prove is_set(i) returns false if set(i) has never been called, regardless of the initial p[i].
Tap to enlarge
Answer & solution

Answer: Either p[i] is out of the initialized range, or q[p[i]] differs from i. (no official key was published)

There are two exhaustive cases. First, p[i]<=0 or p[i]>count: the first guard returns false before q is indexed, so an arbitrary invalid p[i] cannot cause an out-of-range read. Second, 1<=p[i]<=count: every cell in q[1..count] was explicitly written by some set(j) call and stores that call’s j. Since set(i) never occurred, none of these cells equals i. In particular q[p[i]]!=i, so the second guard returns false. This argument also covers count=0, when every possible integer p[i] fails the range guard. The reverse-pointer check is what prevents a coincidentally plausible initial p[i] from producing a false positive. This is an abstract-array algorithm, not permission to read indeterminate C objects: a literal C implementation must use a representation for which such reads are defined. Calls must stay within the arrays’ capacity; otherwise the premise that q[1..count] is valid fails.

Original paper, page 8

Descriptive
Report issue

Memoize Fibonacci recursion

Dynamic Programming

Question 16(a), GATE 2000: Array f[0..M] starts at zero. fib(n) checks n>M for error, returns 1 for n=0 or 1, then executes if([1]) return [2]; t=fib(n−1)+fib(n−2); [3]; return t. Assume 0<=n<=M and exact arithmetic. Fill the three boxes.
Question 16(a), GATE 2000: Array f[0..M] starts at zero. fib(n) checks n>M for error, returns 1 for n=0 or 1, then executes if([1]) return [2]; t=fib(n−1)+fib(n−2); [3]; return t. Assume 0<=n<=M and exact arithmetic. Fill the three boxes.
Tap to enlarge
Answer & solution

Answer: (1) f[n]!=0; (2) f[n]; (3) f[n]=t; (no official key was published)

The completed function is:
fib(n) {
  if (n > M) error();
  if (n == 0) return 1;
  if (n == 1) return 1;
  if (f[n] != 0) return f[n];
  t = fib(n-1) + fib(n-2);
  f[n] = t;
  return t;
}

Use a local t in each recursive activation. Since both base cases equal 1, every valid Fibonacci result is positive. Thus zero safely means “not computed” under the stated exact-arithmetic model. On a cache miss, recursively obtain the two predecessors, store their sum before returning, and reuse it whenever n is requested again. For example fib(4) obtains fib(3)=3, then reads the cached fib(2)=2, producing 5. The base cases need not be stored because they already take constant time. With overflowing machine arithmetic, zero might cease to be a valid sentinel; practical implementations can use an independent computed flag or arbitrary-precision values.

Original paper, page 9

Descriptive
Report issue

Bound memoized Fibonacci work

Dynamic Programming

Question 16(b), GATE 2000: Array f[0..M] starts at zero. fib(n) checks n>M for error, returns 1 for n=0 or 1, then executes if([1]) return [2]; t=fib(n−1)+fib(n−2); [3]; return t. Assume 0<=n<=M and exact arithmetic. With memoization filled correctly, find the running time of the first fib(n) computation.
Question 16(b), GATE 2000: Array f[0..M] starts at zero. fib(n) checks n>M for error, returns 1 for n=0 or 1, then executes if([1]) return [2]; t=fib(n−1)+fib(n−2); [3]; return t. Assume 0<=n<=M and exact arithmetic. With memoization filled correctly, find the running time of the first fib(n) computation.
Question 16(b), GATE 2000: Array f[0..M] starts at zero. fib(n) checks n>M for error, returns 1 for n=0 or 1, then executes if([1]) return [2]; t=fib(n−1)+fib(n−2); [3]; return t. Assume 0<=n<=M and exact arithmetic. With memoization filled correctly, find the running time of the first fib(n) computation.
Tap to enlarge
Answer & solution

Answer: Θ(n) time in the unit-cost arithmetic model; Θ(n) recursion depth and used cache cells. (no official key was published)

For each k from 2 through n there is at most one cache miss. That miss performs a constant number of comparisons, two recursive calls, one addition and one store. All later calls on the same k return from the cache in constant time. The subproblem dependency graph has n+1 possible arguments and two outgoing calls per non-base argument, so the total number of calls and primitive operations is O(n), not exponential. A first computation must actually compute each of fib(2),...,fib(n), giving Ω(n) work; therefore the tight bound is Θ(n). The descent n,n−1,...,1 can occupy Θ(n) stack frames. Initializing the provided whole array costs Θ(M) separately, but the stem says it is already initialized. If bit complexity is counted, Fibonacci numbers have Θ(n) bits, and the n additions have increasing cost; the conventional linear answer assumes constant-time arithmetic.

Original paper, page 9

Descriptive
Report issue

Bound worst-case sorting swaps

Searching, Sorting & Selection

Question 17(a), GATE 2000: An array has four 0s, five 1s and three 2s, and is to be sorted increasingly using swaps. GFG Q64 p9 permits nonadjacent swaps; GateForum Q17 p16 requires adjacent swaps. Solve both distinct source versions. Find the maximum, over initial orders, of the minimum required swaps.
Question 17(a), GATE 2000: An array has four 0s, five 1s and three 2s, and is to be sorted increasingly using swaps. GFG Q64 p9 permits nonadjacent swaps; GateForum Q17 p16 requires adjacent swaps. Solve both distinct source versions. Find the maximum, over initial orders, of the minimum required swaps.
Tap to enlarge
Answer & solution

Answer: 7 for arbitrary swaps; 47 for adjacent-only swaps. (no official key was published)

Arbitrary-swap version: partition the target positions into zones of sizes 4,5,3 for 0,1,2. A misplaced value j in zone i is a directed edge i→j. Incoming and outgoing edge counts balance at every zone. First cancel every opposite pair i→j,j→i with one swap, fixing two positions. Once opposite pairs are exhausted, remaining edges form consistently oriented 3-cycles, each fixed by two swaps. Let d be the number of canceled pairs and c the number of remaining 3-cycles. This uses d+2c swaps and moves M=2d+3c<=12 misplaced positions. Each 3-cycle uses one position in the 2-zone, so c<=3. For c=0,1,2,3, the bound d<=floor((12−3c)/2) gives d+2c<=6,6,7,7 respectively. Hence seven swaps always suffice.
Attainment: use 1111|00222|001, where bars show target zones. Its opposite pairs are two 0/1 pairs and one 1/2 pair, and the remaining six misplaced entries form two 3-cycles, so seven suffice. To see six cannot suffice, all 12 positions are initially wrong. Six swaps would have to fix two positions each, and thus every swap would need to exchange an opposite pair without creating any new error. There are only three opposite pairs initially; after removing those, the remaining directed 3-cycles have no such pair. Six swaps are therefore impossible. The worst-case optimum is exactly 7.
Adjacent-only version: the minimum number of swaps equals the inversion count because an adjacent swap changes that count by exactly 1, and swapping adjacent inverted pairs sorts while decreasing it each time. The largest inversion count is attained by descending groups 222111110000. Every unequal pair is then inverted: 3*5+3*4+5*4=15+12+20=47. Equal-value pairs contribute zero. This discrepancy is substantive; the paper is authenticated as the official wording.

Original paper, page 9

Descriptive
Report issue

Construct worst-case swap orders

Searching, Sorting & Selection

Question 17(b), GATE 2000: An array has four 0s, five 1s and three 2s, and is to be sorted increasingly using swaps. GFG Q64 p9 permits nonadjacent swaps; GateForum Q17 p16 requires adjacent swaps. Solve both distinct source versions. Give an order attaining the worst-case minimum.
Question 17(b), GATE 2000: An array has four 0s, five 1s and three 2s, and is to be sorted increasingly using swaps. GFG Q64 p9 permits nonadjacent swaps; GateForum Q17 p16 requires adjacent swaps. Solve both distinct source versions. Give an order attaining the worst-case minimum.
Tap to enlarge
Answer & solution

Answer: Arbitrary: 111100222001. Adjacent-only: 222111110000. (no official key was published)

For arbitrary swaps, choose [1,1,1,1 | 0,0,2,2,2 | 0,0,1], with target-zone lengths 4,5,3. The counts are four 0s, five 1s, three 2s. Number positions 1 through 12. One seven-swap sorting sequence is (1,5),(2,6),(7,12),(3,10),(8,10),(4,11),(9,11). After the first three swaps, the unsorted portion consists of two cycles, each carrying a 1 in the 0-zone, a 2 in the 1-zone and a 0 in the 2-zone. Each takes two swaps. All 12 entries were initially misplaced, so six swaps would require every swap to fix two errors. Only three opposite pairs are available, and a residual 3-cycle cannot be fixed in that way. Thus seven are necessary as well as sufficient; the general upper bound is proved in part(a).
For adjacent-only swaps, choose [2,2,2,1,1,1,1,1,0,0,0,0]. It has 3*5 inversions of type(2,1), 3*4 of type(2,0), and 5*4 of type(1,0), for 47. No array with these multiplicities can have more inversions, because every unequal pair is already inverted here. An adjacent inversion-removal sort takes exactly 47 swaps. This descending arrangement is not the arbitrary-swap witness: allowing distant exchanges changes the optimization problem.

Original paper, page 9

Descriptive
Report issue

Trace static scope and value parameters

Scope, Lifetime & Storage Classes

Question 18(a), GATE 2000: Pseudo-Pascal: global x; Q(z) does z:=z+x; writeln(z). P(y) declares local x, does x:=y+2; Q(x); writeln(x). Main does x:=5; P(x); Q(x); writeln(x). Q and P are siblings declared in main. Find output under call-by-value and static scoping.
Question 18(a), GATE 2000: Pseudo-Pascal: global x; Q(z) does z:=z+x; writeln(z). P(y) declares local x, does x:=y+2; Q(x); writeln(x). Main does x:=5; P(x); Q(x); writeln(x). Q and P are siblings declared in main. Find output under call-by-value and static scoping.
Tap to enlarge
Answer & solution

Answer: 12 7 10 5 (no official key was published)

Main sets global x=5. P receives a separate value parameter y=5 and sets its local x=y+2=7. P calls Q(x), so Q receives a separate z=7. Static scoping resolves Q’s free x through its lexical declaration environment, main, not through the caller P: that x is the global 5. Therefore Q sets its own z=7+5=12 and prints 12. Because z was passed by value, P’s local x remains 7, so P next prints 7. Returning to main leaves global x=5. Main’s Q(x) receives z=5 and uses global x=5, so it prints 10; this changes only z. Finally main prints global x=5. The four outputs, one per writeln, are 12,7,10,5. Do not let P’s local x affect a statically scoped sibling procedure.

Original paper, page 9

Descriptive
Report issue

Trace dynamic scope and reference parameters

Scope, Lifetime & Storage Classes

Question 18(b), GATE 2000: Pseudo-Pascal: global x; Q(z) does z:=z+x; writeln(z). P(y) declares local x, does x:=y+2; Q(x); writeln(x). Main does x:=5; P(x); Q(x); writeln(x). Q and P are siblings declared in main. Find output under call-by-reference and dynamic scoping.
Question 18(b), GATE 2000: Pseudo-Pascal: global x; Q(z) does z:=z+x; writeln(z). P(y) declares local x, does x:=y+2; Q(x); writeln(x). Main does x:=5; P(x); Q(x); writeln(x). Q and P are siblings declared in main. Find output under call-by-reference and dynamic scoping.
Tap to enlarge
Answer & solution

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

Main’s x starts at 5. In P(x), y aliases main’s x, but P also owns a distinct local x. It reads y=5 and assigns local x=7. Q(x) is then called with a reference to that local x, so z aliases P.x. Under dynamic scoping, Q’s free x resolves to the nearest active caller with an x, also P.x. The assignment z:=z+x therefore reads 7+7 and writes 14 into P.x. Q prints 14, and P’s next writeln(x) prints the same 14. Main’s global x is still 5 because neither assignment changed y or main.x. After P returns, main calls Q(x); now both reference parameter z and dynamically resolved x refer to main.x. Their old values are 5, so the assignment writes 10 into main.x. Q prints 10 and main’s final writeln(x) also prints 10. Aliasing and name resolution are separate steps: first identify each referenced storage cell, then evaluate the addition using its pre-assignment value.

Original paper, page 9

Descriptive
Report issue

Parse unusual arithmetic precedence

Parsing & Syntax Analysis

Question 19(a), GATE 2000: Grammar/SDTS: E→E1*T {E.val=E1.val*T.val}; E→T {E.val=T.val}; T→F−T1 {T.val=F.val−T1.val}; T→F {T.val=F.val}; F→2 {F.val=2}; F→4 {F.val=4}. Attributes are evaluated immediately after bottom-up reductions. Construct the parse tree for 4−2−4*2 and evaluate it.
Question 19(a), GATE 2000: Grammar/SDTS: E→E1*T {E.val=E1.val*T.val}; E→T {E.val=T.val}; T→F−T1 {T.val=F.val−T1.val}; T→F {T.val=F.val}; F→2 {F.val=2}; F→4 {F.val=4}. Attributes are evaluated immediately after bottom-up reductions. Construct the parse tree for 4−2−4*2 and evaluate it.
Tap to enlarge
Answer & solution

Answer: (4−(2−4))*2 = 12 (no official key was published)

Step through it (19 steps)

The grammar makes subtraction part of T and multiplication part of E. Thus subtraction binds more tightly than multiplication. Moreover T→F−T is right-recursive, so the subtraction chain groups to the right, not to the left. The annotated parse tree is:

E[12]
├── E[6]
│   └── T[6]
│       ├── F[4] → 4
│       ├── −
│       └── T[−2]
│           ├── F[2] → 2
│           ├── −
│           └── T[4]
│               └── F[4] → 4
├── *
└── T[2]
    └── F[2] → 2

Its left-to-right terminal yield is exactly 4−2−4*2. Bottom-up, the innermost T has value 4; its parent computes 2−4=−2; the next T computes 4−(−2)=6. E→T copies 6. The final right T has value 2, so the root computes 6*2=12. Ordinary arithmetic precedence would give a different result; here the supplied grammar, not familiar operator conventions, defines the grouping.

Original paper, page 9

Descriptive
Report issue

Synthesize reduction-count attributes

Semantic Analysis & Type Checking

Question 19(b), GATE 2000: Grammar/SDTS: E→E1*T {E.val=E1.val*T.val}; E→T {E.val=T.val}; T→F−T1 {T.val=F.val−T1.val}; T→F {T.val=F.val}; F→2 {F.val=2}; F→4 {F.val=4}. Attributes are evaluated immediately after bottom-up reductions. Add synthesized attributes to compute E.red, the total reductions without changing the grammar.
Question 19(b), GATE 2000: Grammar/SDTS: E→E1*T {E.val=E1.val*T.val}; E→T {E.val=T.val}; T→F−T1 {T.val=F.val−T1.val}; T→F {T.val=F.val}; F→2 {F.val=2}; F→4 {F.val=4}. Attributes are evaluated immediately after bottom-up reductions. Add synthesized attributes to compute E.red, the total reductions without changing the grammar.
Question 19(b), GATE 2000: Grammar/SDTS: E→E1*T {E.val=E1.val*T.val}; E→T {E.val=T.val}; T→F−T1 {T.val=F.val−T1.val}; T→F {T.val=F.val}; F→2 {F.val=2}; F→4 {F.val=4}. Attributes are evaluated immediately after bottom-up reductions. Add synthesized attributes to compute E.red, the total reductions without changing the grammar.
Tap to enlarge
Answer & solution

Answer: Each production adds 1 to the sum of its nonterminal children’s red attributes; the given input has E.red=10. (no official key was published)

Every nonterminal node in a parse tree represents one use of a grammar production, hence one reduction in a bottom-up parse. A terminal contributes no reduction by itself; F→2 or F→4 contributes one. Preserve all original val actions and append:

E → E1 * T : E.red = E1.red + T.red + 1
E → T      : E.red = T.red + 1
T → F − T1 : T.red = F.red + T1.red + 1
T → F      : T.red = F.red + 1
F → 2      : F.red = 1
F → 4      : F.red = 1

These are synthesized because each left-hand attribute depends only on child attributes. No global counter or inherited attribute is needed. In 4−2−4*2, there are four F reductions, four T reductions (two T→F and two T→F−T), and two E reductions (E→T and E→E*T), totaling 10. One bottom-up production sequence is F→4, F→2, F→4, T→F, T→F−T, T→F−T, E→T, F→2, T→F, E→E*T, understood as reductions from right-hand sides to left-hand sides. Parser accept is not an additional grammar reduction, and any augmented start rule is outside the question’s requested reduction to E.

Original paper, page 9

Descriptive
Report issue

Complete readers-writers entry protocol

Synchronization & Concurrency

Question 20(a), GATE 2000: R=W=0, binary semaphore mutex=1. Reader acquires mutex, and if W==0 increments R then executes box 1; otherwise executes box 2 and retries. After reading it acquires mutex, decrements R and releases mutex. Writer acquires mutex; if box 3 is true it releases mutex and retries; otherwise it sets W=1, releases mutex, writes, then acquires mutex, sets W=0 and releases mutex. Fill boxes 1,2,3.
Question 20(a), GATE 2000: R=W=0, binary semaphore mutex=1. Reader acquires mutex, and if W==0 increments R then executes box 1; otherwise executes box 2 and retries. After reading it acquires mutex, decrements R and releases mutex. Writer acquires mutex; if box 3 is true it releases mutex and retries; otherwise it sets W=1, releases mutex, writes, then acquires mutex, sets W=0 and releases mutex. Fill boxes 1,2,3.
Tap to enlarge
Answer & solution

Answer: (1) signal(mutex); (2) signal(mutex); (3) R>0 || W!=0. (no official key was published)

The complete intended protocol is:
Reader() {
L1: wait(mutex);
  if (W == 0) {
    R = R + 1;
    signal(mutex);                 // box 1
  } else {
    signal(mutex);                 // box 2
    goto L1;
  }
  /* read shared data */
  wait(mutex);
  R = R - 1;
  signal(mutex);
}
Writer() {
L2: wait(mutex);
  if (R > 0 || W != 0) {           // box 3
    signal(mutex);
    goto L2;
  }
  W = 1;
  signal(mutex);
  /* write shared data */
  wait(mutex);
  W = 0;
  signal(mutex);
}

wait/signal must implement a genuine atomic binary semaphore with appropriate memory visibility. Merely reading and writing an ordinary flag is not a substitute. All tests and updates of R,W occur under mutex, so checking admission and registering the admitted reader/writer are atomic relative to competitors. A writer enters only when no reader and no writer is active, and W=1 prevents later admissions until it finishes. Multiple readers are allowed while W=0. Both reader branches must release mutex; retaining it would block exits or retries and can deadlock. The mutex protects admission bookkeeping, not the whole read/write operation; R and W reserve access while mutex is released. Safety holds, but fairness is not guaranteed.

Original paper, page 10

Descriptive
Report issue

Demonstrate writer starvation

Synchronization & Concurrency

Question 20(b), GATE 2000: R=W=0, binary semaphore mutex=1. Reader acquires mutex, and if W==0 increments R then executes box 1; otherwise executes box 2 and retries. After reading it acquires mutex, decrements R and releases mutex. Writer acquires mutex; if box 3 is true it releases mutex and retries; otherwise it sets W=1, releases mutex, writes, then acquires mutex, sets W=0 and releases mutex. With correct boxes, can writers starve?
Question 20(b), GATE 2000: R=W=0, binary semaphore mutex=1. Reader acquires mutex, and if W==0 increments R then executes box 1; otherwise executes box 2 and retries. After reading it acquires mutex, decrements R and releases mutex. Writer acquires mutex; if box 3 is true it releases mutex and retries; otherwise it sets W=1, releases mutex, writes, then acquires mutex, sets W=0 and releases mutex. With correct boxes, can writers starve?
Question 20(b), GATE 2000: R=W=0, binary semaphore mutex=1. Reader acquires mutex, and if W==0 increments R then executes box 1; otherwise executes box 2 and retries. After reading it acquires mutex, decrements R and releases mutex. Writer acquires mutex; if box 3 is true it releases mutex and retries; otherwise it sets W=1, releases mutex, writes, then acquires mutex, sets W=0 and releases mutex. With correct boxes, can writers starve?
Tap to enlarge
Answer & solution

Answer: Yes. Waiting writers do not prevent new readers from entering. (no official key was published)

Consider two streams of readers whose reading intervals overlap. Before the last current reader exits, a new reader acquires mutex, observes W=0, increments R and begins reading. Arrange this repeatedly so R never becomes 0. A waiting writer may acquire mutex infinitely often, but each time it finds R>0, releases mutex and retries. It therefore never reaches W=1, even though every individual read finishes. A pending writer is not recorded anywhere: W means an active writer, not a waiting writer. Consequently new readers remain admissible throughout this schedule. This is starvation, not deadlock, since readers keep making progress. Even fairness in acquiring the bookkeeping semaphore would not repair this example because the writer gets turns and still cannot enter. Avoiding it requires a different admission policy, for example recording waiting writers and refusing new readers while a writer waits, together with suitable queue fairness; that change is outside the requested three boxes.

Original paper, page 10

Descriptive
Report issue

Draw B-plus tree after six inserts

Indexing, Storage & Query Processing

Question 21(a)(i), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 6, without intermediate diagrams.
Question 21(a)(i), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 6, without intermediate diagrams.
Question 21(a)(i), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 6, without intermediate diagrams.
Tap to enlarge
Answer & solution

Answer: Root [4]; linked leaves [1,2,3] → [4,5,6]. (no official key was published)

The requested final tree is:
             [4]
            /   ╲
     [1 2 3] → [4 5 6]

The first five keys fit in the single root-leaf. Inserting 6 overflows its capacity to six keys, so divide its sorted entries evenly into [1,2,3] and [4,5,6]. Create an internal root with separator 4, the minimum of the right child. A search for a key below 4 chooses the left child and a search for 4 or greater chooses the right. Because this is a B+-tree, copying 4 to the parent does not remove 4 from the leaf. The arrow denotes the leaf-level successor link. The stem does not define its separator convention; a max-left convention can instead display root[3] with the same leaves. Here and in subsequent parts the minimum-of-right convention is fixed explicitly.

Original paper, page 10

Descriptive
Report issue

Draw B-plus tree after ten inserts

Indexing, Storage & Query Processing

Question 21(a)(ii), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 10, without intermediate diagrams.
Question 21(a)(ii), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 10, without intermediate diagrams.
Question 21(a)(ii), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 10, without intermediate diagrams.
Tap to enlarge
Answer & solution

Answer: Root [4,7]; linked leaves [1,2,3] → [4,5,6] → [7,8,9,10]. (no official key was published)

The requested tree is:
                  [4 | 7]
                /    |    ╲
       [1 2 3] → [4 5 6] → [7 8 9 10]

After the first split, increasing keys always enter the rightmost leaf. That leaf fills with 4,5,6,7,8 and overflows on 9. Splitting its six keys yields [4,5,6] and [7,8,9]; copy 7 into the existing root. The root now has two separators and three child pointers, well within its five-key capacity, so it does not split. Insert 10 into the rightmost leaf to get [7,8,9,10]. The first leaf remains [1,2,3]. Separators4 and 7 remain present in their respective data leaves. Under a max-left separator convention the same leaf layout can be shown with root[3,6]; the answer above uses the stated minimum-of-right convention throughout.

Original paper, page 10

Descriptive
Report issue

Redistribute before splitting B-plus leaves

Indexing, Storage & Query Processing

Question 21(b), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Modify insertion: before splitting an overflowing/full target, move one value to its left sibling if that sibling exists and has room; otherwise split. Show the tree after inserting 1 through 9.
Question 21(b), GATE 2000: An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Modify insertion: before splitting an overflowing/full target, move one value to its left sibling if that sibling exists and has room; otherwise split. Show the tree after inserting 1 through 9.
Tap to enlarge
Answer & solution

Answer: Root [5]; leaves [1,2,3,4] → [5,6,7,8,9]. (no official key was published)

The final tree under the stated overflow-split convention is:

                 [5]
                /   ╲
      [1 2 3 4] → [5 6 7 8 9]

At the first overflow there is no left sibling, so the first six keys split as usual into [1,2,3] and [4,5,6]. Increasing insertions fill the right leaf through 8. To accommodate 9, that target leaf would contain [4,5,6,7,8,9], but the left sibling has spare capacity. Move its smallest key4 to the left sibling, and keep [5,6,7,8,9] on the right. Moving the smallest, rather than the largest, preserves the global leaf ordering. Update the parent separator from 4 to 5 because the right leaf’s minimum changed. No new leaf is needed. Equivalently one can redistribute4 just before inserting 9 into the full right leaf. Do not split again merely because the right leaf has five entries: five is its legal maximum; the sixth causes overflow. Separator conventions and split timing must be consistent with part(a).

Original paper, page 10

Descriptive
Report issue

Estimate sorted-insertion leaf occupancy

Indexing, Storage & Query Processing

Question 21(c)(i), GATE 2000: A B+-tree leaf holds at most m keys. Insert a long increasing sequence using ordinary balanced splits on overflow. What is the approximate average number of keys per leaf?
Question 21(c)(i), GATE 2000: A B+-tree leaf holds at most m keys. Insert a long increasing sequence using ordinary balanced splits on overflow. What is the approximate average number of keys per leaf?
Question 21(c)(i), GATE 2000: A B+-tree leaf holds at most m keys. Insert a long increasing sequence using ordinary balanced splits on overflow. What is the approximate average number of keys per leaf?
Tap to enlarge
Answer & solution

Answer: Approximately m/2; more precisely the frozen left split size, usually floor((m+1)/2), up to rounding and a boundary leaf. (no official key was published)

All new larger keys enter the rightmost leaf. When it overflows with m+1 keys, a balanced split leaves about half in the old left leaf and half in a new rightmost leaf. The old left leaf will never receive another key during an increasing insertion sequence. Repeating this process freezes nearly every completed leaf at its half-full split occupancy. Only the final rightmost leaf varies between its initial split size and m, and its contribution to the average vanishes as the number of leaves grows. Therefore the average is approximately m/2, not the roughly 69% occupancy sometimes quoted for random insertions. If the convention gives the left leaf floor((m+1)/2) keys, the limiting average is that integer. For m=5 and a3+3 split this is exactly 3 in the limit. Rounding and the choice of which side gets an extra key for even m explain why the question asks approximately.

Original paper, page 10

Descriptive
Report issue

Estimate occupancy with left redistribution

Indexing, Storage & Query Processing

Question 21(c)(ii), GATE 2000: A B+-tree leaf holds at most m keys. Insert a long increasing sequence, moving a key to the left sibling before splitting whenever that sibling has room. Estimate average leaf occupancy.
Question 21(c)(ii), GATE 2000: A B+-tree leaf holds at most m keys. Insert a long increasing sequence, moving a key to the left sibling before splitting whenever that sibling has room. Estimate average leaf occupancy.
Question 21(c)(ii), GATE 2000: A B+-tree leaf holds at most m keys. Insert a long increasing sequence, moving a key to the left sibling before splitting whenever that sibling has room. Estimate average leaf occupancy.
Question 21(c)(ii), GATE 2000: A B+-tree leaf holds at most m keys. Insert a long increasing sequence, moving a key to the left sibling before splitting whenever that sibling has room. Estimate average leaf occupancy.
Tap to enlarge
Answer & solution

Answer: Approximately m keys per leaf, approaching full occupancy. (no official key was published)

New keys continue to enter the rightmost leaf. Whenever it overflows, move its smallest key into its left sibling if possible. Repeated overflows progressively fill that left sibling to m entries. Only once that sibling is full must the rightmost leaf split; at that moment the earlier leaves are already full and will receive no more keys. After a split the two rightmost leaves can be partly full, but later insertions fill the older of them by redistribution. Consequently all except at most the final two leaves are full. If there are L leaves, their combined deficit from Lm keys is O(m), independent of L, so average occupancy is m−O(m/L) and tends to m as L grows. This is the improvement over ordinary splitting’s approximately half-full completed leaves for monotone input. Parent separator updates are essential for correctness but do not change the leaf occupancy calculation.

Original paper, page 10

Descriptive
Report issue

Define transaction-prefix SQL view

SQL & Queries

Question 22(a), GATE 2000: Bank relation transaction(transno,acctno,date,amount) stores positive deposits and negative withdrawals. TP must contain (acctno,T1.date,T2.amount) for every pair of transactions on the same account with T2.date<=T1.date. Define TP in SQL.
Question 22(a), GATE 2000: Bank relation transaction(transno,acctno,date,amount) stores positive deposits and negative withdrawals. TP must contain (acctno,T1.date,T2.amount) for every pair of transactions on the same account with T2.date<=T1.date. Define TP in SQL.
Tap to enlarge
Answer & solution

Answer: Self-join by equal account and T2.date<=T1.date, without DISTINCT. (no official key was published)

One SQL definition is

CREATE VIEW TP (acctno, txn_date, amount) AS
SELECT T1.acctno, T1.date, T2.amount
FROM transaction AS T1
JOIN transaction AS T2
  ON T1.acctno = T2.acctno
 AND T2.date <= T1.date;

Here T1 chooses a balance-observation date and T2 chooses one transaction contributing to that balance. Include equality so the transaction on the observation date contributes; using < would produce the balance before, rather than after, that transaction and omit the first date’s self-pair. Each qualifying transaction pair contributes a row. Do not add DISTINCT: SQL’s bag semantics deliberately preserve separate same-amount transactions even though the projected triples may be identical. For example two deposits of 100 on different days generate two copies of (account,later_date,100), both of which must be summed. transaction and date can be reserved identifiers in some SQL dialects; quote the existing identifiers with that dialect’s supported delimiters if needed.

Original paper, page 10

Descriptive
Report issue

Find minimum historical account balances

SQL & Queries

Question 22(b), GATE 2000: Bank relation transaction(transno,acctno,date,amount) stores positive deposits and negative withdrawals. TP must contain (acctno,T1.date,T2.amount) for every pair of transactions on the same account with T2.date<=T1.date. Using only TP, create intermediate view V and query each account’s minimum balance after a transaction, excluding the initial zero. At most one transaction per account per day; each account has at least one transaction.
Question 22(b), GATE 2000: Bank relation transaction(transno,acctno,date,amount) stores positive deposits and negative withdrawals. TP must contain (acctno,T1.date,T2.amount) for every pair of transactions on the same account with T2.date<=T1.date. Using only TP, create intermediate view V and query each account’s minimum balance after a transaction, excluding the initial zero. At most one transaction per account per day; each account has at least one transaction.
Question 22(b), GATE 2000: Bank relation transaction(transno,acctno,date,amount) stores positive deposits and negative withdrawals. TP must contain (acctno,T1.date,T2.amount) for every pair of transactions on the same account with T2.date<=T1.date. Using only TP, create intermediate view V and query each account’s minimum balance after a transaction, excluding the initial zero. At most one transaction per account per day; each account has at least one transaction.
Tap to enlarge
Answer & solution

Answer: V sums amounts by account and observation date; final query takes MIN(balance) by account. (no official key was published)

Use two aggregation levels:
CREATE VIEW V (acctno, txn_date, balance) AS
SELECT acctno, txn_date, SUM(amount)
FROM TP
GROUP BY acctno, txn_date;

SELECT acctno, MIN(balance) AS minbalance
FROM V
GROUP BY acctno;
For a fixed account and T1 date, TP has one amount row for every transaction up to and including that date. SUM therefore gives the cumulative balance immediately after the transaction, assuming the opening balance is zero as specified. The one-transaction-per-account-per-day condition ensures each observation date has one T1 row, avoiding repeated copies of the entire prefix caused by multiple T1 transactions on the same day. Taking MIN over these cumulative balances returns the lowest post-transaction balance, including negative balances when appropriate. There is no row for account creation, so the initial zero is not accidentally included; a positive-only account correctly returns its first positive balance rather than zero. An account with amounts 100,100,−250 has balances 100,200,−50 and minimum−50. DISTINCT in TP would collapse the two 100 entries at the later dates and corrupt these sums. Distinct dates, not distinct amounts, define observation groups. Non-null numeric amounts and a comparable chronological date type are implicit in the bank model.

Original paper, page 10