GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 2020

65 questions

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

03:00:00
1 mark · MCQ
Report issue

English Grammar & Usage

Question 1, GATE 2020: Complete: Raman is confident of speaking English ___ six months as he has been practising regularly ___ the last three weeks. Options: A during, for; B for, since; C for, in; D within, for.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

Read each blank according to its time role. The first says when the desired ability will have been acquired: “within six months” means no later than the end of that period. The second follows present-perfect continuous “has been practising” and specifies a duration, so it takes “for.” “Since” would require a starting point such as “since Monday,” not “the last three weeks.” “During” locates an event inside a period but does not express this deadline. Substitution produces the coherent sentence with D.

Derivation and answer

Within six months sets a future deadline, while for the last three weeks describes the duration of ongoing practice. Thus within, for, D.

Original paper, page 1 · Answer key

1 mark · MCQ
Report issue

Vocabulary & Verbal Analogies

Question 2, GATE 2020: Complete: His knowledge of the subject was excellent but his classroom performance was ___. Options: A extremely poor; B good; C desirable; D praiseworthy.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

The conjunction “but” signals an unexpected contrast between strong subject knowledge and classroom results. A negative description supplies that contrast. All three distractors, good, desirable and praiseworthy, positively evaluate the performance and therefore continue rather than contrast the first clause. This is a semantic fit question, not a question of grammatical adjective placement: all four phrases can follow “was,” but only A matches the intended contrast.

Derivation and answer

But signals a contrast with excellent knowledge. Extremely poor supplies that contrast for classroom performance; the positive alternatives do not. Thus A.

Original paper, page 1 · Answer key

1 mark · MCQ
Report issue

Vocabulary & Verbal Analogies

Question 3, GATE 2020: Complete the analogy Cook : Cook :: Fly : ___. Options: A Flyer; B Flying; C Flew; D Flighter.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

Identify the relationship before trying to match word endings. In the left pair, the same spelling has two grammatical roles: to cook is the action, and a cook is the person doing it. Apply action→agent to fly. A flyer is someone or something that flies. Flying names the activity or participle, flew is a past-tense verb, and flighter is not the standard agent noun. Thus the matching role, rather than identical spelling, decides A.

Derivation and answer

The first cook is an action and the second cook is the person performing it. The corresponding person associated with flying is a flyer, A.

Original paper, page 1 · Answer key

1 mark · MCQ
Report issue

Reading Comprehension & Verbal Reasoning

Question 4, GATE 2020: Passage essentials: Melting glaciers supply too much or too little freshwater to billions dependent on them. Without deep emissions cuts, a UN report estimates at least 30% of northern-hemisphere surface permafrost could melt by century end. Rising seas could displace billions, so nations should rethink their carbon footprint for political concerns, if not environmental ones. What follows? A Nations have no environmental concerns; B Nations are responsible for providing freshwater to billions; C Billions are responsible for man-made emissions; D Billions are affected by melting glaciers.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

An inference must be supported by the passage without importing extra claims. Water-supply changes already establish an effect on people, while displacement adds another effect. The phrase “if not for environmental ones” urges political motivation even where environmental motivation is insufficient; it does not assert that every nation lacks environmental concerns. Dependence on freshwater does not establish which institution must supply it, and mention of human emissions does not identify all affected people as emitters. Hence only D is warranted.

Derivation and answer

The passage explicitly connects melting glaciers to billions of people who depend on them and to displacement from rising seas. Thus billions are affected, D. It does not establish the stronger claims about lack of environmental concern or responsibility in the other choices.

Original paper, page 1 · Answer key

1 mark · MCQ
Report issue

Data Interpretation & Logical Reasoning

Question 5, GATE 2020: Find the cheapest directed route from 1 to 2, counting edge costs and tolls. Complete figure equivalent, edge:rupees: 1→a:200, a→c:100, c→2:100, a→2:200, 1→b:300, b→2:200, 1→f:100, f→b:0, b→d:0, d→e:100, f→e:100, e→2:200. Tolls: a,e cost 200 each; b,c,d,f cost 100 each. Options: A 1-a-c-2; B 1-f-b-2; C 1-b-2; D 1-f-e-2.
Question 5, GATE 2020: Find the cheapest directed route from 1 to 2, counting edge costs and tolls. Complete figure equivalent, edge:rupees: 1→a:200, a→c:100, c→2:100, a→2:200, 1→b:300, b→2:200, 1→f:100, f→b:0, b→d:0, d→e:100, f→e:100, e→2:200. Tolls: a,e cost 200 each; b,c,d,f cost 100 each. Options: A 1-a-c-2; B 1-f-b-2; C 1-b-2; D 1-f-e-2.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

A useful accounting rule is route cost = sum of directed edge weights + sum of tolls at intermediate vertices. Do not confuse a zero-cost edge with a free toll booth. For B, the edges cost 100+0+200=300 and booths f,b add 100+100=200, totaling 500. For A, edges total 400 and booths add 300, totaling 700. C totals 500+100=600 and D totals 400+300=700. For completeness, route 1-a-2 costs 400+200=600. A detour b-d-e-2 costs 0+100+200 plus tolls d,e instead of direct b-2 at 200, so it cannot improve a route already reaching b. This checks the global minimum as well as the listed options.

Derivation and answer

Include both edge costs and every visited toll. The listed routes cost: 1-a-c-2=200+100+100+200+100=700; 1-f-b-2=100+0+200+100+100=500; 1-b-2=300+200+100=600; 1-f-e-2=100+100+200+100+200=700. Thus B.

Original paper, page 2 · Answer key

2 marks · MCQ
Report issue

Reading Comprehension & Verbal Reasoning

Question 6, GATE 2020: Passage essentials: GST, introduced in India in 2017, taxes the supply of goods and services, subsumes all indirect taxes except a few, is destination-based rather than imposed at origin, and has state, central and Union Territory components. Which inference follows? A GST taxes production; B GST includes all indirect taxes; C GST has no UT-specific component; D GST is imposed where goods and services are used.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

Separate the passage’s definition from outside knowledge of tax law. “Destination-based” is immediately explained by taxation where goods/services are used, giving D directly. A replaces destination with production/origin, contradicting that explanation. B drops the qualification “except few,” turning a qualified claim into a universal one. C denies the explicitly mentioned Union Territory component. The date of introduction and component names provide context but are not needed to calculate anything.

Derivation and answer

The passage calls GST destination-based and says it is imposed where goods and services are used. This directly supports D. The other options contradict its exception for some indirect taxes or its stated UT component, or substitute production for consumption.

Original paper, page 2 · Answer key

2 marks · MCQ
Report issue

Algebra, Equations & Number Patterns

Question 7, GATE 2020: If P=3, R=27 and T=243, find Q+S using the intended alphabetic number pattern. Options: A 40; B 80; C 90; D 110.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

Fill in consecutive letters rather than interpolating by arithmetic differences: P,Q,R,S,T correspond to 3¹,3²,3³,3⁴,3⁵. Consecutive multiplication by 3 produces Q=9 and S=81, so their sum is 90. As a consistency check, moving two letters multiplies the value by 9: 3→27→243. The inference is the intended simple puzzle rule, not uniqueness among all functions on letters; infinitely many contrived rules fit the three supplied values.

Derivation and answer

The intended alphabetic sequence P, Q, R, S, T takes successive powers of 3: 3, 9, 27, 81, 243. Hence Q+S=9+81=90, C. As in sequence puzzles, this uses the simple geometric pattern; three specified values do not mathematically determine a unique arbitrary assignment.

Original paper, page 2 · Answer key

2 marks · MCQ
Report issue

Geometry & Spatial Aptitude

Question 8, GATE 2020: An annulus has inner radius a and outer radius b. Its painted region comprises n nonoverlapping equal disks, each tangent to both concentric boundaries (figure equivalent). Find unpainted area. Options: A π[(b²−a²)−(n/4)(b−a)²]; B π[(b²−a²)−n(b−a)²]; C π[(b²−a²)+(n/4)(b−a)²]; D π[(b²−a²)+n(b−a)²].
Question 8, GATE 2020: An annulus has inner radius a and outer radius b. Its painted region comprises n nonoverlapping equal disks, each tangent to both concentric boundaries (figure equivalent). Find unpainted area. Options: A π[(b²−a²)−(n/4)(b−a)²]; B π[(b²−a²)−n(b−a)²]; C π[(b²−a²)+(n/4)(b−a)²]; D π[(b²−a²)+n(b−a)²].
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

Let ρ be a painted disk’s radius and d the distance from the common annulus center to its center. Internal tangency to the outer circle gives d+ρ=b; external tangency to the inner circle gives d−ρ=a. Subtracting yields 2ρ=b−a. Therefore one disk has area π(b−a)²/4. The nonoverlap shown in the figure lets us multiply by n. The annular area is the larger circle’s area minus the smaller circle’s area. Subtract the painted area, not add it: this rejects C,D. B mistakenly treats the annulus thickness as a radius rather than a diameter.

Derivation and answer

Each painted disk touches both concentric boundaries, so its diameter is b−a and radius(b−a)/2. For n nonoverlapping disks as pictured, total painted area is nπ(b−a)²/4. Subtract from annular areaπ(b²−a²), givingπ[(b²−a²)−n(b−a)²/4], A. The options continue on physical page3.

Original paper, page 2 · Answer key

2 marks · MCQ
Report issue

Geometry & Spatial Aptitude

Question 9, GATE 2020: Two perpendicular lines in the xy-plane make acute angles α and β with the x-axis. Find α+β. Options: A 60°; B 90°; C 120°; D 180°.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

A line has no preferred direction, so use its smaller angle with the x-axis. If one line has inclination θ with 0<θ<90°, its perpendicular has inclination θ+90°, whose acute angle to the x-axis is 180°−(θ+90°)=90°−θ. The sum is therefore 90°. Equivalently, for nonvertical perpendicular lines m1 m2=−1, so their acute-angle tangents are reciprocals. The word “acute” excludes the horizontal/vertical endpoint case.

Derivation and answer

For perpendicular non-axis-aligned lines, their acute angles with the x-axis are complementary: if one isθ, the other is 90°−θ. Hence α+β=90°, B.

Original paper, page 3 · Answer key

2 marks · MCQ
Report issue

Data Interpretation & Logical Reasoning

Question 10, GATE 2020: Bar-chart equivalent: company revenues for 2014, 2015, 2016, 2017, 2018 are respectively 500,700,800,600,400 million rupees. Expenditure is 500 million each year. Find aggregate profit/loss as a percentage of total expenditure. Options: A 16.67% profit; B 16.67% loss; C 20% profit; D 20% loss.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

