StreakPeaked· Practice

ExamsGATETechnical › Computer Science and Information Technology Set-2

GATE Technical: Computer Science and Information Technology Set-2 questions with solutions

21 questions with worked solutions.

Questions

Q1. A certain processor uses a fully associative cache of size 16 kB. The cache block size is 16 bytes. Assume that the main memory is byte addressable and uses a 32-bit address. How many bits are required for the Tag and the Index fields respectively in the addresses generated by the processor?

  1. 24 bits and 0 bits
  2. 28 bits and 4 bits
  3. 24 bits and 4 bits
  4. 28 bits and 0 bits

Answer: 28 bits and 0 bits

Block size 16 bytes needs 4 offset bits; a fully associative cache has zero index bits since any block maps anywhere. Tag = 32 - 4 - 0 = 28 bits. So 28 bits tag and 0 bits index, which is the last option, not '24 and 0'.

Q2. Which one of the following kinds of derivation is used by LR parsers?

  1. Leftmost
  2. Leftmost in reverse
  3. Rightmost
  4. Rightmost in reverse

Answer: Rightmost in reverse

LR parsers utilize a rightmost in reverse derivation because they construct the parse tree from the leaves up to the root, effectively processing the input from the end to the beginning, which aligns with the rightmost derivation approach.

Q3. In 16-bit 2’s complement representation, the decimal number −28 is:

  1. 1111 1111 0001 1100
  2. 0000 0000 1110 0100
  3. 1111 1111 1110 0100
  4. 1000 0000 1110 0100

Answer: 1111 1111 1110 0100

The correct option represents the 2's complement of the positive value 28, which is calculated by first converting 28 to binary (0000 0000 0001 1100), then inverting the bits and adding 1, resulting in 1111 1111 1110 0100 for -28 in 16-bit representation.

Q4. Let U = {1,2,...,n}. Let A = {(x,X)|x ∈ X, X ⊆ U}. Consider the following two statements on |A|. I. |A| = n2^(n−1) II. |A| = ∑(k=1 to n) k C(n,k) Which of the above statements is/are TRUE?

  1. Only I
  2. Only II
  3. Both I and II
  4. Neither I nor II

Answer: Both I and II

Both statements are true because they represent different ways to count the number of pairs (x, X) where x is an element of the subset X of U. The first statement counts all possible subsets and their elements, while the second uses combinatorial counting to arrive at the same total.

Q5. Which one of the following is NOT a valid identity?

  1. (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z)
  2. (x + y) ⊕ z = x ⊕ (y + z)
  3. x ⊕ y = x + y, if xy = 0
  4. x ⊕ y = (xy + x'y')'

Answer: (x + y) ⊕ z = x ⊕ (y + z)

Option B is incorrect because it misapplies the properties of the XOR operation (⊕) and addition (+). Unlike addition, XOR does not distribute over addition, making this identity invalid.

Q6. If L is a regular language over Σ = {a, b}, which one of the following languages is NOT regular?

  1. L · L^R = {xy | x ∈ L, y^R ∈ L}
  2. {ww^R | w ∈ L}
  3. Prefix(L) = {x ∈ Σ* | ∃y ∈ Σ* such that xy ∈ L}
  4. Suffix(L) = {y ∈ Σ* | ∃x ∈ Σ* such that xy ∈ L}

Answer: {ww^R | w ∈ L}

The language {ww^R | w ∈ L} is not regular because it requires matching a string with its reverse, which cannot be done by a finite automaton, as it lacks the memory to store an arbitrary length of 'w' for comparison.

Q7. Let X be a square matrix. Consider the following two statements on X. I. X is invertible. II. Determinant of X is non-zero. Which one of the following is TRUE?

  1. I implies II; II does not imply I.
  2. II implies I; I does not imply II.
  3. I does not imply II; II does not imply I.
  4. I and II are equivalent statements.

Answer: I and II are equivalent statements.

A square matrix is invertible if and only if its determinant is non-zero, meaning that both statements are true simultaneously or false simultaneously. Therefore, I and II are equivalent statements.

Q8. Let G be an arbitrary group. Consider the following relations on G: R1: ∀a, b ∈ G, a R1 b if and only if ∃g ∈ G such that a = g^−1bg R2: ∀a, b ∈ G, a R2 b if and only if a = b^−1 Which of the above is/are equivalence relation/relations?

  1. R1 and R2
  2. R1 only
  3. R2 only
  4. Neither R1 nor R2

Answer: R1 only

R1 (a = g^-1 b g) is conjugacy, which is reflexive, symmetric, and transitive in any group, so it is an equivalence relation. R2 (a = b^-1) fails reflexivity since a = a^-1 requires a^2 = e, not true for all a. Only R1, index 1, not 'R1 and R2'.

