Organised by IIT Kanpur

GATE 2023 CS (Computer Science) question paper with solutions

61 questions with the official answer key and a worked solution for each. Try a question before opening its answer.

Practise this paper with instant checking
Q1MCQ1 mark · -1/3· Easy

We reached the station late, and _______ missed the train.

  1. (A)near
  2. (B)nearly
  3. (C)utterly
  4. (D)mostly
Answer: B - show solution

The blank must modify the verb "missed" and convey that the train was almost caught but not quite. "nearly" (an adverb meaning almost) fits: we arrived late and nearly missed the train. "near" is an adjective/preposition, "utterly" means completely and does not collocate with missed a train, and "mostly" makes no sense for a single event. Answer: (B) nearly.

Concept: Tests adverb choice in context. The trap is "near", which sounds similar but is not the adverb meaning "almost"; "nearly" is the correct modifier for a verb.

Q3MCQ1 mark · -1/3· Easy

A series of natural numbers F1, F2, F3, F4, F5, F6, F7, ... obeys Fₙ₊₁ = Fₙ + Fₙ₋₁ for all integers n ≥ 2. If F6 = 37, and F7 = 60, then what is F1?

  1. (A)4
  2. (B)5
  3. (C)8
  4. (D)9
Answer: A - show solution

Run the recurrence backwards using Fₙ₋₁ = Fₙ₊₁ - Fₙ. F5 = F7 - F6 = 60 - 37 = 23. F4 = F6 - F5 = 37 - 23 = 14. F3 = F5 - F4 = 23 - 14 = 9. F2 = F4 - F3 = 14 - 9 = 5. F1 = F3 - F2 = 9 - 5 = 4. Check forwards: 4, 5, 9, 14, 23, 37, 60. Answer: (A) 4.

Concept: A Fibonacci-type recurrence solved in reverse. The usual slip is subtracting in the wrong order or stopping at F2 = 5, which is also an option.

Q4MCQ1 mark · -1/3· Easy

A survey for a certain year found that 90% of pregnant women received medical care at least once before giving birth. Of these women, 60% received medical care from doctors, while 40% received medical care from other healthcare providers. Given this information, which one of the following statements can be inferred with certainty?

  1. (A)More than half of the pregnant women received medical care at least once from a doctor.
  2. (B)Less than half of the pregnant women received medical care at least once from a doctor.
  3. (C)More than half of the pregnant women received medical care at most once from a doctor.
  4. (D)Less than half of the pregnant women received medical care at most once from a doctor.
Answer: A - show solution

90% of pregnant women received care at least once. Of these, 60% received care from doctors, i.e. 0.9 × 0.6 = 0.54 = 54% of all pregnant women received care at least once from a doctor. 54% is more than half, so (A) follows with certainty. Nothing is said about how many times care was received, so the "at most once" options cannot be inferred. Answer: (A).

Concept: Percent of a percent: 60% applies to the 90% subgroup, not to everyone. The trap is reading 60% as a share of all women, or being distracted by the "at most once" options, which the data do not address.

Q5MCQ1 mark · -1/3· Easy

Looking at the surface of a smooth 3-dimensional object from the outside, which one of the following options is TRUE?

  1. (A)The surface of the object must be concave everywhere.
  2. (B)The surface of the object must be convex everywhere.
  3. (C)The surface of the object may be concave in some places and convex in other places.
  4. (D)The object can have edges, but no corners.
Answer: C - show solution

A smooth 3D object need not be convex (for example a bowl or a dumbbell shape) nor concave everywhere (a closed surface seen from outside cannot be concave everywhere). Smooth also rules out edges and corners, so (D) is wrong. The only statement that is always true is that the surface may be concave in some places and convex in others. Answer: (C).

Concept: Spatial reasoning about curvature. The trap is assuming every smooth object is convex like a sphere; smoothness only excludes edges and corners, not concave regions.

Q6MCQ2 marks · -2/3· Easy

The country of Zombieland is in distress since more than 75% of its working population is suffering from serious health issues. Studies conducted by competent health experts concluded that a complete lack of physical exercise among its working population was one of the leading causes of their health issues. As one of the measures to address the problem, the Government of Zombieland has decided to provide monetary incentives to those who ride bicycles to work. Based only on the information provided above, which one of the following statements can be logically inferred with certainty?

  1. (A)All the working population of Zombieland will henceforth ride bicycles to work.
  2. (B)Riding bicycles will ensure that all of the working population of Zombieland is free of health issues.
  3. (C)The health experts suggested to the Government of Zombieland to declare riding bicycles as mandatory.
  4. (D)The Government of Zombieland believes that riding bicycles is a form of physical exercise.
Answer: D - show solution

The government pays people to cycle to work as a measure against health problems caused by lack of physical exercise. That measure only makes sense if the government believes cycling is a form of physical exercise, so (D) is a necessary assumption and can be inferred. (A) and (B) predict outcomes that are not guaranteed, and (C) attributes a recommendation to the experts that the passage never mentions. Answer: (D).

Concept: Inference vs. speculation: the correct option is the belief implicit in the stated policy. Options that predict results or invent facts about what experts said are the usual traps.

Q7MCQ2 marks · -2/3· Easy

Consider two functions of time (t), f(t) = 0.01 t² and g(t) = 4 t, where 0 < t < ∞. Now consider the following two statements: (i) For some t > 0, g(t) > f(t). (ii) There exists a T, such that f(t) > g(t) for all t > T. Which one of the following options is TRUE?

  1. (A)only (i) is correct
  2. (B)only (ii) is correct
  3. (C)both (i) and (ii) are correct
  4. (D)neither (i) nor (ii) is correct
Answer: C - show solution

f(t) - g(t) = 0.01t² - 4t = 0.01t(t - 400). For 0 < t < 400 this is negative, so g(t) > f(t) (e.g. t = 1: g = 4, f = 0.01), and (i) holds. For t > 400 it is positive, so taking T = 400 gives f(t) > g(t) for all t > T, and (ii) holds. Answer: (C) both (i) and (ii) are correct.

Concept: A quadratic eventually overtakes any linear function, but the linear one can be larger for small t. The trap is assuming one function dominates everywhere.

Q8MCQ2 marks · -2/3· Easy

Which one of the following sentence sequences creates a coherent narrative? (i) Once on the terrace, on her way to her small room in the corner, she notices the man right away. (ii) She begins to pant by the time she has climbed all the stairs. (iii) Mina has bought vegetables and rice at the market, so her bags are heavy. (iv) He was leaning against the parapet, watching the traffic below.

  1. (A)(i), (ii), (iv), (iii)
  2. (B)(ii), (iii), (i), (iv)
  3. (C)(iv), (ii), (i), (iii)
  4. (D)(iii), (ii), (i), (iv)
Answer: D - show solution

(iii) introduces Mina and her heavy bags - the natural opening. (ii) follows: she pants after climbing the stairs, explained by the heavy bags. (i) then has her reach the terrace and notice "the man", and (iv) describes what "he" was doing, which needs the man to have been introduced in (i). Order: (iii), (ii), (i), (iv). Answer: (D).

Concept: Narrative ordering using pronoun references and cause-effect. "He" in (iv) must follow the introduction of "the man", and the panting needs the heavy bags first.

Q9MCQ2 marks · -2/3· Moderate

f(x) and g(y) are functions of x and y, respectively, and f(x) = g(y) for all real values of x and y. Which one of the following options is necessarily TRUE for all x and y?

  1. (A)f(x) = 0 and g(y) = 0
  2. (B)f(x) = g(y) = constant
  3. (C)f(x) ≠ constant and g(y) ≠ constant
  4. (D)f(x) + g(y) = f(x) - g(y)
Answer: B - show solution

Fix y = y0. Then f(x) = g(y0) for every x, so f is constant, say c. Similarly fixing x shows g(y) = f(x0) = c for every y. Hence f(x) = g(y) = c, a constant, but not necessarily zero (f = g = 5 works), so (A) is not necessary. (C) contradicts what we proved. (D) would force g(y) = 0, again not necessary. Answer: (B).

Concept: If a function of x equals a function of y for all independent x and y, both must equal the same constant. The trap is picking (A), which is one valid case but not forced.

Q11MCQ1 mark · -1/3· Easy

Consider the following statements regarding the front-end and back-end of a compiler. S1: The front-end includes phases that are independent of the target hardware. S2: The back-end includes phases that are specific to the target hardware. S3: The back-end includes phases that are specific to the programming language used in the source code. Identify the CORRECT option.

  1. (A)Only S1 is TRUE.
  2. (B)Only S1 and S2 are TRUE.
  3. (C)S1, S2, and S3 are all TRUE.
  4. (D)Only S1 and S3 are TRUE.
Answer: B - show solution

