GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 2017 · Set 1

65 questions

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

03:00:00
1 mark · MCQ
Report issue

English Grammar & Usage

Question 56, GATE 2017: Fill the blank: “After Rajendra Chola returned from his voyage to Indonesia, he ___ to visit the temple in Thanjavur.” A was wishing; B is wishing; C wished; D had wished.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. The clause “returned from his voyage” places the narrative in the past. The main clause describes the next event in that narrative.

2. Simple past “wished” naturally states that event and agrees with the completed return: “After ... returned, he wished ...”.

3. “Is wishing” shifts to the present. “Had wished” puts the wish before a past reference point, and “was wishing” emphasizes an ongoing state not intended here. The best completion is C.

Original paper, page 25 · Answer key

1 mark · MCQ
Report issue

English Grammar & Usage

Question 57, GATE 2017: Complete: “Research in the workplace reveals that people work for many reasons ___.” A money beside; B beside money; C money besides; D besides money.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. The sentence contrasts money with additional reasons for working. The required meaning is “in addition to money.”

2. “Besides” is the preposition expressing addition, and its object follows it: besides money. “Beside” instead normally means next to.

3. Thus D completes the sentence grammatically and semantically. The alternatives placing money before the preposition also fail the required phrase order.

Original paper, page 25 · Answer key

1 mark · MCQ
Report issue

Data Interpretation & Logical Reasoning

Question 58, GATE 2017: Rahul, Murali, Srinivas and Arul sit around a square table. Rahul is to Murali’s left; Srinivas is to Arul’s right. Which pair is opposite? A Rahul/Murali; B Srinivas/Arul; C Srinivas/Murali; D Srinivas/Rahul. Use the conventional inward-facing adjacent-seat interpretation.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. Fix Murali at the north side facing the table centre. His left is the east side, so place Rahul at the east. Only south and west remain.

2. Place Arul at west facing east: his right is south, so Srinivas can occupy south. Reversing those two would put Arul at south with his right toward east, already occupied by Rahul, so it fails.

3. The resulting opposite pairs are Murali/Srinivas and Rahul/Arul. The listed matching pair is C. Rotating the whole arrangement does not change opposite relationships.

Original paper, page 25 · Answer key

1 mark · MCQ
Report issue

Algebra, Equations & Number Patterns

Question 59, GATE 2017: Find the smallest number y such that 162y is a perfect cube. A 24; B 27; C 32; D 36. The choices imply the intended positive-integer domain.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Prime-factorize 162=2×81=21×34. In a perfect integer cube every prime exponent must be divisible by three.

2. Raise the exponent of 2 from 1 to 3 by multiplying by 2²; raise that of 3 from 4 to 6 by multiplying by 3². Smaller nonnegative exponent increments cannot achieve divisibility by three.

3. The least positive multiplier is 2²3²=36, D. Check 162×36=5832=18³. The positive-integer restriction is essential: allowing zero or arbitrary rationals changes the question.

Original paper, page 25 · Answer key

1 mark · MCQ
Report issue

Counting, Probability & Sets

Question 60, GATE 2017: What is the probability that a k-digit number contains none of 0,5,9? A (0.3)^k; B (0.6)^k; C (0.7)^k; D (0.9)^k. The source does not explicitly allow leading zeros; distinguish a k-digit integer from a length-k digit string.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Our answer: 7^k/(9·10^(k−1)); C only for digit strings

1. The seven permitted digits are 1,2,3,4,6,7,8. For length-k independent uniformly selected decimal digit strings, each position succeeds with probability 7/10, yielding (0.7)k, official C.

2. For a uniformly selected positive k-digit integer, however, the first digit has only nine possible values. Its success probability is 7/9; each remaining digit succeeds with probability 7/10.

3. Thus the literal integer answer is (7/9)(7/10)k−1=7k/(9·10k−1)=(10/9)(0.7)k, absent from the choices. At k=1 this is 7/9 rather than 0.7, exposing the mismatch. Preserve the official answer and this sample-space caveat separately.

Original paper, page 25 · Answer key

2 marks · MCQ
Report issue

Reading Comprehension & Verbal Reasoning

Question 61, GATE 2017: “The hold of the nationalist imagination on our colonial past is such that anything inadequately or improperly nationalist is just not history.” Which best reflects the author’s opinion? A nationalists are highly imaginative; B history is viewed through the filter of nationalism; C our colonial past never happened; D nationalism has to be both adequately and properly imagined.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. Focus on the phrase “anything inadequately or improperly nationalist is just not history.” It says material is accepted as history only if it fits a nationalist standard.

2. That is a claim about selection or interpretation of the past through a filter, directly matching B.

3. A substitutes a claim about imaginative ability; C mistakes exclusion from an account for nonexistence of the past; D turns the author’s description into a prescription for nationalism. None captures the quoted criticism as directly as B.

Original paper, page 26 · Answer key

2 marks · MCQ
Report issue

Data Interpretation & Logical Reasoning

Question 62, GATE 2017: Six people sit around a circular table, with at least two men and two women and at least three right-handed people. Every woman has a left-handed person immediately to her right; no woman is right-handed. How many women? A 2; B 3; C 4; D cannot be determined.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. At least three of six people are right-handed, leaving at most three left-handed people. Since every woman is left-handed, there can be at most three women; at least two are required.

2. Assume three women. They would be exactly all three left-handed people. The person immediately to each woman’s right must then also be a woman. Repeatedly stepping right around the six-seat circle would force every seat to be a woman, contradicting the men requirement.

3. So three is impossible and exactly two remain. Feasibility is shown, in the direction designated right, by W-left,W-left,M-left,M-right,M-right,M-right around the circle. Each woman’s next neighbour is left-handed. Answer A.

Original paper, page 26 · Answer key

2 marks · MCQ
Report issue

Algebra, Equations & Number Patterns

Question 63, GATE 2017: For real x,y, simplify ((x+y)−|x−y|)/2. A max(x,y); B min(x,y); C 1; D none.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. Split into the two possible orderings because of the absolute value. If x≥y, |x−y|=x−y.

2. Then ((x+y)−(x−y))/2=2y/2=y, which is the smaller value. If x<y, |x−y|=y−x, giving ((x+y)−(y−x))/2=x.

3. Both cases return min(x,y), including equality where either value is the same. Thus B. A quick check x=2,y=5 gives (7−3)/2=2.

Original paper, page 26 · Answer key

2 marks · MCQ
Report issue

Counting, Probability & Sets

Question 64, GATE 2017: Arun,Gulab,Neel,Shweta each get one distinct shirt from red,pink,blue,white. Arun dislikes red; Shweta dislikes white; the others accept any colour. How many acceptable assignments? A 21; B 18; C 16; D 14.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Without restrictions, the four distinct shirts can be assigned to four people in 4!=24 ways.

2. Assignments with Arun receiving red number 3!=6. Those with Shweta receiving white also number 6. Subtracting both removes assignments violating both restrictions twice; with those two shirts fixed, the other two have 2!=2 arrangements.

3. Inclusion-exclusion gives 24−6−6+2=14, D. Restoring the overlap is necessary; simply subtracting the two sixes would undercount.

Original paper, page 26 · Answer key

2 marks · MCQ
Report issue

Data Interpretation & Logical Reasoning