Compute aggregate figures before taking a percentage. The annual profits in millions are 0,200,300,100,−100, whose sum is 500. Total expenditure is 2500, so 100×500/2500=20%. The alternative 16.67% arises from dividing by revenue 3000; that is a profit margin, not the requested return on expenditure. The positive aggregate identifies profit rather than loss. Because expenditures happen to be equal, averaging annual expenditure-based percentages also works here, but adding the money amounts is the safer general method.

Derivation and answer

Visually reading the bars gives revenues500, 700, 800, 600, 400 million, totaling 3000. Total expenditure is 5·500=2500. Profit is 500, and profit/expenditure is 500/2500=20%, C.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Calculus

Question 1, GATE 2020: Which functions increase throughout [0,1]? I e^(−x); II x²−sin x; III √(x³+1). Options: A III only; B II only; C II and III; D I and III.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

For a differentiable function, a negative derivative anywhere in the interior rules out increasing throughout the interval. Function I has derivative −e−x<0 everywhere. For II, continuity of 2x−cos x and its value −1 at zero imply negativity on some interval immediately to the right of zero. Function III has derivative 3x²/(2√(x³+1)), positive for x>0 and zero only at the endpoint. A zero derivative at one endpoint does not prevent strict increase: for x<y, x³+1<y³+1, and square root preserves this inequality.

Derivation and answer

The derivative of e−x is negative. The derivative of x²−sin x is 2x−cos x, which is−1 at 0 and remains negative nearby, so that function is not increasing throughout the interval. The third function√(x³+1) is strictly increasing on[0, 1] since both x³ and square root are strictly increasing there. Only III, A.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 2, GATE 2020: For parameters a,b, both printed as ω(1), T(n)=T(n^(1/a))+1 and T(b)=1. Choose the printed asymptotic expression. Options: A Θ(log_a(log_b n)); B Θ(log_(ab) n); C Θ(log_b(log_a n)); D Θ(log_2(log_2 n)). No cutoff for inputs below b is specified; retain this qualification.
Question 2, GATE 2020: For parameters a,b, both printed as ω(1), T(n)=T(n^(1/a))+1 and T(b)=1. Choose the printed asymptotic expression. Options: A Θ(log_a(log_b n)); B Θ(log_(ab) n); C Θ(log_b(log_a n)); D Θ(log_2(log_2 n)). No cutoff for inputs below b is specified; retain this qualification.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A under the intended recurrence-depth convention

Worked explanation

Unroll without changing the logarithm bases: T(n)=T(n1/a²)+2=…=T(n1/a^j)+j. Exact termination at b requires n1/a^j=b, or (ln n)/aj=ln b. Thus aj=ln n/ln b=logb n. Taking log base a yields the expression in A, with total value j+1. This derivation assumes a,b are held fixed during a recursion chain, even if their initial values depend on the original input size. It does not justify swapping a and b as in C. The rigorous cutoff-based estimate is Θ(1+max(0,loga(logb n))) in the regime n>1,a>1,b>1, with ceiling for integral depth.

Derivation and answer

After j recursive calls the argument is n1/a^j. Equating it to b gives aj=logb n, hence j=loga(logb n) and T(n)=j+1 on exact-depth inputs. With a base cutoff at n≤b, the corresponding depth is max(0, ceil(loga(logb n))) for fixed call parameters a, b>1. This gives intended A when the depth is bounded below away from 0, in particular when it grows. Qualification: the source says a, b are ω(1), not fixed constants, and gives only T(b)=1. Arbitrary inputs need a cutoff/rounding convention, and the additive 1 cannot always be dropped when parameters vary. For example a=n, b=log n gives depth 1 under the cutoff, but loga(logb n) tends to 0. Thus the printed unconditional Theta claim requires a parameter regime/termination convention.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Input/Output, DMA & Interrupts

Question 3, GATE 2020: Which statements are true? I Daisy chaining assigns interrupt priority. II For a vectored interrupt CPU polls to identify the source. III Polling periodically checks device status bits. IV During DMA the CPU and DMA controller can simultaneously be masters of the bus. Options: A I,II; B I,IV; C I,III; D III only.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

In a daisy chain an interrupt acknowledge passes through devices in order; the first requesting device captures it, establishing priority. In vectored handling, vector information selects the service routine, avoiding the source-identification poll claimed in II. Polling explicitly means testing device status, establishing III. DMA can overlap CPU computation that does not require the shared bus, but that is different from two simultaneous masters driving one shared bus. The conventional bus arbitration model permits one current owner, making IV false.

Derivation and answer

Daisy chaining imposes interrupt priority, and polling periodically examines device status, so I and III are true. A vectored interrupt supplies identification/vector information rather than requiring source polling. A single shared bus has one current master, so CPU and DMA controller cannot simultaneously master that bus. Thus C in the depicted conventional bus model.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Datapath & Control Unit

Question 4, GATE 2020: Execute R0←R1+R2 on a single-bus datapath. Figure equivalent: bus connects MAR, MDR, IR, PC and R0–R7; one ALU input comes directly from bus, the other from TEMP1 (loaded from bus); ALU output enters TEMP2, which can drive bus. MAR addresses memory; MDR exchanges memory data. PC increment is handled. Steps (r read,w write): 1 R2_r,TEMP1_r,ALU_add,TEMP2_w; 2 R1_r,TEMP1_w; 3 PC_r,MAR_w,MEM_r; 4 TEMP2_r,R0_w; 5 MDR_r,IR_w. Correct order? A 2,1,4,5,3; B 1,2,4,3,5; C 3,5,2,1,4; D 3,5,1,2,4.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

Follow data dependencies rather than memorizing an instruction cycle. The instruction register cannot receive the requested instruction before the PC address has been sent to memory and the result has reached MDR, so 3 precedes 5. To add two register values on one bus, first save one operand in TEMP1: step 2 must precede step 1. The ALU result is latched into TEMP2 before R0 can receive it, so 1 precedes 4. Fetch followed by execution therefore gives 3→5→2→1→4. D violates the TEMP1 dependency; A,B attempt execution before the fetch sequence.

Derivation and answer

Fetch the instruction with PC→MAR and memory read(step3), then MDR→IR(step5). Load R1 into TEMP1(step2), add R2 through the bus with TEMP1 and store the result in TEMP2(step1), then TEMP2→R0(step4). Therefore3, 5, 2, 1, 4, C.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Binary Search & Balanced Trees

Question 5, GATE 2020: A BST preorder is 15,10,12,11,20,18,16,19. Find postorder. A 10,11,12,15,16,18,19,20; B 11,12,10,16,19,18,20,15; C 20,19,18,16,15,12,11,10; D 19,16,18,20,11,12,10,15.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (19 steps)

Worked explanation

Preorder lists root, left subtree, right subtree; the BST ordering tells us where the left subtree ends. The reconstructed tree has edges 15→10(left),15→20(right),10→12(right),12→11(left),20→18(left),18→16(left),18→19(right). Postorder recursively visits left, right, root, hence the entire left subtree appears before the right subtree and 15 must be last. Option A is sorted inorder, C follows a different ordering, and D puts the right subtree before the left. This explicit edge list also makes the reconstruction checkable without a picture.

Derivation and answer

Root15 splits the preorder into left10, 12, 11 and right20, 18, 16, 19. On the left, 10 has right child12 with left child11, giving postorder 11, 12, 10. On the right, 20 has left child18 with children 16, 19, giving 16, 19, 18, 20. Append the root: 11, 12, 10, 16, 19, 18, 20, 15, B.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Binary Search & Balanced Trees

Question 6, GATE 2020: What is the worst-case time to insert n² elements into an AVL tree initially containing n elements? A Θ(n⁴); B Θ(n²); C Θ(n² log n); D Θ(n³).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

With m nodes, an AVL tree has height Θ(log m); locating an insertion position and propagating height changes take O(log m), while rotations do not introduce a larger order. During the sequence, m=n+i for 0≤i<n². Thus the total upper bound is Σ O(log(n+i))≤n² O(log(n+n²))=O(n² log n). For ordinary comparison-based insertion of distinct keys, an AVL tree’s external search paths have logarithmic depth; in particular an adversarial sequence can repeatedly force logarithmic work. A constant fraction of n² operations therefore contributes Ω(n² log n). Do not multiply by an extra n for rebalancing.

Derivation and answer

Throughout the n² insertions the AVL size lies between n and n+n², so each logarithmic insertion is O(log n). Their total is O(n²log n), and worst-case searches over a constant fraction of the later insertions require Ω(log n) each. Hence Θ(n²log n), C.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Regular Expressions & Languages

Question 7, GATE 2020: Which regular expression denotes binary strings with an odd number of 1s? Here + means union. A ((0+1)*1(0+1)*1)*10*; B (0*10*10*)*0*1; C 10*(0*10*10*)*; D (0*10*10*)*10*. The official answer is MTA, not a letter.
Tap to enlarge
Your answer
Answer & solution

Official answer: MTA

Our answer: No correct option; official MTA

Worked explanation

Checking a claimed regular expression needs both inclusions: every generated string must have odd parity, and every odd-parity string must be generated. A violates soundness because the arbitrary (0+1)* portions can introduce extra 1s: use the repeated block 111 and final 1 to generate 1111. B violates completeness on 10, because it ends in a mandatory 1. C violates completeness on 01, because its first symbol is 1. In D, zero repeated blocks give a leading 1; a positive number supplies at least two 1s before the final mandatory one, so 01 is again missing. In the corrected teaching expression 0*(10*10*)*10*, the repeated block contributes pairs of 1s and the final block contributes one; the surrounding zero runs allow arbitrary gaps and ends. This correction is explanatory only and does not replace official MTA scoring.

Derivation and answer

Each offered expression fails. A accepts 1111: choose 111 for one repeated block and the final 1, producing an even number of ones. B always ends in 1 and misses the valid string 10. C begins in 1 and misses 01. D also misses 01: zero repetitions begin with 1, while any positive repetition contributes at least two ones before the final 1. A correct expression is 0*(10*10*)*10*. The official key awards MTA, which is preserved rather than mapped to a letter.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 8, GATE 2020: Test I: if L1∪L2 is regular, both L1 and L2 must be regular. II: regular languages are closed under infinite union. Options: A I only; B II only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

Closure under a binary operation gives the forward implication: if both languages are regular then their union is regular. It does not give the converse. For a concrete converse counterexample choose L={an bn:n≥0} over {a,b}, and its complement. L is nonregular; its complement is nonregular because otherwise closure under complement would make L regular. Their union is the regular language {a,b}*. For infinite union, each singleton {an bn} has a finite automaton, but the union over all n is L. Finite union closure cannot be extended to countably many automata by treating an infinite construction as a finite automaton.

