Exams › GATE › Technical › COMPUTER SCIENCE & INFORMATION TECH. - CS
59 questions with worked solutions.
Q1. The truth table X Y f(X,Y) 0 0 0 0 1 0 1 0 1 1 1 1 represents the Boolean function
Answer: X
The truth table shows that the output is true (1) only when X is true (1), regardless of the value of Y, which directly corresponds to the Boolean function represented by X.
Q2. The decimal value 0.5 in IEEE single precision floating point representation has
Answer: fraction bits of 000...000 and exponent value of -1
In IEEE single precision, the value 0.5 is represented with a fraction (mantissa) of all zeros, as it is exactly 1/2, and an exponent of -1, which indicates the position of the binary point. This representation aligns with the format where the exponent is adjusted to reflect the normalized form of the number.
Q3. A process executes the code fork(); fork(); fork(); The total number of child processes created is
Answer: 7
Each call to fork() creates a new process, and the number of processes doubles with each fork. After three fork calls, the total number of processes is 2³ - 1 (the original process is not counted as a child), resulting in 7 child processes.
Q4. The protocol data unit (PDU) for the application layer in the Internet stack is
Answer: Message
The application layer's protocol data unit is referred to as a 'Message' because it encompasses the data that applications send and receive, which is distinct from the transport, network, and data link layers that use segments, datagrams, and frames respectively.
Answer: 3, 4
Options 3 and 4 are correct because the complement of a regular language is always regular, and the complement of a recursive language is also recursive, making both problems decidable. In contrast, the other options involve undecidable problems.
Answer: Commutative but not associative
x(+)y = x^2*y^2 = y^2*x^2 so it is commutative. But (x(+)y)(+)z = (x^2 y^2)^2 z^2 = x^4 y^4 z^2 while x(+)(y(+)z) = x^2 (y^2 z^2)^2 = x^2 y^4 z^4, which differ, so it is not associative. Answer: commutative but not associative.
Q7. The smallest integer that can be represented by an 8-bit number in 2's complement form is
Answer: -128
In 2's complement representation, the range of an 8-bit number is from -128 to 127. The smallest integer, which is represented by setting the most significant bit to 1 (indicating a negative number) and all other bits to 0, is -128.
Answer: Priority encoder
The truth table represents a priority encoder because it outputs a binary representation of the highest-priority active input (D2, D1, D0) while indicating validity (V) when at least one input is active.
Answer: O(n)
Selection sort requires a linear number of swaps, specifically one swap for each of the n elements in the worst case, making O(n) the tightest upper bound for the number of swaps.
Answer: O(n)
The time complexity for inserting an object into a binary search tree can be O(n) in the worst case, which occurs when the tree is unbalanced and resembles a linked list, requiring traversal of all n nodes.
Q11. Consider the languages L1 = {ε} and L2 = {a}. Which one of the following represents L1 ∪ L2 ?
Answer: {ε, a}
The union of two sets includes all unique elements from both sets. Since L1 contains the empty string ε and L2 contains the string 'a', their union results in the set {ε, a}.
Answer: n-1
In a bottom-up parsing process, each reduce move corresponds to reducing a production rule, and since the parser must eventually reduce the entire input string to the start symbol, the maximum number of reduce moves is one less than the number of tokens, which is n-1.
Answer: This algorithm is equivalent to the first-come-first-serve algorithm.
The algorithm assigns priorities based on waiting time, which means that processes are scheduled in the order they arrive without preemption, similar to first-come-first-serve. Since all processes start with the same priority and there are no I/O operations, the order of execution remains unchanged, making it equivalent to FCFS.
Answer: P-3, Q-1, R-4, S-2
The correct option matches service-oriented computing with publish-find-bind (P-3), which facilitates service discovery; heterogeneous communicating systems with interoperability (Q-1), which ensures different systems can work together; information representation with XML (R-4), a standard for data encoding; and process description with BPMN (S-2), which is specifically designed for modeling business processes.
Answer: UDP, TCP, UDP and TCP
UDP is preferred for real-time multimedia due to its low latency, while TCP is used for file transfer and email because it ensures reliable delivery. DNS also uses UDP for quick query responses.
Answer: Encryption: X's private key followed by Y's public key; Decryption: Y's private key followed by X's public key
The correct option involves X using their private key to create a digital signature, ensuring authenticity, and then encrypting the message with Y's public key, which ensures that only Y can decrypt it with their private key. This sequence maintains both the integrity of the message and the confidentiality of its content.
Answer: Network layer - 4 times and Data link layer - 6 times
Each packet must pass through the network layer at the source, each router, and the destination, totaling four visits to the network layer. Additionally, the packet must traverse the data link layer at the source, each router, and the destination, resulting in six visits to the data link layer.
Q18. An index is clustered, if
Answer: the data records of the file are organized in the same order as the data entries of the index.
A clustered index organizes the actual data records in the database according to the order of the index entries, allowing for efficient data retrieval based on the indexed fields.
Answer: X: P(b)P(a)P(c) Y: P(b)P(c)P(d) Z: P(a)P(c)P(d)
The correct option avoids circular wait conditions by ensuring that each process acquires semaphores in a consistent order. By having X acquire b before a, Y acquire b before c, and Z acquire a before c, it prevents any possibility of deadlock since no process will hold a semaphore while waiting for another that is held by a different process.
Answer: 2 only
Statement 2 is false because Turing recognizable languages are not closed under complementation; while they are closed under union, the complement of a recognizable language may not be recognizable.
Answer: 1, 2 and 3
All three statements are true: the cycle detection problem in undirected graphs can be solved in polynomial time (thus in P), the directed graph cycle problem is verifiable in polynomial time (hence in NP), and NP-Complete problems are defined by the existence of non-deterministic polynomial time algorithms.
Answer: Θ(n³)
The Bellman-Ford algorithm has a time complexity of Θ(n * m), where n is the number of vertices and m is the number of edges. In a complete graph, the number of edges m is Θ(n²), leading to a total time complexity of Θ(n³).
Answer: (j mod v) * k to (j mod v) * k + (k-1)
The correct option accurately describes how a main memory block is mapped to a specific range of cache lines in a k-way set associative cache. It indicates that the block indexed by j can occupy any of the k lines within the set determined by the modulo operation with v, ensuring that the mapping adheres to the structure of the cache.
Q24. Which one of the following expressions does NOT represent exclusive NOR of x and y?
Answer: x ⊕ y
The expression x ⊕ y represents the exclusive OR (XOR) operation, which outputs true when exactly one of the inputs is true, while exclusive NOR (XNOR) outputs true when both inputs are the same. Therefore, x ⊕ y does not represent exclusive NOR.
Answer: 7
There are C(8,3)=56 vertex triples; each forms a triangle with probability (1/2)^3=1/8. Expected triangles = 56*(1/8) = 7. Stored '1' is wrong; correct is 7.
Answer: Both P and Q
In undirected graphs, the sum of the degrees of all vertices is always even because each edge contributes two to the total degree count. Additionally, the number of vertices with an odd degree must be even due to the Handshaking Lemma, which states that the sum of the degrees is equal to twice the number of edges.
Answer: P only
The statement P is true because the line graph of a cycle retains the cyclic structure, where each edge corresponds to a vertex in the line graph, and edges in the original cycle connect these vertices in a cyclic manner. The other statements do not hold true universally for their respective graph types.
Q28. What is the logical translation of the following statement? "None of my friends are perfect."
Answer: ∀x [F x ⊃ ¬P x]
The correct option states that for all individuals x, if x is a friend, then x is not perfect. This accurately captures the meaning of the original statement that none of the friends possess perfection.
Answer: 1284
Sectors per cylinder = 16*64 = 1024. File = 42797 KB / 0.5 KB = 85594 sectors. Start linear address = 1200*1024 + 9*64 + 40 = 1229416; last = 1229416 + 85594 - 1 = 1315009; cylinder = 1315009 / 1024 = 1284.
Answer: Θ(n² log n)
Outer loop runs about n/2 times, inner loop (j doubling to n) runs log2(n) times, and each iteration adds n/2. Total return value ~ (n/2)(log n)(n/2) = Theta(n^2 log n).
Answer: I, II, III and IV
All four options accurately express the requirement to find distinct student names who scored above 90% in course 107, using different representations of relational algebra and SQL, thus confirming their equivalence.
Answer: 2
The maximum length of the cable is determined by the propagation delay and the transmission time of the frames. Given the data rate and frame size, the transmission time is 0.02 seconds, and with a signal speed of 200,000 km/s, the maximum distance that can be covered without collisions is 2 km.
Answer: Last fragment, 2400 and 2759
The M bit being 0 indicates that this is the last fragment. The HLEN of 10 means the header is 40 bytes, and with a total length of 400 bytes, the payload is 360 bytes. The fragment offset of 300 indicates that the first byte of the payload starts at byte 2400 (300 * 8) and ends at byte 2759 (2400 + 360 - 1), confirming the correct option.
Answer: 6561
Because x is passed by reference, all recursive frames share it. The recursion increments x to 6,7,8,9 until c reaches 0, so at unwind x=9 everywhere; the product is 1 * 9 * 9 * 9 * 9 = 9^4 = 6561, not 161051.
Answer: 15, 10, 23, 25, 20, 35, 42, 39, 30
The postorder traversal visits the left subtree, then the right subtree, and finally the root node. In this case, the sequence correctly reflects that order, with the root (30) appearing last after all left and right children have been processed.
Answer: Θ(n)
The worst-case time complexity is Θ(n) because each Dequeue operation takes constant time, and even if MultiDequeue attempts to dequeue up to k elements, it will only process as many elements as are present in the queue, which is n in total.
Answer: 165
The total time to complete the program is calculated by considering the pipeline stages and the delays, including the impact of the branch instruction. Since the branch is taken during the execution of I4, it causes a stall that adds extra cycles, resulting in a total time of 165 ns for the execution of all 12 instructions.
Answer: 8
With a 4-byte PTE the entries per page are 2^(p-2), so each level uses p-2 index bits and the first-level table fits one page. The VPN has 46-p bits = 3(p-2), giving p=13, i.e. an 8 KB page. The stored 4 KB is wrong.
Answer: 1, 2 and 3
All three statements are true: determining the existence of a cycle in an undirected graph can be solved in polynomial time (making it in P), it is also verifiable in polynomial time (placing it in NP), and NP-Complete problems have non-deterministic polynomial time algorithms, which is a defining characteristic.
Answer: 2 only
Statements 1, 3, and 4 are true. Statement 2 is false: Turing-recognizable (RE) languages are closed under union but NOT under complementation. So only statement 2 is false.
Answer: the data records of the file are organized in the same order as the data entries of the index.
A clustered index organizes the actual data records in the database table in the same order as the index entries, allowing for faster retrieval of data since the physical storage aligns with the logical ordering of the index.
Answer: Encryption: X's private key followed by Y's public key; Decryption: X's public key followed by Y's private key
The correct option involves encrypting the message with X's private key to create a digital signature, ensuring authenticity, and then using Y's public key to encrypt the entire package for confidentiality. During decryption, Y uses their private key to access the message and X's public key to verify the signature, confirming that the message originated from X.
Q43. Consider the languages L1 = ∅ and L2 = {a, ε}. Which one of the following represents L1 ∪ L2 ?
Answer: {ε, a}
The union of L1 and L2 combines all elements from both languages. Since L1 is empty and L2 contains the elements {a, ε}, the result of L1 ∪ L2 is simply {ε, a}.
Answer: Neither commutative nor associative
The operation ⊕ is not commutative because x ⊕ y = x² - y² is not equal to y ⊕ x = y² - x² for all integers x and y. It is also not associative since (x ⊕ y) ⊕ z does not equal x ⊕ (y ⊕ z) when calculated, demonstrating that the grouping of operations affects the result.
Answer: 6561
x is passed by reference to p throughout, while c (by value) counts 5->4->3->2->1->0, incrementing the shared p four times from 5 to 9. The base case returns 1, and each of the four returns multiplies by the final shared value 9, giving 9^4 = 6561.
Answer: Θ(n² log n)
The function has two nested loops: the outer loop runs for n/2 to n, which is Θ(n), and the inner loop runs logarithmically with respect to n (specifically, it doubles j each iteration). Therefore, the total complexity is the product of these two, resulting in Θ(n² log n).
Answer: 1284
To find the cylinder number of the last sector, first calculate the total number of sectors needed for the file size of 42797 KB, which is 42797 * 1024 bytes. This results in 83,000 sectors. Starting from the initial location <1200, 9, 40>, the last sector will be located at <1200 + (83000 / 64), 9, (40 + (83000 % 64))>. This calculation leads to the last sector being in cylinder 1284.
Answer: Priority encoder
The truth table represents a priority encoder because it outputs a binary code corresponding to the highest-priority active input, indicating which input is valid. This function is distinct from decoders, multiplexers, and demultiplexers, which serve different roles in digital logic.
Answer: Both P and Q
In undirected graphs, the sum of the degrees of all vertices is always even because each edge contributes two to the total degree count. Additionally, the number of vertices with odd degrees must be even due to the Handshaking Lemma, which states that the sum of the degrees of all vertices is equal to twice the number of edges.
Answer: Network layer - 4 times and Data link layer - 6 times
Each packet must traverse the network layer at the source and each router, totaling four visits. Additionally, the data link layer is engaged at the source, each router, and the destination, resulting in six visits overall.