Question 65, GATE 2017: A contour map has 25 m contour intervals. In the figure, P lies inside the 575 m contour of the left hill; Q lies between the 525 and 550 m contours of the right hill; R lies between 475 and 500 m; S is in the small low region between 450 and 475 m; T lies between 500 and 525 m. At flood-water level 525 m, which villages submerge? A P,Q; B P,Q,T; C R,S,T; D Q,R,S. These height bands are a textual description of the source figure.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. A contour line represents a fixed elevation. Starting from the labelled 500 and 550 m curves and using 25 m spacing identifies intermediate 525 m curves; points inside a hill’s higher contours are higher, not lower.

2. P is above 575 m and Q is above 525 m, so neither lies below the flood level. R is below 500 m, S lies in the low region below 475 m, and T lies between 500 and 525 m.

3. All of R,S,T have elevation less than 525 m and are submerged under the exam’s level-water assumption. Hence C. A closed contour alone does not establish a hill; the height labels and surrounding contours determine the low region at S.

Original paper, page 27 · Answer key

1 mark · MCQ
Report issue

Propositional & Predicate Logic

Question 1, GATE 2017: Which statements are equivalent to (¬p)→(¬q)? I: p→q; II: q→p; III: (¬q)∨p; IV: (¬p)∨q. Options A I only; B I and IV; C II only; D II and III.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Use the identity A→B ≡ ¬A∨B. Substituting A=¬p and B=¬q gives p∨¬q.

2. Statement II becomes ¬q∨p, and III already has that form. Commutativity of OR makes both equivalent to the target.

3. Statements I and IV instead equal ¬p∨q. For p=true,q=false they are false while the target is true. Hence exactly II and III, option D.

Original paper, page 2 · Answer key

1 mark · MCQ
Report issue

Propositional & Predicate Logic

Question 2, GATE 2017: For a nonempty domain, F=∀x∃y R(x,y). Which are implied? I ∃y∃x R(x,y); II ∃y∀x R(x,y); III ∀y∃x R(x,y); IV ¬∃x∀y¬R(x,y). A IV only; B I and IV; C II only; D II and III.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. The premise gives a witness y for every x, but the witness may depend on x. Because the domain is nonempty, select one x; its witness proves ∃x∃yR, equivalently I.

2. Simplify the negations in IV stepwise: ¬∃x∀y¬R ≡ ∀x¬∀y¬R ≡ ∀x∃yR. Thus IV is precisely the premise.

3. II wrongly demands one common witness. On {0,1}, R(x,y) iff x=y satisfies F but not II. III wrongly demands every y be used: R(x,y) iff y=0 satisfies F but fails III at y=1. Therefore B.

Original paper, page 2 · Answer key

1 mark · MCQ
Report issue

Linear Algebra

Question 3, GATE 2017: Let a1,...,an be column vectors in R^n and let scalars c1,...,cn, not all zero, satisfy Σ ci ai=0. Set A=[a1,...,an] and b=Σ ai. For Ax=b choose: A unique solution x=J (all-ones vector); B no solution; C infinitely many solutions; D finitely many solutions.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. A linear combination of columns is a matrix-vector product. Thus c≠0 and Ac=0, so A has nontrivial nullspace. Singularity alone does not tell us whether Ax=b is consistent.

2. Here b is specifically the sum of the columns. Therefore AJ=b for J=(1,...,1), establishing consistency.

3. For each real t, A(J+tc)=AJ+tAc=b. Since c≠0, different t give distinct solutions. There are infinitely many, C, not merely the known solution J.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 4, GATE 2017: Arrange 10, √n, n, log₂n, 100/n in increasing asymptotic complexity. A log₂n,100/n,10,√n,n; B 100/n,10,log₂n,√n,n; C 10,100/n,√n,log₂n,n; D 100/n,log₂n,10,√n,n.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. Compare eventual growth rather than the values at a particular small n. The reciprocal 100/n tends to zero while 10 stays constant.

2. log₂n is unbounded, but log₂n/√n→0. Also √n/n=1/√n→0. These limiting ratios put logarithm below square root below linear growth.

3. Consequently 100/n < 10 < log₂n < √n < n in asymptotic growth, option B. Constants such as 100 do not reverse eventual ordering.

Original paper, page 3 · Answer key

1 mark · MCQ
Report issue

Other / Mixed Topics

Question 5, GATE 2017: Match P Kruskal, Q Quicksort, R Floyd–Warshall to i divide and conquer, ii greedy, iii dynamic programming. A P-ii Q-iii R-i; B P-iii Q-i R-ii; C P-ii Q-i R-iii; D P-i Q-ii R-iii.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. Kruskal sorts edges by weight and repeatedly accepts a cheapest edge that does not form a cycle. This is the greedy paradigm ii.

2. Quicksort partitions around a pivot, recursively sorts the two resulting parts, and combines their order: divide and conquer i.

3. Floyd–Warshall updates distances by allowing intermediate vertices one at a time: Dk[i,j]=min(Dk−1[i,j],Dk−1[i,k]+Dk−1[k,j]). Reused subproblem values make it dynamic programming iii. Thus C.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Binary Search & Balanced Trees

Question 6, GATE 2017: A binary search tree has 15 nodes. A one-node tree has height 0. Find minimum and maximum heights. A (4,15); B (3,14); C (4,14); D (3,15).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. Height counts edges, so levels 0 through h hold at most 1+2+...+2h=2h+1−1 nodes.

2. For 15 nodes, 2h+1−1≥15 requires h≥3. A perfect four-level tree realizes height 3 and can be assigned sorted BST keys.

3. At the other extreme, a one-child chain uses one edge per additional node, giving 14 edges. No simple root-to-leaf path can exceed 14 edges with 15 nodes. Answer B.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Number Systems & Computer Arithmetic

Question 7, GATE 2017: An unsigned n-bit fixed-point number has f fractional bits and i=n−f integer bits. Find its range. A 2^(−f) to 2^i; B 2^(−f) to 2^i−2^(−f); C 0 to 2^i; D 0 to 2^i−2^(−f).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Represent the stored bits first as an unsigned integer N. Its smallest code is 0 and largest is 2n−1.

2. The fixed binary point gives value X=N/2f, so the step size is 2−f. The upper endpoint is (2n−1)2−f=2n−f−2−f.

3. Substitute i=n−f. The inclusive representable range is 0 through 2i−2−f, D. The value 2i itself would need an extra integer bit.

Original paper, page 4 · Answer key

1 mark · MCQ
Report issue

Pointers & Memory

Question 8, GATE 2017: The printed C fragment is:
typedef struct node { int data; node* next; } node;
void join(node* m,node* n) { node* p=n; while(p->next != NULL) { p=p->next; } p->next=m; }
Assume m and n point to valid NULL-terminated linked lists. A always appends m to n; B either null-pointer dereference or appends m to n; C always null-pointer dereference; D always appends n to m. The source typedef is retained literally, not silently repaired.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Our answer: B under intended corrected C declaration

1. Trace the pointer, not the data fields: p starts at n, and each iteration follows the next link. For a nonempty terminating n list, the loop stops at its final node.

2. The assignment p->next=m connects that final node to the head of m. It therefore appends m to n, including the case m is empty.