Q9. Consider the following two statements about database transaction schedules: I. Strict two-phase locking protocol generates conflict serializable schedules that are also recoverable. II. Timestamp-ordering concurrency control protocol with Thomas' Write Rule can generate view serializable schedules that are not conflict serializable. Which of the above statements is/are TRUE?

  1. I only
  2. II only
  3. Both I and II
  4. Neither I nor II

Answer: Both I and II

Both statements are true because the strict two-phase locking protocol ensures that transactions are executed in a way that maintains conflict serializability and recoverability. Additionally, the timestamp-ordering concurrency control with Thomas' Write Rule allows for the generation of view serializable schedules that may not adhere to conflict serializability due to its handling of write operations.

Q10. Let G be an undirected complete graph on n vertices, where n > 2. Then, the number of different Hamiltonian cycles in G is equal to

  1. n!
  2. (n - 1)!
  3. 1
  4. (n - 1)! / 2

Answer: (n - 1)! / 2

In a complete graph with n vertices, each Hamiltonian cycle can be represented by fixing one vertex and arranging the remaining (n-1) vertices in a cycle. Since each cycle can be traversed in two directions (clockwise and counterclockwise), we divide by 2, resulting in (n - 1)! / 2 distinct Hamiltonian cycles.

Q11. Which one of the following statements is NOT correct about the B+ tree data structure used for creating an index of a relational database table?

  1. B+ Tree is a height-balanced tree
  2. Non-leaf nodes have pointers to data records
  3. Key values in each node are kept in sorted order
  4. Each leaf node has a pointer to the next leaf node

Answer: Non-leaf nodes have pointers to data records

Non-leaf nodes in a B+ tree do not contain pointers to actual data records; instead, they only store keys and pointers to child nodes, which helps in navigating the tree structure. This characteristic distinguishes B+ trees from other tree structures, ensuring efficient searching and maintaining balance.

Q12. Which of the following protocol pairs can be used to send and retrieve e-mails (in that order)?

  1. IMAP, POP3
  2. SMTP, POP3
  3. SMTP, MIME
  4. IMAP, SMTP

Answer: SMTP, POP3

SMTP (Simple Mail Transfer Protocol) is used to send emails from a client to a server, while POP3 (Post Office Protocol version 3) is used to retrieve emails from the server to the client, making this pair suitable for the specified order of operations.

Q13. Consider the following C function. void convert(int n){ if(n<0) printf("%d",n); else{ convert(n/2); printf("%d",n%2); } } Which one of the following will happen when the function convert is called with any positive integer n as argument?

  1. It will print the binary representation of n and terminate
  2. It will print the binary representation of n in the reverse order and terminate
  3. It will print the binary representation of n but will not terminate
  4. It will not print anything and will not terminate

Answer: It will not print anything and will not terminate

For any positive n the recursion reaches convert(0), which takes the else branch and calls convert(0/2)=convert(0) endlessly, never returning, so no printf in the else branch ever executes. The function prints nothing and does not terminate (index 3), not the stored index 2.

Q14. Consider three machines M, N, and P with IP addresses 100.10.5.2, 100.10.5.5, and 100.10.5.6 respectively. The subnet mask is set to 255.255.255.252 for all the three machines. Which one of the following is true?

  1. M, N, and P all belong to the same subnet
  2. Only M and N belong to the same subnet
  3. Only N and P belong to the same subnet
  4. M, N, and P belong to three different subnets

Answer: Only N and P belong to the same subnet

With mask 255.255.255.252 (/30) the network is the address with its last two bits cleared. .2 gives network .0, while .5 and .6 both give network .4. So M is alone in subnet .0 and N and P share subnet .4: only N and P belong to the same subnet (index 2).

Q15. Suppose that in an IP-over-Ethernet network, a machine X wishes to find the MAC address of another machine Y in its subnet. Which one of the following techniques can be used for this?

  1. X sends an ARP request packet to the local gateway’s IP address which then finds the MAC address of Y and sends to X
  2. X sends an ARP request packet to the local gateway’s MAC address which then finds the MAC address of Y and sends to X
  3. X sends an ARP request packet with broadcast MAC address in its local subnet
  4. X sends an ARP request packet with broadcast IP address in its local subnet

Answer: X sends an ARP request packet with broadcast MAC address in its local subnet

The correct option is effective because ARP (Address Resolution Protocol) uses a broadcast MAC address to reach all devices on the local subnet, allowing machine X to request the MAC address of machine Y, which will respond with its MAC address.

Q16. Consider the following sets: S1. Set of all recursively enumerable languages over the alphabet {0,1} S2. Set of all syntactically valid C programs S3. Set of all languages over the alphabet {0,1} S4. Set of all non-regular languages over the alphabet {0,1} Which of the above sets are uncountable?

  1. S1 and S2
  2. S3 and S4
  3. S2 and S3
  4. S1 and S4

Answer: S3 and S4

