StreakPeaked· Practice

ExamsGATETechnical › COMPUTER SCIENCE & INFORMATION TECH. - CS

GATE Technical: COMPUTER SCIENCE & INFORMATION TECH. - CS questions with solutions

59 questions with worked solutions.

Questions

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

  1. X
  2. X + Y
  3. X ⊕ Y
  4. Y

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

  1. fraction bits of 000...000 and exponent value of 0
  2. fraction bits of 000...000 and exponent value of -1
  3. fraction bits of 100...000 and exponent value of 0
  4. no exact representation

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

  1. 3
  2. 4
  3. 7
  4. 8

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

  1. Segment
  2. Datagram
  3. Message
  4. Frame

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.

Q5. Which of the following problems are decidable? 1) Does a given program ever produce an output? 2) If L is a context-free language, then is L̄ also context-free? 3) If L is a regular language, then is L̄ also regular? 4) If L is a recursive language, then is L̄ also recursive?

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

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.

Q6. A binary operation ⊕ on a set of integers is defined as x ⊕ y = x² × y². Which one of the following statements is TRUE about ⊕?

  1. Commutative but not associative
  2. Both commutative and associative
  3. Associative but not commutative
  4. Neither commutative nor associative

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

  1. -256
  2. -128
  3. -127
  4. 0

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.

Q8. In the following truth table, V = 1 if and only if the input is valid. Inputs | Outputs D0 D1 D2 D3 | X0 X1 V 0 0 0 0 | x x 0 1 0 0 0 | 0 0 1 x 1 0 0 | 0 1 1 x x 1 0 | 1 0 1 x x x 1 | 1 1 1 What function does the truth table represent?

  1. Priority encoder
  2. Decoder
  3. Multiplexer
  4. Demultiplexer

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.

Q9. Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort?

  1. O(log n)
  2. O(n)
  3. O(n log n)
  4. O(n²)

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.

Q10. Which one of the following is the tightest upper bound that represents the time complexity of inserting an object into a binary search tree of n nodes?

  1. O(1)
  2. O(log n)
  3. O(n)
  4. O(n log n)

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 ?

  1. {ε}
  2. Φ
  3. a*
  4. {ε, a}

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}.

Q12. What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e. of type A → ε and A → a) to parse a string with n tokens?

  1. n/2
  2. n-1
  3. 2n-1
  4. 2ⁿ

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.

Q13. A scheduling algorithm assigns priority proportional to the waiting time of a process. Every process starts with priority zero (the lowest priority). The scheduler re-evaluates the process priorities every time unit and decides the next process to schedule. Which one of the following is TRUE if the processes have no I/O operations and all arrive at time zero?

  1. This algorithm is equivalent to the first-come-first-serve algorithm.
  2. This algorithm is equivalent to the round-robin algorithm.
  3. This algorithm is equivalent to the shortest-job-first algorithm.
  4. This algorithm is equivalent to the shortest-remaining-time-first algorithm.

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.

Q14. Match the problem domains in GROUP I with the solution technologies in GROUP II. GROUP I (P) Service oriented computing (Q) Heterogeneous communicating systems (R) Information representation (S) Process description GROUP II (1) Interoperability (2) BPMN (3) Publish-find-bind (4) XML

  1. P-1, Q-2, R-3, S-4
  2. P-3, Q-4, R-2, S-1
  3. P-3, Q-1, R-4, S-2
  4. P-4, Q-3, R-2, S-1

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.

Q15. The transport layer protocols used for real time multimedia, file transfer, DNS and email, respectively are

  1. TCP, UDP, UDP and TCP
  2. UDP, TCP, TCP and UDP
  3. UDP, TCP, UDP and TCP
  4. TCP, UDP, TCP and UDP

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.

Q16. Using public key cryptography, X adds a digital signature σ to message M, encrypts <M, σ>, and sends it to Y, where it is decrypted. Which one of the following sequences of keys is used for the operations?

  1. Encryption: X's private key followed by Y's private key; Decryption: X's public key followed by Y's public key
  2. Encryption: X's private key followed by Y's public key; Decryption: X's public key followed by Y's private key
  3. Encryption: X's public key followed by Y's private key; Decryption: X's public key followed by Y's private key
  4. Encryption: X's private key followed by Y's public key; Decryption: Y's private key followed by X's public key

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.