3. An empty list can be represented by n=NULL; then even the first test p->next dereferences NULL. This prevents the “for all inputs” claim A. Intended B assumes a valid declaration and disjoint lists for an acyclic concatenation.

node* appears inside the typedef before node is declared as a typedef name. Standalone C needs struct node* next or an earlier forward typedef. This source defect is not repaired in the displayed code.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Number Systems & Computer Arithmetic

Question 9, GATE 2017: Two 8-bit two’s-complement numbers A7...A0 and B7...B0 are added, producing S7...S0 and carry bits C7...C0. A0 and B0 are least significant. Which detects overflow? A C7=1; B all carries 1; C A7 B7 ¬S7 + ¬A7 ¬B7 S7=1; D A0 B0 ¬S0 + ¬A0 ¬B0 S0=1. Products mean AND and + means OR.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. In two’s complement the high bit is the sign. Opposite-sign addition cannot exceed both representable bounds, so overflow requires equal operand signs.

2. If both signs are 0, overflow means the result sign is 1: ¬A7∧¬B7∧S7. If both signs are 1, overflow means the result sign is 0: A7∧B7∧¬S7.

3. OR the two mutually exclusive cases to obtain C. For example, 127+1 produces negative 8-bit result without needing an unsigned carry-out; sign overflow and unsigned carry are different tests.

Original paper, page 5 · Answer key

1 mark · MCQ
Report issue

Context-Free Grammars & Languages

Question 10, GATE 2017: Grammar: S→abScT | abcT; T→bT | b. Which language? A {(ab)^n(cb)^n:n≥1}; B {(ab)^n c b^m1 c b^m2 ... c b^mn:n,m1,...,mn≥1}; C {(ab)^n(cb^m)^n:m,n≥1}; D {(ab)^n(cb^n)^m:m,n≥1}.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. T→bT|b generates bm for any m≥1. Different occurrences of T are expanded independently.

2. After k applications of S→abScT and then S→abcT, there are k+1 leading ab pairs and k+1 trailing cT groups. Put n=k+1≥1.

3. Replace each T by its own positive b count. The result is (ab)n cbm1 ... cbmn, B. Options A and C unnecessarily force all b blocks to have equal size.

Original paper, page 6 · Answer key

1 mark · MCQ
Report issue

Instructions & Addressing Modes

Question 11, GATE 2017: C declaration: struct data { int marks[100]; char grade; int cnumber; }; struct data student; Register R1 holds the base address of student. How to access student.grade efficiently? A postincrement (R1)+; B predecrement −(R1); C register direct R1; D indexed X(R1), with signed 16-bit displacement X.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. A structure layout assigns each member a fixed byte offset from its base. The compiler determines grade’s offset after the marks array, accounting for the implementation’s layout rules.

2. R1 already contains the base. Computing effective address R1+X directly selects grade without traversing the array or modifying R1.

3. That is displacement/index addressing X(R1), D. Register direct accesses the register rather than the field; predecrement and postincrement unnecessarily change the base. No assumed int width is needed.

Original paper, page 6 · Answer key

1 mark · MCQ
Report issue

Intermediate Code

Question 12, GATE 2017: Convert p=a−b; q=p*c; p=u*v; q=p+q to static single assignment form. Options: A p1=a−b;q1=p1*c;p1=u*v;q1=p1+q1. B p3=a−b;q4=p3*c;p4=u*v;q5=p4+q4. C p1=a−b;q1=p2*c;p3=u*v;q2=p4+q3. D p1=a−b;q1=p*c;p2=u*v;q2=p+q.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. SSA requires each defined variable version to have exactly one assignment. Subscripts need not start at 1, but every use must refer to the correct reaching definition.

2. First create p3=a−b; then q4=p3*c must use that version. The reassignment p=u*v needs a different version, p4.

3. The last sum uses new p and old q: q5=p4+q4. This is option B. A repeats definitions, C uses undefined versions, and D leaves unversioned references.

Original paper, page 7 · Answer key

1 mark · MCQ
Report issue

Pointers & Memory

Question 13, GATE 2017: Printed C source:
#include <stdio.h>
int *assignval(int *x,int val) { *x=val; return x; }
void main() { int *x=malloc(sizeof(int)); if(NULL==x) return; x=assignval(x,0); if(x) { x=(int *)malloc(sizeof(int)); if(NULL==x) return; x=assignval(x,10); } printf("%d\n",*x); free(x); }
Choose A compiler error because malloc lacks a cast; B compiler error because NULL==x must be reversed; C compiles but may leave dangling pointer; D compiles but may leak memory. The missing stdlib.h and void main are literal source issues.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Our answer: D under declared-library interpretation

1. Name the first allocated block A. If its allocation fails the function returns. Otherwise assignval(x,0) changes *x, not x: x still points to A and is nonnull.

2. Thus if(x) is entered even though the integer stored is zero. The second malloc result overwrites x, so no live variable retains A’s address.

3. If allocation B succeeds, printing/freeing uses B only. If it fails, the early return still does not free A. Either way after the second assignment A is leaked. This is intended D, subject to the source-declaration caveat below.

stdlib.h is omitted, so malloc/free lack their required declarations in modern C; void main is not a standard hosted entry point. The intended leak analysis assumes these routine issues are repaired, rather than endorsing option D’s literal “compiles successfully” wording.

Original paper, page 8 · Answer key

1 mark · MCQ
Report issue

Transport, Congestion Control & Traffic Shaping

Question 14, GATE 2017: After TCP data transfer, a client calls close, sends FIN, and receives the server’s ACK. In which RFC793 state does the client now wait for the server FIN? A LAST-ACK; B TIME-WAIT; C FIN-WAIT-1; D FIN-WAIT-2.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. The client is the active closer because it sends FIN first. Sending FIN moves it from ESTABLISHED into FIN-WAIT-1.

2. The ACK acknowledges that outgoing FIN. The client has finished its own send direction but the server has not yet sent its FIN, so it enters FIN-WAIT-2.

3. Receiving the peer FIN and acknowledging it leads to TIME-WAIT. LAST-ACK belongs to the passive closer awaiting acknowledgment of its own FIN. Therefore D.

Original paper, page 8 · Answer key

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Network Security

Question 15, GATE 2017: S digitally signs message m with its private key and sends it to R. Who can use a birthday attack to replace m with a fraudulent message? I S; II a third-party attacker; III R. A I and II; B I only; C II only; D II and III.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. A birthday collision attack searches for any two distinct messages with the same digest; it does not efficiently target one already fixed digest. For an n-bit digest its generic collision cost is about 2n/2, versus 2n for a fixed-target second preimage.

2. The signer can prepare many harmless and fraudulent variants before selecting what to sign, find a colliding pair, and reuse the signature on the fraudulent member. This makes I possible in the intended hash-then-sign setting.

3. The receiver or outside attacker only receives the fixed signed m. Replacing that requires a second preimage, not the freely chosen birthday pair. Thus II and III do not follow, and B is intended.

Original paper, page 9 · Answer key

1 mark · MCQ
Report issue

Functional Dependencies & Keys

Question 16, GATE 2017: R(V,W,X,Y,Z) has dependencies V→W, VW→X, Y→VX, Y→Z. Choose an irreducible equivalent set. A {V→W,V→X,Y→V,Y→Z}; B {V→W,W→X,Y→V,Y→Z}; C {V→W,V→X,Y→V,Y→X,Y→Z}; D {V→W,W→X,Y→V,Y→X,Y→Z}.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (7 steps)