The front end (lexical, syntax, semantic analysis, intermediate code generation) depends on the source language but not on the target machine, so S1 is true. The back end (target-specific optimisation, code generation, register allocation) depends on the target hardware, so S2 is true. The back end works on the intermediate representation and is independent of the source language, so S3 is false. Answer: (B) Only S1 and S2 are TRUE.

Concept: The front-end/back-end split exists so one front end can target many machines and one back end can serve many languages. The trap is S3: language specifics belong to the front end.

Q12MCQ1 mark · -1/3· Easy

Which one of the following sequences when stored in an array at locations A[1], . . . , A[10] forms a max-heap?

  1. (A)23, 17, 10, 6, 13, 14, 1, 5, 7, 12
  2. (B)23, 17, 14, 7, 13, 10, 1, 5, 6, 12
  3. (C)23, 17, 14, 6, 13, 10, 1, 5, 7, 15
  4. (D)23, 14, 17, 1, 10, 13, 16, 12, 7, 5
Answer: B - show solution

With 1-based indexing, the children of A[i] are A[2i] and A[2i+1]. (A): A[3] = 10 has child A[6] = 14 > 10, fails. (C): A[5] = 13 has child A[10] = 15, fails. (D): A[4] = 1 has children 12 and 7, fails. (B): 23 ≥ 17, 14; 17 ≥ 7, 13; 14 ≥ 10, 1; 7 ≥ 5, 6; 13 ≥ 12. Every parent is at least its children. Answer: (B).

Concept: Max-heap property: every node is at least as large as its children. Check each parent at index i against 2i and 2i+1; a sorted-looking prefix does not guarantee validity deep in the array.

Q13MCQ1 mark · -1/3· Easy

Let SLLdel be a function that deletes a node in a singly-linked list given a pointer to the node and a pointer to the head of the list. Similarly, let DLLdel be another function that deletes a node in a doubly-linked list given a pointer to the node and a pointer to the head of the list. Let n denote the number of nodes in each of the linked lists. Which one of the following choices is TRUE about the worst-case time complexity of SLLdel and DLLdel?

  1. (A)SLLdel is O(1) and DLLdel is O(n)
  2. (B)Both SLLdel and DLLdel are O(log(n))
  3. (C)Both SLLdel and DLLdel are O(1)
  4. (D)SLLdel is O(n) and DLLdel is O(1)
Answer: D - show solution

To delete a node from a singly-linked list, its predecessor's next pointer must be changed, and the only way to find the predecessor is to walk from the head: O(n) in the worst case (the node may be last). In a doubly-linked list the node's prev pointer gives the predecessor directly, so unlinking takes a constant number of pointer updates: O(1). Answer: (D) SLLdel is O(n) and DLLdel is O(1).

Concept: The cost of deletion is the cost of finding the predecessor. The copy-next-node trick for singly-linked lists fails for the last node, so the worst case remains O(n).

Q14MCQ1 mark · -1/3· Easy

Consider the Deterministic Finite-state Automaton (DFA) A shown below. The DFA runs on the alphabet {0, 1}, and has the set of states {s, p, q, r}, with s being the start state and p being the only final state. Transitions: s --1--> p, s --0--> r, p --0--> p, p --1--> q, q --1--> p, q --0--> r, r --0,1--> r. Which one of the following regular expressions correctly describes the language accepted by A?

  1. (A)1(0*11)*
  2. (B)0(0 + 1)*
  3. (C)1(0 + 11)*
  4. (D)1(110*)*
Answer: C - show solution

From s the only useful move is 1 to p (0 goes to the dead state r). At p, reading 0 loops at p, and reading 1 goes to q, from where 1 must follow to return to p (0 goes to r). So from p, the strings that return to p are built from the pieces 0 and 11 in any order. Accepted language: 1(0 + 11)*. (A) forbids trailing 0s such as "10"; (D) forbids "10" too and allows 0s only after 11. Answer: (C).

Concept: Read loops at the final state as alternatives: a 0-self-loop and a 1-1 round trip give (0 + 11)*. The trap is (A) or (D), which force a fixed order of 0s and 11s.

Q15MCQ1 mark · -1/3· Moderate

The Lucas sequence Lₙ is defined by the recurrence relation: Lₙ = Lₙ₋₁ + Lₙ₋₂, for n ≥ 3, with L1 = 1 and L2 = 3. Which one of the options given is TRUE?

  1. (A)Lₙ = ((1 + √5)/2)ⁿ + ((1 - √5)/2)ⁿ
  2. (B)Lₙ = ((1 + √5)/2)ⁿ - ((1 - √5)/3)ⁿ
  3. (C)Lₙ = ((1 + √5)/2)ⁿ + ((1 - √5)/3)ⁿ
  4. (D)Lₙ = ((1 + √5)/2)ⁿ - ((1 - √5)/2)ⁿ
Answer: A - show solution

The characteristic equation r² = r + 1 has roots φ = (1 + √5)/2 and ψ = (1 - √5)/2, so Lₙ = aφⁿ + bψⁿ; options with (1 - √5)/3 are not solutions of the recurrence. Test (A): n = 1: φ + ψ = 1 = L1. n = 2: φ² + ψ² = (φ + ψ)² - 2φψ = 1 - 2(-1) = 3 = L2. Test (D): n = 1 gives φ - ψ = √5 ≠ 1. Answer: (A).

Concept: Linear recurrences are solved by the roots of the characteristic equation, then fitted to initial values. The trap is (D), the Fibonacci form without the 1/√5 factor; Lucas numbers use the sum.

Q16MCQ1 mark · -1/3· Easy

Which one of the options given below refers to the degree (or arity) of a relation in relational database systems?

  1. (A)Number of attributes of its relation schema.
  2. (B)Number of tuples stored in the relation.
  3. (C)Number of entries in the relation.
  4. (D)Number of distinct domains of its relation schema.
Answer: A - show solution

The degree (arity) of a relation is the number of attributes (columns) in its schema. The number of tuples (rows) is its cardinality. Answer: (A) Number of attributes of its relation schema.

Concept: Degree = number of attributes; cardinality = number of tuples. Swapping these two terms is the standard trap.

Q17MCQ1 mark · -1/3· Easy

Suppose two hosts are connected by a point-to-point link and they are configured to use Stop-and-Wait protocol for reliable data transfer. Identify in which one of the following scenarios, the utilization of the link is the lowest.

  1. (A)Longer link length and lower transmission rate
  2. (B)Longer link length and higher transmission rate
  3. (C)Shorter link length and lower transmission rate
  4. (D)Shorter link length and higher transmission rate
Answer: B - show solution

For Stop-and-Wait, utilization U = Tt / (Tt + 2Tp) = 1 / (1 + 2a), where a = Tp/Tt, Tt = L/R is transmission time and Tp is propagation delay (grows with link length). U is lowest when a is largest: Tp large (longer link) and Tt small (higher transmission rate). Answer: (B) Longer link length and higher transmission rate.

Concept: Stop-and-Wait wastes the round trip; the waste dominates when the frame is sent quickly but takes long to propagate. The trap is thinking a faster link always improves utilization.

Q18MCQ1 mark · -1/3· Easy

Let A = [[1, 2, 3, 4], [4, 1, 2, 3], [3, 4, 1, 2], [2, 3, 4, 1]] and B = [[3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1]] (rows listed top to bottom). Let det(A) and det(B) denote the determinants of the matrices A and B, respectively. Which one of the options given below is TRUE?

  1. (A)det(A) = det(B)
  2. (B)det(B) = -det(A)
  3. (C)det(A) = 0
  4. (D)det(AB) = det(A) + det(B)
Answer: B - show solution

B is obtained from A by swapping row 1 and row 3 (rows 2 and 4 are unchanged). A single row interchange multiplies the determinant by -1, so det(B) = -det(A). det(A) is not 0 (A is a circulant whose eigenvalues 10, -2 ± 2i, -2 are all non-zero; det(A) = -160), so (A) and (C) fail, and det(AB) = det(A)det(B) = -det(A)², not a sum. Answer: (B).

Concept: Row operations and determinants: swapping two rows flips the sign. Spot the swap rather than expanding a 4×4 determinant; also recall det(AB) is a product, not a sum.

Q19MCQ1 mark · -1/3· Moderate

Consider the following definition of a lexical token id for an identifier in a programming language, using extended regular expressions: letter → [A-Za-z], digit → [0-9], id → letter (letter | digit)*. Which one of the following Non-deterministic Finite-state Automata with ϵ-transitions accepts the set of valid identifiers? (State 0 is the start state; F marks a final state.)

  1. (A)States 0, 1(F). 0 --letter--> 1; 0 --ϵ--> 1; 1 --letter, digit--> 1.
  2. (B)States 0, 1(F), 2(F), 3(F). 0 --letter--> 1; 1 --ϵ--> 2; 1 --ϵ--> 3; 2 --letter--> 2; 3 --digit--> 3.
  3. (C)States 0, 1(F), 2, 3, 4, 5, 6. 0 --letter--> 1; 1 --ϵ--> 2; 2 --letter--> 3; 3 --ϵ--> 6; 1 --ϵ--> 4; 4 --digit--> 5; 5 --ϵ--> 6; 6 --ϵ--> 1.
  4. (D)States 0, 1(F), 2, 3. 0 --letter--> 1; 1 --letter--> 2; 2 --digit--> 3; 3 --ϵ--> 1.