Q17. Assume that source S and destination D are connected through two intermediate routers labeled R. Determine how many times each packet has to visit the network layer and the data link layer during a transmission from S to D.

  1. Network layer - 4 times and Data link layer - 4 times
  2. Network layer - 4 times and Data link layer - 3 times
  3. Network layer - 4 times and Data link layer - 6 times
  4. Network layer - 2 times and Data link layer - 6 times

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

  1. it is on a set of fields that form a candidate key.
  2. it is on a set of fields that include the primary key.
  3. the data records of the file are organized in the same order as the data entries of the index.
  4. the data records of the file are organized not in the same order as the data entries of the index.

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.

Q19. Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d and a before entering the respective code segments. After completing the execution of the code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to 1. Which one of the following is a deadlock-free order of invoking the P operations by the processes?

  1. X: P(a)P(b)P(c) Y: P(b)P(c)P(d) Z: P(c)P(d)P(a)
  2. X: P(b)P(a)P(c) Y: P(b)P(c)P(d) Z: P(a)P(c)P(d)
  3. X: P(b)P(a)P(c) Y: P(c)P(b)P(d) Z: P(a)P(c)P(d)
  4. X: P(a)P(b)P(c) Y: P(c)P(b)P(d) Z: P(c)P(d)P(a)

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.

Q20. Which of the following statements is/are FALSE ? 1. For every non-deterministic Turing machine, there exists an equivalent deterministic Turing machine. 2. Turing recognizable languages are closed under union and complementation. 3. Turing decidable languages are closed under intersection and complementation. 4. Turing recognizable languages are closed under union and intersection.

  1. 1 and 4 only
  2. 1 and 3 only
  3. 2 only
  4. 3 only

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.

Q21. Which of the following statements are TRUE ? 1. The problem of determining whether there exists a cycle in an undirected graph is in P. 2. The problem of determining whether there exists a cycle in a directed graph is in NP. 3. If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A.

  1. 1, 2 and 3
  2. 1 and 2 only
  3. 2 and 3 only
  4. 1 and 3 only

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.

Q22. What is the time complexity of Bellman-Ford single-source shortest path algorithm on a complete graph of n vertices?

  1. Θ(n²)
  2. Θ(n² log n)
  3. Θ(n³)
  4. Θ(n³ log n)

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³).

Q23. In a k-way set associative cache, the cache is divided into v sets, each of which consists of k lines. The lines of a set are placed in sequence one after another. The lines in sets are sequenced before the lines in set (s+1). The main memory blocks are numbered 0 onwards. A main memory block numbered j must be mapped to any one of the cache lines from

  1. (j mod v) * k to (j mod v) * k + (k-1)
  2. (j mod v) to (j mod v) + (k-1)
  3. (j mod k) to (j mod k) + (v-1)
  4. (j mod k) * v to (j mod k) * v + (v-1)

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?

  1. x y ⊕ x̅ y̅
  2. x ⊕ y̅
  3. x ⊕ y
  4. x̅ ⊕ 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.

Q25. Consider an undirected random graph of eight vertices. The probability that there is an edge between a pair of vertices is 1/2. What is the expected number of unordered cycles of length three?

  1. 1/8
  2. 1
  3. 7
  4. 8

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.

Q26. Which of the following statements is/are TRUE for undirected graphs? P: Number of odd degree vertices is even. Q: Sum of degrees of all vertices is even.

  1. P only
  2. Q only
  3. Both P and Q
  4. Neither P nor Q

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.

Q27. The line graph L(G) of a simple graph G is defined as follows: • There is exactly one vertex v(e) in L(G) for each edge e in G. • For any two edges e and e' in G, L(G) has an edge between v(e) and v(e'), if and only if e and e' are incident with the same vertex in G. Which of the following statements is/are TRUE? (P) The line graph of a cycle is a cycle. (Q) The line graph of a clique is a clique. (R) The line graph of a planar graph is planar. (S) The line graph of a tree is a tree.

  1. P only
  2. P and R only
  3. R only
  4. P, Q and S only

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."

  1. ∃x [F x ⊃ P x]
  2. ∃x [F x ⊃ ¬P x]
  3. ∀x [F x ⊃ ¬P x]
  4. ∃x [¬F x ⊃ P x]

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.

