GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 2008

85 questions

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

03:00:00
1 mark · MCQ
Report issue

Limit with bounded trigonometric terms

Calculus

Question 1, GATE 2008: Evaluate lim(x→∞) (x−sin x)/(x+cos x).

(A) 1
(B) −1
(C) ∞
(D) −∞
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Divide both terms by x, obtaining (1−sin(x)/x)/(1+cos(x)/x).
2. Since |sin x|≤1 and |cos x|≤1, both divided trigonometric terms tend to zero by squeezing.
3. The denominator tends to 1, not zero, so the quotient limit is 1: A.

Original paper, page 2

1 mark · MCQ
Report issue

Set expression covers the universe

Sets, Relations & Functions

Question 2, GATE 2008: For subsets P,Q,R of universe U, simplify (P∩Q∩R)∪(Pᶜ∩Q∩R)∪Qᶜ∪Rᶜ.

(A) Qᶜ∪Rᶜ
(B) P∪Qᶜ∪Rᶜ
(C) Pᶜ∪Qᶜ∪Rᶜ
(D) U
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Distribute the common intersection: (P∩Q∩R)∪(Pᶜ∩Q∩R)=(P∪Pᶜ)∩Q∩R=Q∩R.
2. De Morgan gives Qᶜ∪Rᶜ=(Q∩R)ᶜ.
3. A set union its complement is U, giving D. The result is independent of P.

Original paper, page 2

1 mark · MCQ
Report issue

Parameter for a unique linear-system solution

Linear Algebra

Question 3, GATE 2008: The equations x₁+x₂+2x₃=1, x₁+2x₂+3x₃=2, x₁+4x₂+αx₃=4 have a unique solution. The only possible value(s) of α is/are:

(A) 0
(B) Either 0 or 1
(C) One of 0,1,−1
(D) Any real number
Tap to enlarge
Your answer
Answer & solution

Answer: All real α except 5; no exact listed option (no official key was published)

1. Subtract the first equation from the second and third. The remaining coefficient rows are(0,1,1) and(0,3,α−2), so the determinant is α−5.
2. A unique solution exists exactly when α≠5. At α=5 the third reduced equation is three times the second, including its right side, so solutions are nonunique.
3. None of the printed choices gives the exhaustive set R minus{5}:0,1,−1 all work but are not the only possibilities, while any real number incorrectly includes 5. No official key has been located; this is a source/options discrepancy, not a claimed official-key correction.

Original paper, page 2

1 mark · MCQ
Report issue

All-zero IEEE binary32 encoding

Number Systems & Computer Arithmetic

Question 4, GATE 2008: In IEEE floating-point representation, what does hexadecimal 0x00000000 represent?

(A) Normalized value 2^(−127)
(B) Normalized value 2^(−126)
(C) Normalized value +0
(D) Special value +0
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (6 steps)

1. Split binary32 into sign, exponent and fraction fields. Every field is zero here.
2. An all-zero exponent is reserved for zero/subnormal encodings, so the normalized-number formula with an implicit leading 1 does not apply.
3. The zero fraction makes the magnitude zero; sign bit 0 makes it +0. This is the special value in D.

Original paper, page 2

1 mark · MCQ
Report issue

K-map minimum using dont-cares

Logic Minimization & Karnaugh Maps

Question 5, GATE 2008: Minimize the Karnaugh map. Columns ab are 00,01,11,10; rows cd are 00,01,11,10. Rows of cell values are [1,1,0,1], [X,0,0,0], [X,0,0,0], [1,1,0,X]. X is a don’t-care; blank source cells are zero. Prime denotes complement.

(A) b′d′+a′d′
(B) a′b′+b′d′+a′bd′
(C) b′d′+a′bd′
(D) a′b′+b′d′+a′d′
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (11 steps)

1. Treat the map edges as adjacent. The four corners form a legal group by using the bottom-right don’t-care; b and d are zero throughout, giving b′d′.
2. Group the cells in the top and bottom rows of the left two columns. Here a=d=0, giving a′d′.
3. The union covers every specified 1 without any specified 0, so f=b′d′+a′d′, A. One implicant cannot cover both required ab=01 and ab=10 regions without including a forbidden ab=11 cell, so two terms are needed.

Original paper, page 2

1 mark · MCQ
Report issue

Radix-independent square identity

Number Systems & Computer Arithmetic

Question 6, GATE 2008: For radix r, which r satisfy √(121ᵣ)=11ᵣ?

(A) Decimal 10
(B) Decimal 11
(C) Decimal 10 and 11
(D) Any valid radix greater than 2
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Interpret the digits by place value: 121ᵣ=r²+2r+1=(r+1)², while 11ᵣ=r+1.
2. The positive square root is r+1 for every positive radix.
3. Digit 2 is valid only when the integer radix exceeds 2. Hence all valid r>2 satisfy the equation, D; there is nothing special about decimal 10 or 11.

Original paper, page 2

1 mark · MCQ
Report issue

Counting graph connected components

Graph Algorithms

Question 7, GATE 2008: What is the most efficient time complexity to count connected components in an undirected graph with n vertices and m edges?

(A) Θ(n)
(B) Θ(m)
(C) Θ(m+n)
(D) Θ(mn)
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Maintain a visited flag for each vertex. Start a BFS/DFS at every vertex not yet visited and increment a component counter.
2. Each search visits precisely one previously unvisited component. Across all searches each vertex is processed once and each undirected edge twice.
3. With adjacency lists the total is Θ(n+m), C. The n term includes isolated vertices; an adjacency-matrix representation instead requires Θ(n²).

Original paper, page 2

1 mark · MCQ
Report issue

Compatible minterms of an internal signal

Boolean Algebra & Logic Gates

Question 8, GATE 2008: An AND gate combines f₁ and f₂, and its output is ORed with f₃ to produce f. Given f₁=Σm(4,5,6,7,8), f₃=Σm(1,6,15), f=Σm(1,6,8,15), which offered f₂ works?

(A) Σm(4,6)
(B) Σm(4,8)
(C) Σm(6,8)
(D) Σm(4,6,8)
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The circuit computes f=(f1∧f2)∨f3. Minterm8 must be supplied through f1f2, while 4,5,7 must not be introduced.
2. Of the options, only f2=Σm(6,8) meets these conditions, giving final set{1,6,8,15}, C. The internal function is not uniquely determined over all possible minterms: values outside f1’s support are irrelevant and minterm 6 is already covered by f3.
3. C is the unique compatible supplied choice.

Original paper, page 3

1 mark · MCQ
Report issue

Unary prime-length language

Context-Free Grammars & Languages

Question 9, GATE 2008: Which statement holds for {a^p | p is prime}?

(A) Not accepted by a Turing machine
(B) Regular but not context-free
(C) Context-free but not regular
(D) Neither regular nor context-free, but accepted by a Turing machine
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Primality of the input length is decidable, so a Turing machine accepts the language. It is not regular: if a pumping length is p, choose prime q>p; a pumpable nonempty segment has length d≤p, and pumping it q+1 times changes length to q+qd=q(1+d), composite.
2. Every unary context-free language is regular (its length set is ultimately periodic/semilinear), so this language is not context-free either. Therefore D.

Original paper, page 3

1 mark · MCQ
Report issue

Decidability questions about automata and grammar

Decidability & Computability

Question 10, GATE 2008: Which are decidable? I: whether the intersection of two regular languages is infinite. II: whether a given context-free language is regular. III: whether two pushdown automata accept the same language. IV: whether a given grammar is context-free.

(A) I and II
(B) I and IV
(C) II and III
(D) II and IV
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. For I, construct a product DFA for the intersection and test whether a reachable cycle can reach an accepting state; this decides infinitude. IV is a syntactic check of the grammar’s productions: every left side must be a single nonterminal.
2. Regularity of an arbitrary CFL and equivalence of arbitrary nondeterministic PDAs are undecidable. Thus I and IV, B.
3. IV asks whether the presented grammar is context-free in form, not whether an arbitrary grammar’s language happens to be a CFL.

Original paper, page 3

1 mark · MCQ
Report issue

Handle in LR parsing

Parsing & Syntax Analysis

Question 11, GATE 2008: Which describes a handle in LR parsing?

(A) A position in a sentential form for the next shift or reduce operation
(B) A nonterminal whose production is used for the next reduction
(C) A production possibly used for a future reduction and the position of the next shift or reduce operation
(D) The production used in the next reduction and the position of its right-hand side in the sentential form
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Bottom-up LR parsing reverses a rightmost derivation: it replaces a production’s right-hand side by its left-hand-side nonterminal.
2. A handle must specify both which production to reduce and which occurrence of its right-hand side is the correct next one. Merely naming a position or a nonterminal is insufficient.
3. D gives exactly this production-and-position pair. A possible future reduction, as in C, is not necessarily the next handle.

Original paper, page 3

1 mark · MCQ
Report issue

Intermediate-code optimization portability

Code Optimization & Data-Flow Analysis

Question 12, GATE 2008: Why are some code optimizations performed on intermediate code?

(A) They enhance compiler portability to other target processors
(B) Program analysis is more accurate on intermediate code than machine code
(C) Dataflow-analysis information cannot otherwise be used for optimization
(D) Front-end information cannot otherwise be used for optimization
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Intermediate code abstracts away many machine-specific details, allowing one optimization pass to serve several target back ends.
2. This reuse makes it easier to retarget the compiler, which is the portability benefit in A.
3. B claims a universal analysis-accuracy advantage that does not follow. C and D incorrectly say dataflow/front-end information cannot otherwise be used; such information can also inform other compilation stages.

Original paper, page 3

1 mark · MCQ
Report issue

Recognizable language and recognizable complement

Decidability & Computability

Question 13, GATE 2008: If both L and its complement are recursively enumerable, L is necessarily:

(A) Regular
(B) Context-free
(C) Context-sensitive
(D) Recursive
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Run recognizers for L and its complement in dovetailing fashion, alternating simulation steps so neither can prevent the other from progressing.
2. Every input lies in exactly one of the two languages, so exactly one recognizer eventually accepts. Accept if it is the L recognizer and reject otherwise.
3. This constructed decider halts on every input, making L recursive, D. Nothing here guarantees regularity, context-freeness or a linear-space bound.

Original paper, page 3

1 mark · MCQ
Report issue

Application data size passed to TCP

Transport, Congestion Control & Traffic Shaping

Question 14, GATE 2008: What is the maximum size of data the application layer can pass to TCP?

(A) Any size
(B) 2^16 bytes minus TCP-header size
(C) 2^16 bytes
(D) 1500 bytes
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. TCP offers applications an ordered byte stream, rather than one application-message-per-packet service.
2. TCP divides that stream into segments; IP and link-layer limits constrain individual packets/frames, not the total stream length.
3. Thus neither 1500 nor 216 bytes is a maximum application stream size. A is intended. Real API calls may still impose implementation-specific buffer limits.