Answer: C - show solution

(A) has an ϵ-move from the start straight to the final state, so it accepts the empty string and strings starting with a digit such as "9". (B) commits after the first letter to only letters or only digits, so "a1b" is rejected. (D) after the first letter accepts only repeated "letter digit" pairs, so "ab" is rejected. (C) is the Thompson construction: after one letter, the final state 1 can loop through either a letter branch or a digit branch and return via ϵ to 1, any number of times, giving letter(letter | digit)*. Answer: (C).

Concept: Tests turning a regular definition into an ϵ-NFA. Watch for ϵ-edges that skip the mandatory first letter and for loops that cannot mix letters and digits.

Q20MCQ1 mark · -1/3· Easy

An algorithm has to store several keys generated by an adversary in a hash table. The adversary is malicious who tries to maximize the number of collisions. Let k be the number of keys, m be the number of slots in the hash table, and k > m. Which one of the following is the best hashing strategy to counteract the adversary?

  1. (A)Division method, i.e., use the hash function h(k) = k mod m.
  2. (B)Multiplication method, i.e., use the hash function h(k) = m(kA - kA ) , where A is a carefully chosen constant.
  3. (C)Universal hashing method.
  4. (D)If k is a prime number, use Division method. Otherwise, use Multiplication method.
Answer: C - show solution

Any fixed hash function (division or multiplication method) is known to the adversary, who can then choose keys that all hash to the same slot, giving Θ(k) chains. Universal hashing picks the hash function at random from a universal family at run time, so for any fixed set of keys the expected number of collisions for a pair is at most 1/m, regardless of how the keys were chosen. Answer: (C) Universal hashing method.

Concept: Randomisation defeats a malicious input generator. The trap is believing a carefully chosen constant or a prime modulus helps; any deterministic function can be attacked.

Q21MCQ1 mark · -1/3· Easy

The output Q of a 2-input multiplexer is connected back to its input 0, as shown in the figure. Input 1 is an external data line and the select line S is an external control line. Match the functional equivalence of this circuit to one of the following options.

  1. (A)D Flip-flop
  2. (B)D Latch
  3. (C)Half-adder
  4. (D)Demultiplexer
Answer: B - show solution

Let the external input on line 1 be D. When S = 1 the mux passes input 1, so Q = D (transparent). When S = 0 it passes input 0, which is Q itself, so Q holds its previous value. Q = S·D + S'·Q: the output follows D while S is high and holds while S is low. That is level-triggered storage with S as enable, i.e. a D latch, not an edge-triggered flip-flop. Answer: (B) D Latch.

Concept: A mux with output fed back to one input is the classic gated D latch. The trap is choosing D flip-flop: there is no edge detection, so the output is transparent for the whole time S is high.

Q22MSQ1 mark · no negative· Easy

Which one or more of the following need to be saved on a context switch from one thread (T1) of a process to another thread (T2) of the same process?

  1. (A)Page table base register
  2. (B)Stack pointer
  3. (C)Program counter
  4. (D)General purpose registers
Answer: B, C, D - show solution

Threads of the same process share the address space, so the page table base register does not change and need not be saved. Each thread has its own execution context: its own stack (stack pointer), its own next instruction (program counter) and its own register values (general purpose registers). These must be saved for T1 and restored for T2. Answer: (B), (C), (D).

Concept: Thread context = PC, SP, registers; process context additionally includes the address space. The trap is including the page table base register, which only changes on a process switch.

Q23MSQ1 mark · no negative· Easy

Which one or more of the following options guarantee that a computer system will transition from user mode to kernel mode?

  1. (A)Function Call
  2. (B)malloc Call
  3. (C)Page Fault
  4. (D)System Call
Answer: C, D - show solution

A function call is an ordinary jump within user mode. malloc is a library routine that usually serves requests from memory already obtained by the process and only sometimes calls brk/mmap, so it does not guarantee a mode switch. A page fault is an exception that always traps into the kernel's fault handler. A system call executes a trap instruction that always switches to kernel mode. Answer: (C) and (D).

Concept: Only traps, exceptions and interrupts guarantee entry to kernel mode. The trap is malloc: it may make a system call, but not on every invocation.

Q24MSQ1 mark · no negative· Easy

Which of the following statements is/are CORRECT?

  1. (A)The intersection of two regular languages is regular.
  2. (B)The intersection of two context-free languages is context-free.
  3. (C)The intersection of two recursive languages is recursive.
  4. (D)The intersection of two recursively enumerable languages is recursively enumerable.
Answer: A, C, D - show solution

Regular languages are closed under intersection (product automaton), so (A) is correct. CFLs are not: {aⁿbⁿcᵐ} ∩ {aᵐbⁿcⁿ} = {aⁿbⁿcⁿ}, which is not context-free, so (B) is incorrect. Recursive languages are closed under intersection (run both deciders, accept if both accept), so (C) is correct. Recursively enumerable languages are closed under intersection (run both recognisers; accept if both accept; if either loops the string is not in the intersection anyway), so (D) is correct. Answer: (A), (C), (D).

Concept: Closure under intersection holds for regular, recursive and RE languages but fails for CFLs. The standard counterexample is the intersection giving aⁿbⁿcⁿ.

Q25MSQ1 mark · no negative· Easy

Which of the following statements is/are INCORRECT about the OSPF (Open Shortest Path First) routing protocol used in the Internet?

  1. (A)OSPF implements Bellman-Ford algorithm to find shortest paths.
  2. (B)OSPF uses Dijkstra's shortest path algorithm to implement least-cost path routing.
  3. (C)OSPF is used as an inter-domain routing protocol.
  4. (D)OSPF implements hierarchical routing.
Answer: A, C - show solution

OSPF is a link-state protocol: each router floods link-state advertisements and computes least-cost paths with Dijkstra's algorithm, so (B) is correct and (A), which describes distance-vector protocols like RIP, is incorrect. OSPF is an interior gateway protocol used within one autonomous system (intra-domain); inter-domain routing uses BGP, so (C) is incorrect. OSPF supports hierarchical routing through areas and a backbone area, so (D) is correct. The INCORRECT statements are (A) and (C).

Concept: Link-state = Dijkstra (OSPF); distance-vector = Bellman-Ford (RIP); inter-domain = BGP. Note the question asks for INCORRECT statements.

Q26MSQ1 mark · no negative· Moderate

Geetha has a conjecture about integers, which is of the form ∀x (P(x) ⇒ ∃y Q(x, y)), where P is a statement about integers, and Q is a statement about pairs of integers. Which of the following (one or more) option(s) would imply Geetha's conjecture?

  1. (A)∃x (P(x) ∧ ∀y Q(x, y))
  2. (B)∀x ∀y Q(x, y)
  3. (C)∃y ∀x (P(x) ⇒ Q(x, y))
  4. (D)∃x (P(x) ∧ ∃y Q(x, y))
Answer: B, C - show solution

(B): if Q(x, y) holds for all x, y, then for every x, ∃y Q(x, y) is true, so P(x) ⇒ ∃y Q(x, y) holds for all x. (C): take the witness y0; for every x, P(x) ⇒ Q(x, y0), hence P(x) ⇒ ∃y Q(x, y). So ∃y∀x implies ∀x∃y. (A) and (D) speak about only one particular x; another x with P(x) true and no suitable y would still falsify the conjecture. Answer: (B) and (C).

Concept: Quantifier strength: ∃y∀x implies ∀x∃y, and a universal statement implies its weaker forms. Statements about a single x (existentials) never imply a universal claim.

Q28MSQ1 mark · no negative· Easy

Let f(x) = x³ + 15x² - 33x - 36 be a real-valued function. Which of the following statements is/are TRUE?

  1. (A)f (x) does not have a local maximum.
  2. (B)f (x) has a local maximum.
  3. (C)f (x) does not have a local minimum.
  4. (D)f (x) has a local minimum.
Answer: B, D - show solution

f'(x) = 3x² + 30x - 33 = 3(x² + 10x - 11) = 3(x + 11)(x - 1), so critical points are x = -11 and x = 1. f''(x) = 6x + 30: f''(-11) = -36 < 0, a local maximum; f''(1) = 36 > 0, a local minimum. Answer: (B) f(x) has a local maximum and (D) f(x) has a local minimum.

Concept: A cubic with two distinct real critical points has one local maximum and one local minimum (but no global extrema). The trap is confusing "no global maximum" with "no local maximum".