1. First split Y→VX into Y→V and Y→X, so every right-hand side is a singleton.

2. From V→W, knowing V gives both V and W; VW→X then gives X. Therefore W is extraneous in the left side of VW→X, and we replace it by V→X.

3. Now Y→X is implied by Y→V and V→X and can be removed. None of V→W,V→X,Y→V,Y→Z follows from the other three. This is A; C is equivalent but not irreducible.

Original paper, page 9 · Answer key

1 mark · MCQ
Report issue

Parsing & Syntax Analysis

Question 17, GATE 2017: Grammar: P→xQRS; Q→yz | z; R→w | ε; S→y. Find FOLLOW(Q). A {R}; B {w}; C {w,y}; D {w,$}.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (13 steps)

1. FOLLOW(Q) contains terminal symbols that can occur immediately after a derivation of Q, not the next nonterminal’s name. Its only occurrence is in P→xQRS.

2. R can produce w, placing w immediately after Q. It can also disappear through ε, exposing S, which produces y.

3. S is not nullable, so Q never reaches the end of this production and no end marker is inherited. FOLLOW(Q)={w,y}, C.

Original paper, page 10 · Answer key

1 mark · MCQ
Report issue

Processes, Threads & System Calls

Question 18, GATE 2017: Threads of one process share: A globals but not heap; B heap but not globals; C neither globals nor heap; D both globals and heap.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Threads are separate execution streams inside the same process address space. Globals live in that shared address space.

2. Heap allocations also belong to the process address space; one thread can pass an allocated object’s address to another. Sharing does not itself make unsynchronized updates safe.

3. Each thread instead has its own execution state, such as registers and program counter, and normally its own stack. Hence both heap and globals are shared, D.

Original paper, page 10 · Answer key

1 mark · NAT
Report issue

Probability & Statistics

Question 19, GATE 2017: X is Gaussian with mean 0 and variance σ². Let Y=max(X,0). Find the median of Y.
Tap to enlarge
Answer & solution

Official answer: 0.0

Our answer: 0

1. For positive variance, symmetry of a zero-mean Gaussian gives P(X≤0)=1/2. The map max(X,0) sends every negative input to exactly zero.

2. Thus Y has no negative values and has probability 1/2 concentrated at zero. A median m satisfies P(Y≤m)≥1/2 and P(Y≥m)≥1/2; m=0 satisfies both.

3. For m<0 the first probability is zero; for m>0 the second is less than 1/2. Hence the median is 0. If variance is zero, Y is identically zero and the same answer holds.

Original paper, page 10 · Answer key

1 mark · NAT
Report issue

Trees & Connectivity

Question 20, GATE 2017: T is a tree with 10 vertices. Find the sum of degrees of all vertices.
Tap to enlarge
Answer & solution

Official answer: 18.0

Our answer: 18

1. A finite undirected tree is connected and acyclic. Its edge count is number of vertices minus one, so this tree has 10−1=9 edges.

2. Sum the degrees by counting edge ends: every edge contributes exactly one to each of its two endpoints. Hence Σdeg(v)=2|E|.

3. The result is 2×9=18. This does not depend on whether the tree is a path, star, or another shape.

Original paper, page 10 · Answer key

1 mark · NAT
Report issue

Logic Minimization & Karnaugh Maps

Question 21, GATE 2017: A four-variable K-map has columns ba=00,01,11,10 and rows dc=00,01,11,10, both in Gray order. Row entries respectively are [0,X,X,0], [1,0,0,X], [1,0,0,1], [0,X,X,0], where X means don’t care. All inputs a,b,c,d and their complements are available. Using only 2-input NOR gates, find the minimum number of gates.
Tap to enlarge
Answer & solution

Official answer: 1.0

Our answer: 1

1. Use the stated column order ba, not ab. The three required ones are at (dc,ba)=(01,00),(11,00),(11,10).

2. Choose the don’t-care at (01,10) to be 1. With wraparound column adjacency, these four cells form a group: a stays 0 and c stays 1, while b and d vary. Thus f=¬a∧c.

3. De Morgan gives f=¬(a∨¬c). Since ¬c is supplied, feed a and ¬c to one NOR gate. A direct wire to any supplied literal fails some required cell, so zero gates cannot suffice. Minimum 1.

Original paper, page 11 · Answer key

1 mark · NAT
Report issue

Finite Automata

Question 22, GATE 2017: For L described by (a+b)*b(a+b) over {a,b}, find the smallest number of states in a deterministic finite automaton accepting L.
Tap to enlarge
Answer & solution

Official answer: 4.0

Our answer: 4

Step through it (2 parts)

1. The expression allows any prefix, then b, then exactly one final symbol. Thus acceptance depends on whether the second-last symbol is b, and words shorter than two are rejected.

2. Use states aa,ab,ba,bb representing the last two symbols, padding the initial short prefix on the left with a. Start at aa; on input z shift xy to yz. Accept ba and bb. All four states are reachable.

3. Two states with different first symbols have different acceptance immediately. If their first symbols agree but second symbols differ, append a; their new first symbols then differ. Every pair is distinguishable, proving the four-state construction minimal.

Original paper, page 11 · Answer key

1 mark · NAT
Report issue

SQL & Queries

Question 23, GATE 2017: EMP(EmpId,EmpName,DeptName) has rows with IDs 1 through 13, names XYA through XYM, and departments AA,AA,AA,AA,AB,AB,AB,AC,AC,AC,AD,AD,AE respectively. The source SQL is:
SELECT AVG(EC.Num) FROM EC WHERE (DeptName, Num) IN
(SELECT DeptName, COUNT(EmpId) AS EC(DeptName, Num) FROM EMP GROUP BY DeptName)
Find its output. This unusual source syntax is retained; the solution distinguishes the intended aggregate from the literal SQL.
Tap to enlarge
Answer & solution

Official answer: 2.6

Our answer: 2.6 under intended grouped-table query

1. For the intended group operation, collect all rows with equal DeptName. The counts are AA:4, AB:3, AC:3, AD:2, AE:1.

2. AVG must average these five group counts, not average EmpId values or take an ungrouped COUNT. Their sum is 13, so the average is 13/5=2.6.

3. That derives the official intended numeric answer, but not an execution of the literal SQL. EC is not introduced as a proper relation/CTE, and AS EC(DeptName,Num) is not a valid ordinary COUNT alias. A corrected query must define EC before SELECT AVG(Num) FROM EC.

Original paper, page 12 · Answer key

1 mark · NAT
Report issue

CPU Scheduling

Question 24, GATE 2017: Processes P1,P2,P3,P4 have (arrival,CPU burst) in ms: (0,7),(3,3),(5,5),(6,2). Use preemptive shortest-remaining-time-first scheduling and find average waiting time.
Tap to enlarge
Answer & solution

Official answer: 3.0

Our answer: 3

Step through it (7 steps)

1. Run P1 at t=0. At t=3 it has 4 ms left, so newly arrived P2 with 3 ms preempts it. At t=5 P2 has only 1 ms left, less than P3’s 5, so P2 continues to completion at 6.

