StreakPeaked· Practice

ExamsGATETechnical › Computer Science and Information Technology Set 1 (CS1)

GATE Technical: Computer Science and Information Technology Set 1 (CS1) questions with solutions

23 questions with worked solutions.

Questions

Q1. Which one of the following statements is FALSE?

  1. In the cycle stealing mode of DMA, one word of data is transferred between an I/O device and main memory in a stolen cycle
  2. For bulk data transfer, the burst mode of DMA has a higher throughput than the cycle stealing mode
  3. Programmed I/O mechanism has a better CPU utilization than the interrupt driven I/O mechanism
  4. The CPU can start executing an interrupt service routine faster with vectored interrupts than with non-vectored interrupts

Answer: Programmed I/O mechanism has a better CPU utilization than the interrupt driven I/O mechanism

The statement is false because programmed I/O typically requires the CPU to actively wait for I/O operations to complete, leading to lower CPU utilization compared to interrupt-driven I/O, where the CPU can perform other tasks while waiting for interrupts.

Q2. A user starts browsing a webpage hosted at a remote server. The browser opens a single TCP connection to fetch the entire webpage from the server. The webpage consists of a top-level index page with multiple embedded image objects. Assume that all caches (e.g., DNS cache, browser cache) are all initially empty. The following packets leave the user’s computer in some order. (i) HTTP GET request for the index page (ii) DNS request to resolve the web server’s name to its IP address (iii) HTTP GET request for an image object (iv) TCP SYN to open a connection to the web server Which one of the following is the CORRECT chronological order (earliest in time to latest) of the packets leaving the computer?

  1. (iv), (ii), (iii), (i)
  2. (ii), (iv), (iii), (i)
  3. (ii), (iv), (i), (iii)
  4. (iv), (ii), (i), (iii)

Answer: (ii), (iv), (i), (iii)

The correct order starts with the DNS request to resolve the server's name, as the browser needs the IP address before establishing a connection. Next, the TCP SYN packet is sent to open a connection to the server. After the connection is established, the browser sends the HTTP GET request for the index page, followed by requests for any embedded image objects.

Q3. Given an integer array of size N, we want to check if the array is sorted (in either ascending or descending order). An algorithm solves this problem by making a single pass through the array and comparing each element of the array only with its adjacent elements. The worst-case time complexity of this algorithm is

  1. both O(N) and Ω(N)
  2. O(N) but not Ω(N)
  3. Ω(N) but not O(N)
  4. neither O(N) nor Ω(N)

Answer: both O(N) and Ω(N)

The algorithm checks each pair of adjacent elements in a single pass through the array, which requires examining all N elements, resulting in a linear time complexity of O(N). Since it must at least look at each element once to determine the order, it also has a lower bound of Ω(N), making the correct option both O(N) and Ω(N).

Q4. Consider the following C program: #include <stdio.h> int main(){ int a = 6; int b = 0; while(a < 10) { a = a / 12 + 1; a += b;} printf("%d", a); return 0;} Which one of the following statements is CORRECT?

  1. The program prints 9 as output
  2. The program prints 10 as output
  3. The program gets stuck in an infinite loop
  4. The program prints 6 as output

Answer: The program gets stuck in an infinite loop

The program enters an infinite loop because the condition 'a < 10' remains true indefinitely. The value of 'a' is updated in such a way that it never reaches or exceeds 10, causing the loop to continue without termination.

Q5. Consider the following C program: #include <stdio.h> void fX(); int main(){ fX(); return 0;} void fX(){ char a; if((a=getchar()) != ' ') fX(); if(a != ' ') putchar(a);} Assume that the input to the program from the command line is 1234 followed by a newline character. Which one of the following statements is CORRECT?

  1. The program will not terminate
  2. The program will terminate with no output
  3. The program will terminate with 4321 as output
  4. The program will terminate with 1234 as output

Answer: The program will terminate with 4321 as output

