GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 2012

65 questions

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

03:00:00
1 mark · MCQ
Report issue

Profit-maximizing production

Algebra, Equations & Number Patterns

Question 56, GATE 2012: The cost function for a product in a firm is given by 5q², where q is the amount of production. The
       firm can sell the product at a market price of 50 per unit. The number of units to be produced by
       the firm such that the profit is maximized is
        (A) 5                   (B) 10                  (C) 15                  (D) 25
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Revenue is 50q and cost is 5q², so profit is 50q−5q²=125−5(q−5)². Its maximum occurs at q=5, which is also a feasible integer quantity. Thus A.

Check: At q=0 profit is zero, whereas q=5 gives revenue 250 and cost 125, hence profit 125. Maximizing revenue alone would ignore the quadratic cost; π′(q)=50−10q and π″(q)=−10 independently verify the unique maximum.

Original paper, page 16 · Answer key

1 mark · MCQ
Report issue

Contrast introduced by despite

Vocabulary & Verbal Analogies

Question 57, GATE 2012: Choose the most appropriate alternative from the options given below to complete the following
       sentence:

        Despite several ––––––––– the mission succeeded in its attempt to resolve the conflict.
        (A) attempts            (B) setbacks            (C) meetings            (D) delegations
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Despite introduces a circumstance that would normally hinder the outcome. Setbacks hinder a mission, yet it succeeded. Attempts, meetings and delegations do not supply that direct contrast. Hence setbacks, B.

Check: The clause after the blank states a positive outcome, success. The introductory word despite signals that the blank should describe an opposing circumstance, not simply an activity that happened during the mission.

Original paper, page 16 · Answer key

1 mark · MCQ
Report issue

Meaning of mitigate

Vocabulary & Verbal Analogies

Question 58, GATE 2012: Which one of the following options is the closest in meaning to the word given below?

        Mitigate
        (A) Diminish            (B) Divulge             (C) Dedicate            (D) Denote
Tap to enlarge
Your answer
Answer & solution

Official answer: A

To mitigate is to make something less severe or intense. Diminish has the closest meaning. Divulge means disclose, dedicate means devote, and denote means signify. Hence A.

Check: For example, mitigating damage means reducing damage rather than revealing or describing it. This usage distinguishes diminish from divulge even though both can be verbs applied to an unpleasant situation.

Original paper, page 16 · Answer key

1 mark · MCQ
Report issue

Incorrect comparative construction

English Grammar & Usage

Question 59, GATE 2012: Choose the grammatically INCORRECT sentence:
        (A) They gave us the money back less the service charges of Three Hundred rupees.
        (B) This country’s expenditure is not less than that of Bangladesh.
        (C) The committee initially asked for a funding of Fifty Lakh rupees, but later settled for a lesser
            sum.
        (D) This country’s expenditure on educational reforms is very less.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Less is comparative and is not normally modified by very in standard written English. The intended correction is very low or much less, depending on whether a comparison is intended. The subtraction use of less in A, not less than in B, and lesser sum in C are valid uses. Thus D is the intended incorrect construction.

Check: The adjective low describes an absolute expenditure level and accepts very. The comparative less instead requires a comparative modifier such as much. Thus very low and much less are grammatical repairs with different meanings.

Original paper, page 16 · Answer key

1 mark · MCQ
Report issue

Relative pronoun referring to a dog

English Grammar & Usage

Question 60, GATE 2012: Choose the most appropriate alternative from the options given below to complete the following
       sentence:

        Suresh’s dog is the one ––––––––– was hurt in the stampede.
        (A) that                (B) which               (C) who                 (D) whom
Tap to enlarge
Your answer
Answer & solution

Official answer: Marks to All

Our answer: A or B (usage-dependent)

The missing relative pronoun is the subject of was hurt, so whom is unsuitable. That naturally introduces the defining clause identifying which dog; which can also introduce a defining relative clause referring to an animal, particularly in British usage. Who may be used for an individually regarded pet in some contexts. The item therefore need not have a uniquely grammatical choice. The official scoring entry is Marks to All; this language analysis is independent and is not an official explanation of that decision.

Check: To test case, replace the relative clause by “the dog was hurt”: the missing pronoun stands where a subject would stand, not where an object would stand. That eliminates whom but does not uniquely separate that and which.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

Inference from a recruitment advertisement

Reading Comprehension & Verbal Reasoning

Question 61, GATE 2012: Wanted Temporary, Part-time persons for the post of Field Interviewer to conduct personal
       interviews to collect and collate economic data. Requirements: High School-pass, must be
       available for Day, Evening and Saturday work. Transportation paid, expenses reimbursed.

        Which one of the following is the best inference from the above advertisement?
        (A) Gender-discriminatory
        (B) Xenophobic
        (C) Not designed to make the post attractive
        (D) Not gender-discriminatory
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The advertisement requests persons and lists education and availability, without restricting the applicant’s gender. Among the stated choices, not gender-discriminatory is the supported inference about the advertisement’s wording. It gives no basis for xenophobia or for assuming that the employer intends an unattractive post. This is not proof about any unstated hiring practice. Hence D.

Check: An inference must be supported by the advertisement itself. “Persons” supplies no gender restriction, and reimbursed travel is an offered benefit; neither an employer’s hidden motive nor actual discrimination can be established from this text.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

Maximum height of a parabolic arch

Algebra, Equations & Number Patterns

Question 62, GATE 2012: A political party orders an arch for the entrance to the ground in which the annual convention is
       being held. The profile of the arch follows the equation y = 2x – 0.1x² where y is the height of the
       arch in meters. The maximum possible height of the arch is
        (A) 8 meters            (B) 10 meters           (C) 12 meters           (D) 14 meters
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Complete the square: y=2x−0.1x²=10−0.1(x−10)². Since the squared term is nonnegative, the greatest height is 10 metres, attained at x=10 metres. Hence B.

Check: The parabola opens downward because its x² coefficient is negative. Its zeros are x=0 and x=20, so the vertex lies midway at x=10; substituting gives 20−10=10 metres, within the arch’s nonnegative-height span.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

Supplier conditional on a reliable component

Counting, Probability & Sets

Question 63, GATE 2012: An automobile plant contracted to buy shock absorbers from two suppliers X and Y. X supplies
       60% and Y supplies 40% of the shock absorbers. All shock absorbers are subjected to a quality test.
       The ones that pass the quality test are considered reliable. Of X’s shock absorbers, 96% are reliable.
       Of Y’s shock absorbers, 72% are reliable.

        The probability that a randomly chosen shock absorber, which is found to be reliable, is made by Y
        is
        (A) 0.288               (B) 0.334                (C) 0.667                (D) 0.720
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Let R mean reliable. P(Y∩R)=0.40×0.72=0.288 and P(R)=0.60×0.96+0.40×0.72=0.864. Bayes’ rule gives P(Y|R)=0.288/0.864=1/3. Option B lists 0.334, the closest offered value, although ordinary three-decimal rounding of 1/3 is 0.333. The exact mathematical answer is 1/3; retain official B.

Check: For a concrete frequency check, imagine 1000 components: 600 come from X and 400 from Y. Reliable counts are 576 and 288, so the conditioning pool contains 864 components, not all 1000. The numerator alone, 0.288, is the joint probability and corresponds to distractor A.

Original paper, page 17 · Answer key

2 marks · MCQ
Report issue

Changes to mean and standard deviation

Data Interpretation & Logical Reasoning

Question 64, GATE 2012: Which of the following assertions are CORRECT?

        P: Adding 7 to each entry in a list adds 7 to the mean of the list
        Q: Adding 7 to each entry in a list adds 7 to the standard deviation of the list
        R: Doubling each entry in a list doubles the mean of the list
        S: Doubling each entry in a list leaves the standard deviation of the list unchanged
        (A) P, Q                (B) Q, R                 (C) P, R                 (D) R, S
Tap to enlarge
Your answer
Answer & solution

Official answer: C

For transformed observations zi=a xi+b, the mean becomes a times the old mean plus b and standard deviation becomes |a| times the old standard deviation. Adding 7 changes the mean by 7 but leaves deviations from the mean unchanged. Doubling doubles both mean and standard deviation. P and R are true, Q and S are not general identities. Hence C.

Check: Writing μ′=aμ+b gives zi−μ′=a(xi−μ). Squaring and averaging multiplies variance by a²; taking the square root gives |a|σ. The same transformation rule holds for sample standard deviation because its denominator is unchanged.

Original paper, page 17 · Answer key

2 marks · MCQ
Report issue

Letter-pair sequence

Algebra, Equations & Number Patterns

Question 65, GATE 2012: Given the sequence of terms, AD CG FK JP, the next term is
        (A) OV                  (B) OW                   (C) PV                   (D) PW
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Write alphabet positions. First letters are 1, 3, 6, 10, with successive increases 2, 3, 4; the next is 15, O. Second letters are 4, 7, 11, 16, with successive increases 3, 4, 5; the next is 22, V. The intended continuation is OV, A. As usual for finite sequence puzzles, this uses the simplest offered incremental pattern rather than claiming mathematical uniqueness among arbitrary rules.

Check: Align the two columns separately rather than reading AD as a single word: A,C,F,J and D,G,K,P. Continuing their increasing differences requires +5 and +6 respectively, ruling out choices with P as the first letter or W as the second.

Original paper, page 17 · Answer key

1 mark · MCQ
Report issue

Validity of conditional inferences

Propositional & Predicate Logic

