GATE / CS ARCHIVE

PAPER / ORIGINAL ORDER

GATE 2004

90 questions

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

03:00:00
1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Purpose of structured programming

Software Engineering

Question 1, GATE 2004: What is the goal of structured programming?
Options:
(A) Have well-indented programs
(B) Infer the flow of control from compiled code
(C) Infer the flow of control from program text
(D) Avoid using GOTO statements
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Structured control constructs make the program’s control flow understandable from its source text, C. Indentation helps readability but is not the defining goal, and eliminating every GOTO is a technique rather than the underlying purpose.

2. This general programming-methodology item is retained as supplemental.

3. Teaching check: Sequence, selection and iteration expose control structure directly in the source. Indentation is cosmetic: a well-indented unstructured jump sequence still requires reconstructing its control-flow graph. Conversely, the educational goal is understandability, not a syntactic ban treated as an end in itself.

Original paper, page 1

1 mark · MCQ
Report issue

Pass-by-value swap

Functions & Parameter Passing

Question 2, GATE 2004: Consider this C function:
void swap(int a, int b) {
  int temp; temp = a; a = b; b = temp;
}
To exchange caller variables x and y, which statement is correct?
Options:
(A) Call swap(x,y)
(B) Call swap(&x,&y)
(C) swap(x,y) cannot be used because it returns no value
(D) swap(x,y) cannot be used because its parameters are passed by value
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The function receives local copies a and b. Swapping those copies does not modify the caller’s x,y, so D.

2. A void function can modify caller objects through pointers, but this function’s parameters are int, not int*, and calling it with addresses does not repair its body.

3. Teaching check: Trace x=3,y=8: entry makes local a=3,b=8; the body leaves a=8,b=3, but x=3,y=8. A correct pointer-based version would take int *a,int *b and exchange *a,*b. A return value is not essential for that alternative.

Original paper, page 1

1 mark · MCQ
Report issue

Two stacks sharing an array

Stacks & Queues

Question 3, GATE 2004: Two stacks share A[1..MAXSIZE], growing from opposite ends. top1<top2 identify their topmost occupied cells. What full condition uses the available space efficiently?
Options:
(A) top1=MAXSIZE/2 AND top2=MAXSIZE/2+1
(B) top1+top2=MAXSIZE
(C) top1=MAXSIZE/2 OR top2=MAXSIZE
(D) top1=top2−1
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The unused positions lie strictly between top1 and top2. There is no free position exactly when the tops are adjacent, top1=top2−1, D.

2. This lets either stack use all available space instead of reserving half the array.

3. Teaching check: The number of unused cells is top2−top1−1. Setting this to zero immediately gives the full condition. A fixed half-array boundary can falsely declare overflow while the other stack leaves unused cells, defeating the purpose of sharing capacity.

Original paper, page 1

1 mark · MCQ
Report issue

Height after binary-search-tree insertions

Binary Search & Balanced Trees

Question 4, GATE 2004: Insert 10,1,3,5,15,12,16, in that order, into an empty binary search tree. What is its height, defined as the maximum edge distance from root to a leaf?
Options:
(A) 2
(B) 3
(C) 4
(D) 6
Question 4, GATE 2004: Insert 10,1,3,5,15,12,16, in that order, into an empty binary search tree. What is its height, defined as the maximum edge distance from root to a leaf?
Options:
(A) 2
(B) 3
(C) 4
(D) 6
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step through it (9 steps)

1. Inserting10,1,3,5 produces the chain 10→1→3→5 on the left side. The remaining 15,12,16 form a right subtree rooted 15 with two children.

2. The deepest leaf 5 is three edges from 10, so the stated edge-distance height is 3, B.

3. Teaching check: The complete parent-child structure is 10:(left 1,right 15), 1:(right 3), 3:(right 5), 15:(left 12,right 16). The deepest path has four vertices but three edges. Distinguishing edge height from node count eliminates the off-by-one distractor.

Original paper, page 1

1 mark · MCQ
Report issue

Balanced parentheses

Stacks & Queues

Question 5, GATE 2004: Which listed data structure is best for checking whether parentheses in an arithmetic expression are balanced?
Options:
(A) Queue
(B) Stack
(C) Tree
(D) List
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. A stack matches each closing delimiter with the most recently unmatched opening delimiter. Reject an unmatched/mismatched close and accept only if the stack is empty at the end.

2. Thus B. With only one kind of parenthesis a counter is sufficient, but stack is the appropriate listed general delimiter-matching structure.

3. Teaching check: On an opening parenthesis, push it; on a closing one, require and pop its matching opener. The last-in-first-out rule handles nesting such as (()()). A FIFO queue does not retain the most recently opened delimiter at its removal end.

Original paper, page 1

1 mark · MCQ
Report issue

Level-order traversal

Tree Properties & Traversals

Question 6, GATE 2004: Starting at the root, which traversal produces level order in a rooted tree?
Options:
(A) Preorder
(B) Inorder
(C) Depth-first search
(D) Breadth-first search
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Breadth-first search uses a queue to visit the root, then all children, then their children, and so on. This is precisely level order, D; depth-first traversals do not generally preserve depth order.

2. Teaching check: Begin with just the root in a queue. Repeatedly dequeue a vertex and enqueue its children. Children of a depth-d vertex are enqueued behind all remaining depth-d vertices, so no depth-(d+1) vertex is processed prematurely.

Original paper, page 1

1 mark · MCQ
Report issue

Hash collisions under modulo ten

Hashing

Question 7, GATE 2004: Hash the input 4322,1334,1471,9679,1989,6171,6173,4199 using h(x)=x mod 10. Which statements hold? (1) 9679,1989,4199 collide. (2) 1471,6171 collide. (3) All inputs hash to the same value. (4) Every input has a different hash value.
Options:
(A) 1 only
(B) 2 only
(C) 1 and 2 only
(D) 3 or 4
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The hash is the last decimal digit.9679,1989,4199 all map to 9, while 1471 and 6171 both map to 1. The remaining values map to 2,4,3.

2. Thus statements 1 and 2 only are true, C.

3. Teaching check: The eight hash values in input order are 2,4,1,9,9,1,3,9. This explicit list both verifies the two claimed collisions and refutes the “all equal” and “all different” alternatives. Collision means equal hash output, not equal original keys.

Original paper, page 1

1 mark · MCQ
Report issue

Forbidden operator-grammar productions

Parsing & Syntax Analysis

Question 8, GATE 2004: P,Q,R are nonterminals and r,s,t are terminals. Which rules violate the requirements for an operator grammar? (i) P→QR; (ii) P→QsR; (iii) P→ε; (iv) P→QtRr.
Options:
(A) i only
(B) i and iii only
(C) ii and iii only
(D) iii and iv only
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. An operator grammar forbids adjacent nonterminals on a right-hand side and, in the standard definition used here, empty productions. P→QR violates the first rule and P→ε the second.

2. P→QsR and P→QtRr separate nonterminals by terminals. Thus i and iii, B.

3. Teaching check: A right-hand side can contain several nonterminals provided terminals separate adjacent ones. Thus QsR and QtRr are permitted. The empty-production restriction belongs to the conventional operator-grammar definition used here; do not confuse this syntactic test with conflict-free operator-precedence parsing.

Original paper, page 1

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Resolving an external function reference

Compiler Phases, Linking & Loading

Question 9, GATE 2004: A program has separately stored source modules M1 and M2. M1 refers to a function defined in M2. At what stage is this reference resolved in the conventional separate-compilation model?
Options:
(A) Edit time
(B) Compile time
(C) Link time
(D) Load time
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. With conventional separate compilation and static linking, each module produces an object file with symbol definitions/references. The linker matches the external reference in M1 to the definition in M2, so link time, C.

2. Dynamic loading can defer binding, but is not the default compilation model stated here.

3. Teaching check: Compilation can emit an unresolved external symbol into M1’s object file. Linking has access to both objects and supplies the address from M2. Editing only changes text; loading places an already linked image into memory under the assumed static-binding model.

Original paper, page 2

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Evaluation order with one accumulator

Code Generation & Register Allocation

Question 10, GATE 2004: For E→E1−E2, generate code for a CPU with only one user register. Subtraction requires its first operand in that register; E1 and E2 have no common subexpression. Which evaluation order gives the shortest code?
Options:
(A) Evaluate E1 first
(B) Evaluate E2 first
(C) Necessarily interleave E1 and E2 evaluation
(D) Evaluation order is of no consequence
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Evaluate E2 first and save its value in a temporary memory location. Then evaluate E1, leaving the required first operand in the sole register, and subtract the saved E2.

2. Evaluating E1 first would require saving it, evaluating/storing E2, then reloading E1 before subtraction. Thus E2-first, B, avoids an extra reload in the stated accumulator-style model, assuming both expressions require evaluation and their order is free of side-effect constraints.

3. Teaching check: The final subtraction needs register=E1 and memory temporary=E2. E2-first naturally reaches that arrangement after one save. E1-first must preserve E1 across E2’s evaluation, then reload it, adding a memory operation. This argument assumes unrestricted evaluation order and nontrivial expression evaluations.

Original paper, page 2

1 mark · MCQ
Report issue

User and kernel thread properties

Processes, Threads & System Calls

Question 11, GATE 2004: Regarding user-level and kernel-supported threads, select the true statements: (1) Context switching is faster with kernel-supported threads. (2) A system call by a user-level thread can block the whole process. (3) Kernel-supported threads can be scheduled independently. (4) User-level threads are transparent to the kernel.
Options:
(A) 2,3,4 only
(B) 2,3 only
(C) 1,3 only
(D) 1,2 only
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. In the conventional many-to-one user-thread model, a blocking system call can block the process, the kernel does not see individual user threads, and kernel-supported threads can be scheduled independently. Thus2,3,4 are true, A.

2. User-thread context switches normally avoid kernel transitions and are not slower by definition; statement 1 is false. Modern hybrid threading arrangements need not share the many-to-one blocking limitation.

3. Teaching check: Separate visibility from speed: the kernel schedules only what it knows about. A library can switch its user threads without a kernel transition, but a blocking call can stop their common kernel scheduling entity. Kernel-supported threads trade that limitation for kernel-managed scheduling.

Original paper, page 2

1 mark · MCQ
Report issue

Disk scheduling with one outstanding request

I/O & Disk Scheduling

Question 12, GATE 2004: An OS can load and execute one sequential user process at a time. FCFS disk scheduling is replaced by SSTF, advertised as giving 50% better benchmark performance. What improvement in user-program I/O performance is expected? The usual one-outstanding-request assumption is not explicitly stated.
Options:
(A) 50%
(B) 40%
(C) 25%
(D) 0%
Question 12, GATE 2004: An OS can load and execute one sequential user process at a time. FCFS disk scheduling is replaced by SSTF, advertised as giving 50% better benchmark performance. What improvement in user-program I/O performance is expected? The usual one-outstanding-request assumption is not explicitly stated.
Options:
(A) 50%
(B) 40%
(C) 25%
(D) 0%
Tap to enlarge
Your answer
Answer & solution

Answer: D under synchronous single-request I/O (no official key was published)

1. If the single sequential process blocks for each disk request, there is never a choice among queued requests. FCFS and SSTF therefore execute the same sequence, giving 0% improvement, D; a benchmark with concurrency does not transfer to this case.

2. The premise of one sequential process alone does not prohibit asynchronous I/O, readahead or background requests. Without the one-outstanding-request assumption, the improvement is not determined by the stated facts.

3. Teaching check: A seek scheduler can improve ordering only when it can choose between multiple pending requests. With exactly one pending request, both rules choose it. “50% better” on another workload is not evidence for this workload; asynchronous requests would require further information.

Original paper, page 2

1 mark · MCQ
Report issue

Foreign-key inclusion in relational algebra

Relational Algebra & Calculus

Question 13, GATE 2004: Relations R1(A,B,C) and R2(D,E) have keys A and D respectively. C is a foreign key in R1 referencing D in R2. Instances r1,r2 satisfy referential integrity. Which expression must be empty? Projection outputs in set differences are identified by their compatible single domains.
Options:
(A) π_D(r2) − π_C(r1)
(B) π_C(r1) − π_D(r2)
(C) π_D(r1 ⋈_(C≠D) r2)
(D) π_C(r1 ⋈_(C=D) r2)
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Referential integrity requires every C value in r1 to occur as a referenced D value in r2. Hence π_C(r1)⊆π_D(r2), and π_C(r1)−π_D(r2) is empty, B, under classical relational algebra without SQL nulls.

2. The reverse difference can contain unreferenced parent keys.

3. Teaching check: Think of C values as child references and D values as parent keys. A dangling reference would be a value in the child projection absent from the parent projection. Referential integrity forbids precisely that difference, while allowing parent rows with no children.

Original paper, page 2

1 mark · MCQ
Report issue

Natural-join cardinality and an unstated foreign key

Relational Algebra & Calculus

Question 14, GATE 2004: Student(rollno,name,address) has key rollno; Enroll(rollno,courseno,coursename) has composite key (rollno,courseno). They have 120 and 8 tuples respectively. What are the maximum and minimum sizes of Student ⋈ Enroll (natural join)? No foreign-key constraint is stated.
Options:
(A) 8,8
(B) 120,8
(C) 960,8
(D) 960,120
Tap to enlarge
Your answer
Answer & solution

Answer: Maximum8, minimum 0; A only with referential integrity (no official key was published)