The program reads characters from input recursively until it encounters a newline, storing each character in reverse order due to the nature of the recursive calls. When the newline is reached, the recursion unwinds, and the characters are printed in reverse, resulting in '4321' as the output.

Q6. In a B+ tree, the requirement of at least half-full (50%) node occupancy is relaxed for which one of the following cases?

  1. Only the root node
  2. All leaf nodes
  3. All internal nodes
  4. Only the leftmost leaf node

Answer: Only the root node

The root node of a B+ tree can have fewer than half of its maximum capacity, allowing it to have just one key when the tree is small or when it is being initialized. This flexibility is essential for maintaining the tree's structure during insertions and deletions.

Q7. Which of the following statements about a relation R in first normal form (1NF) is/are TRUE ?

  1. R can have a multi-attribute key
  2. R cannot have a foreign key
  3. R cannot have a composite attribute
  4. R cannot have more than one candidate key

Answer: R can have a multi-attribute key

A relation in first normal form (1NF) allows for multi-attribute keys, meaning that a primary key can consist of more than one attribute to uniquely identify each record in the relation.

Q8. Which of the following is/are Bottom-Up Parser(s)?

  1. Shift-reduce Parser
  2. Predictive Parser
  3. LL(1) Parser
  4. LR Parser

Answer: Shift-reduce Parser

The Shift-reduce Parser is a type of bottom-up parser that builds the parse tree from the leaves (input symbols) up to the root (start symbol) by shifting input symbols onto a stack and reducing them to non-terminals according to production rules.

Q9. Let A and B be two events in a probability space with P(A) = 0.3, P(B) = 0.5, and P(A ∩ B) = 0.1. Which of the following statements is/are TRUE?

  1. The two events A and B are independent
  2. P(A ∪ B) = 0.7
  3. P(A ∩ B^c) = 0.2, where B^c is the complement of the event B
  4. P(A^c ∩ B^c) = 0.4, where A^c and B^c are the complements of the events A and B, respectively

Answer: P(A ∪ B) = 0.7

The statement P(A ∪ B) = P(A) + P(B) - P(A ∩ B) simplifies to 0.3 + 0.5 - 0.1, which equals 0.7, confirming the correctness of the statement.

Q10. TCP client P successfully establishes a connection to TCP server Q. Let N_P denote the sequence number in the SYN sent from P to Q. Let N_Q denote the acknowledgement number in the SYN ACK from Q to P. Which of the following statements is/are CORRECT?

  1. The sequence number N_P is chosen randomly by P
  2. The sequence number N_P is always 0 for a new connection
  3. The acknowledgement number N_Q is equal to N_P
  4. The acknowledgement number N_Q is equal to N_P + 1

Answer: The acknowledgement number N_Q is equal to N_P + 1

The acknowledgement number N_Q is set to N_P + 1 because it indicates that the server Q has received the SYN packet from client P and is acknowledging the next expected sequence number, which is one more than the initial sequence number sent by P.

Q11. Which of the following fields is/are modified in the IP header of a packet going out of a network address translation (NAT) device from an internal network to an external network?

  1. Source IP
  2. Destination IP
  3. Header Checksum
  4. Total Length

Answer: Source IP

The source IP address is modified by the NAT device to replace the internal IP with its own public IP, allowing the packet to be correctly routed on the external network.

Q12. Consider the following two threads T1 and T2 that update two shared variables a and b. Assume that initially a = b = 1. Though context switching between threads can happen at any time, each statement of T1 or T2 is executed atomically without interruption. T1 a = a + 1; b = b + 1; T2 b = 2 * b; a = 2 * a; Which one of the following options lists all the possible combinations of values of a and b after both T1 and T2 finish execution?

  1. (a = 4, b = 4); (a = 3, b = 3); (a = 4, b = 3)
  2. (a = 3, b = 4); (a = 4, b = 3); (a = 3, b = 3)
  3. (a = 4, b = 4); (a = 4, b = 3); (a = 3, b = 4)
  4. (a = 2, b = 2); (a = 2, b = 3); (a = 3, b = 4)