Question 1, GATE 2012: Consider the following logical inferences.

       I1: If it rains then the cricket match will not be played.
           The cricket match was played.
           Inference: There was no rain.
       I2: If it rains then the cricket match will not be played.
           It did not rain.
           Inference: The cricket match was played.

       Which of the following is TRUE?
       (A) Both I1 and I2 are correct inferences
       (B) I1 is correct but I2 is not a correct inference
       (C) I1 is not correct but I2 is a correct inference
       (D) Both I1 and I2 are not correct inferences
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Let R mean rain and M mean match played. The premise is R→¬M. Its contrapositive M→¬R proves inference I1. From ¬R alone one cannot infer M: the match could be cancelled for another reason. I2 denies the antecedent and is invalid. Hence B.

Check: A truth assignment supplies a counterexample to I2: set R=false and M=false. Both R→¬M and ¬R are true, but M is false. In contrast, R=true together with M=true would violate the conditional, so I1 is forced.

Original paper, page 2 · Answer key

1 mark · MCQ
Report issue

Relationship between BCNF and 3NF

Normalization & Decomposition

Question 2, GATE 2012: Which of the following is TRUE?
       (A) Every relation in 3NF is also in BCNF
       (B) A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every
           key of R
       (C) Every relation in BCNF is also in 3NF
       (D) No relation can be in both BCNF and 3NF
Tap to enlarge
Your answer
Answer & solution

Official answer: C

BCNF requires every determinant of a nontrivial functional dependency to be a superkey. This satisfies the 3NF alternative that the determinant is a superkey or the dependent attribute is prime. Therefore BCNF implies 3NF, C. The converse need not hold. Full dependence of non-prime attributes on keys describes the 2NF condition and does not by itself exclude transitive dependencies.

Check: For a concrete 3NF-not-BCNF schema, take R(A,B,C) with AB→C and C→B. Candidate keys are AB and AC. C→B violates BCNF because C is not a superkey, but satisfies 3NF because B is prime.

Original paper, page 2 · Answer key

1 mark · MCQ
Report issue

Switch fall-through and escape sequences

Control Flow & Loop Tracing

Question 3, GATE 2012: What will be the output of the following C program segment?

       char inChar = ‘A’ ;
       switch ( inChar ) {
       case ‘A’ : printf (“Choice A\ n”) ;
       case ‘B’ :
       case ‘C’ : printf (“Choice B”) ;
       case ‘D’ :
       case ‘E’ :
       default : printf ( “ No Choice” ) ; }
       (A) No Choice
       (B) Choice A
       (C) Choice A
            Choice B No Choice
       (D) Program gives no output as it is erroneous
Tap to enlarge
Your answer
Answer & solution

Official answer: Marks to All

Our answer: C under intended newline interpretation

If the first printf is interpreted as the intended standard newline escape \n, execution enters case A and falls through every following label because there is no break. It prints Choice A, a newline, then Choice B and No Choice, matching C. The printed source visibly separates the backslash and n in the first string; taking backslash-space literally is not the standard newline escape and does not justify an unconditional portable-output answer. The official key awards Marks to All. This is an independently observed printing/interpretation concern, not a claim about the authority’s reason.

Check: Switch labels are entry points, not implicit stopping points. After executing the case-A printf, the empty B label passes through to C’s printf; D and E are also empty, so execution reaches default’s printf before leaving the switch.

Original paper, page 2 · Answer key

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

NP-completeness assuming P differs from NP

Complexity & Reductions

Question 4, GATE 2012: Assuming P ≠ NP, which of the following is TRUE?
       (A) NP-complete = NP                                  (B) NP-complete ∩ P = ∅
       (C) NP-hard = NP                                      (D) P = NP-complete
Tap to enlarge
Your answer
Answer & solution

Official answer: B

If an NP-complete language belonged to P, every language in NP could be reduced to it in polynomial time and then decided in polynomial time. This would imply P=NP, contrary to the premise. Thus NP-complete∩P=∅, B. In particular, NP-complete cannot equal NP because P is a nonempty subset of NP.

Check: NP-completeness combines membership in NP with polynomial reductions from every NP language. The contradiction uses both properties: a polynomial algorithm for one complete problem would compose with those reductions to solve all NP problems.

Original paper, page 2 · Answer key

1 mark · MCQ
Report issue

Balanced search tree with exponential size

Binary Search & Balanced Trees

Question 5, GATE 2012: What is the worst-case search time in a balanced binary search tree containing n·2^n elements?
(A) Θ(n log n) (B) Θ(n·2^n) (C) Θ(n) (D) Θ(log n).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

A balanced binary search tree on N elements has worst-case search length Θ(log N). Here N=n·2n, so log₂N=log₂n+n=Θ(n). The answer is C, not Θ(log n), since n itself is not the number of elements.

Check: Search follows just one root-to-leaf branch and performs constant work per visited node. With base-two logarithms, n≤log₂(n2n)≤2n for n≥2, explicitly establishing matching linear upper and lower asymptotic bounds.

Original paper, page 2 · Answer key

1 mark · MCQ
Report issue

Boolean function from truth table

Boolean Algebra & Logic Gates

Question 6, GATE 2012: The truth table
                                                  X    Y     f (X, Y)
                                                  0    0         0
                                                  0    1         0
                                                  1    0         1
                                                  1    1         1
        represents the Boolean function
        (A) X                   (B) X + Y                  (C) X ⊕ Y              (D) Y
Tap to enlarge
Your answer
Answer & solution

Official answer: A

For X=0 both rows output 0, and for X=1 both rows output 1, regardless of Y. Thus f(X, Y)=X, option A.

Check: Using minterms, the two true rows give XȲ+XY. Factor X to obtain X(Ȳ+Y)=X. X+Y would wrongly output 1 on input 01, while XOR would wrongly output 0 on 11.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

IEEE single-precision representation of one half

Data Representation & Arithmetic

Question 7, GATE 2012: The decimal value 0.5 in IEEE single precision floating point representation has
        (A) fraction bits of 000…000 and exponent value of 0
        (B) fraction bits of 000…000 and exponent value of −1
        (C) fraction bits of 100…000 and exponent value of 0
        (D) no exact representation
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (6 steps)

Normalize 0.5 as 1.0₂×2−1. The fractional field after the implicit leading 1 is all zeros; the actual unbiased exponent is −1. Thus B uses the mathematical exponent convention. For clarity, the stored biased exponent is −1+127=126, binary 01111110, and the full 32-bit encoding is 0x3F000000. The exponent field itself is not a signed −1.

Check: The single-precision format has one sign bit, eight exponent bits, and 23 stored fraction bits. Here the sign is 0, the exponent field is 01111110, and every fraction bit is 0; binary fractions with denominator a power of two can be exact.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Children created by repeated fork

Processes, Threads & System Calls

Question 8, GATE 2012: A process executes the code
                fork();
                fork();
                fork();
        The total number of child processes created is
        (A) 3                   (B) 4                      (C) 7                  (D) 8
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (9 steps)

Assuming each fork succeeds, the first invocation creates one child, the second is executed by two processes and creates two more, and the third by four processes creates four more. There are 1+2+4=7 children, or eight total processes including the original. Hence C.

Check: Track the live population after each call as 1→2→4→8. Every new process is a child of an existing process, but the original process is not its own child, so subtracting it from the final population avoids distractor D.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Local minima on a closed interval

Calculus

Question 9, GATE 2012: Consider the function f(x) = sin(x) in the interval x ∈ [π/4, 7π/4]. The number and location(s) of the
        local minima of this function are
        (A) One, at π/2
        (B) One, at 3π/2
        (C) Two, at π/2 and 3π/2
        (D) Two, at π/4 and 3π/2
Tap to enlarge
Your answer
Answer & solution

Official answer: D

On the restricted domain [π/4, 7π/4], the left endpoint π/4 is a one-sided local minimum because sin x increases immediately to its right. The interior stationary points satisfy cos x=0: π/2 is a maximum and 3π/2 is a minimum. The right endpoint is not a minimum because sin x increases toward it from the left. Thus the restricted-domain convention yields two local minima, π/4 and 3π/2, D. If local extrema are defined to exclude endpoints, only the interior minimum remains; the official key uses the former convention.

Check: A local minimum on a domain means comparison with nearby points belonging to that domain. At the left endpoint there are no allowed comparison points to its left. At 7π/4 there are smaller nearby values to the left, so it is not a minimum.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Application-layer protocol data unit

Network Layers & Devices

Question 10, GATE 2012: The protocol data unit (PDU) for the application layer in the Internet stack is
        (A) Segment             (B) Datagram               (C) Message            (D) Frame
Tap to enlarge
Your answer
Answer & solution

Official answer: C

The generic PDU at the application layer is a message. Segment is associated with TCP at transport, datagram with connectionless network/transport use, and frame with the data-link layer. Hence C.

Check: Encapsulation gives the useful hierarchy: application message, transport segment (TCP), network datagram or packet, and link frame. The question asks for the application unit before lower-layer headers are added.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Eigenvalues of a high matrix power

Linear Algebra

Question 11, GATE 2012: Let A=[[1,1],[1,−1]]. Find the eigenvalues of A^19.
(A) ±1024 (B) ±1024√2 (C) ±4√2 (D) ±512√2.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

For A=[[1, 1],[1,−1]], direct multiplication gives A²=2I. Its eigenvalues are √2 and −√2, and powering A raises each eigenvalue to the nineteenth power. Therefore they are ±(√2)19=±29√2=±512√2. Hence D.

