"From where are they bringing their books? ________ bringing _______ books from _____."
The words that best fill the blanks in the above sentence are
- (A)Their, they're, there
- (B)They're, their, there
- (C)There, their, they're
- (D)They're, there, there
The first blank needs a subject and verb: "They're" (they are) bringing. The second blank needs a possessive before "books": "their". The third blank needs a place, answering "from where": "there". So the sentence reads "They're bringing their books from there." Answer: (B).
Concept: Tests the homophones they're / their / there: contraction of "they are", possessive pronoun, and adverb of place. The trap is choosing by sound; read each blank for its grammatical role.
"A _________ investigation can sometimes yield new facts, but typically organized ones are more successful."
The word that best fills the blank in the above sentence is
- (A)meandering
- (B)timely
- (C)consistent
- (D)systematic
The word "but" sets up a contrast with "organized" investigations. The blank therefore needs a word meaning the opposite of organized: "meandering" (wandering, without a fixed course). "Systematic" and "consistent" mean organized, and "timely" is unrelated to the contrast. Answer: (A).
Concept: Vocabulary in context with a contrast signal. "But" means the blank opposes "organized". The trap is picking "systematic" because it sounds like a positive word for an investigation.
The area of a square is d. What is the area of the circle which has the diagonal of the square as its diameter?
- (A)πd
- (B)πd²
- (C)(1/4)πd²
- (D)(1/2)πd
Side of the square = √d, so the diagonal = √2 · √d = √(2d). This is the circle's diameter, so the radius r = √(2d)/2 and r² = 2d/4 = d/2. Area of the circle = πr² = πd/2. Answer: (D) (1/2)πd.
Concept: Square diagonal = side × √2, and circle area uses the radius, not the diameter. The usual trap is using the diagonal as the radius (giving 2πd) or squaring d itself, which is already an area.
What would be the smallest natural number which when divided either by 20 or by 42 or by 76 leaves a remainder of 7 in each case?
- (A)3047
- (B)6047
- (C)7987
- (D)63847
The number is LCM(20, 42, 76) + 7. 20 = 2² · 5, 42 = 2 · 3 · 7, 76 = 2² · 19. LCM = 2² · 3 · 5 · 7 · 19 = 7980. Smallest number = 7980 + 7 = 7987. Check: 7987 = 20 × 399 + 7 = 42 × 190 + 7 = 76 × 105 + 7. Answer: (C) 7987.
Concept: Same remainder for several divisors means number = k × LCM + remainder; the smallest is LCM + remainder. The trap is multiplying the divisors instead of taking the LCM, which overshoots.
What is the missing number in the following sequence?
2, 12, 60, 240, 720, 1440, _____, 0
- (A)2880
- (B)1440
- (C)720
- (D)0
Successive ratios: 12/2 = 6, 60/12 = 5, 240/60 = 4, 720/240 = 3, 1440/720 = 2. The next multiplier is 1, so the missing term is 1440 × 1 = 1440, and then 1440 × 0 = 0, which matches the last term. Answer: (B) 1440.
Concept: A multiplicative series with a decreasing multiplier 6, 5, 4, 3, 2, 1, 0. The final 0 confirms the pattern. The trap is assuming the terms keep growing and picking 2880.
In appreciation of the social improvements completed in a town, a wealthy philanthropist decided to gift Rs 750 to each male senior citizen in the town and Rs 1000 to each female senior citizen. Altogether, there were 300 senior citizens eligible for this gift. However, only 8/9th of the eligible men and 2/3rd of the eligible women claimed the gift. How much money (in Rupees) did the philanthropist give away in total?
- (A)1,50,000
- (B)2,00,000
- (C)1,75,000
- (D)1,51,000
Let m men and w women be eligible, m + w = 300. Money given = 750 × (8/9)m + 1000 × (2/3)w = (2000/3)m + (2000/3)w = (2000/3)(m + w) = (2000/3) × 300 = 2,00,000. The split between men and women does not matter. Answer: (B) 2,00,000.
Concept: The per-person effective amounts happen to be equal (750 × 8/9 = 1000 × 2/3), so the total depends only on m + w. The trap is thinking the problem is unsolvable without knowing m and w separately.
If pqr ≠ 0 and p⁻ˣ = 1/q, q⁻ʸ = 1/r, r⁻ᶻ = 1/p, what is the value of the product xyz?
- (A)-1
- (B)1/(pqr)
- (C)1
- (D)pqr
p⁻ˣ = 1/q gives pˣ = q. Similarly qʸ = r and rᶻ = p. Substitute: p = rᶻ = (qʸ)ᶻ = q^(yz) = (pˣ)^(yz) = p^(xyz). So p^(xyz) = p¹, giving xyz = 1. Answer: (C) 1.
Concept: Chained exponent substitution: rewrite each relation without negatives and substitute back to the starting base. The trap is getting lost in the reciprocals and choosing -1 or 1/(pqr).
In a party, 60% of the invited guests are male and 40% are female. If 80% of the invited guests attended the party and if all the invited female guests attended, what would be the ratio of males to females among the attendees in the party?
- (A)2:3
- (B)1:1
- (C)3:2
- (D)2:1
Take 100 invited guests: 60 male, 40 female. Attendees = 80. All 40 females attended, so males attending = 80 - 40 = 40. Ratio of males to females = 40 : 40 = 1 : 1. Answer: (B) 1:1.
Concept: Assume a convenient total (100) for percentage problems. The trap is applying 80% to males alone (48 males, ratio 6:5) instead of to all guests.
In the figure below, ∠DEC + ∠BFC is equal to ____________ .
(Figure, described: E, D and A lie on one straight line, with D between E and A. A, B and F lie on a second straight line, with B between A and F. Segment EB meets segment DF at C, so E, C, B are collinear and D, C, F are collinear. ABCD is a quadrilateral.)
- (A)∠BCD - ∠BAD
- (B)∠BAD + ∠BCF
- (C)∠BAD + ∠BCD
- (D)∠CBA + ∠ADC
Triangle EAB: ∠DEC = 180° - ∠BAD - ∠ABC. Triangle FAD: ∠BFC = 180° - ∠BAD - ∠ADC. Adding: ∠DEC + ∠BFC = 360° - 2∠BAD - (∠ABC + ∠ADC). In quadrilateral ABCD, ∠ABC + ∠ADC = 360° - ∠BAD - ∠BCD. Substituting: ∠DEC + ∠BFC = 360° - 2∠BAD - 360° + ∠BAD + ∠BCD = ∠BCD - ∠BAD. Answer: (A).
Concept: Angle sums in overlapping triangles combined with the quadrilateral angle sum of 360°. The trap is adding instead of subtracting ∠BAD, since it appears in both triangles and once in the quadrilateral.
A six sided unbiased die with four green faces and two red faces is rolled seven times. Which of the following combinations is the most likely outcome of the experiment?
- (A)Three green faces and four red faces.
- (B)Four green faces and three red faces.
- (C)Five green faces and two red faces.
- (D)Six green faces and one red face.
P(green) = 2/3, P(red) = 1/3. P(k green in 7) = C(7,k)(2/3)^k(1/3)^(7-k), proportional to C(7,k) · 2^k. k=3: 35 × 8 = 280. k=4: 35 × 16 = 560. k=5: 21 × 32 = 672. k=6: 7 × 64 = 448. The largest is k = 5. Answer: (C) Five green faces and two red faces.
Concept: Binomial mode: compare C(n,k)p^k q^(n-k) across k (mode is near (n+1)p = 5.33, so k = 5). The trap is picking six green because green is more likely per roll, ignoring the C(7,k) factor.
Which one of the following is a closed form expression for the generating function of the sequence {aₙ}, where aₙ = 2n + 3 for all n = 0, 1, 2, ... ?
- (A)3/(1 - x)²
- (B)3x/(1 - x)²
- (C)(2 - x)/(1 - x)²
- (D)(3 - x)/(1 - x)²
Σ aₙxⁿ = 2 Σ n xⁿ + 3 Σ xⁿ. Known forms: Σ xⁿ = 1/(1 - x), Σ n xⁿ = x/(1 - x)². So G(x) = 2x/(1 - x)² + 3/(1 - x) = [2x + 3(1 - x)]/(1 - x)² = (3 - x)/(1 - x)². Check: at x = 0 this gives 3 = a₀. Answer: (D).
Concept: Uses the standard generating functions for 1 and n and linearity. A quick check is G(0) = a₀ = 3, which eliminates (B) and (C). The trap is forgetting to bring 3/(1 - x) to the common denominator.
Consider the following C program.
The output of this program is:
#include<stdio.h>
struct Ournode{
char x,y,z;
};
int main(){
struct Ournode p = {'1', '0', 'a'+2};
struct Ournode *q = &p;
printf ("%c, %c", *((char*)q+1), *((char*)q+2));
return 0;
}- (A)0, c
- (B)0, a+2
- (C)'0', 'a+2'
- (D)'0', 'c'
The struct holds three chars x = '1', y = '0', z = 'a' + 2 = 'c'. Chars have no padding between them, so (char*)q points at x, (char*)q + 1 at y and (char*)q + 2 at z. %c prints the character itself without quotes: 0 and c. Output: 0, c. Answer: (A).
Concept: Casting a struct pointer to char* and doing byte arithmetic; 'a'+2 is evaluated as the character 'c'. Traps: thinking %c prints quotes, or that 'a'+2 is stored as text.
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let enqueue be implemented by inserting a new node at the head, and dequeue be implemented by deletion of a node from the tail.
(Figure: head points to the first node; each node points to the next; tail points to the last node, whose next pointer is NULL.)
Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?
- (A)θ(1), θ(1)
- (B)θ(1), θ(n)
- (C)θ(n), θ(1)
- (D)θ(n), θ(n)
Enqueue at the head: create a node, point its next to the old head, update head. θ(1). Dequeue at the tail: the last node must be removed and tail moved to its predecessor, but a singly linked list has no back pointer, so we must walk from head to the second-last node. θ(n). Answer: (B) θ(1), θ(n).
Concept: Deleting from the end of a singly linked list needs the predecessor, which costs a traversal even with a tail pointer. The trap is assuming the tail pointer alone makes deletion O(1); it only makes insertion at the tail O(1).
Let ⊕ and ⊙ denote the Exclusive OR and Exclusive NOR operations, respectively. Which one of the following is NOT CORRECT?
- (A)¬(P ⊕ Q) = P ⊙ Q
- (B)P̄ ⊕ Q = P ⊙ Q
- (C)P̄ ⊕ Q̄ = P ⊕ Q
- (D)(P ⊕ P̄) ⊕ Q = (P ⊙ P̄) ⊙ Q̄
(A) XNOR is the complement of XOR: correct. (B) Complementing one input of XOR complements the output: P̄ ⊕ Q = ¬(P ⊕ Q) = P ⊙ Q: correct. (C) Complementing both inputs leaves XOR unchanged: correct. (D) Left: P ⊕ P̄ = 1, and 1 ⊕ Q = Q̄. Right: P ⊙ P̄ = 0, and 0 ⊙ Q̄ = ¬(0 ⊕ Q̄) = ¬Q̄ = Q. Q̄ ≠ Q, so (D) is NOT correct. Answer: (D).
Concept: XOR/XNOR identities: x ⊕ 1 = x̄, x ⊙ 0 = x̄, and complementing one input flips the result. The trap is mis-evaluating 0 ⊙ Q̄; XNOR with 0 inverts its other input.
Consider the following processor design characteristics.
I. Register-to-register arithmetic operations only
II. Fixed-length instruction format
III. Hardwired control unit
Which of the characteristics above are used in the design of a RISC processor?
- (A)I and II only
- (B)II and III only
- (C)I and III only
- (D)I, II and III
RISC uses a load-store architecture, so arithmetic operates only on registers (I). Instructions have a fixed length to simplify fetch, decode and pipelining (II). The small, simple instruction set allows a fast hardwired control unit instead of microprogramming (III). All three are RISC characteristics. Answer: (D) I, II and III.
Concept: RISC traits: load-store, fixed-length simple instructions, hardwired control, many registers, pipelining. Microprogrammed control and variable-length formats are CISC traits. The trap is thinking hardwired control is optional for RISC.
Let N be an NFA with n states. Let k be the number of states of a minimal DFA which is equivalent to N. Which one of the following is necessarily true?
- (A)k ≥ 2ⁿ
- (B)k ≥ n
- (C)k ≤ n²
- (D)k ≤ 2ⁿ
The subset construction turns an n-state NFA into a DFA whose states are subsets of the NFA's states, at most 2ⁿ of them. The minimal DFA can be no larger than this DFA, so k ≤ 2ⁿ always. k can be much smaller than n (an NFA can have redundant states), so (A) and (B) fail, and some languages need exactly 2ⁿ states, so (C) fails. Answer: (D) k ≤ 2ⁿ.
Concept: Subset construction gives the 2ⁿ upper bound; there is no lower bound in terms of n because the NFA itself may be non-minimal. The trap is reading the exponential blow-up as always happening (k ≥ 2ⁿ).
The set of all recursively enumerable languages is
- (A)closed under complementation.
- (B)closed under intersection.
- (C)a subset of the set of all recursive languages.
- (D)an uncountable set.
(A) False: the complement of the halting language is not RE. (B) True: run the two recognizing TMs in parallel (or one after the other) and accept when both accept. (C) False: recursive languages are a subset of RE, not the other way round. (D) False: each RE language has a Turing machine, and TMs can be encoded as finite strings, so there are only countably many. Answer: (B).
Concept: RE languages are closed under union and intersection but not complement. The number of TMs is countable, so RE is countable. The trap is reversing the subset relation between recursive and RE.
Which one of the following statements is FALSE?
- (A)Context-free grammar can be used to specify both lexical and syntax rules.
- (B)Type checking is done before parsing.
- (C)High-level language programs can be translated to different Intermediate Representations.
- (D)Arguments to a function can be passed using the program stack.
(A) True: lexical rules are regular, and every regular language is context-free. (B) False: type checking is part of semantic analysis, which works on the parse tree produced by the parser, so it is done after parsing. (C) True: three-address code, syntax trees, SSA and so on. (D) True: activation records on the stack commonly hold arguments. Answer: (B).
Concept: Compiler phase order: lexical analysis, parsing, semantic analysis (type checking), IR generation. The trap is option (A); CFGs can describe tokens because regular is a subset of context-free, even though lexers use regular expressions in practice.
The following are some events that occur after a device controller issues an interrupt while process L is under execution.
(P) The processor pushes the process status of L onto the control stack.
(Q) The processor finishes the execution of the current instruction.
(R) The processor executes the interrupt service routine.
(S) The processor pops the process status of L from the control stack.
(T) The processor loads the new PC value based on the interrupt.
Which one of the following is the correct order in which the events above occur?
- (A)QPTRS
- (B)PTRSQ
- (C)TRPQS
- (D)QTPRS
Interrupts are checked at instruction boundaries, so the current instruction finishes first (Q). The state of L is saved on the stack (P) before the PC is overwritten with the ISR address (T). The ISR runs (R), and on return the saved status is popped (S). Order: Q P T R S. Answer: (A).
Concept: Interrupt handling sequence: complete instruction, save context, vector to ISR, run ISR, restore context. The trap is (D), loading the new PC before saving the old state, which would lose L's return address.
Consider a process executing on an operating system that uses demand paging. The average time for a memory access in the system is M units if the corresponding memory page is available in memory, and D units if the memory access causes a page fault. It has been experimentally measured that the average time taken for a memory access in the process is X units.
Which one of the following is the correct expression for the page fault rate experienced by the process?
- (A)(D - M) / (X - M)
- (B)(X - M) / (D - M)
- (C)(D - X) / (D - M)
- (D)(X - M) / (D - X)
Let p be the page fault rate. Effective access time X = (1 - p)M + pD = M + p(D - M). Solving, p = (X - M)/(D - M). Sanity check: X = M gives p = 0 and X = D gives p = 1. Answer: (B).
Concept: Effective memory access time is a weighted average of hit and fault times. The trap is inverting the fraction; checking the limits p = 0 and p = 1 catches it immediately.
In an Entity-Relationship (ER) model, suppose R is a many-to-one relationship from entity set E1 to entity set E2. Assume that E1 and E2 participate totally in R and that the cardinality of E1 is greater than the cardinality of E2.
Which one of the following is true about R?
- (A)Every entity in E1 is associated with exactly one entity in E2.
- (B)Some entity in E1 is associated with more than one entity in E2.
- (C)Every entity in E2 is associated with exactly one entity in E1.
- (D)Every entity in E2 is associated with at most one entity in E1.
Many-to-one from E1 to E2 means each E1 entity relates to at most one E2 entity; total participation of E1 makes it at least one, so exactly one (A true, B false). Since |E1| > |E2| and every E1 entity maps into E2, by pigeonhole some E2 entity is associated with more than one E1 entity, so (C) and (D) are false. Answer: (A).
Concept: Combining mapping cardinality (at most one) with total participation (at least one) gives exactly one. The trap is reading "many-to-one" backwards and picking (B).
Consider the following two tables and four queries in SQL.
Book (isbn, bname), Stock (isbn, copies) (isbn is the primary key of each table)
Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
Query 1: SELECT B.isbn, S.copies
FROM Book B INNER JOIN Stock S
ON B.isbn = S.isbn;
Query 2: SELECT B.isbn, S.copies
FROM Book B LEFT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 3: SELECT B.isbn, S.copies
FROM Book B RIGHT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 4: SELECT B.isbn, S.copies
FROM Book B FULL OUTER JOIN Stock S
ON B.isbn = S.isbn;- (A)Query 1
- (B)Query 2
- (C)Query 3
- (D)Query 4
The inner join returns the matching rows. The left outer join adds Book rows with no match (copies NULL); the right outer join adds Stock rows with no match (B.isbn NULL). The full outer join contains the matching rows plus both sets of unmatched rows, so it always contains the output of each of the other three. Answer: (D) Query 4.
Concept: FULL OUTER JOIN = INNER JOIN rows plus unmatched rows from both sides, so it is a superset of LEFT, RIGHT and INNER joins. The trap is choosing LEFT or RIGHT, which each miss the other side's unmatched rows.
Match the following:
Field Length in bits
P. UDP Header's Port Number I. 48
Q. Ethernet MAC Address II. 8
R. IPv6 Next Header III. 32
S. TCP Header's Sequence Number IV. 16
- (A)P-III, Q-IV, R-II, S-I
- (B)P-II, Q-I, R-IV, S-III
- (C)P-IV, Q-I, R-II, S-III
- (D)P-IV, Q-I, R-III, S-II
UDP port numbers are 16 bits (P-IV). An Ethernet MAC address is 48 bits (Q-I). The IPv6 Next Header field is 8 bits (R-II). The TCP sequence number is 32 bits (S-III). Answer: (C) P-IV, Q-I, R-II, S-III.
Concept: Recall of standard header field sizes. Ports are 16 bits (0 to 65535), MAC 48, TCP sequence 32, IPv6 Next Header 8 (it plays the role of IPv4's Protocol field). The trap is confusing the 8-bit Next Header with the 32-bit sequence number.
Consider the following statements regarding the slow start phase of the TCP congestion control algorithm. Note that cwnd stands for the TCP congestion window and MSS denotes the Maximum Segment Size.
(i) The cwnd increases by 2 MSS on every successful acknowledgment.
(ii) The cwnd approximately doubles on every successful acknowledgement.
(iii) The cwnd increases by 1 MSS every round trip time.
(iv) The cwnd approximately doubles every round trip time.
Which one of the following is correct?
- (A)Only (ii) and (iii) are true
- (B)Only (i) and (iii) are true
- (C)Only (iv) is true
- (D)Only (i) and (iv) are true
In slow start, cwnd grows by 1 MSS for every ACK received, so (i) and (ii) are false. If cwnd is W segments, one RTT brings about W ACKs and adds W MSS, so cwnd roughly doubles each RTT: (iv) true. Growth of 1 MSS per RTT is congestion avoidance (additive increase), not slow start, so (iii) is false. Answer: (C) Only (iv) is true.
Concept: Slow start is exponential per RTT (+1 MSS per ACK); congestion avoidance is linear (+1 MSS per RTT). The trap is mixing the per-ACK and per-RTT descriptions of the two phases.
Two people, P and Q, decide to independently roll two identical dice, each with 6 faces, numbered 1 to 6. The person with the lower number wins. In case of a tie, they roll the dice repeatedly until there is no tie. Define a trial as a throw of the dice by P and Q. Assume that all 6 numbers on each dice are equi-probable and that all trials are independent. The probability (rounded to 3 decimal places) that one of them wins on the third trial is _____.
A trial is a tie when both show the same number: P(tie) = 6/36 = 1/6, so P(someone wins) = 5/6. Winning on the third trial needs ties on trials 1 and 2 and no tie on trial 3: (1/6)(1/6)(5/6) = 5/216 ≈ 0.0231. Answer: 0.023 (accepted range 0.021 to 0.024).
Concept: A geometric distribution: first success on trial k has probability (1 - p)^(k-1) p with p = 5/6. The trap is computing the probability that a particular person (say P) wins, which would halve the answer.
The value of ∫₀^(π/4) x cos(x²) dx correct to three decimal places (assuming that π = 3.14) is _____.
Substitute u = x², du = 2x dx. The limits become 0 to (π/4)² = π²/16. Integral = (1/2)∫₀^(π²/16) cos u du = (1/2) sin(π²/16). With π = 3.14: π² = 9.8596, π²/16 = 0.61623 rad, sin(0.61623) ≈ 0.5780. Value ≈ 0.289. Answer: 0.289 (accepted range 0.27 to 0.30).
Concept: Simple substitution; the derivative of x² appears in the integrand. Traps: forgetting to change the upper limit to (π/4)², and evaluating the sine in degrees instead of radians.
Consider a matrix A = uvᵀ where u = [1, 2]ᵀ (column vector) and v = [1, 1]ᵀ (column vector). Note that vᵀ denotes the transpose of v. The largest eigenvalue of A is _____.
A = uvᵀ = [[1, 1], [2, 2]]. It has rank 1, so one eigenvalue is 0. The other equals the trace, 1 + 2 = 3 (equivalently vᵀu = 1 + 2 = 3, since A u = u(vᵀu) = 3u). Eigenvalues are 0 and 3. Answer: 3.
Concept: An outer product uvᵀ has rank 1; its only nonzero eigenvalue is vᵀu with eigenvector u. The trap is confusing uvᵀ (a 2×2 matrix) with vᵀu (a scalar) when forming A.
The chromatic number of the following graph is _______.
(Graph, described: vertices a, b, c, d, e, f. Edges: a-b, a-c, a-e, b-c, b-d, b-f, c-d, c-e, d-f, e-f.)
a, b, c form a triangle (a-b, b-c, a-c), so at least 3 colours are needed. A 3-colouring exists: a = 1, b = 2, c = 3; e (adjacent to a, c) = 2; d (adjacent to b, c) = 1; f (adjacent to b, d, e, which use 2, 1, 2) = 3. Every edge joins different colours. Chromatic number = 3.
Concept: Lower bound from a clique (here a triangle), upper bound from an explicit colouring. The trap is stopping at the lower bound without checking that 3 colours suffice, or assuming 4 because the graph looks dense.
Let G be a finite group on 84 elements. The size of a largest possible proper subgroup of G is ________.
By Lagrange's theorem the order of a subgroup divides 84. The proper divisors of 84 are 1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, and the largest is 42. It is attained, for example the cyclic group Z₈₄ has a subgroup of order 42 (generated by 2). Answer: 42.
Concept: Lagrange's theorem limits subgroup orders to divisors of the group order; a proper subgroup excludes the whole group. The trap is answering 84 (not proper) or thinking the bound may not be reachable.
The postorder traversal of a binary tree is 8,9,6,7,4,5,2,3,1. The inorder traversal of the same tree is 8,6,9,4,7,2,5,1,3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is ______.
The last postorder element, 1, is the root. Inorder splits into left {8,6,9,4,7,2,5} and right {3}. In the left part the postorder ends with 2, so 2 is its root, with left {8,6,9,4,7} and right {5}. Next root is 4, with left {8,6,9} and right {7}. Then 6 is the root of {8,6,9}, with children 8 and 9. Longest path: 1-2-4-6-8, which has 4 edges. Answer: 4.
Concept: Rebuild the tree recursively: postorder gives the root (last element), inorder splits left and right subtrees. The trap is counting nodes (5) instead of edges, since height here is a path length.
Consider the following C program:
The output of this program is _____.
#include <stdio.h>
int counter = 0;
int calc (int a, int b) {
int c;
counter++;
if (b==3) return (a*a*a);
else {
c = calc(a, b/3);
return (c*c*c);
}
}
int main (){
calc(4, 81);
printf ("%d", counter);
}Each call increments counter once. Calls: calc(4, 81) calls calc(4, 27), which calls calc(4, 9), which calls calc(4, 3); that one hits b == 3 and returns. That is 4 calls in total, so counter = 4 and the program prints 4. (The returned value overflows int, but it is never printed.) Answer: 4.
Concept: Count recursive calls, not the computed value: b goes 81, 27, 9, 3. The trap is getting distracted by the cube computations or stopping the count before the base-case call.
Consider the sequential circuit shown in the figure, where both flip-flops used are positive edge-triggered D flip-flops.
(Figure, described: input "in" drives D of the first flip-flop; Q of the first flip-flop drives D of the second flip-flop; Q of the second flip-flop is "out". Both flip-flops share the same clock.)
The number of states in the state transition diagram of this circuit that have a transition back to the same state on some value of "in" is _____.
This is a 2-bit shift register. State (Q1, Q2); on a clock edge the next state is (in, Q1). A self-loop needs (in, Q1) = (Q1, Q2), that is Q1 = Q2 and in = Q1. State 00 stays 00 on in = 0, state 11 stays 11 on in = 1. State 01 goes to 00 or 10, and 10 goes to 01 or 11, never itself. So 2 states have a self-loop. Answer: 2.
Concept: Derive next-state equations from the D inputs and check which states can map to themselves. The trap is assuming every state can hold its value, as with an enable-controlled register.
A 32-bit wide main memory unit with a capacity of 1 GB is built using 256M × 4-bit DRAM chips. The number of rows of memory cells in the DRAM chip is 2¹⁴. The time taken to perform one refresh operation is 50 nanoseconds. The refresh period is 2 milliseconds. The percentage (rounded to the closest integer) of the time available for performing the memory read/write operations in the main memory unit is __________.
Each chip is 256M × 4 bits = 128 MB, so 1 GB needs 8 chips, and a 32-bit word needs 32/4 = 8 chips side by side: all 8 form one bank and are refreshed in parallel. Refreshing all 2¹⁴ rows takes 16384 × 50 ns = 819.2 µs in every 2 ms. Fraction spent refreshing = 0.8192/2 = 40.96%. Available = 59.04%, about 59. Answer: 59 (accepted range 59 to 60).
Concept: Refresh overhead = rows × refresh time / refresh period, with chips in a bank refreshed together. The trap is multiplying by the number of chips, as though they refreshed one after another.
Consider a system with 3 processes that share 4 instances of the same resource type. Each process can request a maximum of K instances. Resource instances can be requested and released only one at a time. The largest value of K that will always avoid deadlock is ____.
The worst case is every process holding K - 1 instances and waiting for one more. Deadlock is impossible if even then one instance is free: 3(K - 1) + 1 ≤ 4, so K ≤ 2. With K = 3, two processes could hold 2 each, leaving 0 free, and both wait forever. Answer: 2.
Concept: For n processes each needing at most K of R instances, deadlock freedom needs n(K - 1) + 1 ≤ R. The trap is using n × K ≤ R, which is sufficient but far too strict.
Consider a long-lived TCP session with an end-to-end bandwidth of 1 Gbps (= 10⁹ bits-per-second). The session starts with a sequence number of 1234. The minimum time (in seconds, rounded to the closest integer) before this sequence number can be used again is _______.
TCP numbers bytes with a 32-bit sequence number, so 2³² bytes are sent before a number repeats. At 10⁹ bits/s = 1.25 × 10⁸ bytes/s, the wrap-around time = 2³² / 1.25 × 10⁸ = 4294967296 / 125000000 ≈ 34.36 s. Answer: 34 (accepted range 34 to 35).
Concept: Sequence-number wrap-around time = 2³² bytes / bandwidth in bytes per second. The trap is forgetting that sequence numbers count bytes, not bits (which gives about 4.3 s).
Consider a matrix P whose only eigenvectors are the multiples of [1, 4]ᵀ.
Consider the following statements.
(I) P does not have an inverse
(II) P has a repeated eigenvalue
(III) P cannot be diagonalized
Which one of the following options is correct?
- (A)Only I and III are necessarily true
- (B)Only II is necessarily true
- (C)Only I and II are necessarily true
- (D)Only II and III are necessarily true
P is 2×2 with only one independent eigenvector. Two distinct eigenvalues would give two independent eigenvectors, so the eigenvalue is repeated (II true). Diagonalization needs 2 independent eigenvectors, so P cannot be diagonalized (III true). Invertibility depends on whether the repeated eigenvalue is 0. With N = [[4, -1], [16, -4]] (N² = 0, only eigenvectors multiples of [1, 4]ᵀ), P = N is singular but P = 2I + N is invertible, and both satisfy the condition, so (I) is not necessarily true. Answer: (D).
Concept: Geometric multiplicity 1 in a 2×2 matrix forces algebraic multiplicity 2 and a defective (non-diagonalizable) matrix. The trap is assuming singularity; a matrix is singular only if 0 is an eigenvalue.
Let N be the set of natural numbers. Consider the following sets.
P: Set of Rational numbers (positive and negative)
Q: Set of functions from {0, 1} to N
R: Set of functions from N to {0, 1}
S: Set of finite subsets of N.
Which of the sets above are countable?
- (A)Q and S only
- (B)P and S only
- (C)P and R only
- (D)P, Q and S only
P: rationals are countable (enumerate p/q by |p| + q). Q: a function from {0, 1} to N is a pair (f(0), f(1)), so Q is in bijection with N × N, which is countable. R: functions N → {0, 1} correspond to subsets of N (characteristic functions), i.e. the power set of N, which is uncountable by Cantor's diagonal argument. S: finite subsets of N can be listed by size and largest element (a countable union of finite sets), so countable. Answer: (D) P, Q and S only.
Concept: Finite products and countable unions of countable sets are countable; the power set of N (or infinite binary sequences) is not. The trap is confusing functions from {0, 1} to N with functions from N to {0, 1}.
Consider the first-order logic sentence
φ ≡ ∃s∃t∃u∀v∀w∀x∀y ψ(s, t, u, v, w, x, y)
where ψ(s, t, u, v, w, x, y) is a quantifier-free first-order logic formula using only predicate symbols, and possibly equality, but no function symbols. Suppose φ has a model with a universe containing 7 elements.
Which one of the following statements is necessarily true?
- (A)There exists at least one model of φ with universe of size less than or equal to 3.
- (B)There exists no model of φ with universe of size less than or equal to 3.
- (C)There exists no model of φ with universe of size greater than 7.
- (D)Every model of φ has a universe of size equal to 7.
In the 7-element model pick witnesses a, b, c for s, t, u. Restrict the model to the universe {a, b, c} (at most 3 elements), keeping the predicates' truth values on these elements. With no function symbols this restriction is a valid structure. ψ(a, b, c, v, w, x, y) held for all v, w, x, y in the large universe, so it holds in particular for all choices from {a, b, c}, since ψ is quantifier-free and its truth depends only on the chosen elements. Hence the restriction is a model of φ of size at most 3. Answer: (A).
Concept: Universal sentences are preserved under substructures, and an ∃³∀* sentence (Bernays-Schönfinkel class) has a model of size at most the number of existential variables. Options (B), (C), (D) cannot be guaranteed. The trap is thinking the 7-element model fixes the size.
Consider the following C program:
The output of the program above is
#include<stdio.h>
void fun1(char *s1, char *s2){
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
void fun2(char **s1, char **s2){
char *tmp;
tmp = *s1;
*s1 = *s2;
*s2 = tmp;
}
int main(){
char *str1 = "Hi", *str2 = "Bye";
fun1(str1, str2); printf("%s %s ", str1, str2);
fun2(&str1, &str2); printf("%s %s", str1, str2);
return 0;
}- (A)Hi Bye Bye Hi
- (B)Hi Bye Hi Bye
- (C)Bye Hi Hi Bye
- (D)Bye Hi Bye Hi
fun1 receives copies of the pointers and swaps only its local copies, so str1 and str2 in main are unchanged: prints "Hi Bye ". fun2 receives the addresses of str1 and str2 and swaps the pointers they hold, so now str1 points to "Bye" and str2 to "Hi": prints "Bye Hi". Output: Hi Bye Bye Hi. Answer: (A).
Concept: C passes everything by value; to change a caller's pointer you must pass a pointer to it (char**). The trap is believing fun1 swaps because it takes pointers.
Let G be a simple undirected graph. Let T_D be a depth first search tree of G. Let T_B be a breadth first search tree of G. Consider the following statements.
(I) No edge of G is a cross edge with respect to T_D. (A cross edge in G is between two nodes neither of which is an ancestor of the other in T_D.)
(II) For every edge (u,v) of G, if u is at depth i and v is at depth j in T_B, then |i - j| = 1.
Which of the statements above must necessarily be true?
- (A)I only
- (B)II only
- (C)Both I and II
- (D)Neither I nor II
(I) In an undirected DFS, when an edge (u, v) is examined from u and v is unvisited, v becomes a descendant of u; if v is already visited it must be an ancestor or descendant, since u's subtree is finished before DFS backs out. So every non-tree edge is a back edge and there are no cross edges: true. (II) In BFS, edge endpoints differ in depth by at most 1, but can be at the same depth: in a triangle x-y-z rooted at x, y and z are both at depth 1 and the edge y-z has |i - j| = 0. False. Answer: (A) I only.
Concept: Undirected DFS has only tree and back edges; BFS non-tree edges join the same or adjacent levels. The trap is reading BFS's "at most 1" as "exactly 1".
Assume that multiplying a matrix G₁ of dimension p × q with another matrix G₂ of dimension q × r requires pqr scalar multiplications. Computing the product of n matrices G₁G₂G₃...Gₙ can be done by parenthesizing in different ways. Define GᵢGᵢ₊₁ as an explicitly computed pair for a given paranthesization if they are directly multiplied. For example, in the matrix multiplication chain G₁G₂G₃G₄G₅G₆ using parenthesization (G₁(G₂G₃))(G₄(G₅G₆)), G₂G₃ and G₅G₆ are the only explicitly computed pairs.
Consider a matrix multiplication chain F₁F₂F₃F₄F₅, where matrices F₁, F₂, F₃, F₄ and F₅ are of dimensions 2×25, 25×3, 3×16, 16×1 and 1×1000, respectively. In the parenthesization of F₁F₂F₃F₄F₅ that minimizes the total number of scalar multiplications, the explicitly computed pairs is/are
- (A)F₁F₂ and F₃F₄ only
- (B)F₂F₃ only
- (C)F₃F₄ only
- (D)F₁F₂ and F₄F₅ only
Dimensions p = 2, 25, 3, 16, 1, 1000. Pairs: m12 = 150, m23 = 1200, m34 = 48, m45 = 16000. m13 = min(150 + 96, 1200 + 800) = 246. m24 = min(48 + 75, 1200 + 400) = 123, via F₂(F₃F₄). m35 = min(16000 + 48000, 48 + 3000) = 3048. m14 = min(123 + 50, 150 + 48 + 6, 246 + 32) = 173, via F₁(F₂(F₃F₄)). m15: split after F₄ gives 173 + 2·1·1000 = 2173; after F₂ gives 150 + 3048 + 6000 = 9198; others are larger. Optimum ((F₁(F₂(F₃F₄)))F₅) = 2173. The only directly multiplied adjacent pair is F₃F₄. Answer: (C).
Concept: Matrix chain multiplication DP. The 16×1 and 1×1000 shapes make it cheap to collapse everything to a 2×1 matrix first, then multiply by F₅ once. The trap is greedily multiplying the cheapest-looking pairs, such as F₁F₂.
Consider the following C code. Assume that unsigned long int type length is 64 bits.
The value returned when we call fun with the input 2⁴⁰ is
unsigned long int fun(unsigned long int n){
unsigned long int i, j = 0, sum = 0;
for (i = n; i > 1; i = i/2) j++;
for ( ; j > 1; j = j/2) sum++;
return(sum);
}- (A)4
- (B)5
- (C)6
- (D)40
First loop: i halves from 2⁴⁰ down to 1, running 40 times, so j = 40 (j = log₂ n). Second loop: j goes 40 → 20 → 10 → 5 → 2 → 1, incrementing sum each time while j > 1: 5 iterations. sum = 5 (that is floor(log₂ 40)). Answer: (B) 5.
Concept: Nested logarithms: the result is floor(log₂(log₂ n)). The trap is computing log₂ 40 ≈ 5.3 and rounding to 6, or stopping the trace one step early.
Consider the unsigned 8-bit fixed point binary number representation below,
b₇ b₆ b₅ b₄ b₃ . b₂ b₁ b₀
where the position of the binary point is between b₃ and b₂. Assume b₇ is the most significant bit. Some of the decimal numbers listed below cannot be represented exactly in the above representation:
(i) 31.500 (ii) 0.875 (iii) 12.100 (iv) 3.001
Which one of the following statements is true?
- (A)None of (i), (ii), (iii), (iv) can be exactly represented
- (B)Only (ii) cannot be exactly represented
- (C)Only (iii) and (iv) cannot be exactly represented
- (D)Only (i) and (ii) cannot be exactly represented
5 integer bits give 0 to 31, and 3 fraction bits give multiples of 1/8 = 0.125. (i) 31.5 = 11111.100: representable. (ii) 0.875 = 7/8 = 00000.111: representable. (iii) 0.1 is not a multiple of 1/8, so 12.1 is not exact. (iv) 0.001 is not a multiple of 1/8, so 3.001 is not exact. Answer: (C) Only (iii) and (iv) cannot be exactly represented.
Concept: With f fraction bits, exactly representable fractions are multiples of 2^(-f). The trap is thinking 31.5 overflows; 31 is exactly the 5-bit maximum.
The size of the physical address space of a processor is 2ᴾ bytes. The word length is 2ᵂ bytes. The capacity of cache memory is 2ᴺ bytes. The size of each cache block is 2ᴹ words. For a K-way set-associative cache memory, the length (in number of bits) of the tag field is
- (A)P - N - log₂K
- (B)P - N + log₂K
- (C)P - N - M - W - log₂K
- (D)P - N - M - W + log₂K
Block size = 2ᴹ words × 2ᵂ bytes = 2^(M+W) bytes, so the offset is M + W bits. Number of blocks = 2^(N-M-W); number of sets = 2^(N-M-W)/K, so the set index is N - M - W - log₂K bits. Tag = P - (N - M - W - log₂K) - (M + W) = P - N + log₂K. Answer: (B).
Concept: Address = tag + set index + block offset; higher associativity means fewer sets and a longer tag. The trap is the sign of log₂K, or forgetting to convert block size from words to bytes.
Consider the following languages:
I. {aᵐbⁿcᵖd^q | m + p = n + q, where m, n, p, q ≥ 0}
II. {aᵐbⁿcᵖd^q | m = n and p = q, where m, n, p, q ≥ 0}
III. {aᵐbⁿcᵖd^q | m = n = p and p ≠ q, where m, n, p, q ≥ 0}
IV. {aᵐbⁿcᵖd^q | mn = p + q, where m, n, p, q ≥ 0}
Which of the languages above are context-free?
- (A)I and IV only
- (B)I and II only
- (C)II and III only
- (D)II and IV only
I: the condition is m - n + p - q = 0. A PDA keeps a signed counter on the stack (push for a and c, pop for b and d, switching to a negative marker when the count goes below zero) and accepts if it ends at zero: CFL. II: aᵐbᵐ followed by cᵖdᵖ is the concatenation of two CFLs: CFL. III: requires m = n = p, i.e. it contains the comparison aⁿbⁿcⁿ, which a single stack cannot do (pumping lemma): not CFL. IV: mn = p + q needs multiplication of two counts: not CFL. Answer: (B) I and II only.
Concept: A PDA can do one linear count (including signed sums) or nested matching, but not three-way equality or products. The trap is thinking I needs two stacks because it mentions four counts.
Consider the following problems. L(G) denotes the language generated by a grammar G. L(M) denotes the language accepted by a machine M.
(I) For an unrestricted grammar G and a string w, whether w ∈ L(G)
(II) Given a Turing machine M, whether L(M) is regular
(III) Given two grammars G₁ and G₂, whether L(G₁) = L(G₂)
(IV) Given an NFA N, whether there is a deterministic PDA P such that N and P accept the same language.
Which one of the following statements is correct?
- (A)Only I and II are undecidable
- (B)Only III is undecidable
- (C)Only II and IV are undecidable
- (D)Only I, II and III are undecidable
(I) Membership for unrestricted (type-0) grammars is equivalent to TM acceptance: undecidable. (II) Regularity of L(M) for a TM is a non-trivial semantic property: undecidable by Rice's theorem. (III) Equivalence of grammars is undecidable even for context-free grammars, so for arbitrary grammars too. (IV) An NFA accepts a regular language, and every regular language is accepted by some DPDA (a DFA is a DPDA that ignores its stack), so the answer is always yes: decidable. Answer: (D) Only I, II and III are undecidable.
Concept: Rice's theorem for TM language properties; CFG equivalence is undecidable. The trap is (IV): it sounds like a hard question about DPDAs, but its answer is always yes, which makes it trivially decidable.
A lexical analyzer uses the following patterns to recognize three tokens T₁, T₂, and T₃ over the alphabet {a,b,c}.
T₁: a?(b|c)*a
T₂: b?(a|c)*b
T₃: c?(b|a)*c
Note that 'x?' means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix.
If the string bbaacabc is processed by the analyzer, which one of the following is the sequence of tokens it outputs?
- (A)T₁T₂T₃
- (B)T₁T₁T₃
- (C)T₂T₁T₃
- (D)T₃T₃
Input bbaacabc. Longest matches from the start: T₂ matches "bb" (length 2); T₁ matches "bba" ((b|c)* = bb, then a; length 3); T₃ matches "bbaac" (c? empty, (b|a)* = bbaa, then c; length 5). Longest is T₃ on "bbaac". Remaining "abc": T₁ matches only "a" (length 1), T₂ matches "ab" (length 2), T₃ matches "abc" ((b|a)* = ab, then c; length 3). Longest is T₃. Output: T₃T₃. Answer: (D).
Concept: Maximal munch: at each position try all patterns and take the longest match. The trap is committing to the first pattern that matches (T₁ or T₂ on "bb...") instead of checking which one reaches furthest.
Consider the following parse tree for the expression a#b$c$d#e#f, involving two binary operators $ and #.
(Parse tree, described: the root is # with left child a and right child a second #. That second # has left child a $ node and right child a third # whose children are e and f. The $ node has left child another $ (with children b and c) and right child d. In bracket form the tree is a # (((b $ c) $ d) # (e # f)).)
Which one of the following is correct for the given parse tree?
- (A)$ has higher precedence and is left associative; # is right associative
- (B)# has higher precedence and is left associative; $ is right associative
- (C)$ has higher precedence and is left associative; # is left associative
- (D)# has higher precedence and is right associative; $ is left associative
Operators lower in the tree are applied first. The $ operations (b $ c, then $ d) sit below every #, so $ binds tighter: $ has higher precedence. b$c$d is grouped as (b $ c) $ d, so $ is left associative. The # operations group as a # (X # (e # f)), each # taking the rest of the expression on its right, so # is right associative. Answer: (A).
Concept: Reading precedence and associativity from a parse tree: deeper means higher precedence; a left-leaning chain means left associative, a right-leaning chain means right associative. The trap is reading associativity of # from the top-level split alone.
In a system, there are three types of resources: E, F and G. Four processes P₀, P₁, P₂ and P₃ execute concurrently. At the outset, the processes have declared their maximum resource requirements using a matrix named Max as given below. For example, Max[P₂,F] is the maximum number of instances of F that P₂ would require. The number of instances of the resources allocated to the various processes at any given state is given by a matrix named Allocation.
Consider a state of the system with the Allocation matrix as shown below, and in which 3 instances of E and 3 instances of F are the only resources available.
Allocation Max
E F G E F G
P₀ 1 0 1 4 3 1
P₁ 1 1 2 2 1 4
P₂ 1 0 3 1 3 3
P₃ 2 0 0 5 4 1
From the perspective of deadlock avoidance, which one of the following is true?
- (A)The system is in safe state.
- (B)The system is not in safe state, but would be safe if one more instance of E were available
- (C)The system is not in safe state, but would be safe if one more instance of F were available
- (D)The system is not in safe state, but would be safe if one more instance of G were available
Need = Max - Allocation: P₀ (3,3,0), P₁ (1,0,2), P₂ (0,3,0), P₃ (3,4,1). Available (3,3,0). P₀'s need (3,3,0) fits; it finishes and releases (1,0,1): Available (4,3,1). P₂ needs (0,3,0): fits; releases (1,0,3): Available (5,3,4). P₁ needs (1,0,2): fits; releases (1,1,2): Available (6,4,6). P₃ needs (3,4,1): fits. Safe sequence P₀, P₂, P₁, P₃ exists, so the state is safe. Answer: (A).
Concept: Banker's safety algorithm: compute Need, then repeatedly run any process whose Need fits Available and reclaim its Allocation. The trap is comparing Max (not Need) with Available, which makes the state look unsafe.
Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is N. Three semaphores empty, full and mutex are defined with respective initial values of 0, N and 1. Semaphore empty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore full denotes the number of available slots in the buffer, for the producer to write to. The placeholder variables, denoted by P, Q, R, and S, in the code below can be assigned either empty or full. The valid semaphore operations are: wait() and signal().
Which one of the following assignments to P, Q, R and S will yield the correct solution?
Producer: Consumer:
do{ do{
wait(P); wait(R);
wait(mutex); wait(mutex);
//Add item to buffer //Consume item from buffer
signal(mutex); signal(mutex);
signal(Q); signal(S);
}while(1); }while(1);- (A)P: full, Q: full, R: empty, S: empty
- (B)P: empty, Q: empty, R: full, S: full
- (C)P: full, Q: empty, R: empty, S: full
- (D)P: empty, Q: full, R: full, S: empty
Here the names are swapped from the textbook: full (initial N) counts free slots and empty (initial 0) counts filled slots. The producer must wait for a free slot, wait(full), so P = full, and after adding announce a filled slot, signal(empty), so Q = empty. The consumer waits for a filled slot, wait(empty), so R = empty, and then frees a slot, signal(full), so S = full. Answer: (C).
Concept: Bounded-buffer pattern: each side waits on the counter of what it consumes and signals the counter of what it produces. The trap is going by the usual names; read the initial values and definitions given in the question.
Consider the relations r(A, B) and s(B, C), where s.B is a primary key and r.B is a foreign key referencing s.B. Consider the query
Q: r ⋈ (σ_(B<5)(s))
Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values.
Which one of the following queries is NOT equivalent to Q?
- (A)σ_(B<5)(r ⋈ s)
- (B)σ_(B<5)(r LOJ s)
- (C)r LOJ (σ_(B<5)(s))
- (D)σ_(B<5)(r) LOJ s
Q returns the r tuples with B < 5 joined with their s tuple. Because r.B is a foreign key into s, every r tuple has a matching s tuple, so r LOJ s = r ⋈ s. (A) Selection pushed past the join on the join attribute: equivalent. (B) r LOJ s = r ⋈ s, then select: equivalent. (D) σ_(B<5)(r) LOJ s = σ_(B<5)(r) ⋈ s: equivalent. (C) r LOJ σ_(B<5)(s) keeps every r tuple with B ≥ 5 too, padded with C = NULL, so it has extra rows: NOT equivalent. Answer: (C).
Concept: Foreign keys guarantee matches, so a left outer join from the referencing side behaves like a natural join, unless the referenced side is filtered first. The trap is assuming the filter position never matters in outer joins.
Consider the following four relational schemas. For each schema, all non-trivial functional dependencies are listed. The underlined attributes are the respective primary keys.
Schema I: Registration (rollno, courses) primary key: rollno
Field 'courses' is a set-valued attribute containing the set of courses a student has registered for.
Non-trivial functional dependency: rollno → courses
Schema II: Registration (rollno, courseid, email) primary key: (rollno, courseid)
Non-trivial functional dependencies: rollno, courseid → email; email → rollno
Schema III: Registration (rollno, courseid, marks, grade) primary key: (rollno, courseid)
Non-trivial functional dependencies: rollno, courseid → marks, grade; marks → grade
Schema IV: Registration (rollno, courseid, credit) primary key: (rollno, courseid)
Non-trivial functional dependencies: rollno, courseid → credit; courseid → credit
Which one of the relational schemas above is in 3NF but not in BCNF?
- (A)Schema I
- (B)Schema II
- (C)Schema III
- (D)Schema IV
I: a set-valued attribute violates 1NF, so it is not in 3NF. II: candidate keys are {rollno, courseid} and {email, courseid}. email → rollno has a non-superkey left side, so not BCNF, but rollno is a prime attribute, so 3NF holds. III: marks → grade is a transitive dependency of a non-prime attribute: not 3NF. IV: courseid → credit is a partial dependency: not even 2NF. Answer: (B) Schema II.
Concept: 3NF allows X → A with X not a superkey only when A is prime; BCNF does not. The classic 3NF-not-BCNF case is a non-key attribute determining part of a key. The trap is missing the second candidate key {email, courseid}.
Let G be a graph with 100! vertices, with each vertex labelled by a distinct permutation of the numbers 1, 2, ..., 100. There is an edge between vertices u and v if and only if the label of u can be obtained by swapping two adjacent numbers in the label of v. Let y denote the degree of a vertex in G, and z denote the number of connected components in G. Then, y + 10z = _____.
A permutation of 100 numbers has 99 adjacent positions, and each adjacent swap gives a different permutation, so every vertex has degree y = 99. Any permutation can be sorted by adjacent swaps (bubble sort), so every vertex is connected to the identity permutation: the graph is connected, z = 1. y + 10z = 99 + 10 = 109. Answer: 109.
Concept: Adjacent transpositions generate all permutations, which is why bubble sort always works. The trap is counting all C(100,2) swaps for the degree, or thinking parity splits the graph into two components (that happens only if moves preserve parity, and adjacent swaps flip it).
Consider Guwahati (G) and Delhi (D) whose temperatures can be classified as high (H), medium (M) and low (L). Let P(H_G) denote the probability that Guwahati has high temperature. Similarly, P(M_G) and P(L_G) denotes the probability of Guwahati having medium and low temperatures respectively. Similarly, we use P(H_D), P(M_D) and P(L_D) for Delhi.
The following table gives the conditional probabilities for Delhi's temperature given Guwahati's temperature.
H_D M_D L_D
H_G 0.40 0.48 0.12
M_G 0.10 0.65 0.25
L_G 0.01 0.50 0.49
Consider the first row in the table above. The first entry denotes that if Guwahati has high temperature (H_G) then the probability of Delhi also having a high temperature (H_D) is 0.40; i.e., P(H_D | H_G) = 0.40. Similarly, the next two entries are P(M_D | H_G) = 0.48 and P(L_D | H_G) = 0.12. Similarly for the other rows.
If it is known that P(H_G) = 0.2, P(M_G) = 0.5, and P(L_G) = 0.3, then the probability (correct to two decimal places) that Guwahati has high temperature given that Delhi has high temperature is _______.
Total probability: P(H_D) = 0.2 × 0.40 + 0.5 × 0.10 + 0.3 × 0.01 = 0.08 + 0.05 + 0.003 = 0.133. Bayes: P(H_G | H_D) = P(H_D | H_G) P(H_G) / P(H_D) = 0.08 / 0.133 ≈ 0.6015. Answer: 0.60 (accepted range 0.60 to 0.62).
Concept: Bayes' theorem with the law of total probability for the denominator. The trap is answering 0.40, which is P(H_D | H_G), the reverse conditional.
Consider the following program written in pseudo-code. Assume that x and y are integers.
The number of times that the print statement is executed by the call Count(1024,1024) is _____.
Count(x,y) {
if (y != 1){
if (x != 1) {
print("*");
Count(x/2, y);
}
else {
y = y-1;
Count(1024, y);
}
}
}For a fixed y ≠ 1, x halves from 1024 down to 1, printing once for each x in 1024, 512, ..., 2: that is 10 prints. When x reaches 1, y drops by one and x resets to 1024. This repeats for y = 1024, 1023, ..., 2, which is 1023 values; at y = 1 the function stops without printing. Total = 1023 × 10 = 10230. Answer: 10230.
Concept: Nested iteration written as recursion: an outer counter y and an inner halving x (log₂ 1024 = 10 prints). The trap is using 1024 rounds instead of 1023, since y = 1 prints nothing.
The number of possible min-heaps containing each value from {1, 2, 3, 4, 5, 6, 7} exactly once is _____.
A 7-node heap is a complete tree: a root with two subtrees of 3 nodes each. The root must be 1. Choose which 3 of the remaining 6 values go to the left subtree: C(6,3) = 20. In a 3-node subtree the smallest value must be its root and the other two can be in either order: 2 ways for each subtree. Total = 20 × 2 × 2 = 80. Answer: 80.
Concept: Recurrence H(n) = C(n - 1, L) × H(L) × H(R), where L and R are the fixed subtree sizes of the complete tree. The trap is forcing 2 and 3 to be the root's children; 3 can sit below 2 in the same subtree.
Consider the following undirected graph G:
(Graph, described: five vertices T, A, B, C, R. Edges with weights: T-A = 4, A-B = 4, T-B = 1, T-C = 3, B-C = 4, T-R = x, C-R = 5.)
Choose a value for x that will maximize the number of minimum weight spanning trees (MWSTs) of G. The number of MWSTs of G for this value of x is ______.
Edges T-B (1) and T-C (3) are the two cheapest and form no cycle, so every MST contains them. Vertex A joins through T-A or A-B, both weight 4, giving 2 choices (B-C, also 4, would close the cycle T-B-C and is never needed). Vertex R joins only through T-R (x) or C-R (5). If x = 5 both are equally cheap, giving 2 choices; any other x gives 1. Maximum number of MSTs = 2 × 2 = 4 with x = 5. Answer: 4.
Concept: Multiple MSTs arise from ties among the cheapest edges crossing a cut. Choosing x equal to the competing edge (5) creates a tie for R. The trap is counting B-C as a third option for A; it never crosses the cut that separates A.
Consider the weights and values of items listed below. Note that there is only one unit of each item.
Item number Weight (in Kgs) Value (in Rupees)
1 10 60
2 7 28
3 4 20
4 2 24
The task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by V_opt. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by V_greedy.
The value of V_opt - V_greedy is ____________.
Ratios: item 4 = 12, item 1 = 6, item 3 = 5, item 2 = 4. Greedy takes item 4 (2 kg, 24); item 1 (10 kg) would make 12 kg, so it is skipped; item 3 (4 kg) fits, total 6 kg, 44; item 2 (7 kg) would make 13 kg, skipped. V_greedy = 44. Optimal: item 1 alone gives 60; no other item fits with it (10 + 2 = 12). Other subsets: 2 + 4 = 52, 2 + 3 = 48, 3 + 4 = 44. V_opt = 60. Difference = 60 - 44 = 16. Answer: 16.
Concept: Greedy by value/weight is optimal only for fractional knapsack; 0/1 knapsack needs DP or exhaustive search. The trap is letting greedy stop at the first item that does not fit; it continues down the list.
Consider the minterm list form of a Boolean function F given below.
F(P, Q, R, S) = Σm(0, 2, 5, 7, 9, 11) + d(3, 8, 10, 12, 14)
Here, m denotes a minterm and d denotes a don't care term. The number of essential prime implicants of the function F is ______.
Prime implicants (using don't cares): Q'S' = {0, 2, 8, 10}; PQ' = {8, 9, 10, 11}; Q'R = {2, 3, 10, 11}; P'QS = {5, 7}; P'RS = {3, 7}; PS' = {8, 10, 12, 14} (only don't cares plus none of the minterms, so irrelevant). Minterm 0 is covered only by Q'S', minterm 5 only by P'QS, and minterm 9 only by PQ', so these three are essential. Together they cover 0, 2, 5, 7, 9, 11, i.e. the whole function. Number of essential prime implicants = 3.
Concept: An essential prime implicant is the only prime implicant covering some required minterm; don't cares help form implicants but never need covering. The trap is counting implicants made only of don't cares, or treating don't-care cells as minterms that make a prime essential.
The instruction pipeline of a RISC processor has the following stages: Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Perform Operation (PO) and Writeback (WB). The IF, ID, OF and WB stages take 1 clock cycle each for every instruction. Consider a sequence of 100 instructions. In the PO stage, 40 instructions take 3 clock cycles each, 35 instructions take 2 clock cycles each, and the remaining 25 instructions take 1 clock cycle each. Assume that there are no data hazards and no control hazards.
The number of clock cycles required for completion of execution of the sequence of instructions is ______.
PO is the only multi-cycle stage, and the 1-cycle stages before it always have the next instruction ready, so PO is busy continuously once it starts. The first instruction spends 3 cycles in IF, ID, OF before reaching PO. PO then needs 40 × 3 + 35 × 2 + 25 × 1 = 120 + 70 + 25 = 215 cycles for all instructions back to back. The last instruction needs 1 more cycle in WB. Total = 3 + 215 + 1 = 219. Answer: 219.
Concept: With one variable-latency stage, total time = fill time before it + sum of its busy times + drain time after it. The trap is using the standard (k + n - 1) formula with the slowest stage time, which gives 3 × 104 = 312.
A processor has 16 integer registers (R0, R1, ..., R15) and 64 floating point registers (F0, F1, ..., F63). It uses a 2-byte instruction format. There are four categories of instructions: Type-1, Type-2, Type-3, and Type-4. Type-1 category consists of four instructions, each with 3 integer register operands (3Rs). Type-2 category consists of eight instructions, each with 2 floating point register operands (2Fs). Type-3 category consists of fourteen instructions, each with one integer register operand and one floating point register operand (1R+1F). Type-4 category consists of N instructions, each with a floating point register operand (1F).
The maximum value of N is __________.
An integer register needs 4 bits, a floating point register 6 bits; there are 2¹⁶ = 65536 encodings. Type-1: 4 instructions × 2¹² operand combinations = 16384. Type-2: 8 × 2¹² = 32768. Type-3: 14 × 2¹⁰ = 14336. Used = 63488, leaving 65536 - 63488 = 2048 encodings. Each Type-4 instruction uses 2⁶ = 64 encodings, so N = 2048 / 64 = 32. Answer: 32.
Concept: Expanding-opcode problems are solved by counting encodings: each instruction consumes 2^(operand bits) codes out of 2^(instruction length). The trap is assigning fixed opcode widths per category instead of counting the shared code space.
Given a language L, define Lⁱ as follows:
L⁰ = {ε}
Lⁱ = Lⁱ⁻¹ · L for all i > 0
The order of a language L is defined as the smallest k such that Lᵏ = Lᵏ⁺¹.
Consider the language L₁ (over alphabet 0) accepted by the following automaton.
(Automaton, described: three states q0, q1, q2. q0 is the start state and is accepting; q1 is accepting; q2 is not accepting. Transitions on 0: q0 → q1, q1 → q2, q2 → q1.)
The order of L₁ is _____.
Accepted strings: ε (at q0) and strings of odd length (ending at q1), so L₁ = {ε} ∪ {0^(2j+1) | j ≥ 0}. L⁰ = {ε}, which differs from L¹. L¹ = L₁ lacks even-length strings of length ≥ 2. L² = L₁ · L₁ contains ε, every odd string (odd · ε) and every even string of length ≥ 2 (odd · odd), so L² = 0*. Then L³ = L² · L₁ = 0*. The smallest k with Lᵏ = Lᵏ⁺¹ is 2. Answer: 2.
Concept: Powers of a language containing ε form an increasing chain; the order is where the chain stabilises. The trap is answering 1 by missing that ε ∈ L₁ means L¹ ⊆ L², and checking whether they are actually equal (they are not, since 00 ∉ L₁).
Consider a storage disk with 4 platters (numbered as 0, 1, 2 and 3), 200 cylinders (numbered as 0, 1, ..., 199), and 256 sectors per track (numbered as 0, 1, ..., 255). The following 6 disk requests of the form [sector number, cylinder number, platter number] are received by the disk controller at the same time:
[120, 72, 2], [180, 134, 1], [60, 20, 0], [212, 86, 3], [56, 116, 2], [118, 16, 1]
Currently the head is positioned at sector number 100 of cylinder 80, and is moving towards higher cylinder numbers. The average power dissipation in moving the head over 100 cylinders is 20 milliwatts and for reversing the direction of the head movement once is 15 milliwatts. Power dissipation associated with rotational latency and switching of head between different platters is negligible.
The total power consumption in milliwatts to satisfy all of the above disk requests using the Shortest Seek Time First disk scheduling algorithm is _______.
Cylinders requested: 72, 134, 20, 86, 116, 16. SSTF from 80: 86 (6), then 72 (14), then 116 (44, closer than 20 at 52), then 134 (18), then 20 (114), then 16 (4). Total movement = 6 + 14 + 44 + 18 + 114 + 4 = 200 cylinders, costing 200/100 × 20 = 40 mW. Direction: up to 86 (already moving up), down to 72 (reversal 1), up to 116 and 134 (reversal 2), down to 20 and 16 (reversal 3). Reversals cost 3 × 15 = 45 mW. Total = 40 + 45 = 85. Answer: 85.
Concept: SSTF picks the nearest pending cylinder each time; sector and platter numbers are distractors here. The trap is miscounting reversals: the initial move to 86 continues the current upward direction, so it is not a reversal.
Consider an IP packet with a length of 4,500 bytes that includes a 20-byte IPv4 header and a 40-byte TCP header. The packet is forwarded to an IPv4 router that supports a Maximum Transmission Unit (MTU) of 600 bytes. Assume that the length of the IP header in all the outgoing fragments of this packet is 20 bytes. Assume that the fragmentation offset value stored in the first fragment is 0.
The fragmentation offset value stored in the third fragment is _______.
IP payload = 4500 - 20 = 4480 bytes (the TCP header is part of the IP payload). Each fragment may carry at most 600 - 20 = 580 bytes, rounded down to a multiple of 8: 576 bytes. Offsets are stored in 8-byte units: fragment 1 starts at byte 0 (offset 0), fragment 2 at byte 576 (offset 72), fragment 3 at byte 1152 (offset 144). Answer: 144.
Concept: Fragment data sizes must be multiples of 8 (except the last), and the offset field counts 8-byte units. Traps: subtracting the TCP header from every fragment, or reporting the byte offset 1152 instead of 144.
Consider a simple communication system where multiple nodes are connected by a shared broadcast medium (like Ethernet or wireless). The nodes in the system use the following carrier-sense based medium access protocol. A node that receives a packet to transmit will carrier-sense the medium for 5 units of time. If the node does not detect any other transmission in this duration, it starts transmitting its packet in the next time unit. If the node detects another transmission, it waits until this other transmission finishes, and then begins to carrier-sense for 5 time units again. Once they start to transmit, nodes do not perform any collision detection and continue transmission even if a collision occurs. All transmissions last for 20 units of time. Assume that the transmission signal travels at the speed of 10 meters per unit time in the medium.
Assume that the system has two nodes P and Q, located at a distance d meters from each other. P starts transmitting a packet at time t=0 after successfully completing its carrier-sense phase. Node Q has a packet to transmit at time t=0 and begins to carrier-sense the medium.
The maximum distance d (in meters, rounded to the closest integer) that allows Q to successfully avoid a collision between its proposed transmission and P's ongoing transmission is _____.
Q senses the medium from t = 0 to t = 5. To avoid colliding it must detect P's signal within that window, after which it defers until P finishes. P's signal reaches Q at t = d/10. The condition d/10 ≤ 5 gives d ≤ 50 m. For any larger d, Q hears nothing during sensing, starts transmitting and collides with P's 20-unit transmission. Answer: 50.
Concept: Carrier sensing only works if the other station's signal arrives within the sensing interval: propagation delay ≤ sensing time. The trap is involving the 20-unit transmission time, which matters for collision detection but not for this deferral condition.
Answers are the official GATE answer key. Questions that depend on a figure are left out until they can be shown faithfully.