Original paper, page 4

1 mark · MCQ
Report issue

Universal relational-calculus condition

Relational Algebra & Calculus

Question 15, GATE 2008: Which tuple-calculus expressions equal ∀t∈r P(t)? I: ¬∃t∈r P(t). II: ∃t∉r P(t). III: ¬∃t∈r ¬P(t). IV: ∃t∉r ¬P(t).

(A) I only
(B) II only
(C) III only
(D) III and IV only
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. A universal statement fails exactly when there is a counterexample. Here a counterexample is a tuple t in r for which P(t) is false.
2. Excluding every such counterexample gives ¬∃t∈r ¬P(t), which is III.
3. I instead says no tuple satisfies P; II and IV discuss tuples outside r. Therefore III only, C.

Original paper, page 4

1 mark · MCQ
Report issue

Classical clustering-index classification

Indexing, Storage & Query Processing

Question 16, GATE 2008: A clustering index is defined on fields of which type?

(A) Non-key and ordering
(B) Non-key and non-ordering
(C) Key and ordering
(D) Key and non-ordering
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. An ordering field determines the physical ordering of the data file.
2. If that field is non-key, multiple records can share a value and form a contiguous cluster, indexed by a clustering-index entry.
3. This classical classification gives A. An ordering key instead gives a primary index; a non-ordering field gives a secondary index. Modern clustered-index terminology can be broader.

Original paper, page 4

1 mark · MCQ
Report issue

Socket operation initiating TCP handshake

Transport, Congestion Control & Traffic Shaping

Question 17, GATE 2008: Which system call results in sending SYN packets?

(A) socket
(B) bind
(C) listen
(D) connect
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. socket creates a socket, bind assigns a local endpoint, and listen makes a TCP socket passive.
2. connect initiates the active TCP open, starting the three-way handshake by sending SYN.
3. The requested call is therefore D. This reasoning is specifically for TCP; UDP connect does not initiate a TCP handshake.

Original paper, page 4

1 mark · MCQ
Report issue

Nested conditional computes the maximum

Expressions, Operators & Types

Question 18, GATE 2008: Which (x,y,z) makes a=4 in the C expression a=(x>y)?((x>z)?x:z):((y>z)?y:z)?

(A) (3,4,2)
(B) (6,5,3)
(C) (6,3,5)
(D) (5,4,5)
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. If x>y, the expression selects the larger of x and z. Otherwise it selects the larger of y and z. Thus a=max(x,y,z).
2. The maxima for A,B,C,D are respectively 4,6,6,5.
3. Only A yields 4. Equality in a comparison does not change the selected maximum value.

Original paper, page 4

1 mark · MCQ
Report issue

Valid queue-based BFS order

Graph Algorithms

Question 19, GATE 2008: An undirected graph has vertices M,N,O,P,Q,R and edges MN,NO,OP,PQ,QM,QN,MR. Which is a possible queue-based breadth-first traversal?

(A) MNOPQR
(B) NQMPOR
(C) QMNPRO
(D) QMNPOR
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step through it (4 options)

1. BFS uses a FIFO queue, so all newly discovered neighbors enter behind previously queued vertices. Start at Q and discover M,N,P in that order.
2. Processing M next discovers R. Processing N then discovers O. Processing P adds nothing because O is already discovered.
3. The dequeue/visit order is Q,M,N,P,R,O, C. D puts O before R despite the specified first-layer order; the other offered orders violate BFS layers.

Original paper, page 4

1 mark · MCQ
Report issue

Large Unix file block allocation

File Systems

Question 20, GATE 2008: How are blocks of a very large file allocated in the Unix file system?

(A) Contiguous allocation
(B) Linked allocation
(C) Indexed allocation
(D) An extension of indexed allocation
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Unix inodes store direct data-block addresses for small files.
2. For larger files, indirect blocks contain further addresses; double and triple indirection extend this hierarchy.
3. This is multilevel indexed allocation, the extension described in D. It neither requires contiguous blocks nor follows a next-block pointer stored in each data block.

Original paper, page 4

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Trapezoidal error bound versus actual minimum

Numerical Methods

Question 21, GATE 2008: What minimum number of equal subintervals is needed to approximate ∫₁² xe^x dx with error at most (1/3)×10^−6 using the trapezoidal rule?

(A) 1000e
(B) 1000
(C) 100e
(D) 100
Tap to enlarge
Your answer
Answer & solution

Answer: A is the conventional sufficient bound; literal minimum is not represented (no official key was published)

1. For f(x)=xex on[1,2], f″(x)=(x+2)ex is increasing, with maximum 4e². The composite trapezoidal bound is |En|≤4e²/(12n²)=e²/(3n²). Requiring this upper bound≤10−6/3 gives n≥1000e, corresponding to A; an integer subdivision count would be ceil(1000e)=2719.
2. This is a sufficient worst-derivative bound, not the exact minimum demanded by the wording. Direct high-precision evaluation gives error 3.33057431918×10−7 at n=2046, already within the tolerance and substantially below 2719. At n=2045 the error is 3.33383240096×10−7.
3. Thus A describes the standard error-bound calculation, not a literal minimal integer answer. No official key is asserted.

Original paper, page 5

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Newton iteration for a square root

Numerical Methods

Question 22, GATE 2008: The Newton–Raphson iteration xₙ₊₁=(xₙ+R/xₙ)/2 computes which quantity?

(A) Square of R
(B) Reciprocal of R
(C) Square root of R
(D) Logarithm of R
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Newton iteration for f(x)=0 is x_next=x−f(x)/f′(x).
2. Set f(x)=x²−R; then f′(x)=2x and x_next=x−(x²−R)/(2x)=(x+R/x)/2.
3. Thus the fixed point satisfies x²=R. For R>0 and positive initial x, it computes the positive square root, C; zero starting values are invalid.

Original paper, page 5

2 marks · MCQ
Report issue

Planar-graph vertex-cover bound

Graph Theory

Question 23, GATE 2008: Which is true for every planar graph on n vertices?

(A) It is connected
(B) It is Eulerian
(C) It has a vertex cover of size at most 3n/4
(D) It has an independent set of size at least n/3
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. By the four-color theorem, a simple loopless planar graph has an independent color class of size at least n/4. Its complement covers every edge and has size at most 3n/4, proving C.
2. A planar graph need not be connected or Eulerian. K4 is planar but has maximum independent-set size 1<4/3, refuting D.
3. The standard loopless graph convention is needed for the coloring argument.

Original paper, page 5

2 marks · MCQ
Report issue

Odd and even integer sums

Proof Techniques & Number Theory

Question 24, GATE 2008: For positive integer k, P is the sum of odd i with 1≤i≤2k, and Q is the sum of even i in the same range. Which relation holds?

(A) P=Q−k
(B) P=Q+k
(C) P=Q
(D) P=Q+2k
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Write the odd terms as 2j−1 and their paired even terms as 2j, for j=1,…,k.
2. Each even term exceeds its odd partner by exactly one, so Q−P=Σ1=k.
3. Rearrange to P=Q−k, A. Equivalently P=k² and Q=k(k+1).

Original paper, page 5

2 marks · MCQ
Report issue

Number of local extrema of a quartic

Calculus

Question 25, GATE 2008: An extremum is a local minimum or maximum. How many distinct extrema does 3x⁴−16x³+24x²+37 have?

(A) 0
(B) 1
(C) 2
(D) 3
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Differentiate: f′(x)=12x³−48x²+48x=12x(x−2)². Stationary points are 0 and 2.
2. The squared factor is nonnegative. The derivative is negative before 0 and positive after 0 except where it vanishes at 2. Hence 0 is a local minimum.
3. At 2 the derivative remains positive on both sides, so there is no extremum there. The count is one, B.

Original paper, page 5

2 marks · MCQ
Report issue

Boolean-product simplification

Boolean Algebra & Logic Gates

Question 26, GATE 2008: Simplify (P+Q′)(PQ′+PR)(P′R′+Q′), where + is Boolean OR and juxtaposition is AND.

(A) PQ′
(B) PR′
(C) PQ′+R
(D) PR′+Q
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (9 steps)

1. Factor the middle term as P(Q′+R), so when P=0 the whole expression is 0.
2. For P=1, the first factor P+Q′ is 1; the middle is Q′+R; the last P′R′+Q′ is Q′.
3. Absorption gives (Q′+R)Q′=Q′. Combining both P cases yields PQ′, A. This checks the full function, not just a selected input.

Original paper, page 5

2 marks · MCQ
Report issue

Two-day subject-transition probability

Probability & Random Variables

Question 27, GATE 2008: Aishwarya studies either CS or mathematics each day. After a CS day, the probability of mathematics next day is 0.6; after a mathematics day, the probability of CS next day is 0.4. Given CS on Monday, what is the probability of CS on Wednesday?

(A) 0.24
(B) 0.36
(C) 0.4
(D) 0.6
Tap to enlarge
Your answer
Answer & solution

Answer: C under the Markov interpretation (no official key was published)

1. Interpret the given next-day probabilities as the transition probabilities of a two-state Markov chain. After CS, the chance of CS is 1−0.6=0.4.
2. Wednesday CS can arise through CS→CS→CS with probability 0.4×0.4=0.16 or CS→Math→CS with probability 0.6×0.4=0.24.
3. These cases are disjoint; add them to get 0.40, C. Without the usual Markov interpretation, unconditional pairwise information alone would not justify the two-step conditional calculation.

Original paper, page 5

2 marks · MCQ
Report issue

Matrices with eigenvalue one

Linear Algebra

Question 28, GATE 2008: How many of these matrices have eigenvalue 1? [[1,0],[0,0]], [[0,1],[0,0]], [[1,−1],[1,1]], [[−1,0],[1,−1]].

(A) One
(B) Two
(C) Three
(D) Four
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. A matrix has eigenvalue 1 exactly when M−I is singular.
2. Subtract the identity from the four matrices and compute their determinants. In order they are 0,1,1,4.
3. Only the first determinant vanishes, giving one matrix, A. The remaining eigenvalues need not be computed.

Original paper, page 5

2 marks · MCQ
Report issue

Matching normal-distribution tails

Probability & Statistics

Question 29, GATE 2008: X is normal with mean +1 and variance 4. Y is normal with mean −1 and unknown variance. If P(X≤−1)=P(Y≥2), what is the standard deviation of Y?

(A) 3
(B) 2
(C) √2
(D) 1
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. X has standard deviation √4=2. Standardization gives P(X≤−1)=Φ((−1−1)/2)=Φ(−1).
2. Write Y’s positive standard deviation as s. Then P(Y≥2)=1−Φ((2+1)/s)=Φ(−3/s), using normal symmetry.
3. Φ is strictly increasing, so equality implies −3/s=−1 and s=3, A. The requested quantity is standard deviation, not variance 9.