2. At t=6 choose P4’s 2 ms over P1’s 4 and P3’s 5. P4 completes at 8, P1 runs 8–12, then P3 runs 12–17.

3. Waiting=completion−arrival−burst. For P1,P2,P3,P4 these are 12−0−7=5,6−3−3=0,17−5−5=7,8−6−2=0. Average=(5+0+7+0)/4=3 ms.

Original paper, page 12 · Answer key

1 mark · NAT
Report issue

Cache Memory

Question 25, GATE 2017: A two-level cache sees 1.4 memory accesses per instruction. L1 miss rate is 0.1; L2 has 7 misses per 1000 instructions. Find the L2 miss rate to two decimals.
Tap to enlarge
Answer & solution

Official answer: 0.05

1. Choose a common basis of 1000 instructions. This gives 1000×1.4=1400 L1 accesses.

2. L1 misses on 0.1×1400=140 of these, and only those misses access L2. L2 therefore sees 140 accesses, not 1400 and not 1000.

3. Its local miss rate is L2 misses/L2 accesses=7/140=0.05. Dividing 7 by 1400 instead computes a global miss rate and answers a different question.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Graph Algorithms

Question 26, GATE 2017: In any connected undirected graph with positive distinct edge weights, are these necessarily true? I the minimum spanning tree is unique; II the shortest path between any two vertices is unique. A I only; B II only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. For uniqueness of the MST, suppose two different minimum trees exist. Select the lightest edge in their symmetric difference and add it to the tree not containing it.

2. The resulting cycle has an edge belonging to that tree but not the other. This edge is heavier because weights are distinct and the chosen edge was lightest in the difference. Exchanging them strictly reduces weight, contradicting minimality. Thus I is true.

3. Distinct edge weights do not make path sums distinct. In a triangle with weights 1,2,3 the direct weight-3 edge ties the 1+2 route. II fails, so A.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Deadlocks

Question 27, GATE 2017: A program has x threads and y non-reentrant locks. A thread cannot reacquire a lock it holds, and blocks if acquisition fails. Find minimum x,y allowing deadlock. A (1,2); B (2,1); C (2,2); D (1,1).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. Consider a single thread and one initially free non-reentrant lock L. The thread acquires L successfully.

2. Before releasing L, let the same thread request L again. The non-reentrancy rule blocks it because L is already held, even though the holder is itself.

3. Only this blocked thread could release L, so it cannot progress: self-deadlock. At least one thread and one lock are needed to discuss this failure, and this example achieves both minima. Answer D.

Original paper, page 13 · Answer key

2 marks · MCQ
Report issue

Calculus

Question 28, GATE 2017: Evaluate lim(x→1) (x^7−2x^5+1)/(x^3−3x²+2). A 0; B −1; C 1; D does not exist.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. Direct substitution gives numerator 1−2+1=0 and denominator 1−3+2=0, an indeterminate 0/0 rather than a value of zero.

2. Differentiate numerator and denominator: 7x6−10x4 and 3x²−6x. At x=1 both equal −3.

3. The denominator derivative is nonzero near 1, so the standard 0/0 limit rule applies. The limit is (−3)/(−3)=1, option C. Equivalently both polynomials have a common simple factor x−1 that cancels.

Original paper, page 14 · Answer key

2 marks · MCQ
Report issue

Propositional & Predicate Logic

Question 29, GATE 2017: The source says (p→q)→r is “a contradiction.” Classify (r→p)→q: A tautology; B contradiction; C always true when p is false; D always true when q is true. Distinguish the source’s literal logical terminology from its intended false-valuation reading.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Our answer: D with false-valuation interpretation

1. Under the intended interpretation, an implication A→r is false exactly when A is true and r is false. Therefore p→q is true and r=false.

2. With r=false, r→p is true regardless of p. Hence (r→p)→q reduces to true→q, namely q. It is true whenever q is true, D.

3. The allowed valuation p=false,q=false,r=false makes the target false, ruling out both tautology and C. Taking q=true makes it true, ruling out contradiction. Literally, the first expression is not a contradiction over independent atoms: setting r=true satisfies it.

Original paper, page 14 · Answer key

2 marks · MCQ
Report issue

Linear Algebra

Question 30, GATE 2017: Nonzero vectors u,v in R² satisfy ||u||=2||v||. What α makes w=u+αv bisect their angle? A 2; B 1/2; C 1; D −1/2. The intended case is the internal bisector of a nonstraight angle.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A for nondegenerate internal bisector

1. Simply adding u and v weights their directions unequally because their lengths differ. First normalize: û=u/||u|| and v̂=v/||v||.

2. The vector û+v̂ makes equal angles with the two unit vectors: its dot product with each is 1+û·v̂, and their norms are equal. Thus it points along the internal bisector when nonzero.

3. Multiply by ||u|| to obtain u+(||u||/||v||)v=u+2v. Therefore α=2, A. Zero vectors or opposite directions make this construction degenerate and are not the intended case.

Original paper, page 14 · Answer key

2 marks · MCQ
Report issue

Linear Algebra

Question 31, GATE 2017: A is an n×n real symmetric rank-2 matrix satisfying ΣiΣj Aij²=50. I: an eigenvalue must lie in [−5,5]. II: the eigenvalue of largest magnitude must be strictly greater than 5. Which necessarily hold? A both; B I only; C II only; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. For a real symmetric matrix, orthogonal diagonalization preserves the squared Frobenius norm: ΣAij²=trace(AᵀA)=Σλi². Rank 2 means exactly two eigenvalues are nonzero.

2. Thus λ1²+λ2²=50. If both had magnitude greater than 5, their squares would sum to more than 50, impossible. At least one is in [−5,5], proving I; any additional zero eigenvalues also satisfy it.

3. For II, A=diag(5,5) satisfies all premises but has largest eigenvalue magnitude exactly 5. Strictly greater is therefore not guaranteed. Answer B.

Original paper, page 14 · Answer key

2 marks · MCQ
Report issue

Data Link, Framing, Error Control & ARQ

Question 32, GATE 2017: A network uses CRC over GF(2), eight information bits and generator x³+x+1. How is message 01011011 transmitted? A 01011011010; B 01011011011; C 01011011101; D 01011011100.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (6 steps)

1. The degree-three generator requires three check bits. Append three zeros to 01011011, obtaining dividend 01011011000; generator bits are 1011.

2. Division in GF(2) uses XOR instead of subtraction. As integers the aligned XORs are 728 XOR (11<<6)=24; 24 XOR (11<<1)=14; 14 XOR 11=5. The remainder 5 is three-bit 101.

3. Replace the three zero placeholders with 101: transmitted bits are 01011011101, C. Dividing this final codeword by 1011 yields remainder zero, an independent check.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Flip-Flops, Registers & Sequential Circuits

Question 33, GATE 2017: Two flip-flops share a clock. T flip-flop output Q1 feeds the D input; D flip-flop output Q0 feeds the T input. Initial Q1Q0=11 before cycle 1. Select states after cycles 3 and 4: A (11,00); B (11,01); C (00,11); D (01,01).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. A T flip-flop toggles when T=1 and holds when T=0, so Q1(next)=Q1 XOR Q0. A D flip-flop copies its input, so Q0(next)=Q1.

2. Both right-hand sides use the old state at the same clock edge. Starting 11, edge 1 gives 01, edge 2 gives 10, and edge 3 gives 11.