Derivation and answer

For I, take a nonregular language L and its complement; their union isΣ*, regular, although neither component is regular. For II, each singleton{an bn} is regular but their union over n≥0 is not. Both assertions are false, D.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 9, GATE 2020: Test I: symbol tables are accessed only in lexical and syntax analysis. II: supporting recursion necessarily requires heap allocation. III: declaration-before-use errors are detected during syntax analysis. Options: A I only; B I and III; C II only; D none.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

A symbol table records information such as declarations, types and locations. Type checking needs that information in semantic analysis, and code generation may need offsets and storage locations, so “only” makes I false. Recursive calls need distinct activation records, but their last-in-first-out lifetimes are exactly what a runtime stack handles; a heap is not logically necessary. Finally, syntax checks whether token sequences fit grammatical productions, whereas whether a particular name has already been declared depends on the binding environment. That contextual condition belongs to semantic analysis in the conventional compiler-phase distinction used here.

Derivation and answer

Semantic analysis and code generation also consult symbol-table information, refuting I. Ordinary nested recursion can be supported with stack activation records and does not inherently need a heap, refuting II. Declaration-before-use is a contextual semantic condition, not ordinary context-free syntax checking, refuting III. Thus none, D.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Pushdown Automata

Question 10, GATE 2020: L={a^n:n≥0}∪{a^n b^n:n≥0}. Test I L is deterministic context-free; II L is context-free but not deterministic context-free; III L is not LL(k) for any k. Options: A I only; B II only; C I and III; D III only.
Question 10, GATE 2020: L={a^n:n≥0}∪{a^n b^n:n≥0}. Test I L is deterministic context-free; II L is context-free but not deterministic context-free; III L is not LL(k) for any k. Options: A I only; B II only; C I and III; D III only.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

A deterministic pushdown recognizer can use an accepting a-phase, initially with a bottom marker. Each a pushes one marker. Seeing the first b changes permanently to a b-phase and pops one marker per b; a b with no marker, or any later a, rejects. At end-of-input it accepts either the a-phase (including ε) or the b-phase with exactly the bottom marker left. This establishes I constructively and rejects II. The familiar non-LL(k) separation is a language-level result: do not infer it merely because the obvious grammar S→A|B, A→aA|ε, B→aBb|ε has a FIRST-set conflict. The shared-prefix argument below explains the obstruction; a full formal proof that no equivalent LL(k) grammar exists requires the bounded-lookahead language theorem, not just testing that one grammar. III is the standard classification used by the official answer.

Derivation and answer

A DPDA pushes while reading a symbols, then pops one per b after the first b. It accepts an all-a input by final state at end-of-input, and accepts an an bn input when the count matches, so the language is deterministic context-free. The standard strict-separation example a* union {an bn} is not an LL(k) language for any finite k: arbitrarily long common a-prefixes postpone the distinction between an unmatched all-a ending and the matching b-suffix beyond any fixed lookahead. A predictive leftmost derivation cannot use that late distinction to discharge an unbounded number of already predicted matching b obligations. This is the language-level bounded-lookahead obstruction, not merely an observation that one displayed grammar is not left-factored. Thus I and III, C.

Original paper, page 6 · Answer key

1 mark · MCQ
Report issue

Memory Allocation & Segmentation

Question 11, GATE 2020: Allocate one process into a memory hole, with no exact fit. Which comparison of newly remaining holes is always true? A first-fit remainder > next-fit remainder; B worst-fit remainder > first-fit remainder; C best-fit remainder ≤ first-fit remainder; D next-fit remainder ≤ best-fit remainder.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

Let p be the process size and let H be the set of adequate hole sizes. Best fit chooses hB=min H. If first fit chooses hF∈H, then hB≤hF, and subtracting p gives hB−p≤hF−p. This is exactly C and allows equality. For counterexamples to strict claims A and B, take a single adequate hole: all policies choose it, so no remainder is strictly larger. D fails with adequate holes of sizes 10 and 20 for a process of size 6 when next fit chooses 20: its remainder 14 exceeds best fit’s 4. The cursor position matters for next fit, not for the minimum defining best fit.

Derivation and answer

Best fit chooses the smallest adequate hole. Subtracting the same process size from that hole and from the first-fit hole preserves the ≤ relation, so the best-fit remainder is never larger. Strict inequalities in the other options can fail when policies select the same hole. Thus C.

Original paper, page 6 · Answer key

1 mark · MCQ
Report issue

Processes, Threads & System Calls

Question 12, GATE 2020: For preemptive scheduling, which direct state transitions are possible? I running→ready; II ready→running; III blocked→running; IV blocked→ready. Options: A I,II,III; B II,III; C I,II,IV; D all four.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

Ready means eligible to run but not currently assigned a CPU; blocked means waiting for an event and therefore not eligible. A timer interrupt can preempt a running process into ready (I). Dispatch selects a ready process to run (II). I/O completion changes blocked to ready (IV); the scheduler may then dispatch it, but that is a second transition, not the direct blocked→running edge in III. The standard graph also has running→blocked when a process requests I/O. Distinguishing a possible two-edge path from one direct transition is the key to choosing C.

Derivation and answer

Preemption gives running→ready; dispatch gives ready→running; completion of the awaited event gives blocked→ready. In the standard state-transition model a blocked process becomes ready before dispatch, not directly running. Thus I, II, IV, C.

Original paper, page 6 · Answer key

1 mark · MCQ
Report issue

SQL & Queries

Question 13, GATE 2020: Catalogue(sno,pno,cost) has rows (S1,P1,150),(S1,P2,50),(S1,P3,100),(S2,P4,200),(S2,P5,250),(S3,P1,250),(S3,P2,150),(S3,P5,300),(S3,P4,250), primary key (sno,pno). Suppliers has primary key sno and one row each: S1/Royal furniture/Delhi, S2/Balaji furniture/Bangalore, S3/Premium furniture/Chennai. Parts has primary key pno: P1/Table/Wood, P2/Chair/Wood, P3/Table/Steel, P4/Almirah/Steel, P5/Almirah/Wood. Count rows returned by:
SELECT s.sno, s.sname FROM Suppliers s, Catalogue c
WHERE s.sno=c.sno AND cost >
(SELECT AVG(cost) FROM Catalogue WHERE pno='P4' GROUP BY pno);
Options: A 4; B 5; C 0; D 2.
Question 13, GATE 2020: Catalogue(sno,pno,cost) has rows (S1,P1,150),(S1,P2,50),(S1,P3,100),(S2,P4,200),(S2,P5,250),(S3,P1,250),(S3,P2,150),(S3,P5,300),(S3,P4,250), primary key (sno,pno). Suppliers has primary key sno and one row each: S1/Royal furniture/Delhi, S2/Balaji furniture/Bangalore, S3/Premium furniture/Chennai. Parts has primary key pno: P1/Table/Wood, P2/Chair/Wood, P3/Table/Steel, P4/Almirah/Steel, P5/Almirah/Wood. Count rows returned by:
SELECT s.sno, s.sname FROM Suppliers s, Catalogue c
WHERE s.sno=c.sno AND cost >
(SELECT AVG(cost) FROM Catalogue WHERE pno='P4' GROUP BY pno);
Options: A 4; B 5; C 0; D 2.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

Evaluate the uncorrelated scalar subquery once. Filtering pno=P4 leaves prices 200 and 250, so its one group has average 225. Apply the outer strict comparison to every Catalogue row; prices 250,250,300,250 survive. The supplier primary key makes each surviving row join with exactly one supplier row, so the join neither loses nor multiplies them. Projection returns S2 once and S3 three times. SQL SELECT uses bag semantics unless DISTINCT is requested; it does not automatically collapse those repeated S3 names. The Parts table is not referenced by this query and cannot affect the count.

Derivation and answer

The P4 rows have costs 200 and 250, so the subquery returns 225. Catalogue costs greater than 225 occur at(S2, P5),(S3, P1),(S3, P5),(S3, P4): four rows. The supplier join preserves all four and SELECT has no DISTINCT, so repeated S3 output rows remain. Answer 4, A.

Original paper, page 7 · Answer key

1 mark · MCQ
Report issue

Database Models, Architecture & ER Diagrams

Question 14, GATE 2020: In an ER diagram, which symbol denotes the supporting many-to-one relationship for a weak entity? A double/bold diamond; B double/bold rectangle; C double/bold oval; D oval with underlined identifier.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

In Chen notation, shape and border encode different information. A rectangle denotes an entity, an oval an attribute, and a diamond a relationship. A double rectangle marks a weak entity whose identity depends on an owner. The supporting identifying relationship is correspondingly the double diamond. A double oval normally represents a multivalued attribute, and underlining an attribute name indicates key information, not a relationship. Because the question asks about the relationship rather than the weak entity itself, A rather than B is required.

Derivation and answer

The identifying relationship connecting a weak entity to its owner is shown by a double-bordered diamond in the standard Chen ER notation. A double rectangle denotes the weak entity itself. Thus A.

Original paper, page 7 · Answer key

1 mark · MCQ
Report issue

Routing Algorithms

Question 15, GATE 2020: Which IP-router claims are true? I Forwarding never modifies IP packets. II A router need not implement a routing protocol. III It should reassemble fragments when outgoing-link MTU exceeds incoming-packet size. Options: A I,II; B I only; C II,III; D II only.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

Distinguish the forwarding plane from the control plane. Forwarding uses an existing destination-prefix table; a human can configure static routes, so a dynamic routing protocol is not mandatory. Forwarding is not a bit-for-bit copy of the IP header: hop lifetime is decremented, and IPv4’s header checksum must reflect that. A larger next-link MTU merely permits larger packets; it does not make a transit router the reassembly destination. Fragments may follow different paths, another reason end-to-end reassembly belongs at the destination. Thus only II survives.

Derivation and answer

A router changes at least TTL/hop limit while forwarding and, in IPv4, adjusts the header checksum, so I is false. It can use a static forwarding/routing table without a dynamic routing protocol, so II is true. Ordinary IP fragment reassembly is performed at the destination, not by transit routers merely because the next MTU is larger, so III is false. Thus D.

Original paper, page 7 · Answer key

1 mark · MCQ
Report issue

Arrays & Linked Lists

Question 16, GATE 2020: Find worst-case time to insert n elements into an initially empty ordinary linked list while keeping it sorted. A Θ(n); B Θ(n log n); C Θ(n²); D Θ(1).
Question 16, GATE 2020: Find worst-case time to insert n elements into an initially empty ordinary linked list while keeping it sorted. A Θ(n); B Θ(n log n); C Θ(n²); D Θ(1).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