Original paper, page 6

2 marks · MCQ
Report issue

Quantifier scope in an FSA-to-PDA statement

Propositional & Predicate Logic

Question 30, GATE 2008: Predicates fsa(x), pda(y), equivalent(a,b) mean finite-state automaton, pushdown automaton and language equivalence respectively. Which printed formula represents “Each finite-state automaton has an equivalent pushdown automaton”? Quantifier scopes below retain the printed parentheses.

(A) (∀x fsa(x)) ⇒ (∃y pda(y)∧equivalent(x,y))
(B) ¬∀y (∃x fsa(x) ⇒ pda(y)∧equivalent(x,y))
(C) ∀x∃y (fsa(x)∧pda(y)∧equivalent(x,y))
(D) ∀x∃y (fsa(y)∧pda(x)∧equivalent(x,y))
Tap to enlarge
Your answer
Answer & solution

Answer: No exact displayed formula under ordinary first-order scope (no official key was published)

1. The intended formula is∀x(fsa(x)→∃y(pda(y)∧equivalent(x,y))). As printed, A puts ∀x only inside its antecedent, leaving the x in equivalent(x,y) free; it also fails to express a separate witness for each FSA. B has the wrong negation and quantifier structure.
2. C asserts that every object is an FSA rather than restricting the implication to FSAs. D likewise asserts every object is a PDA and existentially chooses an FSA, reversing the intended roles. The high-resolution source confirms these displayed forms.
3. A would become the intended answer only after repairing its quantifier scope; no unavailable official key is inferred.

Original paper, page 6

2 marks · MCQ
Report issue

Equivalent propositional disjunctions

Propositional & Predicate Logic

Question 31, GATE 2008: Which propositions are equivalent? I: P∨¬Q. II: ¬(¬P∧Q). III: (P∧Q)∨(P∧¬Q)∨(¬P∧¬Q). IV: (P∧Q)∨(P∧¬Q)∨(¬P∧Q).

(A) I and II only
(B) I,II,III only
(C) I,II,IV only
(D) I,II,III,IV
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. De Morgan converts II to P∨¬Q, exactly I.
2. In III, the first two terms combine to P. Then P∨(¬P∧¬Q)=P∨¬Q by distribution/absorption.
3. In IV, the first two terms again combine to P, but P∨(¬P∧Q)=P∨Q. At P=false,Q=true, this differs from I. Thus exactly I,II,III agree, B.

Original paper, page 6

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Nonlinear disk seek time

Secondary Storage

Question 32, GATE 2008: Why is seek latency not proportional to seek distance on a magnetic disk with concentric circular tracks?

(A) Nonuniform request distribution
(B) Arm starting and stopping inertia
(C) Higher capacity of tracks at platter periphery
(D) Unfair arm-scheduling policies
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. A seek consists of accelerating the arm, moving it and decelerating it to settle accurately at the target track.
2. A short seek may spend most of its time accelerating and braking; a longer seek has a different velocity profile. The average speed is therefore not constant across distances.
3. This is arm starting/stopping inertia, B. Request frequencies and track capacities do not explain the mechanical distance-time relation.

Original paper, page 6

2 marks · MCQ
Report issue

Auto-increment addressing properties

Instructions & Addressing Modes

Question 33, GATE 2008: Which statements about auto-increment addressing are true? I: useful for self-relocating code. II: including it in an ISA requires an additional ALU for effective-address calculation. III: increment amount depends on the accessed data-item size.

(A) I only
(B) II only
(C) III only
(D) II and III only
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Auto-increment addressing uses a register as an operand address and advances it after the access. To point at the next element, the increment must match the item’s byte size: III is true.
2. It does not inherently make code relocation-independent, so I is not a property of this mode.
3. An implementation can reuse existing arithmetic hardware; an additional ALU is not logically required. II is false, leaving C.

Original paper, page 6

2 marks · MCQ
Report issue

Return-from-exception instruction requirements

Instructions & Addressing Modes

Question 34, GATE 2008: Which must be true of RFE (return from exception) on a general-purpose processor? I: it must be a trap instruction. II: it must be privileged. III: no exception can be allowed during its execution.

(A) I only
(B) II only
(C) I and II only
(D) I,II,III
Tap to enlarge
Your answer
Answer & solution

Answer: B in the conventional privileged-return model (no official key was published)

1. RFE restores saved execution/control state and may change privilege, so the conventional architecture restricts its use to privileged code: II. It returns from a trap rather than being required to generate one, so I is false.
2. A processor may define exceptions/faults during a return, for example invalid saved state, so III is not universally required. Therefore B under the conventional model.
3. Architectures can instead permit restricted unprivileged returns that cannot escalate privilege, so the broad must wording is architecture-dependent.

Original paper, page 6

2 marks · MCQ
Report issue

Inclusive multilevel-cache requirements

Cache Memory

Question 35, GATE 2008: Which are necessary for L1/L2 cache inclusion? I: L1 must be write-through. II: L2 must be write-through. III: L2 associativity must exceed L1 associativity. IV: L2 must be at least as large as L1.

(A) IV only
(B) I and IV only
(C) I,II,IV only
(D) I,II,III,IV
Tap to enlarge
Your answer
Answer & solution

Answer: A under full-capacity inclusion convention (no official key was published)

1. For every resident L1 block also to be represented in L2 while L1 can use its full capacity, L2 must be at least as large: IV. Write-back can be compatible with inclusion via appropriate dirty-state and invalidation handling, so I and II are not required.
2. Equal associativity can satisfy inclusion; it need not be strictly greater, so III is false. Hence A under the standard capacity convention.
3. A policy that deliberately underutilizes a larger L1 through back-invalidations could preserve resident-set inclusion with a smaller L2, so IV is not a purely set-theoretic necessity without the full-capacity convention.

Original paper, page 6

2 marks · MCQ
Report issue

False pipeline-hazard claims

Pipelining & Hazards

Question 36, GATE 2008: Which are NOT true in a pipelined processor? I: bypassing handles all RAW hazards. II: register renaming eliminates all register-carried WAR hazards. III: dynamic branch prediction eliminates control-hazard penalties.

(A) I and II only
(B) I and III only
(C) II and III only
(D) I,II,III
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. RAW is a real data dependency. Forwarding helps only once the producer’s value exists; a load-use consumer can still require a stall. I is false.
2. WAR is a false name dependency. Assigning distinct physical registers removes register-carried WAR hazards, so II is true.
3. Dynamic prediction can still choose the wrong branch direction, requiring recovery. III is false. The NOT-true statements are I and III, B.

Original paper, page 7

2 marks · MCQ
Report issue

Benefits of overlapping register windows

Instructions & Addressing Modes

Question 37, GATE 2008: Overlapping multiple register windows reduce memory accesses for which items? I: function locals and parameters. II: register saves and restores. III: instruction fetches.

(A) I only
(B) II only
(C) III only
(D) I,II,III
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. A function’s locals and parameters can stay in its register window instead of memory, reducing I.
2. Overlap exposes caller arguments as callee inputs, and window rotation avoids many explicit saves/restores, reducing II.
3. Eliminating save/restore instructions also removes their instruction fetches, reducing III. Therefore all three are benefits, D. Overflowing the available windows still requires spills, so the reduction is not elimination of all memory traffic.

Original paper, page 7

2 marks · MCQ
Report issue

Earliest conventional data-TLB access

Memory Organization & Address Translation

Question 38, GATE 2008: In an execution pipeline, when can the data TLB be accessed at the earliest?

(A) Before effective-address calculation starts
(B) During effective-address calculation
(C) After effective-address calculation completes
(D) After data-cache lookup completes
Tap to enlarge
Your answer
Answer & solution

Answer: C in the conventional address-generation pipeline (no official key was published)

1. The data TLB maps a virtual page number to a physical frame number. The virtual page number comes from the effective address of the data operand.
2. In the conventional sequential stage model, effective-address calculation must finish before that page number is available for translation. This gives C.
3. Waiting until the cache lookup ends is unnecessary. Speculative or overlapping translation in optimized microarchitectures is a separate implementation possibility, so the statement is not a universal physical restriction.

Original paper, page 7

2 marks · MCQ
Report issue

Factorial versus exponential and quasipolynomial

Asymptotic Analysis & Recurrences

Question 39, GATE 2008: Let f(n)=2^n, g(n)=n!, h(n)=n^(log n). Which asymptotic statement is true?

(A) f=O(g); g=O(h)
(B) f=Ω(g); g=O(h)
(C) g=O(f); h=O(f)
(D) h=O(f); g=Ω(f)
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Compare logarithms, which preserve growth order for positive functions. log h=(log n)² up to base constants; log f=Θ(n). Since (log n)²=o(n), h grows slower than f.
2. Stirling gives log(n!)=n log n−n+O(log n), which grows faster than n. Thus f grows slower than g.
3. Therefore h=O(f) and g=Ω(f), D.

Original paper, page 7

2 marks · MCQ
Report issue

Majority test in a sorted array

Searching, Sorting & Selection

Question 40, GATE 2008: What is the minimum worst-case number of comparisons needed to determine whether some integer appears more than n/2 times in a sorted array of n integers?

(A) Θ(n)
(B) Θ(log n)
(C) Θ(log* n)
(D) Θ(1)
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. If a value occurs more than n/2 times, it must occupy the middle array position. Take that value as candidate and use binary searches for its first and last occurrences; accept exactly when the count exceeds n/2.
2. This needs Θ(log n) comparisons in the worst case. A logarithmic lower bound follows by locating a candidate-block boundary among linearly many possible positions while distinguishing length floor(n/2) from floor(n/2)+1.
3. Sortedness is essential; without it a linear majority scan is needed. Thus B.

Original paper, page 7

2 marks · MCQ
Report issue

Maximum splits in an order-four B-tree

B-Trees & Multiway Search Trees

Question 41, GATE 2008: A B-tree of order 4 is built from empty by ten successive insertions. What is the maximum number of node-splitting operations?

(A) 3
(B) 4
(C) 5
(D) 6
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. An order-four B-tree has at most three keys per node. The maximum is five splits. For ordinary overflow-triggered insertion, inserting 1 through 10 in ascending order and promoting the lower middle key splits a leaf on insertions 4, 6, 8 and 10; the fourth leaf split also overflows and splits the root. For a timing-independent bound, after L leaf splits there are L+1 nonempty leaves. A B-tree with L+1 leaves has exactly L separator keys in all internal nodes combined: each internal node has one fewer key than children, and summing over the tree gives leaves minus one.
2. Consequently n≥(L+1)+L=2L+1. With n=10, L≤4. Under overflow-triggered insertion, the first internal split needs the root to receive four separators from four leaf splits. With no further leaf split possible, no second internal split can occur. Thus there is at most one internal/root split and the total is at most 4+1=5.
3. Under preemptive splitting, the full root may instead split after three leaf splits, distributing its three separators into a new root with one key and two internal children with one key each. At most one further leaf split is possible, which can increase only one such child to two keys; no internal node can become full again. The same upper bound therefore holds, and increasing-key insertion attains five splits under this convention too.

