Consider the following two statements about the function f(x)=|x|: P. f(x) is continuous for all real values of x Q. f(x) is differentiable for all real values of x Which of the following is TRUE?
Statement P: A function is continuous if its graph can be drawn without lifting the pen. The graph of f(x)=∣x∣ has no breaks or jumps, including at x=0.
We evaluate the limit at x=0: limx→0−∣x∣=limx→0−(−x)=0 and limx→0+∣x∣=limx→0+x=0. Since f(0)=0, limx→0f(x)=f(0). Thus, f(x) is continuous for all real x. P is TRUE.
Statement Q: A function is differentiable at a point if its graph has a unique tangent line at that point. At x=0, the graph of f(x)=∣x∣ has a sharp corner (a "cusp").
The left-hand derivative at x=0 is limh→0−h∣0+h∣−∣0∣=limh→0−h−h=−1.
The right-hand derivative at x=0 is limh→0+h∣0+h∣−∣0∣=limh→0+hh=1.
Since the left-hand derivative (=−1) and right-hand derivative (=1) are not equal, f(x) is not differentiable at x=0. Thus, f(x) is not differentiable for all real values of x. Q is FALSE.
Therefore, P is true and Q is false.
Q2GATE 0MCQ1MDiscrete Mathematics
Let S be a set of n elements. The number of ordered pairs in the largest and the smallest equivalence relations on S are:
Let S be a set with n elements.
The largest equivalence relation on S is the universal relation, RL={(a,b)∣a,b∈S}. Every element is related to every other element. The number of ordered pairs in RL is n×n=n2.
The smallest equivalence relation on S is the identity relation, RS={(a,a)∣a∈S}. Each element is only related to itself. The number of ordered pairs in RS is n.
Therefore, the number of ordered pairs in the largest and the smallest equivalence relations are n2 and n, respectively.
Q3GATE 0MCQ1MDigital Logic
What is the maximum number of different Boolean functions involving n Boolean variables?
For n Boolean variables, there are 2n distinct possible input combinations.
For each of these 2n input combinations, a Boolean function can independently output either 0 or 1.
Thus, for each input combination, there are 2 possible output values.
Since there are 2n input combinations, and each can have 2 independent output choices, the total number of different Boolean functions is: 2n\times2×2×⋯×2=22n
Q4GATE 0MCQ1MDiscrete Mathematics
Let G be the non-planar graph with the minimum possible number of edges. Then G has
The minimum non-planar graphs are subdivisions of K5 or K3,3 (by Kuratowski's Theorem). K5 is the complete graph on 5 vertices. V(K5)=5
The number of edges in K5 is given by: E(K5)=(25)=25×4=10 K3,3 is the complete bipartite graph with 3 vertices in each partition. V(K3,3)=3+3=6
The number of edges in K3,3 is given by: E(K3,3)=3×3=9
Comparing the number of edges, K3,3 has 9 edges, which is less than K5's 10 edges. Thus, K3,3 is the non-planar graph with the minimum possible number of edges.
Therefore, G has 9 edges and 6 vertices.
Q5GATE 0MCQ1MAlgorithm
Consider the DAG with V = {1,2,3,4,5,6}, shown below. Which of the following is NOT a topological ordering?
A topological ordering requires that for every directed edge u→v, vertex u appears before vertex v in the ordering. Let's check option D.
The given DAG has edges including 1→2 and 1→3.
For option D: 324165
For the edge 1→2, vertex 1 must appear before vertex 2. In option D, 2 appears before 1.
For the edge 1→3, vertex 1 must appear before vertex 3. In option D, 3 appears before 1.
Since both conditions are violated, this ordering is not a topological ordering.
The membership problem for CFGs, the finiteness problem for FSAs, and the equivalence problem for FSAs are all decidable. Algorithms exist to determine whether a string is in a CFG's language, if an FSA's language is finite, or if two FSAs recognize the same language. However, there is no algorithm that can determine for an arbitrary CFG whether it is ambiguous. This property makes the ambiguity problem for CFGs undecidable.
Any finite language is regular, as it can be recognized by a finite automaton with a path for each string.
A. Every subset of a regular set is regular. False. Example: Σ∗ is regular, but {anbn∣n≥0}⊂Σ∗ is not regular.
B. Every finite subset of a non-regular set is regular. True. Any finite language is regular.
C. The union of two non-regular sets is not regular. False. Let L1={anbn∣n≥0} and L2=Σ∗∖L1. Both L1 and L2 are non-regular. However, L1∪L2=Σ∗, which is regular.
D. Infinite union of finite sets is regular. False. Example: L=⋃n=0∞{anbn} is an infinite union of finite sets, but L is non-regular.
Q8GATE 0MCQ1MDigital Logic
How many 3-to-8 line decoders with an enable input are needed to construct a 6- to-64 line decoder without using any other logic gates?
A 6-to-64 line decoder requires 6 input bits. We can split these into two groups: 3 higher-order bits and 3 lower-order bits.
The 3 lower-order input bits (A2,A1,A0) are fed to the data inputs of eight 3-to-8 decoders. These eight decoders produce the 64 output lines (8×8=64).
The 3 higher-order input bits (A5,A4,A3) are used to enable one of these eight decoders at a time. This requires an additional 3-to-8 decoder acting as an enable decoder.
The 8 outputs of this master 3-to-8 decoder are connected to the enable inputs of the eight slave 3-to-8 decoders.
The corner group of four: m1(0001),m3(0011),m9(1001),m11(1011).
Comparing these minterms: w changes (0 to 1), x is 0, y changes (0 to 1), z is 1.
This group simplifies to x′z.
The corner group of four: m4(0100),m6(0110),m12(1100),m14(1110).
Comparing these minterms: w changes (0 to 1), x is 1, y changes (0 to 1), z is 0.
This group simplifies to xz′.
The simplified Boolean function is f(w,x,y,z)=x′z+xz′.
This expression can also be written as x⊕z.
The variables w and y are not present in the simplified function.
Therefore, the function is independent of two variables (w and y).
Q10GATE 0MCQ1MComputer Organization
Consider a 4-way set associative cache consisting of 128 lines with a line size of 64 words. The CPU generates a 20-bit address of a word in main memory. The number of bits in the TAG, LINE and WORD fields are respectively:
The address is divided into three fields: TAG, SET (or LINE), and WORD (or Block Offset).
WORD (Block Offset) bits: The line size is 64 words. WORD bits=log2(Line Size)=log2(64)=6 bits
SET (LINE) bits: The cache has 128 lines and is 4-way set associative. Number of Sets=AssociativityTotal Lines=4128=32 SET bits=log2(Number of Sets)=log2(32)=5 bits
TAG bits: The total CPU address is 20 bits. TAG bits=Total Address bits−SET bits−WORD bits TAG bits=20−5−6=9 bits
Thus, the TAG, LINE, and WORD bits are 9, 5, and 6, respectively.
Q11GATE 0MCQ1MComputer Organization
Consider a disk pack with 16 surfaces, 128 tracks per surface and 256 sectors per track. 512 bytes of data are stored in a bit serial manner in a sector. The capacity of the disk pack and the number of bits required to specify a particular sector in the disk are respectively:
The total capacity is calculated by multiplying the number of surfaces, tracks per surface, sectors per track, and bytes per sector. Capacity=16×128×256×512 bytes=24×27×28×29 bytes=228 bytes
Since 1 Mbyte=220 bytes, the capacity is 228/220=28 Mbyte=256 Mbyte.
To specify a particular sector, we need bits for the surface, track, and sector number.
Number of bits for surface = ⌈log2(16)⌉=4 bits.
Number of bits for track = ⌈log2(128)⌉=7 bits.
Number of bits for sector = ⌈log2(256)⌉=8 bits.
Total bits required = 4+7+8=19 bits.
Q12GATE 0MCQ1MData Structure
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:
To maximize the number of nodes for a given height h, the binary tree must be a perfect binary tree, meaning all levels are completely filled.
The root is at level 0 and has 20=1 node.
Level 1 has 21=2 nodes.
Level 2 has 22=4 nodes.
...
Level k has 2k nodes.
For a tree of height h, the levels range from 0 to h.
The total maximum number of nodes is the sum of nodes at each level: N=∑k=0h2k
This is a geometric series sum: N=20+21+⋯+2h=2−12h+1−1=2h+1−1
Q13GATE 0MCQ1MData Structure
The maximum number of binary trees that can be formed with three unlabeled nodes is:
The number of distinct binary trees that can be formed with n unlabeled nodes is given by the n-th Catalan number, Cn.
The formula for the n-th Catalan number is: Cn=n+11(n2n)
For three unlabeled nodes, n=3. Substituting n=3 into the formula: C3=3+11(32×3)=41(36)
Calculate the binomial coefficient: (36)=3!(6−3)!6!=3!3!6!=3×2×16×5×4=20
Substitute the value back into the formula for C3: C3=41×20=5
Thus, 5 distinct binary trees can be formed with three unlabeled nodes.
Q14GATE 0MCQ1MAlgorithm
Which of the following sorting algorithms has the lowest worst-case complexity?
Let's compare the worst-case time complexities of the given sorting algorithms:
Merge Sort: O(nlogn)
Bubble Sort: O(n2)
Quick Sort: O(n2) (occurs with already sorted or reverse-sorted input)
Selection Sort: O(n2)
Comparing these complexities, O(nlogn) is asymptotically lower than O(n2). Therefore, Merge Sort has the lowest worst-case complexity.
Q15GATE 0MCQ1MC Programming
Consider the following segment of C-code: int j, n; j = 1; while (j <=n) j=j*2; The number of comparisons made in the execution of the loop for any n>0 is:
The variable j starts at 1 and doubles in each iteration, taking values 1,2,4,…,2k,….
The loop continues as long as the condition j≤n is true. We are counting the number of times this comparison evaluates to true.
The values of j for which the condition j≤n is true are 20,21,22,…,2k, where 2k is the largest power of 2 such that 2k≤n.
Taking log2 on both sides of 2k≤n, we get k≤log2n.
Since k must be an integer (representing the exponent of 2), the maximum value for k is ⌊log2n⌋.
Therefore, the comparisons that evaluate to true occur for j=20,21,…,2⌊log2n⌋.
The count of these values is (⌊log2n⌋−0)+1=⌊log2n⌋+1.
Q16GATE 0MCQ1MOperating System
Group 1 contains some CPU scheduling algorithms and Group 2 contains some applications. Match entries in Group 1 to entries in Group 2. Group I Group II
Here's the matching of CPU scheduling algorithms to their applications:
(P) Gang Scheduling involves scheduling a group of related processes or threads to run simultaneously on different processors. Therefore, P matches (3) Thread Scheduling.
(Q) Rate Monotonic Scheduling is a priority-based algorithm widely used in real-time scheduling systems where tasks have deadlines. Therefore, Q matches (2) Real-time Scheduling.
(R) Fair Share Scheduling ensures that each user or group receives a guaranteed share of the CPU's processing time. Therefore, R matches (1) Guaranteed Scheduling.
Thus, the correct matching is P - 3, Q - 2, R - 1.
Q17GATE 0MCQ1MOperating System
Consider the following statements about user level threads and kernel level threads. Which one of the following statements is FALSE?
Statement A is true because kernel threads require a kernel mode switch and OS intervention for context switching, which is more overhead than user-level thread switching that happens entirely in user space. Statement B is true as user-level threads are managed by a user-level library without direct kernel involvement or specialized hardware. Statement C is true because the kernel schedules kernel threads, allowing it to distribute them across multiple processors. Statement D is false because if one kernel-level thread blocks (e.g., waiting for I/O), the kernel can still schedule other kernel-level threads from the same process to run, preventing the entire process from blocking.
Top-down parsers build the parse tree from the root (start symbol) down to the leaves (input tokens) by predicting the next production rule.
A recursive descent parser is a type of top-down parser that consists of a set of recursive procedures, one for each non-terminal, which directly implement the grammar's production rules.
Conversely, operator precedence, LR(k), and LALR(k) parsers are all types of bottom-up parsers, which build the parse tree from the leaves up to the root.
Q19GATE 0MCQ1MComputer Network
In Ethernet when Manchester encoding is used, the bit rate is:
In Manchester encoding, each bit is represented by two signal transitions (e.g., a high-to-low or low-to-high transition within the bit period).
This means that to transmit one bit, two signaling elements (symbols) are required.
Therefore, the number of signal changes per second (baud rate) is twice the number of bits transmitted per second (bit rate).
If Rb is the bit rate and Rs is the baud rate, then Rs=2×Rb.
Consequently, the bit rate is half the baud rate: Rb=21Rs.
Q20GATE 0MCQ1MComputer Network
Which one of the following uses UDP as the transport protocol?
UDP is a connectionless protocol that prioritizes speed over guaranteed delivery, making it suitable for quick, small transactions. DNS (Domain Name System) primarily uses UDP for its standard query/response operations because individual requests and responses are small and fast, and retransmissions are handled at the application layer if needed. In contrast, HTTP, Telnet, and SMTP require reliable, ordered data delivery, which is provided by TCP.
Q21GATE 0MCQ1MDiscrete Mathematics
How many different non-isomorphic Abelian groups of order 4 are there?
To find the number of non-isomorphic Abelian groups of order 4, we use the Fundamental Theorem of Finite Abelian Groups.
First, find the prime factorization of the order: 4=22.
The number of non-isomorphic Abelian groups of order pk is equal to the number of partitions of k. Here, p=2 and k=2.
The partitions of 2 are:
2: This corresponds to the cyclic group Z4.
1+1: This corresponds to the direct product Z2×Z2.
These two groups are non-isomorphic (e.g., Z4 has an element of order 4, while Z2×Z2 does not).
Thus, there are 2 different non-isomorphic Abelian groups of order 4.
Q22GATE 0MCQ1MDiscrete Mathematics
Let Graph(x) be a predicate which denotes that x is a graph. Let Connected(x) be a predicate which denotes that x is connected. Which of the following first order logic sentences DOES NOT represent the statement: "Not every graph is connected"?
The statement "Not every graph is connected" means "There exists at least one graph that is not connected." This can be formalized as ∃x(Graph(x)∧¬Connected(x)).
Let's evaluate each option:
A. ¬∀x(Graph(x)⇒Connected(x))
This is equivalent to ∃x¬(Graph(x)⇒Connected(x)). Using the equivalence ¬(A⇒B)≡A∧¬B, this simplifies to ∃x(Graph(x)∧¬Connected(x)). This directly represents the statement.
C. ¬∀x(¬Graph(x)∨Connected(x))
Using the equivalence A⇒B≡¬A∨B, the expression (¬Graph(x)∨Connected(x)) is equivalent to (Graph(x)⇒Connected(x)). is identical to option A and also represents the statement.
D. ∀x(Graph(x)⇒¬Connected(x))
This statement translates to "For every x, if x is a graph, then x is not connected," which means "All graphs are disconnected." This is a much stronger claim than "Not every graph is connected" (which only requires at least one disconnected graph). For example, if there's one connected graph and one disconnected graph, "Not every graph is connected" is true, but D is false. Thus, D does NOT represent the statement.
B. ∃x(Graph(x)⇒¬Connected(x))
In problems of this type, it is a common implicit assumption that the domain of discourse is restricted to the type of objects being discussed (i.e., graphs). If the domain consists only of graphs, then Graph(x) is always true. Under this assumption, Graph(x)⇒¬Connected(x) simplifies to True⇒¬Connected(x), which is ¬Connected(x). So, B becomes ∃x(¬Connected(x)), which means "There exists a graph that is not connected." This represents the original statement.
Given that A, B, and C represent the statement (under the common implicit assumption for B), D is the only option that does NOT represent the statement.
The final answer is D
Q23GATE 0MCQ1MDiscrete Mathematics
Which of the following graphs has an Eulerian circuit?
A connected graph has an Eulerian circuit if and only if every vertex has an even degree.
A. Any k-regular graph where k is an even number. This is not necessarily true because the graph might not be connected (e.g., two disjoint K3 graphs, each 2-regular).
B. A complete graph on 90 vertices (K90). In K90, every vertex has degree 90−1=89. Since 89 is odd, K90 does not have an Eulerian circuit.
C. The complement of a cycle on 25 vertices (Cˉ25).
A cycle graph C25 has 25 vertices, and each vertex has degree 2.
The degree of a vertex v in its complement Cˉ25 is (25−1)−degC25(v)=24−2=22.
Since 22 is an even number, all vertices in Cˉ25 have an even degree.
For n≥4, the complement of a cycle graph Cˉn is connected. Since n=25, Cˉ25 is connected.
Thus, Cˉ25 is connected and all its vertices have even degrees, so it has an Eulerian circuit.
Q24GATE 0MCQ1MDiscrete Mathematics
Suppose we uniformly and randomly select a permutation from the 20! Permutations of 1, 2,3 ,...,20. What is the probability that 2 appears at an earlier position than any other even number in the selected permutation?
Let E={2,4,6,8,10,12,14,16,18,20} be the set of all even numbers from 1 to 20. There are 10 even numbers.
Consider any permutation of the numbers 1,2,…,20. In this permutation, the 10 even numbers will appear in some order. For example, if we consider the numbers 2, 4, and 6, one possible relative order is (4, 2, 6), meaning 4 appears before 2, and 2 appears before 6.
We are interested in the event that 2 appears at an earlier position than any other even number. This means that among the 10 even numbers, 2 must be the first to appear in the permutation.
By symmetry, each of the 10 even numbers is equally likely to appear first among the even numbers.
There are 10! ways to arrange these 10 even numbers among themselves within the permutation.
The number of arrangements where 2 appears first is 9! (since 2 is fixed as the first, and the remaining 9 even numbers can be arranged in 9! ways).
The probability is the ratio of favorable arrangements to the total arrangements for the relative order of the even numbers: P(2 appears first among evens)=Total number of arrangements of even numbersNumber of arrangements where 2 is first=10!9!=101
Q25GATE 0MCQ1MEngineering Mathematics
Let A be a 4 x 4 matrix with eigenvalues -5, -2, 1, 4. Which of the following is an eigenvalue of
The eigenvalues of A are -5, -2, 1, 4.
The possible eigenvalues for M are λ±1:
For λ=−5: −5±1⟹−4,−6.
For λ=−2: −2±1⟹−1,−3.
For λ=1: 1±1⟹0,2.
For λ=4: 4±1⟹3,5.
The set of all eigenvalues of M is {−6,−4,−3,−1,0,2,3,5}.
Comparing with the options, 2 is an eigenvalue of M.
The final answer is C
Q26GATE 0MCQ1MEngineering Mathematics
Consider the set of (column) vectors defined by X={x∈R3∣x1+x2+x3=0,wherexT=[x1,x2,x3]T}. Which of the following is TRUE?
The set X is defined by x1+x2+x3=0, which is a homogeneous linear equation. Thus, X is a subspace of R3, specifically a plane through the origin, with dimension 3−1=2.
Consider the given vectors v1=[1,−1,0]T and v2=[1,0,−1]T.
First, verify they are in X:
For v1: 1+(−1)+0=0.
For v2: 1+0+(−1)=0.
Both vectors belong to X.
Next, check for linear independence:
Since v1 and v2 are not scalar multiples of each other (v1=cv2 for any scalar c), they are linearly independent.
As X is a 2-dimensional subspace and we have found two linearly independent vectors within X, these vectors must form a basis for X.
Q27GATE 0MCQ1MEngineering Mathematics
Consider the series xn+1=2xn+8xn9,x0=0.5 obtained from the Newton-Raphson method. The series converges to
If the series converges to a limit L, then as n→∞, we have xn+1→L and xn→L.
Substituting L into the given recurrence relation: L=2L+8L9
Subtract 2L from both sides: 2L=8L9
Multiply both sides by 8L: 4L2=9 L2=49
Taking the square root, L=±23=±1.5.
Since x0=0.5>0, all subsequent terms xn will be positive (xn+1 is a sum of positive terms if xn is positive). Therefore, the limit L must be positive.
Thus, L=1.5.
Q28GATE 0MCQ1MTheory of Computation
A minimum state deterministic finite automaton accepting the language L={w|w ∈ {0,1}*} , number of 0s and 1s in w are divisible by 3 and 5, respectively has
Let n0(w) be the number of 0s in w and n1(w) be the number of 1s in w.
The language L requires n0(w)≡0(mod3) and n1(w)≡0(mod5).
A state in the DFA must keep track of the remainder of n0(w) modulo 3 and the remainder of n1(w) modulo 5.
Let a state be represented by an ordered pair (q0,q1), where q0=n0(w)(mod3) and q1=n1(w)(mod5).
The possible values for q0 are {0,1,2}.
The possible values for q1 are {0,1,2,3,4}.
The total number of such distinct pairs (states) is the product of the number of possible remainders: Number of states=(modulus for 0s)×(modulus for 1s)=3×5=15
All these 15 states are reachable from the initial state (0,0), and each represents a distinct equivalence class of strings, making it a minimum DFA.
The initial state is (0,0), and the only accepting state is (0,0).
Q29GATE 0MCQ1MTheory of Computation
The language L={0i21i∣i≥0} over the alphabet {0,1,2} is:
The language L={0i21i∣i≥0} is a Context-Free Language (CFL) because it can be generated by the CFG: S→0S1∣2. This grammar clearly matches the count of 0s and 1s separated by a '2'.
It is a Deterministic Context-Free Language (DCFL) because a Deterministic Pushdown Automaton (DPDA) can recognize it:
Push each '0' onto the stack.
Upon reading '2', change state.
For each '1', pop a '0' from the stack.
Accept if the stack is empty when the input ends.
This DPDA is deterministic as there is no ambiguity in transitions for any input symbol.
Since all CFLs are recursive, and DCFLs are a subset of CFLs, L is also recursive. Therefore, it is both recursive and a deterministic CFL.
A, B, and D are non-regular due to the presence of the pattern wwR, which requires matching an arbitrarily long prefix w with its reverse wR. This demands unbounded memory, which a finite automaton (FA) cannot provide. For example:
A. wwR∣win0,1+: Classic non-regular language (e.g., 0n0n).
B. wwRx∣x,win0,1+: Contains strings like 0n0n1. Pumping 0p0p1 yields 0p−k0p1, which is not in the language if k is odd.
D. xwwR∣x,win0,1+: Contains strings like 10n0n. Pumping 102p yields 102p−k, which is not in the language if k is odd.
C. wxwR∣x,win0,1+: A string s is in this language if it can be written as s=wxwR with w,x∈{0,1}+. This implies that the first character of s must be equal to its last character (s1=sn). Also, ∣w∣≥1,∣x∣≥1, so ∣s∣=∣w∣+∣x∣+∣wR∣≥1+1+1=3.
Conversely, any string s of length ≥3 where s1=sn can be written as s1(s2…sn−1)s1. We can set w=s1 and x=s2…sn−1. Since ∣s∣≥3, x is non-empty. Thus, LC={s∈{0,1}∗∣∣s∣≥3 and s1=sn}. This language is regular and can be described by the regular expression: 0(0∣1)(0∣1)∗0∪1(0∣1)(0∣1)∗1
Q31GATE 0MCQ1MDigital Logic
Let f(w,x,y,z)= Σ (0,4,5,7,8,9,13,15). Which of the following expressions are NOT equivalent to f ? (P) x'y'z' + w'xy' + wy'z + xz (Q) w'y'z' + wx'y' + xz (R) w'y'z' + wx'y' + xyz + xy'z (S) x'y'z' + wx'y' + w'y
To determine which expressions are not equivalent to f(w,x,y,z)=Σ(0,4,5,7,8,9,13,15), we first identify the minterms covered by each expression.
The minterms for f are {0,4,5,7,8,9,13,15}.
Expression (P):x′y′z′+w′xy′+wy′z+xz
x′y′z′ covers m0(0000) and m8(1000).
w′xy′ covers m4(0100) and m5(0101).
wy′z covers m9(1001) and m13(1101).
xz covers m5(0101), m7(0111), m13(1101), and m15(1111).
Total minterms covered by (P): {0,8,4,5,9,13,7,15}={0,4,5,7,8,9,13,15}.
Therefore, (P) is equivalent to f.
Expression (Q):w′y′z′+wx′y′+xz
w′y′z′ covers m0(0000) and m4(0100).
wx′y′ covers m8(1000) and m9(1001).
xz covers m5(0101), m7(0111), m13(1101), and m15(1111).
Total minterms covered by (Q): {0,4,8,9,5,7,13,15}={0,4,5,7,8,9,13,15}.
Therefore, (Q) is equivalent to f.
Expression (R):w′y′z′+wx′y′+xyz+xy′z
w′y′z′ covers m0(0000) and m4(0100).
wx′y′ covers m8(1000) and m9(1001).
xyz covers m7(0111) and m15(1111).
xy′z covers m5(0101) and m13(1101).
Total minterms covered by (R): {0,4,8,9,7,15,5,13}={0,4,5,7,8,9,13,15}.
Therefore, (R) is equivalent to f.
Expression (S):x′y′z′+wx′y′+w′y
x′y′z′ covers m0(0000) and m8(1000).
wx′y′ covers m8(1000) and m9(1001).
w′y covers m4(0100), m5(0101), m6(0110), and m7(0111).
Total minterms covered by (S): {0,8,9,4,5,6,7}.
Comparing with f's minterms {0,4,5,7,8,9,13,15}, expression (S) includes m6 (which is not in f) and misses m13 and m15.
Therefore, (S) is NOT equivalent to f.
Based on the analysis, only expression (S) is not equivalent to f.
The final answer is D
Q32GATE 0MCQ1MDigital Logic
Define the connective * for the Boolean variables X and Y as: X * Y = XY + X'Y'. Let Z= X *Y. Consider the following expressions P, Q and R. P : X = Y * Z Q :Y = X * Z R : X *Y * Z = 1 Which of the following is TRUE?
The connective ∗ is defined as X∗Y=XY+X′Y′, which is the XNOR operation.
Given Z=X∗Y.
1. Evaluate P: X=Y∗Z
Substitute Z=XY+X′Y′ into the expression: Y∗Z=Y∗(XY+X′Y′)
Using the definition of ∗: Y∗Z=Y(XY+X′Y′)+Y′(XY+X′Y′)′ Y∗Z=YXY+YX′Y′+Y′((XY)′⋅(X′Y′)′) (De Morgan's Law) Y∗Z=XY+0+Y′((X′+Y′)(X+Y)) Y∗Z=XY+Y′(X′X+X′Y+Y′X+Y′Y) Y∗Z=XY+Y′(0+X′Y+Y′X+0) Y∗Z=XY+X′YY′+XYY′ Y∗Z=XY+0+XY′ Y∗Z=X(Y+Y′)=X⋅1=X.
So, P is true.
2. Evaluate Q: Y=X∗Z
Since the operation ∗ is commutative (X∗Y=Y∗X), and Z=X∗Y, the expression Y=X∗Z is symmetric to X=Y∗Z.
Following the same algebraic steps as for P, by interchanging X and Y: X∗Z=X∗(XY+X′Y′) X∗Z=X(XY+X′Y′)+X′(XY+X′Y′)′ X∗Z=XY+Y(X+X′)=Y.
So, Q is true.
3. Evaluate R: X∗Y∗Z=1
Substitute Z=X∗Y: X∗Y∗Z=(X∗Y)∗(X∗Y).
Let A=X∗Y. The expression becomes A∗A.
Using the definition of ∗ for A∗A: A∗A=AA+A′A′
Since for any Boolean variable A, AA=A and A′A′=A′, we have: A∗A=A+A′. A+A′=1 for any Boolean variable A.
So, R is true.
All expressions P, Q, and R are true.
The final answer is D
Q33GATE 0MCQ1MDigital Logic
Suppose only one multiplexer and one inverter are allowed to be used to implement any Boolean function of n variables. What is the minimum size of the multiplexer needed?
To implement any Boolean function of n variables using a multiplexer, we can use n−1 of the variables as select lines and the remaining one variable as an input to the data lines.
Let the n variables be X1,X2,…,Xn.
We choose n−1 variables, say X1,…,Xn−1, to be the select lines for the multiplexer.
A multiplexer with n−1 select lines requires 2n−1 data input lines.
The output of the multiplexer will be F(X1,…,Xn). For each of the 2n−1 combinations of X1,…,Xn−1, the output must correspond to one of the four possible functions of the remaining variable Xn:
0 (constant 0)
1 (constant 1)
Xn
Xnˉ
Since we are allowed one inverter, we can generate Xnˉ from Xn. The constants 0 and 1 are readily available.
Therefore, for each of the 2n−1 data inputs, we can connect it to 0, 1, Xn, or Xnˉ as required to implement the function. This configuration covers all possible Boolean functions of n variables.
To see why 2n−2-to-1 is insufficient: if we use n−2 select lines, there would be two remaining variables, say Xn−1 and Xn. Each data input would need to implement a Boolean function of these two variables. There are 222=16 possible functions of two variables (e.g., Xn−1⋅Xn, Xn−1+Xn, XOR, etc.). However, with only one allowed inverter for the entire circuit, we can only provide 0,1,Xn−1,Xn−1ˉ,Xn,Xnˉ as inputs. We cannot form general two-variable functions like Xn−1Xn or Xn−1+Xn without additional gates.
Thus, the minimum size of the multiplexer needed is 2n−1 line to 1 line.
Q34GATE 0MCQ1MDigital Logic
In a look-ahead carry generator, the carry generate function i G and the carry propagate function Pi for inputs Ai and Bi are given by: Pi=Ai⨁BiandGi=AiBi The expressions for the sum bit Si and the carry bit Ci+1 of the look-ahead carry Combinational Circuit are given by: Si=Pi⨁CiandCi+1=Gi+PiCi Consider a two-level logic implementation of the look-ahead carry generator. Assume that all Pi and Gi are available for the carry generator circuit and that the AND and OR gates can have any number of inputs. The number of AND gates and OR gates needed to implement the look-ahead carry generator for a 4-bit Combinational Circuit with and S3,S2,S1,S0 as C4 its outputs are respectively:
The look-ahead carry generator computes the carry bits (C1,C2,C3,C4) based on the propagate (Pi) and generate (Gi) functions and the initial carry (C0). We are given that Pi and Gi are available, so their gate count is not included. The sum bits Si are typically generated using XOR gates (Si=Pi⨁Ci). In the context of a "two-level logic implementation" asking for "AND gates and OR gates," XOR gates for sums are generally not counted or are assumed to be separate, as they would involve more than two levels if decomposed into AND/OR gates with complements. Thus, we only count gates for the carry logic.
The carry equations are derived as follows: C1=G0+P0C0 C2=G1+P1C1=G1+P1G0+P1P0C0 C3=G2+P2C2=G2+P2G1+P2P1G0+P2P1P0C0 C4=G3+P3C3=G3+P3G2+P3P2G1+P3P2P1G0+P3P2P1P0C0
Now, we count the AND and OR gates for each carry output:
For C1: 1 AND gate (P0C0), 1 OR gate.
For C2: 2 AND gates (P1G0, P1P0C0), 1 OR gate.
For C3: 3 AND gates (P2G1, P2P1G0, P2P1P0C0), 1 OR gate.
For C4: 4 AND gates (P3G2, P3P2G1, P3P2P1G0, P3P2P1P0C0), 1 OR gate.
Total number of AND gates = 1+2+3+4=10.
Total number of OR gates = 1+1+1+1=4.
Q35GATE 0MCQ1MDigital Logic
The control signal functions of a 4-bit binary counter are given below (where X is "don't care"): Assume that the counter and gate delays are negligible. If the counter starts at 0, then it cycles through the following sequence:
Analyze Control Signals: Count=1 and Load=0 are fixed. The counter will Count next unless Clear=1.
Determine Clear Condition: The Clear input is fed by an AND gate. Observing the diagram carefully, the inputs to the AND gate are connected to outputs A3 and A1 (indicated by black dots on the respective lines). Thus, Clear = A3 AND A1.
Trace Sequence (assuming A4 is MSB and A1 is LSB):
5 (01012): A3=1,A1=1⟹Clear=1∧1=1. The counter's Clear input becomes 1, resetting it to 0 instantaneously (as per "negligible delays" and standard asynchronous clear behavior).
The counter sequences through states 0, 1, 2, 3, 4. When it reaches 5, it is immediately cleared back to 0. Therefore, 5 is not a stable state in the cycle.
The final answer is C
Q36GATE 0MCQ1MComputer Organization
Consider a pipelined processor with the following four stages: IF: Instruction Fetch ID: Instruction Decode and Operand Fetch EX: Execute WB: Write Back The IF, ID and WB stages take one clock cycle each to complete the operation. The number of clock cycles for the EX stage depends on the instruction. The ADD and SUB instructions need 1 clock cycle and the MUL instruction needs 3 clock cycles in the EX stage. Operand forwarding is used in the pipelined processor. What is the number of clock cycles taken to complete the following sequence of instructions? ADD R2, R1, R0 (R2 ← R1 + R0) MUL R4, R3, R2 (R4 ← R3 * R2) SUB R6, R5, R4 (R6 ← R5 - R4)
Let's trace the execution of the instructions cycle by cycle, considering operand forwarding and variable EX stage latencies:
I1: ADD R2, R1, R0 (EX stage is 1 cycle)
CC1: I1.IF
CC2: I1.ID
CC3: I1.EX (R2 is available for forwarding at the end of CC3)
CC4: I1.WB
I2: MUL R4, R3, R2 (EX stage is 3 cycles)
CC2: I2.IF (starts after I1.IF)
CC3: I2.ID (needs R2. R2 is forwarded from I1.EX in the same cycle. No stall.)
CC4: I2.EX (1/3)
CC5: I2.EX (2/3)
CC6: I2.EX (3/3) (R4 is available for forwarding at the end of CC6)
CC7: I2.WB
I3: SUB R6, R5, R4 (EX stage is 1 cycle)
CC3: I3.IF (starts after I2.IF)
CC4: I3.ID (needs R4. R4 is being computed by I2.EX and will be ready at the end of CC6.)
Since R4 is not available from I2 until the end of CC6, I3's EX stage must stall.
CC5: I3.STALL (waiting for R4)
CC6: I3.STALL (waiting for R4)
CC7: I3.EX (R4 is forwarded from I2's EX stage that completed at the end of CC6)
CC8: I3.WB
The last instruction (I3) completes its Write Back stage at clock cycle 8.
The final answer is 8
Q37GATE 0MCQ1MData Structure
The following postfix expression with single digit operands is evaluated using a stack: 8 2 3 ^ / 2 3 * + 5 1 * - Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing? Note that '-' denotes an empty location in the table.
Insert 8: h(8)=(3×8+4)(mod7)=28(mod7)=0. Index 0 is occupied by 1.
Probe 1: (0+1)(mod7)=1. Index 1 is empty. Insert 8 at index 1.
Table: [1, 8, -, -, -, -, 3]
Insert 10: h(10)=(3×10+4)(mod7)=34(mod7)=6. Index 6 is occupied by 3.
Probe 1: (6+1)(mod7)=0. Index 0 is occupied by 1.
Probe 2: (0+1)(mod7)=1. Index 1 is occupied by 8.
Probe 3: (1+1)(mod7)=2. Index 2 is empty. Insert 10 at index 2.
Final table: [1, 8, 10, -, -, -, 3]
Q40GATE 0MCQ1MAlgorithm
In an unweighted, undirected connected graph, the shortest path from a node S to every other node is computed most efficiently, in terms of time complexity, by
In an unweighted graph, Breadth-First Search (BFS) systematically explores the graph layer by layer, ensuring that all nodes at distance k from the source are visited before any node at distance k+1. This property guarantees that the first time a node is discovered, the path taken is a shortest path. Its time complexity is O(V+E), which is optimal for this problem. Dijkstra's algorithm is designed for weighted graphs and, while correct for unweighted graphs, is generally less efficient than BFS. Warshall's algorithm computes all-pairs shortest paths and has a higher complexity of O(V3). Depth-First Search (DFS) does not guarantee finding shortest paths.
Q41GATE 0MCQ1MC Programming
Consider the following C function: #include < stdio.h >
int f(int n) {
static int r = 0;
if (n <= 0) return 1;
if (n > 3) {
r = n;
return f(n-2)+2;
}
return f(n-1)+r;
}
f(3): n=3 \ngtr 3. Returns f(2) + r. (current r=5)
f(2): n=2 \ngtr 3. Returns f(1) + r. (current r=5)
f(1): n=1 \ngtr 3. Returns f(0) + r. (current r=5)
f(0): n=0 ≤ 0. Returns 1.
Substituting back:
f(1) evaluates to 1+5=6.
f(2) evaluates to 6+5=11.
f(3) evaluates to 11+5=16.
f(5) evaluates to 16+2=18.
The final result is 18.
Q42GATE 0MCQ1MData Structure
A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41, and I = 10, what is the value of n?
In a complete n-ary tree, every internal node has exactly n children. The total number of children produced by all internal nodes is I⋅n. These children comprise all nodes in the tree except the root. Thus, the total number of children is also (I−1)+L.
Therefore, we have the formula: I⋅n=(I−1)+L
Given L=41 and I=10, substitute these values into the formula: 10⋅n=(10−1)+41 10n=9+41 10n=50
Solving for n: n=1050=5
Q43GATE 0MCQ1MAlgorithm
In the following C function, let n ≥ m.
int gcd(n,m) {
if (n%m ==0) return m;
n = n%m;
return gcd(m,n);
}
How many recursive calls are made by this function?
The given function gcd(n,m) implements the Euclidean algorithm. In each recursive step, the larger number is replaced by the smaller number, and the smaller number is replaced by the remainder of their division.
Let the sequence of calls be (n0,m0),(n1,m1),…,(nk,mk).
Initially, (n0,m0)=(n,m).
The function makes a recursive call gcd(m, n%m). So, (n1,m1)=(m,n%m).
In general, (ni+1,mi+1)=(mi,ni%mi). This is the standard form of the Euclidean algorithm.
Lamé's theorem states that the number of steps (divisions or recursive calls) required by the Euclidean algorithm for inputs (n,m) with n≥m is at most 5×(number of digits of m). More formally, the number of steps is O(logm).
Since m≤n, the number of recursive calls is bounded by O(logn).
For a tight bound, consider the worst-case scenario, which occurs when n and m are consecutive Fibonacci numbers, say n=Fk and m=Fk−1. In this case, the number of recursive calls is proportional to k. Since Fk≈ϕk/5 (where ϕ is the golden ratio), we have k≈logϕ(Fk5). Thus, the number of calls is Θ(logFk), which is Θ(logn).
Therefore, the number of recursive calls is Θ(logn).
The final answer is A.
Q44GATE 0MCQ1MAlgorithm
What is the Asymptotic Notation of the following recursive function:
int DoSomething (int n) {
if (n <= 2) return 1;
else return (DoSomething (floor(sqrt(n))) + n);
}
To derive the given asymptotic notation, we consider the recurrence relation for the function.
The function is int DoSomething (int n) { if (n <= 2) return 1; else return (DoSomething (floor(sqrt(n))) + n); }.
For the target answer Θ(log2log2n), the additive term n must be effectively a constant, implying the question asks for the number of recursive calls or a scenario where the work per step is constant.
Thus, the recurrence relation is modeled as: T(n)=T(⌊n⌋)+1
Let n=2m. Then ⌊n⌋≈n=2m/2.
Substituting this into the recurrence: T(2m)=T(2m/2)+1
Let S(m)=T(2m). The recurrence becomes: S(m)=S(m/2)+1
This is a standard recurrence relation that solves to S(m)=Θ(logm).
Finally, substitute back m=log2n: T(n)=Θ(log(log2n))=Θ(log2log2n)
Q45GATE 0MCQ1MData Structure
Consider the following C program segment where CellNode represents a node in a binary tree: struct CellNode { struct CellNOde *leftChild; int element; struct CellNode *rightChild; };
int GetValue(struct CellNode *ptr) {
int value = 0;
if (ptr != NULL) {
if ((ptr->leftChild == NULL) && (ptr->rightChild == NULL)) value = 1;
else value = value + GetValue(ptr->leftChild) + GetValue(ptr->rightChild);
}
return(value);
}
The value returned by GetValue when a pointer to the root of a binary tree is passed as its argument is:
The function GetValue uses a recursive approach to traverse the binary tree.
Base case 1: If ptr is NULL, it returns 0. This means null children do not contribute to the count.
Base case 2: If ptr is not NULL AND both ptr->leftChild and ptr->rightChild are NULL, the node is a leaf node. In this case, value is set to 1.
Recursive step: If ptr is not a leaf node (i.e., it's an internal node), it recursively calls GetValue for its left and right children and sums their returned values.
This logic effectively counts 1 for each leaf node and sums these counts up the tree, ignoring internal nodes themselves but including their children's contributions.
Q46GATE 0MCQ1MData Structure
Consider the process of inserting an element into a Max Heap, where the Max Heap is represented by an array. Suppose we perform a binary search on the path from the new leaf to the root to find the position for the newly inserted element, the number of comparisons performed is:
When inserting an element into a Max Heap, it is initially placed at the next available leaf position. The path from this new leaf to the root has a length equal to the height of the heap. For a heap with n elements, the height is Θ(logn).
Let L be the length of this path. Thus, L=Θ(logn).
Performing a binary search on a path of length L requires Θ(logL) comparisons.
Substituting the value of L, the number of comparisons is Θ(log(logn)).
Q47GATE 0MCQ1MDatabase Management System
Which of the following is TRUE about formulae in Conjunctive Normal Form?
Let F be a Conjunctive Normal Form (CNF) formula with m clauses, C1,…,Cm.
Consider a random truth assignment where each variable is assigned 'true' with probability 1/2 independently.
For any non-empty clause Cj, it is false only if all its literals are false. The probability of this is P(Cj is false)=(1/2)kj (where kj is the number of literals in Cj), so P(Cj is true)=1−(1/2)kj. Since kj≥1, P(Cj is true)≥1−1/2=1/2.
Let S be the total number of true clauses. The expected number of true clauses is E[S]=∑j=1mP(Cj is true)≥∑j=1m(1/2)=m/2.
By the probabilistic method, since the expected number of true clauses is at least m/2, there must exist at least one specific truth assignment for which at least half the clauses evaluate to true.
Q48GATE 0MCQ1MAlgorithm
Let w be the minimum weight among all edge weights in an undirected connected graph. Let e be a specific edge of weight w . Which of the following is FALSE?
Let w be the minimum edge weight in the graph, and e be an edge with weight w.
Option D states that e is present in every minimum spanning tree. This is false.
Consider a graph with three vertices A,B,C. Let the edges be (A,B), (B,C), and (A,C), and assign each edge a weight of w=1. Thus, the minimum edge weight is w=1.
Let e=(A,B) be the specific edge of weight w.
There are three possible minimum spanning trees (MSTs) for this graph, each having a total weight of 1+1=2:
T1={(A,B),(B,C)}: This MST contains the edge e=(A,B).
T2={(A,C),(B,C)}: This MST does not contain the edge e=(A,B).
T3={(A,B),(A,C)}: This MST contains the edge e=(A,B).
Since there exists at least one minimum spanning tree (T2) that does not contain e=(A,B), the statement "e is present in every minimum spanning tree" is false.
Q49GATE 0MCQ1MData Structure
An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is TRUE about the number of comparisons needed?
To find the maximum and minimum of n numbers (where n is even) optimally:
Compare elements in pairs. There are n/2 such pairs. For each pair (ai,ai+1), compare ai with ai+1. This takes n/2 comparisons. After this step, we have n/2 "smaller" elements and n/2 "larger" elements.
The true minimum must be among these n/2 "smaller" elements. Finding the minimum of these n/2 elements requires n/2−1 comparisons.
The true maximum must be among these n/2 "larger" elements. Finding the maximum of these n/2 elements requires n/2−1 comparisons.
The total number of comparisons is: 2n+(2n−1)+(2n−1)=23n−2=1.5n−2
This strategy provides an upper bound on the number of comparisons. Since it is known to be the optimal number of comparisons required (the lower bound), the statement "At most 1.5n−2 comparisons are needed" is true.
Q50GATE 0MCQ1MAlgorithm
Consider the following C code segment:
int IsPrime(n) {
int i,n;
for(i=2;i<=sqrt(n);i++) if(n%i == 0) {
printf("Not Primen");
return 0;
}
return 1;
}
Let T(n)denote the number of times the for loop is executed by the program on input n. Which of the following is TRUE?
The time complexity T(n) is determined by the number of iterations of the for loop: for(i=2; i<=sqrt(n); i++).
Upper Bound (O notation):
The loop iterates from i=2 up to ⌊n⌋. In the worst case (when n is a prime number), the loop completes all its iterations. The number of iterations in this case is ⌊n⌋−2+1=⌊n⌋−1.
Since ⌊n⌋−1≤n, we can say that T(n)=O(n).
Lower Bound (Ω notation):
The loop starts with i=2.
If n<4, then n<2. The loop condition i <= sqrt(n) (i.e., 2 <= sqrt(n)) will be false immediately, and the loop will not execute even once. For example, T(2)=0, T(3)=0.
If n≥4, then n≥2. The loop will execute at least once for i=2. For example, if n=4, i=2 satisfies 2 <= sqrt(4) and the loop runs once. If n=5, i=2 satisfies 2 <= sqrt(5) and the loop runs once (and then i becomes 3, loop condition 3 <= sqrt(5) becomes false).
Thus, for n≥4, T(n)≥1. This means T(n) is bounded below by a constant for sufficiently large n.
Therefore, T(n)=Ω(1).
Combining these, we have T(n)=O(n) and T(n)=Ω(1).
The final answer is C
Q51GATE 0MCQ1MCompiler Design
Consider the grammar with non-terminals N={ S,C,S1 }, terminals T={a,b,i,t,e}, with S as the start symbol, and the following set of rules: S→iCtSS1∣aS1→eS∣ϵC→b The grammar is NOT LL(1) because:
Statement P is false. Regular grammars can be left-recursive (e.g., A→Aa∣b), which makes them non-LL(1). LL(1) grammars cannot handle left recursion or common prefixes without transformation.
Statement Q is true. Every regular set (regular language) is a deterministic context-free language. It is a well-established fact that every deterministic context-free language can be generated by an LR(1) grammar. Thus, every regular set has an LR(1) grammar.
Q53GATE 0MCQ1MCompiler Design
In a simplified computer the instructions are: The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block: Assume that all operands are initially in memory. The final value of the computation should be in memory. What is the minimum number of MOV instructions in the code generated for this basic block?
We trace the execution, minimizing MOV instructions by keeping intermediate values in registers (R1,R2) as long as possible. The final result (t4) must be stored back to memory.
t1=a+b:
MOV a, R_1 (R1←a) - (1st MOV instruction)
ADD b, R_1 (R1←b+R1, so R1←b+a=t1)
Current state: R1=t1, R2 is free.
t2=c+d:
MOV c, R_2 (R2←c) - (2nd MOV instruction)
ADD d, R_2 (R2←d+R2, so R2←d+c=t2)
Current state: R1=t1, R2=t2.
t3=e−t2:
The instruction OP m, R_i performs val(m) OP Ri and stores the result in Ri.
We want e−t2. t2 is in R2.
SUB e, R_2 (R2←val(e)−R2, so R2←e−t2=t3)
No MOV instruction is needed for e because it's used as a direct memory operand.
Current state: R1=t1, R2=t3 (t2 is consumed).
t4=t1−t3:
The instruction OP R_j, R_i performs Rj OP Ri and stores the result in Ri.
We want t1−t3. t1 is in R1, t3 is in R2.
SUB R_1, R_2 (R2←R1−R2, so R2←t1−t3=t4)
Current state: R1=t1 (not needed after this step), R2=t4 (t3 is consumed).
Store final result t4 to memory:
MOV R_2, t_4\_mem (stores t4 from R2 to memory) - (3rd MOV instruction)
The total number of MOV instructions is 3.
Q54GATE 0MCQ1MOperating System
An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following processes: Process Execution time Arrival time P1 20 0 P2 25 15 P3 10 30 P4 15 45 What is the total waiting time for process P2?
The Shortest Remaining Time First (SRTF) algorithm is preemptive. We trace the execution:
T=0: P1 arrives (ET=20). P1 starts execution.
T=15: P2 arrives (ET=25). P1's remaining time is 20−15=5. Since P1(5) < P2(25), P1 continues. P2 waits.
T=20: P1 completes. P2 is the only ready process. P2 starts execution.
P2's first waiting period: 20−15=5 units.
T=30: P3 arrives (ET=10). P2 has run for 30−20=10 units, so its remaining time is 25−10=15. Since P3(10) < P2(15), P3 preempts P2 and starts execution. P2 waits.
T=40: P3 completes (P3 ran for 10 units). P2 resumes execution.
P2's second waiting period: 40−30=10 units.
T=45: P4 arrives (ET=15). P2 has run for 45−40=5 units, so its remaining time is 15−5=10. Since P2(10) < P4(15), P2 continues.
T=55: P2 completes (P2 ran for remaining 10 units).
Total waiting time for P2 = First waiting period + Second waiting period =5+10=15 units.
The final answer is 15.
Q55GATE 0MCQ1MOperating System
A virtual memory system uses First In First Out (FIFO) page replacement policy and allocates a fixed number of frames to a process. Consider the following statements: P: Increasing the number of page frames allocated to a process sometimes increases the page fault rate. Q: Some programs do not exhibit locality of reference. Which one of the following is TRUE?
Statement P is true due to Belady's Anomaly, where increasing page frames with FIFO can paradoxically increase page faults for certain reference strings. Statement Q is true because not all programs exhibit strong temporal or spatial locality of reference; some access memory randomly or in non-sequential patterns. However, Belady's Anomaly (P) is a characteristic of the FIFO algorithm's interaction with specific access patterns, not directly caused by a lack of program locality (Q).
Q56GATE 0MCQ1MOperating System
A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?
Calculate initial available resources.
Total resources: X=5, Y=5, Z=5.
Allocated resources: (AllocX,AllocY,AllocZ)=(1+2+2,2+0+2,1+1+1)=(5,4,3)
Initial available resources: (AvailX,AvailY,AvailZ)=(5−5,5−4,5−3)=(0,1,2)
Determine the sequence of processes that can finish.
P0 needs: (1, 0, 3). Not satisfiable by (0, 1, 2) (needs more X and Z).
P1 needs: (0, 1, 2). Satisfiable by (0, 1, 2). P1 can finish.
P2 needs: (1, 2, 0). Not satisfiable by (0, 1, 2) (needs more X and Y).
Thus, P1 finishes first.
After P1 finishes, it releases (2, 0, 1). NewAvail=(0,1,2)+(2,0,1)=(2,1,3)
With NewAvail=(2,1,3):
P0 needs: (1, 0, 3). Satisfiable by (2, 1, 3). P0 can finish.
P2 needs: (1, 2, 0). Not satisfiable by (2, 1, 3) (needs more Y).
Thus, P0 finishes next.
After P0 finishes, it releases (1, 2, 1). NewAvail=(2,1,3)+(1,2,1)=(3,3,4)
With NewAvail=(3,3,4):
P2 needs: (1, 2, 0). Satisfiable by (3, 3, 4). P2 finishes last.
The safe execution sequence is P1 → P0 → P2. Therefore, P2 finishes last.
Q57GATE 0MCQ1MOperating System
Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes: Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?
This construct ensures mutual exclusion: if P1 is in its Critical Section (CS), wants1 is true. P2, if attempting entry, will set wants2=true then busy-wait on wants1==true, thus being blocked.
However, it does not prevent deadlocks: if P1 sets wants1=true and then P2 sets wants2=true (due to interleaving), both flags are true. P1 then waits on wants2==true and P2 waits on wants1==true, leading to a deadlock where neither process can enter the CS.
Therefore, the construct ensures mutual exclusion but fails to prevent deadlocks.
Q58GATE 0MCQ1MDatabase Management System
Information about a collection of students is given by the relation studinfo( studId , name, sex). The relation enroll(studId, courseId) gives which student has enrolled for (or taken) what course(s). Assume that every course is taken by at least one male and at least one female student. What does the following relational algebra expression represent?
σsex="female" (studInfo): This selects all female students and their details.
ΠstudId (σsex="female" (studInfo)): This projects the studId of all female students. Let's call this set F.
ΠcourseId (enroll): This projects all unique courseIds. Let's call this set C.
F×C: This computes the Cartesian product, yielding all possible (studId, courseId) pairs where studId is a female student and courseId is any existing course. This represents "all female students considered for all courses."
(F×C) - enroll: This subtracts the actual enroll relation. The result contains (studId, courseId) pairs where studId is a female student, but this specific female student is not enrolled in that specific course.
ΠcourseId (...) : Finally, this projects the courseIds from the result of step 5. A courseId appears in the final result if and only if there exists at least one female student who is not enrolled in that course.
Given that "every course is taken by at least one male and at least one female student," we know that for any course, some female students are enrolled. If the expression identifies a course where "at least one female student is not enrolled," then it implies that not all female students are enrolled. Combining "some are enrolled" with "not all are enrolled" precisely describes a scenario where a proper subset of female students is enrolled in that course.
Q59GATE 0MCQ1MDatabase Management System
Consider the relation employee(name, sex, supervisorName) with name as the key. supervisorName gives the name of the supervisor of the employee under consideration. What does the following Tuple Relational Calculus query produce?
The query selects e.name for an employee(e) satisfying the condition.
The condition is: (∀x)[¬employee(x)∨x.supervisorName=e.name∨x.sex="male"]
This can be rewritten using De Morgan's laws and implication: (∀x)[employee(x)⟹(x.supervisorName=e.name∨x.sex="male")]
This means "For every employee x, if x is an employee, then x is either not supervised by e OR x is male."
Equivalently, "For every employee x, it is NOT the case that (x is supervised by e AND x is female)."
Therefore, employee e must not supervise any female employee. This means e has no immediate female subordinates.
Q60GATE 0MCQ1MDatabase Management System
Consider the table employee(empId, name, department, salary) and the two queries Q1 ,Q2 below. Assuming that department 5 has more than one employee, and we want to find the employees who get higher salary than anyone in the department 5, which one of the statements is TRUE for any arbitrary employee table? Q1 : Select e.empId From employee e Where not exists (Select * From employee s where s.department = "5" and s.salary >=e.salary) Q2 : Select e.empId From employee e Where e.salary > Any (Select distinct salary From employee s Where s.department ="5"
The requirement is to find employees whose salary is strictly greater than the maximum salary of any employee in department 5.
Q1: Select e.empId From employee e Where not exists (Select * From employee s where s.department = "5" and s.salary >=e.salary)
This query selects employees e for whom there is no employee s in department 5 with s.salary >= e.salary. This logically means for all employees s in department 5, s.salary < e.salary. This correctly identifies employees whose salary is greater than everyone in department 5.
Q2: Select e.empId From employee e Where e.salary > Any (Select distinct salary From employee s Where s.department ="5")
The ANY keyword means that e.salary must be greater than at least one salary in department 5. This is equivalent to e.salary > MIN(salary in department 5). This does not satisfy the condition of being higher than anyone (i.e., higher than the maximum).
A relation is in BCNF if for every non-trivial functional dependency X→Y, X is a superkey.
Let's analyze option D: "A prime attribute can be transitively dependent on a key in a BCNF relation."
A transitive dependency implies a chain K→A and A→P, where K is a key and P is a prime attribute. For this to be a "problematic" or notable transitive dependency, A should not be a superkey.
If A is not a superkey:
The functional dependency A→P exists.
For the relation to be in BCNF, the LHS of every functional dependency must be a superkey.
Since A is not a superkey, the FD A→P directly violates the BCNF condition, regardless of whether P is a prime attribute or not.
Therefore, a BCNF relation cannot have such a transitive dependency where the intermediate attribute A is not a superkey.
If Ais a superkey:
Then P is functionally dependent on a superkey (A). While technically a "transitive" dependency, it doesn't cause BCNF violation. However, the spirit of "transitive dependency" in the context of normalization problems usually implies that the intermediate attribute is not a superkey. If A is a superkey, A determines the entire relation schema, effectively K↔A. So, P is directly dependent on A (a superkey).
In summary, for a transitive dependency K→A→P to exist in a BCNF relation, A must be a superkey. But if A is a superkey, then P is functionally dependent on a superkey. The statement implies a scenario that would typically violate BCNF. Thus, a prime attribute cannot be transitively dependent on a key via an intermediate attribute that is not a superkey in a BCNF relation.
The final answer is D
Q62GATE 0MCQ1MDatabase Management System
The order of a leaf node in a B+ tree is the maximum number of (value, data record pointer) pairs it can hold. Given that the block size is 1K bytes, data record pointer is 7 bytes long, the value field is 9 bytes long and a block pointer is 6 bytes long, what is the order of the leaf node?
A leaf node in a B+ tree stores N (value, data record pointer) pairs and one block pointer to the next leaf node. The total size must fit within the block size.
Given:
Block size = 1024 bytes
Data record pointer (D) = 7 bytes
Value field (V) = 9 bytes
Block pointer (P) = 6 bytes
The space occupied by N pairs and one next-leaf pointer is: N×(V+D)+P≤Block Size
Substituting the given values: N×(9+7)+6≤1024 16N+6≤1024 16N≤1018 N≤161018=63.625
Since N must be an integer, the maximum number of pairs is 63.
Q63GATE 0MCQ1MDatabase Management System
Consider the following schedules involving two transactions. Which one of the following statements is TRUE? S1:r1(X);r1(Y);r2(X);r2(Y);w2(Y);w1(X)S2:r1(X);r2(X);r2(Y);w2(Y);r1(Y);w1(X)
To determine conflict serializability, we construct a precedence graph for each schedule and check for cycles. An edge Ti→Tj exists if Ti accesses an item before Tj, and at least one of these accesses is a write operation (i.e., they conflict).
For S1:r1(X);r1(Y);r2(X);r2(Y);w2(Y);w1(X):
r1(Y) and w2(Y) conflict (read-write on Y), so T1→T2.
r2(X) and w1(X) conflict (read-write on X), so T2→T1.
The precedence graph contains a cycle: T1→T2→T1. Thus, S1 is not conflict serializable.
For S2:r1(X);r2(X);r2(Y);w2(Y);r1(Y);w1(X):
r2(X) and w1(X) conflict (read-write on X), so T2→T1.
w2(Y) and r1(Y) conflict (write-read on Y), so T2→T1.
The precedence graph contains only edges T2→T1. There is no cycle. Thus, S2 is conflict serializable.
Therefore, S1 is not conflict serializable, and S2 is conflict serializable.
The final answer is C
Q64GATE 0MCQ1MComputer Network
There are n stations in a slotted LAN. Each station attempts to transmit with a probability p in each time slot. What is the probability that ONLY one station transmits in a given time slot?
Let P(transmit) be the probability a station transmits, which is p.
Let P(not transmit) be the probability a station does not transmit, which is 1−p.
For a specific station i to transmit, its probability is p.
For the remaining n−1 stations to not transmit, the probability for each is (1−p).
Since transmissions are independent, the probability that station i transmits AND all other n−1 stations do not transmit is: p×(1−p)n−1
There are n possible stations that could be the "only one" transmitting. Since these are mutually exclusive events, we sum their probabilities.
The total probability that only one station transmits is n times the probability for any specific station: n×p(1−p)n−1
Q65GATE 0MCQ1MComputer Network
In a token ring network the transmission speed is 107 bps and the propagation speed is 200 metres/ μs . The 1-bit delay in this network is equivalent to:
The time duration for one bit (Tbit) is given by the inverse of the transmission speed: Tbit=107 bps1 bit=10−7 s
The propagation speed (v) is 200 metres/μs. Converting this to metres/s: v=200 metres/μs=200×106 metres/s=2×108 metres/s
The equivalent length of cable is the product of propagation speed and the time for one bit: Length=v×Tbit=(2×108 m/s)×(10−7 s)=2×108−7 m=2×101 m=20 metres
Q66GATE 0MCQ1MComputer Network
The address of a class B host is to be split into subnets with a 6-bit subnet number. What is the maximum number of subnets and the maximum number of hosts in each subnet?
For a Class B address, the first 16 bits are for the network ID.
Given a 6-bit subnet number, the number of subnets is 26−2=64−2=62 (excluding all-zeros and all-ones subnets).
The total host bits become 32 (total bits)−16 (network bits)−6 (subnet bits)=10 host bits.
The maximum number of hosts per subnet is 210−2=1024−2=1022 (excluding the network and broadcast addresses).
Q67GATE 0MCQ1MComputer Network
The message 11001001 is to be transmitted using the CRC polynomial x3 +1 to protect it from errors. The message that should be transmitted is:
To protect the message M=11001001 using the CRC polynomial P(x)=x3+1:
Identify the generator polynomial P(x)=x3+1. Its binary representation is P=1001.
The degree of the polynomial is k=3. This means the CRC checksum will be 3 bits long.
Append k=3 zeros to the original message: M′=11001001000.
Perform binary division (XOR division) of M′ by P. We simulate a shift register:
Initialize a k-bit register (remainder R) to 000. The "reduced" divisor for XOR operations is P without its MSB, i.e., 001.
Iterate through each bit of M′ (11001001000):
Current bit 1: R (MSB is 0) →001
Current bit 1: R (MSB is 0) →011
Current bit 0: R (MSB is 0) →110
Current bit 0: R (MSB is 1) →100→100 \oplus 001 = 101
Current bit 1: R (MSB is 1) →011→011 \oplus 001 = 010
Current bit 0: R (MSB is 0) →100
Current bit 0: R (MSB is 1) →000→000 \oplus 001 = 001
Current bit 1: R (MSB is 0) →011
Current bit 0: R (MSB is 0) →110
Current bit 0: R (MSB is 1) →100→100 \oplus 001 = 101
Current bit 0: R (MSB is 1) →010→010 \oplus 001 = 011
The final remainder (CRC checksum) is 011.
Append the CRC checksum to the original message:
Transmitted message = 11001001 + 011=11001001011.
The message that should be transmitted is 11001001011.
Q68GATE 0MCQ1MComputer Network
The distance between two stations M and N is L kilometers. All frames are K bits long. The propagation delay per kilometer is t seconds. Let R bits/second be the channel capacity. Assuming that processing delay is negligible, the minimum number of bits for the sequence number field in a frame for maximum utilization, when the sliding window protocol is used, is:
For maximum utilization in a sliding window protocol, the sender window size (Ws) must be large enough to keep the channel pipeline full. This means the sender must be able to transmit frames continuously without waiting for acknowledgements.
Transmission Delay (Tt): The time it takes to transmit one frame is given by its length divided by the channel capacity. Tt=Channel CapacityFrame Length=RK seconds
Propagation Delay: The one-way propagation delay is L×t. The Round Trip Time (RTT) for propagation is: RTT=2×L×t=2Lt seconds
Dimensionless Ratio 'a': This ratio represents the number of frame transmission times that fit into one RTT. a=TtRTT=K/R2Lt=K2LtR
Minimum Sender Window Size (Ws) for Maximum Utilization: To achieve maximum utilization, the sender must transmit frames for a duration equal to or greater than the RTT before an acknowledgement for the first frame is received. The minimum window size required to keep the pipe full is 1+2a. The '1' accounts for the frame currently being transmitted, and '2a' accounts for the frames that can be sent during the RTT. Ws=1+a=1+K2LtR
This can be rewritten by finding a common denominator: Ws=KK+K2LtR=KK+2LtR
Minimum Bits for Sequence Number Field ('m'): If m bits are used for the sequence number, then 2m unique sequence numbers are available. For the sliding window protocol to function correctly and avoid ambiguity, the sender window size Ws must be less than or equal to the total sequence number space, i.e., 2m≥Ws. To find the minimum number of bits, we use the ceiling function: m=⌈log2(Ws)⌉=⌈log2(K2LtR+K)⌉
The square brackets [x] in the options typically denote the ceiling function ⌈x⌉.
The derived expression matches option C.
The final answer is C
Q69GATE 0MCQ1MComputer Network
Match the following: (P) SMTP (1) Application layer (Q) BGP (2) Transport layer (R) TCP (3) Data link layer (S) PPP (4) Network layer (5) Physical layer
SMTP (Simple Mail Transfer Protocol) is an Application layer protocol. Thus, P - 1.
BGP (Border Gateway Protocol) is a routing protocol that operates at the Network layer. Thus, Q - 4.
TCP (Transmission Control Protocol) is a Transport layer protocol, providing reliable data delivery. Thus, R - 2.
PPP (Point-to-Point Protocol) is a Data link layer protocol used for direct connection between two nodes. Thus, S - 3.
Combining these matches: P - 1, Q - 4, R - 2, S - 3, which corresponds to option B.
Q70GATE 0MCQ1MComputer Organization
Consider the following program segment. Here R1, R2 and R3 are the general purpose registers. Assume that the content of memory location 3000 is 10 and the content of the register R3 is 2000. The content of each of the memory locations from 2000 to 2010 is 100. The program is loaded from the memory location 1000. All the numbers are in decimal. Assume that the memory is word addressable. The number of memory references for accessing the data in executing the program completely is:
The program segment is analyzed for data memory references:
LOAD R1, (3000): This instruction reads the content of memory location 3000 (which is 10) into register R1. This is 1 data memory reference.
LOAD R2, #0: This loads an immediate value (0) into R2. Immediate values are typically part of the instruction itself and do not require a data memory access. So, 0 data memory references.
The loop consists of ADD R2, (R3), INC R3, DEC R1, BNZ LOOP.
R1 starts at 10 and decrements by 1 in each iteration. The BNZ LOOP instruction causes the loop to execute 10 times (when R1 is 10, 9, ..., 1).
INC R3, DEC R1, BNZ LOOP are register operations or control flow, which do not involve data memory references.
ADD R2, (R3): This instruction reads the content of the memory location pointed to by R3 (e.g., Mem[2000], Mem[2001], ..., Mem[2009]). By standard interpretation, this is 1 data memory reference per execution.
Based on standard interpretation, the total data memory references would be 1(initial LOAD)+10×1(ADD \inloop)=11.
However, the target answer is 21. To reach this answer, the ADD R2, (R3) instruction must count as 2 data memory references for each of its 10 executions.
While ADD R2, (R3) typically involves one memory read (from (R3)), achieving 2 references per iteration suggests a non-standard counting method. This could imply that, in addition to reading Mem[R3], a second data memory interaction is counted (e.g., an implicit cache line access, or a conceptual read/write of R2's value if it were memory-mapped, or a peculiar architecture where any instruction operating on a memory operand somehow incurs two distinct data memory accesses related to that operation).
Assuming each ADD R2, (R3) operation accounts for 2 data memory references:
Initial LOAD R1, (3000): 1 reference.
Loop (10 iterations) with ADD R2, (R3): 10×2=20 references.
Total data memory references = 1+20=21.
The final answer is D
Q71GATE 0MCQ1MComputer Organization
Consider the following program segment. Here R1, R2 and R3 are the general purpose registers. Assume that the content of memory location 3000 is 10 and the content of the register R3 is 2000. The content of each of the memory locations from 2000 to 2010 is 100. The program is loaded from the memory location 1000. All the numbers are in decimal. Assume that the memory is word addressable. After the execution of this program, the content of memory location 2010 is:
Initial values: R1 (not specified initially, but set by first instruction) R3=2000 M[3000]=10 M[2000] through M[2010] all contain 100.
MOV R1, (3000): R1←M[3000]⟹R1←10.
The program enters the LOOP. R1 acts as a loop counter, starting at 10 and decrementing by 1 in each iteration until it becomes 0. Thus, the loop will execute 10 times.
Let's trace the values within the loop:
Iteration 1 (R1=10): R2←M[R3]=M[2000]=100. R2←R1+R2=10+100=110. M[R3]←R2⟹M[2000]←110. R3←R3+1=2000+1=2001. R1←R1−1=10−1=9.
Since R1=0, branch to LOOP.
Iteration 2 (R1=9): R2←M[R3]=M[2001]=100. R2←R1+R2=9+100=109. M[R3]←R2⟹M[2001]←109. R3←R3+1=2001+1=2002. R1←R1−1=9−1=8.
Since R1=0, branch to LOOP.
This continues for 10 iterations.
Iteration 10 (R1=1): (At the start of this iteration, R3 would be 2000+(10−1)=2009). R2←M[R3]=M[2009]=100. R2←R1+R2=1+100=101. M[R3]←R2⟹M[2009]←101. R3←R3+1=2009+1=2010. R1←R1−1=1−1=0.
Since R1=0, the BNZ LOOP instruction will not branch, and the loop terminates.
The loop modified memory locations M[2000] through M[2009].
The memory location M[2010] was pointed to by R3after its increment in the last iteration, but no write operation was performed to M[2010] within the loop.
Therefore, the content of M[2010] remains its initial value.
The final content of memory location 2010 is 100.
Q72GATE 0MCQ1MComputer Organization
Consider the following program segment. Here R1, R2 and R3 are the general purpose registers. Assume that the content of memory location 3000 is 10 and the content of the register R3 is 2000. The content of each of the memory locations from 2000 to 2010 is 100. The program is loaded from the memory location 1000. All the numbers are in decimal. Assume that the memory is byte addressable and the word size is 32 bits. If an interrupt occurs during the execution of the instruction "INC R3", what return address will be pushed on to the stack?
The program starts at memory location 1000. Each word is 32 bits, meaning 4 bytes.
MOV R1, (3000): Starts at 1000. Size = 2 words = 8 bytes. Next instruction starts at 1000+8=1008.
MOV R2, (R3) (LOOP): Starts at 1008. Size = 1 word = 4 bytes. Next instruction starts at 1008+4=1012.
ADD R2, R1: Starts at 1012. Size = 1 word = 4 bytes. Next instruction starts at 1012+4=1016.
MOV (R3), R2: Starts at 1016. Size = 1 word = 4 bytes. Next instruction starts at 1016+4=1020.
INC R3: Starts at 1020. Size = 1 word = 4 bytes.
If an interrupt occurs during INC R3, the return address saved on the stack is the address of the instruction immediately following INC R3. This is the starting address of DEC R1, which is 1020+4=1024.
Q73GATE 0MCQ1MTheory of Computation
Consider the following Finite State Automaton: The language accepted by this automaton is given by the regular expression
To reach an accepting state (q1 or q2), the automaton must transition from q0 to q1 by reading an 'a'. Before this, any number of 'b's can be read at q0. Thus, the initial part of any accepted string must be of the form b∗a.
Once in q1 (an accepting state), consider the possible subsequent strings:
From q1, reading 'b' keeps the automaton in q1 (accepting).
From q1, reading 'a' moves the automaton to q2 (also an accepting state).
From q2, reading 'b' keeps the automaton in q2 (accepting).
From q2, reading 'a' moves the automaton to q1 (also an accepting state).
Since q1 and q2 are both accepting states and any input symbol ('a' or 'b') from either of these states leads to an accepting state, any sequence of 'a's and 'b's can be appended after reaching q1, and the string will remain accepted. This pattern is represented by (a+b)∗.
The state q3 is unreachable as it has no incoming transitions from any other state. Therefore, it does not affect the language accepted by this automaton.
Combining these parts, the regular expression for the language is b∗a(a+b)∗.
The final answer is C
Q74GATE 0MCQ1MTheory of Computation
Consider the following Finite State Automaton: The minimum state automaton equivalent to the above FSA has the following number of states
To find the minimum state automaton, we first remove unreachable states, then group equivalent states.
Remove unreachable states:
q0 is the initial state, so it is reachable.
From q0, q1 is reachable (via 'a').
From q1, q2 is reachable (via 'a').
There are no incoming transitions to q3 from any other state. Thus, q3 is an unreachable state and can be removed.
The set of reachable states is {q0,q1,q2}.
Identify equivalent states using the table-filling algorithm:
Initial partition P0 groups final and non-final states: P0={{q0},{q1,q2}} (where q0 is non-final, and q1,q2 are final).
Next, we check if any states within a block are distinguishable.
Consider the block {q1,q2}:
For input 'a': δ(q1,a)=q2 and δ(q2,a)=q1. Both q1,q2 are in the same block {q1,q2}.
For input 'b': δ(q1,b)=q1 and δ(q2,b)=q2. Both q1,q2 are in the same block {q1,q2}.
Since q1 and q2 transition to states within the same block for all inputs, they are equivalent.
The partition does not refine further. P1=P0.
The equivalence classes are {q0} and {q1,q2}. Each class corresponds to a state in the minimal automaton.
Therefore, the minimum state automaton has 2 states.
Q75GATE 0MCQ1MAlgorithm
Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a, b, c, d, e, f?
To construct the Huffman code, we iteratively combine the two symbols with the lowest probabilities until a single root is formed. We assign '0' to the left branch and '1' to the right branch of each node.
The probabilities are: P(a)=21, P(b)=41, P(c)=81, P(d)=161, P(e)=321, P(f)=321.
Sort symbols by probability: f(321),e(321),d(161),c(81),b(41),a(21).
Combine e and f: Node N1 (prob 322=161). Assign e←0, f←1.
Combine d and N1: Node N2 (prob 161+161=81). Assign d←0, N1←1.
Combine c and N2: Node N3 (prob 81+81=41). Assign c←0, N2←1.
Combine b and N3: Node N4 (prob 41+41=21). Assign b←0, N3←1.
Combine a and N4: Root node (prob 21+21=1). Assign a←0, N4←1.
Tracing the paths from the root to each leaf symbol gives the codes: a:0 b:10 (from N4→b) c:110 (from N4→N3→c) d:1110 (from N4→N3→N2→d) e:11110 (from N4→N3→N2→N1→e) f:11111 (from N4→N3→N2→N1→f)
This set of codes matches Option A.
Q76GATE 0MCQ1MAlgorithm
Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. What is the average length of the Huffman code for the letters a,b,c,d,e,f?
To construct the Huffman code, we iteratively combine the two lowest probabilities until one root node remains.
Combine e(1/32) and f(1/32) to get ef(2/32=1/16).
Combine d(1/16) and ef(1/16) to get def(2/16=1/8).
Combine c(1/8) and def(1/8) to get cdef(2/8=1/4).
Combine b(1/4) and cdef(1/4) to get bcdef(2/4=1/2).
Combine a(1/2) and bcdef(1/2) to get the root.
The codeword lengths (Li) for each letter are determined by their depth in the Huffman tree: La=1, Lb=2, Lc=3, Ld=4, Le=5, Lf=5.
The average length Lˉ is calculated as ∑PiLi: Lˉ=21(1)+41(2)+81(3)+161(4)+321(5)+321(5) Lˉ=21+42+83+164+325+325 Lˉ=3216+3216+3212+328+325+325=3216+16+12+8+5+5=3262 Lˉ=1631=1.9375
Q77GATE 0MCQ1MCompiler Design
Consider the CFG with {S, A,B} as the non-terminal alphabet, {a,b} as the terminal alphabet, S as the start symbol and the following set of production rules: S → aB S → bA B → b A → a B → bS A → aS B → aBB S → bAA Which of the following strings is generated by the grammar?
The derivation for the string aabbab is as follows: S→aB aB→a(aBB)(using B→aBB) a(aBB)→aa(b)B(using B→b) aabB→aab(bS)(using B→bS) aabbS→aabb(aB)(using S→aB) aabbaB→aabba(b)(using B→b)
This yields the string aabbab.
Q78GATE 0MCQ1MCompiler Design
Consider the CFG with {S, A,B} as the non-terminal alphabet, {a,b} as the terminal alphabet, S as the start symbol and the following set of production rules: S → aB S → bA B → b A → a B → bS A → aS B → aBB S → bAA For the string "aabbab", how many derivation trees are there?
The string to be derived is "aabbab".
The only production starting with 'a' from S is S→aB. So, the first step is always S→aB.
We need to derive "abbab" from B.
Here are the two distinct derivations:
Derivation 1: S→aB →a(aBB)(using B→aBB) →aa(b)B(using B→b for the first B) →aab(bS)(using B→bS for the second B) →aabb(aB)(using S→aB) →aabba(b)(using B→b)
This derivation results in "aabbab".
Derivation 2: S→aB →a(aBB)(using B→aBB) →aa(bS)B(using B→bS for the first B) →aab(bA)B(using S→bA) →aabb(a)B(using A→a) →aabba(b)(using B→b)
This derivation also results in "aabbab".
After systematically exploring all possible expansions, these are the only two ways to derive "aabbab" from the given CFG.
The final answer is B
Q79GATE 0MCQ1MComputer Organization
Consider a machine with a byte addressable main memory of 216 bytes. Assume that a direct mapped data cache consisting of 32 lines of 64 bytes each is used in the system. A 50 x 50 two-dimensional array of bytes is stored in the main memory starting from memory location 1100H. Assume that the data cache is initially empty. The complete array is accessed twice. Assume that the contents of the data cache do not change in between the two accesses. How many data cache misses will occur in total?
The array is 50x50 bytes, so its total size is 50×50=2500 bytes.
The number of cache blocks required to store the array is ⌈642500⌉=40 blocks.
The array starts at memory location 1100H. Let Bk denote the k-th block of the array (for k=0,…,39).
The memory address of the start of Bk is Addrk=1100H+k×64.
The block number in main memory for Bk is BlockNumk=64Addrk=641100H+k=644352+k=68+k.
For a direct-mapped cache, the cache index and tag for Bk are:
Indexk=BlockNumk(mod32)=(68+k)(mod32)
Tagk=⌊32BlockNumk⌋=⌊3268+k⌋
First Access (Array accessed for the first time):
Since the cache is initially empty, every access to a new block will be a compulsory miss.
There are 40 blocks in the array, so there will be 40 misses in the first access.
Total misses for first access = 40.
After the first access, the cache will contain the blocks that were loaded and not evicted by subsequent accesses during this pass. Let's determine the final state of the cache:
For k=0…27: Indexk=(68+k)(mod32) ranges from 4(mod32)=4 to 95(mod32)=31. Tagk=⌊(68+k)/32⌋=⌊68/32⌋=2.
These 28 blocks (B0…B27) occupy cache lines 4…31 with Tag 2.
For k=28…39: Indexk=(68+k)(mod32) ranges from 96(mod32)=0 to 107(mod32)=11. Tagk=⌊(68+k)/32⌋=⌊96/32⌋=3.
These 12 blocks (B28…B39) occupy cache lines 0…11 with Tag 3.
Conflicts during the first pass:
Blocks B0…B7 (Tag 2) map to lines 4…11.
Blocks B32…B39 (Tag 3) also map to lines 4…11. Since B32…B39 are accessed afterB0…B7, and their tags are different (3 vs 2), B32…B39 will evict B0…B7 from lines 4…11.
Lines 12…31: Contain blocks B8…B27 (Tag 2), as no later blocks map to these lines. (20 blocks)
Total blocks in cache = 4+8+20=32 blocks. The cache is full.
Second Access (Array accessed for the second time):
The array is accessed again in order B0,B1,…,B39.
Access B0…B7 (8 blocks):
These blocks map to lines 4…11 with Tag 2.
Current cache lines 4…11 hold B32…B39 (Tag 3).
The tags (2 vs 3) do not match. Each access will be a miss. These 8 blocks (B0…B7) are loaded, evicting B32…B39.
Misses = 8.
Access B8…B27 (20 blocks):
These blocks map to lines 12…31 with Tag 2.
Current cache lines 12…31 already hold B8…B27 (Tag 2).
The tags match. Each access will be a hit.
Misses = 0.
Access B28…B31 (4 blocks):
These blocks map to lines 0…3 with Tag 3.
Current cache lines 0…3 already hold B28…B31 (Tag 3).
The tags match. Each access will be a hit.
Misses = 0.
Access B32…B39 (8 blocks):
These blocks map to lines 4…11 with Tag 3.
During the access of B0…B7 in this second pass, lines 4…11 were updated to hold B0…B7 (Tag 2).
The tags (3 vs 2) do not match. Each access will be a miss. These 8 blocks (B32…B39) are loaded, evicting B0…B7.
Misses = 8.
Total misses for second access = 8+0+0+8=16.
Total data cache misses = (Misses in first access) + (Misses in second access)
Total data cache misses = 40+16=56.
The final answer is 56.
Q80GATE 0MCQ1MComputer Organization
Consider a machine with a byte addressable main memory of 216 bytes. Assume that a direct mapped data cache consisting of 32 lines of 64 bytes each is used in the system. A 50 x 50 two-dimensional array of bytes is stored in the main memory starting from memory location 1100H. Assume that the data cache is initially empty. The complete array is accessed twice. Assume that the contents of the data cache do not change in between the two accesses. Which of the following lines of the data cache will be replaced by new blocks in accessing the array for the second time?
Starts at 1100H. Ends at 1100H + 2500 - 1 = 1AA3H.
The array spans memory addresses from 1100H to 1AA3H.
Identify Tags and Indices for Array Blocks:
Addresses 1100H to 17FFH: These addresses share Tag 00010 (decimal 2).
1100H (00010 00100 000000) maps to (Tag 2, Index 4).
17C0H (00010 11111 000000) maps to (Tag 2, Index 31).
Addresses 1800H to 1AA3H: These addresses share Tag 00011 (decimal 3).
1800H (00011 00000 000000) maps to (Tag 3, Index 0).
1A80H (00011 01010 000000) maps to (Tag 3, Index 10) (this block contains 1AA3H).
Cache State After First Pass:
During the first pass, blocks from 1100H to 17FFH (Tag 2) are loaded into lines 4 to 31.
Then, blocks from 1800H to 1AA3H (Tag 3) are loaded into lines 0 to 10.
For lines 4 to 10, the Tag 3 blocks overwrite the Tag 2 blocks.
For lines 0 to 3, Tag 3 blocks are loaded.
For lines 11 to 31, Tag 2 blocks remain.
Result: Lines 0-3 hold Tag 3; Lines 4-10 hold Tag 3; Lines 11-31 hold Tag 2.
Replacements in Second Pass:
The array is accessed again (1100H to 1AA3H).
Accessing Tag 2 blocks (1100H to 17FFH):
Lines 4 to 10 currently hold Tag 3. Accessing Tag 2 blocks for these lines results in a miss, and Tag 3 blocks are replaced by Tag 2 blocks.
Lines 11 to 31 currently hold Tag 2. Accessing Tag 2 blocks results in a hit. No replacement.
Accessing Tag 3 blocks (1800H to 1AA3H):
Lines 0 to 3 currently hold Tag 3. Accessing Tag 3 blocks results in a hit. No replacement.
Lines 4 to 10 now hold Tag 2 (from previous step in second pass). Accessing Tag 3 blocks for these lines results in a miss, and Tag 2 blocks are replaced by Tag 3 blocks.
Conclusion: The lines replaced during the second access are 4, 5, 6, 7, 8, 9, 10. This is "line 4 to line 10". Since this exact range is not an option, and option A ("line 4 to line 11") is the smallest provided range that includes all replaced lines, we select A. Line 11 is not replaced as it always holds Tag 2 and is only accessed by Tag 2 blocks within the array's range.
The final answer is A
Q81GATE 0MCQ1MOperating System
A process has been allocated 3 page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequence of page references (reference string): 1, 2, 1, 3, 7, 4, 5, 6, 3, 1. If optimal page replacement policy is used, how many page faults occur for the above reference string?
The Optimal page replacement policy replaces the page that will not be used for the longest period of time in the future.
1, 2, 1, 3:
1: Fault. Frames: [1, _, _]
2: Fault. Frames: [1, 2, _]
1: Hit. Frames: [1, 2, _]
3: Fault. Frames: [1, 2, 3]
(Total faults: 3)
7: Page 2 is replaced as it's not used again. Frames: [1, 7, 3]. (Faults: 1, Total: 4)
4: Page 7 is replaced as it's not used again. Frames: [1, 4, 3]. (Faults: 1, Total: 5)
5: Page 4 is replaced as it's not used again. Frames: [1, 5, 3]. (Faults: 1, Total: 6)
6: Page 5 is replaced as it's not used again. Frames: [1, 6, 3]. (Faults: 1, Total: 7)
3, 1: These are hits in the current frames [1, 6, 3]. (Faults: 0, Total: 7)
The total number of page faults is 7.
Q82GATE 0MCQ1MOperating System
A process has been allocated 3 page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequence of page references (reference string): 1, 2, 1, 3, 7, 4, 5, 6, 3, 1. Least Recently Used (LRU) page replacement policy is a practical approximation to optimal page replacement. For the above reference string, how many more page faults occur with LRU than with the optimal page replacement policy?
We calculate the number of page faults for both LRU and Optimal page replacement policies. The number of available page frames is 3. The reference string is 1,2,1,3,7,4,5,6,3,1.
1. LRU (Least Recently Used) Page Replacement Policy:
A page fault occurs if the referenced page is not in memory. If memory is full, the page that has not been used for the longest time is replaced.
2. Optimal Page Replacement Policy:
A page fault occurs if the referenced page is not in memory. If memory is full, the page that will not be used for the longest period of time in the future is replaced.
1: [1, _, _] (Fault)
2: [1, 2, _] (Fault)
1: [1, 2, _] (Hit)
3: [1, 2, 3] (Fault)
7: (Pages in memory: {1, 2, 3}. Page 2 is not used again. Replace 2) [1, 3, 7] (Fault)
4: (Pages in memory: {1, 3, 7}. Page 7 is not used again. Replace 7) [1, 3, 4] (Fault)
5: (Pages in memory: {1, 3, 4}. Page 4 is not used again. Replace 4) [1, 3, 5] (Fault)
6: (Pages in memory: {1, 3, 5}. Page 5 is not used again. Replace 5) [1, 3, 6] (Fault)
3: [1, 3, 6] (Hit)
1: [1, 3, 6] (Hit)
Total Optimal page faults = 7.
3. Difference:
The difference in page faults is 9−7=2.
The final answer is C
Q83GATE 0MCQ1MAlgorithm
Suppose that a robot is placed on the Cartesian plane. At each step it is allowed to move either one unit up or one unit right, i.e., if it is at (i,j) then it can move to either (i+1,j) or (i,j+1). How many distinct paths are there for the robot to reach the point (10,10) starting from the initial position (0,0)?
To reach point (10,10) from (0,0), the robot must make exactly 10 moves to the right and 10 moves up.
The total number of moves will be 10 (right)+10 (up)=20 moves.
This problem is equivalent to finding the number of ways to arrange 10 'R' (right) moves and 10 'U' (up) moves in a sequence of 20 moves.
This is a combination problem where we choose 10 positions out of 20 for the 'R' moves (or 'U' moves).
The number of distinct paths is given by the binomial coefficient: (1020)
This matches option A.
Q84GATE 0MCQ1MAlgorithm
Suppose that a robot is placed on the Cartesian plane. At each step it is allowed to move either one unit up or one unit right, i.e., if it is at (i,j) then it can move to either (i+1,j) or (i,j+1). Suppose that the robot is not allowed to traverse the line segment from (4,4) to (5,4). With this constraint, how many distinct paths are there for the robot to reach (10,10) starting from (0,0)?
The total number of paths from (0,0) to (10,10) without any constraints is given by selecting 10 'right' moves out of 20 total moves (10 right, 10 up): (1010+10)=(1020)
A path traverses the forbidden segment from (4,4) to (5,4) if it passes through (4,4), takes a right step to (5,4), and then continues to (10,10).
The number of paths from (0,0) to (4,4) is (44+4)=(48).
The number of paths from (5,4) to (10,10) requires 10−5=5 right moves and 10−4=6 up moves. This is (55+6)=(511).
The number of paths traversing the forbidden segment is the product of these two: (48)×(511).
Therefore, the number of distinct paths avoiding the forbidden segment is the total number of paths minus those that traverse the segment: (1020)−(48)×(511)