The pointer rewiring for insertion is constant time once the predecessor is known. The expensive part is finding that predecessor. For the ith insertion a singly or doubly linked list can require Θ(i) node visits, since it has no random-access midpoint for binary search. Summing i from 0 to n−1 gives n(n−1)/2, which is Θ(n²). A tail pointer can make some input orders cheap but not all possible insertion positions; the question asks for worst case. Sorting the complete input first changes the online-maintenance task and is not the ordinary operation being analyzed.

Derivation and answer

Maintaining the list in sorted order after each online insertion can require scanning all current nodes to locate the insertion point. Summing worst-case costs 0+1+…+(n−1) givesΘ(n²), C. This assumes the ordinary linked-list representation without an auxiliary search index or presorting all future inputs.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Sets, Relations & Functions

Question 17, GATE 2020: Choose uniformly from all binary relations on {1,2,3}. What is the probability the relation is reflexive, to three decimal places?
Tap to enlarge
Answer & solution

Official answer: 0.125

Worked explanation

A binary relation is any subset of A×A. With |A|=3 there are nine ordered pairs, not three unordered pairs. Every pair can be included or omitted independently, yielding 512 subsets. Reflexivity requires (1,1),(2,2),(3,3) to be present; the other six bits remain free, yielding 64 favorable relations. The ratio is 64/512=0.125. Equivalently the three required diagonal bits each have probability 1/2, so their conjunction has probability (1/2)³. Symmetry and transitivity are not required.

Derivation and answer

There are 2⁹ binary relations on a three-element set. Reflexivity fixes the three diagonal pairs as present, leaving six arbitrary choices and 2⁶ relations. Under uniform random selection the probability is 2⁶/2⁹=1/8=0.125.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Algebraic Structures

Question 18, GATE 2020: G is a group of 35 elements. What is the largest possible order of a subgroup other than G itself?
Tap to enlarge
Answer & solution

Official answer: 7

Worked explanation

Lagrange’s theorem gives an upper-bound filter: subgroup order must divide the group order. The divisors of 35 are 1,5,7,35, and the last is excluded because a subgroup of full finite order is G. Divisibility alone would not guarantee existence of every divisor-sized subgroup in arbitrary finite groups. Here the largest remaining divisor is prime, so Cauchy’s theorem supplies an element of order 7, and its generated cyclic subgroup has exactly 7 elements. Hence the upper bound is attained for every group of order 35, not just for one cyclic example.

Derivation and answer

By Lagrange’s theorem a proper subgroup order divides 35 and is smaller than 35, so it is 1, 5, or 7. Cauchy’s theorem guarantees an element of order 7, whose cyclic subgroup has 7 elements. Thus the largest possible proper subgroup size is 7.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Combinational Circuits

Question 19, GATE 2020: A multiplexer selects exactly one of 32 registers to transfer to an accumulator. What is the minimum number of binary select lines?
Tap to enlarge
Answer & solution

Official answer: 5

Worked explanation

With s binary selection inputs, a multiplexer can encode at most 2s choices. Four lines provide only 16 choices, fewer than the 32 register inputs. Five lines provide 32, exactly enough. This counts control lines; the register word width determines the data-path width and is irrelevant to this count. The accumulator is the common destination, not a 33rd selectable source.

Derivation and answer

Selecting one of 32 registers requires 32 distinct selector patterns. The minimum binary selector width is ceil(log₂32)=5.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Combinational Circuits

Question 20, GATE 2020: A decoder with m input lines and n output lines uniquely addresses a byte-addressable 1 KB RAM. Find the minimum m+n.
Tap to enlarge
Answer & solution

Official answer: 1034

Worked explanation

Byte addressability means each byte is a separately selected location. Under the binary memory-size convention, 1 KB=210 bytes, so there must be 1024 distinct outputs in the one-hot address decoder. Its m input bits must encode all 1024 choices, requiring m=10. Thus n=1024 and m+n=1034. Do not confuse the RAM’s 8-bit data width with the number of decoder outputs: those outputs select addresses, not individual data bits.

Derivation and answer

A byte-addressable 1KB memory has 1024 distinct byte locations. A one-hot decoder needs 1024 output lines and log₂1024=10 address inputs. Thus m+n=10+1024=1034, using the conventional 1KB=1024 bytes.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 21, GATE 2020: A 1 MB direct-mapped cache has 256-byte blocks, access time 3 ns, hit rate 94%, and 64-bit words. On a miss, main memory delivers the first word in 20 ns and every subsequent word in 5 ns. Find average access time to one decimal place. Official scoring accepts 13.3 or 13.5 ns as separate values.
Tap to enlarge
Answer & solution

Official answer: 13.3 OR 13.5

Our answer: 13.5 or 13.3 under the two accepted timing conventions

Worked explanation

Convert the word size first: 64 bits is 8 bytes. A block therefore contains 32 words, and the first-word latency is paid once, followed by 31 further transfers, giving 20+31×5=175 ns. Miss probability is 1−0.94=0.06. If the 175 ns is an extra miss penalty after lookup, every reference pays 3 ns and 6% pay the extra penalty. If it is the entire miss-path time instead, only the hit branch uses the separate 3 ns figure in a weighted average. These conventions produce the two official answers already preserved below. The 1 MB capacity and direct mapping are not needed once the hit rate is given. No early-restart timing is specified, so use a full refill.

Derivation and answer

Each block holds 256/8=32 words. A complete refill takes 20+31·5=175 ns. If a miss incurs the 3 ns cache lookup before refill, AMAT=3+0.06·175=13.5 ns. If the 175 ns miss time is treated as the total miss-service time, the weighted average is 0.94·3+0.06·175=13.32 ns, rounding to 13.3. The official key explicitly accepts both 13.3 and 13.5; neither is silently discarded. Both calculations assume full-block service without critical-word early restart.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Pointers & Memory

Question 22, GATE 2020: Find the output of this C program:
#include <stdio.h>
int main(void) {
 int a[4][5]={{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20}};
 printf("%d\n", *(*(a+**a+2)+3));
 return 0;
}
Tap to enlarge
Answer & solution

Official answer: 19

Step through it (6 steps)

Worked explanation

Track pointer types: in this expression a decays to a pointer to an array of five ints, so adding 1 advances by a whole row. *a denotes row zero, and a is its first integer, 1. Therefore a+a+2 is a+3. Dereferencing gives row three, which in the addition +3 decays to a pointer to its first int. Adding 3 selects its fourth entry and the outer dereference reads 19. Written with subscripts the expression is a[3][3], not a[0][6] or a linear six-element offset. Both row and column indices are valid.

Derivation and answer

Here a=a[0][0]=1. Thus a+a+2=a+3 points to the fourth row. Dereferencing that row and adding 3 selects a[3][3]=19. All pointer arithmetic stays within the relevant row/outer array, so the printed expression has the defined result 19.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Hashing

Question 23, GATE 2020: Double hashing uses h1(k)=k mod 23, h2(k)=1+(k mod 19), and table size 23. Probe numbering starts at 0. What address is returned at probe 1 for key 90?
Tap to enlarge
Answer & solution

Official answer: 13

Worked explanation

Double hashing uses h(k,i)=(h1(k)+i·h2(k)) mod m. Since 90=3×23+21, h1=21. Since 90=4×19+14, h2=1+14=15. The requested i=1 is the second probe, because i=0 gives the initial position. Add the step once and wrap around: (21+15) mod 23=13. Further probes would be 5,20,…, but their occupancy is irrelevant because only the address of a specified probe is requested.

Derivation and answer

h1(90)=90 mod23=21 and h2(90)=1+(90 mod19)=15. Probe1 is(21+1·15)mod23=36mod23=13. Probe0 would have been 21.

Original paper, page 8 · Answer key

1 mark · NAT
Report issue

Parsing & Syntax Analysis

Question 24, GATE 2020: Grammar: S→aSB | d; B→b. How many reductions does a bottom-up parser perform to accept aaadbbb?
Question 24, GATE 2020: Grammar: S→aSB | d; B→b. How many reductions does a bottom-up parser perform to accept aaadbbb?
Tap to enlarge
Answer & solution

Official answer: 7

Step through it (16 steps)

Worked explanation

An explicit reduction sequence is aaadbbb ⇒ aaaSbbb ⇒ aaaSBbb ⇒ aaSbb ⇒ aaSBb ⇒ aSb ⇒ aSB ⇒ S. The first step uses d→S; each pair thereafter uses b→B followed by aSB→S. Thus there are 1+3+3=7 reductions. The corresponding derivation tree has four S-production nodes and three B-production nodes. A bottom-up parser may also shift seven terminals and eventually perform an accept action; neither shifts nor accept are additional grammar reductions.

Derivation and answer

The derivation uses S→aSB three times, S→d once, and B→b three times. A bottom-up parse reverses these seven production applications, so it performs 7 reductions, excluding the separate parser accept action.

Original paper, page 9 · Answer key

1 mark · NAT
Report issue

Application Protocols

Question 25, GATE 2020: An empty-cache browser fetches a page with text and five very small separately referenced images using nonpersistent HTTP. What is the minimum number of TCP connections needed to display it completely?
Tap to enlarge
Answer & solution

Official answer: 6

Worked explanation

First retrieve the HTML/text document. Its references reveal five image resources, each of which must then be requested because the cache starts empty. Nonpersistent HTTP closes a connection after one request/response object, so the six objects require six connections. Concurrently opening image connections may reduce elapsed time but cannot reduce the count. “Very small” changes transmission duration, not HTTP’s connection-reuse rule. Persistent HTTP would permit reuse, but the question expressly excludes it.

Derivation and answer

Nonpersistent HTTP uses a separate TCP connection for each retrieved object. There is one HTML/text object and five image objects, so six connections. This uses the standard interpretation of separate externally referenced images, not inline data embedded in the HTML.

Original paper, page 9 · Answer key

2 marks · MCQ
Report issue

Decidability & Computability

Question 26, GATE 2020: Which languages of machine encodings are undecidable? L1={⟨M⟩:L(M)=∅}; L2={⟨M,w,q⟩:M on w reaches q in exactly 100 steps}; L3={⟨M⟩:L(M) is not recursive}; L4={⟨M⟩:L(M) has at least 21 members}. A L1,L3,L4; B L1,L3; C L2,L3; D L2,L3,L4.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