Original paper, page 7

2 marks · MCQ
Report issue

Two edge-disjoint spanning trees and connectivity

Trees & Connectivity

Question 42, GATE 2008: A graph G has n vertices and 2n−2 edges partitionable into two edge-disjoint spanning trees. Which statement is NOT true?

(A) Every induced subgraph on k vertices has at most 2k−2 edges
(B) The minimum cut has at least two edges
(C) Every pair of vertices has two edge-disjoint paths
(D) Every pair of vertices has two internally vertex-disjoint paths
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The claim about two internally vertex-disjoint paths is not guaranteed. Take two copies of K4 sharing exactly one vertex: n=7 and m=12=2n−2. Each K4 decomposes into two spanning trees (for example a path on its four vertices and its complementary path); joining corresponding trees at the shared vertex gives two edge-disjoint spanning trees of the whole graph.
2. The common vertex is nevertheless an articulation vertex, so paths between the two sides must share it. A is true because each tree induces a forest with at most k−1 edges on a nonempty k-vertex set. B is true since each spanning tree contributes a distinct edge across every nontrivial cut.
3. C follows by taking the unique path in each of the two edge-disjoint trees.

Original paper, page 7

2 marks · MCQ
Report issue

Quicksort recurrence from bounded partition sizes

Searching, Sorting & Selection

Question 43, GATE 2008: A quicksort pivot procedure splits the list into two sublists each containing at least n/5 elements. If T(n) counts sorting comparisons, which offered upper recurrence follows?

(A) T(n)≤2T(n/5)+n
(B) T(n)≤T(n/5)+T(4n/5)+n
(C) T(n)≤2T(4n/5)+n
(D) T(n)≤2T(n/2)+n
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Each recursive subproblem has size at most 4n/5, because each side has at least n/5 elements. With the usual monotone worst-case upper-bound interpretation of T and linear partitioning cost, both recursive costs are bounded individually by T(4n/5), so T(n)≤2T(4n/5)+n, option C.
2. This loose recurrence follows immediately from the given size bounds. The tempting expression T(n/5)+T(4n/5)+n assumes that the most unequal permitted split maximizes the sum of recursive costs; monotonicity alone does not establish that.
3. More precisely the general recurrence is T(n)≤maxn/5≤k≤4n/5{T(k)+T(n−k)}+O(n), ignoring pivot/rounding constants. The standard comparison model includes linear partition/pivot overhead; the statement does not specify the cost of an arbitrary extra pivot-selection procedure.

Original paper, page 7

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Pseudo-polynomial subset-sum complexity

Computational Complexity

Question 44, GATE 2008: Subset sum asks whether a subset of n positive integers sums to a positive integer W. Algorithm Q takes O(nW) time. Which statement is false?

(A) Q is polynomial-time for unary input encoding
(B) Q is polynomial-time for binary input encoding
(C) Subset sum belongs to NP
(D) Subset sum is NP-hard
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. B is false. The dynamic program takes O(nW), polynomial in the numerical value W, not in its binary encoding length Θ(log W).
2. For binary input W can be exponential in the input length, so this is a pseudo-polynomial algorithm. With unary encoding the input has length at least W and at least n, hence nW is polynomial in that length.
3. A subset is a polynomial-size certificate whose sum can be checked in polynomial time, so subset sum is in NP; its standard decision form is NP-complete and therefore NP-hard. Thus A, C and D are true.

Original paper, page 8

2 marks · MCQ
Report issue

Dijkstra on the given negative-edge graph

Graph Algorithms

Question 45, GATE 2008: Run Dijkstra from a in this directed weighted graph: a→b:1, b→c:2, c→d:3, d→a:2, b→e:−3, c→h:−5, d→g:2, h→e:1, g→h:2, g→e:1, e→f:2, f→g:3. To which vertices does it compute correct shortest-path distances?

(A) Only a
(B) Only a,e,f,g,h
(C) Only a,b,c,d
(D) All vertices
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (22 steps)

1. All vertices receive the correct distance despite the negative edges. From a, settle b at 1, which sets c=3 and e=−2. Settle e at −2, then f at 0, setting g=3. Vertices c and g tie at 3.
2. Whichever is handled first, c sets h=3−5=−2 before h is settled (if g was handled first it only proposes h=5). Vertex h proposes e=−1, not an improvement over −2. Vertex d gets 6 from c and offers no improvement to a or g. Final distances (a,b,c,d,e,f,g,h)=(0,1,3,6,−2,0,3,−2).
3. They also satisfy every edge relaxation inequality, with each value attained by a path, proving optimality. Negative edges invalidate Dijkstra’s general guarantee, but do not force failure on every particular input.

Original paper, page 8

2 marks · MCQ
Report issue

Reconstructing a BST from postorder

Binary Search & Balanced Trees

Question 46, GATE 2008: Given the postorder traversal P of a BST on distinct elements 1,…,n, what is the most efficient time to construct the unique BST having traversal P?

(A) Θ(log n)
(B) Θ(n)
(C) Θ(n log n)
(D) None: the tree cannot be uniquely determined
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Θ(n) time is sufficient and necessary. Read the postorder sequence backward: the next element is the root, followed by the right subtree in reverse postorder and then the left.
2. A recursive builder with allowed key interval (low,high) consumes a value only if it belongs in that interval; after creating a node with key r, build the right interval (r,high), then the left (low,r). Each key is consumed once and there are O(n) calls, so the time is O(n).
3. Distinct BST keys and their ordering make the construction unique. Reading and outputting n nodes requires Ω(n), yielding Θ(n).

Original paper, page 8

2 marks · MCQ
Report issue

Batch insertion into a binary heap

Heaps & Priority Queues

Question 47, GATE 2008: A binary heap contains n elements. Insert another n elements, not necessarily one at a time. What is the optimum total time?

(A) Θ(log n)
(B) Θ(n)
(C) Θ(n log n)
(D) Θ(n²)
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Append all n new elements to the existing n-element heap array, then run bottom-up BUILD-HEAP on the resulting 2n elements. Its total sift-down work is O(n), since the number of nodes of height h decreases geometrically and Σh/2h is constant.
2. Reading/storing n new elements requires Ω(n), so the optimum total is Θ(n), option B. The permission to insert them in a batch is crucial: n separate ordinary heap insertions can require Θ(n log n).

Original paper, page 8

2 marks · MCQ
Report issue

False claim about recursively enumerable subsets

Decidability & Computability

Question 48, GATE 2008: Which statement is false?

(A) Every NFA has an equivalent DFA
(B) Every nondeterministic TM has an equivalent deterministic TM
(C) Every regular language is context-free
(D) Every subset of a recursively enumerable set is recursive
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. D is false. The set Σ* is recursive and hence recursively enumerable, but it contains nonrecursive subsets, including an encoding of the halting language.
2. Even a recursively enumerable set itself need not be recursive. A holds by the subset construction for NFAs.
3. B holds because a deterministic Turing machine can dovetail the finitely branching computation tree of a nondeterministic machine, accepting exactly when an accepting branch is found. C holds because a finite automaton can be converted to a right-linear context-free grammar.

Original paper, page 8

2 marks · MCQ
Report issue

Product automaton transition-table discrepancy

Finite Automata

Question 49, GATE 2008: DFA Y has start 1, final 2, and transitions on (a,b): 1→(1,2), 2→(2,1). DFA Z has start 1, final 2: 1→(2,2), 2→(1,1). Which printed table is their intersection product Z×Y? In every offered table P is initial, R is the only final state, and each row below lists its (a,b) destinations.

(A) P:(S,R), Q:(R,S), R:(Q,P), S:(Q,P)
(B) P:(S,Q), Q:(R,S), R:(Q,P), S:(P,Q)
(C) P:(Q,S), Q:(R,S), R:(Q,P), S:(Q,P)
(D) P:(S,Q), Q:(S,R), R:(Q,P), S:(Q,P)
Tap to enlarge
Your answer
Answer & solution

Answer: None (no official key was published)

1. There is no correct option as printed. Let product states be P=(1,1), Q=(1,2), R=(2,2), S=(2,1), in (Z,Y) order. P is initial and R is the sole accepting state.
2. Applying both component transitions gives the rows (a,b): P=(S,R), Q=(R,S), R=(Q,P), S=(P,Q). Option A agrees in its first three rows but prints S=(Q,P), not (P,Q). Options B, C and D send the initial state on b to a nonfinal state, whereas b is accepted by both Y and Z and must be accepted by their intersection product.
3. Thus none represents the product, even after renaming. A would be correct if its final row were repaired. No official key is available to determine how the examination treated the printing defect.

Original paper, page 9

2 marks · MCQ
Report issue

Grammar transformations and normal-form trees

Context-Free Grammars & Languages

Question 50, GATE 2008: Which statements are true? I: every left-recursive grammar can be converted to a right-recursive grammar and vice versa. II: all ε-productions can be removed from any CFG by suitable transformations. III: a CFG with only X→w or X→wY, where w is a terminal string and Y a nonterminal, always generates a regular language. IV: derivation trees for a CFG in Chomsky normal form are always binary trees.

(A) I,II,III,IV
(B) II,III,IV only
(C) I,III,IV only
(D) I,II,IV only
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Under the conventional grammar-transformation interpretation, I, III and IV are true, giving C. I refers to eliminating left recursion using right-recursive auxiliaries and the symmetric transformation for right recursion; it does not mean every context-free grammar becomes a right-linear regular grammar.
2. II is false as stated: if ε belongs to the language, removing every ε-production cannot preserve that language, since no nonempty sentential form can derive the empty string without one. III is a right-linear grammar, possibly with multi-terminal labels; expanding labels into paths yields a finite automaton, so its language is regular.
3. IV is true in the at-most-two-children sense of binary tree: CNF uses A→BC or A→a (and possibly the special start ε-rule), so no derivation-tree node has more than two children.

Original paper, page 9

2 marks · MCQ
Report issue

Matching language patterns to compiler requirements

Context-Free Grammars & Languages

Question 51, GATE 2008: Match E: checking identifiers are declared before use; F: agreement of numbers of formal and actual function parameters; G: arithmetic expressions with matched parentheses; H: palindromes. Models: P={a^n b^m c^n d^m | n,m≥1}; Q: X→XbX|XcX|dXf|g; R={wcw | w∈{a,b}*}; S: X→bXb|cXc|ε.