1. Student.rollno is the underlined key, while Enroll has the composite key(rollno,courseno). Each of the 8 enrollment tuples can match at most one Student tuple, so the maximum join size is 8.

2. With only the stated keys, all enrollment roll numbers may be absent from Student, giving minimum 0; no listed pair is then correct. If the intended additional constraint is Enroll.rollno referencing Student.rollno, every enrollment matches exactly once and both maximum/minimum are 8, A.

3. This foreign-key constraint is not stated and is not inferred from matching attribute names alone.

4. Teaching check: The maximum is attained when all eight enrollments use existing student roll numbers, possibly different courses for the same student. The minimum zero is attained by eight enrollments with roll numbers absent from Student. Primary-key uniqueness alone rules out duplicate student matches, not missing matches.

Original paper, page 2

1 mark · MCQ
Report issue

Layer-function matching

Network Layers & Devices

Question 15, GATE 2004: Match layers P=data link, Q=network, R=transport with: (1) reliable transfer over a physical point-to-point link; (2) encode/decode data for physical transmission; (3) end-to-end communication between processes; (4) route data from one network node to the next.
Options:
(A) P-1,Q-4,R-3
(B) P-2,Q-4,R-1
(C) P-2,Q-3,R-1
(D) P-1,Q-3,R-2
Question 15, GATE 2004: Match layers P=data link, Q=network, R=transport with: (1) reliable transfer over a physical point-to-point link; (2) encode/decode data for physical transmission; (3) end-to-end communication between processes; (4) route data from one network node to the next.
Options:
(A) P-1,Q-4,R-3
(B) P-2,Q-4,R-1
(C) P-2,Q-3,R-1
(D) P-1,Q-3,R-2
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The data-link layer supplies link-local transfer/reliability, P→1; the network layer routes between nodes, Q→4; the transport layer supports end-to-end process communication, R→3. Thus A.

2. Physical encoding/decoding belongs to the physical layer rather than these three.

3. Teaching check: Ask what the communication endpoints are: adjacent link endpoints identify the data-link layer; hosts or network nodes identify routing; application processes identify transport. Encoding bits onto a physical medium is the unused physical-layer description, not a network-layer function.

Original paper, page 2

1 mark · MCQ
Report issue

Bridge and router addressing

Network Layers & Devices

Question 16, GATE 2004: Which statement about a transparent bridge and a router is NOT true?
Options:
(A) Both selectively forward data packets
(B) A bridge uses IP addresses while a router uses MAC addresses
(C) A bridge builds its forwarding table by inspecting incoming packets
(D) A router can connect a LAN to a WAN
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. A transparent bridge forwards using learned MAC addresses, while an IP router forwards using network-layer IP addresses. Option B reverses these roles and is false.

2. Both can selectively forward, bridges learn source addresses from arriving frames, and routers can join LANs to WANs.

3. Teaching check: A learning bridge records the source MAC and incoming port of received frames, then consults destination MACs for forwarding. A router performs a network-prefix lookup on a destination IP address. Reversing these address families is the decisive false statement.

Original paper, page 3

1 mark · MCQ
Report issue

Simplifying a Boolean sum

Boolean Algebra & Logic Gates

Question 17, GATE 2004: Simplify f=x′y′+xy+x′y, where prime denotes complement, juxtaposition AND and + OR.
Options:
(A) x′+y′
(B) x+y
(C) x+y′
(D) x′+y
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (10 steps)

1. x′y′+xy+x′y=x′(y′+y)+xy=x′+xy=x′+y by absorption. Thus D.

2. Teaching check: A case check confirms the algebra: when x=0, either y value satisfies x′y′+x′y, so output is 1; when x=1 only xy remains, so output equals y. The function is therefore x′ OR y, not x OR y′.

Original paper, page 3

1 mark · MCQ
Report issue

Both inputs low in a NAND latch

Flip-Flops, Registers & Sequential Circuits

Question 18, GATE 2004: An SR latch consists of two cross-coupled NAND gates. What happens while both external S and R inputs are held at 0?
Options:
(A) Q=0,Q′=1
(B) Q=1,Q′=0
(C) Q=1,Q′=1
(D) Indeterminate states
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Each NAND gate has a forced 0 input, so both outputs are 1 regardless of feedback: Q=1,Q′=1, C. These labels cease to be complements in this forbidden input condition.

2. Indeterminacy can arise when both inputs are subsequently released together, not while both remain 0.

3. Teaching check: For a NAND gate, NAND(0,z)=1 for either z. Applying that fact to both cross-coupled gates resolves the held-input state without timing analysis. The later release race is a different event and must not replace the question’s fixed-input condition.

Original paper, page 3

1 mark · MCQ
Report issue

Equality in two number bases

Number Systems & Computer Arithmetic

Question 19, GATE 2004: If the base-x numeral 73 equals the base-y numeral 54, which pair (x,y) is possible?
Options:
(A) 8,16
(B) 10,12
(C) 9,13
(D) 8,11
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (6 steps)

1. The equation is 7x+3=5y+4, or 7x−5y=1. Among the options x=8,y=11 gives 56−55=1 and both bases exceed their digits.

2. Thus D; both numerals represent 59.

3. Teaching check: A two-digit numeral ab in base r equals ar+b, rather than a×10+b. Substitution for (8,11) gives 7×8+3=59 and 5×11+4=59. Valid bases must also exceed every digit used; algebra alone would not suffice otherwise.

Original paper, page 3

1 mark · MCQ
Report issue

Relocation-friendly addressing modes

Instructions & Addressing Modes

Question 20, GATE 2004: Which addressing modes support program relocation at runtime? (i) Absolute; (ii) Based; (iii) Relative; (iv) Indirect.
Options:
(A) i and iv
(B) i and ii
(C) ii and iii
(D) i,ii and iv
Question 20, GATE 2004: Which addressing modes support program relocation at runtime? (i) Absolute; (ii) Based; (iii) Relative; (iv) Indirect.
Options:
(A) i and iv
(B) i and ii
(C) ii and iii
(D) i,ii and iv
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Base addressing forms an address as relocation base plus displacement, while PC-relative addressing uses a displacement from the moving instruction location. Both preserve relative positions when code is relocated, so ii and iii, C.

2. Absolute embedded addresses require adjustment; indirection alone does not guarantee that stored pointer values relocate correctly.

3. Teaching check: If relocation shifts all code by Δ, a PC-relative target shifts with the PC while its displacement stays fixed. A base-addressed target shifts when the base register is updated. An arbitrary indirect pointer can still contain an obsolete absolute address, so indirection alone is not a relocation guarantee.

Original paper, page 3

1 mark · MCQ
Report issue

Architectural minimum frame allocation

Virtual Memory & Paging

Question 21, GATE 2004: What determines the minimum number of page frames that must be allocated to a running process in a virtual-memory environment?
Options:
(A) Instruction set architecture
(B) Page size
(C) Physical memory size
(D) Number of processes in memory
Tap to enlarge
Your answer
Answer & solution

Answer: A under a fixed paging configuration (no official key was published)

1. The instruction set determines which instruction bytes and operands may have to be resident together to complete/restart one instruction without endless page faults. Thus A is the standard determinant of the minimum required frame count, rather than a count based simply on concurrent processes or total RAM.

2. Exact numerical requirements also depend on the fixed page size, operand placement, and restart implementation; the answer identifies the architectural constraint, not independence from all those details.

3. Teaching check: The minimum is about making forward progress on an instruction, not fitting the whole working set. For example, an instruction may simultaneously need its code page and multiple operand pages. The ISA constrains these requirements; page geometry and restart details matter when calculating an actual number.

Original paper, page 3

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Asynchronous serial character rate

Physical Layer & Transmission

Question 22, GATE 2004: A 9600-baud asynchronous serial link sends each 8-bit character with one start bit, eight data bits, two stop bits and one parity bit. Under binary signaling, how many characters per second can it send?
Options:
(A) 600
(B) 800
(C) 876
(D) 1200
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Each character occupies 1 start+8 data+2 stop+1 parity=12 transmitted bits. Under binary serial signaling,9600 baud means 9600 bits/s, yielding 9600/12=800 characters/s, B.

2. No additional idle time is assumed.

3. Teaching check: Framing overhead is four bits per character, making twelve transmitted bits for eight useful bits. The useful-data fraction is 8/12, but the question asks characters per second, so divide by 12 rather than reporting a bit rate.

Original paper, page 3

1 mark · MCQ
Report issue

Existential boy taller than every girl

Propositional & Predicate Logic

Question 23, GATE 2004: Translate “Some boys in the class are taller than all the girls.” The domain is the class and taller(x,y) means x is taller than y. Options below follow GFG; GateForum prints ∧ instead of → inside option D, making its B and D identical and neither a correct translation.
Options:
(A) ∃x[boy(x)→∀y(girl(y)∧taller(x,y))]
(B) ∃x[boy(x)∧∀y(girl(y)∧taller(x,y))]
(C) ∃x[boy(x)→∀y(girl(y)→taller(x,y))]
(D) ∃x[boy(x)∧∀y(girl(y)→taller(x,y))]
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The required structure is ∃x[boy(x)∧∀y(girl(y)→taller(x,y))], option D, with the domain understood as members of the class. Conjunction ensures the witness is a boy; implication restricts the universal comparison to girls rather than asserting that every person is a girl.

2. Teaching check: An existential implication could be satisfied merely by choosing a person who is not a boy. A universal conjunction would require everyone in the domain to be a girl. The outer conjunction and inner implication prevent these two distinct logical errors. The answer D is source-qualified to the paper’s correctly printed option.

Original paper, page 3

1 mark · MCQ
Report issue

Reflexive transitive closure of successor

Sets, Relations & Functions

Question 24, GATE 2004: On the nonnegative integers, S={(x,y):y=x+1}. Find its reflexive transitive closure. GFG prints the domain {0,1,2,…}; GateForum omits the ellipsis and prints {0,1,2}, for which the same order condition applies restricted to that finite domain.
Options:
(A) {(x,y):y>x}
(B) {(x,y):y≥x}
(C) {(x,y):y<x}
(D) {(x,y):y≤x}
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. A path of k successor steps takes x to x+k, for any integer k≥0. Zero steps supply reflexivity.

2. Thus the closure is{(x,y):y≥x, x,y nonnegative integers}, B.

3. Teaching check: Reflexive closure adds (x,x); transitivity adds (x,x+2),(x,x+3), and all later successors. No operation can create a pair with y<x because every original step increases the value.

Original paper, page 3

1 mark · MCQ
Report issue

Two heads in four tosses

Probability & Random Variables

Question 25, GATE 2004: A fair coin is independently tossed four times. What is the probability of exactly two heads and two tails?
Options:
(A) 3/8
(B) 1/2
(C) 5/8
(D) 3/4
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Among24=16 equally likely independent outcomes, binomial(4,2)=6 have exactly two heads and therefore two tails. Probability6/16=3/8, A.

2. Teaching check: Choose which two of the four positions contain heads: there are six choices. Each complete sequence has probability (1/2)4. Counting one arrangement such as HHTT gives only 1/16 and misses the other five arrangements.

Original paper, page 4

1 mark · MCQ
Report issue

Counting symmetric binary matrices

Combinatorics & Counting

Question 26, GATE 2004: How many n×n symmetric matrices have every entry either 0 or 1? Option C follows GFG; GateForum has malformed parentheses around its exponent.
Options:
(A) 2^n
(B) 2^(n²)
(C) 2^((n²+n)/2)
(D) 2^((n²−n)/2)
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Choose the n diagonal bits and the n(n−1)/2 bits above the diagonal freely; symmetry then determines the lower triangle. There are n(n+1)/2 independent bits and therefore 2^((n²+n)/2) matrices, C.

2. This is a finite counting problem.

3. Teaching check: For n=2, the matrix is [[a,b],[b,c]], with three independent bits and eight possibilities. This small case distinguishes 2^((n²+n)/2) from formulas that omit diagonal freedom or count the mirrored off-diagonal bits twice.

Original paper, page 4

1 mark · MCQ
Report issue

Inverse of a matrix factor

Linear Algebra

Question 27, GATE 2004: A,B,C,D are n×n matrices with nonzero determinants and ABCD=I. What is B^−1?
Options:
(A) D^−1 C^−1 A^−1
(B) CDA
(C) ADC
(D) It need not exist
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. From ABCD=I, multiply on the left by A-1 to get BCD=A-1, then on the right by A to get B(CDA)=I. Since B is invertible, B-1=CDA, B.

2. Factor order matters for matrices.

3. Teaching check: Use multiplication on the correct side: B(CDA)=ABCD conjugated by A, namely A−1 I A=I. Matrix products generally do not commute. The formula for the inverse of a product reverses factor order and cannot be applied by casually rearranging ABCD.

Original paper, page 4

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Three-significant-digit floating-point addition

Numerical Methods

Question 28, GATE 2004: Evaluate (113+(−111))+7.51 and 113+((−111)+7.51), rounding to three significant decimal digits after each floating-point operation.
Options:
(A) 9.51 and 10.0
(B) 10.0 and 9.51
(C) 9.51 and 9.51
(D) 10.0 and 10.0
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. For the first association,113+(−111)=2 exactly, then 2+7.51=9.51. For the second,−111+7.51=−103.49 rounds to−103 with three significant digits;113+(−103)=10.0.

2. Thus9.51 and 10.0, A. Rounding is applied after each operation, not merely at the end.