Q29MSQ1 mark · no negative· Easy

Let f and g be functions of natural numbers given by f(n) = n and g(n) = n². Which of the following statements is/are TRUE?

  1. (A)f ∈ O(g)
  2. (B)f ∈ Ω(g)
  3. (C)f ∈ o(g)
  4. (D)f ∈ Θ(g)
Answer: A, C - show solution

n ≤ n² for all n ≥ 1, so f ∈ O(g). Moreover f(n)/g(n) = 1/n → 0, so f ∈ o(g) (strictly slower growth). Since the ratio tends to 0, there is no constant c > 0 with n ≥ c·n² for all large n, so f ∉ Ω(g) and therefore f ∉ Θ(g). Answer: (A) and (C).

Concept: Little-o means the ratio tends to 0, which implies big-O but rules out Ω and Θ. The trap is marking only O and forgetting that o also holds.

Q31NAT1 mark · no negative· Easy

The value of the definite integral ∫ from x = -3 to 3 ∫ from y = -2 to 2 ∫ from z = -1 to 1 (4x²y - z³) dz dy dx is ________. (Rounded off to the nearest integer)

Answer: 0 - show solution

Split the integrand. ∫∫∫ 4x²y: the y-integral ∫ from -2 to 2 of y dy = 0 (odd function over a symmetric interval), so this term is 0. ∫∫∫ z³: the z-integral ∫ from -1 to 1 of z³ dz = 0, also odd. Hence the whole integral is 0. Answer: 0.

Concept: Odd-function symmetry: integrating an odd power of a variable over a symmetric interval gives zero. Spotting it avoids a long computation.

Q32NAT1 mark · no negative· Easy

A particular number is written as 132 in radix-4 representation. The same number in radix-5 representation is .

Answer: 110 - show solution

132 in radix 4 = 1×16 + 3×4 + 2 = 30 in decimal. Convert 30 to radix 5: 30 = 1×25 + 1×5 + 0, so the digits are 1, 1, 0. Answer: 110.

Concept: Base conversion via decimal. A common slip is reading 132 as decimal or reversing the digits when dividing repeatedly by 5.

Q33NAT1 mark · no negative· Easy

Consider a 3-stage pipelined processor having a delay of 10 ns (nanoseconds), 20 ns, and 14 ns, for the first, second, and the third stages, respectively. Assume that there is no other delay and the processor does not suffer from any pipeline hazards. Also assume that one instruction is fetched every cycle. The total execution time for executing 100 instructions on this processor is ns.

Answer: 2040 - show solution

The clock cycle must accommodate the slowest stage: max(10, 20, 14) = 20 ns. For k = 3 stages and n = 100 instructions with no hazards, total cycles = k + n - 1 = 3 + 99 = 102. Time = 102 × 20 = 2040 ns. Answer: 2040.

Concept: Pipeline time = (k + n - 1) × cycle time, with the cycle set by the slowest stage. Traps: using the sum of stage delays (44 ns) as the cycle, or using n × k.

Q34NAT1 mark · no negative· Moderate

A keyboard connected to a computer is used at a rate of 1 keystroke per second. The computer system polls the keyboard every 10 ms (milli seconds) to check for a keystroke and consumes 100 μs (micro seconds) for each poll. If it is determined after polling that a key has been pressed, the system consumes an additional 200 μs to process the keystroke. Let T1 denote the fraction of a second spent in polling and processing a keystroke. In an alternative implementation, the system uses interrupts instead of polling. An interrupt is raised for every keystroke. It takes a total of 1 ms for servicing an interrupt and processing a keystroke. Let T2 denote the fraction of a second spent in servicing the interrupt and processing a keystroke. The ratio T1/T2 is ________. (Rounded off to one decimal place)

Answer: 10.2 - show solution

Polling: 1 s / 10 ms = 100 polls per second, each 100 μs, giving 10,000 μs = 10 ms. Plus one keystroke processed: 200 μs. T1 = 10.2 ms per second. Interrupts: one keystroke per second, 1 ms each, so T2 = 1 ms per second. T1/T2 = 10.2 / 1 = 10.2. Answer: 10.2.

Concept: Polling costs time even when nothing happens; interrupts cost only per event. Remember to add the 200 μs processing for the one actual keystroke.

Q35NAT1 mark · no negative· Easy

The integer value printed by the ANSI-C program given below is ________.

#include<stdio.h>

int funcp(){
    static int x = 1;
    x++;
    return x;
}

int main(){
    int x,y;
    x = funcp();
    y = funcp()+x;
    printf("%d\n", (x+y));
    return 0;
}
Answer: 7 - show solution

The static x in funcp is initialised once to 1 and keeps its value between calls. First call: x becomes 2 and returns 2, so main's x = 2. Second call: static x becomes 3 and returns 3, so y = 3 + 2 = 5. Printed value: x + y = 2 + 5 = 7. Answer: 7.

Concept: A static local variable is initialised once and persists across calls. The trap is re-initialising it to 1 on every call, which would give 2 + 4 = 6.

Q36MCQ2 marks · -2/3· Moderate

Consider the following program. Which one of the following options represents the activation tree corresponding to the main function? (Each tree is written as parent -> children, children listed left to right.)

int main()
{
    f1();
    f2(2);
    f3();
    return(0);
}

int f1()
{
    return(1);
}

int f2(int X)
{
    f3();
    if (X==1)
        return f1();
    else
        return (X*f2(X-1));
}

int f3()
{
    return(5);
}
  1. (A)main -> f1, f2, f3; that f2 -> f3, f2; the inner f2 -> f3, f1
  2. (B)main -> f1, f2, f3; f2 -> f3, f1
  3. (C)main -> f1; f1 -> f2; f2 -> f3, f1
  4. (D)main -> f1, f2, f3; f2 -> f3, f2, f1
Answer: A - show solution

main calls f1(), f2(2), f3() in that order, so its children are f1, f2, f3. f2(2) first calls f3(); since X = 2 ≠ 1 it then calls f2(1). So f2(2) has children f3, f2. f2(1) calls f3(), then, since X == 1, calls f1(). So f2(1) has children f3, f1. f1 and f3 make no calls. Answer: (A).

Concept: An activation tree has one node per call, with children in call order. The trap is (D), which flattens the recursive call f2(1) and its callees into one level.

Q37MCQ2 marks · -2/3· Moderate

Consider the control flow graph shown. B1: i = m - 1; j = n; a = 10. B2: i = i + 1; j = j - 1. B3: a = 20. B4: i = a + 1. Edges: ENTRY -> B1, B1 -> B2, B2 -> B3, B2 -> B4, B3 -> B4, B4 -> B2, B4 -> EXIT. Which one of the following choices correctly lists the set of live variables at the exit point of each basic block?

  1. (A)B1: {}, B2: {a}, B3: {a}, B4: {a}
  2. (B)B1: {i, j}, B2: {a}, B3: {a}, B4: {i}
  3. (C)B1: {a, i, j}, B2: {a, i, j}, B3: {a, i}, B4: {a}
  4. (D)B1: {a, i, j}, B2: {a, j}, B3: {a, j}, B4: {a, i, j}
Answer: D - show solution

Use IN(B) = USE(B) ∪ (OUT(B) - DEF(B)). B2: USE {i, j}, DEF {i, j}. B3: DEF {a}. B4: USE {a}, DEF {i}. OUT(B4) = IN(B2) ∪ IN(EXIT) = IN(B2). Iterate to a fixed point: IN(B2) = {i, j} ∪ (OUT(B2) - {i, j}); OUT(B2) = IN(B3) ∪ IN(B4); IN(B4) = {a} ∪ (OUT(B4) - {i}); IN(B3) = OUT(B3) - {a} = IN(B4) - {a}. Fixed point: IN(B2) = {a, i, j}, so OUT(B4) = {a, i, j}, IN(B4) = {a, j}, OUT(B3) = {a, j}, IN(B3) = {j}, OUT(B2) = {a, j}, OUT(B1) = {a, i, j}. Answer: (D) B1: {a, i, j}, B2: {a, j}, B3: {a, j}, B4: {a, i, j}.

Concept: Backward data-flow analysis with the loop B4 -> B2 carrying i and j back. The trap is ignoring the back edge, which makes i and j look dead at the end of B4.

Q38MCQ2 marks · -2/3· Moderate

Consider the two functions incr and decr shown below. There are 5 threads each invoking incr once, and 3 threads each invoking decr once, on the same shared variable X. The initial value of X is 10. Suppose there are two implementations of the semaphore s, as follows: I-1: s is a binary semaphore initialized to 1. I-2: s is a counting semaphore initialized to 2. Let V1, V2 be the values of X at the end of execution of all the threads with implementations I-1, I-2, respectively. Which one of the following choices corresponds to the minimum possible values of V1, V2, respectively?

incr(){
    wait(s);
    X = X+1;
    signal(s);
}