(A) E–P,F–R,G–Q,H–S
(B) E–R,F–P,G–S,H–Q
(C) E–R,F–P,G–Q,H–S
(D) E–P,F–R,G–S,H–Q
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The matching is E–R, F–P, G–Q, H–S, option C. E requires the same identifier string in declaration and use, modeled by the copy language wcw.
2. F matches counts of formal and actual parameters; an bm cn dm models the two cross-referenced counts. G is modeled by X→XbX | XcX | dXf | g: b and c act as binary operators, d/f as matched opening/closing parentheses, and g as an operand.
3. H is modeled by X→bXb | cXc | ε, which generates even-length palindromes. These are structural analogies, not claims that the small grammars capture every feature of a programming language or all odd-length palindromes.

Original paper, page 9

2 marks · MCQ
Report issue

Matching four NFAs to regular expressions

Regular Expressions & Languages

Question 52, GATE 2008: Match four NFAs to regular expressions. Each NFA has lower state L (initial and accepting), upper-left A and upper-right B. Unlisted transitions are absent. P: L−0→A, A−0→L and B, B−1→A and B; B is also accepting. Q: L−0→A, A−0→L, A−1→B, B−1→A, B−0→B; only L accepts. R: L−0→A, A−1→L and B, B−1→A, B−0→B; only L accepts. S has R’s transitions with both L and B accepting. Expressions: 1: ε+0(01*1+00)*01*; 2: ε+0(10*1+00)*0; 3: ε+0(10*1+10)*1; 4: ε+0(10*1+10)*10*.

(A) P–2,Q–1,R–3,S–4
(B) P–1,Q–3,R–2,S–4
(C) P–1,Q–2,R–3,S–4
(D) P–3,Q–2,R–1,S–4
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Name the lower start state L, upper-left state A and upper-right state B. Every automaton accepts ε at L; every nonempty accepted path begins with 0 from L to A. In P, cycles from A back to A are 00 via L or 01*1 via B, and a finishing path to either accepting state is represented by 01*.
2. Hence P matches expression 1: ε+0(01*1+00)*01*. In Q, the A-cycles are 00 or 10*1, with final 0 to L, giving expression 2. In R, the A-cycles are 10 or 10*1, with final 1 to L, giving expression 3.
3. In S, the same cycles apply but B is also accepting, so a final 10* covers both possible accepting destinations, giving expression 4. Thus P–1,Q–2,R–3,S–4, option C.

Original paper, page 10

2 marks · MCQ
Report issue

Regularity of four language families

Regular Expressions & Languages

Question 53, GATE 2008: Which sets are regular? I: {a^n b^(2m) | n,m≥0}. II: {a^n b^m | n=2m}. III: {a^n b^m | n≠m}. IV: {xcy | x,y∈{a,b}*}.

(A) I and IV only
(B) I and III only
(C) I only
(D) IV only
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. I and IV are regular, giving A. I has expression a*(bb)*: n and m are independent and only the parity of the b-count is restricted.
2. IV has expression (a|b)*c(a|b)* because x and y need not be equal. II is {a2mbm}; applying the pumping lemma to a2pbp pumps only a symbols and destroys the required 2:1 relation.
3. III is not regular: if it were, subtracting it from the regular language a*b* would make {an bn} regular by closure under difference, a contradiction.

Original paper, page 10

2 marks · MCQ
Report issue

Activation records, recursion and escaping closures

Runtime Environments & Parameter Passing

Question 54, GATE 2008: Which are true? I: a language without globals or nested procedures, but with recursion, can use static storage allocation. II: multilevel access links/displays are needed only for languages with nested procedures. III: recursion cannot use dynamic storage allocation. IV: nesting and recursion require heap allocation and cannot use stack activation records. V: languages allowing a function to return a function cannot use only stack allocation for activation records.

(A) II and V only
(B) I,III,IV only
(C) I,II,V only
(D) II,III,V only
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Under the standard language-runtime assumptions, II and V are true, giving A. I is false: recursive calls can have arbitrarily many simultaneously live instances of local variables, so one statically allocated activation record per procedure is insufficient even without globals or nested procedures.
2. II is true: multilevel static access links/displays serve access to lexically enclosing procedures; without lexical nesting no multilevel environment chain is needed. III is false because dynamic stack allocation supports ordinary recursion.
3. IV is false because nested procedures and recursion alone can use stack activation records with static/dynamic links. V describes a returned nested function that can retain its defining environment after the creator returns: pure stack allocation cannot preserve that environment, so escaping environments need extended lifetime, normally heap allocation or copying.
4. The literal statement V is too broad without that escaping-closure assumption: a function may return a pointer to a global function, or a function with no captured environment, while ordinary activation records remain stack allocated. Thus A is the intended answer under the nested escaping-function interpretation, not a universal consequence of merely returning any function.

Original paper, page 11

2 marks · MCQ
Report issue

Shift-reduce conflicts under LALR merging

Parsing & Syntax Analysis

Question 55, GATE 2008: An LALR(1) parser for G has shift-reduce conflicts if and only if:

(A) Its SLR(1) parser has shift-reduce conflicts
(B) Its LR(1) parser has shift-reduce conflicts
(C) Its LR(0) parser has shift-reduce conflicts
(D) Its LALR(1) parser has reduce-reduce conflicts
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. The equivalence is with canonical LR(1), option B. An LALR state merges LR(1) states having the same LR(0) core and unions lookaheads. Suppose a merged state has a reduction A→α on lookahead a and a shift on a.
2. The reduction/lookahead pair came from some original LR(1) state. The shift item is in the shared LR(0) core, so it also occurred in that very original state. Thus the shift-reduce conflict already existed before merging.
3. Conversely a conflict in an original LR(1) state survives the merge. Merging can introduce reduce-reduce conflicts, but cannot create a new shift-reduce conflict. SLR/LR(0) may report conflicts avoided by finer LR(1) lookaheads.

Original paper, page 11

2 marks · MCQ
Report issue

TCP slow-start congestion-window growth

Transport, Congestion Control & Traffic Shaping

Question 56, GATE 2008: During TCP slow start, how does the congestion-window size grow over successive round trips?

(A) Does not increase
(B) Linearly
(C) Quadratically
(D) Exponentially
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The congestion window grows exponentially over successive round-trip times in slow start, option D. In the simplified textbook model each acknowledged segment increases the window by one MSS; a window of W segments produces about W acknowledgments in one RTT, so the window becomes approximately 2W.
2. After k such rounds it is approximately 2k times its initial value, until reaching a threshold or encountering loss. Growth is per ACK rather than continuous time; delayed ACKs and practical implementations affect the precise factor but not the intended exponential-versus-linear distinction.

Original paper, page 11

2 marks · MCQ
Report issue

Usable hosts under a /21 IPv4 mask

IP Addressing, Fragmentation & Address Resolution

Question 57, GATE 2008: A Class B network uses subnet mask 255.255.248.0. What is the maximum number of hosts per subnet?

(A) 1022
(B) 1023
(C) 2046
(D) 2047
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step through it (3 steps)

Step 1: 255.255.248.0 has 8+8+5=21 leading one bits because 248=11111000₂. Thus 32−21=11 host bits remain.
Step 2: A subnet has 211=2048 addresses; reserving the all-zero host part for the subnet address and the all-one host part for broadcast leaves 2046 usable host addresses, option C. The original Class B label does not change the host count once the subnet mask is supplied.

Original paper, page 11

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Maximum token-bucket burst duration

Transport, Congestion Control & Traffic Shaping

Question 58, GATE 2008: A computer transmits on a 10-Mbit/s network through a token bucket replenished at 2 Mbit/s. Initially it holds its full capacity of 16 Mbits. How long can transmission continue at the full 10 Mbit/s?

(A) 1.6 seconds
(B) 2 seconds
(C) 5 seconds
(D) 8 seconds
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. At full output rate 10 Mbit/s, tokens are consumed at 10 Mbit/s while replenishment continues at 2 Mbit/s. The initially full 16-Mbit bucket therefore drains at a net rate of 8 Mbit/s.
2. Its maximum full-rate burst lasts 16/(10−2)=2 seconds, option B. Equivalently 10t≤16+2t gives t≤2.
3. Ignoring concurrent refill would incorrectly produce 1.6 seconds.

Original paper, page 11

2 marks · MCQ
Report issue

TCP connect before the server calls accept

Transport, Congestion Control & Traffic Shaping

Question 59, GATE 2008: A TCP server executes socket(), bind(), listen(), then is preempted before any accept(). A client executes socket() and connect() to it. Which event can occur in the intended normal setting?

(A) connect() returns successfully
(B) connect() blocks
(C) connect() returns an error
(D) connect() causes a core dump
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The client connect() can return successfully, option A. After socket(), bind() and listen(), the server kernel has a listening TCP endpoint and can complete the three-way handshake while the server process is descheduled.
2. The resulting established connection waits in the listener’s accept queue; accept() subsequently removes an entry and returns a connected socket to the server process. Hence user-space accept() is not required for the client handshake to complete.
3. The intended setting assumes an available backlog slot and normal network operation; incidental loss, queue exhaustion or unrelated errors can of course affect real calls.

Original paper, page 11

2 marks · MCQ
Report issue

Aliased pointer updates and a value parameter

Pointers & Memory

Question 60, GATE 2008: What does this historical C program print?
int f(int x, int *py, int **ppz) {
 int y,z;
 **ppz += 1; z=*ppz;
 *py += 2; y=*py;
 x += 3;
 return x+y+z;
}
void main() {
 int c,*b,**a;
 c=4; b=&c; a=&b;
 printf("%d",f(c,b,a));
}

(A) 18
(B) 19
(C) 21
(D) 22
Tap to enlarge
Your answer
Answer & solution

Answer: B only if z=*ppz is repaired to z=**ppz; no portable numeric answer as printed (no official key was published)

1. The scan prints **ppz += 1; z = *ppz; with only one dereference in the assignment to z. Since ppz has type int **, *ppz is an int * rather than the integer value of c. Assigning that pointer to int z violates the standard C simple-assignment constraints and requires a diagnostic. Consequently the printed program has no portable numeric answer among the options; accepting it as an extension does not make z equal to 5.
2. If the apparent typo is explicitly repaired to z = **ppz, the intended alias trace is: x starts as a separate copy 4; **ppz += 1 makes c=5 and z=5; *py += 2 makes c=7 and y=7; x += 3 makes x=7. The sum is then 7+7+5=19, option B only for that repaired program.
3. The source also uses historical void main() and omits the stdio declaration. Those conventions do not remove the single-dereference defect. The derived answer is therefore conditional: B applies only after the stated repair, and no listed portable answer is justified for the printed code. No official key is available.

Original paper, page 12

2 marks · MCQ
Report issue

Recursive string reversal

Recursion