Check: The characteristic polynomial is det(A−λI)=(1−λ)(−1−λ)−1=λ²−2. Also A19=(A²)9A=512A, so multiplying A’s two eigenvalues by 512 gives the same result without repeated matrix multiplication.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Complement of an epsilon-NFA language

Finite Automata

Question 12, GATE 2012: Over Σ={a}, an epsilon-NFA has states s (initial, nonaccepting), t (accepting), and u (nonaccepting). Its only transitions are s --a--> t, t --ε--> u, u --ε--> s. What is the complement of its accepted language within Σ*?
(A) ∅ (B) {ε} (C) a* (D) {a,ε}.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The initial state is nonaccepting. A single a reaches the only accepting state, and two epsilon transitions return from that state through the third state to the initial state. Thus each traversal consumes one a and any positive number of a symbols is accepted; epsilon is not. The language is a⁺ and its complement within {a}*=Σ* is {ε}, B.

Check: The initial epsilon-closure is just {s}; no epsilon move leaves s. Therefore the empty input is rejected. After one a reaches t, epsilon moves can return to s, allowing any further a and accepting again at t.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Existential translation of some real numbers

Propositional & Predicate Logic

Question 13, GATE 2012: What is the correct translation of the following statement into mathematical logic?
                                           “Some real numbers are rational”
        (A) ∃x (real(x) ∨ rational(x))
        (B) ∀x (real(x) → rational(x))
        (C) ∃x (real(x) ∧ rational(x))
        (D) ∃x (rational(x) → real(x))
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Some asserts existence of an object satisfying both properties. The translation is ∃x(real(x)∧rational(x)), C. A disjunction need not satisfy both properties, a universal quantifier says all rather than some, and an implication can be true solely because its antecedent is false.

Check: The conjunction ensures that the same witness x is both real and rational. For instance, x=1/2 is such a witness. Using ∨ would allow an object satisfying just one property and would not express the stated overlap.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Atomic attributes in the basic relational model

Database Models, Architecture & ER Diagrams

Question 14, GATE 2012: Given the basic ER and relational models, which of the following is INCORRECT?
        (A) An attribute of an entity can have more than one value
        (B) An attribute of an entity can be composite
        (C) In a row of a relational table, an attribute can have more than one value
        (D) In a row of a relational table, an attribute can have exactly one value or a NULL value
Tap to enlarge
Your answer
Answer & solution

Official answer: C

The basic ER model can represent composite and multivalued attributes. In the ordinary first-normal-form relational representation, however, each cell contains a single atomic value (or the SQL-style NULL marker admitted by the options), not several values for that attribute. Therefore C is the incorrect statement. Multivalued ER attributes need a separate relational representation.

Check: An ER address can have components such as city and postcode, and an ER person can have several phone numbers. Mapping to relations separates components into columns and multiple phone values into rows of a related table rather than storing a set in one atomic cell.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

HAVING without GROUP BY and unselected grouping attributes

SQL & Queries

Question 15, GATE 2012: Which of the following statements are TRUE about an SQL query?

        P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause
        Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause
        R : All attributes used in the GROUP BY clause must appear in the SELECT clause
        S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause
        (A) P and R             (B) P and S              (C) Q and R             (D) Q and S
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Our answer: B

P is true: SELECT COUNT(*) FROM T HAVING COUNT(*)>0 is a valid aggregate query without GROUP BY, treating the input as one group. S is true: SELECT COUNT(*) FROM T GROUP BY a groups by a without selecting a. Therefore Q and R are false, and the correct pair is P and S, option B. The appended official Code A key instead prints C (Q and R). Preserve official C for scoring provenance and derived B as a documented source/key discrepancy; do not silently change either.

Check: On a table with values a=1,1,2, grouping by a while selecting only COUNT(*) returns counts 2 and 1 without exposing a. On the same nonempty table, HAVING COUNT(*)>0 without GROUP BY retains its one aggregate group. These concrete cases refute both universal claims Q and R.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Towers of Hanoi recurrence

Asymptotic Analysis & Recurrences

Question 16, GATE 2012: The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with
        n discs is
        (A) T(n) = 2T(n − 2) + 2                         (B) T(n) = 2T(n − 1) + n
        (C) T(n) = 2T(n/2) + 1                           (D) T(n) = 2T(n − 1) + 1
Tap to enlarge
Your answer
Answer & solution

Official answer: D

To move n discs, first move the top n−1 discs to the spare peg, move the largest disc once, then move those n−1 discs onto it. These two subproblems cannot be avoided in an optimal solution. Thus T(n)=2T(n−1)+1 with T(0)=0, yielding 2n−1 moves. Hence D.

Check: The largest disc cannot move until all n−1 smaller discs are off it, and afterward those smaller discs must be transferred onto it. With T(1)=1, the recurrence yields T(2)=3 and T(3)=7, consistent with 2n−1.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Bounded faces in a connected planar graph

Graph Theory

Question 17, GATE 2012: Let G be a simple undirected planar graph on 10 vertices with 15 edges. If G is a connected graph,
        then the number of bounded faces in any embedding of G on the plane is equal to
        (A) 3                   (B) 4                    (C) 5                   (D) 6
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Euler’s formula for a connected plane graph is V−E+F=2, counting the unbounded outer face. With V=10 and E=15, F=7. Exactly one face is unbounded, so the number of bounded faces is 6, D. The count is independent of the particular embedding.

Check: F=E−V+2=15−10+2=7 is the total face count. Removing the exterior gives E−V+1=6. Using seven as the bounded count would mistakenly count the outside region as a bounded face.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Average time compared with worst-case time

Asymptotic Analysis & Recurrences

Question 18, GATE 2012: Let W(n) and A(n) denote respectively, the worst case and average case running time of an
        algorithm executed on an input of size n. Which of the following is ALWAYS TRUE?
        (A) A(n) = Ω(W(n))                              (B) A(n) = Θ (W(n))
        (C) A(n) = O (W(n))                              (D) A(n) = o (W(n))
Tap to enlarge
Your answer
Answer & solution

Official answer: C

At a fixed input size, each running time is at most the maximum W(n). Taking an expectation over any input distribution preserves the inequality A(n)≤W(n). Hence A(n)=O(W(n)), C. Equality in order can occur, ruling out an always-strict little-o claim; no matching lower bound is guaranteed.

Check: Average time depends on a distribution; worst-case time does not. If every input takes n steps then A=W=n, disproving an unconditional o bound. If a rare expensive input exists, the average can be much smaller, disproving an unconditional Θ bound.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

ROM capacity for a four-bit multiplier

Combinational Circuits

Question 19, GATE 2012: The amount of ROM needed to implement a 4 bit multiplier is
        (A) 64 bits             (B) 128 bits             (C) 1 Kbits             (D) 2 Kbits
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Two four-bit operands supply eight address bits, so a ROM table needs 28=256 entries. Their product ranges up to 15×15=225 and needs eight output bits. Total ROM capacity is 256×8=2048 bits=2 Kbits, D, using binary K.

Check: The address is the concatenation of the two operands, not their sum, so four bits are insufficient to index all operand pairs. Although there are fewer distinct products than pairs, a direct ROM lookup still reserves one eight-bit output word for each of 256 addresses.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Purpose of register renaming

Pipelining & Hazards

Question 20, GATE 2012: Register renaming is done in pipelined processors
        (A) as an alternative to register allocation at compile time
        (B) for efficient access to function parameters and local variables
        (C) to handle certain kinds of hazards
        (D) as part of address translation
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Renaming assigns different physical registers to distinct logical-register definitions. This removes false dependencies due to reusing a register name, specifically WAR and WAW hazards, allowing more overlapping execution. It cannot remove a genuine RAW data dependency. Thus it handles certain pipeline hazards, C.

Check: For example, an older instruction reading logical R1 and a newer instruction writing logical R1 need not share a physical register. Giving the newer result a new physical destination avoids a write-after-read name hazard while preserving the old value for its reader.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

CDF of a two-point distribution

Probability & Random Variables

Question 21, GATE 2012: Consider a random variable X that takes values +1 and −1 with probability 0.5 each. The values of
        the cumulative distribution function F(x) at x = −1 and +1 are
        (A) 0 and 0.5           (B) 0 and 1              (C) 0.5 and 1           (D) 0.25 and 0.75
Tap to enlarge
Your answer
Answer & solution

Official answer: C

The cumulative distribution is F(x)=P(X≤x). At x=−1 it includes the mass at −1, giving 0.5. At x=+1 it includes both possible outcomes, giving 1. The requested pair is (0.5, 1), C.

Check: The full CDF is 0 for x<−1, 1/2 for −1≤x<1, and 1 for x≥1. CDFs include the probability mass at their argument; using P(X<x) instead would produce incorrect endpoint values.

Original paper, page 4 · Answer key

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Transport protocol supporting email

Transport, Congestion Control & Traffic Shaping

Question 22, GATE 2012: Which of the following transport layer protocols is used to support electronic mail?
        (A) SMTP                (B) IP                   (C) TCP                  (D) UDP
Tap to enlarge
Your answer
Answer & solution

Official answer: C

SMTP carries electronic mail at the application layer but normally relies on TCP for reliable transport. The question explicitly asks for the transport-layer protocol, so TCP, C, is correct. IP is network-layer and SMTP itself is not transport-layer.

Check: The service needs ordered, reliable delivery rather than raw IP datagrams. TCP supplies these transport properties; SMTP supplies mail-transfer commands above it. Selecting SMTP would answer which mail application protocol is used, a different layer question.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Class C network-number count