3. Teaching check: Three digits means three significant digits, not three decimal places. The intermediate −103.49 becomes −103, losing 0.49 before the final addition. Floating-point addition is therefore not associative even though exact real-number addition is.

Original paper, page 4

1 mark · MCQ
Report issue

Comparison-sorting lower bound

Searching, Sorting & Selection

Question 29, GATE 2004: What is the tight asymptotic order of the worst-case lower bound on comparisons required by comparison-based sorting of n elements?
Options:
(A) n
(B) n²
(C) n log n
(D) n(log n)²
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. A comparison decision tree must distinguish n! possible input permutations, so its worst-case height is at least ceil(log2(n!))=Ω(n log n). Mergesort or heapsort attains O(n log n), making that the tight order of the worst-case comparison bound, C.

2. Teaching check: A binary comparison tree of height h has at most 2h leaves. Distinct orderings need separate leaves, so 2h≥n!. Summing logarithms or using Stirling’s estimate gives log2(n!)=Θ(n log n). This lower bound applies to comparison sorting, not every integer-key sorting method.

Original paper, page 4

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Complexity of two-SAT and three-SAT

Complexity & Reductions

Question 30, GATE 2004: Which complexity classification applies to 3-SAT and 2-SAT respectively?
Options:
(A) Both in P
(B) Both NP-complete
(C) NP-complete and in P
(D) Undecidable and NP-complete
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: 3-SAT is NP-complete.2-SAT is decidable in polynomial time, for example by strongly connected components of its implication graph, so C. These classifications are established without assuming P≠NP; saying 3-SAT is NP-complete is not a proof that it lies outside P.

Step 2: Teaching check: For 2-SAT, clause (u∨v) adds implications ¬u→v and ¬v→u. The formula is unsatisfiable exactly when some variable and its negation occupy one strongly connected component. This polynomial algorithm is why one cannot extend the 3-SAT hardness conclusion to two literals.

Original paper, page 4

2 marks · MCQ
Report issue

Recursion with a persistent static counter

Scope, Lifetime & Storage Classes

Question 31, GATE 2004: For the first invocation of this C function, what does f(1) return?
int f(int n) {
  static int i=1;
  if(n>=5) return n;
  n=n+i; i++;
  return f(n);
}
Options:
(A) 5
(B) 6
(C) 7
(D) 8
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step through it (6 steps)

1. On the first call, n=1,i=1; the update yields n=2,i=2. The next call yields n=4,i=3, then n=7,i=4.

2. Since7≥5, that call returns7 and the result propagates back, C. This assumes f(1) is the first call, since static i persists across calls.

3. Teaching check: Static storage is initialized once, not once per recursive activation. The entry states (n,i) are (1,1),(2,2),(4,3),(7,4). Replacing static i with an ordinary local initialized to 1 would produce a different trace and return 5.

Original paper, page 4

2 marks · MCQ
Report issue

Invariant for reversing decimal digits

Control Flow & Loop Tracing

Question 32, GATE 2004: An input nonnegative integer has original digits d1 d2 … dm. The fragment is:
int n, rev; /* n contains the input */
rev=0;
while(n>0) {
  rev=rev*10+n%10;
  n=n/10;
}
Which invariant holds after iteration i? Assume integer division and no overflow; digit strings denote numeric values.
Options:
(A) n=d1…d_(m−i) AND rev=d_m d_(m−1)…d_(m−i+1)
(B) n=d_(m−i+1)…d_(m−1)d_m OR rev=d_(m−i)…d2 d1
(C) n≠rev
(D) n=d1 d2…d_m OR rev=d_m…d2 d1
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. After i iterations, n is the original prefix d1...dm−i, and rev is the processed suffix in reverse order dm dm−1...dm−i+1, A. Each step removes n’s final digit and appends it to rev.

2. The notation describes numeric digit values, so leading zeros in the reversed suffix do not change the value; assume the input is supplied nonnegative and the reversed value fits int.

3. Teaching check: For input 1234, successive (n,rev) pairs are (123,4),(12,43),(1,432),(0,4321). This verifies both halves of the invariant simultaneously. An OR condition that merely describes the initial or final arrangement does not express the state after every iteration.

Original paper, page 4

2 marks · MCQ
Report issue

Copying the terminator before reversed characters

Arrays & Strings

Question 33, GATE 2004: What is printed by this C fragment? Assume appropriate declarations/includes for i, strlen and printf.
char p[20];
char *s="string";
int length=strlen(s);
for(i=0;i<length;i++) p[i]=s[length-i];
printf("%s",p);
The %s format follows GFG. GateForum visibly prints a malformed alternate format rather than %s.
Options:
(A) gnirts
(B) string
(C) gnirt
(D) No output is printed
Tap to enlarge
Your answer
Answer & solution

Answer: D under the displayed intended C fragment (no official key was published)

1. The source length is 6. At i=0, p[0]=s[length−0]=s[6], which is the string terminator.

2. Consequently printf with %s sees an empty string immediately, regardless of later copied characters, and prints nothing, D. This uses the paper’s %s format and assumes surrounding declarations/includes for i and the library functions.

4. Teaching check: The source string positions are 0:s,1:t,2:r,3:i,4:n,5:g,6:\0. The very first assignment copies position 6 into p[0].

Original paper, page 4

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Employee-class design

Other Computing Topics

Question 34, GATE 2004: An employee system has superclass Employee and subclasses Manager, Engineer and Secretary. Each employee has name, unique ID and salary; salary depends on category. Choose the best design for getName, getId and computeSalary (called getSalary in the numbered statements). (i) Implement getId in superclass; (ii) implement getId in subclass; (iii) getName abstract in superclass; (iv) implement getName in superclass; (v) implement getName in subclass; (vi) getSalary abstract in superclass; (vii) implement getSalary in superclass; (viii) implement getSalary in subclass.
Options:
(A) i,iv,vi,viii
(B) i,iv,vii
(C) i,iii,v,vi,viii
(D) ii,v,viii
Question 34, GATE 2004: An employee system has superclass Employee and subclasses Manager, Engineer and Secretary. Each employee has name, unique ID and salary; salary depends on category. Choose the best design for getName, getId and computeSalary (called getSalary in the numbered statements). (i) Implement getId in superclass; (ii) implement getId in subclass; (iii) getName abstract in superclass; (iv) implement getName in superclass; (v) implement getName in subclass; (vi) getSalary abstract in superclass; (vii) implement getSalary in superclass; (viii) implement getSalary in subclass.
Options:
(A) i,iv,vi,viii
(B) i,iv,vii
(C) i,iii,v,vi,viii
(D) ii,v,viii
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The common name and identifier accessors can be implemented once in Employee, statements i and iv. Salary computation varies by employee category, so declare it abstract in Employee and implement it in each category subclass, vi and viii.

2. Thus A is the best listed design. The narrative says computeSalary while the numbered statements say getSalary; the intended varying salary operation is treated consistently.

3. Teaching check: Inheritance should share the common accessors while polymorphism handles category-specific salary rules. An abstract salary method specifies the common interface without imposing one implementation. Making getName abstract duplicates a behavior that the problem gives no reason to vary.

Original paper, page 4

2 marks · MCQ
Report issue

Traversal pairs uniquely determining a binary tree

Tree Properties & Traversals

Question 35, GATE 2004: For an unrestricted binary tree with distinct node labels, which pairs of label sequences determine the tree uniquely? (i) preorder and postorder; (ii) inorder and postorder; (iii) preorder and inorder; (iv) level order and postorder.
Options:
(A) i only
(B) ii and iii
(C) iii only
(D) iv only
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. With distinct node labels, inorder plus preorder identifies the root then splits both subtrees recursively; inorder plus postorder does the same using the final element as root. Thus ii and iii, B.

2. A root with one left child versus one right child has identical preorder, postorder and level order, so the other pairs do not suffice for unrestricted binary trees. Distinct labels are the conventional assumption.

3. Teaching check: For a concrete ambiguity, a root A with sole left child B and a root A with sole right child B both have preorder A,B, postorder B,A and level order A,B. Inorder distinguishes B,A from A,B, explaining why it is indispensable among the offered pairs.

Original paper, page 5

2 marks · MCQ
Report issue

One-pointer circular queue

Stacks & Queues

Question 36, GATE 2004: A queue is represented by a singly linked circular list: front→successive queue nodes→rear→front. One pointer p is available. Where should p point so both enqueue and dequeue take constant time?
Options:
(A) Rear node
(B) Front node
(C) Impossible with one pointer
(D) Node next to front
Question 36, GATE 2004: A queue is represented by a singly linked circular list: front→successive queue nodes→rear→front. One pointer p is available. Where should p point so both enqueue and dequeue take constant time?
Options:
(A) Rear node
(B) Front node
(C) Impossible with one pointer
(D) Node next to front
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Keep p at the rear, whose next pointer is the front. Enqueue inserts after p and advances p to the new rear; dequeue removes p.next, with a special empty result for a singleton.

2. Both take constant time, A. Keeping only the front would require finding its predecessor to update the rear link.

3. Teaching check: For enqueue, set new.next=p.next, then p.next=new and p=new. For dequeue, remove p.next and advance that link; if it was the sole node, mark the queue empty. A circular rear pointer therefore exposes both ends without a predecessor scan.

Original paper, page 5

2 marks · MCQ
Report issue

Heap built by successive insertions

Heaps & Priority Queues

Question 37, GATE 2004: Insert 32,15,20,30,12,25,16 one at a time into an empty binary max-heap, using upward restoration after each insertion. Which resulting heap is obtained? The four source diagrams are encoded below as level-order arrays (root first, left-to-right at each level).
Options:
(A) [32,30,25,15,12,20,16]
(B) [32,25,30,12,15,20,16]
(C) [32,30,25,15,12,16,20]
(D) [32,25,30,12,15,16,20]
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (11 steps)

1. Insert32,15,20, then 30 bubbles above 15, giving[32,30,20,15]. Insert12 unchanged.

2. Insert25 bubbles above 20, giving[32,30,25,15,12,20];16 remains under 25. Final level order is 32,30,25,15,12,20,16, diagram A.

3. Teaching check: Insertion order matters: the final heap need not be the one obtained by bottom-up heapifying the array or sorting its values. Inserting 30 swaps it above 15; inserting 25 swaps it above 20. All remaining parent-child inequalities already hold.

Original paper, page 5

2 marks · MCQ
Report issue

Postfix with right-associative exponentiation

Stacks & Queues

Question 38, GATE 2004: Operators +,−,× are left-associative and ^ is right-associative. Precedence from highest to lowest is ^,×,+,−. Find postfix for a+b×c−d^e^f. Tokens in each alternative are separated for readability.
Options:
(A) a b c × + d e f ^ ^ −
(B) a b c × + d e ^ f ^ −
(C) a b + c × d − e ^ f ^
(D) − + a × b c ^ ^ d e f
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (13 steps)

1. The grouping is(a+(b×c))−(de^f). Write each subtree’s operands before its operator: a b c × + d e f ^ ^ −.

2. Thus A. Right associativity places the ef operation before raising d to that result.

3. Teaching check: The parse first builds b×c and ef, then de^f, then a+(b×c), and finally subtraction. Postorder traversal emits operands before operators. The alternative with d e ^ f ^ instead encodes (de)f and violates right associativity.

Original paper, page 5

2 marks · MCQ
Report issue

Matrix layout and asymptotic multiplication cost

Asymptotic Analysis & Recurrences

Question 39, GATE 2004: Matrices M1,M2 are stored in arrays A,B respectively. Each may use row-major or column-major contiguous storage. How does this affect the time complexity of a fixed algorithm computing M1×M2?
Options:
(A) Best when A is row-major and B column-major
(B) Best when both are row-major
(C) Best when both are column-major
(D) Independent of storage scheme
Question 39, GATE 2004: Matrices M1,M2 are stored in arrays A,B respectively. Each may use row-major or column-major contiguous storage. How does this affect the time complexity of a fixed algorithm computing M1×M2?
Options:
(A) Best when A is row-major and B column-major
(B) Best when both are row-major
(C) Best when both are column-major
(D) Independent of storage scheme
Tap to enlarge
Your answer
Answer & solution

Answer: D under a unit-cost RAM model (no official key was published)

1. Changing row-major to column-major storage changes the address formula, not the number of arithmetic operations or constant-time element accesses. Thus asymptotic running time for a fixed multiplication algorithm is independent of the layout, D.

2. For the usual i,j,k loop order, A-row-major/B-column-major can improve locality and elapsed time, but that is a cache-performance distinction rather than an asymptotic RAM-operation count.

3. Teaching check: For an r×c row-major array, address(i,j) uses ic+j; column-major uses jr+i. Both formulas take constant time under a unit-cost RAM model. Cache misses may differ dramatically, but that does not by itself alter a fixed algorithm’s asymptotic arithmetic/access count.

Original paper, page 5

2 marks · MCQ
Report issue

Set operations on unsorted linked lists

Arrays & Linked Lists

Question 40, GATE 2004: Each set is an unsorted linked list. Under direct list algorithms, which operations among union, intersection, membership and cardinality are slowest?
Options:
(A) Union only
(B) Intersection and membership
(C) Membership and cardinality
(D) Union and intersection
Tap to enlarge
Your answer
Answer & solution

Answer: D for direct list algorithms (no official key was published)

1. Membership scans a list in O(n), and cardinality is O(n) by traversal (or O(1) if stored). For union/intersection of two unsorted lists of comparable size, direct algorithms test each element against the other list, taking Θ(n²) worst case while avoiding duplicates in the union.