Question 61, GATE 2008: Fill ?1 and ?2 so this historical C program reverses a newline-terminated input string.
void reverse(void) {
 int c;
 if (?1) reverse();
 ?2
}
main() {
 printf("Enter Text"); printf("\n");
 reverse(); printf("\n");
}

(A) ?1: (getchar()!='\n'); ?2: getchar(c);
(B) ?1: ((c=getchar())!='\n'); ?2: getchar(c);
(C) ?1: (c!='\n'); ?2: putchar(c);
(D) ?1: ((c=getchar())!='\n'); ?2: putchar(c);
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Each invocation must read and retain its own character: ((c=getchar()) != '\n'). Recurse only for a non-newline character, then putchar(c) while unwinding.
2. This prints the input characters in reverse, option D. As written, the base invocation also prints the terminating newline before the reversed characters; main then prints a newline afterward.
3. A and B use getchar instead of output; C tests an uninitialized c. The source uses legacy implicit-int main; interpret the algorithm under its historical C conventions.

Original paper, page 12

2 marks · MCQ
Report issue

Pairwise linked-list value swaps

Arrays & Linked Lists

Question 62, GATE 2008: The list initially contains 1,2,3,4,5,6,7. What does it contain after this C function?
struct node { int value; struct node *next; };
void rearrange(struct node *list) {
 struct node *p,*q; int temp;
 if (!list || !list->next) return;
 p=list; q=list->next;
 while(q) {
  temp=p->value; p->value=q->value; q->value=temp;
  p=q->next; q=p ? p->next : 0;
 }
}

(A) 1,2,3,4,5,6,7
(B) 2,1,4,3,6,5,7
(C) 1,3,2,5,4,7,6
(D) 2,3,4,5,6,7,1
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. p starts at the first node and q at the second. The temporary variable exchanges their value fields; no next pointer is modified.
2. p=q->next advances to the next pair’s first node, and q becomes its successor when it exists. Thus pairs (1,2), (3,4), (5,6) swap.
3. The final node 7 has no partner, so q becomes null and the loop stops. The sequence is 2,1,4,3,6,5,7, B.

Original paper, page 12

2 marks · MCQ
Report issue

Initializing binary semaphores

Synchronization & Concurrency

Question 63, GATE 2008: Counting-semaphore operations are P(s): decrement s and wait if s<0; V(s): increment s and wake one waiter if s≤0. Given binary-semaphore wait/signal Pb,Vb, consider:
P(s): Pb(xb); s=s−1; if(s<0){Vb(xb); Pb(yb);} else Vb(xb);
V(s): Pb(xb); s=s+1; if(s≤0) Vb(yb); Vb(xb);
What initial values should xb,yb have respectively?

(A) 0,0
(B) 0,1
(C) 1,0
(D) 1,1
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The semaphore xb protects the shared count and must start unlocked at 1. The semaphore yb represents the waiting gate and must start at 0, so a P operation with negative count blocks.
2. Thus the required initial values are (1,0), option C. This answers the initialization question, not a proof of the whole implementation.
3. Under ordinary saturating binary-semaphore semantics the shown implementation can lose a wakeup: two P callers decrement to -2 and pause before Pb(yb); two V callers then both signal yb before either waiter consumes it, leaving only one stored signal. A robust implementation needs additional synchronization or a specified wakeup protocol.

Original paper, page 13

2 marks · MCQ
Report issue

Synchronous versus asynchronous I/O

I/O & Disk Scheduling

Question 64, GATE 2008: Which statement about synchronous/asynchronous I/O is NOT true in the interrupt-driven model?

(A) An ISR is invoked on synchronous completion but not asynchronous completion
(B) Both synchronous and asynchronous I/O invoke an ISR after completion
(C) Synchronous callers wait for completion; asynchronous callers do not
(D) For synchronous I/O, the completion ISR wakes the waiting process
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. In the intended interrupt-driven I/O model, both synchronous and asynchronous operations can invoke an ISR on completion. Synchronous versus asynchronous describes whether the requesting process waits, not whether completion interrupts exist.
2. Hence A is the false statement; B, C and D describe the model. More generally I/O can be polled, so interrupt use is an assumed implementation detail rather than a universal consequence of synchronous/asynchronous semantics.

Original paper, page 13

2 marks · MCQ
Report issue

Deadlock prevention versus avoidance

Deadlocks

Question 65, GATE 2008: Which is NOT true of deadlock prevention and avoidance?

(A) Prevention always grants a request if the resulting state is safe
(B) Avoidance always grants a request if the resulting state is safe
(C) Avoidance is less restrictive than prevention
(D) Avoidance needs resource requirements known in advance
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Prevention breaks a necessary condition for deadlock, for example by requiring a fixed acquisition order or all-at-once requests. It may deny a request even though granting it would leave a safe state.
2. Avoidance explicitly tests safety using declared maximum needs and grants an otherwise valid request if safety is preserved.
3. Thus A incorrectly attributes avoidance’s rule to prevention. The conventional comparison makes B,C,D true: avoidance is less structurally restrictive but needs advance resource information.

Original paper, page 13

2 marks · MCQ
Report issue

Process count after repeated fork

Processes, Threads & System Calls

Question 66, GATE 2008: A process executes for(i=0;i<n;i++) fork();. How many child processes are created in total, assuming all forks succeed?

(A) n
(B) 2^n−1
(C) 2^n
(D) 2^(n+1)−1
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step through it (3 cases)

1. Both parent and new child continue the loop after each successful fork. Hence each iteration doubles the number of processes still executing.
2. From one process, n iterations yield 2n total processes. Equivalently the iterations create 1+2+⋯+2n−1 children.
3. Subtract the one original process: 2n−1, B. Counting only n forks by the original parent misses descendants’ forks.

Original paper, page 13

2 marks · MCQ
Report issue

Pointer bits in a three-level page table

Virtual Memory & Paging

Question 67, GATE 2008: A processor has 36-bit physical and 32-bit virtual addresses, 4-KiB page frames, and 4-byte page-table entries. Its three-level translation indexes level 1 with VA bits 30–31, level 2 with bits 21–29, level 3 with bits 12–20; bits 0–11 are page offset. How many address bits in entries at levels 1,2,3 identify the next table or final frame, respectively?

(A) 20,20,20
(B) 24,24,24
(C) 24,24,20
(D) 25,25,24
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Each second- and third-level table has 29 entries of 4 bytes, so it occupies 211 bytes. With compact 2-KiB-aligned tables in a 36-bit physical address space, a pointer to either table needs 36−11=25 bits.
2. A data page frame occupies 212 bytes and its frame number needs 36−12=24 bits. The result is (25,25,24), option D.
3. This uses the intended natural table-size alignment; forcing every table to a separate 4-KiB frame would instead produce 24-bit table-frame pointers.

Original paper, page 14

2 marks · MCQ
Report issue

Equivalent relational-algebra projections

Relational Algebra & Calculus

Question 68, GATE 2008: R(P,Q,R1,R2,R3) and S(P,Q,S1,S2) each have key {P,Q}. Which relational-algebra queries are equivalent? ⋈ denotes natural join. I: πP(R⋈S). II: πP(R)⋈πP(S). III: πP(πP,Q(R)∩πP,Q(S)). IV: πP(πP,Q(R)−(πP,Q(R)−πP,Q(S))).

(A) I and II only
(B) I and III only
(C) I,II,III only
(D) I,III,IV only
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The natural join matches both common attributes P and Q. Consequently I returns P values of pairs (P,Q) appearing in both relations, exactly III.
2. Since A−(A−B)=A∩B, IV is also equivalent. II only matches P after discarding Q: R containing (p,q1) and S containing (p,q2), q1≠q2, makes II nonempty but I empty.
3. Thus only I, III and IV are equivalent, option D.

Original paper, page 14

2 marks · MCQ
Report issue

Normal forms of Book and Collection

Normalization & Decomposition

Question 69, GATE 2008: Book(Title,Author,Catalog_no,Publisher,Year,Price) and Collection(Title,Author,Catalog_no) have key {Author,Title}. Dependencies: Title Author→Catalog_no; Catalog_no→Title Author Publisher Year; Publisher Title Year→Price. Which statement is true?

(A) Both are in BCNF
(B) Both are in 3NF only
(C) Book is in 2NF and Collection is in 3NF
(D) Both are in 2NF only
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step through it (2 parts)

1. In Book, both {Title,Author} and {Catalog_no} are candidate keys. No given dependency makes a nonprime attribute depend on a proper subset of a candidate key, so Book is in 2NF.
2. Publisher,Title,Year→Price violates 3NF because its determinant is not a superkey and Price is nonprime. Collection has only Title, Author and Catalog_no; its nontrivial determinants are candidate keys, so it is BCNF and hence also 3NF.
3. Therefore C is true. The wording of C does not say Collection is only in 3NF.

Original paper, page 14

2 marks · MCQ
Report issue

Secondary multilevel index blocks

Indexing, Storage & Query Processing

Question 70, GATE 2008: A file has 16384 records of 32 bytes each, with a 6-byte key. It is ordered on a non-key field and uses unspanned organization. Block size is 1024 bytes and block pointers occupy 10 bytes. A multilevel secondary index is built on the key. How many first- and second-level index blocks are needed?

(A) 8 and 0
(B) 128 and 6
(C) 256 and 4
(D) 512 and 5
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Because the file is not ordered by the indexed key, the first secondary-index level is dense, with one entry per record. An entry occupies 6+10=16 bytes, so a 1024-byte block holds 64 entries.
2. The first level therefore needs 16384/64=256 blocks. The second level indexes those ordered first-level blocks, requiring 256/64=4 blocks.
3. Option C. The 512 data blocks are not the first-level index-block count.

Original paper, page 14

2 marks · MCQ
Report issue

Total virtual cache-tag storage

Cache Memory

Question 71, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the total tag storage in the cache directory?

(A) 32 Kibits
(B) 34 Kibits
(C) 64 Kibits
(D) 68 Kibits
Question 71, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the total tag storage in the cache directory?

(A) 32 Kibits
(B) 34 Kibits
(C) 64 Kibits
(D) 68 Kibits
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The 64-KiB cache with 16-byte blocks contains 4096 lines. Two ways give 2048 sets, requiring 11 index bits; the byte offset needs 4 bits.
2. The 32-bit virtual address therefore leaves 32−11−4=17 tag bits per line. Total tag storage is 4096×17=69632 bits=68 Kibits, option D.
3. Valid, dirty and replacement bits are not tags and are excluded.

Original paper, page 15

2 marks · MCQ
Report issue

Array element sharing a cache index

Cache Memory

Question 72, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
Which element has the same cache index as ARR[0][0]?

(A) ARR[0][4]
(B) ARR[4][0]
(C) ARR[0][5]
(D) ARR[5][0]
Question 72, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
Which element has the same cache index as ARR[0][0]?