Apply Rice’s theorem only to semantic properties of the recognized language that are neither true for every recognizable language nor false for all of them. Emptiness is nontrivial (∅ versus {ε}); nonrecursiveness is nontrivial (a recognizable undecidable language versus a finite language); at least 21 strings is nontrivial (∅ versus any 21-element finite language). Thus L1,L3,L4 qualify. L2 instead concerns a bounded computation trace. A simulator executes at most 100 transitions and checks q at the specified step, rejecting if the run ends earlier without that event. This always halts. An unbounded reachability question would be very different.

Derivation and answer

TM-language emptiness, being nonrecursive, and having at least 21 strings are each nontrivial semantic properties of recursively enumerable languages, so Rice’s theorem makes L1, L3, L4 undecidable. L2 is decidable by simulating the specified machine and input for exactly 100 steps and checking the state. Thus A.

Original paper, page 9 · Answer key

2 marks · MCQ
Report issue

Linear Algebra

Question 27, GATE 2020: For real n×n matrices A,B, test I rank(AB)=rank(A)rank(B); II det(AB)=det(A)det(B); III rank(A+B)≤rank(A)+rank(B); IV det(A+B)≤det(A)+det(B). A I,II; B I,IV; C II,III; D III,IV.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

The product determinant identity is valid even for singular matrices. For the rank inequality, every column of A+B is a sum of a column of A and a column of B, so its span lies in col(A)+col(B). The dimension of a sum of subspaces is at most the sum of their dimensions, proving III. To refute universal assertions, one legal counterexample suffices: choose 2×2 identities. AB=I has rank 2, not 4, and A+B=2I has determinant 4, exceeding det A+det B=2. Rank multiplication is not the correct rule; a useful correct bound is rank(AB)≤min(rank A,rank B).

Derivation and answer

Determinants multiply, so II is true. The column space of A+B is contained in the sum of the column spaces of A and B, proving rank(A+B)≤rank(A)+rank(B), III. With A=B=I2, rank(AB)=2 differs from 2·2=4, refuting I, while det(A+B)=4 exceeds 1+1=2, refuting IV. Thus C.

Original paper, page 9 · Answer key

2 marks · MCQ
Report issue

Logic Minimization & Karnaugh Maps

Question 28, GATE 2020: Circuit equivalent: b enters NOT, its output and c enter AND, and that result and a enter OR to produce z. With minterm index 4a+2b+c, choose z. A Σm(0,1,3,7); B Σm(1,4,5,6,7); C Σm(2,4,5,6,7); D Σm(2,3,5).
Question 28, GATE 2020: Circuit equivalent: b enters NOT, its output and c enter AND, and that result and a enter OR to produce z. With minterm index 4a+2b+c, choose z. A Σm(0,1,3,7); B Σm(1,4,5,6,7); C Σm(2,4,5,6,7); D Σm(2,3,5).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

Read the inversion bubble on b before constructing the product term. The AND output is b′c and the final OR adds a. Truth-table equivalent, in order abc=000,001,010,011,100,101,110,111: z=0,1,0,0,1,1,1,1. Index each assignment as binary abc with a most significant. The true rows are therefore 1,4,5,6,7. Option C incorrectly includes minterm 2, which has c=0, while A and D omit true rows with a=1. The displayed gate connections, rather than a guessed canonical expression, determine the result.

Derivation and answer

The circuit computes z=a∨(¬b∧c). For a=1 all four minterms 4, 5, 6, 7 are on. For a=0 the only on assignment is b=0, c=1, minterm 1. Thus Σm(1, 4, 5, 6, 7), B.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Data Representation & Arithmetic

Question 29, GATE 2020: R1=0x42200000 and R2=0xC1200000 are IEEE-754 single-precision bit patterns. Find the pattern for R3=R1/R2. A 0x40800000; B 0xC0800000; C 0x83400000; D 0xC8500000.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (10 steps)

Worked explanation

For a normal single-precision value, decode (−1)s×(1+fraction/223)×2E−127. R1 has s=0,E=132,fraction=0x200000, so its significand is 1+1/4=1.25 and its value is 40. R2 has s=1,E=130,the same fraction, so it is −10. Divide the represented values, not the hexadecimal integers: 40/(−10)=−4. Normalize −4 as −1.0×2², yielding sign 1, exponent 129=10000001₂ and all-zero fraction. Packing those fields gives 0x80000000+0x40800000=0xC0800000. No rounding is needed because all values are exact powers-of-two fractions.

Derivation and answer

0x42200000 represents+1.25·2⁵=40. 0xC1200000 represents−1.25·2³=−10. Their quotient is−4=−1.0·2². Its sign bit is 1, biased exponent 129, fraction 0, yielding 0xC0800000, B.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Cache Memory

Question 30, GATE 2020: A 32-bit-word system has 16 MB byte-addressable memory and a 64 KB four-way set-associative cache with 256-byte blocks. Addresses: A1=0x42C8A4, A2=0x546888, A3=0x6A289C, A4=0x5E4880. Which is true? A A1,A4 map to different sets; B A2,A3 same set; C A3,A4 same set; D A1,A3 same set.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

Compute organization before extracting bits. Total cache blocks=216/28=28; four blocks per set gives 26 sets. A 24-bit physical byte address therefore divides as tag 10 bits | set 6 bits | byte offset 8 bits. Shifting each address right by 8 discards its final byte; masking the next six bits gives 0x08,0x28,0x28,0x08, or 8,40,40,8. Same set does not require equal tags or equal byte offsets, and four-way associativity does not change this index extraction. Only B among the offered statements is true.

Derivation and answer

The cache has 65536/256=256 lines and 64 four-way sets. Offset uses 8 bits and set index 6 bits, so index=(address>>8)&63. The four addresses map to sets 8, 40, 40, 8, respectively. Exactly A2 and A3 share a set among the listed positive claims, B; A1 and A4 actually also share a set, contrary to A.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Graph Algorithms

Question 31, GATE 2020: A weighted undirected graph has MST T maintained in adjacency lists. A new weighted edge (u,v) is added. Without an additional preprocessed path-query index, what is the worst-case time to decide whether T remains an MST? A Θ(|E|+|V|); B Θ(|E||V|); C Θ(|E| log |V|); D Θ(|V|).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Worked explanation

Let e be the new edge and P the unique u-v path in T. If w(e)<max weight on P, replace a maximum-weight path edge by e; the resulting spanning tree is strictly lighter, so T fails. Conversely, if w(e)≥that maximum, consider any competing tree using e. Removing e separates it into two parts; P crosses that cut at some tree edge f with w(f)≤w(e). Replacing e by f gives an old-graph spanning tree no heavier than the competitor. Since T was minimum among old trees, no new competitor is lighter. A DFS of T visits at most |V|−1 edges, carrying the path maximum. No need to rerun an MST algorithm on all of G.

Derivation and answer

Adding edge(u, v) creates one cycle with the unique u-v path in T. T remains minimum exactly when the new weight is at least the maximum weight on that tree path. A DFS of the adjacency-list tree finds the path and its maximum in O(|V|), and an unpreprocessed path-like tree can force inspection ofΘ(|V|) edges. ThusΘ(|V|), D.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 32, GATE 2020: L1={wxyx:w,x,y∈{0,1}*}; L2={xy:x,y∈{a,b}*, |x|=|y|, x≠y}. Which statement is true? A L1 regular and L2 context-free; B L1 context-free but not regular, L2 context-free; C neither context-free; D L1 context-free, L2 not context-free.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

Empty strings are permitted for the starred variables in L1. Setting x=y=ε produces every binary w, so repeated appearances of x impose no restriction at all. For L2, the grammar below is more informative than incorrectly invoking closure under complement of context-free languages. Write V→b|aVa|aVb|bVa|bVb in addition to the displayed U productions. U and V wrap arbitrary equal numbers of symbols around different central letters. Concatenating them makes the central positions differ by half the total length. Conversely, if unequal halves of length m differ at position r, choose first component length 2r−1 and second length 2(m−r)+1. Their centers land at r and m+r. This proves both grammar inclusions, hence context-freeness without claiming that arbitrary complements of CFLs are CFLs.

Derivation and answer

For L1 choose x=ε, y=ε and let w be any binary string; hence L1=Σ*, regular. For L2 a CFG can guess a differing position in the two equal-length halves. Explicitly let U generate all odd-length strings with central a via U→a|aUa|aUb|bUa|bUb, and V generate those with central b by the analogous rules with base b. S→UV|VU then generates exactly even-length strings whose two halves differ somewhere. If component lengths are 2i+1 and 2j+1, their differing central symbols are i+j+1 positions apart, exactly half the total length. Conversely any mismatch supplies such a split. Thus L2 is context-free and A holds.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Semantic Analysis & Type Checking

Question 33, GATE 2020: Productions A→PQ and A→XY have inherited i and synthesized s attributes on each nonterminal. Rule 1: P.i=A.i+2; Q.i=P.i+A.i; A.s=P.s+Q.s. Rule 2: X.i=A.i+Y.s; Y.i=X.s+A.i. Which are L-attributed? A both; B only Rule 1; C only Rule 2; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

An inherited attribute of a child in an L-attributed definition may depend on inherited attributes of the parent and attributes of siblings to its left. In A→PQ, P has no left sibling, and its inherited value depends only on A.i. Q can use P.i because P is left of Q. Synthesized A.s is evaluated after both children return. A valid evaluation order is A.i, P.i, process P to get P.s, Q.i, process Q to get Q.s, then A.s. In A→XY, X.i needs Y.s even though Y is on X’s right, violating the restriction. Y.i’s use of X.s would be allowed by itself; it does not rescue the first dependency.

Derivation and answer

Rule1 computes each inherited attribute from the parent’s inherited attribute and, for Q, a left sibling’s attribute; the parent synthesized attribute can then combine child results. This is L-attributed. Rule2 computes X.i using right sibling Y.s, violating the left-to-right dependency restriction. Only Rule1, B.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Synchronization & Concurrency

Question 34, GATE 2020: Each of n processes runs this once, with shared count=0, semaphores a=1,b=0, and P not using count:
P;
wait(a); count=count+1;
if(count==n) signal(b);
signal(a); wait(b); signal(b);
Q;
What is guaranteed? A no Q before all P finish; B at most two in Q; C P mutually exclusive; D at most n−1 in P.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

Before any process can signal b, some process must observe count=n while holding a. Since increments are protected and occur after P, count is exactly the number of completed P sections that have passed the increment. Thus the first b signal proves every P has completed. The subsequent wait(b);signal(b) passes a token along the waiting processes; it gates entry but does not keep b held during Q. A process may enter Q and another may immediately enter too, so no mutual-exclusion or two-process bound follows. P is outside both waits, so every process can be in P simultaneously. This is a one-use barrier, not a reusable barrier because count is never reset.

Derivation and answer