decr(){
    wait(s);
    X = X-1;
    signal(s);
}
  1. (A)15, 7
  2. (B)7, 7
  3. (C)12, 7
  4. (D)12, 8
Answer: C - show solution

I-1: a binary semaphore gives mutual exclusion, so every update takes effect: V1 = 10 + 5 - 3 = 12. I-2: two threads can be inside together, so X = X ± 1 (read, modify, write) can race. Minimum: decr1 reads X = 10 and pauses. Through the other slot all 5 incr run one after another, X = 15. decr1 now writes 10 - 1 = 9, wiping out all increments. The remaining two decr run serially: 8, 7. Nothing lower is possible, since only 3 decrements exist and every write is some read value ± 1. V2 = 7. Answer: (C) 12, 7.

Concept: A counting semaphore initialised to 2 is not a mutex, so lost updates are possible. To minimise, let one stale decrement overwrite all the increments.

Q39MCQ2 marks · -2/3· Moderate

Consider the context-free grammar G below: S → aSb | X, X → aX | Xb | a | b, where S and X are non-terminals, and a and b are terminal symbols. The starting non-terminal is S. Which one of the following statements is CORRECT?

  1. (A)The language generated by G is (a + b)*
  2. (B)The language generated by G is a*(a + b)b*
  3. (C)The language generated by G is a*b*(a + b)
  4. (D)The language generated by G is not a regular language
Answer: B - show solution

X generates any number of a's on the left and b's on the right around one base symbol a or b: L(X) = a*(a + b)b*. S → aSb wraps X in equal numbers of a's and b's: L(S) = {aⁿ w bⁿ : w ∈ a*(a + b)b*, n ≥ 0}. Since aⁿa* = a* and b*bⁿ = b*, this is just a*(a + b)b*, which is regular. Strings like "ba" are not generated, ruling out (A), and (C) wrongly puts the single symbol at the end. Answer: (B).

Concept: The aSb rule looks like it forces equal counts, but X already absorbs arbitrary a's and b's, so the language stays regular. The trap is option (D).

Q40MCQ2 marks · -2/3· Moderate

Consider the pushdown automaton (PDA) P below, which runs on the input alphabet {a, b}, has stack alphabet {⊥, A}, and has three states {s, p, q}, with s being the start state. A transition from state u to state v, labelled c/X/γ, where c is an input symbol or ϵ, X is a stack symbol, and γ is a string of stack symbols, represents the fact that in state u, the PDA can read c from the input, with X on the top of its stack, pop X from the stack, push in the string γ on the stack, and go to state v. In the initial configuration, the stack has only the symbol ⊥ in it. The PDA accepts by empty stack. Transitions: s --a/⊥/A⊥--> s; s --a/A/AA--> s; s --b/A/ϵ--> p; p --b/A/ϵ--> p; s --ϵ/A/ϵ--> q; p --ϵ/A/ϵ--> q; q --ϵ/A/ϵ--> q; q --ϵ/⊥/ϵ--> q. Which one of the following options correctly describes the language accepted by P?

  1. (A){aᵐbⁿ | 1 ≤ m and n < m}
  2. (B){aᵐbⁿ | 0 ≤ n ≤ m}
  3. (C){aᵐbⁿ | 0 ≤ m and 0 ≤ n}
  4. (D){aᵐ | 0 ≤ m} ∪ {bⁿ | 0 ≤ n}
Answer: A - show solution

The stack can only be emptied in q (the only move that pops ⊥), and q can be entered only by popping an A. In s, each a pushes one A. Reading b's (s to p, then p) pops one A per b. To reach q from s or p we need an A still on top, so after m a's and n b's we need m - n ≥ 1. In q the remaining A's and ⊥ are popped. The empty string fails (no A to enter q), and m ≥ 1 with n < m works. Language: {aᵐbⁿ | m ≥ 1, n < m}. Answer: (A).

Concept: With empty-stack acceptance, find the only route that pops the bottom marker. Here entering q costs one A, so b's must be strictly fewer than a's; the trap is (B), which allows n = m.

Q41MCQ2 marks · -2/3· Moderate

Consider the given C-code and its corresponding assembly code, with a few operands U1-U4 being unknown. Some useful information as well as the semantics of each unique assembly instruction is annotated as inline comments in the code. The memory is byte-addressable. Which one of the following options is a CORRECT replacement for operands in the position (U1, U2, U3, U4) in the above assembly code?

//C-code
int a[10], b[10], i;
// int is 32-bit
for (i=0; i<10;i++)
    a[i] = b[i] * 8;

;assembly-code (; indicates comments)
;r1-r5 are 32-bit integer registers
;initialize r1=0, r2=10
;initialize r3, r4 with base address of a, b
L01: jeq r1, r2, end   ;if(r1==r2) goto end
L02: lw  r5, 0(r4)     ;r5 <- Memory[r4+0]
L03: shl r5, r5, U1    ;r5 <- r5 << U1
L04: sw  r5, 0(r3)     ;Memory[r3+0] <- r5
L05: add r3, r3, U2    ;r3 <- r3+U2
L06: add r4, r4, U3
L07: add r1, r1, 1
L08: jmp U4            ;goto U4
L09: end
  1. (A)(8, 4, 1, L02)
  2. (B)(3, 4, 4, L01)
  3. (C)(8, 1, 1, L02)
  4. (D)(3, 1, 1, L01)
Answer: B - show solution

Multiplying by 8 = 2³ is a left shift by 3, so U1 = 3. int is 32 bits = 4 bytes and memory is byte-addressable, so the pointers to a[i] and b[i] advance by 4 each iteration: U2 = 4, U3 = 4. The loop must re-test the condition r1 == r2 every iteration, so it jumps back to L01: U4 = L01 (jumping to L02 would never exit). Answer: (B) (3, 4, 4, L01).

Concept: Tests strength reduction (×8 = <<3) and byte addressing (stride = sizeof(int) = 4). The traps are shifting by 8 and stepping pointers by 1.

Q42MCQ2 marks · -2/3· Moderate

A 4 kilobyte (KB) byte-addressable memory is realized using four 1 KB memory blocks X1, X2, X3, X4. Two input address lines (IA4 and IA3) are connected to the chip select (CS) port of these memory blocks through a 2-to-4 decoder: IA4 drives decoder input A1, IA3 drives A0, and decoder outputs Q0, Q1, Q2, Q3 drive the CS of X1, X2, X3, X4 respectively. The remaining ten input address lines IA11-IA5 and IA2-IA0 are connected (as a 10-bit bus, IA11 as MSB and IA0 as LSB) to the address port of each block. The chip select (CS) is active high. The input memory addresses (IA11-IA0), in decimal, for the starting locations (Addr=0) of each block are among the options given below. Which one of the following options is CORRECT?

  1. (A)(0, 1, 2, 3)
  2. (B)(0, 1024, 2048, 3072)
  3. (C)(0, 8, 16, 24)
  4. (D)(0, 0, 0, 0)
Answer: C - show solution

Addr = 0 inside a block means all ten address-port lines (IA11-IA5, IA2-IA0) are 0. Only IA4 and IA3 vary, selecting the block. X1: IA4 IA3 = 00, address 0. X2: 01, IA3 = 1, address 2³ = 8. X3: 10, IA4 = 1, address 2⁴ = 16. X4: 11, address 16 + 8 = 24. Answer: (C) (0, 8, 16, 24).

Concept: Chip-select lines taken from the middle of the address bus interleave blocks. The trap is (B), which assumes the top two bits (IA11, IA10) select the block.

Q43MCQ2 marks · -2/3· Moderate

Consider a sequential digital circuit consisting of T flip-flops and D flip-flops as shown in the figure. CLKIN is the clock input to the circuit and clocks all three flip-flops. Flip-flop 1 is a T flip-flop with output Q1 whose T input is Q3' (Q3 passed through an inverter); flip-flop 2 is a D flip-flop with D = Q1 and output Q2; flip-flop 3 is a T flip-flop with T = Q2 and output Q3. At the beginning, Q1, Q2 and Q3 have values 0, 1 and 1, respectively. Which one of the given values of (Q1, Q2, Q3) can NEVER be obtained with this digital circuit?

  1. (A)(0, 0, 1)
  2. (B)(1, 0, 0)
  3. (C)(1, 0, 1)
  4. (D)(1, 1, 1)
Answer: A - show solution

Next state: Q1+ = Q1 XOR Q3', Q2+ = Q1, Q3+ = Q3 XOR Q2. From (0,1,1): T1 = 0, so (0,0,0). Then (1,0,0), (0,1,0), (1,0,1), (1,1,1), (1,1,0), and back to (0,1,1). The cycle visits 011, 000, 100, 010, 101, 111, 110 - seven states. The only missing state is (0,0,1). Answer: (A) (0, 0, 1).