(A) ARR[0][4]
(B) ARR[4][0]
(C) ARR[0][5]
(D) ARR[5][0]
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. The index repeats every 2048 sets×16 bytes=32768 bytes. A row contains 1024 doubles×8 bytes=8192 bytes.
2. ARR[4][0] is 4×8192=32768 bytes after ARR[0][0], so it has the same set index, option B. ARR[0][4] and ARR[0][5] are only 32 and 40 bytes later; ARR[5][0] is 40960 bytes later, changing the index.

Original paper, page 15

2 marks · MCQ
Report issue

Cache hits for row-major initialization

Cache Memory

Question 73, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the cache hit ratio for the initialization loop? The printed statement does not specify write allocation.

(A) 0%
(B) 25%
(C) 50%
(D) 75%
Question 73, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
 for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the cache hit ratio for the initialization loop? The printed statement does not specify write allocation.

(A) 0%
(B) 25%
(C) 50%
(D) 75%
Tap to enlarge
Your answer
Answer & solution

Answer: C (assuming write allocation) (no official key was published)

1. Sequential row-major stores touch two adjacent 8-byte doubles in each 16-byte cache line. With the intended write-allocate policy and an initially empty cache, the first store misses and allocates the line, and the second store hits.
2. The hit ratio is therefore 1/2=50%, option C. The array is page-aligned and thus line-aligned.
3. No line is reused after the traversal moves beyond it, so capacity misses do not change this pairing. A no-write-allocate cache would leave every store a miss and yield 0% (A).

Original paper, page 15

2 marks · MCQ
Report issue

Recursive versus iterative recurrence runtime

Asymptotic Analysis & Recurrences

Question 74, GATE 2008: Consider these C functions, assuming valid array bounds and the intended unit-cost arithmetic model:
int f1(int n) {
 if(n==0 || n==1) return n;
 else return 2*f1(n-1)+3*f1(n-2);
}
int f2(int n) {
 int i; int X[N],Y[N],Z[N];
 X[0]=Y[0]=Z[0]=0;
 X[1]=1; Y[1]=2; Z[1]=3;
 for(i=2;i<=n;i++) {
  X[i]=Y[i-1]+Z[i-2];
  Y[i]=2*X[i]; Z[i]=3*X[i];
 }
 return X[n];
}
What are the running times of f1(n) and f2(n), respectively?

(A) Θ(n),Θ(n)
(B) Θ(2^n),Θ(n)
(C) Θ(n),Θ(2^n)
(D) Θ(2^n),Θ(2^n)
Question 74, GATE 2008: Consider these C functions, assuming valid array bounds and the intended unit-cost arithmetic model:
int f1(int n) {
 if(n==0 || n==1) return n;
 else return 2*f1(n-1)+3*f1(n-2);
}
int f2(int n) {
 int i; int X[N],Y[N],Z[N];
 X[0]=Y[0]=Z[0]=0;
 X[1]=1; Y[1]=2; Z[1]=3;
 for(i=2;i<=n;i++) {
  X[i]=Y[i-1]+Z[i-2];
  Y[i]=2*X[i]; Z[i]=3*X[i];
 }
 return X[n];
}
What are the running times of f1(n) and f2(n), respectively?

(A) Θ(n),Θ(n)
(B) Θ(2^n),Θ(n)
(C) Θ(n),Θ(2^n)
(D) Θ(2^n),Θ(2^n)
Tap to enlarge
Your answer
Answer & solution

Answer: No exact option; B is the apparent intended choice (no official key was published)

1. The recursive function makes one call on n−1 and one on n−2; coefficients 2 and 3 multiply the returned values and do not multiply the number of calls. Thus T(n)=T(n−1)+T(n−2)+Θ(1), giving Θ(φn), where φ=(1+√5)/2.
2. The iterative f2 executes n−1 constant-time iterations, Θ(n). None of the printed options gives Θ(φn),Θ(n).
3. Option B prints Θ(2n),Θ(n), which supplies an exponential upper bound but falsely labels it tight Θ. This analysis assumes unit-cost bounded-size arithmetic and n within valid array bounds; unbounded n in actual C would also encounter overflow.

Original paper, page 16

2 marks · MCQ
Report issue

Values of matching recurrence implementations

Recursion

Question 75, GATE 2008: Consider these C functions, assuming valid array bounds and the intended unit-cost arithmetic model:
int f1(int n) {
 if(n==0 || n==1) return n;
 else return 2*f1(n-1)+3*f1(n-2);
}
int f2(int n) {
 int i; int X[N],Y[N],Z[N];
 X[0]=Y[0]=Z[0]=0;
 X[1]=1; Y[1]=2; Z[1]=3;
 for(i=2;i<=n;i++) {
  X[i]=Y[i-1]+Z[i-2];
  Y[i]=2*X[i]; Z[i]=3*X[i];
 }
 return X[n];
}
What values do f1(8) and f2(8) return?

(A) 1661 and 1640
(B) 59 and 59
(C) 1640 and 1640
(D) 1640 and 1661
Question 75, GATE 2008: Consider these C functions, assuming valid array bounds and the intended unit-cost arithmetic model:
int f1(int n) {
 if(n==0 || n==1) return n;
 else return 2*f1(n-1)+3*f1(n-2);
}
int f2(int n) {
 int i; int X[N],Y[N],Z[N];
 X[0]=Y[0]=Z[0]=0;
 X[1]=1; Y[1]=2; Z[1]=3;
 for(i=2;i<=n;i++) {
  X[i]=Y[i-1]+Z[i-2];
  Y[i]=2*X[i]; Z[i]=3*X[i];
 }
 return X[n];
}
What values do f1(8) and f2(8) return?

(A) 1661 and 1640
(B) 59 and 59
(C) 1640 and 1640
(D) 1640 and 1661
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Both functions implement a0=0, a1=1, an=2a(n−1)+3a(n−2). In f2, Y[i]=2X[i] and Z[i]=3X[i], including the initialized indices, so X has exactly that recurrence.
2. Values a2 through a8 are 2,7,20,61,182,547,1640. Thus both return 1640, option C, assuming N≥9.
3. Equivalently an=(3^n−(−1)^n)/4.

Original paper, page 16

2 marks · MCQ
Report issue

Semantics of an unconditional delay slot

Pipelining & Hazards

Question 76, GATE 2008: Delayed branching handles control hazards. For a delayed conditional branch, regardless of whether the condition is true or false, which statement holds?

(A) The instruction immediately following the branch in memory is executed
(B) The first instruction in the fall-through path is executed
(C) The first instruction in the taken path is executed
(D) The branch takes longer than any other instruction
Question 76, GATE 2008: Delayed branching handles control hazards. For a delayed conditional branch, regardless of whether the condition is true or false, which statement holds?

(A) The instruction immediately following the branch in memory is executed
(B) The first instruction in the fall-through path is executed
(C) The first instruction in the taken path is executed
(D) The branch takes longer than any other instruction
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. In the ordinary non-annulling delayed-branch model, the instruction immediately following the branch in memory executes before control transfers, regardless of whether the branch is taken. That is the delay-slot instruction, option A.
2. Instructions beyond the delay slot on the fall-through or target paths are not both guaranteed to execute. Some ISAs offer annulled slots, but those are outside the simple delayed-branch model used by this linked pair.

Original paper, page 16

2 marks · MCQ
Report issue

Safe instruction for a branch delay slot

Pipelining & Hazards

Question 77, GATE 2008: A processor has one branch delay slot. Which instruction can be moved into it without other program changes?
I1: ADD R2←R7+R8
I2: SUB R4←R5−R6
I3: ADD R1←R2+R3
I4: STORE Memory[R4]←R1
BRANCH to Label if R1==0

(A) I1
(B) I2
(C) I3
(D) I4
Question 77, GATE 2008: A processor has one branch delay slot. Which instruction can be moved into it without other program changes?
I1: ADD R2←R7+R8
I2: SUB R4←R5−R6
I3: ADD R1←R2+R3
I4: STORE Memory[R4]←R1
BRANCH to Label if R1==0

(A) I1
(B) I2
(C) I3
(D) I4
Question 77, GATE 2008: A processor has one branch delay slot. Which instruction can be moved into it without other program changes?
I1: ADD R2←R7+R8
I2: SUB R4←R5−R6
I3: ADD R1←R2+R3
I4: STORE Memory[R4]←R1
BRANCH to Label if R1==0

(A) I1
(B) I2
(C) I3
(D) I4
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. I4 stores R1 through address R4 but changes neither register used by the branch condition. Moving it from immediately before the branch to the single delay slot preserves its unconditional execution and lets the branch still test the R1 computed by I3.
2. I1 cannot move because I3 needs R2; I2 cannot move because I4 needs R4; I3 cannot move because I4 and the branch need R1. Thus I4, option D, is the legal choice in the stated dependency model.

Original paper, page 17

2 marks · MCQ
Report issue

Counting strings with no consecutive zeros

Recurrences & Generating Functions

Question 78, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. Which recurrence does it satisfy?

(A) xₙ=2xₙ₋₁
(B) xₙ=x⌊ₙ/₂⌋+1
(C) xₙ=x⌊ₙ/₂⌋+n
(D) xₙ=xₙ₋₁+xₙ₋₂
Question 78, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. Which recurrence does it satisfy?

(A) xₙ=2xₙ₋₁
(B) xₙ=x⌊ₙ/₂⌋+1
(C) xₙ=x⌊ₙ/₂⌋+n
(D) xₙ=xₙ₋₁+xₙ₋₂
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Divide valid strings of length n≥2 by their first bit. A leading 1 can be followed by any valid length-(n−1) string.
2. A leading 0 must be followed by 1, leaving any valid length-(n−2) suffix. These two groups cannot overlap and cover every valid string.
3. Add their counts: xₙ=xₙ₋₁+xₙ₋₂, D. Initial values are x₀=1 and x₁=2, which are essential for numerical evaluation.

Original paper, page 17

2 marks · MCQ
Report issue

Length-five strings with no consecutive zeros

Combinatorics & Counting

Question 79, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. What is x₅?

(A) 5
(B) 7
(C) 8
(D) 16
Question 79, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. What is x₅?

(A) 5
(B) 7
(C) 8
(D) 16
Question 79, GATE 2008: Let xₙ count binary strings of length n containing no consecutive zeros. What is x₅?

(A) 5
(B) 7
(C) 8
(D) 16
Tap to enlarge
Your answer
Answer & solution

Answer: 13; no listed option (no official key was published)

1. The initial counts are x0=1 for the empty string and x1=2 for 0 and 1. The recurrence from Q78 gives x2=3, x3=5, x4=8 and x5=13.
2. Independently, count by the number of nonadjacent zeros: binomial(6,0)+binomial(5,1)+binomial(4,2)+binomial(3,3)=1+5+6+1=13. The scan lists 5,7,8,16; none is correct.
3. Do not use Fibonacci seeds 1,1, which count the wrong objects.