2. Thus union and intersection, D. Auxiliary hashing or sorting can improve these operations; the comparison assumes direct operations on the stated unsorted-list representation without such an index.

3. Teaching check: For two length-n lists, compare each candidate against up to n elements of the other list. That nested search costs Θ(n²), unlike a single membership or counting scan. Union must eliminate duplicates rather than merely concatenate the lists.

Original paper, page 6

2 marks · MCQ
Report issue

Subtractive Euclidean algorithm

Control Flow & Loop Tracing

Question 41, GATE 2004: What does this C-style fragment compute for positive integers x,y?
m=x; n=y;
while(m!=n) {
  if(m>n) m=m-n;
  else n=n-m;
}
printf("%d",n);
GFG option A is division by repeated subtraction; GateForum prints x+y instead.
Options:
(A) x/y by repeated subtraction
(B) x mod y by repeated subtraction
(C) Greatest common divisor of x,y
(D) Least common multiple of x,y
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. For positive x,y, each iteration replaces the larger of m,n by its difference with the smaller. This preserves gcd(m,n), keeps both positive, and strictly decreases m+n until m=n.

2. The printed common value is gcd(x,y). This is not ordinary repeated subtraction for division: the roles of the two operands change.

3. Teaching check: For x=12,y=8, the pairs evolve (12,8)→(4,8)→(4,4), so the answer is 4. Every common divisor is preserved by subtracting one operand from the other. The positive decreasing sum proves termination, completing both partial correctness and progress.

Original paper, page 6

2 marks · MCQ
Report issue

Arithmetic-mean square-root iteration

Correctness, Invariants & Design

Question 42, GATE 2004: For real arithmetic, m>1 and ε>0, what does this algorithm approximate?
x=m; y=1;
while(x-y>ε) { x=(x+y)/2; y=m/x; }
print(x);
Options:
(A) log m
(B) m²
(C) m^(1/2)
(D) m^(1/3)
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. In real arithmetic xy=m initially and after each iteration. Thus x is an upper bound and y=m/x a lower bound for sqrt(m).

2. Updating x to (x+m/x)/2 preserves x≥sqrt(m) and decreases it unless equality holds; resetting y preserves the invariant. The limits agree at sqrt(m).

3. At termination y≤sqrt(m)≤x and x−y≤epsilon, giving absolute error at most epsilon. This is an algorithm question about iteration, not a request to solve an excluded calculus topic; integer division would invalidate the real-arithmetic interpretation.

4. Teaching check: After the update, x is the arithmetic mean of a pair whose product is m, so x≥sqrt(m) by AM–GM. Setting y=m/x gives y≤sqrt(m). Their shrinking gap supplies a direct error bound, not merely a guess based on numerical similarity.

Original paper, page 6

2 marks · MCQ
Report issue

Recursive binary-tree height

Tree Properties & Traversals

Question 43, GATE 2004: Consider a binary-tree node with fields leftChild, element and rightChild, and this function (max returns the larger argument):
int DoSomething(struct CellNode *ptr) {
  int value=0;
  if(ptr!=NULL) {
    if(ptr->leftChild!=NULL)
      value=1+DoSomething(ptr->leftChild);
    if(ptr->rightChild!=NULL)
      value=max(value,1+DoSomething(ptr->rightChild));
  }
  return value;
}
What is returned when ptr is the root of a nonempty tree?
Options:
(A) Number of leaf nodes
(B) Number of nodes
(C) Number of internal nodes
(D) Height of tree
Question 43, GATE 2004: Consider a binary-tree node with fields leftChild, element and rightChild, and this function (max returns the larger argument):
int DoSomething(struct CellNode *ptr) {
  int value=0;
  if(ptr!=NULL) {
    if(ptr->leftChild!=NULL)
      value=1+DoSomething(ptr->leftChild);
    if(ptr->rightChild!=NULL)
      value=max(value,1+DoSomething(ptr->rightChild));
  }
  return value;
}
What is returned when ptr is the root of a nonempty tree?
Options:
(A) Number of leaf nodes
(B) Number of nodes
(C) Number of internal nodes
(D) Height of tree
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. A leaf returns zero. A node with a child takes one plus that child’s recursively computed value; with two children it takes the maximum.

2. Induction gives the maximum number of edges from the node to a descendant leaf, i.e. height measured in edges. The null check returns zero but no missing child adds an edge.

3. The code does not count nodes or leaves.

4. Teaching check: A singleton tree returns zero, immediately excluding both total-node and leaf counts. A two-edge chain returns two. The recursive maximum chooses the deepest child path, while adding one accounts for the edge from the current node to that child.

Original paper, page 6

2 marks · MCQ
Report issue

Dijkstra finalization sequence

Graph Algorithms

Question 44, GATE 2004: Run Dijkstra from P on the directed graph with vertices P,Q,R,S,T,U and weighted arcs P→Q:1, P→S:6, P→T:7, Q→R:1, Q→S:4, R→S:2, R→U:1, S→T:3, S→U:2, T→U:2. In what order are shortest-path distances finalized? This arc list completely specifies the source figure.
Options:
(A) P,Q,R,S,T,U
(B) P,Q,R,U,S,T
(C) P,Q,R,U,T,S
(D) P,Q,T,R,U,S
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step through it (18 steps)

1. From P, tentative distances are Q=1,S=6,T=7. Finalizing Q sets R=2 and improves S=5.

2. Finalizing R sets U=3 and improves S=4. U has no outgoing improvement, so S=4 is next; S gives T=min(7,4+3)=7.

3. The order is P,Q,R,U,S,T, with final distances 0,1,2,3,4,7 in that order. In particular the diagonal edge is directed R→S, not S→R.

4. Teaching check: Record the finalized distances in extraction order: P:0,Q:1,R:2,U:3,S:4,T:7. Once R is processed, its outgoing R→S edge lowers S to 4. Reversing that arrow would alter the computation, so direction is part of the essential figure data.

Original paper, page 6

2 marks · MCQ
Report issue

Translation-rule precedence

Semantic Analysis & Type Checking

Question 45, GATE 2004: Grammar and semantic rules, start E: E→E1 # T with E.value=E1.value×T.value, or E→T with E.value=T.value; T→T1 & F with T.value=T1.value+F.value, or T→F with T.value=F.value; F→num with F.value=num.value. Find the root value for 2 # 3 & 5 # 6 & 4. The addition rule is visible in GFG; GateForum instead prints multiplication for that rule as well.
Options:
(A) 200
(B) 180
(C) 160
(D) 40
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The grammar groups & inside T, hence it has higher precedence than #. Image the T→T1 & F semantic rule is T.value=T1.value+F.value, while E→E1 # T multiplies.

2. Therefore 2 # 3 & 5 # 6 & 4 evaluates as 2×(3+5)×(6+4)=160, option C.

4. Teaching check: Precedence comes from the grammar, not the symbols’ usual meanings. T binds & before the E-level #. Thus the parse groups 3&5 and 6&4 before combining the factors with #.

Original paper, page 6

2 marks · MCQ
Report issue

Preemptive shortest remaining time

CPU Scheduling

Question 46, GATE 2004: Processes (arrival time,CPU burst), in ms, are P1=(0,5), P2=(1,3), P3=(2,3), P4=(4,1). What is the average turnaround time under preemptive shortest remaining processing time first (SRPT)?
Options:
(A) 5.50 ms
(B) 5.75 ms
(C) 6.00 ms
(D) 6.25 ms
Question 46, GATE 2004: Processes (arrival time,CPU burst), in ms, are P1=(0,5), P2=(1,3), P3=(2,3), P4=(4,1). What is the average turnaround time under preemptive shortest remaining processing time first (SRPT)?
Options:
(A) 5.50 ms
(B) 5.75 ms
(C) 6.00 ms
(D) 6.25 ms
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (7 steps)

1. A valid SRPT schedule is P1:[0,1), P2:[1,4), P4:[4,5), P3:[5,8), P1:[8,12). P2 still has the smallest remaining time when P3 arrives.

2. Completion times for P1,P2,P3,P4 are 12,4,8,5; subtracting arrivals 0,1,2,4 gives turnaround times 12,3,6,1. Their mean is 22/4=5.50ms.

3. Teaching check: Turnaround is completion minus arrival, not total waiting time. The four turnaround values are 12,3,6,1; their sum is 22. Context-switch overhead is not supplied and is therefore excluded. Arrival of P3 at time 2 does not preempt P2, whose remaining burst is only 2.

Original paper, page 6

2 marks · MCQ
Report issue

Two-level paging effective instruction time

Virtual Memory & Paging

Question 47, GATE 2004: A two-level paging system has regular memory access time 150 ns and page-fault service time 8 ms. An average instruction uses 100 ns CPU time and two memory accesses. TLB hit ratio is 90%; page faults occur once per 10,000 instructions. What is effective average instruction time? TLB lookup time and caching of page-table levels are unspecified.
Options:
(A) 645 ns
(B) 1050 ns
(C) 1215 ns
(D) 1230 ns
Tap to enlarge
Your answer
Answer & solution

Answer: 1260 ns under literal two-level page-table model; no listed option (no official key was published)

1. Assuming negligible TLB lookup time and a true two-level page table, a TLB hit costs 150ns and a miss costs three memory accesses: two page-table reads plus the requested data access,450ns. Two accesses per instruction therefore cost 2(0.9×150+0.1×450)=360ns.

2. Add100ns CPU time and 8,000,000/10,000=800ns amortized fault service:1260ns. None of 645,1050,1215,1230 matches.

3. Option D=1230ns results from counting only TWO total memory accesses per TLB miss:100+2(0.9×150+0.1×300)+800. That requires a single-level translation model or an unstated cached first-level entry.

4. Treat the result as model-dependent rather than silently forcing D. Minor whether-fault-service-includes-retry conventions do not account for the 30ns discrepancy.

5. Teaching check: A true two-level TLB miss reads level 1, level 2 and data: three memory accesses. The page-fault rate is per instruction, so add the 800-ns average penalty once, not twice. The closest-looking listed value must not erase the extra translation read.

Original paper, page 7

2 marks · MCQ
Report issue

Common semaphore acquisition order

Deadlocks

Question 48, GATE 2004: Shared X,Y are protected by binary semaphores Sx,Sy, initially 1. P waits/decrements and V signals/increments. Fill L1,L2,L3,L4 to avoid deadlock:
P1: while true {
  L1; L2; X=X+1; Y=Y-1; V(Sx); V(Sy);
}
P2: while true {
  L3; L4; Y=Y+1; X=X-1; V(Sy); V(Sx);
}
GateForum prints X=Y−1 in P2; that arithmetic variant does not change the locking question.
Options:
(A) P(Sy),P(Sx),P(Sx),P(Sy)
(B) P(Sx),P(Sy),P(Sy),P(Sx)
(C) P(Sx),P(Sx),P(Sy),P(Sy)
(D) P(Sx),P(Sy),P(Sx),P(Sy)
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Both processes must acquire both Sx and Sy, exactly once, in the same global order. Option D supplies P(Sx),P(Sy) to both processes.

2. A process that has acquired Sx prevents its competitor from holding Sy while it waits for Sx, so the circular-wait condition is impossible. Options A/B use opposite acquisition orders and admit deadlock; C acquires the same binary semaphore twice and can block itself.

3. Different release orders do not invalidate the common acquisition order.

4. Teaching check: Construct an opposite-order deadlock: P1 holds Sx and waits for Sy while P2 holds Sy and waits for Sx. Requiring the same acquisition order eliminates this cycle. A release-order difference is harmless here because neither process waits while executing V.

Original paper, page 7

2 marks · MCQ
Report issue

Exact inode addressing capacity

File Systems

Question 49, GATE 2004: A Unix-style inode has 10 direct pointers and one each single-, double- and triple-indirect pointer. Blocks are 1 Kbyte, block addresses are 32 bits, and integers are 48 bits. What is the maximum file size? Use 1 Kbyte=1024 bytes; alternatives are powers of two, not exact inode totals.
Options:
(A) 2^24 bytes
(B) 2^32 bytes
(C) 2^34 bytes
(D) 2^48 bytes
Question 49, GATE 2004: A Unix-style inode has 10 direct pointers and one each single-, double- and triple-indirect pointer. Blocks are 1 Kbyte, block addresses are 32 bits, and integers are 48 bits. What is the maximum file size? Use 1 Kbyte=1024 bytes; alternatives are powers of two, not exact inode totals.
Options:
(A) 2^24 bytes
(B) 2^32 bytes
(C) 2^34 bytes
(D) 2^48 bytes
Tap to enlarge
Your answer
Answer & solution

Answer: 17,247,250,432 bytes; C only as a power-of-two approximation (no official key was published)

1. A1KiB indirect block holds 1024/4=256 addresses. The inode can reference 10+256+256²+256³=16,843,018 data blocks, totaling 17,247,250,432 bytes.

2. The32-bit block-address space and 48-bit integer bound are both larger and do not constrain this total. The dominant triple-indirect contribution alone is 256³×1024=234 bytes, option C, but the exact maximum includes direct, single-indirect and double-indirect blocks and exceeds 234 by 67,381,248 bytes.

3. Thus no offered power-of-two option is exactly the stated maximum; C is the usual scale approximation, not an exact equality.