Concept: Write the next-state equations and trace from the given initial state. T flip-flops toggle when T = 1; the D flip-flop copies Q1. Options (B), (C), (D) all appear in the cycle.

Q44MCQ2 marks · -2/3· Moderate

A Boolean digital circuit is composed using two 4-input multiplexers (M1 and M2) and one 2-input multiplexer (M3). X0-X3 are the data inputs 0-3 of M1 and X4-X7 are the data inputs 0-3 of M2; each could be connected to either 0 or 1. Both M1 and M2 have select lines S1 = A and S0 = C. The outputs of M1 and M2 go to inputs 0 and 1 of M3 respectively, and M3's select line is B. Which one of the following set of values of (X0, X1, X2, X3, X4, X5, X6, X7) will realise the Boolean function A' + A'.C' + A.B'.C?

  1. (A)(1, 1, 0, 0, 1, 1, 1, 0)
  2. (B)(1, 1, 0, 0, 1, 1, 0, 1)
  3. (C)(1, 1, 0, 1, 1, 1, 0, 0)
  4. (D)(0, 0, 1, 1, 0, 1, 1, 1)
Answer: C - show solution

Simplify: A' + A'C' = A', so F = A' + AB'C. B = 0 selects M1: F = A' + AC; inputs indexed by (A, C): 00 gives 1, 01 gives 1, 10 gives 0, 11 gives 1, so X0..X3 = 1, 1, 0, 1. B = 1 selects M2: F = A'; (A, C) = 00, 01 give 1, 10, 11 give 0, so X4..X7 = 1, 1, 0, 0. Answer: (C) (1, 1, 0, 1, 1, 1, 0, 0).

Concept: Split the function on the M3 select variable (B), then fill each 4-input mux with the truth table in its own select order (A as S1, C as S0). Using the wrong select order swaps X1 and X2.

Q45MCQ2 marks · -2/3· Moderate

Consider the IEEE-754 single precision floating point numbers P=0xC1800000 and Q=0x3F5C2EF4. Which one of the following corresponds to the product of these numbers (i.e., P × Q), represented in the IEEE-754 single precision format?

  1. (A)0x404C2EF4
  2. (B)0x405C2EF4
  3. (C)0xC15C2EF4
  4. (D)0xC14C2EF4
Answer: C - show solution

P = 0xC1800000: sign 1, exponent 1000 0011 = 131, so 2^(131-127) = 2⁴, mantissa 0: P = -16. Q = 0x3F5C2EF4: sign 0, exponent 0111 1110 = 126, fraction 0x5C2EF4, Q = 1.f × 2⁻¹. P × Q = -(1.f) × 2³: same fraction, exponent 126 + 4 = 130 = 1000 0010, sign 1. Bits: 1 10000010 then fraction 0x5C2EF4, i.e. 0xC1000000 + 0x5C2EF4 = 0xC15C2EF4. Answer: (C).

Concept: Multiplying by a power of two only changes the exponent (and here the sign); the fraction bits are copied. The trap is forgetting the sign or adding 4 to the wrong field.

Q46MCQ2 marks · -2/3· Easy

Let A be a priority queue for maintaining a set of elements. Suppose A is implemented using a max-heap data structure. The operation Extract-Max(A) extracts and deletes the maximum element from A. The operation Insert(A,key) inserts a new element key in A. The properties of a max-heap are preserved at the end of each of these operations. When A contains n elements, which one of the following statements about the worst case running time of these two operations is TRUE?

  1. (A)Both Extract-Max(A) and Insert(A,key) run in O(1).
  2. (B)Both Extract-Max(A) and Insert(A,key) run in O(log(n)).
  3. (C)Extract-Max(A) runs in O(1) whereas Insert(A,key) runs in O(n).
  4. (D)Extract-Max(A) runs in O(1) whereas Insert(A,key) runs in O(log(n)).
Answer: B - show solution

Extract-Max removes the root, moves the last element to the root and sifts it down, at most the tree height: O(log n). Insert places the key at the end and sifts it up, again at most the height: O(log n). Neither can be O(1) in the worst case because restoring the heap may need a full root-to-leaf path. Answer: (B) Both run in O(log(n)).

Concept: Finding the max is O(1), but extracting it is O(log n) because of the heapify step. The trap is (D), which confuses Find-Max with Extract-Max.

Q47MCQ2 marks · -2/3· Easy

Consider the C function foo and the binary tree shown. The tree has root 10; 10 has left child 5 and right child 11; 5 has left child 3 and right child 8; 11 has only a right child 13. When foo is called with a pointer to the root node of the given binary tree, what will it print?

typedef struct node {
    int val;
    struct node *left, *right;
} node;

int foo(node *p) {
    int retval;
    if (p == NULL)
        return 0;
    else {
        retval = p->val + foo(p->left) + foo(p->right);
        printf("%d ", retval);
        return retval;
    }
}
  1. (A)3 8 5 13 11 10
  2. (B)3 5 8 10 11 13
  3. (C)3 8 16 13 24 50
  4. (D)3 16 8 50 24 13
Answer: C - show solution

foo prints after both recursive calls, i.e. in postorder, and each printed value is the sum of the subtree. Postorder: 3, 8, 5, 13, 11, 10. Sums: subtree 3 = 3; subtree 8 = 8; subtree 5 = 5 + 3 + 8 = 16; subtree 13 = 13; subtree 11 = 11 + 0 + 13 = 24; subtree 10 = 10 + 16 + 24 = 50. Output: 3 8 16 13 24 50. Answer: (C).

Concept: Postorder traversal returning subtree sums. The trap is (A), which prints node values in postorder rather than the accumulated sums.

Q48MCQ2 marks · -2/3· Moderate

Let U = {1, 2, ..., n}, where n is a large positive integer greater than 1000. Let k be a positive integer less than n. Let A, B be subsets of U with |A| = |B| = k and A ∩ B = ∅. We say that a permutation of U separates A from B if one of the following is true. - All members of A appear in the permutation before any of the members of B. - All members of B appear in the permutation before any of the members of A. How many permutations of U separate A from B?

  1. (A)n!
  2. (B)C(n, 2k) (n - 2k)!
  3. (C)C(n, 2k) (n - 2k)! (k!)²
  4. (D)2 C(n, 2k) (n - 2k)! (k!)²
Answer: D - show solution

Choose the 2k positions occupied by A ∪ B: C(n, 2k). Fill the other n - 2k positions with the remaining elements: (n - 2k)!. Within the chosen positions, either A takes the first k or B does: 2 ways; then arrange A among its k positions (k!) and B among its k (k!). Total = 2 C(n, 2k) (n - 2k)! (k!)². The two cases are disjoint since k ≥ 1. Answer: (D).

Concept: Positions-first counting. The trap is (C), which forgets that either A or B may come first.

Q49MSQ2 marks · no negative· Moderate

Let f : A B be an onto (or surjective) function, where A and B are nonempty sets. Define an equivalence relation on the set A as a1 a2 if f (a1) = f (a2) , where a1, a2 A. Let E = {[x] : x A} be the set of all the equivalence classes under . Define a new mapping F : E B as F ([x]) = f (x), for all the equivalence classes [x] in E. Which of the following statements is/are TRUE?

  1. (A)F is NOT well-defined.
  2. (B)F is an onto (or surjective) function.
  3. (C)F is a one-to-one (or injective) function.
  4. (D)F is a bijective function.
Answer: B, C, D - show solution

Well-defined: if [x] = [y] then x ∼ y, i.e. f(x) = f(y), so F([x]) does not depend on the representative; (A) is false. Onto: for b ∈ B, f onto gives x with f(x) = b, so F([x]) = b. One-to-one: F([x]) = F([y]) means f(x) = f(y), i.e. x ∼ y, so [x] = [y]. Being injective and surjective, F is bijective. Answer: (B), (C), (D).

Concept: The quotient of a function by its kernel relation is always injective; surjectivity is inherited from f. This is the set-level first isomorphism theorem.

Q50MSQ2 marks · no negative· Moderate

Suppose you are asked to design a new reliable byte-stream transport protocol like TCP. This protocol, named myTCP, runs over a 100 Mbps network with Round Trip Time of 150 milliseconds and the maximum segment lifetime of 2 minutes. Which of the following is/are valid lengths of the Sequence Number field in the myTCP header?

  1. (A)30 bits
  2. (B)32 bits
  3. (C)34 bits
  4. (D)36 bits
Answer: B, C, D - show solution

Sequence numbers count bytes and must not wrap around within the maximum segment lifetime. Bytes sent in 2 minutes at 100 Mbps: 100 × 10⁶ / 8 × 120 = 1.5 × 10⁹ bytes. Need 2^b ≥ 1.5 × 10⁹. 2³⁰ ≈ 1.07 × 10⁹ is too small; 2³¹ ≈ 2.15 × 10⁹ suffices. So any length ≥ 31 bits is valid: 32, 34, 36 bits. (The window needed for the 150 ms RTT, about 1.9 MB, is much smaller.) Answer: (B), (C), (D).