Original paper, page 17

2 marks · MCQ
Report issue

Subset-sum dynamic-programming recurrence

Dynamic Programming

Question 80, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which recurrence is valid for 2≤i≤n and aᵢ≤j≤W?

(A) X[i,j]=X[i−1,j]∨X[i,j−aᵢ]
(B) X[i,j]=X[i−1,j]∨X[i−1,j−aᵢ]
(C) X[i,j]=X[i−1,j]∧X[i,j−aᵢ]
(D) X[i,j]=X[i−1,j]∧X[i−1,j−aᵢ]
Question 80, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which recurrence is valid for 2≤i≤n and aᵢ≤j≤W?

(A) X[i,j]=X[i−1,j]∨X[i,j−aᵢ]
(B) X[i,j]=X[i−1,j]∨X[i−1,j−aᵢ]
(C) X[i,j]=X[i−1,j]∧X[i,j−aᵢ]
(D) X[i,j]=X[i−1,j]∧X[i−1,j−aᵢ]
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Consider whether the chosen subset contains aᵢ. If not, the first i−1 elements alone must sum to j, represented by X[i−1,j].
2. If aᵢ is included, remove it once; the remaining subset of the first i−1 elements must sum to j−aᵢ, represented by X[i−1,j−aᵢ].
3. Either alternative suffices, so combine with OR, giving B. Using row i in the second term allows repeated copies of aᵢ; AND incorrectly requires both choices.

Original paper, page 17

2 marks · MCQ
Report issue

Subset-sum answer table cell

Dynamic Programming

Question 81, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which entry, if TRUE, implies there is a subset summing to W? (This preserves the printed one-way wording.)

(A) X[1,W]
(B) X[n,0]
(C) X[n,W]
(D) X[n−1,n]
Question 81, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which entry, if TRUE, implies there is a subset summing to W? (This preserves the printed one-way wording.)

(A) X[1,W]
(B) X[n,0]
(C) X[n,W]
(D) X[n−1,n]
Question 81, GATE 2008: Given positive integers S={a₁,…,aₙ} and target W>0, a subset-sum dynamic program uses Boolean X with n rows and W+1 columns. X[i,j] is true iff some subset of {a₁,…,aᵢ} sums to j, for 1≤i≤n and 0≤j≤W. Which entry, if TRUE, implies there is a subset summing to W? (This preserves the printed one-way wording.)

(A) X[1,W]
(B) X[n,0]
(C) X[n,W]
(D) X[n−1,n]
Tap to enlarge
Your answer
Answer & solution

Answer: C intended; A also satisfies the literal implication (no official key was published)

1. By the definition of X, X[n,W] is true if and only if a subset of all n inputs sums to W. Therefore C is the terminal decision cell intended by the algorithm.
2. However, the printed wording asks only which TRUE entry implies the existence of a subset summing to W. X[1,W] being true also implies that fact, since {a1} is contained in the full set.
3. B is always true via the empty subset and D concerns sum n rather than W. Thus A and C both satisfy the literal one-way implication; C alone is necessary and sufficient for the full problem.

Original paper, page 17

2 marks · MCQ
Report issue

Minimum relations for an ER diagram

Database Models, Architecture & ER Diagrams

Question 82, GATE 2008: An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. What is the minimum number of tables in the standard relational mapping?

(A) 2
(B) 3
(C) 4
(D) 5
Question 82, GATE 2008: An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. What is the minimum number of tables in the standard relational mapping?

(A) 2
(B) 3
(C) 4
(D) 5
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Use three relations: P(P1,P2), M(M1,M2,M3,P1), and N(P1,N1,N2). R1 is many-to-one from M to P with total participation of M, so a P1 foreign key in M represents it without a separate relationship table.
2. N is weak, R2 is its identifying many-to-one relationship with P, and N1 is the partial key; include P1 in N, whose primary key is (P1,N1). Thus the standard ER-to-relational mapping needs three tables, option B.

Original paper, page 18

2 marks · MCQ
Report issue

Attributes in the mapped M relation

Database Models, Architecture & ER Diagrams

Question 83, GATE 2008: An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. In the minimum-table standard mapping, which is the attribute set of one resulting table?

(A) {M1,M2,M3,P1}
(B) {M1,P1,N1,N2}
(C) {M1,P1,N1}
(D) {M1,P1}
Question 83, GATE 2008: An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. In the minimum-table standard mapping, which is the attribute set of one resulting table?

(A) {M1,M2,M3,P1}
(B) {M1,P1,N1,N2}
(C) {M1,P1,N1}
(D) {M1,P1}
Question 83, GATE 2008: An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. In the minimum-table standard mapping, which is the attribute set of one resulting table?

(A) {M1,M2,M3,P1}
(B) {M1,P1,N1,N2}
(C) {M1,P1,N1}
(D) {M1,P1}
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The many-to-one R1 relationship associates each M with a unique P. Total participation means every M must have that owner/reference.
2. Store P’s key P1 as a foreign key beside M’s own attributes M1,M2,M3; a separate R1 table is unnecessary.
3. Thus M’s table has {M1,M2,M3,P1}, A. N is represented separately by owner key P1, partial key N1 and N2; there is no direct M-to-N relationship to justify the other sets.

Original paper, page 18

2 marks · MCQ
Report issue

Nontermination in a binary-search implementation

Control Flow & Loop Tracing

Question 84, GATE 2008: This erroneous historical C binary-search function uses integer division:
1. f(int Y[10], int x) {
2.   int i,j,k;
3.   i=0; j=9;
4.   do {
5.     k=(i+j)/2;
6.     if(Y[k]<x) i=k; else j=k;
7.   } while((Y[k]!=x) && (i<j));
8.   if(Y[k]==x) printf("x is in the array");
9.   else printf("x is not in the array");
10. }
For which input does it fail?

(A) Y=[1,2,3,4,5,6,7,8,9,10], x<10
(B) Y=[1,3,5,7,9,11,13,15,17,19], x<1
(C) Y=[2,2,2,2,2,2,2,2,2,2], x>2
(D) Y=[2,4,6,8,10,12,14,16,18,20], 2<x<20 and x even
Question 84, GATE 2008: This erroneous historical C binary-search function uses integer division:
1. f(int Y[10], int x) {
2.   int i,j,k;
3.   i=0; j=9;
4.   do {
5.     k=(i+j)/2;
6.     if(Y[k]<x) i=k; else j=k;
7.   } while((Y[k]!=x) && (i<j));
8.   if(Y[k]==x) printf("x is in the array");
9.   else printf("x is not in the array");
10. }
For which input does it fail?

(A) Y=[1,2,3,4,5,6,7,8,9,10], x<10
(B) Y=[1,3,5,7,9,11,13,15,17,19], x<1
(C) Y=[2,2,2,2,2,2,2,2,2,2], x>2
(D) Y=[2,4,6,8,10,12,14,16,18,20], 2<x<20 and x even
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. With all entries equal to 2 and x>2, every comparison takes i=k. The interval evolves (i,j)=(0,9)→(4,9)→(6,9)→(7,9)→(8,9), then k remains 8 forever.
2. Y[k]≠x and i<j both stay true, so the program fails to terminate, option C. For A, all integer keys below 10 that are present (1 through 9) can be found and keys below 1 terminate as absent; B also shrinks j to zero and terminates absent; D contains only present even values strictly between its endpoints.

Original paper, page 18

2 marks · MCQ
Report issue

Repairing the erroneous binary search

Control Flow & Loop Tracing

Question 85, GATE 2008: This erroneous historical C binary-search function uses integer division:
1. f(int Y[10], int x) {
2.   int i,j,k;
3.   i=0; j=9;
4.   do {
5.     k=(i+j)/2;
6.     if(Y[k]<x) i=k; else j=k;
7.   } while((Y[k]!=x) && (i<j));
8.   if(Y[k]==x) printf("x is in the array");
9.   else printf("x is not in the array");
10. }
Which correction makes the program work properly?

(A) Replace line 6 with if(Y[k]<x) i=k+1; else j=k−1;
(B) Replace line 6 with if(Y[k]<x) i=k−1; else j=k+1;
(C) Replace line 6 with if(Y[k]<=x) i=k; else j=k;
(D) Replace line 7 with } while((Y[k]==x) && (i<j));
Question 85, GATE 2008: This erroneous historical C binary-search function uses integer division:
1. f(int Y[10], int x) {
2.   int i,j,k;
3.   i=0; j=9;
4.   do {
5.     k=(i+j)/2;
6.     if(Y[k]<x) i=k; else j=k;
7.   } while((Y[k]!=x) && (i<j));
8.   if(Y[k]==x) printf("x is in the array");
9.   else printf("x is not in the array");
10. }
Which correction makes the program work properly?

(A) Replace line 6 with if(Y[k]<x) i=k+1; else j=k−1;
(B) Replace line 6 with if(Y[k]<x) i=k−1; else j=k+1;
(C) Replace line 6 with if(Y[k]<=x) i=k; else j=k;
(D) Replace line 7 with } while((Y[k]==x) && (i<j));
Question 85, GATE 2008: This erroneous historical C binary-search function uses integer division:
1. f(int Y[10], int x) {
2.   int i,j,k;
3.   i=0; j=9;
4.   do {
5.     k=(i+j)/2;
6.     if(Y[k]<x) i=k; else j=k;
7.   } while((Y[k]!=x) && (i<j));
8.   if(Y[k]==x) printf("x is in the array");
9.   else printf("x is not in the array");
10. }
Which correction makes the program work properly?

(A) Replace line 6 with if(Y[k]<x) i=k+1; else j=k−1;
(B) Replace line 6 with if(Y[k]<x) i=k−1; else j=k+1;
(C) Replace line 6 with if(Y[k]<=x) i=k; else j=k;
(D) Replace line 7 with } while((Y[k]==x) && (i<j));
Tap to enlarge
Your answer
Answer & solution

Answer: No fully correct option; A repairs the update but is incomplete (no official key was published)

1. Option A changes the bounds to i=k+1 or j=k−1, removing the nonprogress bug in Q84. But line 7 still tests i<j, so it can stop before examining a remaining singleton. Counterexample: Y=[1,2,3,4,5,6,7,8,9,10], x=4.
2. With A, k=4 gives j=3; k=1 gives i=2; k=2 gives i=3. Now i=j=3, so the loop exits and wrongly reports absent because its last examined value was Y[2]=3. A complete repair also changes the continuation bound to i<=j (while retaining the found test), or rewrites the usual while(i<=j) search.
3. B expands bounds, C still stalls on many absent keys, and D continues on equality instead of inequality. Thus A is the likely intended correction, but none alone makes the displayed program generally correct.

Original paper, page 18