4. Teaching check: Indirect blocks contain addresses, so divide 1024 bytes by four bytes per address before exponentiating. The triple-indirect branch contributes 256³ data blocks; it does not replace the smaller branches. Distinguish exact capacity from the dominant-power approximation offered by the choices.

Original paper, page 7

2 marks · MCQ
Report issue

Prime-attribute dependencies and normal form

Normalization & Decomposition

Question 50, GATE 2004: StudentPerformance(name,courseNo,rollNo,grade) has dependencies (name,courseNo)→grade; (rollNo,courseNo)→grade; name→rollNo; rollNo→name. What is its highest listed normal form?
Options:
(A) 2NF
(B) 3NF
(C) BCNF
(D) 4NF
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step through it (8 steps)

1. The candidate keys are{name,courseNo} and{rollNo,courseNo}. Thus name,rollNo,courseNo are prime attributes, and grade is non-prime.

2. Dependencies from either key to grade satisfy 3NF. The non-key determinants name and rollNo determine only another prime attribute, so these dependencies also satisfy 3NF.

3. But name→rollNo and rollNo→name violate BCNF because neither determinant determines courseNo. Highest listed normal form is 3NF.

4. Teaching check: Compute closures: {name,courseNo}+ and {rollNo,courseNo}+ both contain all attributes, but name+ contains only name,rollNo. In 3NF a non-superkey determinant may determine a prime attribute; BCNF forbids that exception. This is exactly why the two normal forms differ here.

Original paper, page 7

2 marks · MCQ
Report issue

Universal comparison through relational difference

Relational Algebra & Calculus

Question 51, GATE 2004: Student(name,sex,marks), key name, contains at least one boy and one girl. Let ρ_(n,x,m)(Student) rename the three attributes. Interpret π_name(σ_(sex=female)(Student)) − π_name(Student ⋈_(sex=female ∧ x=male ∧ marks≤m) ρ_(n,x,m)(Student)).
Options:
(A) Names of girls with the highest marks
(B) Names of girls with more marks than some boy
(C) Names of girls with marks not less than some boy
(D) Names of girls with more marks than every boy
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The left expression selects all female names. The right expression finds a female student paired with a male student whose marks m satisfy female marks≤m, and projects that female name.

2. Subtracting these removes every girl for whom at least one boy has marks greater than or equal to hers. Remaining girls therefore have marks greater than EVERY boy.

3. The primary-key name makes the projected subtraction unambiguous, and the stated existence of boys avoids a vacuous comparison.

4. Teaching check: The joined part is an existential counterexample set: it contains a girl if there exists a boy with marks at least hers. Subtracting all such counterexamples converts “there exists a violating boy” into “every boy has fewer marks.” Equality is removed because the join uses ≤.

Original paper, page 7

2 marks · MCQ
Report issue

B-plus tree internal-node order

Indexing, Storage & Query Processing

Question 52, GATE 2004: The order of an internal B+ tree node is its maximum number of children. Child pointers use 6 bytes, search keys 14 bytes and each node occupies a 512-byte block. With no stated header overhead, what is the order?
Options:
(A) 24
(B) 25
(C) 26
(D) 27
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. With order p, an internal node holds p child pointers and p−1 separator keys. The size is 6p+14(p−1)=20p−14≤512, so p≤26.3 and the maximum integer is 26.

2. At p=26 the node uses 506 bytes; p=27 would need 526 bytes. No unmentioned header overhead is assumed.

3. Teaching check: There is one fewer separator key than child pointers, so a p-child node needs p pointers and p−1 keys. Using p of each would incorrectly lower the capacity. Testing the two neighboring integers confirms maximality rather than relying only on rounded division.

Original paper, page 7

2 marks · MCQ
Report issue

Grouped salary comparison with global average

SQL & Queries

Question 53, GATE 2004: Employee(name,sex,salary,deptName) has key name. What department names does this SQL query return?
SELECT deptName FROM Employee
WHERE sex='M'
GROUP BY deptName
HAVING AVG(salary) > (SELECT AVG(salary) FROM Employee);
Options:
(A) Departments whose average salary exceeds the company average
(B) Departments whose male average salary exceeds the company-wide male average
(C) Departments whose male average salary exceeds the average of all employees in that department
(D) Departments whose male average salary exceeds the company average
Question 53, GATE 2004: Employee(name,sex,salary,deptName) has key name. What department names does this SQL query return?
SELECT deptName FROM Employee
WHERE sex='M'
GROUP BY deptName
HAVING AVG(salary) > (SELECT AVG(salary) FROM Employee);
Options:
(A) Departments whose average salary exceeds the company average
(B) Departments whose male average salary exceeds the company-wide male average
(C) Departments whose male average salary exceeds the average of all employees in that department
(D) Departments whose male average salary exceeds the company average
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. WHERE sex=M filters the outer rows to male employees before grouping by department. HAVING compares each such group’s average salary with the uncorrelated subquery SELECT AVG(salary) FROM Employee, which averages all employees company-wide.

2. Therefore it returns departments whose male employees’ average exceeds the overall company average. The inner query has no male filter and is not restricted to the same department.

3. Teaching check: Read SQL in stages: WHERE keeps only males; GROUP BY makes one male group per department; HAVING compares its average against a separately computed company-wide average. There is no correlation predicate linking the subquery to the department, and no sex filter inside it.

Original paper, page 7

2 marks · MCQ
Report issue

Ethernet binary exponential backoff race

Medium Access & Ethernet

Question 54, GATE 2004: A,B are the only Ethernet stations, each with a steady frame queue. Their first frames collide; A wins the first backoff race and transmits successfully. They transmit again and collide. What is the probability A wins the second backoff race?
Options:
(A) 0.5
(B) 0.625
(C) 0.75
(D) 1.0
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. After A succeeds, its next frame starts with collision count reset; following the next collision A chooses uniformly from{0,1}. B’s still-unsent frame has now collided twice, so B chooses uniformly from{0,1,2,3}.

2. Of the 8 equally likely pairs, A wins strictly when(A,B) is(0,1),(0,2),(0,3),(1,2),(1,3), giving 5/8=0.625. Equal choices cause another collision, not a win.

3. This evaluates the stated next backoff race, not eventual success after arbitrarily many tied races.

4. Teaching check: Binary exponential backoff counts collisions for the current frame, not for the station forever. A has a new frame while B retries its old one. Among A’s two and B’s four choices, five of eight pairs give A the strictly smaller delay; ties are new collisions.

Original paper, page 8

2 marks · MCQ
Report issue

Longest-prefix routing and host route

Routing Algorithms

Question 55, GATE 2004: Router entries (destination,mask,interface) are (128.75.43.0,255.255.255.0,Eth0), (128.75.43.0,255.255.255.128,Eth1), (192.12.17.5,255.255.255.255,Eth3), and default→Eth2. Which interfaces forward destinations 128.75.43.16 and 192.12.17.10 respectively?
Options:
(A) Eth1,Eth2
(B) Eth0,Eth2
(C) Eth0,Eth3
(D) Eth1,Eth3
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (4 steps)

Step 1: 128.75.43.16 matches both 128.75.43.0/24 and 128.75.43.0/25; the longer /25 prefix selects Eth1.192.12.17.10 does not equal the only 192.12.17.* explicit route, the /32 host route 192.12.17.5 via Eth3, so it uses default Eth2. Matching the first three octets does not make a /32 host route a subnet route.

Step 2: Teaching check: The /25 mask covers last-octet values 0–127, including 16, and outranks /24. The /32 entry matches exactly 192.12.17.5, not all addresses beginning 192.12.17. Any other unmatched destination, including .10, uses default.

Original paper, page 8

2 marks · MCQ
Report issue

IP fragmentation and header overhead

IP Addressing, Fragmentation & Address Resolution

Question 56, GATE 2004: Networks A→B→C connect host HA in A to host HC in C. Every application message has 180 bytes; TCP adds a 20-byte header. Maximum IP packet sizes including a 20-byte IP header are A:1000 bytes, B:100 bytes, C:1000 bytes. A–B is 1 Mbps and B–C is 512 Kbps. GateForum labels the second link 512 Mbps in its diagram but 512 Kbps in prose; use the common GFG/prose reading, retaining this discrepancy. Assuming correct delivery and data packets only, how many total bytes including headers reach the destination IP layer for one application message in the best case?
Options:
(A) 200
(B) 220
(C) 240
(D) 260
Question 56, GATE 2004: Networks A→B→C connect host HA in A to host HC in C. Every application message has 180 bytes; TCP adds a 20-byte header. Maximum IP packet sizes including a 20-byte IP header are A:1000 bytes, B:100 bytes, C:1000 bytes. A–B is 1 Mbps and B–C is 512 Kbps. GateForum labels the second link 512 Mbps in its diagram but 512 Kbps in prose; use the common GFG/prose reading, retaining this discrepancy. Assuming correct delivery and data packets only, how many total bytes including headers reach the destination IP layer for one application message in the best case?
Options:
(A) 200
(B) 220
(C) 240
(D) 260
Question 56, GATE 2004: Networks A→B→C connect host HA in A to host HC in C. Every application message has 180 bytes; TCP adds a 20-byte header. Maximum IP packet sizes including a 20-byte IP header are A:1000 bytes, B:100 bytes, C:1000 bytes. A–B is 1 Mbps and B–C is 512 Kbps. GateForum labels the second link 512 Mbps in its diagram but 512 Kbps in prose; use the common GFG/prose reading, retaining this discrepancy. Assuming correct delivery and data packets only, how many total bytes including headers reach the destination IP layer for one application message in the best case?
Options:
(A) 200
(B) 220
(C) 240
(D) 260
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Each application message contributes 180 bytes plus 20 TCP-header bytes, so the IP payload is 200 bytes. The100-byte MTU in network B leaves 80 payload bytes per fragment.

2. Three fragments carry 80,80,40 bytes with their own 20-byte IP headers, totaling 100+100+60=260 bytes delivered to the destination IP layer.80 is divisible by the IPv4 fragment-offset unit 8, so this split is valid. Routers do not reassemble merely because the following network has a larger MTU.

3. Teaching check: Only IP headers are repeated per fragment; the TCP header belongs to the original 200-byte payload and is not added to each fragment. Payload sizes 80,80,40 need three IP headers, so 200+3×20=260 bytes.

Original paper, page 8

2 marks · MCQ
Report issue

Fragmentation-limited application goodput

IP Addressing, Fragmentation & Address Resolution

Question 57, GATE 2004: Networks A→B→C connect host HA in A to host HC in C. Every application message has 180 bytes; TCP adds a 20-byte header. Maximum IP packet sizes including a 20-byte IP header are A:1000 bytes, B:100 bytes, C:1000 bytes. A–B is 1 Mbps and B–C is 512 Kbps. GateForum labels the second link 512 Mbps in its diagram but 512 Kbps in prose; use the common GFG/prose reading, retaining this discrepancy. What is the sustained application-data rate to HC, ignoring errors, acknowledgements and other overhead?
Options:
(A) 325.5 Kbps
(B) 354.5 Kbps
(C) 409.6 Kbps
(D) 512.0 Kbps
Question 57, GATE 2004: Networks A→B→C connect host HA in A to host HC in C. Every application message has 180 bytes; TCP adds a 20-byte header. Maximum IP packet sizes including a 20-byte IP header are A:1000 bytes, B:100 bytes, C:1000 bytes. A–B is 1 Mbps and B–C is 512 Kbps. GateForum labels the second link 512 Mbps in its diagram but 512 Kbps in prose; use the common GFG/prose reading, retaining this discrepancy. What is the sustained application-data rate to HC, ignoring errors, acknowledgements and other overhead?
Options:
(A) 325.5 Kbps
(B) 354.5 Kbps
(C) 409.6 Kbps
(D) 512.0 Kbps
Question 57, GATE 2004: Networks A→B→C connect host HA in A to host HC in C. Every application message has 180 bytes; TCP adds a 20-byte header. Maximum IP packet sizes including a 20-byte IP header are A:1000 bytes, B:100 bytes, C:1000 bytes. A–B is 1 Mbps and B–C is 512 Kbps. GateForum labels the second link 512 Mbps in its diagram but 512 Kbps in prose; use the common GFG/prose reading, retaining this discrepancy. What is the sustained application-data rate to HC, ignoring errors, acknowledgements and other overhead?
Options:
(A) 325.5 Kbps
(B) 354.5 Kbps
(C) 409.6 Kbps
(D) 512.0 Kbps
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Per message the bottleneck B→C link transports260 bytes, of which 180 are application data. Its sustained goodput is 512×180/260=354.4615Kbps, rounding to 354.5Kbps.

2. The1Mbps link is not the bottleneck. This uses pipelined steady-state traffic, ignoring stated overheads; it is not the reciprocal of end-to-end latency of one isolated message.

4. Teaching check: Goodput counts useful application bits, not all bits on the bottleneck. Each 260 transmitted bytes delivers 180 application bytes, giving efficiency 9/13. Multiplying 512 Kbps by that efficiency yields 354.46 Kbps; using 200 useful bytes would incorrectly include TCP overhead.

Original paper, page 8

2 marks · MCQ
Report issue

BCD threshold detector gate count

Binary Codes & Error Detection

Question 58, GATE 2004: A decimal digit is encoded in four-bit BCD: 0=0000,…,9=1001. A combinational circuit must output 1 iff the digit is at least 5. Using only AND,OR,NOT gates, what is the minimum number of gates?
Options:
(A) 2
(B) 3
(C) 4
(D) 5
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Write the BCD inputs A,B,C,D with weights 8,4,2,1. For valid digits 0–9, the threshold predicate digit≥5 is A OR[B AND(C OR D)].