Concept: Sequence space must exceed the bytes that can be in flight during one MSL so old segments cannot be confused with new ones. The trap is sizing by RTT instead of MSL.

Q51MSQ2 marks · no negative· Moderate

Let X be a set and 2^X denote the powerset of X. Define a binary operation Δ on 2^X as follows: AΔB = (A - B) ∪ (B - A). Let H = (2^X, Δ). Which of the following statements about H is/are correct?

  1. (A)H is a group.
  2. (B)Every element in H has an inverse, but H is NOT a group.
  3. (C)For every A ∈ 2^X, the inverse of A is the complement of A.
  4. (D)For every A ∈ 2^X, the inverse of A is A.
Answer: A, D - show solution

Symmetric difference is closed on subsets of X and associative (it is XOR of characteristic functions). Identity: AΔ∅ = A. Inverse: AΔA = ∅, so each A is its own inverse. Hence H is a group (an abelian one), (A) true, (B) false. The complement is not the inverse: AΔA' = X ≠ ∅ unless X is empty. Answer: (A) and (D).

Concept: The power set under symmetric difference is a group with identity ∅ in which every element is self-inverse. The trap is guessing the complement as inverse, which gives X, not the identity.

Q52MSQ2 marks · no negative· Moderate

Suppose in a web browser, you click on the www.gate-2023.in URL. The browser cache is empty. The IP address for this URL is not cached in your local host, so a DNS lookup is triggered (by the local DNS server deployed on your local host) over the 3-tier DNS hierarchy in an iterative mode. No resource records are cached anywhere across all DNS servers. Let RTT denote the round trip time between your local host and DNS servers in the DNS hierarchy. The round trip time between the local host and the web server hosting www.gate-2023.in is also equal to RTT. The HTML file associated with the URL is small enough to have negligible transmission time and negligible rendering time by your web browser, which references 10 equally small objects on the same web server. Which of the following statements is/are CORRECT about the minimum elapsed time between clicking on the URL and your browser fully rendering it?

  1. (A)7 RTTs, in case of non-persistent HTTP with 5 parallel TCP connections.
  2. (B)5 RTTs, in case of persistent HTTP with pipelining.
  3. (C)9 RTTs, in case of non-persistent HTTP with 5 parallel TCP connections.
  4. (D)6 RTTs, in case of persistent HTTP with pipelining.
Answer: C, D - show solution

DNS: iterative lookup through root, TLD and authoritative servers costs 3 RTT. Non-persistent HTTP, 5 parallel connections: base HTML needs TCP setup + request = 2 RTT; the 10 objects go in two rounds of 5, each round 2 RTT (new TCP connection + request) = 4 RTT. Total 3 + 2 + 4 = 9 RTT. Persistent HTTP with pipelining: TCP setup 1 RTT, HTML 1 RTT, all 10 objects pipelined in 1 RTT, total 3 + 3 = 6 RTT. Answer: (C) and (D).

Concept: Count RTTs per phase: DNS levels, TCP handshake, each request round. Non-persistent pays a handshake per object; pipelining collapses all object requests into one RTT.

Q53MSQ2 marks · no negative· Easy

Consider a random experiment where two fair coins are tossed. Let A be the event that denotes HEAD on both the throws, B be the event that denotes HEAD on the first throw, and C be the event that denotes HEAD on the second throw. Which of the following statements is/are TRUE?

  1. (A)A and B are independent.
  2. (B)A and C are independent.
  3. (C)B and C are independent.
  4. (D)Prob(B|C) = Prob(B)
Answer: C, D - show solution

P(A) = 1/4, P(B) = P(C) = 1/2. A ⊆ B, so P(A ∩ B) = 1/4 ≠ P(A)P(B) = 1/8: not independent. Likewise A and C. B ∩ C = A, P = 1/4 = (1/2)(1/2): B and C are independent, which is the same as P(B|C) = P(B ∩ C)/P(C) = (1/4)/(1/2) = 1/2 = P(B). Answer: (C) and (D).

Concept: Independence means P(X ∩ Y) = P(X)P(Y). An event contained in another (A ⊆ B) with probabilities strictly between 0 and 1 is never independent of it.

Q54MSQ2 marks · no negative· Moderate

Consider functions Function 1 and Function 2 expressed in pseudocode as follows. Let f1(n) and f2(n) denote the number of times the statement "x = x + 1" is executed in Function 1 and Function 2, respectively. Which of the following statements is/are TRUE?

Function 1
  while n > 1 do
      for i = 1 to n do
          x = x + 1;
      end for
      n = floor(n/2);
  end while

Function 2
  for i = 1 to 100 * n do
      x = x + 1;
  end for
  1. (A)f1(n) ∈ Θ(f2(n))
  2. (B)f1(n) ∈ o(f2(n))
  3. (C)f1(n) ∈ ω(f2(n))
  4. (D)f1(n) ∈ O(n)
Answer: A, D - show solution

f1(n) = n + floor(n/2) + floor(n/4) + ... (while the value exceeds 1), which lies between n and 2n, so f1(n) = Θ(n). f2(n) = 100n = Θ(n). Hence f1 ∈ Θ(f2) and f1 ∈ O(n). Since the ratio f1/f2 stays between 1/100 and 1/50 (roughly), it neither tends to 0 nor to infinity, so o and ω are false. Answer: (A) and (D).

Concept: A geometric series n + n/2 + n/4 + ... sums to under 2n, so the halving loop is linear, not n log n. Constant factors like 100 do not affect Θ.

Q55MSQ2 marks · no negative· Moderate

Let G be a simple, finite, undirected graph with vertex set {v1, ..., vn}. Let Δ(G) denote the maximum degree of G and let N = {1, 2, ...} denote the set of all possible colors. Color the vertices of G using the following greedy strategy: for i = 1, ..., n: color(vᵢ) ← min{j ∈ N : no neighbour of vᵢ is colored j}. Which of the following statements is/are TRUE?

  1. (A)This procedure results in a proper vertex coloring of G.
  2. (B)The number of colors used is at most Δ(G) + 1.
  3. (C)The number of colors used is at most Δ(G).
  4. (D)The number of colors used is equal to the chromatic number of G.
Answer: A, B - show solution

Each vertex receives a color not used by any already-colored neighbour, and later neighbours avoid it in turn, so the coloring is proper: (A). A vertex has at most Δ(G) neighbours, so among the colors 1..Δ(G)+1 at least one is free: (B). (C) fails for a complete graph K_n, where Δ = n - 1 but n colors are needed. (D) fails because greedy depends on the order; e.g. a path a-b-c-d ordered a, d, b, c uses 3 colors though it is 2-colorable. Answer: (A) and (B).

Concept: Greedy coloring is always proper and uses at most Δ + 1 colors, but it is not optimal in general. Complete graphs and odd cycles show Δ colors can be insufficient.

Q56NAT2 marks · no negative· Moderate

Let U = {1, 2, 3}. Let 2^U denote the powerset of U. Consider an undirected graph G whose vertex set is 2^U. For any A, B ∈ 2^U, (A, B) is an edge in G if and only if (i) A ≠ B, and (ii) either A ⊊ B or B ⊊ A. For any vertex A in G, the set of all possible orderings in which the vertices of G can be visited in a Breadth First Search (BFS) starting from A is denoted by B(A). If ∅ denotes the empty set, then the cardinality of B(∅) is ________.

Answer: 5040 - show solution

G has 8 vertices. ∅ is a proper subset of every other subset, so ∅ is adjacent to all 7 other vertices. BFS from ∅ visits ∅ first and then discovers all 7 neighbours at level 1; they may be enqueued in any order, and once they are all discovered nothing else remains. So every ordering of the 7 non-empty subsets is a valid BFS order: 7! = 5040. Answer: 5040.

Concept: BFS order freedom comes from the order in which neighbours are enqueued. Because the start vertex is adjacent to everything, the count is simply 7!.

Q57NAT2 marks · no negative· Moderate

Consider the following two-dimensional array D in the C programming language, which is stored in row-major order: int D[128][128]; Demand paging is used for allocating memory and each physical page frame holds 512 elements of the array D. The Least Recently Used (LRU) page-replacement policy is used by the operating system. A total of 30 physical page frames are allocated to a process which executes the following code snippet. The number of page faults generated during the execution of this code snippet is ________.

for (int i = 0; i < 128; i++)
    for (int j = 0; j < 128; j++)
        D[j][i] *= 10;
Answer: 4096 - show solution

A row has 128 elements, so one page holds 4 rows; the array spans 128/4 = 32 pages. The inner loop walks down column i, touching rows 0..127, i.e. pages 0..31 in order (4 consecutive accesses per page). With only 30 frames under LRU, a cyclic reference to 32 pages faults on every new page: when page p is needed again it was the least recently used one evicted. So each outer iteration causes 32 faults: 128 × 32 = 4096. Answer: 4096.