IP Addressing, Fragmentation & Address Resolution

Question 23, GATE 2012: In classful IPv4 addressing, how many Class C network numbers are allowed?
(A) 2^14 (B) 2^7 (C) 2^21 (D) 2^24.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Class C addresses begin with the three fixed bits 110. The first 24 bits identify the classful network, leaving 24−3=21 variable network-number bits. Thus the class has 221 network numbers, C. The last eight bits identify hosts within each network; this is historical classful counting, not modern CIDR allocation.

Check: There are 32 total address bits: three class-prefix bits, 21 variable network bits, and eight host bits. The question counts networks, not usable hosts, so subtracting network/broadcast host addresses from 28 is irrelevant.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Decidability and language complementation

Decidability & Computability

Question 24, GATE 2012: Which problems are decidable? (1) Does a given program ever produce an output? (2) Given a context-free language L, is its complement also context-free? (3) Given a regular language L, is its complement also regular? (4) Given a recursive language L, is its complement also recursive?
(A) 1,2,3,4 (B) 1,2 (C) 2,3,4 (D) 3,4. Complements, shown by overbars in the original, are essential.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The overbars in statements 2–4 are essential: each asks about the complement of L. Regular languages are closed under complementation (complete a DFA and exchange accepting/nonaccepting states), and recursive languages are closed under complementation (swap the outcomes of a halting decider), so 3 and 4 always answer yes. Whether an arbitrary program ever outputs is undecidable by simulating a machine and printing only if it halts. For a context-free input language, deciding whether its complement is context-free is an undecidable grammar-property problem; lack of closure alone would not suffice to prove undecidability. Thus the intended decidable entries are 3 and 4, D. For a reduction justifying statement 2, fix a CFL H over a separate alphabet Γ whose complement is the non-CFL {ak bk ck: k≥0}; H is context-free by expressing unequal counts and malformed strings as a union of CFLs. Given a CFG language L over Σ, construct the CFL K consisting of L#Γ*, Σ*#H, and all malformed strings outside Σ*#Γ*. Its complement is (Σ*−L)#(Γ*−H). If L=Σ*, this is empty and context-free. Otherwise, choosing w∉L and intersecting with regular w#Γ* leaves w#(Γ*−H), which is not context-free (remove the fixed prefix by left quotient). Therefore a test for context-freeness of complements would decide the undecidable CFG-universality problem.

Check: A closure fact gives a constant yes-answer for promises 3 and 4, hence a decider exists. For promise 2, nonclosure alone merely says some answers are no; the reduction is necessary to establish that no algorithm can decide all such instances.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Concatenations in a finite language star

Regular Expressions & Languages

Question 25, GATE 2012: Given the language L = {ab, aa, baa}, which of the following strings are in L*?

                    1)   abaabaaabaa
                    2)   aaaabaaaa
                    3)   baaaaabaaaab
                    4)   baaaaabaa
        (A) 1, 2 and 3                                   (B) 2, 3 and 4
        (C) 1, 2 and 4                                   (D) 1, 3 and 4







Q. 26 to Q. 55 carry two marks each.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

The blocks ab, aa and baa have distinct forced beginnings: at a, the next character decides ab versus aa; at b, only baa is possible. String 1 factors as ab·aa·baa·ab·aa; string 2 as aa·aa·baa·aa; and string 4 as baa·aa·ab·aa. For string 3, baaaaabaaaab, the forced parse is baa·aa·ab·aa·aa followed by a lone b, which is not a block. Its reachable complete-block prefix lengths are 0, 3, 5, 7, 9, 11, but its full length is 12. Thus exactly strings 1, 2, 4 belong to L*, C.

Check: Because no listed block is a prefix of another listed block, greedy block recognition cannot discard an alternative valid segmentation. This prefix-code property makes the forced parse failure of string 3 decisive rather than just one unsuccessful guess.

Original paper, page 5 · Answer key

2 marks · MCQ
Report issue

Graph isomorphism from cycle and branches

Graph Theory

Question 26, GATE 2012: Which candidate graph is isomorphic to the given graph? All graphs are simple and undirected. The following edge lists faithfully encode the unlabeled drawings; labels are assigned only for this transcription. Given: {01,12,23,34,40,05,06,67}, i.e. a five-cycle with one-edge and two-edge branches attached at vertex 0.
(A) {01,12,20,23,04,45,06,67}.
(B) {01,12,23,34,40,05,06,67}, drawn with a curved edge completing its cycle.
(C) {01,12,23,34,40,15,06,67}.
(D) {01,12,23,30,04,45,06,67}. Each two-digit pair denotes one undirected edge between its digits.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The given graph consists of one five-vertex cycle, with a pendant edge and a two-edge pendant path attached to the same cycle vertex. That attachment vertex has degree four; two vertices have degree one and the other five have degree two. Option B has exactly this structure: its curved outer edge completes the five-cycle, and its central degree-four vertex supports the one-edge upward branch and the two-edge lower-right branch. Map the attachment vertex, then the two distinct-length branches, then the five-cycle in order to obtain an isomorphism. A has a triangle and D a four-cycle; C attaches its pendant branches at different cycle vertices. Hence B.

Check: An isomorphism preserves cycle lengths, degrees, and which cycle vertices carry branches. Degree sequence alone is not sufficient: candidate C has a different attachment pattern. In the supplied edge encoding, the identity map from the given labels to B demonstrates every edge correspondence.

Original paper, page 6 · Answer key

2 marks · MCQ
Report issue

Conflict cycles in interleaved transactions

Transactions & Concurrency Control

Question 27, GATE 2012: Consider the following transactions with data items P and Q initialized to zero:
        T1 :read (P);
            read (Q);
            if P = 0 then Q := Q + 1 ;
            write (Q).
        T2 : read (Q);
            read (P);
            if Q = 0 then P := P + 1 ;
            write (P).
        Any non-serial interleaving of T1 and T2 for concurrent execution leads to
        (A) a serializable schedule
        (B) a schedule that is not conflict serializable
        (C) a conflict serializable schedule
        (D) a schedule for which a precedence graph cannot be drawn
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Conflicts arise on P between T1’s read and T2’s write, and on Q between T2’s read and T1’s write. If w1(Q) precedes r2(Q), then all of T1’s listed operations precede T2’s first operation, giving serial order T1, T2. Similarly, w2(P) before r1(P) forces serial order T2, T1. Therefore every genuinely nonserial interleaving has r1(P)<w2(P) and r2(Q)<w1(Q), giving both T1→T2 and T2→T1 in the precedence graph. The cycle proves it is not conflict serializable, B. The question’s qualification nonserial is necessary.

Check: The initial values affect the arithmetic outcomes but not the conflict edges, which depend on read/write order. Each transaction’s first read is before its last write; interleaving forces both cross-read-before-write relations, producing a directed two-cycle.

Original paper, page 6 · Answer key

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Bisection iterations to an exact polynomial zero

Numerical Methods

Question 28, GATE 2012: The bisection method is applied to compute a zero of the function f(x) = x⁴ – x³ – x² – 4 in the
        interval [1,9]. The method converges to a solution after ––––– iterations.
        (A) 1                    (B) 3                    (C) 5                   (D) 7
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Let f(x)=x⁴−x³−x²−4. Initially f(1)=−5 and f(9)>0. The first midpoint is 5 with f(5)=471>0, leaving [1, 5]. The second is 3 with f(3)=41>0, leaving [1, 3]. The third is 2 with f(2)=16−8−4−4=0. Therefore an exact root is found after three midpoint evaluations, B; no unspecified tolerance is needed.

Check: The sign checks select the half-interval containing a root because f is continuous. The successive midpoint sequence is 5,3,2; counting the initial endpoints as iterations would miscount the actual bisection steps.

Original paper, page 6 · Answer key

2 marks · MCQ
Report issue

Squaring edge weights and minimum spanning trees

Graph Algorithms

Question 29, GATE 2012: Let G be a weighted graph with edge weights greater than one and G′ be the graph constructed by
        squaring the weights of edges in G. Let T and T′ be the minimum spanning trees of G and G′,
        respectively, with total weights t and t′. Which of the following statements is TRUE?
        (A) T′ = T with total weight t′ = t²
        (B) T′ = T with total weight t′ < t²
        (C) T′ ≠ T but total weight t′ = t²
        (D) None of the above
Tap to enlarge
Your answer
Answer & solution

Official answer: Marks to All

Our answer: B under additional uniqueness and size assumptions

Squaring positive weights preserves every pairwise edge order and equality. Consequently it preserves the set of minimum spanning trees: any chosen MST of G remains an MST of G′, although independently chosen T and T′ can differ if the MST is not unique. For a fixed spanning tree with edge weights wi, its new weight is Σwi², while t²=Σwi²+2Σ_{i<j}w_iw_j. With at least two edges this gives t′<t²; with one edge there is equality. Thus B describes a consistent common choice of tree on at least three vertices, but the unqualified statement T′=T need not hold when multiple MSTs exist, and small graphs also matter. The official entry is Marks to All. These are independent qualifications, not a claimed official cancellation rationale.

Check: For an explicit nonuniqueness example, give every edge of a triangle weight 2. Any two edges form an MST, before and after squaring. T and T′ can therefore be chosen differently even though the collection of optimal trees is unchanged.

Original paper, page 6 · Answer key

2 marks · MCQ
Report issue

Karnaugh map with don’t-care cells