2. This uses three gates: one OR for C+D, one AND with B, and one OR with A. All four inputs are essential on valid BCD pairs (0/8,1/5,4/6,4/5 respectively), and a two-gate AND/OR/NOT network cannot express both the independent A case and the nested B∧(C∨D) case.

3. Invalid BCD encodings 10–15 are unspecified/don’t-care, as the source produces a digit.

4. Teaching check: Use digit weights 8,4,2,1. Digits 8 and 9 are detected by the 8-bit; digits 5,6,7 require the 4-bit and at least one low bit. Values 10–15 are not decimal digits supplied by this source, so they are don’t-care cases rather than additional truth-table requirements.

Original paper, page 8

2 marks · MCQ
Report issue

Essential prime implicants

Logic Minimization & Karnaugh Maps

Question 59, GATE 2004: What are the essential prime implicants of f(a,b,c)=a′c+ac′+b′c?
Options:
(A) a′c and ac′
(B) a′c and b′c
(C) a′c only
(D) ac′ and bc′
Question 59, GATE 2004: What are the essential prime implicants of f(a,b,c)=a′c+ac′+b′c?
Options:
(A) a′c and ac′
(B) a′c and b′c
(C) a′c only
(D) ac′ and bc′
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (12 steps)

1. The on-set of a′c+ac′+b′c is{1,3,4,5,6}. Prime implicants include a′c covering 1,3; ac′ covering 4,6; b′c covering 1,5; and ab′ covering 4,5.

2. Minterm3 is covered only by a′c, and minterm 6 only by ac′, so these two are essential. Minterm5 can be covered by either b′c or ab′, making neither of those essential.

3. Teaching check: A prime implicant is essential only if it alone covers some on-set minterm. Minterm 5 can be covered by either b′c or ab′, so the visible term b′c is not essential merely because it appears in the original expression.

Original paper, page 8

2 marks · MCQ
Report issue

Realizing OR with a multiplexer

Combinational Circuits

Question 60, GATE 2004: A two-input mux selects data input X when control Z=0, and Y when Z=1. Which connections realize f=T+R without extra hardware?
Options:
(A) X=R,Y=1,Z=T
(B) X=T,Y=R,Z=T
(C) X=T,Y=R,Z=0
(D) X=R,Y=0,Z=T
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. A two-input mux computes Z′X+ZY. Set X=R,Y=1,Z=T: output=T′R+T=T+R by absorption.

2. When T=0 it passes R; when T=1 it outputs 1. These are precisely the two cases of OR, with no additional gate.

3. Teaching check: Mux select is a Shannon expansion: f=Z′X+ZY. Taking Z=T splits OR into f|T=0=R and f|T=1=1. This supplies the data connections directly, without trying every arbitrary wiring pattern.

Original paper, page 9

2 marks · MCQ
Report issue

T-flip-flop excitation for Gray sequence

Counters & Timing

Question 61, GATE 2004: A synchronous two-bit counter uses T flip-flops with outputs Q2 (MSB) and Q1 (LSB), driven by a common clock. Its required cycle is 0→2→3→1→0. The figure wires XNOR(Q1,Q2) to T2; the unknown X drives T1. What is X?
Options:
(A) Q2′
(B) Q2+Q1
(C) (Q1⊕Q2)′
(D) Q1⊕Q2
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Use state order Q2Q1=00→10→11→01→00. Since a T flip-flop toggles exactly when T=1, the LSB excitation Q1 XOR Q1(next) takes values 0,1,0,1 at states 00,10,11,01.

2. This is Q1 XOR Q2. The MSB excitation is its complement, agreeing with the pictured XNOR feedback into T2.

3. Thus X=Q1⊕Q2.

4. Teaching check: For each present state, calculate toggle=present bit XOR next bit. At 00,10,11,01 the LSB toggles 0,1,0,1 and the MSB toggles 1,0,1,0. These complementary sequences explain the given XNOR and required XOR together.

Original paper, page 9

2 marks · MCQ
Report issue

Carry lookahead propagation depth

Combinational Circuits

Question 62, GATE 2004: A 4-bit carry-lookahead adder is built only from AND,OR,NOT,NAND,NOR gates. Inputs are supplied in true and complemented forms. Each gate has unit delay, and the carry network is a two-level AND–OR implementation. What is the overall propagation delay? The exact complement-generation/netlist convention is not specified.
Options:
(A) 4 time units
(B) 6 time units
(C) 10 time units
(D) 12 time units
Tap to enlarge
Your answer
Answer & solution

Answer: B under conventional parallel complemented-signal implementation (no official key was published)

1. With input complements supplied, pi=ai XOR bi and its complement can each be formed in two gate levels, while gi=ai bi needs one. Expanding each carry as an OR of generate/propagate products adds two levels after the propagate signals, so carries and their complements can be ready at time 4 (parallel OR/NOR outputs).

2. A sum si=pi XOR ci can then be realized in two further AND–OR levels using these true/complement signals, giving time 6. This is the conventional gate-delay model behind B; it assumes sufficient fan-in for the stipulated two-level carry network and parallel generation of needed complements.

3. The wording does not specify a unique netlist or minimum-area implementation; adding serial inversion or a three-level XOR implementation can produce a different delay, so 6 is not a delay guaranteed for every allowed circuit.

4. Teaching check: The critical path goes through propagate formation, the expanded carry network and sum formation. Under the conventional parallel true/complement implementation these cost 2+2+2 levels. A statement about this implementation is different from a universal claim about every legal gate netlist.

Original paper, page 9

2 marks · MCQ
Report issue

Interrupt return address after halt

Input/Output, DMA & Interrupts

Question 63, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Memory is byte-addressable with 32-bit words and the program starts at decimal 1000. If an interrupt occurs after HALT has executed, what decimal return address is saved on the stack?
Options:
(A) 1007
(B) 1020
(C) 1024
(D) 1028
Question 63, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Memory is byte-addressable with 32-bit words and the program starts at decimal 1000. If an interrupt occurs after HALT has executed, what decimal return address is saved on the stack?
Options:
(A) 1007
(B) 1020
(C) 1024
(D) 1028
Question 63, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Memory is byte-addressable with 32-bit words and the program starts at decimal 1000. If an interrupt occurs after HALT has executed, what decimal return address is saved on the stack?
Options:
(A) 1007
(B) 1020
(C) 1024
(D) 1028
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The five instructions occupy 2+1+1+2+1=7 words. Each word is 32 bits=4 bytes, so the program occupies 28 bytes starting at 1000.

2. Under the ordinary next-instruction-PC convention, after fetching/executing HALT the saved return address is 1000+28=1028. HALT itself begins at 1024;1007 would confuse word and byte addressing.

3. Teaching check: Instruction start addresses are 1000,1008,1012,1016,1024. HALT occupies one four-byte word, so the next sequential address is 1028. Saving 1024 would resume at HALT itself; saving 1007 wrongly treats byte-addressed memory as word-addressed.

Original paper, page 9

2 marks · MCQ
Report issue

Instruction fetch and execution cycles

Processor Performance

Question 64, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Each register/memory transfer costs 3 cycles, register ADD costs 1 cycle, and instruction fetch/decode costs 2 cycles per word. What is the total execution-cycle count?
Options:
(A) 29
(B) 24
(C) 23
(D) 20
Question 64, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Each register/memory transfer costs 3 cycles, register ADD costs 1 cycle, and instruction fetch/decode costs 2 cycles per word. What is the total execution-cycle count?
Options:
(A) 29
(B) 24
(C) 23
(D) 20
Question 64, GATE 2004: A CPU has user registers R1,R2,R3. Program in order (operation; instruction size in words): MOV R1,5000 (R1←Memory[5000];2); MOV R2,(R1) (R2←Memory[R1];1); ADD R2,R3 (R2←R2+R3;1); MOV 6000,R2 (Memory[6000]←R2;2); HALT (machine halts;1). Each register/memory transfer costs 3 cycles, register ADD costs 1 cycle, and instruction fetch/decode costs 2 cycles per word. What is the total execution-cycle count?
Options:
(A) 29
(B) 24
(C) 23
(D) 20
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. There are 7 instruction words, so fetch/decode costs 7×2=14 cycles. The first MOV loads a memory word, the second MOV uses register-indirect addressing to load one memory word, and the last MOV stores one memory word:3 transfers×3=9 cycles.

2. ADD has register operands and costs 1. No extra HALT execution cost is specified.

3. Total14+9+1=24 cycles. Register-indirect addressing does not itself require another memory load because R1 already contains the address.

4. Teaching check: The instruction sizes sum to seven words, so fetch/decode alone costs fourteen cycles. Indirect MOV R2,(R1) uses R1’s value as an address; it does not first fetch that address from memory. This leaves exactly three data-memory transfers and one ADD.

Original paper, page 9

2 marks · MCQ
Report issue

Two-way LRU cache conflicts

Cache Memory

Question 65, GATE 2004: A two-way set-associative cache contains four blocks total and uses LRU replacement. How many misses occur for block references 8,12,0,12,8? Assume an initially empty cache and conventional block-number modulo number-of-sets mapping.
Options:
(A) 2
(B) 3
(C) 4
(D) 5
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Four blocks in a two-way cache means two sets. With the standard block-number modulo 2 mapping,8,12,0 all map to the same set.

2. Starting empty:8 miss gives[8];12 miss gives[8,12];0 miss evicts least-recent 8, giving[12,0];12 hits and becomes MRU;8 misses and evicts 0. Thus four misses.

3. The unused other set cannot absorb these conflicting blocks. An initially empty cache and conventional set indexing are assumed.

4. Teaching check: Only two ways are available in the even-numbered set despite four blocks existing overall. The access to 12 after inserting 0 is a hit and changes recency. That change determines which entry is evicted on the final 8 reference, although the miss count remains four.

Original paper, page 9

2 marks · MCQ
Report issue

Product of signed eight-bit numbers

Number Systems & Computer Arithmetic

Question 66, GATE 2004: A=11111010 and B=00001010 are eight-bit two’s-complement numbers. Which listed eight-bit two’s-complement result represents their product? Option B follows GFG (10011100); GateForum instead prints 10111100.
Options:
(A) 11000100
(B) 10011100
(C) 10100101
(D) 11010101
Question 66, GATE 2004: A=11111010 and B=00001010 are eight-bit two’s-complement numbers. Which listed eight-bit two’s-complement result represents their product? Option B follows GFG (10011100); GateForum instead prints 10111100.
Options:
(A) 11000100
(B) 10011100
(C) 10100101
(D) 11010101
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: 11111010 represents 250−256=−6 and 00001010 represents 10. Their product is −60, which fits in eight signed bits.

Step 2: Its encoding is 256−60=196=11000100, option A. A full sixteen-bit product is its sign extension, 1111111111000100; the options clearly request the eight-bit representation.

Step 3: Teaching check: Negating 11111010 by invert-and-add-one gives magnitude 00000110=6, so the signed operand is −6. The product −60 fits in [−128,127], avoiding overflow. Check the chosen output by decoding 11000100 as 196−256=−60.

Original paper, page 9

2 marks · MCQ
Report issue

Microinstruction address and multiplexer fields

Datapath & Control Unit

Question 67, GATE 2004: A 26-bit microinstruction has a 13-bit micro-operation field, next-address field X and MUX-select field Y. A MUX selects one of eight status bits. Figure connectivity: X feeds the control address register; Y selects the status MUX; the selected status controls address-register load versus increment; that register addresses control memory. What are (X bits,Y bits,control-memory words)?
Options:
(A) 10,3,1024
(B) 8,5,256
(C) 5,8,2048
(D) 10,3,512
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. An eight-input status multiplexer needs Y=log2(8)=3 select bits. Of the 26 microinstruction bits, 13 encode operations, leaving X=26−13−3=10 next-address bits.

2. An address space of ten bits contains 210=1024 control-memory words. Thus (X,Y,words)=(10,3,1024), A.

3. Teaching check: The select field encodes which of eight status lines is used, so it needs three bits rather than eight. The next-address width is what addresses control-memory words; the microinstruction width determines word size, not the number of words.

Original paper, page 10

2 marks · MCQ
Report issue

Processor overhead for DMA blocks

Input/Output, DMA & Interrupts

Question 68, GATE 2004: A disk continuously transfers at 10 Mbytes/s using DMA. A 600-MHz CPU uses 300 cycles to initiate and 900 cycles to complete each 20-Kbyte DMA block transfer. What percentage of CPU time is consumed by transfer overhead?
Options:
(A) 5.0%
(B) 1.0%
(C) 0.5%
(D) 0.1%
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The CPU spends 300+900=1200 cycles per block, or 1200/(600×106)=2 microseconds. At 10 MB/s a 20 KB block takes approximately 2 milliseconds, so CPU overhead is 2 microseconds / 2 milliseconds ×100%=0.1%, D.

2. Consistent binary KB/MB units give about 0.1024%, still the stated approximation. This counts setup/completion CPU time, not the disk-transfer duration as busy CPU time.

3. Teaching check: DMA frees the CPU during the bulk data movement. Charge only 1200 CPU cycles per transfer, not the full disk-transfer interval. Using consistent seconds and clock cycles gives a dimensionless ratio before multiplying by 100 to express a percentage.

Original paper, page 10