Semaphore a serializes count increments after each process finishes P. Semaphore b starts 0 and is signaled for the first time only when count=n, so no process can pass wait(b) before all have finished P. Each passing process signals b to release the next waiter. The signal occurs before Q, so Q is not mutually excluded or limited to two entrants. Thus this is a barrier, A.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

I/O & Disk Scheduling

Question 35, GATE 2020: SSTF disk scheduling begins at cylinder 100 with requests P:155,Q:85,R:110,S:30,T:115. Which is false? A T before P; B Q after S but before T; C direction reverses between service of Q and P; D R before P.
Question 35, GATE 2020: SSTF disk scheduling begins at cylinder 100 with requests P:155,Q:85,R:110,S:30,T:115. Which is false? A T before P; B Q after S but before T; C direction reverses between service of Q and P; D R before P.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

Recompute the nearest remaining request after every move. From 100, distances to P,Q,R,S,T are 55,15,10,70,15, so R wins. From 110, T is 5 away; from 115, Q is 30 away versus P at 40 and S at 85, so Q wins. From 85, S is 55 away versus P at 70, so S wins, leaving P. The path is 100→110→115→85→30→155. T and R both precede P, and movement changes from decreasing to increasing at S between Q and P. B reverses the actual relation of Q to both S and T.

Derivation and answer

From100, nearest requests are R110 thenT115 thenQ85 thenS30 thenP155. The head distances for these choices are 10, 5, 30, 55, 125. Thus Q is before S and after T, making B false. The other assertions hold, including reversal at S between servicing Q andP.

Original paper, page 12 · Answer key

2 marks · MCQ
Report issue

Normalization & Decomposition

Question 36, GATE 2020: R is in 3NF but not BCNF. Which must hold? A a nontrivial FD X→A has nonsuperkey X and prime A; B such an FD has nonprime A and X not a proper subset of any key; C such an FD has nonprime A and X a proper subset of some key; D some cell is a set rather than atomic.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

For each nontrivial dependency X→A, BCNF requires X to be a superkey. 3NF allows an exception when A is prime, meaning A belongs to at least one candidate key. Because R is not BCNF, at least one dependency violates its determinant requirement. Because R still is 3NF, that violating dependency must meet the prime-attribute exception. This proves A directly. Whether X is or is not a proper subset of a key cannot make a nonprime right-hand side acceptable to 3NF when X is not a superkey. Option D contradicts the ordinary atomic-relation setting.

Derivation and answer

Failure of BCNF guarantees a nontrivial FD X→A with X not a superkey. Since3NF still holds, its permitted exception forces A to be prime, belonging to some candidate key. Thus A. The nonprime alternatives violate 3NF, and set-valued cells violate the assumed first normal form.

Original paper, page 12 · Answer key

2 marks · MCQ
Report issue

Transactions & Concurrency Control

Question 37, GATE 2020: Read the following schedule equivalents left to right; Ri(X),Wi(X) belong to transaction i. Both commits follow the listed operations in order C1,C2. Original: R1(A),R2(B),W2(B),R1(C),R2(D),W1(D),W2(C),W1(B),C1,C2. Which is conflict equivalent?
A R2(B),W2(B),R2(D),R1(A),R1(C),W1(D),W1(B),W2(C),C1,C2.
B R1(A),R1(C),W1(D),W1(B),R2(B),W2(B),R2(D),W2(C),C1,C2.
C R1(A),R1(C),W1(D),R2(B),W2(B),R2(D),W1(B),W2(C),C1,C2.
D R2(B),W2(B),R2(D),W2(C),R1(A),R1(C),W1(D),W1(B),C1,C2.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (5 schedules)

Worked explanation

Two operations conflict exactly when they belong to different transactions, access the same item, and at least one writes. There is no cross-transaction access to A. On B, both R2(B) and W2(B) precede W1(B). On D, R2(D) precedes W1(D). On C, R1(C) precedes W2(C). Those four pairwise orders are the complete test, independent of where unrelated reads move. A preserves all four and each transaction’s internal order. B reverses the B and D orders; C reverses only the D order among these; D reverses C. The precedence graph contains both T2→T1 and T1→T2, so the original is not conflict-serializable, but it can still have a conflict-equivalent nonserial schedule. Do not confuse these two questions.

Derivation and answer

The original intertransaction conflict orders are R2(B)<W1(B), W2(B)<W1(B), R2(D)<W1(D), and R1(C)<W2(C). OptionA preserves all four. B reverses the B andD conflicts; C reverses theD conflict; D reverses theC conflict. Thus A.

Original paper, page 12 · Answer key

2 marks · MCQ
Report issue

IP Addressing, Fragmentation & Address Resolution

Question 38, GATE 2020: An ISP owns 202.61.0.0/17 and wants one aggregatable block for 1500 computers. Candidate network starts: I 202.61.84.0/21; II 202.61.104.0/21; III 202.61.64.0/21; IV 202.61.144.0/21. Which candidates are valid? A I,II; B II,III; C III,IV; D I,IV.
Question 38, GATE 2020: An ISP owns 202.61.0.0/17 and wants one aggregatable block for 1500 computers. Candidate network starts: I 202.61.84.0/21; II 202.61.104.0/21; III 202.61.64.0/21; IV 202.61.144.0/21. Which candidates are valid? A I,II; B II,III; C III,IV; D I,IV.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Step through it (6 steps)

Worked explanation

Host capacity first: /22 has 1024 total addresses and cannot serve 1500 machines; /21 has 2048 total, conventionally 2046 usable, so it suffices. A /21 mask is 255.255.248.0, making its third-octet start a multiple of 8. The available /17 spans third octets 0 through 127. I fails alignment because 84 mod 8=4. II starts at 104 and ends at 111, inside the allocation. III spans 64–71, also inside. IV is aligned but spans 144–151 outside the /17. Interpreting 84.0/21 as an arbitrary address within the 80.0/21 network would silently change the listed network start; the intended assessment uses actual aligned block bases.

Derivation and answer

A/21 block provides 2048 addresses, enough for 1500 hosts, and must begin on a multiple-of 8 boundary in the third octet.104 and 64 are aligned and lie within the/17 allocation’s third-octet range 0–127.84 is not an aligned network address, and 144 lies outside the allocation. Thus II andIII, B. This treats the supplied address as the claimed network start rather than silently normalizing a host-bearing prefix.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Propositional & Predicate Logic

Question 39, GATE 2020: W has no free x. Which equivalence is NOT valid (usual nonempty domain)? A ∀x(p(x)∨W) ≡ (∀x p(x))∨W; B ∃x(p(x)∧W) ≡ (∃x p(x))∧W; C ∀x(p(x)→W) ≡ (∀x p(x))→W; D ∃x(p(x)→W) ≡ (∀x p(x))→W.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

Rewrite implication first: p→W is ¬p∨W. Universal quantification then gives ∀x(¬p(x)∨W)≡(∀x¬p(x))∨W≡¬∃x p(x)∨W, which is (∃x p(x))→W, not the universal antecedent printed in C. A countermodel makes the failure tangible: p(u)=true,p(v)=false,W=false. C’s left side fails at u; its right side is true because ∀x p(x) is false. For D, existential quantification instead yields (∃x¬p(x))∨W≡¬∀x p(x)∨W, exactly the printed right side. The side condition that W has no free x is essential when moving W outside a quantifier.

Derivation and answer

Let the domain have two elements, let p be true at one and false at the other, and let W be false. Then ∀x(p(x)→W) is false, while(∀x p(x))→W is true because its antecedent is false. Thus C is not valid. A andB pull an x-independent formula across the corresponding quantifier. D follows from ∃x(¬p(x)∨W)≡¬∀x p(x)∨W in the standard nonempty-domain semantics.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Graph Algorithms

Question 40, GATE 2020: A directed weighted graph has reweighted edges w′(u,v)=w(u,v)+f(u)−f(v), with f:V→R. Shortest paths are preserved: A for every f; B iff f is everywhere positive; C iff f is everywhere negative; D iff f gives shortest distances from a new source joined to all vertices by zero-weight edges.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Worked explanation

For a path v0=s,v1,…,vk=t, summing the added terms gives f(v0)−f(v1)+f(v1)−f(v2)+…+f(vk−1)−f(vk)=f(s)−f(t). Intermediate contributions cancel pairwise. Thus for two s-t paths P,Q, w′(P)−w′(Q)=w(P)−w(Q), preserving strict inequalities and ties. The signs of individual potentials do not matter. Choosing shortest-distance potentials is useful in Johnson’s algorithm to make edge weights nonnegative, but that is an additional goal; it is not necessary for path-order preservation. This argument compares common endpoints, not unrelated paths with different sources or destinations.

Derivation and answer

For any path from s to t, the added potentials telescope: sum[w(u, v)+f(u)−f(v)]=original path weight+f(s)−f(t). All paths with the same endpoints receive the same constant, so their relative order and shortest paths are unchanged for every real-valued f, A. Cycle weights are unchanged too; this does not create finite shortest paths where reachable negative cycles originally prevented them.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Binary Search & Balanced Trees

Question 41, GATE 2020: A balanced BST holds n keys. Reporting all keys in [a,b] produces k outputs. What is the optimal worst-case complexity? A Θ(log n); B Θ(log n+k); C Θ(k log n); D Θ(n log k).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Worked explanation

A pruned inorder routine is: if node is null return; if key>a recurse left; if a≤key≤b output key; if key<b recurse right. With distinct keys, subtrees excluded by the interval are not scanned. Nodes visited without being reported lie along at most the two boundary-search paths, of height O(log n); every other visited node contributes an output. Thus a single traversal costs O(log n+k). Performing a fresh root-to-key successor search for each result would give an avoidable O(k log n). For a lower bound, a query locating a narrow boundary can require logarithmic comparisons and actually emitting k keys needs k operations.

Derivation and answer

Search down the balanced BST to find the lower bound a in O(log n). Then enumerate successive in-range keys with an inorder traversal, pruning subtrees entirely outside the interval. Boundary paths cost O(log n) and reported nodes cost O(k), so the total is O(log n+k). A worst-case boundary search needs logarithmic comparisons and reporting k distinct results needs Ω(k) output work. Thus the optimal worst-case bound is Θ(log n+k), B.

Original paper, page 13 · Answer key

2 marks · NAT
Report issue

Combinatorics & Counting

Question 42, GATE 2020: How many distinct permutations of LILAC place no character in any of its original positions, treating the two Ls as indistinguishable?
Tap to enlarge
Answer & solution

Official answer: 12

Worked explanation