Logic Minimization & Karnaugh Maps

Question 30, GATE 2012: Minimize the following four-variable Karnaugh map. Columns ab are 00,01,11,10; rows cd are 00,01,11,10. In that order the rows are [1,X,X,1], [X,0,0,1], [0,0,0,0], [1,0,0,X]. X denotes a don’t-care; blank cells in the source denote zero. A bar denotes complement.
(A) b̄d̄ (B) b̄d̄+b̄c̄ (C) b̄d̄+ab̄c̄d (D) b̄d̄+b̄c̄+c̄d̄.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (11 steps)

Use Gray-order rows cd=00, 01, 11, 10 and columns ab=00, 01, 11, 10, treating blank cells as zero. The four corners form a wraparound group using the don’t-care at row10, column 10, giving b̄d̄. Rows00 and 01 in the two outer columns form a second wraparound group using the don’t-care at row01, column 00, giving b̄c̄. Their union covers all required ones without covering a zero. No single implicant can cover both required cells with cd=01 and cd=10 without including row11 zeros. Thus the minimal expression is b̄d̄+b̄c̄, B.

Check: Each selected four-cell group varies a and one of c,d, eliminating those variables. In the corner group b=0,d=0 stay fixed; in the rows 00/01 outer-column group b=0,c=0 stay fixed. A don’t-care may be used as 1 to enlarge a group but need not be covered.

Original paper, page 7 · Answer key

2 marks · MCQ
Report issue

FCFS and round-robin completion order

CPU Scheduling

Question 31, GATE 2012: Consider the 3 processes, P1, P2 and P3 shown in the table.

                                       Process       Arrival       Time Units
                                                     time          Required
                                       P1            0             5
                                       P2            1             7
                                       P3            3             4

        The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling
        with CPU quantum of 2 time units) are
        (A) FCFS: P1, P2, P3 RR2: P1, P2, P3                 (B) FCFS: P1, P3, P2 RR2: P1, P3, P2
        (C) FCFS: P1, P2, P3 RR2: P1, P3, P2                 (D) FCFS: P1, P3, P2 RR2: P1, P2, P3
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (2 schedules)

FCFS executes P1 from 0–5, P2 from 5–12 and P3 from 12–16, so completion order is P1, P2, P3. For quantum 2, round robin runs P1 0–2, P2 2–4, P1 4–6, P3 6–8, P2 8–10, P1 10–11, P3 11–13, P2 13–15 and 15–16. Completion times are respectively 11, 16, 13, giving P1, P3, P2. Hence C.

Check: The arrivals occur between quantum boundaries: P2 joins during P1’s first slice, and P3 joins during P2’s first slice. A preempted unfinished process returns to the tail, whereas a completed process is removed. This explains why the shorter P3 finishes before P2 under RR.

Original paper, page 7 · Answer key

2 marks · MCQ
Report issue

Lost unlock in a fetch-and-add lock

Synchronization & Concurrency

Question 32, GATE 2012: Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of
        memory location X, increments it by the value i, and returns the old value of X. It is used in the
        pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable
        initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value
        corresponds to the lock being not available.

            AcquireLock(L){
                  while (Fetch_And_Add(L,1))
                        L = 1;
            }

            ReleaseLock(L){
                  L = 0;
            }

        This implementation
        (A) fails as L can overflow
        (B) fails as L can take on a non-zero value when the lock is actually available
        (C) works correctly but may starve some processes
        (D) works correctly without starvation
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Suppose one process holds the lock with L=1. A waiter executes Fetch_And_Add, obtains old value 1 and changes L to 2, so it must execute the loop body. Before that body executes, the owner releases the lock by storing L=0. The waiter then executes its pending L=1 assignment, restoring a nonzero value even though nobody holds the lock. Subsequent tests keep failing and there need be no owner left to release it. Thus B identifies a failure even without arithmetic overflow.

Check: Atomicity protects the fetch-and-add operation itself, not the following plain assignment. The interleaving is: waiter atomically changes 1→2; owner changes 2→0; waiter changes 0→1. The last store overwrites the release and leaves no holder responsible for another release.

Original paper, page 7 · Answer key

2 marks · MCQ
Report issue

Conditional second roll of a die

Probability & Random Variables

Question 33, GATE 2012: Suppose a fair six-sided die is rolled once. If the value on the die is 1, 2, or 3, the die is rolled a
        second time. What is the probability that the sum total of values that turn up is at least 6?
        (A) 10/21               (B) 5/12                     (C) 2/3                (D) 1/6
Tap to enlarge
Your answer
Answer & solution

Official answer: B

If the first roll is 6, success occurs immediately with probability 1/6; first rolls 4 or 5 stop unsuccessfully. For first roll 1, the second must be 5 or 6 (two outcomes); for 2 it must be 4, 5, 6 (three); for 3 it must be 3, 4, 5, 6 (four). Each ordered two-roll result has probability 1/36. Total success probability is 1/6+(2+3+4)/36=15/36=5/12, B. One-roll and two-roll terminal outcomes are not equiprobable.

Check: Conditioning on the first roll gives (1/6)(2/6)+(1/6)(3/6)+(1/6)(4/6)+1/6. The second roll is not performed after 4,5,6, so treating all terminal outcomes as one uniform list gives the wrong denominator.

Original paper, page 7 · Answer key

2 marks · MCQ
Report issue

Disjoint half and quarter CIDR blocks

IP Addressing, Fragmentation & Address Resolution

Question 34, GATE 2012: An Internet Service Provider (ISP) has the following chunk of CIDR-based IP addresses available
        with it: 245.248.128.0/20. The ISP wants to give half of this chunk of addresses to Organization A,
        and a quarter to Organization B, while retaining the remaining with itself. Which of the following is
        a valid allocation of addresses to A and B?
        (A) 245.248.136.0/21 and 245.248.128.0/22
        (B) 245.248.128.0/21 and 245.248.128.0/22
        (C) 245.248.132.0/22 and 245.248.132.0/21
        (D) 245.248.136.0/24 and 245.248.132.0/21
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (14 steps)

The /20 block spans third-octet values 128–143 and has 4096 addresses. A needs 2048 addresses, a /21 aligned on a multiple of 8, and B needs 1024 addresses, a /22 aligned on a multiple of 4. Option A assigns A the range 136–143 and B the range 128–131, disjoint and within the parent block, leaving 132–135. B overlaps its blocks; C has wrong sizes and an unaligned /21; D has wrong sizes. Hence A as subnet arithmetic. The supplied 245.x address lies in reserved 240.0.0.0/4 rather than ordinary public ISP unicast space, so the scenario is hypothetical.

Check: Splitting a /20 in half adds one prefix bit, giving /21; splitting it into quarters adds two, giving /22. The allocation to A must have twice as many addresses as B, and both blocks must also satisfy their alignment boundaries.

Original paper, page 8 · Answer key

2 marks · MCQ
Report issue

Empty and full circular queue conditions

Stacks & Queues

Question 35, GATE 2012: Suppose a circular queue of capacity (n −1) elements is implemented with an array of n elements.
        Assume that the insertion and deletion operations are carried out using REAR and FRONT as array
        index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full
        and queue empty are
        (A) full: (REAR+1) mod n == FRONT               (B) full: (REAR+1) mod n == FRONT
            empty: REAR == FRONT                            empty: (FRONT+1) mod n == REAR

        (C) full: REAR == FRONT                         (D) full: (FRONT+1) mod n == REAR
            empty: (REAR+1) mod n == FRONT                 empty: REAR == FRONT
Tap to enlarge
Your answer
Answer & solution

Official answer: A

With one of n slots deliberately unused, equal FRONT and REAR denotes the initial empty queue and all subsequent empty states. The queue is full when advancing REAR by one modulo n would collide with FRONT: (REAR+1) mod n=FRONT. These conditions permit n−1 stored elements and distinguish empty from full. Hence A.

Check: For example, with n=4 the usable capacity is three. Starting at FRONT=REAR=0, three insertions advance REAR to 3; its next value would be 0, equal to FRONT, so the full test succeeds without confusing it with the empty state.

Original paper, page 8 · Answer key

2 marks · MCQ
Report issue

Static links in nested procedure activations

Runtime Environments & Parameter Passing

Question 36, GATE 2012: In a lexically scoped block language, main declares A1 and A2. A1 calls A2. A2 declares A21 and calls A21; A21 calls A1. Main calls A1, producing the live call stack main→A1(first)→A2→A21→A1(second). Which activation-record/access-link diagram is correct? Let M, X, Y, Z, W denote these five activations respectively. Arrows below are access (static) links, and FP denotes the frame pointer.
(A) X→M, Y→X, Z→Y, W→Z; FP=W.
(B) Y→M, Z→Y, W→Z; no access link is drawn for X; FP=W.
(C) Only M,X,Y,Z are drawn: X→M, Y→M, Z→Y; W is absent and FP=X.
(D) X→M, Y→M, Z→Y, W→M; FP=W.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

An access link points to the activation of the lexically enclosing procedure, not generally to the caller. Both A1 activations and A2 are declared directly in Main, so all three point to Main. A21 is declared in A2, so its access link points to that A2 activation. The frame pointer is at the latest (bottom) A1 activation. Option D depicts precisely these static links; caller links instead would form the dynamic call chain.

Check: The second A1 was called by A21, but A1’s declaration remains inside main. Dynamic recursion changes which activation is current, not the lexical parent. Thus its static link skips both A21 and A2, while its dynamic caller link would point to A21.