3. Edge 4 repeats the first transition and gives 01. Therefore the requested pair is (11,01), B. Updating one flip-flop before computing the other would incorrectly mix old and new states.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 34, GATE 2017: Grammar S→SaS | aSb | bSa | SS | ε. Which string is NOT generated? A abab; B aaab; C abbaa; D babba.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Step through it (4 derivations)

1. Use the invariant #a−#b≥0. ε starts at zero; SaS increases it by one; aSb and bSa preserve it; SS adds two nonnegative differences. All generated strings satisfy the invariant.

2. babba has two a’s and three b’s, violating it, so D cannot be generated. To ensure it is the only excluded option, exhibit constructions for the others.

3. For abab, use S⇒SS⇒aSb aSb⇒abab. For aaab, use S⇒aSb⇒aSaSb⇒aaSb⇒aaSaSb⇒aaaSb⇒aaab. For abbaa, concatenate ab,ba,a using SS, using S⇒aSb⇒ab, S⇒bSa⇒ba, and S⇒SaS⇒a (ε reductions are implicit). Thus A,B,C are generated.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Recursion

Question 35, GATE 2017: Functions: void fun1(int n) { if(n==0)return; printf("%d",n); fun2(n-2); printf("%d",n); }
void fun2(int n) { if(n==0)return; printf("%d",n); fun1(++n); printf("%d",n); }
What does fun1(5) print? A 53423122233445; B 53423120112233; C 53423122132435; D 53423120213243. Assume declarations needed for mutual calls.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (17 steps)

1. Record entry prints separately from return prints. fun1(5) prints 5 and calls fun2(3); that prints 3, increments its local n to 4, then calls fun1(4).

2. Continuing yields entries fun1(4),fun2(2),fun1(3),fun2(1),fun1(2),fun2(0). The zero call prints nothing. The nonzero entry sequence is 5,3,4,2,3,1,2.

3. Unwind in reverse: fun1(2) prints 2; fun2’s local n is now 2, so it prints 2; subsequent exits print 3,3,4,4,5. Entry string 5342312 plus exit string 2233445 gives 53423122233445, A.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

Recursion

Question 36, GATE 2017: int foo(int val) { int x=0; while(val>0) { x=x+foo(val--); } return val; }
int bar(int val) { int x=0; while(val>0) { x=x+bar(val-1); } return val; }
Classify foo(3),bar(3): A return 6,6; B infinite loop,abnormal termination; C abnormal termination,infinite loop; D both terminate abnormally.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Our answer: C under ordinary finite-stack execution

1. Postdecrement in foo(val--) passes the old value, then decrements the caller’s local copy. Therefore foo(3) calls another foo(3), which calls another foo(3), without reaching a base case.

2. On conventional finite-stack execution, this unbounded recursion exhausts the stack and terminates abnormally. The exam uses that resource model; C does not prescribe a universal stack-overflow mechanism.

3. bar(val−1) passes a smaller value without modifying its caller. Calls descend 3,2,1,0, but bar(1) repeatedly calls bar(0) because its own val remains 1. It loops without return. Intended option C.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 37, GATE 2017: G1: S→aSb | T, T→cT | ε. G2: S→bSa | T, T→cT | ε. Classify L(G1)∩L(G2): A finite; B infinite regular; C context-free but not regular; D recursive but not context-free.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. Applying G1’s outer production n times wraps n a’s before and n b’s after T. T supplies any cm, so L(G1)={an cm bn:n,m≥0}.

2. Similarly L(G2)={bn cm an:n,m≥0}. Any G1 word with n>0 starts with a, while any G2 word with positive outer count starts with b. Such words cannot agree.

3. Common words must have zero outer count in both grammars, leaving exactly c*. This contains ε,c,cc,..., so it is infinite and regular. Answer B.

Original paper, page 17 · Answer key

2 marks · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 38, GATE 2017: L1={a^n b^n c^m:m,n≥0}, L2={a^m b^n c^n:m,n≥0}. Which are context-free? I L1∪L2; II L1∩L2. A I only; B II only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. L1 is context-free: a stack can match a’s with b’s and then ignore a trailing c block. L2 is likewise context-free by ignoring the initial a block and matching b’s with c’s.

2. Context-free languages are closed under union: a new start symbol can choose either constituent grammar. Therefore I holds.

3. Intersection forces #a=#b=#c and preserves block order, giving {an bn cn}. For pumping length p, a pump window of length at most p in ap bp cp touches at most two blocks. Pumping changes some count but leaves a third unchanged, or breaks the block order. Thus it is not context-free; answer A.

Original paper, page 17 · Answer key

2 marks · MCQ
Report issue

Decidability & Computability

Question 39, GATE 2017: A,B are finite alphabets and # belongs to neither. f:A*→B* is total; computable means a Turing machine halts on every x with f(x) on tape. Lf={x#f(x):x∈A*}. A f computable iff Lf recursive; B f computable iff Lf recursively enumerable; C computability implies recursive graph but not conversely; D computability implies RE graph but not conversely. This is printed as a single-choice question.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A and B both valid for total f

1. If f is computable, first reject strings not of form x#y with x∈A*,y∈B*. Otherwise compute f(x), which halts by totality, and compare it with y. This is a decider for Lf, so the graph is recursive and hence RE.

2. Conversely suppose only an RE recognizer for Lf is available. List all y∈B* and simulate the recognizer on x#y in dovetailed rounds, giving every candidate increasingly many steps. Do not run one candidate to completion: a nonmember may loop forever.

3. Because f is total, one candidate y=f(x) exists and will eventually be accepted; function uniqueness ensures it is the right output. This procedure halts for every x and computes f. Thus an RE graph already suffices, and a recursive graph certainly suffices. Both A and B are mathematically true; the protected official single-choice answer A is retained, not treated as eliminating B.

Original paper, page 17 · Answer key

2 marks · MCQ
Report issue

Virtual Memory & Paging

Question 40, GATE 2017: Belady’s anomaly means page faults may increase when allocated frames increase. S1 random replacement suffers from it; S2 LRU suffers from it. A both true; B S1 true,S2 false; C S1 false,S2 true; D both false.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. For LRU, order all pages by recency after each reference. The k-frame cache contains the k most recent distinct pages; those pages are included in the first k+1 pages of that same order.

2. This stack inclusion means a reference hitting with k frames cannot miss with k+1. Increasing LRU capacity therefore never increases faults for a fixed reference string, so S2 is false.

3. Random replacement has no such nested-set guarantee: its eviction choices can retain different useful pages, and an adverse larger-cache realization may fault more. S1 is interpreted as possibility, not inevitability or a claim about every run. Hence B.

Original paper, page 18 · Answer key

2 marks · MCQ
Report issue

Relational Algebra & Calculus

Question 41, GATE 2017: EMP(EmpId,EmpName,DeptId), DEPT(DeptName,DeptId); EMP.DeptId may be NULL. Which tuple-calculus queries are safe?
I {t | ∃u∈EMP (t[EmpName]=u[EmpName] ∧ ∀v∈DEPT (t[DeptId]≠v[DeptId]))}
II {t | ∃u∈EMP (t[EmpName]=u[EmpName] ∧ ∃v∈DEPT (t[DeptId]≠v[DeptId]))}
III {t | ∃u∈EMP (t[EmpName]=u[EmpName] ∧ ∃v∈DEPT (t[DeptId]=v[DeptId]))}
A I and II; B I and III; C II and III; D all three. No range restriction t∈EMP is printed.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Our answer: Only III under unrestricted-domain TRC; official D under active-domain restriction