Number positions 1…5 with original symbols L,I,L,A,C. Neither L may occupy 1 or 3, so choose their two positions from {2,4,5} in C(3,2)=3 ways. After that, remaining positions are 1,3 and one r in {2,4,5}. At positions 1 and 3 any of I,A,C is allowed because the original symbol there was L. The only forbidden placement is the symbol originally at r returning to r. There are 3!=6 arrangements of I,A,C, and fixing that forbidden symbol leaves 2!=2 bad arrangements. Therefore each L choice yields 4 valid arrangements, total 12. Treating the Ls as labeled would double-count; using !5 blindly also misses their shared exclusion from both original L slots.

Derivation and answer

The two indistinguishable Ls must occupy two of positions 2, 4, 5, giving three choices. The one unoccupied position among those three is the original location of one of I, A, C. Place I, A, C in that position and positions 1, 3: of the 6 permutations, exactly 2 put that particular character back in its original position. Thus each L placement permits 4 arrangements, totaling 3*4=12. Direct enumeration of the 60 distinct permutations also yields 12.

Original paper, page 13 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 43, GATE 2020: A nonpipelined 2.5 GHz processor takes 5 cycles/instruction. Its five-stage pipeline runs at 2 GHz. Program mix: 30% memory,60% ALU,10% branch. Of memory instructions,5% cause 50-cycle stalls. Of branches,50% cause 2-cycle stalls. ALU instructions cause none. Find steady-state speedup to two decimals.
Tap to enlarge
Answer & solution

Official answer: 2.15 to 2.18

Our answer: 2.16

Worked explanation

Use time per instruction, since the two designs have different clocks. For 1000 representative instructions, 300 are memory, of which 15 stall for 750 cycles total; 100 are branches, of which 50 stall for 100 cycles total. Add the ideal 1000 pipeline cycles to obtain 1850, or CPI=1.85. Nonpipelined cycle time is 1/2.5 GHz=0.4 ns, so an instruction takes 2 ns. Pipeline cycle time is 0.5 ns, making average time 0.925 ns. Speedup is old time/new time=2/0.925=2.162162…, rounded 2.16. Counting 5% of all instructions as cache misses would overstate the penalty because that rate is conditional on memory instructions.

Derivation and answer

The non-pipelined time per instruction is 5/(2.5GHz)=2 ns. The pipeline average CPI is 1+0.30*0.05*50+0.10*0.50*2=1.85. At2GHz its average time is 1.85*0.5=0.925 ns per instruction. Speedup=2/0.925=2.162162..., or 2.16, within the official 2.15–2.18 range. This is the long-program steady-state calculation; the fixed pipeline fill/drain cost is neglected because program length is not supplied.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 44, GATE 2020: A processor has 64 registers and 16-bit instructions. I-type has opcode, one register and a 4-bit immediate; R-type has opcode and two registers. Given 8 I-type opcodes, what is the maximum number of distinct R-type opcodes?
Tap to enlarge
Answer & solution

Official answer: 14

Worked explanation

A register number occupies log2 64=6 bits. I-type operands occupy 6+4=10 bits, leaving a 6-bit opcode; R-type operands occupy 12 bits, leaving a 4-bit opcode. Their opcode spaces cannot be independently filled because every complete 16-bit word needs an unambiguous interpretation. Each chosen I opcode consumes 210 words, so eight consume 8192. R opcodes each need 212 distinct operand combinations; the 57344 words left permit 14. Constructively, use four-bit prefixes 0000 through 1101 for R instructions. Reserve 1110 and 1111, extending each by two bits to obtain the eight six-bit I opcodes. This proves attainability as well as the counting bound.

Derivation and answer

Each register field needs 6 bits. An I-type opcode leaves 10 operand bits, so 8 I-type opcodes reserve 8*210=8192 of the 65536 instruction words. An R-type opcode needs 12 operand bits, consuming 4096 words. The remaining 57344 words allow 57344/4096=14 R-type opcodes. Achievability: reserve two four-bit opcode prefixes for the eight six-bit I-opcodes and use the other 14 four-bit prefixes for R-type instructions.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Probability & Random Variables

Question 45, GATE 2020: For n>2, a is a fixed nonzero vector in {0,1}^n and x is uniform in {0,1}^n. What is the probability that Σ a_i x_i is odd?
Tap to enlarge
Answer & solution

Official answer: 0.5

Worked explanation

View the sum modulo 2. Since a is nonzero, at least one coordinate j has coefficient 1. Fix every random bit except xj; those fixed bits determine some parity c. The remaining sum parity is c⊕xj. A uniform xj makes that result equally likely to be 0 or 1, regardless of c. Averaging over all choices of the other bits preserves probability 1/2. The pairing proof below is the equivalent combinatorial version. The nonzero hypothesis matters: if a were the zero vector, the sum would always be 0 and the probability would be 0.

Derivation and answer

Because a is nonzero, choose an index j with aj=1. Pair each vector x with the vector obtained by flipping only xj. This is a fixed-point-free bijection on all 2n equally likely inputs, and it reverses the parity of the dot product. Exactly half of the inputs yield an odd sum, so the probability is 1/2. The argument in fact works for any n≥1 with nonzero a.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Scope, Lifetime & Storage Classes

Question 46, GATE 2020: Find fun2(5) on the first invocation of these C functions:
int fun1(int n) {
 static int i=0;
 if(n>0) { ++i; fun1(n-1); }
 return i;
}
int fun2(int n) {
 static int i=0;
 if(n>0) { i=i+fun1(n); fun2(n-1); }
 return i;
}
Tap to enlarge
Answer & solution

Official answer: 55

Step through it (18 steps)

Worked explanation

Use different names u and v in the trace for fun1’s and fun2’s separate static variables. Static initialization occurs once, not on every recursive call. The successive outer fun1 calls add 5,4,3,2,1 to u, making return values 5,9,12,14,15. At the corresponding fun2 entries, v becomes 5,14,26,40,55. The final fun2(0) returns 55 without changing it. When earlier calls unwind, they all return the same current static v=55; ignored recursive return values are not added again. This is why neither the triangular sum 15 nor the sum 5+4+3+2+1 is the final answer.

Derivation and answer

The two static variables named i belong to different functions and persist across calls. Starting from their initial zeros, fun1(5) increments its i five times and returns 5; subsequent fun1(4), fun1(3), fun1(2), fun1(1) return 9, 12, 14, 15 respectively. fun2 adds those five results into its own static i, so it returns 5+9+12+14+15=55. The recursive return values ignored inside fun1/fun2 do not undo updates to static storage. This assumes the displayed call is the first invocation, as intended.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Heaps & Priority Queues

Question 47, GATE 2020: An array-represented binary min-heap contains 1023 elements. What is the minimum guaranteed number of comparisons needed to find a maximum?
Tap to enlarge
Answer & solution

Official answer: 511

Worked explanation

In a one-based heap array, node i has children 2i and 2i+1 when present. Therefore internal nodes are 1…floor(1023/2)=511 and leaves are 512…1023, totaling 512. Every internal value is at most a descendant leaf value by repeatedly applying the min-heap property, so a maximum exists among leaves. There is no ordering constraint between distinct leaves. In the worst case each of 511 nonwinning leaf candidates must lose a comparison to eliminate it; one comparison can eliminate at most one candidate. A scan maintaining the largest leaf seen uses exactly 511 comparisons and attains that bound.

Derivation and answer

The1023-node complete binary min-heap has 512 leaves, at array positions 512–1023 under one-based indexing. A maximum can be chosen among the leaves; their relative values are otherwise unconstrained by the heap property. Finding the maximum of 512 candidates requires 511 comparisons in the worst case, achievable by a linear scan. This is the optimal guaranteed comparison count, not a claim about every favorable tied instance.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Control Flow & Loop Tracing

Question 48, GATE 2020: Find pp(3,4) for these C functions:
int tob(int b,int *arr) {
 int i;
 for(i=0;b>0;i++) {
  if(b%2) arr[i]=1; else arr[i]=0;
  b=b/2;
 }
 return i;
}
int pp(int a,int b) {
 int arr[20]; int i,tot=1,ex,len;
 ex=a; len=tob(b,arr);
 for(i=0;i<len;i++) {
  if(arr[i]==1) tot=tot*ex;
  ex=ex*ex;
 }
 return tot;
}
Question 48, GATE 2020: Find pp(3,4) for these C functions:
int tob(int b,int *arr) {
 int i;
 for(i=0;b>0;i++) {
  if(b%2) arr[i]=1; else arr[i]=0;
  b=b/2;
 }
 return i;
}
int pp(int a,int b) {
 int arr[20]; int i,tot=1,ex,len;
 ex=a; len=tob(b,arr);
 for(i=0;i<len;i++) {
  if(arr[i]==1) tot=tot*ex;
  ex=ex*ex;
 }
 return tot;
}
Tap to enlarge
Answer & solution

Official answer: 81

Worked explanation

The first loop extracts bits from least significant to most significant. Its trace (b before division, stored bit) is (4,0),(2,0),(1,1), then b=0 and len=3. The second loop trace (i,bit,ex before squaring,tot after possible multiply) is (0,0,3,1),(1,0,9,1),(2,1,81,81). Squaring ex is outside the if, so it happens on all iterations; that placement is central. The final ex=6561 is not the returned variable. More generally the loop multiplies powers a2^i for the set bits of b, implementing exponentiation by repeated squaring, so pp(3,4)=34=81.

Derivation and answer

tob(4, arr) stores the low-to-high binary digits 0, 0, 1 and returns len=3. In pp, ex is successively 3, 9, 81. Only the third digit is 1, so tot changes from 1 to 81 then. The final squaring makes ex=6561 but does not change tot. Thus pp(3, 4) returns 81. All values here fit even a 16-bit signed int, so overflow does not alter this evaluation.

Original paper, page 15 · Answer key

2 marks · NAT
Report issue

Graph Algorithms

Question 49, GATE 2020: The complete undirected graph has vertices v1,…,v100 and edge (vi,vj) for every 1≤i<j≤100, with weight |i−j|. Find its MST weight.
Tap to enlarge
Answer & solution

Official answer: 99

Worked explanation

A spanning tree is connected and acyclic on all 100 vertices, hence has exactly 99 edges. Here i≠j makes every weight |i−j| a positive integer, at least 1. Thus 99 is a universal lower bound. Choose precisely the edges (v1,v2),(v2,v3),…,(v99,v100). They form a path through every vertex, so are a valid spanning tree, and every edge has weight 1. Their sum is 99, attaining the bound. Taking all weight-one edges happens to work because they form this path; merely selecting individually cheap edges would not prove connectivity in a general graph.

Derivation and answer