Original paper, page 9 · Answer key

2 marks · MCQ
Report issue

Surjections to a two-element codomain

Sets, Relations & Functions

Question 37, GATE 2012: How many onto (surjective) functions exist from an n-element set, n≥2, to a two-element set?
(A) 2^n (B) 2^n−1 (C) 2^n−2 (D) 2(2^n−2).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Each of n domain elements has two choices, giving 2n functions. A function is not onto precisely when all n elements map to one fixed codomain element. There are two such constant functions. Subtract them to obtain 2n−2 surjections, C.

Check: For n=2 the four functions are the two constants and the two bijections, leaving two onto functions. The formula 2²−2=2 passes this small-case check and explains why subtracting just one constant function is insufficient.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Length-four cycles in labeled K6

Graph Theory

Question 38, GATE 2012: Let G be a complete undirected graph on 6 vertices. If vertices of G are labeled, then the number of
        distinct cycles of length 4 in G is equal to
        (A) 15                 (B) 30                   (C) 90              (D) 360
Tap to enlarge
Your answer
Answer & solution

Official answer: Marks to All

Our answer: 45 (no listed option)

Choose the four vertices in C(6, 4)=15 ways. On a chosen set, cyclic rotations and reversal represent the same undirected cycle, so there are 4!/(4×2)=3 distinct cycles. The total is 15×3=45. None of the listed 15, 30, 90, 360 equals 45. Counting opposite orientations separately would give 90, but that is not the usual convention for distinct undirected cycles. The scoring key says Marks to All. The absent standard answer is an independent diagnosis, not an attributed official reason.

Check: For four fixed labels a,b,c,d, the three undirected cycles can be represented as a-b-c-d-a, a-b-d-c-a, and a-c-b-d-a. Fixing the first vertex removes rotations, and identifying each traversal with its reverse removes the factor two.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Merge-sorting equal-length strings

Searching, Sorting & Selection

Question 39, GATE 2012: A list of n strings, each of length n, is sorted lexicographically using mergesort. What is the worst-case running time?
(A) O(n log n) (B) O(n² log n) (C) O(n²+log n) (D) O(n²).
Tap to enlarge
Your answer
Answer & solution

Official answer: Marks to All

Our answer: B under the standard character-comparison model

Ordinary mergesort uses O(n log n) comparisons to sort n strings. A lexicographic comparison can inspect all n characters, so the standard upper bound is O(n² log n), option B. The bound is tight in the usual character-by-character implementation: strings can share a prefix of length n−O(log n) and have suitably ordered distinct suffixes, so a worst-case merge pattern performs Θ(n log n) comparisons each costing Θ(n). Treating entire strings as unit-cost keys, using LCP-aware comparison, or restricting how many distinct strings exist changes the analysis; those are extra models not specified. The official entry remains Marks to All. No official reason for awarding marks is asserted.

Check: At each merge level O(n) string comparisons may be needed, and there are Θ(log n) levels. Multiplying by the worst-case Θ(n) character work per comparison gives Θ(n² log n) under the ordinary implementation, rather than counting comparisons as constant-time operations.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Dijkstra path under strict improvements

Graph Algorithms

Question 40, GATE 2012: Run Dijkstra from S to T on the directed weighted graph below. Update a vertex’s path only when a strictly shorter path is found, never on an equal-distance tie. Which path is reported? The complete directed edge list (source,target,weight) is: (S,A,4), (S,B,3), (B,S,3), (S,D,7), (A,C,1), (B,D,4), (C,D,3), (C,E,1), (D,E,1), (D,F,5), (D,T,3), (E,G,2), (G,E,2), (E,T,4), (G,T,3), (T,F,5).
(A) SDT (B) SBDT (C) SACDT (D) SACET.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (27 steps)

After settling S, tentative distances are B=3, A=4 and D=7. Settling B offers D=3+4=7, an equal value that does not replace predecessor S. Settling A discovers C=5. Settling C discovers E=6; its edge to D offers 8 and is ignored. E is settled before D and gives T=6+4=10 with predecessor E (and G=8). D then offers T=7+3=10, which is equal and therefore cannot replace the predecessor. The path retained is S→A→C→E→T of length 10, option D. The graph’s G→E edge and T→F edge directions must not be reversed.

Check: The decisive relaxation is E→T, performed at distance 6 before D is settled at distance 7. Both propose distance 10, but only the first establishes T’s predecessor. Thus equal shortest lengths do not imply that a later equal path replaces the already stored path.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Maximum file size with double indirection

File Systems

Question 41, GATE 2012: A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, 1 indirect
        block address and 1 doubly indirect block address. The size of each disk block is 128 Bytes and the
        size of each disk block address is 8 Bytes. The maximum possible file size in this file system is
        (A) 3 KBytes
        (B) 35 KBytes
        (C) 280 KBytes
        (D) dependent on the size of the disk
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Each indirect block holds 128/8=16 addresses. The descriptor therefore reaches 8+16+16²=280 data blocks. Their payload is 280×128=35, 840 bytes=35 KiB (the option calls these KBytes). Indirection blocks are metadata and do not count as file payload. The 300 GByte disk is more than large enough. Hence B.

Check: The eight direct pointers cover 1024 bytes, the single-indirect pointer covers 16×128=2048 bytes, and double indirection covers 256×128=32768 bytes. Their sum is 35840 bytes. Multiplying 280 by KiB instead of by 128 bytes produces the 280-KByte distractor.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Compare FIFO, LRU and optimal page faults

Virtual Memory & Paging

Question 42, GATE 2012: Consider the virtual page reference string
             1, 2, 3, 2, 4, 1, 3, 2, 4, 1
        on a demand paged virtual memory system running on a computer system that has main memory
        size of 3 page frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number
        of page faults under the corresponding page replacement policy. Then
        (A) OPTIMAL < LRU < FIFO                                     (B) OPTIMAL < FIFO < LRU
        (C) OPTIMAL = LRU                                            (D) OPTIMAL = FIFO
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (3 policies)

Number the ten references from 1. FIFO faults at positions 1, 2, 3, 5, 6, 8: six faults. LRU faults at 1, 2, 3, 5, 6, 7, 8, 9, 10: nine faults. Optimal replacement faults at 1, 2, 3, 5, 8: five faults; at reference 5 evict page 2, whose next use is later than those of 1 and 3, and at reference 8 evict page 3, which is never used again. Thus OPTIMAL=5 < FIFO=6 < LRU=9, B.

Check: A hit updates recency in LRU but does not move a page in FIFO’s arrival order. This distinction first matters after reference 4, a hit on page 2: LRU remembers page 2 as recent, while FIFO still regards page 1 as the oldest arrival.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Foreign-key inclusion constraint

Relational Algebra & Calculus

Question 43, GATE 2012: Let r1 and r2 be instances of R1(A,B) and R2(C,D). B is a foreign key referencing C, and referential integrity holds. Which is always true? π denotes projection.
(A) π_B(r1)−π_C(r2)=∅ (B) π_C(r2)−π_B(r1)=∅ (C) π_B(r1)=π_C(r2) (D) π_B(r1)−π_C(r2)≠∅.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

In the classical relational model used by the relational-algebra expression, every B value in r1 must occur as a C value in r2. Thus π_B(r1) is a subset of π_C(r2), and π_B(r1)−π_C(r2)=∅, A. Referenced C values need not all occur in B, so equality and reverse containment are not guaranteed. This is the textbook non-null relational interpretation; SQL nullable foreign keys require separate treatment of NULL.

Check: For a concrete permitted instance, r1 may reference only C=1 while r2 contains C=1 and C=2. Then the forward difference is empty but the reverse difference contains 2. Referenced rows may exist even when no row currently references them.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Packet pipeline across three equal links

Physical Layer & Transmission

Question 44, GATE 2012: A source S sends a 10^6-bit file to D through two store-and-forward routers R1,R2 and three links S→R1→R2→D. Every link is 100 km long, has bandwidth 1 Mbps, and signal speed 10^8 m/s. The file is split into 1000 packets of 1000 bits each. Find the elapsed transmission-plus-propagation delay for the whole file, without additional processing or queuing delay.
(A) 1005 ms (B) 1010 ms (C) 3000 ms (D) 3003 ms.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

A packet takes 1000/10⁶ s=1 ms to transmit on each link. Each link propagation delay is 100, 000/10⁸ s=1 ms. With store-and-forward routers and no extra processing/queueing delays, the first packet reaches D after 3×(1+1)=6 ms. Subsequent packets emerge from the equal-rate pipeline 1 ms apart, so the final packet arrives at 6+999=1005 ms, A. Equivalently, total elapsed completion time is (1000+3−1)×1+3×1 ms. Summing the service time separately over all packets is not the elapsed file-transfer time asked for.

Check: For a single packet, store-and-forward requires all three serial transmissions plus all three propagations. For many packets, transmissions overlap on different links; only 999 additional packet times follow the first packet, rather than 999 complete end-to-end delays.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

TCP congestion window after timeout

Transport, Congestion Control & Traffic Shaping

Question 45, GATE 2012: Consider an instance of TCP’s Additive Increase Multiplicative Decrease (AIMD) algorithm where
        the window size at the start of the slow start phase is 2 MSS and the threshold at the start of the first
        transmission is 8 MSS. Assume that a timeout occurs during the fifth transmission. Find the
        congestion window size at the end of the tenth transmission.
        (A) 8 MSS                 (B) 14 MSS                  (C) 7 MSS               (D) 12 MSS