S3, the set of all languages over the alphabet {0,1}, is uncountable because it includes all possible subsets of strings formed from that alphabet, which corresponds to the power set of the natural numbers. S4, the set of all non-regular languages, is also uncountable since it contains infinitely many languages that cannot be described by finite automata, further contributing to the uncountability.

Q17. Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1, X2, X3, X4, X5, and X6 be the placeholders for the non-terminals D, T, L or L1 in the following table: Production rule | Semantic action D → T L | X1.type = X2.type T → int | T.type = int T → float | T.type = float L → L1, id | X3.type = X4.type addType(id.entry, X5.type) L → id | addType(id.entry, X6.type) Which one of the following are the appropriate choices for X1, X2, X3 and X4?

  1. X1 = L, X2 = T, X3 = L1, X4 = L
  2. X1 = T, X2 = L, X3 = L1, X4 = T
  3. X1 = L, X2 = L, X3 = L1, X4 = T
  4. X1 = T, X2 = L, X3 = T, X4 = L1

Answer: X1 = L, X2 = T, X3 = L1, X4 = L

The correct option is right because it accurately reflects the relationships defined in the grammar: the type of the declaration (D) is derived from the type of the type (T) and the list (L), ensuring that the type of the entire declaration matches the type of its components.

Q18. Let G be any connected, weighted, undirected graph. I. G has a unique minimum spanning tree, if no two edges of G have the same weight. II. G has a unique minimum spanning tree, if, for every cut of G, there is a unique minimum-weight edge crossing the cut. Which of the above two statements is/are TRUE?

  1. I only
  2. II only
  3. Both I and II
  4. Neither I nor II

Answer: Both I and II

Both statements are true because the uniqueness of the minimum spanning tree is guaranteed by the absence of equal edge weights in the first case, and by the presence of a unique minimum-weight edge crossing every cut in the second case. These conditions ensure that there is only one way to construct the minimum spanning tree.

Q19. Consider the following snapshot of a system running n concurrent processes. Process i is holding X_i instances of a resource R, 1 ≤ i ≤ n. Assume that all instances of R are currently in use. Further, for all i, process i can place a request for up to Y_i additional instances of R while holding the X_i instances it already has. Of the n processes, there are exactly two processes p and q such that Yₚ = Y_q = 0. Which one of the following conditions guarantees that no other process apart from p and q can complete execution?

  1. Xₚ + X_q < Min {Yₖ | 1 ≤ k ≤ n, k ≠ p, k ≠ q}
  2. Xₚ + X_q < Max {Yₖ | 1 ≤ k ≤ n, k ≠ p, k ≠ q}
  3. Min (Xₚ, X_q) ≤ Min {Yₖ | 1 ≤ k ≤ n, k ≠ p, k ≠ q}
  4. Min (Xₚ, X_q) ≤ Max {Yₖ | 1 ≤ k ≤ n, k ≠ p, k ≠ q}

Answer: Xₚ + X_q < Min {Yₖ | 1 ≤ k ≤ n, k ≠ p, k ≠ q}

This condition ensures that the total resources held by processes p and q are less than the minimum resources that any other process can request, effectively preventing those processes from obtaining the resources they need to proceed, thus blocking their execution.

Q20. Consider the following statements: I. The smallest element in a max-heap is always at a leaf node II. The second largest element in a max-heap is always a child of the root node III. A max-heap can be constructed from a binary search tree in Θ(n) time IV. A binary search tree can be constructed from a max-heap in Θ(n) time Which of the above statements are TRUE?

  1. I, II and III
  2. I, II and IV
  3. I, III and IV
  4. II, III and IV

Answer: I, II and III

In a max-heap the smallest element is at a leaf (I true) and the second largest must be a child of the root (II true). Building a max-heap from any array (including a BST's nodes) is Theta(n) (III true). Building a BST from a max-heap in Theta(n) would sort in linear time, which is impossible (IV false). So I, II and III, index 0, not the stored option.

Q21. Consider the following relations P(X,Y,Z), Q(X,Y,T) and R(Y,V). P X Y Z X1 Y1 Z1 X1 Y1 Z2 X2 Y2 Z2 X2 Y4 Z4 Q X Y T X2 Y1 2 X1 Y2 5 X1 Y1 6 X3 Y3 1 R Y V Y1 V1 Y3 V2 Y2 V3 Y2 V2 How many tuples will be returned by the following relational algebra query? πX (σ(P.Y=R.Y ∧ R.V=V2)(P × R)) − πX (σ(Q.Y=R.Y ∧ Q.T>2)(Q × R))

  1. 1
  2. 2
  3. 3
  4. 4

Answer: 1

The query first retrieves tuples from the Cartesian product of P and R where P.Y matches R.Y and R.V equals V2, resulting in one matching tuple. Then, it excludes tuples from the Cartesian product of Q and R where Q.Y matches R.Y and Q.T is greater than 2, which yields no tuples to exclude. Thus, the final result contains only one tuple.

⚔️ Practice GATE Technical free + battle 1v1 →