Q29. Consider a hard disk with 16 recording surfaces (0-15) having 16384 cylinders (0-16383) and each cylinder contains 64 sectors (0-63). Data storage capacity in each sector is 512 bytes. Data are organized cylinder-wise and the addressing format is < cylinder no., surface no., sector no. >. A file of size 42797 KB is stored in the disk and the starting disk location of the file is <1200, 9, 40>. What is the cylinder number of the last sector of the file, if it is stored in a contiguous manner?

  1. 1281
  2. 1282
  3. 1283
  4. 1284

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.

Q30. Consider the following function: int unknown(int n){ int i, j, k = 0; for (i = n/2; i <= n; i++) for (j = 2; j <= n; j = j * 2) k = k + n/2; return (k); } The return value of the function is

  1. Θ(n²)
  2. Θ(n² log n)
  3. Θ(n³)
  4. Θ(n³ log n)

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).

Q31. Consider the following relational schema. Students(rollno: integer, sname: string) Courses(courseno: integer, cname: string) Registration(rollno: integer, courseno: integer, percent: real) Which of the following queries are equivalent to this query in English? "Find the distinct names of all students who score more than 90% in the course numbered 107" (I) SELECT DISTINCT S.sname FROM Students as S, Registration as R WHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent > 90 (II) πsname(σcourseno=107 ∧ percent>90 (R registration ⋈ Students)) (III) { T | ∃S Students ∧ ∃R Registration ∧ (R.courseno=107 ∧ R.percent>90 ∧ T.sname=S.sname)} (IV) {<Sₙ> | ∃S, R, p (<S, Sₙ>∈Students ∧ <S, 107, R, p>∈Registration ∧ R > 90)}

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

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.

Q32. Determine the maximum length of the cable (in km) for transmitting data at a rate of 500 Mbps in an Ethernet LAN with frames of size 10,000 bits. Assume the signal speed in the cable to be 2,00,000 km/s.

  1. 1
  2. 2
  3. 2.5
  4. 5

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.

Q33. In an IPv4 datagram, the M bit is 0, the value of HLEN is 10, the value of total length is 400 and the fragment offset value is 300. The position of the datagram, the sequence numbers of the first and the last bytes of the payload, respectively are

  1. Last fragment, 2400 and 2789
  2. First fragment, 2400 and 2759
  3. Last fragment, 2400 and 2759
  4. Middle fragment, 300 and 689

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.

Q34. What is the return value of f(p,p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value. int f (int &x, int c) { c = c - 1; if (c == 0) return 1; x = x + 1; return f(x, c) * x; }

  1. 3024
  2. 6561
  3. 55440
  4. 161051

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.

Q35. The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of the following is the postorder traversal sequence of the same tree?

  1. 10, 20, 15, 23, 25, 35, 42, 39, 30
  2. 15, 10, 25, 23, 20, 42, 35, 39, 30
  3. 15, 20, 10, 23, 25, 42, 35, 39, 30
  4. 15, 10, 23, 25, 20, 35, 42, 39, 30

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.

Q36. Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter. MultiDequeue(Q){ m = k while (Q is not empty) and (m > 0) { Dequeue(Q) m = m - 1 } } What is the worst case time complexity of a sequence of queue operations on an initially empty queue?

  1. Θ(n)
  2. Θ(n + k)
  3. Θ(nk)
  4. Θ(n²)

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.

Q37. Consider an instruction pipeline with five stages without any branch prediction: Fetch Instruction (FI), Decode Instruction (DI), Fetch Operand (FO), Execute Instruction (EI) and Write Operand (WO). The stage delays for FI, DI, FO, EI and WO are 5 ns, 7 ns, 10 ns, 8 ns and 6 ns, respectively. There are intermediate storage buffers after each stage and the delay of each buffer is 1 ns. A program consisting of 12 instructions, I1, I2,..., I12 is executed in this pipelined processor. Instruction I4 is the only branch instruction and its branch target is I9. If the branch is taken during the EI execution of this program, the time (in ns) needed to complete the program is

  1. 132
  2. 165
  3. 176
  4. 328

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.

Q38. Statement for Linked Answer Questions 52 and 53: A computer uses 46-bit virtual address, 32-bit physical address, and a three-level paged page table organization. The page table base register stores the base address of the first-level table (T1), which occupies exactly one page. Each entry of T1 stores the base address of a page of the second-level table (T2). Each entry of T2 stores the base address of a page of the third-level table (T3). Each entry of T3 stores a page table entry (PTE). The PTE is 32 bits in size. The processor used in the computer has a 1 MB 16-way set associative virtually indexed physically tagged cache. The cache block size is 64 bytes. What is the size of a page in KB in this computer?

  1. 2
  2. 4
  3. 8
  4. 16

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.

Q39. Which of the following statements are TRUE? 1. The problem of determining whether there exists a cycle in an undirected graph is in P. 2. The problem of determining whether there exists a cycle in an undirected graph is in NP. 3. If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A.

  1. 1, 2 and 3
  2. 1 and 2 only
  3. 2 and 3 only
  4. 1 and 3 only

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.

Q40. Which of the following statements is/are FALSE? 1. For every non-deterministic Turing machine, there exists an equivalent deterministic Turing machine. 2. Turing recognizable languages are closed under union and complementation. 3. Turing decidable languages are closed under intersection and complementation. 4. Turing recognizable languages are closed under union and intersection.

  1. 1 and 4 only
  2. 1 and 3 only
  3. 2 only
  4. 3 only

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.

Q41. An index is clustered if

  1. it is on a set of fields that form a candidate key.
  2. it is on a set of fields that include the primary key.
  3. the data records of the file are organized in the same order as the data entries of the index.
  4. the data records of the file are organized not in the same order as the data entries of the index.

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.

Q42. Using public key cryptography, X adds a digital signature s to message M, encrypts <M, s>, and sends it to Y, where it is decrypted. Which one of the following sequences of keys is used for the operations?

  1. Encryption: X's private key followed by Y's private key; Decryption: X's public key followed by Y's public key
  2. Encryption: X's private key followed by Y's public key; Decryption: X's public key followed by Y's private key
  3. Encryption: X's public key followed by Y's private key; Decryption: X's public key followed by X's private key
  4. Encryption: X's public key followed by Y's public key; Decryption: X's private key followed by Y's public key

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 ?

  1. {ε}
  2. Φ
  3. a*
  4. {ε, a}

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}.

