Detailed Solutions of GATE 2019: Computer Science & IT
The GATE 2019 Computer Science & IT exam tested candidates on various fundamental concepts of computer science and information technology. This document provides detailed solutions to help students understand the problem-solving approach for different types of questions asked in the exam. The solutions cover key areas such as data structures, algorithms, operating systems, databases, computer networks, theory of computation, compiler design, digital logic, and computer architecture.
Data Structures
Question 1: Consider the following statements regarding a doubly linked list:
I. A pointer to the last node of a doubly linked list can be maintained in O(1) time.
II. Given a node in a doubly linked list, both its predecessor and successor can be accessed in O(1) time.
Which of the above statements is/are TRUE?
Let's analyze each statement:
Statement I: "A pointer to the last node of a doubly linked list can be maintained in O(1) time."
This is TRUE. We can maintain a tail pointer that always points to the last node of the list. Inserting or deleting at the end operations can be done in O(1) time with this pointer.
Statement II: "Given a node in a doubly linked list, both its predecessor and successor can be accessed in O(1) time."
This is TRUE. Each node in a doubly linked list contains pointers to both the previous and next nodes. So, if we are given a pointer to a node, we can directly access both its predecessor and successor in constant time.
Answer: Both I and II are TRUE.
Algorithms
Question 2: 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
A Hamiltonian cycle in a graph is a cycle that visits every vertex exactly once (except the starting/ending vertex which is visited twice).
In a complete graph with n vertices, any permutation of the vertices forms a potential Hamiltonian path.
There are n! permutations of n vertices (where n! = n (n-1) (n-2) ... 2 1).
However, for a cycle:
1. Starting point doesn't matter (a cycle is the same no matter where you start). This reduces the count by a factor of n.
2. Direction doesn't matter (clockwise and anti-clockwise represent the same cycle). This further reduces the count by a factor of 2.
Therefore, the number of different Hamiltonian cycles = n!/(2n) = (n-1)!/2.
Answer: (n-1)!/2
Operating Systems
Question 3: Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.
P1: D = D + 20
P2: D = D - 10
P3: D = D + 25
The processes are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, what is Y - X?
We have three processes that read, modify, and write the shared variable D:
- P1 adds 20 to D
- P2 subtracts 10 from D
- P3 adds 25 to D
Let's consider different possible execution orders:
Maximum value (Y):
For maximum value, we want as many additions as possible to happen before subtractions.
If processes execute in order P1, P3, P2:
- After P1: D = 100 + 20 = 120
- After P3: D = 120 + 25 = 145
- After P2: D = 145 - 10 = 135
So, the maximum value Y = 135.
Minimum value (X):
For minimum value, we want subtractions to happen before additions.
If processes execute in order P2, P1, P3:
- After P2: D = 100 - 10 = 90
- After P1: D = 90 + 20 = 110
- After P3: D = 110 + 25 = 135
So, the minimum value X = 135.
Y - X = 135 - 135 = 0.
Answer: 0
Databases
Question 4: Consider the following two tables and four queries in SQL:
Table 1: students (sid, sname, gender, gpa)
Table 2: courses (cid, cname, credits)
Query 1:
SELECT * FROM students WHERE gpa > (SELECT AVG(gpa) FROM students);
Query 2:
SELECT AVG(gpa) FROM students WHERE gender = 'M';
Query 3:
SELECT COUNT(*) FROM students;
Query 4:
SELECT * FROM students WHERE sname LIKE '%a%';
Which of the above queries are safe queries that return a well-defined result?
Let's analyze each query:
Query 1: This is a nested query that selects students whose GPA is greater than the average GPA of all students. The subquery SELECT AVG(gpa) FROM students returns a single value (the average GPA), and the outer query compares each student's GPA with this average. This is a well-defined and safe query.
Query 2: This query calculates the average GPA of male students. If there are no male students, AVG(gpa) will return NULL. This is still a well-defined result, so this query is also safe.
Query 3: This query counts the total number of students in the students table. COUNT(*) always returns a numeric value (possibly 0 if the table is empty). This is a safe query with a well-defined result.
Query 4: This query selects all students whose name contains the letter 'a'. If there are no such students, it will return an empty result set, which is still well-defined. This is also a safe query.
Answer: All four queries (1, 2, 3, and 4) are safe queries that return a well-defined result.
Computer Networks
Question 5: Consider a simple communication system where multiple nodes need to communicate over a shared medium with a bandwidth of 10 Mbps. The system uses CSMA/CD (Carrier Sense Multiple Access with Collision Detection) for media access control. Assume the propagation delay is 2 microseconds and the frame transmission time is 20 microseconds. What is the efficiency of the CSMA/CD protocol?
The efficiency of CSMA/CD is given by:
Efficiency = Frame transmission time / (Frame transmission time + Contention period)
Where Contention period = 2 Propagation delay
Given:
- Frame transmission time = 20 microseconds
- Propagation delay = 2 microseconds
Contention period = 2 2 microseconds = 4 microseconds
Efficiency = 20 / (20 + 4) = 20 / 24 = 5/6 0.833 or 83.3%
This means approximately 83.3% of the bandwidth is used for actual data transmission, while the remaining 16.7% is spent on handling collisions and contention.
Answer: 5/6 or approximately 83.3%
Theory of Computation
Question 6: Consider the following languages:
L1 = {$a^n b^n c^m | n,m \geq 0$}
L2 = {$a^n b^m c^m | n,m \geq 0$}
Which of the following is/are TRUE?
Let's analyze both languages:
L1 = {$a^n b^n c^m | n,m \geq 0$}
This language consists of strings where the number of a's equals the number of b's (followed by any number of c's).
We can design a pushdown automaton (PDA) for L1 as follows:
1. Read a's and push them onto the stack.
2. For each b, pop an a from the stack.
3. Read all c's (without affecting the stack).
Since we can design a PDA for L1, it is a context-free language (CFL).
L2 = {$a^n b^m c^m | n,m \geq 0$}
This language consists of strings where the number of b's equals the number of c's (with any number of a's before them).
We can design a PDA for L2 as follows:
1. Read all a's without affecting the stack.
2. Read b's and push them onto the stack.
3. For each c, pop a b from the stack.
Since we can design a PDA for L2, it is also a context-free language.
Let's check if L1 L2 is a CFL:
L1 L2 = {$a^n b^n c^n | n \geq 0$}
To accept strings in this intersection, we need to ensure that the number of a's, b's, and c's are all equal. A PDA with a single stack can only track one equality. To track two equalities (a=b and b=c), we would need two stacks, making it a context-sensitive language rather than context-free.
Answer: L1 and L2 are context-free languages, but their intersection L1 L2 is not context-free.
Compiler Design
Question 7: Consider the following grammar:
S A B
A a A |
B b B |
Which of the following strings is NOT generated by this grammar?
Let's analyze the grammar:
S A B (The start symbol generates a concatenation of A and B)
A a A | (A generates zero or more a's)
B b B | (B generates zero or more b's)
This grammar generates strings with zero or more a's followed by zero or more b's.
In other words, the language generated by this grammar is L = {$a^n b^m | n,m \geq 0$}.
So, strings like "" (empty string), "a", "aa", "b", "bb", "ab", "aab", "abb", "aabb", etc. are all generated by this grammar.
However, any string that has a b before an a would NOT be generated by this grammar. For example, "ba", "bbaa", "aba", etc. are not generated by this grammar.
Answer: Strings with b's before a's, such as "ba" or "bbaa", are NOT generated by this grammar.
Digital Logic
Question 8: What is the minimum number of 2-input NOR gates required to implement a 2-input XNOR function?
An XNOR gate has the truth table:
| A | B | Output |
|---|---|--------|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
The Boolean function for XNOR is: A XNOR B = A'B' + AB = (A B)'
Let's implement this using NOR gates:
NOR gate truth table:
| A | B | NOR(A,B) | = (A + B)' |
|---|---|----------|----------|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 |
Implementation:
1. Using De Morgan's law, A' = (A)' = NOR(A,A)
So, we need 2 NOR gates to get A' and B'.
2. A XNOR B = A'B' + AB
= (A+B)' + (A'+B')'
= NOR(A,B) + NOR(A',B')
So, we need 1 NOR gate for NOR(A,B) and 1 NOR gate for NOR(A',B').
3. Finally, we need 1 NOR gate to combine these two results:
(A XNOR B) = NOR(NOR(A,B), NOR(A',B'))' = NOR(NOR(NOR(A,B), NOR(A',B')), NOR(NOR(A,B), NOR(A',B')))
Adding up all the NOR gates:
- 2 for A' and B'
- 1 for NOR(A,B)
- 1 for NOR(A',B')
- 1 for the final combination
Total = 2 + 1 + 1 + 1 = 5 NOR gates
However, there's a more efficient implementation:
A XNOR B = (A B)' = (A'B + AB')'
= ((A)NOR(B) NOR NOR(A,NOR(A,B)))NOR(B,NOR(B,NOR(A,B)))
This implementation uses 5 NOR gates as well.
Let me think of another approach:
A XNOR B = ((A+B)(A'+B'))'
= (A+B)' + (A'+B')'
= NOR(A,B) + NOR(A',B')
= NOR(NOR(A,B), NOR(NOR(A,A), NOR(B,B)))
This implementation uses:
- 2 NOR gates for A' and B'
- 1 NOR gate for NOR(A,B)
- 1 NOR gate for NOR(A',B')
- 1 NOR gate for the final combination
Total = 5 NOR gates
There's an even more efficient implementation:
A XNOR B = ((A'B) (AB'))'
= ((A+B')' (A'+B)')'
= NOR(A,B') + NOR(A',B)
= NOR(NOR(A,B'), NOR(A',B))
= NOR(NOR(A,NOR(B,B)), NOR(NOR(A,A),B))
This implementation uses:
- 1 NOR gate for B'
- 1 NOR gate for A'
- 1 NOR gate for NOR(A,B')
- 1 NOR gate for NOR(A',B)
- 1 NOR gate for the final combination
Total = 5 NOR gates
Answer: The minimum number of 2-input NOR gates required to implement a 2-input XNOR function is 5.
Reference Files For Detailed Solutions Of GATE 2019 : Computer Science & IT
File Name
4ufrep_cs_gate_2019_sol_1.pdf
File Size
1.61 MB
File Type
PDF
File Site
Description
This file is just a reference file for Detailed Solutions Of GATE 2019 : Computer Science & IT. Does not guarantee that the specific things you want are included in it.
Direct download (wait 10 seconds)
Detailed Solutions Of GATE 2019 : Computer Science & IT and Reference File Download Link
Admin
2026-06-14 01:04:13
GATE 2022 Computer Science & IT Book Checklist and Reference File Download Link
Admin
2026-06-10 16:20:13
Higher Education Commission Equivalence Of B.Sc. Computer Engineering To M.Sc. Computer Sc...
Admin
2026-06-13 12:48:18
Gate Sizing and Reference File Download Link
Admin
2026-06-06 08:12:10
GATE Mechanical Exam Preparation and Reference File Download Link
Admin
2026-06-09 03:58:15
We use cookies to enhance your browsing experience and analyze site traffic. By clicking 'Accept all cookies', you agree to the use of these cookies. You can manage your preferences or learn more in our [Privacy Policy/Cookie Policy.