GATE Computer Science IT Solved Paper 2001 2015
GATE Computer Science IT Solved Paper 2001 2015
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 2
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 3
Contents
Chapter : 1 C-Programming
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 4
Chapter : 7 DBMS
1. ER Model
2. Functional Dependencies and Normalization
3. SQL
4. Relational Algebra and Calculus
5. Transactions and Concurrency Control
6. File Structures and Indexing
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 5
Chapter : 1 C-Programming
C Programming
2. What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an
integer requires four bytes of memory. GATE-2015 (SET-1)
int main () {
unsigned int [4][3] =
{{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
printf(“%u, %u, %u”, x+3, *(x+3), *(x+2)+3);
(a) 2036, 2036, 2036 (b) 2012, 4, 2204 (c) 2036, 10, 10 (d) 2012, 4, 6
(a) ABCD EFGH (b) ABCD (c) HGFE DCBA (d) DCBA
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 6
# include <stdio.h>
int f1(void);
int f2 (void);
int f3(void);
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 7
int x = 10;
int main ( )
{
int x= 1;
x += f1( ) + f2( ) + f3( ) + f2( );
printf (“%d”, x);
return 0;
}
# include<stdio.h>
int main ( )
{
static int a[ ] = {10, 20, 30, 40, 50};
static int *p[ ] = {a, a+3, a+4, a+1, a+2};
int **ptr = p;
ptr++;
printf(“%d%d”, ptr-p,**ptr);
}
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 8
void f2 (int*a,int*b)
{
intc;
c=*a; *a=*b; *b=c;
}
a b c
4 5 6 6 5
1000 2000 3000
When the function f1(a,b) is called, values of a, b are passed
So,
a b c
5 4 5 4 4
4000 5000 6000
Now (c–a–b) = 5 – 4 – 6= –5
Ans : 2 a
1 2 3
4 5 6
EXP: int X [4] [3] = is a 2D array
7 8 9
10 11 12
%, X +3 indicates skipping 3 row’s from the base address but the 4th row is not yet selected as there is no
* operator involved
so, 9 elements are skipped and every element is of 4 bytes
2000 + 9 4 = 2036
%, *(X +3) indicates skipping three rows and the 4th row is selected which also points to the some address
2036
%, *(X + 2)+3 indicates skipping two rows, third row is selected and then skipping 3 columns but the
elements are not yet selected as further no * operator is involved.
i.e., 2000 + (64) + (34) = 2036 Hence, option (a) is correct.
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 9
Ans : 3 d
EXP: The program prints all characters before ‘ ‘ or ‘/0’ (whichever comes first) in reverse order.
Hence, the correct option is (d) DCBA
Ans : 4 Numerical answer : 51
EXP:
fun(5) = 1 + fun(1) fun(4) + fun(2) fun(3) + fun(3) fun(2) + fun(4) fun(1)
= 1 + 2 [fun(1) fun(4) + fun(2) fun(3)] …(1)
Putting the value of fun(1) = 1
The equation (1) becomes
1 + 2 [fun(4) + fun(2) fun(3)]
Now calculating the value of fun(2), fun(3) and f(4) respectively,
fun(2) = 1 + fun(1) fun(1) = 1 + 1 1 = 2
fun(3) = 1 + 2 fun(1) fun(2) = 1 + 2 1 2 = 5
fun(4) = 1 + 2 fun(2) fun(3) + fun(2) fun(2) = 1 + 2 1 5 + 2 2 = 15
Substituting these values in equation (1)
fun(5) = 1 + 2 [15 + 2 5] = 51
EXP: x + = f1( ) + f2 + f3 ( ) + f2 ( );
x = x + f1 ( ) + f2( ) + f3 ( ) + f2 ( );
f1( ) returns 26
f2 ( ) returns 51
f3 ( ) returns 100
second call to f2 ( ) returns 52
(x is static in f2( ))
x = 1+26+51+100+52 = 230
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 10
int **p = p;
ptr ++;
2000
ptr
ptr 2004
ptr
ptr p 2004 2000 1 (because it means skipping 1 element)
** ptr 40
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 11
1. Consider the following two C code segments. Y and X are one and two dimensional arrays of size n
and n n respectively, where 2 n 10 .Assume that in both code segments, elements of Y are
initialized to 0 and each element X[i][j] of array X is initialized to i+j. Further assume that when
stored in main memory all elements of X are in same main memory page frame.
Code segment 1: GATE-2015 (SET-3)
// initialize elements of y to 0
// initialize elements of X[i][j] of x to i+j
For(i = 0; i < n; i++)
Y[i] += X[0][i];
Code segment 2:
// initialize elements of y to 0
// initialize elements of X[i][j] of x to i+j
For(i = 0; i < n; i++)
Y[i] += X[i][0];
Which of the following statements is/are correct?
S1: Final contents of array y will be same in both code segments
S2: Elements of array X accessed inside the for loop shown in code segment 1 are
contiguous in main memory
S3: Elements of array X accessed inside the for loop shown in code segment 2 are
contiguous in main memory.
(a) Only S2 is correct
(b) Only S3 is correct.
(c) Only S1 and S2 are correct.
(d) Only S1 and S3 are correct.
2. A program P reads in 500 integers in the range [0, 100] representing the scores of 500 students. It then
prints the frequency of each score above 50. What would be the best way for P to store the
frequencies? GATE-2005 (SET-3)
(a) An array of 50 numbers (b) An array of 100 numbers
(c) An array of 500 numbers (d) A dynamically allocated array of 550 numbers
3. A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite
ends of the array. Variables top1 and top2 (top1 < top2) point to the location of the topmost element in
each of the stacks. If the space is to be used efficiently, the condition for “stack full” is
GATE-2004
(a) (top 1 = MAXSIZE/2) AND (top 2 = MAXSIZE/2 + 1)
(b) top 1 + top 2 = MAXSIZE
(c) (top 1 = MAXSIZE/2) or (top 2 = MAXSIZE)
(d) top 1 = top 2 – 1
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 12
4. Two matrices M1 and M 2 are to be stored in arrays A and B respectively. Each array can be stored
either in row-major or column-major order in contiguous memory locations. The time complexity of
6. Suppose a stack implementation supports an instruction REVERSE, which reverses the order of
elements on the stack, in addition to the PUSH and POP instructions. Which one of the following
statements is TRUE with respect to this modified stack? GATE-2014
(a) A queue cannot be implemented using this stack.
(b) A queue can be implemented where ENQUEUE takes a single instruction and DEQUEUE takes
a sequence of two instructions.
(c) A queue can be implemented where ENQUEUE takes a sequence of three instructions and
DEQUEUE takes a single instruction.
(d) A queue can be implemented where both ENQUEUE and DEQUEUE take a single instruction
each.
7. Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a
global parameter GATE-2013
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 n queue operations on an initially empty
queue?
(a) (n) (b) (n + k) (c) (nk) (d) (n2)
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 13
Ans : 1 c
EXP: Basically, what this program is describing is that
In C, 2D arrays are stored in row major order.
Therefore, S2 is correct, but S3 is not correct.
Ans : 2 a
EXP: An array of size 50 looks the best option to store number of students for each score. We need to
store frequencies of scores above 50. We can ignore scores below 50 and to index the scores above 50.
Ans : 3 d
EXP: A single array
As both stack grow from the opposite end of the array and grow in the opposite direction so stack will
be full only if both Top1 and Top2 are adjacent to each other. Only option (d) satisfies the condition.
Ans : 4 d
EXP: Since matrices are stored in array, complexity is independent of how they are stored. If the starting
address of array is known, with indexes of elements their address can be calculated.
Ans : 5 c
EXP: 10 5 + 60 6 / * 8 –
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 14
/
6 10
5
60 15
10
15
*
10
15
150
8 142
150
Ans : 6 c
EXP: We can implement queue with the help of two stacks but if we have one stack with REVERSE
operation then we can implement the queue operation.
For de-queue operation
(i) Pop the top of the stack
For Enqueue operation
(i) REVERSE (ii) PUSH (iii) REVERSE
So de-queue can be implemented by 1-stack operation and enqueue can be implemented by 3-stack
operation option (c) is correct.
Ans : 7 c
EXP: In the stack and queue every operation takes 0(1) time. Here there are total n operations.
Let a be the en-queue operations
b be the de-queue operations
c be the multi-queue operation
a+b+c=n
All en-queue, de-queue, and multi-queue operations takes constant time so total time complexity is
0(n).
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 15
Which one of the following most closely approximates the return value of the function funl?
(a)n3 (b) n (log n)2 (c) n log n (d) n log (log n)
2. Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The
lower bound for the number of operations to convert the tree to a heap is GATE-2015 SET-1
n
3. Consider the equality i 3 X and the following choices for X GATE-2015 SET-3
i 0
I. (n 4 )
II. ( n5 )
III. o(n5 )
IV. ( n3 )
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 16
5. Let f(n) =n and g(n) = n(1+sin n), where n is a positive integer. Which of the following statements
is/are correct? GATE-2015 SET-3
I. f (n) o( g (n))
II. f (n) ( g ( n))
(a) Only I
(b) Only II
(c) Only I and II
(d) Neither I nor II
Ans : 1 d
EXP:
int fun 1(intn)}
int, i, j, k, p, q = 0;
for (i=1; i<n; i++) This loop runs (n) time
}
p =0
for (j=n; j>1; j=j/2)This loop runs logn time and P =
logn
for (k=1;k<p; k=k2)This loop also runs (Logn) time and
k=log logn [p=logn], 2k = logn, [k=loglogn]
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 17
Ans : 2 a
EXP: Call Max-heapify procedure which recurses at most through the height of the heap i.e.,
(logn)
Ans : 3 c
EXP:
i3 X
i 0
i.e. = 13 2 2 33 43 ....
2
n(n 1) n 2 (n 1) 2
O(n 4 ) or O(n5 ) or (n3 )
2 4
Ans : 4 b
EXP:
Total 25 calls
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 18
Ans : 5 d
EXP:
f ( n) n
g (n) n(1sin n)
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 19
55. The number of min-terms after minimizing the following Boolean expression is ___________.
[D’ + AB’ +A’C +AC’D + A’C’D]’ GATE-2015 SET-2
ANS: 1
40. Given the function F = P’ + QR, where F is a function in three Boolean variables P, Q and R and P’ = !
P, consider the following statements. GATE-2015 SET-3
(S1) F = (4, 5, 6)
(S2) F = (0, 1, 2, 3, 7)
(S3) F = (4, 5, 6)
(S4) F = (0, 1, 2, 3, 7)
Which of the following is true?
(a) (S1)- False, (S2)-True, (S3)-True, (S4)-False
(b) (S1)- True, (S2)-False, (S3)-False, (S4)-True
(c) (S1)- False, (S2)-False, (S3)-True, (S4)-True
(d) (S1)- True, (S2)-True, (S3)-False, (S4)-False
ANS: a
62. The total number of prime implicants of the function f ( w, x, y, z ) (0,2,4,5,6,10) is _____.
GATE-2015 SET-3
ANS: 3
F ( P, Q, R, S ) PQ PQR PQRS
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 20
2. The dual of a Boolean function F(x1, x2, …., xn, +, ., ’) FD, is the same expression as that of F with +
and. Swapped. F is said to be self duel if F = FD. The number of self dual functions with n Boolean
variables is GATE-2014: SET2
n n1
(a.) 2n (b.) 2n – 1 (c.) 22 (d.) 22
F ( P, Q, R, S ) 0, 2,5,7,8,10,13,15
The minterms 2, 7, 8 and 13 are ‘do not care’ terms. The minimal sum – of – products form for F is
(a.) QS QS (b.) QS QS
(c.) QRS QRS QRS QRS (d.) PQS PQS PQS PQS
Ans : 1 a
EXP:
F ( P , Q , R , S ) PQ PQR PQRS
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 21
Ans : 2 d
EXP: For ‘n’ variables.
n
Total number of Boolean functions = 22
n 1
And number of self dual functions = 2 2
Ans : 3 b
EXP: F (P, Q, R, S) = (0, 2, 5, 7, 8, 10, 13, 15)
Where 2, 7, and 13 are don’t care
K – map
Ans : 4 a
EXP: Verifying commutative law:
x y x2 y 2 y 2 x2 y x
Commutative
Verifying associative law:
x y z x y 2 z 2 x2 y 2 z 2 ... 1
2
x y z x2 y 2 z x2 y 2 ... 2
2
z
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 22
(a) Either S1 or S2
(b) Either S2 or S3
2. Consider a processor with byte-addressable memory. Assume that all registers, including Program
Counter (PC) and Program Status Word (PSW), are of size 2 bytes. A stack in the main memory is
implemented from memory location (0100)16 and it grows upward. The stack pointer (SP) points to the
top elements of the stack. The current value of SP is (016E)16. The CALL instruction is of two words, the
first word is the op-code and the second word is the starting address of the subroutine (one word = 2
The content of PC just before the fetch of a CALL instruction is (5FA0)16. After execution of the CALL
3. A machine has a 32-bit architecture, with 1-word long instructions. It has 64 registers, each of which is
32 bit long. It needs to support 45 instructions, which have an immediate operand in addition to two
register operands. Assuming that the immediate operand is an unsigned integer, the maximum value
4. Consider a hypothetical processor with an instruction of type LW R1, 20 (R2), which during execution
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 23
reads a 32-bit word from memory and stores it in a 32-bit register R1. The effective address of the
memory location is obtained by the addition of constant 20 and the contents of register R2. Which of the
following best reflects the addressing mode implemented by this instruction for the operand in memory?
GATE : 2011
5. A computer handles several interrupt sources of which ,the following are relevant for this question.
GATE : 2011
Interrupt from CPU temperature sensor ( raises interrupt if CPU temperature is too high).
Interrupt from mouse ( raises interrupt if the mouse is moved or a button is pressed).
Interrupt from hard disk ( raises interrupt when a disk read is completed).
(c.) Interrupt from Keyboard (d.) Interrupt from CPU temperature sensor
Ans : 1 a
Ans : 1 d
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 24
number of Registers: 64
x = 32 – 18 = 14bits
4. ANS: d
LW R1 , 20( R2 )
Immediate Addressing:
Register Addressing:
EA of memory: 20 + [R2]
R1 M 20 [ R2 ]
In indexed AM, content of index register is added to address part of the instruction, to obtain the
effective address.
5. ANS: d
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 25
1. Consider a uniprocessor system executing three tasks T1, T2 and T3, each of which is
composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals
of 3, 7 and 20 milliseconds, respectively. The priority of each task is the inverse of its period,
and the available tasks are scheduled in order of priority, with the highest priority task
scheduled first. Each instance of T1, T2 and T3, requires an execution time of 1, 2 and 4
milliseconds, respectively. Given that all tasks initially arrive at the beginning of the 1st
millisecond and task preemptions are allowed, the first instance of T3 completes its execution
at the end of __________ milliseconds. GATE-2015 SET-1
2. For the processes listed in the following table, which of the following scheduling schemes will give the
lowest average turnaround time? GATE-2015 SET-3
Process Arrival time Processing time
A 0 3
B 1 6
C 4 4
D 6 2
(a) First Come First Serve
(b) Non-preemptive shortest job First
(c) Shortest Remaining Time
(d) Round Robin with Quantum value two
3. Consider the following set of processes that need to be scheduled on a single CPU. All the times are
given in milliseconds.
Process Name Arrival Time Execution Time
A 0 6
B 3 2
C 5 4
D 7 6
E 10 3
Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in
msec) is ________________. GATE-2014
2. Three processes A, B and C each execute a loop of 100 iterations. In each iteration of the loop, a
process performs a single computation that requires tc CPU milliseconds and then initiates a single I/O
operation that lasts for tio milliseconds. It is assumed that the computer where the processes execute
has sufficient number of I/O devices and the OS of the computer assigns different I/O devices to each
process. Also, the scheduling overhead of the OS is negligible. The processes have the following
characteristics: GATE-2014
Process id tc tio
A 100ms 500ms
B 350ms 500ms
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 26
C 200ms 500ms
The processes A, B, and C are started at times 0, 5 and 10 milliseconds respectively, in a pure time
sharing system (round robin scheduling) that uses a time slice of 50 milliseconds. The time in
milliseconds at which process C would complete its first I/O operation is __________.
3. An operating system uses shortest remaining time first scheduling algorithm for pre-emptive
scheduling of processes. Consider the following set of processes with their arrival times and CPU
burst times (in milliseconds): GATE-2014
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 27
Ans : 2 c
EXP: Turnaround time is the total time token between the submission of a program for execution and the
return of the complete output.
Turnaround time = Completion time – Arrival time
FCFS = First come first serve (A, B, C, D)
SJF = Non-pre emptive shortest job first (A, B, C, D)
SRT = Shortest remaining time first (A(3), B(1), C(4), D(2), B(5))
RR = Round Robin with time quantum 2
(A(2), B(2), A(1), C(2), B(2), D(2), C(2), B(2))
Ans : 3 Numerical answer : 7.2 m sec
EXP:
Process name Arrival name Execution time Completion time Turnaround time
A 0 6 8 8
B 3 2 5 2
C 5 4 12 7
D 7 6 21 14
E 10 3 15 5
36
CPU Scheduling Algo:
Shortest remaining time First (SRTF)
A B A A C C E D
0 3 5 7 8 10 12 15 21
36
Average T.A.T = 7.2m sec
5
Ans : 4 Numerical answer : 1000
EXP:
Process ID Arrival Time tc t IO
A 0ms 100ms 500ms
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 28
Ready Queue:
A, B, C, A, B, C, B, C, B, C, B..........
At t = 200, process A completes its computation and initiates its first I/O operation which completes
at t = 700ms.
At t = 500, process C initiates its first I/O operation which completes at t = 1000ms. Note that I/O
operations of different processes can be overlapped.
Whenever a process initiates I/O operation it changes its state from running state to wait state.
P1 P2 P3 P3 P4 P1
0 2 6 8 12 17 27
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 29
Chapter : 7 DBMS
ER Model
1. Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an m:n
relationship R12. E1 and E3 are connected by a 1:n (1 on the side of E1 and n on the side of E3)
relationship R13.
E1 has two single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-valued
attributes a21 and a22 of which a21 is the key attribute. E3 has two single-valued attributes a31 and a32 of
which a31 is the key attribute. The relationships do not have any attributes.
If a relational model is derived from the above ER model, then the minimum number of relations that
would be generated if all the relations are in 3NF is ____________. GATE-2015 SET-I
2. Given the basic ER and relational models, which of the following is INCORRECT?
GATE-2012
(a) An attribute of an entity can have more than one value
(b) An attribute of an entity can be composite
(c) In a row of a relational table, an attribute can have more than one value
(d) In a row of a relational table, an attribute can have exactly one value or a NULL value
5. Let E1 and E2 be two entities in an E/R diagram with simple single-valued attributes. R1 and R2 are two
relationships between E1and E2, where R1 is one-to-many and R2 is many-to-many. R1 and R2 do not
have any attributes of their own. What is the minimum number of tables required to represent this
situation in the relational model? GATE-2005
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 30
ER Model
Ans : 3 b
EXP:
Double rectangle represents weak entity set, double lines indicate total participation of an entity in a
relationship set.
Strong entities are represented by separate tables, thus M, P are represented by separate tables.
Relation 1: R1 (M1, M2, M3, P1)
Relation2: R2 (P1, P2), N is a weak entity set.
Relation3: R3(N1, N2, P1)
Thus 3 tables are required.
Ans : 4 a
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 31
Ans : 5 b
EXP:
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 32
Consider the DFAs M and N given above. The number of states in a minimal DFA that accepts the
language L(M) L(N) is _________. GATE-2015 SET-1
ANS: 1
EXP: The language accepted by machine M is “strings ending with a”
The language accepted by machine N is “string ending with b”
The intersection between the two is as no string can end with both ‘a’ and ‘b’.
so, for language = , the machine requires only one state.
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 33
(a) (b)
(c) (d)
Which one of the following statements follows from S1 and S2 as per sound inference rules of logic?
3. Which one of the following well formed formulae is a tautology? GATE-2015 SET-2
(a) x y R ( x, y ) y x R ( x, y )
(b) (x [y R( x, y ) S ( x, y )]) x y S ( x, y )
(c) [x y ( P ( x, y ) R ( x, y )] [x y ( P( x, y ) R( x, y )]
(d) x y P ( x, y ) x y ( P ( y, x)
4. In a room there are two types of people, namely Type 1 and Type 2. Type 1 people always till the truth
and Type 2 people always lie. You give a fair coin to a person in that room, without knowing which
type he is from and tell him to toss it and hide the result from you till you ask for it. Upon asking, the
person replies the following GATE-2015 SET-3
“The result of the toss is head if and only if I am telling the truth.”
Which of the following options is correct?
(a) The result is head
(b) The result is tail
(c) If the person is of Type 2, then the result is tail
(d) If the person is of Type 1, then the result is tail.
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 35
ANS: 1 c
EXP: Pstands for Ex-NOR
i.e., (P’q’ + pq)
now checking out the options. The correct option is (c)
(p’ + q) (p+q’)
= p’p + q’q’ + pq + qq’
= o + p’q’ + pq + o
= p’q’ + pq
ANS: 2 c
EXP:
S1 : If a candidate is known to be corrupt, then he will not be elected.
S2 : If a candidate is kind, he will be elected.
If pq, then qp
So from S1 , elected not corrupt; and S2 is, kind elected
Therefore, kind not corrupt
ANS: 3 a
ANS: 4 a
EXP: “The result of the Toss is head if any only if I am telling the truth”
If the person is of type 1 who always tell truth, then result must be head.
If the person is of type 2 who always tell lie, then result must be head.
Negation of a sentence of the form “X is true if and only if Y is true” is “Either X is true and Y is false,
or X is false and Y is true”.
Which means “Either toss is head and I am not telling truth, or toss is tail and I am telling truth”
Since the person always lie, it is “Either toss is head and I am not telling truth”.
x x
40
32 64
x
40
64
x 2560 bits = 320 bytes
2. Consider a LAN with four nodes S1, S2, S3 and S4. Time is divided into fixed-size slots, and a
node can begin its transmission only at the beginning of a slot. A collision is said to have
occurred if more than one node transmit in the same slot. The probabilities of generation of
a frame in a time slot by S1, S2, S3 and S4 are 0.1, 0.2, 0.3 and 0.4, respectively. The
probability of sending a frame in the first slot without any collision by any of these four
stations is _________. GATE-2015 SET-1
ANS: 2 Numerical Answer : 0.40 to 0.46
3. A link has a transmission speed of 106 bits/sec. it uses data packets of size 1000 bytes each. Assume that
the acknowledgment has negligible transmission delay, and that its propagation delay is the same as the
data propagation delay. Also assume that the processing delays at nodes are negligible. The efficiency of
the stop-and-wait protocol in this setup is exactly 25%. The value of the one-way propagation delay (in
milliseconds) is _________ GATE-2015 SET-2
ANS: 3 Numerical Answer : 12
EXP: In stop and wait protocol next packet is sent only when acknowledgment of previous packet is
received.
This causes poor link utilization.
Transmission speed = 106
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 37
(1000 8) bits
Time to send a packet = = 8 milliseconds
106
(8 100)
Since, link utilization or efficiency is 25%, total time taken for 1 packet is = 32
25
milliseconds.
Total time is twice the one way propagation delay plus transmission delay. Propagation delay has to be
considered for packet and acknowledgment both.
Transmission delay is considered only for the packet as the question says that transmission delay for
acknowledgement is negligible.
Let propagation delay be x
2x+8 = 32
x = 12
4. Consider a CSMA/CD network that transmits data at a rate of 100 Mbps (108 bits per second) over a 1
km (Kilometer) cable with no repeaters. If the minimum frame size required for this network is 1250
bytes, what is the signal speed (km/sec) in the cable ? GATE-2015 SET-3
(a) 8000 (b) 10000 (c) 16000 (d) 20000
ANS: 4 d
EXP: Data should be transmitted at the rate of 100 Mbps
Transmission time = 2 * propagation time
2 10 106 m / sec
2 10 103 km / sec
20000km / sec
5. Consider a network connecting two systems located 8000 kilometers apart. The bandwidth of the
network is 500106 bit per second. The propagation speed of the media is 4106 meters per second. It
is needed to design a Go-Back-N sliding window protocol for this network. The average packet size
is 107 bits. The network is to be used to its full capacity. Assume that processing delays at nodes are
negligible. Then, the minimum size in bits of the sequence number field has to be _________.
GATE-2015 SET-3
ANS: 3 Numerical Answer : 8
EXP:
8000 1000
Propagation time 2sec
4 106
Total round trip propagation time = 4 sec.
Packet size
Transmission time for one packet
bandwidth
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com
GATE Solution Computer Science & IT 38
10 7
0.02sec.
500 10 6
400
Total no. of packets that can be transferred before an acknowledgement comes back = 200
0.02
Maximum possible window size is 200
In GoBack-N protocol, max. sequence no. should be one more than window size.
So total 201 sequence numbers are needed 201 different sequence no. can be represented
using 8 bits.
6. Two hosts are connected via a packet switch with 107 bits per second links. Each link has a
propagation delay of 20 microseconds. The switch begins forwarded a packet 35 microseconds after it
receives the same. If 10000 bits of data are to be transmitted between the two hosts using a packet size
of 5000 bits, the time elapsed between the transmission of the first bit of data and the reception of the
last bit of the data in microseconds is ________. GATE-2015 SET-3
ANS: 3 Numerical Answer : 1575
500
EXP: Sender host transmits first packet to switch, the transmission time is which is 500ms.
107
After 500ms, the second packet is transmitted.
The first packed reaches destination in 500 + 35 + 20 + 20 +500 = 1075 ms.
While the first packet is travelling to destination, the second packet starts its journey after 500ms. and
rest of the time taken by second packet overlaps with first packet. So overall time is
1075 + 500 = 1575
Classroom Course
GATE SOLVED PAPER : Computer Science & IT by ENGINEERS INSTITUTE OF INDIA® All Rights Reserved
28-B/7, Jia Sarai, Near IIT, Hauz Khas, New Delhi-110016. Ph. 011-26514888. www.engineersinstitute.com