Tap to enlarge
Your answer
Answer & solution

Official answer: Marks to All

Our answer: No unique numerical answer asserted; conditional round models yield 8 MSS (A) or 7 MSS (C).

The official Code A key awards Marks to All; it does not supply a numerical answer or an official explanation. To expose the conventions needed, take transmissions as RTT-sized rounds: the initial windows are 2, 4, 8, 9, 10 MSS, so a timeout in round 5 sets a halved threshold of 5 MSS under the usual round model. If the post-timeout window resets to the stated slow-start value 2 and slow-start growth is capped at the threshold, rounds 6–10 end with windows 4, 5, 6, 7, 8 MSS (A). With a one-MSS timeout restart and the same threshold-capping convention, they end with 2, 4, 5, 6, 7 MSS (C). Literal doubling across the threshold gives still other round traces. ACK-level growth and whether the quoted window belongs to the beginning or end of a transmission also need a convention. These conditional examples explain why one should not present a uniquely established numerical result from this wording; they are not claimed as the exam authority’s reason for the award.

Check: The timeout point matters because halving acts on the current window, not the original threshold. With the stated round trace the current window is 10 MSS, giving a threshold of 5, after which the restart convention determines which option can follow.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Complete DFA avoiding three consecutive zeros

Finite Automata

Question 46, GATE 2012: Complete a DFA for binary strings in which every length-three substring has at most two zeros (so 000 is forbidden). All strings shorter than three are accepted. States ε (initial),0,1,00,01,10,11 are accepting; q is rejecting. Existing transitions: ε--0→0, ε--1→1, 0--0→00, 0--1→01, 1--0→10, 1--1→11, 01--0→10, 10--1→01, 11--1→11, q--0,1→q. Which list supplies the missing arcs? Each triple means (source,input,target).
(A) (00,1,00),(00,0,01),(01,1,11),(10,0,00),(11,0,10).
(B) (00,0,01),(00,1,q),(01,1,01),(10,0,11),(11,0,01).
(C) (00,1,01),(00,0,q),(01,1,01),(10,0,10),(11,0,01).
(D) (00,1,01),(00,0,q),(01,1,11),(10,0,00),(11,0,10).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The forbidden length-three substring is exactly 000. The two-symbol states retain the last two symbols until the rejecting sink q is reached. Missing transitions are δ(00, 0)=q, δ(00, 1)=01, δ(01, 1)=11, δ(10, 0)=00, and δ(11, 0)=10. These are precisely table D. Every nonsink state accepts, including the states for strings shorter than three symbols.

Check: Appending 0 to suffix 00 creates forbidden 000, requiring the sink. Appending 1 to 00 leaves suffix 01; appending 1 to 01 leaves 11; appending 0 to 10 leaves 00; appending 0 to 11 leaves 10. This derives every missing arc rather than matching only one table entry.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Recursive rooted height and wording mismatch

Tree Properties & Traversals

Question 47, GATE 2012: The source defines tree height as “the number of edges on the longest path in the tree” and gives this rooted-tree routine. Fill B1,B2:
int height(treeptr n) {
 if(n==NULL) return -1;
 if(n->left==NULL)
   if(n->right==NULL) return 0; else return B1;
 else { h1=height(n->left);
   if(n->right==NULL) return 1+h1;
   else { h2=height(n->right); return B2; }
 }
}
(A) B1=1+height(n->right), B2=1+max(h1,h2).
(B) B1=height(n->right), B2=1+max(h1,h2).
(C) B1=height(n->right), B2=max(h1,h2).
(D) B1=1+height(n->right), B2=max(h1,h2).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

For the conventional rooted height, a leaf has height 0 and every parent-to-child step adds one edge. If only the right child exists, B1 must be 1+height(n→right). If both exist, B2 must be 1+max(h1, h2). Thus A is the intended rooted-height answer and matches the official key. However, the opening sentence literally defines the longest path anywhere in the tree, which is its diameter, not necessarily its root-to-leaf height. A root with two leaf children has rooted height 1 but diameter 2; none of the listed B2 expressions returns 2 for that example. Preserve this wording defect rather than claiming the code computes the literal definition.

Check: Check a node with only a right leaf: the child returns 0 and the parent must return 1, forcing B1’s +1. With two children, choose the larger subtree height and add the edge from the current node, forcing B2’s +1.

Original paper, page 12 · Answer key

2 marks · MCQ
Report issue

Static local storage and variable shadowing

Scope, Lifetime & Storage Classes

Question 48, GATE 2012: Common code (source-era C syntax retained):
int a,b,c=0;
void prtFun(void);
main() {
 static int a=1; /* Line 1 */
 prtFun(); a+=1; prtFun();
 printf(" \n %d %d ",a,b);
}
void prtFun(void) {
 static int a=2; /* Line 2 */
 int b=1;
 a+=++b;
 printf(" \n %d %d ",a,b);
}
What three output pairs are printed?
(A) (3,1);(4,1);(4,2) (B) (4,2);(6,1);(6,1) (C) (4,2);(6,2);(2,0) (D) (3,1);(5,2);(5,2).
Question 48, GATE 2012: Common code (source-era C syntax retained):
int a,b,c=0;
void prtFun(void);
main() {
 static int a=1; /* Line 1 */
 prtFun(); a+=1; prtFun();
 printf(" \n %d %d ",a,b);
}
void prtFun(void) {
 static int a=2; /* Line 2 */
 int b=1;
 a+=++b;
 printf(" \n %d %d ",a,b);
}
What three output pairs are printed?
(A) (3,1);(4,1);(4,2) (B) (4,2);(6,1);(6,1) (C) (4,2);(6,2);(2,0) (D) (3,1);(5,2);(5,2).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Assume the snippet is meant as a storage-duration exercise with an appropriate printf declaration and a valid int main(void) supplied; the printed implicit-int main and omitted stdio declaration are not a portable modern-C complete program. The file-scope b has static storage and starts at 0. In prtFun, local b starts at 1 on each call and ++b makes it 2. Its static a starts at 2 once, then becomes 4 on the first call and 6 on the second, printing (4, 2) and (6, 2). The separate main-local a starts at 1 and is incremented to 2; main sees global b=0 and prints (2, 0). Hence C.

Check: There are three different a objects and two different b objects. The function-local a persists across calls but is not main’s a; function-local b shadows global b and never changes it. Keeping an object-by-object trace avoids incorrectly carrying local b back into main.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Automatic and register local lifetimes

Scope, Lifetime & Storage Classes

Question 49, GATE 2012: Common code (source-era C syntax retained):
int a,b,c=0;
void prtFun(void);
main() {
 static int a=1; /* Line 1 */
 prtFun(); a+=1; prtFun();
 printf(" \n %d %d ",a,b);
}
void prtFun(void) {
 static int a=2; /* Line 2 */
 int b=1;
 a+=++b;
 printf(" \n %d %d ",a,b);
}
Replace Line 1 by auto int a=1; and Line 2 by register int a=2;. What three pairs are printed?
(A) (3,1);(4,1);(4,2) (B) (4,2);(6,1);(6,1) (C) (4,2);(6,2);(2,0) (D) (4,2);(4,2);(2,0).
Question 49, GATE 2012: Common code (source-era C syntax retained):
int a,b,c=0;
void prtFun(void);
main() {
 static int a=1; /* Line 1 */
 prtFun(); a+=1; prtFun();
 printf(" \n %d %d ",a,b);
}
void prtFun(void) {
 static int a=2; /* Line 2 */
 int b=1;
 a+=++b;
 printf(" \n %d %d ",a,b);
}
Replace Line 1 by auto int a=1; and Line 2 by register int a=2;. What three pairs are printed?
(A) (3,1);(4,1);(4,2) (B) (4,2);(6,1);(6,1) (C) (4,2);(6,2);(2,0) (D) (4,2);(4,2);(2,0).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Under the same intended valid-declarations assumptions as the preceding common-data question, changing main-local a to auto does not change its lifetime within this single invocation of main: it still becomes 2. Changing prtFun-local a to register gives it automatic storage duration, not persistent storage; each call initializes it to 2. Each call also initializes local b=1, increments b to 2, adds 2 to a, and prints (4, 2). Finally main prints its a=2 and the zero-initialized global b=0. The three output pairs are (4, 2), (4, 2), (2, 0), option D. register does not guarantee physical register allocation.

Check: Storage-class changes affect persistence, not lexical scope. Both modified declarations still shadow the same globals. The register local is recreated on every invocation, so it cannot retain the first call’s value 4 when the second call starts.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Set union followed by disjunctive theta join

Relational Algebra & Calculus

Question 50, GATE 2012: Relations: A(Id,Name,Age)={(12,Arun,60),(15,Shreya,24),(99,Rohit,11)}; B(Id,Name,Age)={(15,Shreya,24),(25,Hari,40),(98,Rohit,20),(99,Rohit,11)}; C(Id,Phone,Area)={(10,2200,02),(99,2100,01)}.
How many tuples result from (A∪B) ⋈_{A.Id>40 OR C.Id<15} C? The union has the schema of A.
(A) 7 (B) 4 (C) 5 (D) 9.
Question 50, GATE 2012: Relations: A(Id,Name,Age)={(12,Arun,60),(15,Shreya,24),(99,Rohit,11)}; B(Id,Name,Age)={(15,Shreya,24),(25,Hari,40),(98,Rohit,20),(99,Rohit,11)}; C(Id,Phone,Area)={(10,2200,02),(99,2100,01)}.
How many tuples result from (A∪B) ⋈_{A.Id>40 OR C.Id<15} C? The union has the schema of A.
(A) 7 (B) 4 (C) 5 (D) 9.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Relational union eliminates the two shared tuples (15, Shreya, 24) and (99, Rohit, 11), leaving five distinct tuples with Id values 12, 15, 25, 98, 99. For C.Id=10, the condition C.Id<15 is true, so all five join. For C.Id=99, only the two union tuples with Id>40 join. There are 5+2=7 result tuples, A. This is a theta join, so each qualifying pair contributes its combined tuple.