1. Safety requires finite results independent of arbitrary values outside the database. The free result tuple t is not explicitly restricted to EMP; only t.EmpName is equated to an employee name in I and II.

2. Use one employee Alice with DeptId 1 and one department with DeptId 1. For every value z outside the database, t=(Alice,z) satisfies I: z differs from every department ID. It also satisfies II because the existing department ID 1 differs from z. Infinitely many z are possible in an unrestricted domain.

3. III instead equates t.EmpName to an EMP name and t.DeptId to a DEPT ID, bounding both fields by finite stored values. Therefore only III is classically safe, but that option is missing. Official D requires an unstated finite active-domain interpretation. Allowing NULL in EMP neither binds t nor removes the counterexample.

Original paper, page 18 · Answer key

2 marks · MCQ
Report issue

Deadlocks

Question 42, GATE 2017: Transactions receive unique Lamport timestamps. T1 holds resource R; T2 requests a conflicting lock. If TS(T2)<TS(T1), kill T1; otherwise T2 waits. Killed transactions restart with the same timestamp; any transaction not killed eventually terminates. A both deadlock-free and starvation-free; B deadlock-free only; C starvation-free only; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Smaller timestamps denote older transactions. An older requester wounds a younger holder; a younger requester waits rather than aborting the older holder. This is wound-wait.

2. Every actual waiting edge points from a younger transaction to an older one, so timestamps strictly decrease along waits. A directed cycle would require returning to the original timestamp after strict decreases, impossible. Hence no deadlock.

3. A restarted transaction keeps its old timestamp, so it does not repeatedly become youngest. With the stated eventual-termination assumption and finitely many older predecessors, those predecessors finish and it ultimately becomes able to proceed. This is the intended starvation-free guarantee, A.

Original paper, page 19 · Answer key

2 marks · NAT
Report issue

Intermediate Code

Question 43, GATE 2017: Grammar: stmt→if expr then expr else expr; stmt | δ; expr→term relop term | term; term→id | number; id→a|b|c; number→[0–9]. δ is the empty statement and relop a relational operator. A program contains ten if terminals. Find its number of control-flow paths, counting the two branches of one if as two paths.
Tap to enlarge
Answer & solution

Official answer: 1024.0

Our answer: 1024

1. The stmt grammar appends one if statement followed by another stmt. Thus ten if terminals describe ten sequential binary choices, not a nesting with an unspecified shape.

2. After the first if there are two structural paths. Each subsequent if doubles the existing path count because every current path can take either its then or else branch.

3. Therefore P0=1 and Pn=2Pn−1, giving P10=210=1024. This counts syntactic control-flow graph paths, as the question’s example does; repeated or constant conditions can make some paths infeasible for actual executions.

Original paper, page 19 · Answer key

2 marks · NAT
Not in GATE 2027 syllabusReport issue

Network Security

Question 44, GATE 2017: RSA uses primes p=13,q=17 and public exponent 35. Find the private exponent (least positive modular inverse).
Tap to enlarge
Answer & solution

Official answer: 11.0

Our answer: 11

1. RSA modulus N=pq=13×17=221. Since p and q are distinct primes, φ(N)=(p−1)(q−1)=12×16=192.

2. The private exponent d must satisfy ed≡1 mod φ(N), so solve 35d≡1 mod192. Euclid gives 192=5×35+17 and 35=2×17+1.

3. Back substitute: 1=35−2(192−5×35)=11×35−2×192. Hence d=11 is the least positive inverse. Check 35×11=385=2×192+1.

Original paper, page 20 · Answer key

2 marks · NAT
Report issue

Data Link, Framing, Error Control & ARQ

Question 45, GATE 2017: Stop-and-wait ARQ: bit rate 1 Mbps; one-way propagation 0.75 ms; frame processing time 0.25 ms; information-frame length 1980 bytes; ACK length 20 bytes; information-frame overhead 20 bytes. No errors. Find useful-data transmission efficiency as a percentage to two decimals.
Tap to enlarge
Answer & solution

Official answer: 86.5 to 89.5

Our answer: 87.11 under stated whole-frame convention

1. Interpret 1980 bytes as total information-frame length including its 20 overhead bytes. Useful payload=1960 bytes, so useful transmission time is 1960×8/106 s=15.68 ms.

2. A full stop-and-wait cycle includes information transmission 1980×8/10^6=15.84 ms; outward and return propagation 2×0.75=1.50 ms; ACK transmission 20×8/10^6=0.16 ms; and two received-frame processing times 2×0.25=0.50 ms. Total=18.00 ms.

3. Efficiency=useful payload time/cycle time=15.68/18=0.871111..., or 87.11%. If “1980” instead denotes payload before overhead, use 15.84/18.16, giving 87.22%.

Original paper, page 20 · Answer key

2 marks · NAT
Report issue

Relational Algebra & Calculus

Question 46, GATE 2017: CR(StudentName,CourseName) contains course sets SA:{CA,CB,CC}, SB:{CB,CC}, SC:{CA,CB,CC}, SD:{CA,CB,CC,CD}, SE:{CD,CA,CB}, SF:{CA,CB,CC}. T1=πCourseName(σStudentName=SA(CR)); T2=CR÷T1. Find rows in T2.
Tap to enlarge
Answer & solution

Official answer: 4.0

Our answer: 4

1. Selection finds the rows for SA, then projection removes the student column. Thus T1 is the three-course set {CA,CB,CC}.

2. Relational division returns each student who is paired with every course in T1. Extra courses do not disqualify a student.

3. SA,SC,SD,SF contain all three. SB lacks CA; SE lacks CC. Thus T2 consists of four student names, so the answer is 4. The number of qualifying enrolment rows is not what division returns.

Original paper, page 21 · Answer key

2 marks · NAT
Report issue

Proof Techniques & Number Theory

Question 47, GATE 2017: How many integers from 1 through 500 inclusive are divisible by 3 or 5 or 7?
Tap to enlarge
Answer & solution

Official answer: 271.0

Our answer: 271

1. Count multiples separately: floor(500/3)=166, floor(500/5)=100, floor(500/7)=71. Their sum double-counts integers divisible by more than one divisor.

2. Subtract pairwise intersections using least common multiples 15,21,35: 33,23,14 respectively. Triple multiples of 105 were counted three times then subtracted three times, so restore floor(500/105)=4.

3. The union size is 166+100+71−33−23−14+4=271. Inclusive endpoints are handled by the floor counts.

Original paper, page 21 · Answer key

2 marks · NAT
Report issue

Searching, Sorting & Selection

Question 48, GATE 2017: An array of 31 entries consists of zeros followed by ones. Find the smallest index i with A[i]=1 using the minimum number of array probes. What is an optimal algorithm’s worst-case probe count?
Tap to enlarge
Answer & solution

Official answer: 5.0

Our answer: 5

1. A probe returns one bit: if A[mid]=0 the first one lies to the right; if A[mid]=1 it lies at mid or to the left. This monotonicity permits binary search.