2 marks · MCQ
Report issue

Four-stage pipeline completion time

Pipelining & Hazards

Question 69, GATE 2004: A four-stage pipeline has stage delays 150,120,160,140 ns and interstage-register delay 5 ns. With a constant clock period, how long does it take to process 1000 items?
Options:
(A) 120.4 μs
(B) 160.5 μs
(C) 165.5 μs
(D) 590.0 μs
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The common clock period is the slowest stage plus register delay: max(150,120,160,140)+5=165 ns. A four-stage pipeline needs 4 cycles for its first item and 999 more for the remaining items.

2. Total time is (1000+4−1)×165=165495 ns=165.495 microseconds, rounded to 165.5 microseconds, C. This is the standard balanced-clock pipeline timing model.

3. Teaching check: Pipeline throughput is set by the slowest stage, not the sum of stage delays. The sum matters for an unpipelined path; the pipelined batch takes a fill of four cycles plus one cycle for each subsequent item. Include the register delay in every clock period.

Original paper, page 10

2 marks · MCQ
Report issue

Satisfiability of an implication formula

Propositional & Predicate Logic

Question 70, GATE 2004: Classify (P→(Q∨R))→((P∨Q)→R). GFG uses ∨ in the second antecedent; GateForum prints ∧ there. Classify the stated GFG formula, and retain the alternate reading.
Options:
(A) Satisfiable but not valid
(B) Valid
(C) A contradiction
(D) None of the above
Question 70, GATE 2004: Classify (P→(Q∨R))→((P∨Q)→R). GFG uses ∨ in the second antecedent; GateForum prints ∧ there. Classify the stated GFG formula, and retain the alternate reading.
Options:
(A) Satisfiable but not valid
(B) Valid
(C) A contradiction
(D) None of the above
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Formula (P→(Q∨R))→((P∨Q)→R), setting R=true makes the whole formula true, so it is satisfiable. Setting P=true,Q=true,R=false makes the premise true and the consequent false, so it is not valid.

2. Hence A.

3. Teaching check: To show satisfiable but not valid, one true assignment and one false assignment suffice. With R=true, the consequent is true. With P=Q=true,R=false, the antecedent is true and the consequent false.

Original paper, page 10

2 marks · MCQ
Report issue

Consistency of three linear equations

Linear Algebra

Question 71, GATE 2004: How many solutions has the system? GFG: −x+5y=1; x−y=2; x−3y=3. GateForum differs: −x+5y=−1; x−y=2; x+3y=3. Both readings are retained rather than merging their signs.
Options:
(A) Infinitely many
(B) Two distinct solutions
(C) Unique
(D) None
Tap to enlarge
Your answer
Answer & solution

Answer: None (no official key was published)

1. The the paper rendering reads −x+5y=1, x−y=2, x−3y=3. The first two give y=3/4 and x=11/4, which yield x−3y=1/2, not 3: no solution (D).

2. Its first two give (x,y)=(9/4,1/4), satisfying the third: a unique solution (C).

3. The source disagreement prevents an unconditional option.

4. Teaching check: Solve two independent equations and substitute into the third rather than counting equations. More equations than unknowns may be inconsistent or redundant. Here changing two signs changes exactly that distinction, so preserving separate source readings is essential.

Original paper, page 10

2 marks · MCQ
Report issue

Complete a cyclic group multiplication table

Algebraic Structures

Question 72, GATE 2004: A group has elements e,a,b,c. Its operation table has columns e,a,b,c. Known row e is e,a,b,c; known row a is a,b,c,e; rows b,c are otherwise blank. What is row c in that column order?
Options:
(A) c,a,e,b
(B) c,b,a,e
(C) c,b,e,a
(D) c,e,a,b
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. The given row for a says a·a=b, a·b=c, and a·c=e. Therefore b=a², c=a³, a⁴=e, so the group is cyclic of order four.

2. The c row under columns e,a,b,c is a³,a⁴,a⁵,a⁶, namely c,e,a,b. This is D.

3. Teaching check: Associativity lets powers of a determine the entire subgroup generated by a. Since e,a,a²=b,a³=c are four distinct elements, this is the whole group. Multiplying c=a³ by e,a,a²,a³ reduces exponents modulo four and yields c,e,a,b.

Original paper, page 10

2 marks · MCQ
Report issue

Minimal offered augmentation of a subset lattice

Partial Orders & Lattices

Question 73, GATE 2004: Let S={{1,2},{1,2,3},{1,3,5},{1,2,4},{1,2,3,4,5}}, ordered by containment. Which listed minimal collection of sets must be adjoined to make a complete lattice? “Necessary” is interpreted as the minimal sufficient offered augmentation, not a claim excluding every other possible bottom element.
Options:
(A) {1}
(B) {1} and {2,3}
(C) {1} and {1,3}
(D) {1}, {1,3}, {1,2,3,4}, {1,2,3,5}
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Write U={1,2}, V={1,2,3}, W={1,3,5}, X={1,2,4}, and T={1,2,3,4,5}. Adjoin B={1}.

2. Comparable pairs already have their meet and join. The incomparable pairs (U,W), (V,W), and (X,W) have meet B and join T; (V,X) has meet U and join T.

3. Thus every pair has meet/join, and the finite nonempty poset with bottom B and top T is complete. Adding only {1}, option A, is sufficient and is the minimal augmentation among the offered choices.

4. Teaching check: A lattice’s join must be the least upper bound within the displayed poset, not necessarily the ordinary union set if that set is absent. Similarly the meet is the greatest available lower bound. After adding {1}, a finite bounded lattice is complete, including empty-family meet and join.

Original paper, page 10

2 marks · MCQ
Report issue

Expected aggregate score from random guesses

Probability & Random Variables

Question 74, GATE 2004: An exam has 150 one-mark multiple-choice questions, each with four choices. Correct answers earn 1; incorrect answers earn −0.25. If 1000 students choose all answers uniformly at random, what is the sum of their expected marks?
Options:
(A) 0
(B) 2550
(C) 7525
(D) 9375
Question 74, GATE 2004: An exam has 150 one-mark multiple-choice questions, each with four choices. Correct answers earn 1; incorrect answers earn −0.25. If 1000 students choose all answers uniformly at random, what is the sum of their expected marks?
Options:
(A) 0
(B) 2550
(C) 7525
(D) 9375
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Each answer earns +1 with probability 1/4 and −1/4 with probability 3/4. Its expected mark is 1/4−3/16=1/16.

2. Linearity of expectation gives 1000×150×(1/16)=9375 total expected marks, D. Independence between different answers is not needed for summing expectations.

3. Teaching check: The negative mark is one quarter, not one third. Therefore random guessing has positive expectation here: (1/4)×1+(3/4)×(−1/4)=1/16 per question. Zero expectation would require a different wrong-answer penalty.

Original paper, page 10

2 marks · MCQ
Report issue

Count unordered colour pairs with repetition

Combinatorics & Counting

Question 75, GATE 2004: Each of 26 English letters is printed twice in a colouring book. Colour each of the 52 prints using k colours so the unordered pair of colours for each letter differs from that for every other letter. Both copies of a letter may have the same colour. What is the minimum k?
Options:
(A) 9
(B) 8
(C) 7
(D) 6
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. A letter receives an unordered pair of colours, allowing the same colour twice. There are binomial(k,2)+k=k(k+1)/2 possible pairs.

2. Distinguishing 26 letters requires k(k+1)/2≥26. Six colours give only 21 pairs, while seven give 28, so the minimum is 7, option C.

3. Teaching check: Count colour pairs with repetition and without order. Distinct-colour pairs contribute k(k−1)/2 and equal-colour pairs contribute k. Ordered pairs would give k² and underestimate the required number of colours for the problem’s pair interpretation.

Original paper, page 11

2 marks · MCQ
Report issue

Bound a matching by a row-column cover

Graph Theory

Question 76, GATE 2004: All nonzero entries of an M×N matrix are covered by the union of a specified a rows and b columns. What universal upper bound holds on the number of nonzero entries that can be selected with no two in the same row or column?
Options:
(A) ≤a+b
(B) ≤max(a,b)
(C) ≤min(M−a,N−b)
(D) ≤min(a,b)
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Treat each nonzero entry as an edge from its row vertex to its column vertex. The stated a rows together with b columns cover all such edges.

2. Any selection with no two entries in the same row or column is a matching. Each chosen entry must use at least one of the a+b covering vertices, and no covering vertex can serve two chosen entries.

3. Consequently the selection has at most a+b entries, A. The bound can be attained with edges using distinct other endpoints; it need not equal the actual maximum.

4. Teaching check: The covering rows and columns form a vertex cover in a bipartite graph. A matching cannot reuse any covering vertex, so its size is at most the cover size. This does not require invoking the stronger theorem equating maximum matching and minimum cover.

Original paper, page 11

2 marks · MCQ
Report issue

Chromatic number of the eight-vertex diagram

Graph Theory

Question 77, GATE 2004: Find the chromatic number of this undirected graph. Textual equivalent of figure: outer vertices T,R,B,L form cycle T–R–B–L–T; inner vertices u,v,w,z form cycle u–v–w–z–u. Additional edges are T–u,T–v,R–v,R–w,B–w,B–z,L–z,L–u. There are no other edges.
Options:
(A) 2
(B) 3
(C) 4
(D) 5
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Name outer vertices T,R,B,L and inner square vertices u (upper-left), v (upper-right), w (lower-right), z (lower-left). The diagram has outer cycle T-R-B-L-T, inner cycle u-v-w-z-u, and edges T-u,T-v,R-v,R-w,B-w,B-z,L-z,L-u.

2. Suppose three colours suffice. Triangle Tuv can be coloured T=3,u=1,v=2.

3. Triangle Tuz is not present, but L is adjacent to T and u, forcing L=2. Since z is adjacent to L and u, z=3.

4. Since w is adjacent to z and v, w=1. B, adjacent to z and w, must then be 2, contradicting edge B-L.

5. Four colours suffice: T=B=1, L=R=2, u=w=3, v=z=4. Therefore the chromatic number is 4, C.

6. Teaching check: The argument needs both a lower and an upper bound: forcing a contradiction under three colours proves at least four; the explicit assignment proves at most four. Merely observing a triangle would establish only a lower bound of three.

Original paper, page 11

2 marks · MCQ
Report issue

Probability of a specified Hamming distance

Probability & Random Variables

Question 78, GATE 2004: Two n-bit binary strings are drawn independently and uniformly. What is the probability their Hamming distance (number of differing positions) is d, 0≤d≤n?
Options:
(A) C(n,d)/2^n
(B) C(n,d)/2^d
(C) d/2^n
(D) 1/2^d
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Fix the first n-bit string. Exactly binomial(n,d) second strings differ in d positions, since the chosen positions uniquely determine their bit flips.

2. All 2n second strings are equally likely, giving binomial(n,d)/2n, A, for integer 0≤d≤n. This uses the intended independent uniform draws; uniform marginals alone without independence would not determine the result.

3. Teaching check: After fixing S1, choose the d positions where S2 differs; at each such binary position its value is forced. No additional factor 2d is needed. Summing C(n,d)/2n over all d gives 1, a useful normalization check.

Original paper, page 11

2 marks · MCQ
Report issue

Count dense labelled simple graphs

Graph Theory

Question 79, GATE 2004: How many simple undirected graphs on n labelled vertices have at least (n²−3n)/2 edges? Write N=(n²−n)/2 and C(N,k)=binomial(N,k).
Options:
(A) C(N,N−n)
(B) Σ_(k=0)^(N−n) C(N,k)
(C) C(N,n)
(D) Σ_(k=0)^n C(N,k)
Question 79, GATE 2004: How many simple undirected graphs on n labelled vertices have at least (n²−3n)/2 edges? Write N=(n²−n)/2 and C(N,k)=binomial(N,k).
Options:
(A) C(N,N−n)
(B) Σ_(k=0)^(N−n) C(N,k)
(C) C(N,n)
(D) Σ_(k=0)^n C(N,k)
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. A simple undirected graph on n labelled vertices has N=binomial(n,2) possible edges. The threshold (n²−3n)/2 is N−n.

2. Having at least N−n edges is equivalent to omitting at most n edges. Choose the missing edges: the count is sum from k=0 to n of binomial(N,k), option D, with binomial(N,k)=0 for k>N.

3. This is also sum from j=max(0,N−n) to N of binomial(N,j).

4. Teaching check: Complementing the edge set turns a dense-graph count into a sparse missing-edge count. “At least” requires a sum over several edge counts, whereas one binomial coefficient counts graphs with exactly one edge count. Use zero for binomial terms with impossible k.

Original paper, page 11

2 marks · MCQ
Report issue

Expected squared radius in a rectangle

Probability & Statistics

Question 80, GATE 2004: Choose a point uniformly from the rectangle with corners (0,0),(1,0),(1,2),(0,2). If p is its distance from the origin, what is E[p²]?
Options:
(A) 2/3
(B) 1
(C) 4/3
(D) 5/3
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Uniform sampling over [0,1]×[0,2] makes X and Y uniform on their respective intervals. Since p²=X²+Y², E[p²]=E[X²]+E[Y²]=(integral from 0 to 1 of x² dx)+(1/2)(integral from 0 to 2 of y² dy)=1/3+4/3=5/3, D.

2. This asks for E[p²], not the square of E[p].