Answer: (a = 4, b = 4); (a = 3, b = 3); (a = 4, b = 3)

Each statement is atomic and order within a thread is fixed (a=a+1 before b=b+1; b=2b before a=2a). Enumerating all valid interleavings yields exactly {(4,4),(3,3),(4,3)}: T1-then-T2 gives (4,4), T2-then-T1 gives (3,3), and the mixed orders give (4,3). The set matching this is (4,4);(3,3);(4,3), so the stored option is wrong.

Q13. An array [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] is heapified. Which one of the following options represents the first three elements in the heapified array?

  1. 82, 90, 101
  2. 82, 11, 93
  3. 131, 11, 93
  4. 131, 111, 90

Answer: 131, 111, 90

In a max heap, the largest element is at the root, followed by its children, which must also be larger than their own children. After heapifying the given array, the largest value, 131, becomes the root, followed by 111 and 90, which are the next largest elements, thus forming the first three elements of the heap.

Q14. Consider the following recurrence relation: T(n) = { √n T(√n) + n for n ≥ 1, 1 for n = 1. Which one of the following options is CORRECT?

  1. T(n) = Θ(n log log n)
  2. T(n) = Θ(n log n)
  3. T(n) = Θ(n² log n)
  4. T(n) = Θ(n² log log n)

Answer: T(n) = Θ(n log log n)

The recurrence relation indicates that the function T(n) grows based on the size of n and its logarithmic factors, specifically due to the repeated halving of n (as seen in T(√n)). This leads to a complexity that is proportional to n multiplied by the logarithm of the logarithm of n, hence T(n) = Θ(n log log n) is the correct characterization.

Q15. Consider a binary min-heap containing 105 distinct elements. Let k be the index (in the underlying array) of the maximum element stored in the heap. The number of possible values of k is

  1. 53
  2. 52
  3. 27
  4. 1

Answer: 53

In a binary min-heap, the maximum element can only be found in the leaf nodes, which are located in the second half of the array representation. With 105 elements, the leaf nodes start from index 53 to 105, giving us a total of 53 possible indices for the maximum element.

Q16. The symbol → indicates functional dependency in the context of a relational database. Which of the following options is/are TRUE?

  1. (X,Y) → (Z,W) implies X → (Z,W)
  2. (X,Y) → (Z,W) implies (X,Y) → Z
  3. ((X,Y) → Z and W → Y) implies (X,W) → Z
  4. (X → Y and Y → Z) implies X → Z

Answer: (X → Y and Y → Z) implies X → Z

This statement is an application of the transitive property of functional dependencies, which states that if one attribute functionally determines a second, and that second attribute functionally determines a third, then the first attribute must also functionally determine the third.

Q17. Consider the following read-write schedule S over three transactions T1, T2, and T3, where the subscripts in the schedule indicate transaction IDs: S: r1(z); w1(z); r2(x); r3(y); w3(y); r2(y); w2(x); w2(y); Which of the following transaction schedules is/are conflict equivalent to S ?

  1. T1 T2 T3
  2. T1 T3 T2
  3. T3 T2 T1
  4. T3 T1 T2

Answer: T1 T3 T2

The correct option T1 T3 T2 maintains the order of conflicting operations from the original schedule S, ensuring that the read and write operations on the same data items occur in the same sequence, thus preserving the consistency of the transactions.

Q18. Consider a Boolean expression given by F(X,Y,Z) = Σ(3,5,6,7). Which of the following statements is/are CORRECT ?

  1. F(X,Y,Z) = Π(0,1,2,4)
  2. F(X,Y,Z) = XY + YZ + XZ
  3. F(X,Y,Z) is independent of input Y
  4. F(X,Y,Z) is independent of input X

Answer: F(X,Y,Z) = XY + YZ + XZ

The correct option is right because the expression F(X,Y,Z) = XY + YZ + XZ accurately represents the minterms 3, 5, 6, and 7 in the given Boolean function, confirming its equivalence to the specified sum of products.

Q19. Consider the following C function definition. int f(int x, int y) { for (int i=0; i<y; i++) { x=x+x+y; } return x; } Which of the following statements is/are TRUE about the above function?

  1. If the inputs are x=20, y=10, then the return value is greater than 2²⁰
  2. If the inputs are x=20, y=20, then the return value is greater than 2²⁰
  3. If the inputs are x=2⁰, y=10, then the return value is less than 2¹⁰
  4. If the inputs are x=1⁰, y=20, then the return value is greater than 2²⁰

Answer: If the inputs are x=20, y=20, then the return value is greater than 2²⁰

The function doubles the value of x and adds y in each iteration of the loop, leading to exponential growth. For x=20 and y=20, the number of iterations (20) allows the value of x to increase significantly, resulting in a return value that exceeds 2²⁰.

Q20. The chromatic number of a graph is the minimum number of colours used in a proper colouring of the graph. Let G be any graph with n vertices and chromatic number k. Which of the following statements is/are always TRUE?

  1. G contains a complete subgraph with k vertices
  2. G contains an independent set of size at least n/k
  3. G contains at least k(k − 1)/2 edges
  4. G contains a vertex of degree at least k

Answer: G contains an independent set of size at least n/k

A graph with chromatic number k can be colored using k colors, which implies that there must be at least one independent set of vertices that can be colored with the same color. By the pigeonhole principle, if there are n vertices and k colors, at least one color must be assigned to at least n/k vertices, ensuring the existence of an independent set of that size.

Q21. Consider two set-associative cache memory architectures: WBC, which uses the write back policy, and WTC, which uses the write through policy. Both of them use the LRU (Least Recently Used) block replacement policy. The cache memory is connected to the main memory. Which of the following statements is/are TRUE?

  1. A read miss in WBC never evicts a dirty block
  2. A read miss in WTC never triggers a write back operation of a cache block to main memory
  3. A write hit in WBC can modify the value of the dirty bit of a cache block
  4. A write miss in WTC always writes the victim cache block to main memory before loading the missed block to the cache

Answer: A write hit in WBC can modify the value of the dirty bit of a cache block

In a write-back cache (WBC), a write hit occurs when data is written to a cache block that is already present, allowing the dirty bit to be set or modified to indicate that the block has been changed but not yet written back to main memory.

Q22. Consider a digital logic circuit consisting of three 2-to-1 multiplexers M1, M2, and M3 as shown below. X1 and X2 are inputs of M1. X3 and X4 are inputs of M2. A, B, and C are select lines of M1, M2, and M3, respectively. For an instance of inputs X1=1, X2=1, X3=0, and X4=0, the number of combinations of A, B, C that give the output Y=1 is

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

Answer: 4

The output Y=1 can occur when M1 selects either X1 or X2 (both are 1), and M2 selects either X3 or X4 (both are 0). Since M3's selection does not affect the output when M2 outputs 0, there are 4 combinations of A, B, and C that can yield Y=1.

Q23. Consider sending an IP datagram of size 1420 bytes (including 20 bytes of IP header) from a sender to a receiver over a path of two links with a router between them. The first link (sender to router) has an MTU (Maximum Transmission Unit) size of 542 bytes, while the second link (router to receiver) has an MTU size of 360 bytes. The number of fragments that would be delivered to the receiver is

  1. 6
  2. 7
  3. 8
  4. 9

Answer: 6

Data = 1420-20 = 1400 bytes. Link1 MTU 542 gives payload floor(522/8)*8 = 520, yielding data fragments 520,520,360. Link2 MTU 360 gives payload 336, so each splits: 520->336+184, 520->336+184, 360->336+24, for 6 fragments delivered. Stored '9' is wrong; correct is 6.

⚔️ Practice GATE Technical free + battle 1v1 →