2. Balanced probing halves the candidate boundary positions each time. Five probes suffice for 31 first-one positions, or 32 possibilities if an all-zero sentinel is allowed.

3. For optimality, a binary decision tree of depth four has at most 24=16 leaves, fewer than 31 distinguishable answers. Thus no algorithm can guarantee four probes. The optimal worst case is 5, not a linear scan of 31.

Original paper, page 21 · Answer key

2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 49, GATE 2017: A RISC instruction is 4 bytes. Branch offsets are byte offsets relative to the NEXT instruction. Instructions are i:add R2,R3,R4; i+1:sub R5,R6,R7; i+2:cmp R1,R9,R10; i+3:beq R1,Offset. Branch target is i. Find signed decimal Offset.
Tap to enlarge
Answer & solution

Official answer: -16.0 to -16.0

Our answer: -16

1. Let the byte address of instruction i be A. Then i+1,i+2,i+3 have addresses A+4,A+8,A+12.

2. The branch uses the next instruction as reference, which is i+4 at A+16, not the branch’s own address A+12.

3. Offset=target−reference=A−(A+16)=−16 bytes. The negative sign denotes a backward branch. Counting three instruction gaps from the branch itself would incorrectly give −12.

Original paper, page 22 · Answer key

2 marks · NAT
Report issue

Pipelining & Hazards

Question 50, GATE 2017: Five pipeline stages IF,ID,OF,EX,WB take 5,4,20,10,3 ns; interstage buffer overhead is 2 ns. NP uses these five stages. EP splits OF into OF1=12 ns,OF2=8 ns. Find EP speedup over NP for 20 independent hazard-free instructions, to two decimals.
Tap to enlarge
Answer & solution

Official answer: 1.49 to 1.52

Our answer: 1.51

1. The clock period is the slowest stage plus buffer overhead. NP therefore has period max(5,4,20,10,3)+2=22 ns. Its five-stage pipeline needs 5+(20−1)=24 cycles, or 528 ns.

2. EP has stages 5,4,12,8,10,3 ns, so its period is 12+2=14 ns. Six stages need 6+19=25 cycles for the same twenty instructions, or 350 ns.

3. Speedup is old time/new time=528/350=1.508571..., rounding to 1.51. Using only the clock ratio 22/14 neglects the extra fill cycle.

Original paper, page 22 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 51, GATE 2017: A 256-block, 2-way set-associative cache uses LRU and starts empty. Repeat this block-reference sequence ten times: 0,128,256,128,0,128,256,128,1,129,257,129,1,129,257,129. Count conflict misses, excluding compulsory first-access misses.
Tap to enlarge
Answer & solution

Official answer: 76.0

Our answer: 76

1. There are 256/2=128 sets. Block number modulo 128 puts {0,128,256} in set 0 and {1,129,257} in set 1; each set holds only two blocks.

2. For the first set-0 subsequence 0,128,256,128,0,128,256,128 the outcomes are compulsory,compulsory,compulsory,hit,conflict,hit,conflict,hit. LRU ends with 256 then 128 from least to most recent. Set 1 behaves identically.

3. Each later subsequence starts with those two survivors: accesses to its first,third,fifth,seventh entries miss, all now conflicts. Thus repetition 1 has four conflicts total, and each of nine later repetitions has eight. Total=4+9×8=76 conflicts, alongside six compulsory misses.

Original paper, page 23 · Answer key

2 marks · NAT
Not in GATE 2027 syllabusReport issue

Code Generation & Register Allocation

Question 52, GATE 2017: For (a−1)*(((b+c)/3)+d), find minimum registers for optimal load/store code generation without spills. Only loads/stores can access memory; arithmetic operands must be registers or immediate constants.
Tap to enlarge
Answer & solution

Official answer: 2.0

Our answer: 2

1. Evaluate the more demanding right subtree first. Load b into R1 and c into R2; add into R1. Divide R1 by immediate 3, then reuse R2 to load d and add it to R1. Now R1 holds ((b+c)/3)+d.

2. Keep R1 live and load a into R2. Subtract immediate 1 from R2, then multiply R2 and R1 into either register. At no time are more than two registers live, and no intermediate is stored to memory.

3. One register cannot perform b+c under the stated arithmetic rule because both non-immediate operands must be in registers simultaneously. Hence both lower and upper bounds are 2.

Original paper, page 23 · Answer key

2 marks · NAT
Report issue

Expressions, Operators & Types

Question 53, GATE 2017: Source includes stdio.h and string.h. void printlength(char *s,char *t) { unsigned int c=0; int len=((strlen(s)-strlen(t))>c)?strlen(s):strlen(t); printf("%d\n",len); } void main() { char *x="abc"; char *y="defgh"; printlength(x,y); }
The question explicitly says size_t, returned by strlen, is unsigned int. What is printed?
Tap to enlarge
Answer & solution

Official answer: 3.0

Our answer: 3

1. strlen("abc")=3 and strlen("defgh")=5. The stipulated return type is unsigned int, so subtraction is unsigned rather than signed.

2. Let the unsigned modulus be U=UINT_MAX+1. Then 3−5 wraps to U−2, a large positive value, not signed −2. The comparison is against unsigned c=0 and is therefore true.

3. The conditional selects strlen(s)=3. Conversion of 3 to int is representable and printf prints 3. The surprising result comes from unsigned subtraction; the printed void main is a separate source portability issue.

void main is a nonstandard hosted-C entry point; the exam assumes an implementation accepting it.

Original paper, page 23 · Answer key

2 marks · NAT
Report issue

Cache Memory

Question 54, GATE 2017: A cache has capacity N words, blocks of B words, and a 10-bit tag when directly mapped. With unchanged capacity and block size, redesign as 16-way set associative. Find tag width.
Tap to enlarge
Answer & solution

Official answer: 14.0

Our answer: 14

1. Address bits are partitioned into tag, set index, and block offset. Keeping B fixed leaves offset width unchanged.

2. A direct-mapped cache has N/B sets. A 16-way cache of the same total capacity has N/(16B) sets, requiring log₂16=4 fewer index bits.

3. The address width has not changed, so those four bits move to the tag. New tag width=10+4=14 bits. Associativity changes the set count, not the number of offset bits.

Original paper, page 24 · Answer key

2 marks · NAT
Report issue

Scope, Lifetime & Storage Classes

Question 55, GATE 2017: #include <stdio.h>
int total(int v) { static int count=0; while(v) { count+=v&1; v>>=1; } return count; }
void main() { static int x=0; int i=5; for(;i>0;i--) { x=x+total(i); } printf("%d\n",x); }
Find printed output.
Tap to enlarge
Answer & solution

Official answer: 23.0

Our answer: 23

1. Inside total, v&1 extracts the low bit and v>>=1 removes it. The loop counts set bits, but count is static: its value persists across different calls.

2. Arguments are 5,4,3,2,1, with binary forms 101,100,11,10,1 and popcounts 2,1,2,1,1. Therefore total returns cumulative counts 2,3,5,6,7, rather than the individual popcounts.

3. main adds each returned value to its own x: 2, then 5,10,16,23. The final output is 23. Resetting count on each call would wrongly give 7.

void main is a nonstandard hosted-C entry point; the exam assumes an implementation accepting it.

Original paper, page 24 · Answer key