Concept: Column-wise access to a row-major array crosses pages constantly. LRU with fewer frames than the cyclic working set degenerates to a fault on every page change.

Q58NAT2 marks · no negative· Moderate

Consider a computer system with 57-bit virtual addressing using multi-level tree-structured page tables with L levels for virtual to physical address translation. The page size is 4 KB (1 KB = 1024 B) and a page table entry at any of the levels occupies 8 bytes. The value of L is .

Answer: 5 - show solution

Page size 4 KB = 2¹² bytes, so the offset uses 12 bits and the virtual page number has 57 - 12 = 45 bits. Each page-table page fits in one page: 4096 / 8 = 512 = 2⁹ entries, so each level resolves 9 bits. Levels L = 45 / 9 = 5. Answer: 5.

Concept: Multi-level paging: bits per level = log2(page size / PTE size). This 57-bit, 5-level layout is exactly x86-64 five-level paging.

Q59NAT2 marks · no negative· Easy

Consider a sequence a of elements a0 = 1, a1 = 5, a2 = 7, a3 = 8, a4 = 9, and a5 = 2. The following operations are performed on a stack S and a queue Q, both of which are initially empty. I: push the elements of a from a0 to a5 in that order into S. II: enqueue the elements of a from a0 to a5 in that order into Q. III: pop an element from S. IV: dequeue an element from Q. V: pop an element from S. VI: dequeue an element from Q. VII: dequeue an element from Q and push the same element into S. VIII: Repeat operation VII three times. IX: pop an element from S. X: pop an element from S. The top element of S after executing the above operations is .

Answer: 8 - show solution

I: S (bottom to top) = 1 5 7 8 9 2. II: Q (front to back) = 1 5 7 8 9 2. III: pop 2, S = 1 5 7 8 9. IV: dequeue 1. V: pop 9, S = 1 5 7 8. VI: dequeue 5, Q = 7 8 9 2. VII: dequeue 7, push: S = 1 5 7 8 7. VIII: three more times: push 8, 9, 2, S = 1 5 7 8 7 8 9 2. IX: pop 2. X: pop 9. Top of S = 8. Answer: 8.

Concept: Careful simulation of LIFO vs FIFO. The usual error is miscounting "repeat VII three times" as three in total rather than three more after VII.

Q60NAT2 marks · no negative· Moderate

Consider the syntax directed translation given by the following grammar and semantic rules. Here N, I, F and B are non-terminals. N is the starting non-terminal, and #, 0 and 1 are lexical tokens corresponding to input letters "#", "0" and "1", respectively. X.val denotes the synthesized attribute (a numeric value) associated with a non-terminal X. I1 and F1 denote occurrences of I and F on the right hand side of a production, respectively. For the tokens 0 and 1, 0.val = 0 and 1.val = 1. N → I # F N.val = I.val + F.val I → I1 B I.val = (2 × I1.val) + B.val I → B I.val = B.val F → B F1 F.val = (1/2)(B.val + F1.val) F → B F.val = (1/2) B.val B → 0 B.val = 0.val B → 1 B.val = 1.val The value computed by the translation scheme for the input string 10#011 is ________. (Rounded off to three decimal places)

Answer: 2.374 to 2.376 - show solution

Integer part "10": I(1) = 1, then I(10) = 2 × 1 + 0 = 2. Fraction part "011" is right-recursive: F(1) = 1/2 × 1 = 0.5; F(11) = 1/2 × (1 + 0.5) = 0.75; F(011) = 1/2 × (0 + 0.75) = 0.375. N.val = 2 + 0.375 = 2.375 (binary 10.011). Answer: 2.375 (key range 2.374 to 2.376).

Concept: The scheme converts a binary fixed-point string to decimal: left recursion doubles for integer digits, right recursion halves for fractional digits. Evaluate F from the rightmost digit.

Q61NAT2 marks · no negative· Easy

Consider the following table named Student in a relational database. The primary key of this table is rollNum. rollNum name gender marks 1 Naman M 62 2 Aliya F 70 3 Aliya F 80 4 James M 82 5 Swati F 65 The SQL query below is executed on this database. The number of rows returned by the query is ________.

SELECT *
FROM Student
WHERE gender = 'F' AND
      marks > 65;
Answer: 2 - show solution

Female students: rollNum 2 (70), 3 (80), 5 (65). marks > 65 is strict, so Swati with 65 is excluded. Rows returned: rollNum 2 and 3. Duplicated names do not matter since SELECT * returns whole rows. Answer: 2.

Concept: Straightforward WHERE filtering; the traps are the strict inequality at 65 and wondering whether the duplicate name "Aliya" collapses rows (it does not without DISTINCT, and rows differ anyway).

Q62NAT2 marks · no negative· Moderate

Consider a database of fixed-length records, stored as an ordered file. The database has 25,000 records, with each record being 100 bytes, of which the primary key occupies 15 bytes (the other fields occupy 85 bytes). The data file is block-aligned in that each data record is fully contained within a block. The database is indexed by a primary index file, which is also stored as a block-aligned ordered file. Each index entry holds the primary key of a data block's anchor (first) record and a pointer to that block. Suppose the block size of the file system is 1024 bytes, and a pointer to a block occupies 5 bytes. The system uses binary search on the index file to search for a record with a given key. You may assume that a binary search on an index file of b blocks takes ⌈log2 b⌉ block accesses in the worst case. Given a key, the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is ________.

Answer: 6 - show solution

Records per data block = floor(1024/100) = 10, so data blocks = 25000/10 = 2500. The primary (sparse) index has one entry per data block: 2500 entries of 15 + 5 = 20 bytes. Entries per index block = floor(1024/20) = 51, so index blocks = ceil(2500/51) = 50. Binary search on the index: ⌈log2 50⌉ = 6 block accesses, which identifies the data block. Answer: 6.

Concept: A primary index is sparse: one entry per data block, not per record. The question stops at identifying the block, so the extra data-block access (7) is not counted.

Q63NAT2 marks · no negative· Easy

Consider the language L over the alphabet {0, 1}, given below: L = {w {0, 1} | w does not contain three or more consecutive 1's}. The minimum number of states in a Deterministic Finite-State Automaton (DFA) for L is .

Answer: 4 - show solution

Track the number of consecutive trailing 1s: state 0 (none), state 1 (one 1), state 2 (two 1s); all three are accepting. A 0 returns to state 0; a 1 moves 0 to 1 to 2, and from 2 to a dead state D (three 1s seen), which loops on both symbols. The four states are pairwise distinguishable: from 0, 1, 2 the strings 111, 11, 1 respectively are the shortest that lead to rejection, and D rejects everything. Minimum states: 4. Answer: 4.

Concept: Count states by what must be remembered: the current run of 1s (0, 1, 2) plus a dead state. Forgetting the dead state gives 3, which is the usual mistake for a complete DFA.

Q64NAT2 marks · no negative· Moderate

An 8-way set associative cache of size 64 KB (1 KB = 1024 bytes) is used in a system with 32-bit address. The address is sub-divided into TAG, INDEX, and BLOCK OFFSET. The number of bits in the TAG is .

Answer: 19 - show solution

Let the block size be 2^b bytes. Number of sets = cache size / (ways × block size) = 2¹⁶ / (2³ × 2^b) = 2^(13 - b), so INDEX = 13 - b bits and OFFSET = b bits. INDEX + OFFSET = 13 regardless of block size. TAG = 32 - 13 = 19. Answer: 19.

Concept: Index + offset bits equal log2(cache size / associativity), so the block size, which is not given, cancels out. Students often stall looking for the missing block size.

Q65NAT2 marks · no negative· Easy

The forwarding table of a router is shown below. Subnet Number Subnet Mask Interface ID 200.150.0.0 255.255.0.0 1 200.150.64.0 255.255.224.0 2 200.150.68.0 255.255.255.0 3 200.150.68.64 255.255.255.224 4 Default 0 A packet addressed to a destination address 200.150.68.118 arrives at the router. It will be forwarded to the interface with ID ________.

Answer: 3 - show solution

AND the destination with each mask. /16: 200.150.0.0, matches (interface 1). /19 (255.255.224.0): 68 AND 224 = 64, giving 200.150.64.0, matches (interface 2). /24: 200.150.68.0, matches (interface 3). /27 (255.255.255.224): 118 AND 224 = 96, giving 200.150.68.96 ≠ 200.150.68.64, no match. Longest prefix match is the /24 entry. Answer: 3.

Concept: Longest prefix matching: among all matching entries choose the longest mask. The trap is assuming 200.150.68.64/27 covers .118; that subnet is .64 to .95.

Answers are the official GATE answer key. Questions that depend on a figure are left out until they can be shown faithfully.