Check: The pair count can also be checked from the union side: Ids 12,15,25 each match only C.Id=10, contributing three; Ids 98,99 each match both C rows, contributing four. The total 3+4=7 agrees with counting from the C side.

Original paper, page 14 · Answer key

2 marks · MCQ
Report issue

ALL over an empty SQL subquery

SQL & Queries

Question 51, GATE 2012: Relations: A(Id,Name,Age)={(12,Arun,60),(15,Shreya,24),(99,Rohit,11)}; B(Id,Name,Age)={(15,Shreya,24),(25,Hari,40),(98,Rohit,20),(99,Rohit,11)}; C(Id,Phone,Area)={(10,2200,02),(99,2100,01)}.
How many tuples result from this SQL query?
SELECT A.Id FROM A WHERE A.Age > ALL (SELECT B.Age FROM B WHERE B.Name='Arun');
(A) 4 (B) 3 (C) 0 (D) 1.
Question 51, GATE 2012: Relations: A(Id,Name,Age)={(12,Arun,60),(15,Shreya,24),(99,Rohit,11)}; B(Id,Name,Age)={(15,Shreya,24),(25,Hari,40),(98,Rohit,20),(99,Rohit,11)}; C(Id,Phone,Area)={(10,2200,02),(99,2100,01)}.
How many tuples result from this SQL query?
SELECT A.Id FROM A WHERE A.Age > ALL (SELECT B.Age FROM B WHERE B.Name='Arun');
(A) 4 (B) 3 (C) 0 (D) 1.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

There is no B row with Name=Arun, so the inner query returns an empty relation. A comparison quantified by ALL over an empty set is true: there is no counterexample. Consequently all three rows of A satisfy the WHERE condition, returning Id values 12, 15, 99. The count is 3, B.

Check: ALL means every returned value satisfies the comparison, not that at least one value exists. NOT EXISTS a violating subquery row is true when there are no subquery rows at all. ANY would have the opposite empty-set truth value, false.

Original paper, page 14 · Answer key

2 marks · MCQ
Report issue

FIRST and FOLLOW with nullable indirect productions

Parsing & Syntax Analysis

Question 52, GATE 2012: Grammar: S→aAbB | bAaB | ε; A→S; B→S. S is the start symbol. The partial predictive table has columns a,b,$: S row=[E1,E2,S→ε]; A row=[A→S,A→S,error]; B row=[B→S,B→S,E3]. ε is empty and $ is the input-end marker.
Find FIRST and FOLLOW of A and B.
(A) FIRST(A)=FIRST(B)={a,b,ε}; FOLLOW(A)={a,b}; FOLLOW(B)={a,b,$}.
(B) FIRST(A)={a,b,$}; FIRST(B)={a,b,ε}; FOLLOW(A)={a,b}; FOLLOW(B)={$}.
(C) FIRST(A)=FIRST(B)={a,b,ε}; FOLLOW(A)={a,b}; FOLLOW(B)=∅.
(D) FIRST(A)=FIRST(B)={a,b}; FOLLOW(A)=FOLLOW(B)={a,b}.
Question 52, GATE 2012: Grammar: S→aAbB | bAaB | ε; A→S; B→S. S is the start symbol. The partial predictive table has columns a,b,$: S row=[E1,E2,S→ε]; A row=[A→S,A→S,error]; B row=[B→S,B→S,E3]. ε is empty and $ is the input-end marker.
Find FIRST and FOLLOW of A and B.
(A) FIRST(A)=FIRST(B)={a,b,ε}; FOLLOW(A)={a,b}; FOLLOW(B)={a,b,$}.
(B) FIRST(A)={a,b,$}; FIRST(B)={a,b,ε}; FOLLOW(A)={a,b}; FOLLOW(B)={$}.
(C) FIRST(A)=FIRST(B)={a,b,ε}; FOLLOW(A)={a,b}; FOLLOW(B)=∅.
(D) FIRST(A)=FIRST(B)={a,b}; FOLLOW(A)=FOLLOW(B)={a,b}.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (14 steps)

S can start with a or b or derive ε; A→S and B→S therefore give FIRST(A)=FIRST(B)={a, b,ε}. In S→aAbB and S→bAaB, A is immediately followed by b and a respectively, so FOLLOW(A)={a, b}. Since S is the start symbol, $ belongs to FOLLOW(S). A→S passes FOLLOW(A) into FOLLOW(S), giving FOLLOW(S)={a, b,$}. B occurs at the end of each nonempty S production, so it inherits FOLLOW(S), and FOLLOW(B)={a, b,$}. B→S adds no new symbols. These are option A.

Check: Nullable propagation is essential: A and B derive ε through S even though neither has an explicit ε production. FOLLOW sets require a fixed point because A→S and B→S propagate symbols back to S, which then propagates them to trailing B.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Predictive-table conflicts in a non-LL(1) grammar

Parsing & Syntax Analysis

Question 53, GATE 2012: Grammar: S→aAbB | bAaB | ε; A→S; B→S. S is the start symbol. The partial predictive table has columns a,b,$: S row=[E1,E2,S→ε]; A row=[A→S,A→S,error]; B row=[B→S,B→S,E3]. ε is empty and $ is the input-end marker.
Fill E1,E2,E3.
(A) E1={S→aAbB,A→S}; E2={S→bAaB,B→S}; E3={B→S}.
(B) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={S→ε}.
(C) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={B→S}.
(D) E1={A→S,S→ε}; E2={B→S,S→ε}; E3={B→S}.
Question 53, GATE 2012: Grammar: S→aAbB | bAaB | ε; A→S; B→S. S is the start symbol. The partial predictive table has columns a,b,$: S row=[E1,E2,S→ε]; A row=[A→S,A→S,error]; B row=[B→S,B→S,E3]. ε is empty and $ is the input-end marker.
Fill E1,E2,E3.
(A) E1={S→aAbB,A→S}; E2={S→bAaB,B→S}; E3={B→S}.
(B) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={S→ε}.
(C) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={B→S}.
(D) E1={A→S,S→ε}; E2={B→S,S→ε}; E3={B→S}.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

For M[S, a], FIRST(aAbB) supplies S→aAbB; because a belongs to FOLLOW(S), the nullable alternative also supplies S→ε. Similarly M[S, b] contains both S→bAaB and S→ε. At M[B,$], B→S is inserted because S is nullable and $ belongs to FOLLOW(B). Thus E1={S→aAbB, S→ε}, E2={S→bAaB, S→ε}, E3={B→S}, exactly C. The two multiple-production cells are FIRST/FOLLOW conflicts, proving this grammar is not LL(1). The source’s phrase “LL(1) parsing table” should be understood as the table-construction procedure, not as certification that the grammar admits deterministic LL(1) parsing.

Check: Each parsing-table row can contain only productions whose left-hand side is that row’s nonterminal. This immediately eliminates options inserting A→S or B→S into S’s row, and eliminates S→ε as the B-row entry E3.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Tag bits in a four-way cache

Cache Memory

Question 54, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
How many address tag bits are there?
(A) 11 (B) 14 (C) 16 (D) 27.
Question 54, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
How many address tag bits are there?
(A) 11 (B) 14 (C) 16 (D) 27.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (7 steps)

Using binary cache units, 256 KiB/32 bytes=8192 cache lines. Four lines per set give 2048=2¹¹ sets, so the set index uses 11 bits. A 32-byte block requires 5 byte-offset bits. The remaining address bits are tag bits: 32−11−5=16, C.

Check: The address splits as [16 tag bits | 11 set bits | 5 byte-offset bits]. Associativity reduces the number of sets relative to the number of lines, so using 13 line-index bits would incorrectly treat the cache as direct mapped.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Cache directory size including per-line metadata

Cache Memory

Question 55, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
What is the tag-directory size?
(A) 160 Kbits (B) 136 Kbits (C) 40 Kbits (D) 32 Kbits.
Question 55, GATE 2012: A 256 KByte, four-way set-associative write-back cache uses 32-byte blocks and 32-bit byte addresses. Every tag-directory entry holds the tag plus 2 valid bits, 1 modified bit, and 1 replacement bit.
What is the tag-directory size?
(A) 160 Kbits (B) 136 Kbits (C) 40 Kbits (D) 32 Kbits.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (9 steps)

There are 256×1024/32=8192 cache lines and hence 8192 tag-directory entries. The preceding calculation gives a 16-bit address tag. Each entry additionally has the explicitly specified 2 valid bits, 1 modified bit and 1 replacement bit, for 16+2+1+1=20 bits. The directory is 8192×20=163, 840 bits=160 Kibits, option A (printed as Kbits). Count entries per cache line, not per set; the problem explicitly assigns the replacement bit per entry.

Check: Four ways do not mean only one tag per set: each way stores a distinct block and needs its own tag and metadata. Equivalently, 2048 sets×4 entries/set×20 bits/entry=163840 bits, confirming the per-line calculation.

Original paper, page 15 · Answer key