Q44. A binary operation ⊕ on a set of integers is defined as x ⊕ y = x² - y². Which one of the following statements is TRUE about ⊕?

  1. Commutative but not associative
  2. Both commutative and associative
  3. Associative but not commutative
  4. Neither commutative nor associative

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.

Q45. What is the return value of f(p, p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value. int f (int &x, int c) { c = c - 1; if (c == 0) return 1; x = x + 1; return f(x, c) * x; }

  1. 3024
  2. 6561
  3. 55440
  4. 161051

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.

Q46. Consider the following function: int unknown(int n){ int i, j, k=0; for (i=n/2; i<=n; i++) for (j=2; j<=n; j=j*2) k = k + n/2; return (k); } The return value of the function is

  1. Θ(n²)
  2. Θ(n² log n)
  3. Θ(n³)
  4. Θ(n³ log n)

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).

Q47. Consider a hard disk with 16 recording surfaces (0-15) having 6384 cylinders (0-6383) and each cylinder contains 64 sectors (0-63). Data storage capacity in each sector is 512 bytes. Data are organized cylinder-wise and the addressing format is < cylinder no., surface no., sector no. >. A file of size 42797 KB is stored in the disk and the starting disk location of the file is <1200, 9, 40>. What is the cylinder number of the last sector of the file, if it is stored in a contiguous manner?

  1. 1281
  2. 1282
  3. 1283
  4. 1284

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.

Q48. In the following truth table, V = 1 if and only if the input is valid. What function does the truth table represent?

  1. Priority encoder
  2. Decoder
  3. Multiplexer
  4. Demultiplexer

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.

Q49. Which of the following statements are TRUE for undirected graphs? P: Number of odd degree vertices is even. Q: Sum of degrees of all vertices is even.

  1. P only
  2. Q only
  3. Both P and Q
  4. Neither P nor Q

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.

Q50. Assume that source S and destination D are connected through two intermediate routers labeled R. D determine how many times each packet has to visit the network layer and the data link layer during a transmission from S to D. S — R — R — D

  1. Network layer - 4 times and Data link layer - 4 times
  2. Network layer - 4 times and Data link layer - 3 times
  3. Network layer - 4 times and Data link layer - 6 times
  4. Network layer - 2 times and Data link layer - 6 times

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.

⚔️ Practice GATE Technical free + battle 1v1 →