3. Teaching check: Uniformity over the rectangle gives density 1/2, so E[Y²]=(1/2)∫₀²y²dy, not simply ∫₀²y²dy. Linearity gives E[X²+Y²] without needing to integrate sqrt(X²+Y²), which would answer a different question.

Original paper, page 11

2 marks · MCQ
Report issue

Disconnected graph intersection forces a union cycle

Graph Theory

Question 81, GATE 2004: G1=(V,E1) and G2=(V,E2) are connected graphs on the same vertex set with more than two vertices. Their intersection (V,E1∩E2) is disconnected. What must be true of their union (V,E1∪E2)?
Options:
(A) It cannot have a cut vertex
(B) It must have a cycle
(C) It must have a bridge
(D) Its chromatic number exceeds those of both G1 and G2
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. The union is connected because it contains connected G1. If the union had no cycle, it would be a tree.

2. Every connected spanning subgraph of a tree must contain all tree edges: deleting any edge disconnects it. Thus both G1 and G2 would equal that tree, making their intersection connected, a contradiction.

3. Therefore the union must contain a cycle, B. This does not force a bridge or eliminate articulation vertices, and a cycle need not increase chromatic number over both constituent graphs.

4. Teaching check: A connected acyclic union would be a tree, and every tree edge is indispensable to every connected spanning subgraph. Hence both input graphs would contain all its edges, contradicting the disconnected intersection. This contradiction proves a cycle must exist.

Original paper, page 11

2 marks · MCQ
Report issue

Amortized cost of processing runs of ones

Asymptotic Analysis & Recurrences

Question 82, GATE 2004: A[1..n] stores bits. Function f(m) takes Θ(m) time for positive m, with constant bookkeeping for m=0. What is the complexity of:
counter=0;
for(i=1;i<=n;i++) {
  if(A[i]==1) counter++;
  else { f(counter); counter=0; }
}
Option D is little-o in the clearer GateForum reproduction.
Options:
(A) Ω(n²)
(B) Ω(n log n) and O(n²)
(C) Θ(n)
(D) o(n)
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The counter measures the current consecutive run of ones. A zero invokes f on that run length and then resets the counter.

2. The lengths passed to all calls sum to at most n, because no position containing one belongs to two completed runs. Thus all calls together take O(n), including O(1) bookkeeping for zero-length runs, while the loop itself always performs n iterations and costs Ω(n).

3. Total complexity is Θ(n), C. A final run without a trailing zero does not increase this bound.

4. Teaching check: Charge each unit of f’s linear work to one of the ones in its completed run. No one belongs to two runs, so total charged work is linear. The always-executed loop supplies the matching linear lower bound; little-o(n) cannot describe it.

Original paper, page 11

2 marks · MCQ
Report issue

Cost of duplicated recursive calls

Asymptotic Analysis & Recurrences

Question 83, GATE 2004: For positive integer n, find the time complexity of:
int recursive(int n) {
  if(n==1) return 1;
  else return recursive(n-1)+recursive(n-1);
}
Use the ordinary execution model without memoization; the source prose says “a>0” although the code parameter is n.
Options:
(A) O(n)
(B) O(n log n)
(C) O(n²)
(D) O(2^n)
Question 83, GATE 2004: For positive integer n, find the time complexity of:
int recursive(int n) {
  if(n==1) return 1;
  else return recursive(n-1)+recursive(n-1);
}
Use the ordinary execution model without memoization; the source prose says “a>0” although the code parameter is n.
Options:
(A) O(n)
(B) O(n log n)
(C) O(n²)
(D) O(2^n)
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. For positive integer n, each nonbase invocation makes two independent calls at n−1. With the usual unit-cost model and no memoization, T(n)=2T(n−1)+Θ(1), T(1)=Θ(1).

2. The recursion tree has 2n−1 leaves and 2n−1 total calls, yielding Θ(2n), and hence D. The identical arguments do not make the two evaluations a single call in this abstract execution model; integer overflow and compiler transformations are outside the model.

3. Teaching check: At recursion depth k there are 2k calls, until depth n−1. Adding the geometric series gives 2n−1 calls. The depth is only n, but depth alone is not total work when the recursion branches.

Original paper, page 12

2 marks · MCQ
Report issue

Solve a linear nonhomogeneous recurrence

Asymptotic Analysis & Recurrences

Question 84, GATE 2004: Solve T(1)=1 and T(n)=2T(n−1)+n for n≥2. The sign is plus in the rendered sources, despite faulty text extraction.
Options:
(A) 2^(n+1)−n−2
(B) 2^n−n
(C) 2^(n+1)−2n−2
(D) 2^n+n
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. The rendered recurrence is T(1)=1 and T(n)=2T(n−1)+n. A particular solution is −n−2, so T(n)=C·2n−n−2.

2. Using T(1)=1 gives 2C−3=1 and C=2. Therefore T(n)=2n+1−n−2, A.

3. Direct substitution gives 2[2n−(n−1)−2]+n=2n+1−n−2.

4. Teaching check: An alternative transformation is U(n)=T(n)+n+2. Then U(n)=2U(n−1), U(1)=4, so U(n)=2n+1. Subtract n+2 to recover T(n); this directly verifies the affine particular solution.

Original paper, page 12

2 marks · MCQ
Report issue

Total smaller-subtree cost in a balanced tree

Asymptotic Analysis & Recurrences

Question 85, GATE 2004: A program visits every node x of a balanced binary search tree with n leaves, computing g(x). The cost at x is min(number of leaves in x’s left subtree,number in x’s right subtree). What is worst-case total time?
Options:
(A) Θ(n)
(B) Θ(n log n)
(C) Θ(n²)
(D) Θ(n² log n)
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. In a perfect balanced tree with n leaves, the root costs n/2, the two children together cost n/2, and every internal level similarly costs n/2. There are log2 n internal levels, so this supplies a Θ(n log n) worst-case lower bound.

2. For any balanced tree, at each depth the subtrees are disjoint and the sum of their leaf counts is at most n; summing min(left leaves,right leaves) at that depth is at most n/2. Height O(log n) gives O(n log n), with traversal overhead O(n).

3. Thus worst-case Θ(n log n), B, assuming the usual balanced binary-tree model.

4. Teaching check: For n=8 in a perfect tree, the root cost is 4, the next level totals 4 and the next totals 4, giving 12 before traversal bookkeeping. Each internal level contributes n/2, and there are log2 n such levels. Counting only the root misses the repeated per-level work.

Original paper, page 12

2 marks · MCQ
Report issue

Product automaton for counts modulo three and two

Finite Automata

Question 86, GATE 2004: A DFA has six states arranged as top row t0,t1,t2 and bottom row b0,b1,b2. Initial and sole accepting state is t0. On 1, each row cycles left-to-right: t0→t1→t2→t0 and b0→b1→b2→b0. On 0, each column toggles tj↔bj. Which condition on (#1,#0) describes the accepted strings?
Options:
(A) Divisible by 3 and 2 respectively
(B) Odd and even respectively
(C) Even and odd respectively
(D) Divisible by 2 and 3 respectively
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Label each of the three columns by the count of ones modulo 3, from left to right 0,1,2; label upper and lower rows by the count of zeros modulo 2, 0 and 1. Each 1 edge advances one column cyclically without changing row, and each 0 edge toggles the row without changing column.

2. The initial upper-left state is the only accepting state. Hence acceptance requires #1≡0 mod3 and #0≡0 mod2, option A, including the empty string.

3. Teaching check: The two counters are independent: reading 1 changes the column but not the row, and reading 0 changes the row but not the column. Returning to t0 requires both modular counts to return to zero. The empty word is accepted because the start state is accepting.

Original paper, page 12

2 marks · MCQ
Report issue

Classify a language with additive block counts

Context-Free Grammars & Languages

Question 87, GATE 2004: Classify L={a^m b^n c^(m+n):m,n≥1}.
Options:
(A) Regular
(B) Context-free but not regular
(C) Context-sensitive but not context-free
(D) Type-0 but not context-sensitive
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. For L={am bn cm+n:m,n≥1}, a context-free grammar is S→aSc | aTc and T→bTc | bc. The outer recursion supplies matching a/c pairs and the inner recursion matching b/c pairs, so it generates exactly L.

2. It is not regular: for a putative pumping length p, use ap b cp+1. Any pumpable segment within the first p symbols consists only of a characters; pumping changes the a count without changing the c count, violating the defining equality.

3. Therefore context-free but not regular, B.

4. Teaching check: A pushdown automaton can push one marker for each a and b, then pop one for each c, while tracking the required block order and nonempty a,b blocks. A finite automaton cannot maintain the unbounded count equality; the pumping argument makes this limitation rigorous.

Original paper, page 12

2 marks · MCQ
Report issue

Right-linear grammar counts a modulo three

Regular Expressions & Languages

Question 88, GATE 2004: Grammar G has S→bS | aA | b; A→bA | aB; B→bB | aS | a. Na(w),Nb(w) count a,b symbols. Which describes L(G) within {a,b}^+ (nonempty words)?
Options:
(A) {w:Na(w)>3Nb(w)}
(B) {w:Nb(w)>3Na(w)}
(C) {w:Na(w)=3k, k∈{0,1,2,…}}
(D) {w:Nb(w)=3k, k∈{0,1,2,…}}
Question 88, GATE 2004: Grammar G has S→bS | aA | b; A→bA | aB; B→bB | aS | a. Na(w),Nb(w) count a,b symbols. Which describes L(G) within {a,b}^+ (nonempty words)?
Options:
(A) {w:Na(w)>3Nb(w)}
(B) {w:Nb(w)>3Na(w)}
(C) {w:Na(w)=3k, k∈{0,1,2,…}}
(D) {w:Nb(w)=3k, k∈{0,1,2,…}}
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Interpret S,A,B as states tracking the number of a symbols modulo 3: a advances S→A→B→S, while b leaves the state unchanged. Terminating production S→b ends with residue 0, and B→a also ends with residue 0.

2. Consequently every generated word has #a divisible by 3. Conversely any nonempty word with that property can be scanned along these transitions; if its last symbol is b it terminates via S→b, and if its last symbol is a it terminates via B→a.

3. Thus L={w in {a,b}^+ : #a(w)≡0 mod3}, option C in the stated positive-word universe.

4. Teaching check: There is no ε production, so the empty word is excluded despite having zero a symbols. The problem explicitly uses {a,b}^+, which resolves that apparent exception. Each a advances one of three residue states while any b preserves it.

Original paper, page 12

2 marks · MCQ
Report issue

Decidability of an enumeration-order language

Decidability & Computability

Question 89, GATE 2004: L1 is recursively enumerable over Σ. Algorithm A enumerates its words as w1,w2,w3,… . Let #∉Σ and L2={wi#wj:wi,wj∈L1 and i<j}. Consider S1: if L1 is recursive then L2 is recursive; S2: if L2 is recursive then L1 is recursive. Which is true? The reproduction does not state whether enumeration can repeat words; keep that distinction explicit.
Options:
(A) Both S1 and S2
(B) S1, but S2 need not be true
(C) S2, but S1 need not be true
(D) Neither need be true
Tap to enlarge
Your answer
Answer & solution

Answer: None (no official key was published)

1. Under repetition-free enumeration, both S1 and S2 hold (A). For S1, first decide membership of both components in recursive L1; if either is absent reject, otherwise run A until both appear and compare their unique indices.

2. For S2, if L1 is empty it is recursive. Otherwise fix its first enumerated word w1.

3. Decide whether x is in L1 by accepting x=w1 and otherwise asking the L2 decider whether w1#x belongs. Every other word appears later, so this is correct.

4. The S2 argument also survives repetitions. However, if arbitrary repetitions are permitted, S1 can fail: let recursive L1 consist of all distinct tags ae and be.

5. Enumerate each be before its ae, and repeat be after ae exactly if machine e halts, using dovetailing. Then ae#be belongs to L2 exactly for halting machines, making L2 nonrecursive despite recursive L1.

6. Thus with repetitions allowed only S2 is necessarily true (C). No unconditional option is assigned without fixing the enumeration convention.

7. Teaching check: The relation depends on enumeration positions, not a lexicographic order on words. If words repeat, one pair may have witnesses in both directions. That is why a proof using unique indices needs an explicit repetition-free convention instead of being applied automatically.

Original paper, page 12

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Match programming paradigms to descriptions

Other Computing Topics

Question 90, GATE 2004: Match styles P=functional, Q=logic, R=object-oriented, S=imperative with characteristics: (1) command-based, procedural; (2) imperative, abstract data types; (3) side-effect-free, declarative, expression evaluation; (4) declarative, clausal representation, theorem proving.
Options:
(A) P-2,Q-3,R-4,S-1
(B) P-4,Q-3,R-2,S-1
(C) P-3,Q-4,R-1,S-2
(D) P-3,Q-4,R-2,S-1
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. Functional programming matches side-effect-free declarative expression evaluation (P→3). Logic programming matches declarative clauses and theorem proving (Q→4).

2. In this classification object-oriented programming matches imperative programming with abstract data types (R→2), while imperative programming matches command-based procedural computation (S→1). Thus P-3,Q-4,R-2,S-1 is D.

3. These are textbook paradigm characterizations, not claims that every language implementing a paradigm has only those features.

4. Teaching check: Match the most diagnostic feature first: theorem proving belongs to logic, and expression evaluation without side effects to functional programming. Those two matches fix P and Q, leaving abstract-data-type encapsulation for object orientation and procedural commands for imperative programming.

Original paper, page 12