Every edge has positive integer weight at least 1, and every spanning tree on 100 vertices has 99 edges, so its total weight is at least 99. The path v1-v2-...-v100 uses 99 consecutive-index edges of weight 1 and attains that bound. Hence the MST weight is 99.

Original paper, page 15 · Answer key

2 marks · NAT
Report issue

CPU Scheduling

Question 50, GATE 2020: All processes arrive at time 0. Burst times: P1=8,P2=7,P3=2,P4=4 ms. Compare SJF with RR, quantum 4 ms and initial order P1,P2,P3,P4. Find the absolute difference in average turnaround times, to two decimal places.
Tap to enlarge
Answer & solution

Official answer: 5.25

Step through it (2 schedules)

Worked explanation

Turnaround time is completion minus arrival, not just waiting time. With all arrivals zero, completion times can be averaged directly. SJF Gantt timeline: 0—P3—2—P4—6—P2—13—P1—21. RR timeline: 0—P1—4—P2—8—P3—10—P4—14—P1—18—P2—21. After their first slices P1 has 4 ms remaining and P2 has 3; P3 and P4 finish in their first slices and leave the queue. In process order P1,P2,P3,P4, completions are (21,13,2,6) for SJF and (18,21,10,14) for RR. Sums 42 and 63 divided by 4 give the required difference 5.25 ms.

Derivation and answer

SJF executes P3, P4, P2, P1, completing them at 2, 6, 13, 21ms. Since arrivals are all zero, average turnaround is 42/4=10.5ms. RR with quantum 4 executes P1[0, 4], P2[4, 8], P3[8, 10], P4[10, 14], P1[14, 18], P2[18, 21]. Completion times are 18, 21, 10, 14ms, averaging 63/4=15.75ms. The absolute difference is 15.75−10.5=5.25ms, with zero context-switch overhead as conventionally assumed.

Original paper, page 15 · Answer key

2 marks · NAT
Report issue

Finite Automata

Question 51, GATE 2020: L consists of strings over {a,b} whose number of a symbols is divisible by 2 but not by 3. Find the minimum states in a DFA for L.
Tap to enlarge
Answer & solution

Official answer: 6

Step through it (2 parts)

Worked explanation

DFA specification: states q0,…,q5; start q0; accepting q2,q4; δ(qr,a)=q((r+1) mod 6); δ(qr,b)=qr. This is a complete transition graph, with an a-cycle of length six and a b-self-loop at each vertex. Counting zero a symbols is divisible by both 2 and 3, so q0 correctly rejects. For minimality, all qr are reached by ar. The accepting suffix exponents modulo 6 for q0…q5 are respectively {2,4},{1,3},{0,2},{1,5},{0,4},{3,5}. These six sets differ pairwise. Choose an exponent in the symmetric difference to distinguish any two states, proving six inequivalent prefixes and the lower bound.

Derivation and answer

Track the number of a symbols modulo 6. On a increment the remainder, on b leave it unchanged, and accept remainders 2 and 4; these are exactly even counts not divisible by 3. All six states are reachable. From remainder r, accepting suffix lengths modulo 6 form {2-r, 4-r}. These six sets are distinct, so any pair of remainders is distinguished by some suffix ak. Myhill-Nerode therefore requires all 6 states, matching the construction.

Original paper, page 15 · Answer key

2 marks · NAT
Report issue

Graph Theory

Question 52, GATE 2020: Start with complete bipartite K3,4, add a vertex s adjacent to all seven original vertices, and keep all original edges. What is the minimum number of edge colors? Edges sharing an endpoint must differ.
Tap to enlarge
Answer & solution

Official answer: 7

Worked explanation

A degree-d vertex forces d distinct colors on its incident edges. Vertex s has degree 7, while original vertices have degree 5 or 4, so Δ=7 supplies the lower bound. Do not apply the bipartite edge-coloring theorem directly: adding s creates triangles. Instead verify the constructive coloring below. Its ai-bj matrix rows are [2,3,4,5], [1,4,3,6], [5,1,2,4]. Row colors are distinct and omit the corresponding s-ai color 1,2,3. Columns are [2,1,5],[3,4,1],[4,3,2],[5,6,4]; each is distinct and omits its s-bj color 4,5,6,7 respectively. At s all seven incident colors differ. Every pair of adjacent edges is therefore checked, proving seven colors suffice.

Derivation and answer

The new vertex s has degree 7, so at least 7 edge colors are needed. A concrete 7-coloring proves sufficiency. Call the parts a 0, a 1, a 2 and b0, b1, b2, b3. Give edges s-a 0, s-a 1, s-a 2 colors 1, 2, 3, and s-b0,..., s-b3 colors 4, 5, 6, 7. For the three rows of edges ai-bj, use colors (2, 3, 4, 5), (1, 4, 3, 6), and (5, 1, 2, 4), respectively. Each row and column has distinct colors and avoids its endpoint edge to s. Thus this is a proper edge-coloring with 7 colors, proving the minimum 7.

Original paper, page 15 · Answer key

2 marks · NAT
Report issue

Virtual Memory & Paging

Question 53, GATE 2020: A one-level page table is in main memory. Main-memory access=100 ns, TLB lookup=20 ns, each disk page transfer=5000 ns. TLB hit ratio=95%, stated page-fault rate=10%, dirty victim on 20% of page faults, negligible TLB-update time. Find average access time to one decimal. The source does not explicitly state what conditions the fault rate.
Question 53, GATE 2020: A one-level page table is in main memory. Main-memory access=100 ns, TLB lookup=20 ns, each disk page transfer=5000 ns. TLB hit ratio=95%, stated page-fault rate=10%, dirty victim on 20% of page faults, negligible TLB-update time. Find average access time to one decimal. The source does not explicitly state what conditions the fault rate.
Tap to enlarge
Answer & solution

Official answer: 154.5 to 155.5

Our answer: 155.0 under conditional page-fault convention

Worked explanation

Under the intended conditional model, split all references into disjoint cases: TLB hit probability .95 and time 120; nonfaulting TLB miss probability .05×.9=.045 and time 220; clean-victim fault probability .05×.1×.8=.004 and time 5220; dirty-victim fault probability .05×.1×.2=.001 and time 10220. These probabilities sum to 1. Weighted contributions are 114,9.9,20.88,10.22 ns, totaling 155.0 ns. The 220 ns baseline counts lookup, page-table read and final data access; the faults add one or two disk transfers. This arithmetic follows the official convention, not a uniquely specified real-system fault handler. An unconditional 10% page-fault rate cannot coexist with 95% valid resident TLB hits in this simple model.

Derivation and answer

A TLB hit costs 20+100=120 ns; a nonfaulting miss costs 20+100+100=220 ns. Average disk work per page fault is 5000+0.20*5000=6000 ns. Interpreting the stated 10% page-fault rate as conditional on a TLB miss gives 0.95*120+0.05*(220+0.10*6000)=155.0 ns, within the official 154.5–155.5 range. The question does not explicitly say conditional: an unconditional 10% fault probability is inconsistent with a 95% valid resident TLB hit ratio in this standard model, since faults can occur only among the 5% misses. Official scoring therefore depends on the conditional interpretation and neglects extra fault-handler/restart overhead.

Original paper, page 16 · Answer key

2 marks · NAT
Report issue

Indexing, Storage & Query Processing

Question 54, GATE 2020: A B+ tree indexes one million records on a disk with 4 KB blocks. Search keys are 12 bytes and tree/disk pointers 8 bytes. Initially no index node or record is cached; each record fits in one disk block. Find the minimum disk accesses to retrieve any record in the conventional separate-record layout.
Tap to enlarge
Answer & solution

Official answer: 4

Worked explanation

An internal node with m child pointers has m−1 separating keys. Its bytes are 8m+12(m−1)=20m−12, at most 4096. Thus m≤205.4 and maximum fanout is 205 (206 would require 4108 bytes). A leaf key/record-pointer pair takes 20 bytes, so it holds at most 204 pairs; adding an 8-byte next-leaf pointer still permits 204. Two index levels, root and leaves, hold at most 205×204=41820 entries and cannot cover one million. Three levels have capacity 205²×204=8573100, enough. A lookup must read one node per level, then follow the leaf’s record pointer to a separate data block. Three index reads plus one data read give four. The calculation concerns minimum height, not arbitrarily sparse trees.

Derivation and answer

With4KB=4096 bytes, an internal node with m child pointers and m−1 keys needs 8m+12(m−1)≤4096, giving maximum fanout 205. A leaf holds up to 204 key/record-pointer pairs even with one 8-byte next-leaf pointer. A root plus leaves can address at most 205*204=41820 records, below one million. Three index levels can address 205*205*204=8573100 records, so the minimum tree has three levels. With nothing cached, fetch root, internal node and leaf, then the separate record block: 4 disk accesses. This is the conventional separate-record B+ index layout; the record itself is not stored inline in the leaf.

Original paper, page 16 · Answer key

2 marks · NAT
Report issue

Transport, Congestion Control & Traffic Shaping

Question 55, GATE 2020: TCP is established at t=0, RTT=6 ms, receiver advertised window=50 KB, client slow-start threshold=32 KB, MSS=2 KB, no errors or timeouts. Find congestion window after all ACKs at t=60 ms. Initial cwnd and ACK growth convention are not stated; give the intended classic-model answer with that caveat.
Tap to enlarge
Answer & solution

Official answer: 44

Our answer: 44 under classic one-MSS initial window

Worked explanation

There are 60/6=10 completed RTT rounds. In the intended one-MSS initial model the window in MSS after rounds 0…10 is 1,2,4,8,16,17,18,19,20,21,22. Multiply by 2 KB to get 2,4,8,16,32,34,36,38,40,42,44 KB at times 0,6,…,60 ms. The threshold 32 KB is reached after round 4, leaving six additive-increase rounds, not ten. The advertised receiver window limits allowed outstanding data to min(cwnd,rwnd), but here 44<50, so it does not bind. This table is conditional on the classic RTT-based growth and stated initial-window assumption; it is not a claim that all compliant TCP implementations must start at 2 KB.

Derivation and answer

In the classic round-based model, start cwnd at one MSS=2KB when t=0. After RTTs at 6, 12, 18, 24ms, slow start gives 4, 8, 16, 32KB. Then congestion avoidance adds one MSS=2KB per RTT; the next six acknowledgments rounds through 60ms give 34, 36, 38, 40, 42, 44KB. The50KB receiver window does not bind. Thus official 44KB follows. The initial congestion window and ACK growth convention are not explicitly specified; modern larger initial windows or different ACK accounting can change the result. Retain44 as the intended historical model, not a universal TCP outcome.

Original paper, page 16 · Answer key