Vous êtes sur la page 1sur 100

# In order to avoid deadlock, the correct operators at L1, L2, L3 and L4 are respectively

## (A) P(Sy),P(Sx);P(Sx),P(Sy) (B) P(Sx),P(Sy);P(Sy),P(Sx)

(C) P(Sx),P(Sx);P(Sy),P(Sy) (D) P(Sx),P(Sy);P(Sx),P(Sy)

SOLUTION

Here semaphores are required to obtain mutual exclusion since both access X & Y . So at L1
P(Sx) which means now Sx = wait at L2P(Sy) Sy wait, this prevents process P2 to start access X
&Y .

V(Sx) & V(Sy) in the end of P1 makes Sx & Sy signal so that at L3 & L4 P(Sx) & P(Sy) can start.

## Hence (D) is correct option.

Question. 24

A Unix-style I-node has 10 direct pointers and one single, one double and one triple indirect
pointers. Disk block size is 1 Kbyte, disk block address is 32 bits, and 48-bit integers are used.
What is the maximum possible file size?

(A) 224 bytes (B) 232 bytes (C) 234 bytes (D) 248 bytes

SOLUTION

Size of 1 block = 1 kB
Block addresses size 1 pointer size = 32 bit
= 4 bytes.
So, no. of pointers in= 210B/ 22B
1 block = 256
So direct pointer will have = 10*1kB = 10kB
Double will have = 256*256*1 kB
Triple will have = 256*256*256*1 kB
= 28*28*28*210 B = 234 B
Hence (C) is correct option.
YEAR 2005

Question. 25

Suppose n processes, P1Pn share m identical resource units, which can be reserved and
released one at a time. The maximum resource requirement of process Pi is sp where si<0.
Which one of the following is a sufficient condition for ensuring that deadlock does not occur?

## (A) i, s < m (B) i,s,< n

n n
(C) si < (m +n) (D) si < (m * n)
i=1 i=1
101
SOLUTION

For every Pi Si is maximum resource requirement where Si > 0. To allot resources to all
processes without any deadlock situation is

n
si < (m +n)
i=1

i.e. sum of all maximum resource requirement should be less than m +n.

Question. 26

if (fork()==0)

## {a = a +5; printf("%d,%/n"a, and a);}

else {a 5; printf("%d,%d/n",a,&a);}

let u, v be the values printed by the parent process, and x,y be the values printed by the child
process. Which one of the following is TRUE?

(A) u = x+10 and v = y (B) u = x+10 and vy (C) u+10 = x and v = y (D) u+10 = x and v y

SOLUTION

Initial value of a is let 10 and its address &a would be different for both parent & child process
so.

(A) & (B) are incorrect also parent process executes a = a 5 = 5 = u & child executes a = a +5
= 15 = x so u +10 = x

## Hence (D) is correct option.

YEAR 2006

Question. 27

Consider three CPU-intensive processes, which require 10,20 and 30 time units and arrive at
times 0,2, and 6, respectively. How many context switches are needed if the operating system

102
implements a shortes remaining time first scheduling algorithm? Do not count the context
switches at time zero and at the end

## (A) 1 (B) 2 (C) 3 (D) 4

SOLUTION

When CPU burst are given to another process, called context switching. The Gantt chart for
shortest remaining time first is.

## Hence (B) is correct option.

Question. 28

The atomic feth-and-set x,y instruction unconditionally sets the memory location x to 1 and
fetches the old value of x in y without allowing any intervening access to the memory location
x. Consider the following implementation of P and V functions on a binary semaphore S.

void p (binary_semaphore*S){
unsigned y;
unsigned*x =& (S->value);}
do {
fetch-and-set x,y;
} while(y);
}
void V (binary_semphore*S){
S_>value = 0;
}

## (D)The code does not implement a binary semaphore

103
SOLUTION

If there are more than two processes and context & switching processes is disabled in P then
this implementation doesnt work properly and cant synchronize the processes.

## Hence (A) is correct option.

Question. 29

A CPU generates 32-bit virtual addresses. The page size is 4 KB. The processor has a
translation look-aside buffer (TLB) which can hold a total of 128 page table entries and is 4-
way set associative.

## (A)11bits (B) 13bits (C) 15bits (D) 20bits

SOLUTION

TLB has 128 page table enteries, each page table would have. 64 bits i.e. 32 +32 virtual

27*26

27*26/22 = 211

## Hence (A) is correct option.

Question. 30

A computer system supports 32-bit virtual addresses as well as 32-bit physical addresses, Since
the virtual address space is of the same size as the physical address space, the operating system
designers decide to get rid of the virtual entirely. Which one of the following is true?

## (D)CPU scheduling can be made more efficient now

104
SOLUTION

Since both virtual and physical memory has 32 bit addresses, so there is no need for address
translation hardware is required.

## Hence (C) is correct option.

Question. 31

Consider three processes (process id 0,1,2, respectively) with compute time bursts 2,4, and 8
time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF)
scheduling algorithm. In LRTF ties are broken by giving priority to the process with the
lowest process id. The average turn around time is

SOLUTION

Process id 0 1 2

CPU Burst 2 4 8

## At t = 4 remaining times for both P1 & P2 is 4 so P1 is given priority.

At t = 8 remaining time for P0P1 & P2 is 2. P0 is given priority & cyclically done till t = 14.

Process TAT
P0 12 0 = 12
P1 13 0 = 13
P2 14 0 = 14
39/3=13 units

## Hence (A) is correct option.

Question. 32

105
Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30
units, respectively. Each process spends the first 20% of execution time doing I/O, the next
70% of time doing computation, and the last 10% of time doing I/O again.The operating system
uses a shortest remaining compute time first scheduling algorithm and schedules a new process
either when the running process get blocked on I/O or when the running process finishes its
compute burst. Assume that all I/O operations can be overlapped as much as possible. For what
percentage of time does the CPU remain idle?

SOLUTION

2 7 1 10
2 4 14 2 20
3 6 21 3 30

Gantt chart

=(6/51)*100

=10.6%

## Hence (B) is correct option.

Question. 33

106
Consider the following snapshot of a system running n processes. Process i is holding xi
instances of a resource R, for 1in. Currently, all instances of R are occupied. Further, for all
i, process i has placed a request for an additional y, instances while holding the xi instances it
already has, There are exactly two processes p and q such that yp = yq = 0: Which one of the
following can serve as a necessary condition to guarantee that the system is not approaching a

(A) min(xp,xq) < maxkp,q yk (B) xp+xq maxkp,q yk (C) min(xp,xq) < 1 (D) min(xp,xq)>1

SOLUTION

## Here option (B) is that min (xp,xq) < maxk p,q yk

Means the min no. of resources allocated should be less than the maximum number of resources
required by any process other than p & q

## Data for Q. 34 & 35 are given below.

Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each
process in the set arrives at the barrier and waits for all others to arrive and then all processes
leave the barrier. Let the number of processes in the set be three and S be a binary semaphore
with the usual P and V functions. Consider the following C implementation of a barrier with
line numbers shown on the left.

Void barrier(void) {
1 :P(S)
2 :Process_arrived++;
3 :V (S) :
4 :while (process_arrived=3);
5 :P(S);
6 :Process_left++;
7 :if(process_left==3)
8 :process_arrived=0;
9 :process_left+0;
10 :}
11 :V(S);
}

The variable process_arrived and process_left are shared among all processes and are initialized
to zero. In a concurrent program all the three processes call the barrier function when they need
to synchronize globally.

Question. 34
107
The above implementation of barrier is incorrect. Which one of the following is true?

## (A)The barrier implementation is wrong due to the use of binary semaphore S

(B)The barrier implementation may lead to a deadlock if two barrier invocations are used in
immediate succession
(C)Lines 6 to 10 need not be inside a critical section
(D)The barrier implementation is correct if there are only two processes instead of three

SOLUTION

This barrier implementation is to keep track of arrival & completion of processes in system, by
incrementing no. of process arrived & left. This implementation may lead to deadlock if two
barrier functions invocations are used is immediate sessions.

SinceV(s) in first invocation at line 3 removes 1-3 from critical section bring 5-11 in critical
section at line 7.

Question. 35

## (A)lines 6 to 10 are simply replaced by process_arrived

(B)At the beginning of the barrier the first process to enter the barrier waits until
process_arrived becomes zero before proceeding to execute P(S)

(C)Context switch is disabled at the beginning of the barrier and re-enabled at the end.

SOLUTION

To rectify the barrier function at the beginning of the functions the first process which inters the
function waits until process arrived becomes zero before executing P(s).

## Hence (B) is correct option.

YEAR 2007

Question. 36

Group-1 contains some CPU scheduling algorithms and group-2 contains some applications.

108
Match entries in Group-1 entries in Group-2

Group-1 Group-2
P. Gang Scheduling 1.Guaranteed Scheduling
Q. Rate Monotonic Scheduling 2. Real-time scheduling
R. Fair Share Scheduling 3.Thread Scheduling

(A)P-3 Q-2 R-1 (B) P-1 Q-2 R-3 (C) P-2 Q-3 R-1 (D) P-1 Q-3 R-2

SOLUTION

Rate monotonic scheduling is for real time processes, Gang scheduling is used to schedule
group of program threads and fair share scheduling is a scheduling which guarantees a fair
share of CPU burst to every competing process.

## Hence (A) is correct option.

Question. 37

of the following statements is FALSE?

(A)Context switch time is longer for kernel level threads than for user level threads
(B)User level threads do not need any hardware support
(C)Related kernal level thread can be scheduled on different processors in a multiprocessor system

SOLUTION

Threading a method of executing small sub processes instead of single big process. This
prevents thread from blocking. So blocking of one kernel level thread doesnt block other

So (D) is false.

## Hence (D) is correct option.

Question. 38

An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm.
Consider the arrival times and execution times for the following processes

## Process Execution Time Arrival Time

P1 20 0
P2 25 15
P3 10 30
P4 15 45
109
What is the total waiting time for process P2?

SOLUTION

## Gantt chart for the processes.

P2 came at t = 15
Scheduled first time at t = 20 wait = 5.
Wait between t = 30 & t = 40 due to short remaining time of new process P3.
Wait now = 5 +10 = 15
Then complete at t = 55
Hence (B) is correct option.

Question. 39

A virtual memory system uses first In First Out (FIFO) page replacement policy and allocates a
fixed number of frames to a process. Consider the following statements:

P:Increasing the number of page frames allocated to a process sometimes increases the page
fault rate.

## Which one of the following is TRUE?

(A)Both P and Q are ture, and Q is the reason for P
(B)Both P and Q are true, but Q is not the reason for P
(C)P is false, but Q is true
(D)Both P and Q are false

SOLUTION

Due to Beladys Anomaly, increasing the number of page frames allocated to a process
sometimes increase the page fault rate so P is true.

Also some program do not exhibit locality of reference, so both are true but Q is not reason for
P.

## Hence (B) is correct option.

110
Question. 40

A single processor system has three resource types X,Y, and Z, which are shared by three
processes. There are 5 units of each resource type. Consider the following scenario, where the
column alloc denotes the number of units of each resource type allocated to each process, and
the column request denotes the number of units of each resource type requested by a process in
order to complete execution. Which of these processes will finish LAST?

alloc request
XYZ XYZ
P0 121 103
P1 201 012
P2 221 120

SOLUTION

Initially.

## Process Allow Request/need Available

XYZ XYZ XYZ
P0 121 103 012
P1 121 012
P2 221 120

Here looking at available resources, only need of P1 can be completed. So P1 will execute &
free 2 0 1 so now available XYZ = 203.

This is need for P0 so at second no. P0 will execute & free XYZ = 121 so available 3 2 4 & in
the end need of P2 is fulfilled.

## Hence (C) is correct option.

Question. 41

Two processes, P1 and P2, need to access a critical section of code. Consider the following
synchronization construct used by the processes:

/* P1 */ /*P2*/
while (true) { while (true) {
wants1=true; wants2 = true;
while(wants2==true); while (wants1 == true);
/* Critical /* Critical

111
Section Section

*/ */
wants 1 = false; wants 2 = false;
} }
/* Remainder section*/ /*Remainder section*/

Here, wants 1 and wants 2 are shared variables, Which are initialized to false. Which one of the
following statements is TRUE about the above construct?

## (A)It does not ensure mutual exclusion.

(B)It does not ensure bounded waiting.
(C)It requires that processes enter the critical section in strict alternation.
(D)It does not prevent deadlocks, but ensures mutual exclusion

SOLUTION

If P1 make wants 1 = true then P2 goes in critical section & vice versa so both together are
implementing mutual exclusion but. Since both are accessing wants 1 & wants 2 concurrently 4
wants 1 is first captured by P1 so P2 will wait & P2 captures want 2 so P1 will have to wait.

## Data for Q. 42 & 43 are given below.

A process has been allocated 3 page frames. Assume that none of the pages of the process are
available in the memory initially. The process makes the following sequence of page references
(reference string): 1,2,1,3,7,4,5,6,3,1.

Question. 42

If optimal page replacement policy is used, how many page faults occur for the above reference
string?

## (A) 7 (B)8 (C) 9 (D)10

SOLUTION

Reference string 1, 2, 1, 3, 7, 4, 5, 6, 3, 1

Using optimal replacement policy, we will replace that page in memory which either will not be
used or latest used in future.

112
*denotes page fault

## Hence (A) is correct option.

Question. 43

Least Recently Used (LRU) page replacement policy is a practical approximation to optimal
page replacement. For the above reference string, how many more page faults occur with LRU
than with the optimal page replacement policy?

## (A) 0 (B)1 (C) 2 (D)3

SOLUTION

Instead of optimal policy if we use LRU then we dont have future knowledge but we replace
that page in memory which has been recently used in past.

## *denotes page faults.

In this case no. of page fault = 9
In optimal strategy = 7
Difference = 9 7 = 2
Hence (C) is correct option.

113
YEAR 2008

Question. 44

Which of the following system calls results in the sending of SYN packets?

## (A) socket (B)bind (C) listen (D)connect

SOLUTION

SYN packets are used for synchronization between sender & receiver, these packets are sent by
sender during connect system call for synchronous connection.

## Hence (D) is correct option.

Question. 45

The data block of a very large file in the Unix file system are allocated using
(A) Contiguous allocation
(C) indexed allocation
(D) an extension of indexed allocation

SOLUTION

Generally a large file system for UNIX OS use indexed allocation, but for very large systems an
extension of indexed allocation i.e. ext 2, ext 3 are used.

## Hence (D) is correct option.

Question. 46

The P and V operations on counting semaphores, where s is a counting ewmaphore, are defined
as follows:

P(s);s = s 1;
If s < 0 then wait;
V(s): s = s +1;
If s <= 0 then wakeup a process waiting on s;

Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two
binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as
follows:

P( s ): Pb( Xb );
s = s-1;
if( s <0 ) {
114
Vb( Xb );
Pb( Yb );
}
else Vb ( Xb );
V( s ): Pb( Xb );
s = s+1;
if( s <= 0 ) Vb( Yb );
Vb( Xb );

## (A) 0 and 0 (B)0 and 1 (C) 1 and 0 (D)1 and 1

SOLUTION

Xb & Yb are binary semaphores used to implement mutual exclusion here. So when Xb is 1 Yb
should be zero so only 1 code between the two could run.

Since Pb(Xb) module implementing wait process so Xb should be 1. Pb(Yb) implementing signal
s = s +1

## So Yb should be 0 initially. Hence (C) is correct option.

Question. 47

Which of the following statements about synchronous and asynchronous I/O is NOT true?

(A) An ISR is invoked on completion of I/O in synchronous I/O but not in asynchronous I/O
(B)In both synchronous and asynchronous I/O an ISR (Interrupt Serive Routine) is
invoked after completion of the I/O
(C) A process making a synchronous I/O cal waits until I/O is complete, but a process making an
asynchronous I/O call does not wait for completion of the I/O
(D) In the case of synchronous I/O, the process waiting for the completion of I/O is woken up by
the ISR that is invoked afterr the completion of I/O

SOLUTION

For the completion of I/0 an interrupt should be generated for CPU in case of both synchronous
& asynchronous I/0 and this ISR call is before them.

## So CPU can switch to I/0. Hence (B) is correct option.

Question. 48

Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes?
115
(A) In deadlock prevention, the request for resources is always granted if the resulting state is
safe
(B) In deadlock avoidance, the request for resources is always granted if the resulting state is
safe
(D) Deadlock avoidance requires knowledge of resource requirements a priori

SOLUTION

Both deadlock prevention, & avoidance allocate resources if the resulting state is safe state so
option (A) & (B) are tree. The difference in both schemes is that in avoidance we know the
requirement a prior. But Deadlock avoidance is less restrictive than prevention is false.

## Hence (C) is correct option.

Question. 49

A process executes the following code for(i = 0;i < n;i ++) fork();

## (A) n (B)2n-1 (C) 2n (D)2n+1-1

SOLUTION

The loop is called for n times. The first process is parent process so this should not be counted
in child process. But after that every child process has its own child created so after every loop.

## Hence (B) is correct option.

Question. 50

A processor uses 36 bit physical addresses and 32 bit virtual addresses, with a page frame size
of 4 Kbytes. Each page table entry is of size 4 bytes. A three level page table is used for virtual-

bits 30-31 are used to index into the first level page table,
bits 21-29 are used to index into second level page table
bits 12-20 are used to index into third level page table
bits 0-11 are used as offset within the page

The number of bits required for addressing the next level page table(or page frame) in the page
table entry of the first, second and third level page table are respectively
116
(A) 20,20 and 20 (B)24,24 and 24 (C) 24,24 and 20 (D) 25,25 and 24

SOLUTION

## Total address single = 36 bit

First level no. of bits = 2*12 = 24 bits
Second level = 4*6 = 24 bits
Third level = 8*3 = 24 bits
Hence (B) is correct option.

YEAR 2009

Question. 51

## Consider a system with 4 type of resources R1 (3 units), R2 (2 units), R3 (3 units), R4

(4units). A non-preemptive resource allocation policy is used. At any give instance, a request
is not entertained if it cannot be completely satisfied. Three processes P1, P2, P3 request the
resources as follows if executed independently.

Which one of the following statements is TRUE if all three processes run concurrently starting
at time t = 0 ?

## (D)All three processes will be in deadlock

SOLUTION

Total resources = 3 2 3 2
117
Process 1Process 2Process 3Available
Time 1234 1234 1234 1234
0 0200 0020 0001 3011
1 0210 0020 0001 3001
2 0210 0021 2001 1000
3 0210 0021 2001 1000
4 0210 1021 2001 0000
5 1110 1021 0001 1100
6 1110 1011 0001 1110
7 1100 1011 0101 1020
8 1100 0000 0111 2021
9 1102 0000 0000 2130
10 0000 0000 0000 3232

## Hence (A) is correct option.

Question. 52

In which of the following page replacement policies, Beladys anomaly may occur ?

## (A) FIFO (B)Optimal (C) LRU (D)MRU

SOLUTION

Beladys anomaly is a properly of FIFO page replacement policy in which the no. of page faults
increases even if the no. of page frames are increased in some cases.

Question. 53

## (A)virtual page number

(B)page frame number
(C)Both virtual page number and page frame number
(D)access right information

SOLUTION

A page table is in main memory which mop a page frame to a virtual memory page.
So essential content is page frame number
Hence (B) is correct option.

118
Question. 54

Consider a disk system with 100 cylinders. The requests to access the cylinders occur in
following sequence :

## 4, 34, 10, 7, 19, 73, 2, 15, 6, 20

Assuming that the head is currently at cylinder 50, what is the time taken to satisfy all requests
if it takes 1 ms to move from one cylinder to adjacent one and shortest seek time first policy is
used?

## (A) 95ms (B) 119ms (C) 233ms (D) 276ms

SOLUTION

Arranging in order.

## Hence (B) is correct option.

Question. 55

In the following process state transition diagram for a uniprocessor system, assume that there
are always some processes in the steady state :

## I. If a process makes a transition D, it would result in another process making

transition A immediately
119
II. A process P2 in blocked state can make transition E while another process P1 is in
running state
III. The OS uses non-preemptive scheduling
IV. The OS uses non-preemptive scheduling

## Which of the above statement are TRUE ?

(A) I and II (B) I and III (C) II and III (D) II and IV

SOLUTION

## IIs not necessary that a new process enters immediately.

IIIs true different process can be in different states one is ready and another in running state.
IIIIs also correct since if one blocked it stop running so other can run.
IV Is not correct.
Hence (C) is correct option.

Question. 56

The enter_CS( ) and leave_CS( ) functions to implement critical section of a process are
realized using test and set instruction as follows :

Void enter_cs(X)
{
while (test-and-set)(X)) :
}
Void leave_CS(X)
{
X=0;
}

In the above solution, X is a memory location associated with the CS and is initialized to 0.
Now consider the following statements

## I. The above solution to CS problem is deadlock-free

II. II The solution is starvation free
III. The processes enter CS in FIFO order
IV. More than one process can enter CS at the same time

## (A) I only (B) I and II (C) II and III (D) IV only

SOLUTION

I Is true since X is initialized to zero, this cause only 1 process to enter into critical so no
120
II & III Are false, other process which doesnt capture X will wait so ultimately starve.

## Hence (A) is correct option.

Question. 57

A multilevel page table is preferred in comparison to a single level page table for translating

(A) It reduces the memory access time to read or write and memory location

(B) It helps to reduce the size of page table needed to implement the virtual address space
of a process

## (C) If is required by the translation look aside buffer

(D) If helps to reduce the number of page faults in page replacement algorithms.

SOLUTION

Single level page table is not preferred since it requires the number of page table entries equal
to the number of virtual memory addresses, but a multilevel page table has smaller number of
entries so reduce the size of page table needed.

## Hence (B) is correct option.

YEAR 2010

Question. 58

Consider the methods used by processes P1 and P2 for accessing their critical sections whenever
needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly
assigned.

## Method used by P1 Method used by P2

While(S1= = S2) While(S1!= S2)
Critical Section Critical Section
S1= S2; S2= not(S1);

## (A)Mutual exclusion nut nor progress

(B)Progress but not mutual exclusion
(C)Neither mutual exclusion nor progress
121
(D)Both mutual exclusion and progress

SOLUTION

Method used by P1 & P2 enters into critical section when S1 = S2 & S1! = S2 respectively, since
both are opposite conditions so mutual exclusion is there, but if P1's while loop true then it will
always be true & in P2 if while loop true it would run infinitely so no progress.

## Hence (A) is correct option.

Question. 59

A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded to
begin with. The system first accesses 100 distinct pages in some order and then accesses the
same 100 pages but now in the reverse order. How many page faults will occur ?

## (A) 196 (B) 192 (C) 197 (D) 195

SOLUTION

In FIFO page replacement policy, the pages which entered first are replaced first so for first 100
accesses, 100 page faults will occur. Now in memory there are last 4 pages 97, 98, 99 & 100th
page.

So during reverse access there 4 pages would not create any page fault & other 97 page faults.

Question. 60

## I. Shortest remaining time first scheduling may cause starvation

II. Preemptive scheduling may cause starvation
III. Round robin in better than FCFS in terms of response time

(A) I only (B) I and III only (C) II and III only (D) I, II and III

SOLUTION

I. SRIF scheduling may cause starvation since the processes which require large CPU
burst periods would have to wait.
122
II. Generally preemptive scheduling doesnt cause starvation but in some cases, it may
cause

starvation when one process doesnt block due to I/O so others have to wait.

III. It is quite obvious that due to preemption involvement round orbit is better than FCFS,
in

## Hence (D) is correct option.

Question. 61

The following program consists of 3 concurrent processes and 3 binary semaphores. The
semaphores are initialized as S0 = 1, S1 = 0, S2 = 0

## Process P0 Process P1 Process P2

while( true ){ wait ( S1 ); wait ( S2 );
wait ( S0 ); release ( S0 ); release ( S0 );
print 0
release ( S1 );
release ( S2 );
}

## How many times will process P0 print 0?

(A) At least twice (B) Exactly twice (C) Exactly thrice (D) Exactly
once

SOLUTION

Let us see what will happen initially S0 = 1, S1 = 0 S2 = 0 so P1 & P2 will wait & P0 runs & make S0 = 0 wait
decrements semaphore by 1 & release increments if by 1.
So after P0's 1st run S1 = 1 & S2 = 1 0 is printed
Now P1 & P2 can run & make S1 = 0, S2 = 0 but both increments S0 = 1 again.
So P0 again starts and print '0' so this would continue again & again.
So '0' will be printed at least twice.
Hence (A) is correct option.

Question. 62

A system has n resources R0..Rn-1, and k processes P0..Pk-1.The implementation of the resource
request logic of each process Pi, is as follows:

if (i%2==0){
123
if(i<n)request Ri;
if(i+2<n) request Ri+2;
}
else {
if (i<n) request Rn-i ;
if (i+2<n) request Rn-i-2;
}

## In which one of the following situations is a deadlock possible ?

(A) n=40, k=26 (B) n=21, k=12 (C) n=20 , k=10 (D) n=41, k=19

SOLUTION

## Allotment of resources would be successful to all cases but in option

(B) where n = 21 & k = 12.
Let use take i = 10
So for P10 only R10 can be allotted whereas for P11 odd case (else).
R2111 i.e R10 can only be allotted.
This is an conflict.
Hence (B) is correct option.

## DATABASE MANAGEMENT SYSTEMS

1) Which of the following statements are TRUE about an SQL query? (GATE 2012)
P: An SQL query can contain a HAVING clause even if it does not a GROUP BY clause
Q: An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R: All attributes used in the GROUP BY clause must appear in the SELECT clause
S: Not all attributes used in the GROUP BY clause need to apper in the SELECT clause
(A) P and R (B) P and S (C) Q and R (D) Q and S

P is correct. HAVING clause can also be used with aggregate function. If we use a HAVING
clause without a GROUP BY clause, the HAVING condition applies to all rows that satisfy the
search condition. In other words, all rows that satisfy the search condition make up a single
group. S is correct. To verify S, try following queries in SQL.

## CREATE TABLE temp

(
id INT,
name VARCHAR(100)
);

## INSERT INTO temp VALUES (1, "abc");

INSERT INTO temp VALUES (2, "abc");
INSERT INTO temp VALUES (3, "bcd");
INSERT INTO temp VALUES (4, "cde");
124
SELECT Count(*)
FROM temp
GROUP BY name;

Output:

count(*)
--------
2
1
1

2) Given the basic ER and relational models, which of the following is INCORRECT?
(GATE 2012)
(A) An attributes of an entity can have more that 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

The term entity belongs to ER model and the term relational table belongs to relational
model.
A and B both are true. ER model supports both multivalued and composite attributes

(C) is false and (D) is true. In Relation model, an entry in relational table can can have exactly
one value or a NULL.

3) Suppose (A, B) and (C,D) are two relation schemas. Let r1 and r2 be the corresponding
relation instances. B is a foreign key that refers to C in r2. If data in r1 and r2 satisfy
referential integrity constraints, which of the following is ALWAYS TRUE? (GATE
2012)

B is a foreign key in r1 that refers to C in r2. r1 and r2 satisfy referential integrity constraints.
So every value that exists in column B of r1 must also exist in column C of r2.

125
4) Which of the following is TRUE? (GATE
2012)
(A) Every relation in 2NF is also in BCNF
(B) A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on
every key of R
(C) Every relation in BCNF is also in 3NF
(D) No relation can be in both BCNF and 3NF

BCNF is a stronger version 3NF. So every relation in BCNF will also be in 3NF.

5) Consider the following transactions with data items P and Q initialized to zero:

if P = 0 then Q : = Q + 1 ;
write (Q) ;
if Q = 0 then P : = P + 1 ;
write (P) ;

## Any non-serial interleaving of T1 and T2 for concurrent execution leads to (GATE

2012)
(A) A serializable schedule
(B) A schedule that is not conflict serializable
(C) A conflict serializable schedule
(D) A schedule for which a precedence graph cannot be drawn

Two or more actions are said to be in conflict if:
1) The actions belong to different transactions.
2) At least one of the actions is a write operation.
3) The actions access the same object (read or write).

The schedules S1 and S2 are said to be conflict-equivalent if the following conditions are
satisfied:
1) Both schedules S1 and S2 involve the same set of transactions (including ordering of actions
within each transaction).
2) The order of each pair of conflicting actions in S1 and S2 are the same.

## A schedule is said to be conflict-serializable when the schedule is conflict-equivalent to one or

more serial schedules.

## In the given scenario, there are two possible serial schedules:

1) T1 followed by T2
2) T2 followed by T1.
In both of the serial schedules, one of the transactions reads the value written by other

126
transaction as a first step. Therefore, any non-serial interleaving of T1 and T2 will not be
conflict serializable.

6) Consider the following relations A, B, C. How many tuples does the result of the
following relational algebra expression contain? Assume that the schema of A U B is the
same as that of A. (GATE 2012)

Table A
Id Name Age
----------------
12 Arun 60
15 Shreya 24
99 Rohit 11

Table B
Id Name Age
----------------
15 Shreya 24
25 Hari 40
98 Rohit 20
99 Rohit 11

Table C
Id Phone Area
-----------------
10 2200 02
99 2100 01

(A) 7
(B) 4
(C) 5
(D) 9

Id Name Age
----------------
12 Arun 60
15 Shreya 24
99 Rohit 11
25 Hari 40
98 Rohit 20

## The result of given relational algebra expression will be

127
Id Name Age Id Phone Area
---------------------------------
12 Arun 60 10 2200 02
15 Shreya 24 10 2200 02
99 Rohit 11 10 2200 02
25 Hari 40 10 2200 02
98 Rohit 20 10 2200 02
99 Rohit 11 99 2100 01
98 Rohit 20 99 2100 01

7) Consider the above tables A, B and C. How many tuples does the result of the following
SQL query contains? (GATE 2012)

SELECT A.id
FROM A
WHERE A.age > ALL (SELECT B.age
FROM B
WHERE B. name = "arun")

(A) 4
(B) 3
(C) 0
(D) 1

The meaning of ALL is the A.Age should be greater than all the values returned by the
subquery. There is no entry with name arun in table B. So the subquery will return NULL. If
a subquery returns NULL, then the condition becomes true for all rows of A So all rows of
table A are selected.

8. Consider a relational table with a single record for each registered student with the
following attributes.

## 1. Registration_Number:< Unique registration number for each registered student

2. UID: Unique Identity number, unique at the national level for each citizen
3. BankAccount_Number: Unique account number at the bank. A student can have
multiple accounts or joint accounts. This attributes stores the primary account number
4. Name: Name of the Student
5. Hostel_Room: Room number of the hostel

## Which of the following options is INCORRECT? (GATE 2011)

(A) BankAccount_Number is a candidate key
(B) Registration_Number can be a primary key
(C) UID is a candidate key if all students are from the same country
(D) If S is a superkey such that S UID is NULL then S UID is also a superkey

128
A Candidate Key value must uniquely identify the corresponding row in table.
BankAccount_Number is not a candidate key. As per the question A student can have multiple
accounts or joint accounts. This attributes stores the primary account number. If two students
have a joint account and if the joint account is their primary account, then
BankAccount_Number value cannot uniquely identify a row.

9) Consider a relational table r with sufficient number of records, having attributes A1,
A2,, An and let 1 <= p <= n. Two queries Q1 and Q2 are given below.

## The database can be configured to do ordered indexing on Ap or hashing on Ap. Which of

the following statements is TRUE? (GATE 2011)
(A) Ordered indexing will always outperform hashing for both queries
(B) Hashing will always outperform ordered indexing for both queries
(C) Hashing will outperform ordered indexing on Q1, but not on Q2
(D) Hashing will outperform ordered indexing on Q2, but not on Q1.

If record are accessed for a particular value from table, hashing will do better. If records are
accessed in a range of values, ordered indexing will perform better. See this for more details.

## Borrower Bank_Manager Loan_Amount

Ramesh Sunderajan 10000.00
Suresh Ramgopal 5000.00
Mahesh Sunderajan 7000.00

## What is the output of the following SQL query? (GATE 2011)

SELECT Count(*)
FROM ( (SELECT Borrower, Bank_Manager
FROM Loan_Records) AS S
NATURAL JOIN (SELECT Bank_Manager,
Loan_Amount
FROM Loan_Records) AS T );

(A) 3
(B) 9
(C) 5
(D) 6

129

## Following will be contents of temporary table S

Borrower Bank_Manager
--------------------------
Ramesh Sunderajan
Suresh Ramgqpal
Mahesh Sunderjan

## Following will be contents of temporary table T

Bank_Manager Loan_Amount
---------------------------
Sunderajan 10000.00
Ramgopal 5000.00
Sunderjan 7000.00

Following will be the result of natural join of above two tables. The key thing to note is that the
natural join happens on column name with same name which is Bank_Manager in the above
example. Sunderjan appears two times in Bank_Manager column, so their will be four entries
with Bank_Manager as Sunderjan.

------------------------------------
Ramesh Sunderajan 10000.00
Ramesh Sunderajan 7000.00
Suresh Ramgopal 5000.00
Mahesh Sunderajan 10000.00
Mahesh Sunderajan 7000.00

11) the table at any point in time. Using MX and MY, new records are inserted in the
table 128 times with X and Y values being MX+1, 2*MY+1 respectively. It may be noted
that each time after the insertion, values of MX and MY change. What will be the output
of the following SQL query after the steps mentioned above are carried out?
(GATE 2011)

(A) 127
(B) 255
(C) 129
(D) 257

X Y
-------
1 1
130
2 3
3 7
4 15
5 31
6 63
7 127
......
......

## 12) A relational schema for a train reservation database is given below.

Passenger (pid, pname, age)
Reservation (pid, class, tid)

Table: Passenger
pid pname age
-----------------
0 Sachin 65
1 Rahul 66
2 Sourav 67
3 Anil 69

Table : Reservation
pid class tid
---------------
0 AC 8200
1 AC 8201
2 SC 8201
5 AC 8203
1 SC 8204
3 AC 8202

What pids are returned by the following SQL query for the above instance of the tables?
(GATE 2010)

SLECT pid
FROM Reservation ,
WHERE class AC AND
EXISTS (SELECT *
FROM Passenger
WHERE age > 65 AND
Passenger. pid = Reservation.pid)

(A) 1, 0
(B) 1, 2
(C) 1, 3
(S) 1, 5

When a subquery uses values from outer query, the subquery is called correlated subquery. The
correlated subquery is evaluated once for each row processed by the outer query.

131
The outer query selects 4 entries (with pids as 0, 1, 5, 3) from Reservation table. Out of these
selected entries, the subquery returns Non-Null values only for 1 and 3.

13) Which of the following concurrency control protocols ensure both conflict
I. 2-phase locking
II. Time-stamp ordering (GATE 2010)
(A) I only
(B) II only
(C) Both I and II
(D) Neither I nor II

2 Phase Locking (2PL) is a concurrency control method that guarantees serializability. The
protocol utilizes locks, applied by a transaction to data, which may block (interpreted as signals
to stop) other transactions from accessing the same data during the transactions life. 2PL may
be lead to deadlocks that result from the mutual blocking of two or more transactions. See the
following situation, neither T3 nor T4 can make progress.

## Timestamp-based concurrency control algorithm is a non-lock concurrency control method. In

Timestamp based method, deadlock cannot occur as no transaction ever waits.

14) Consider the following schedule for transactions T1, T2 and T3:

Which one of the schedules below is the correct serialization of the above? (GATE
2010)
(A)T1 T3 T2
132
(B)T2 T1 T3
(C)T2 T3 T1
(D)T3 T1 T2

T1 can complete before T2 and T3 as there is no conflict between Write(X) of T1 and the
operations in T2 and T3 which occur before Write(X) of T1 in the above diagram.
T3 should can complete before T2 as the Read(Y) of T3 doesnt conflict with Read(Y) of T2.
Similarly, Write(X) of T3 doesnt conflict with Read(Y) and Write(Y) operations of T2.
Another way to solve this question is to create a dependency graph and topologically sort the
dependency graph. After topologically sorting, we can see the sequence T1, T3, T2.

15) The following functional dependencies hold for relations R(A, B, C) and S(B, D, E):
B A,
A C
The relation R contains 200 tuples and the rel ation S contains 100 tuples. What is the
maximum number of tuples possible in the natural join R S (R natural join S)

(GATE 2010)
(A) 100
(B) 200
(D) 300
(D) 2000

From the given set of functional dependencies, it can be observed that B is a candidate key of
R. So all 200 values of B must be unique in R. There is no functional dependency given for S.
To get the maximum number of tuples in output, there can be two possibilities for S.
1) All 100 values of B in S are same and there is an entry in R that matches with this value. In
this case, we get 100 tuples in output.
2) All 100 values of B in S are different and these values are present in R also. In this case also,
we get 100 tuples.

16) Consider two transactions T1 and T2, and four schedules S1, S2, S3, S4 of T1 and T2
as given below:
T1 = R1[X] W1[X] W1[Y]
T2 = R2[X] R2[Y] W2[Y]
S1 = R1[X] R2[X] R2[Y] W1[X] W1[Y] W2[Y]
S2 = R1[X] R2[X] R2[Y] W1[X] W2[Y] W1[Y]
S3 = R1[X] W1[X] R2[X] W1[Y] R2[Y] W2[Y]
S1 = R1[X] R2[Y]R2[X]W1[X] W1[Y] W2[Y]
Which of the above schedules are conflict-serializable? (GATE: 2009)
(A) S1 and S2
(B) S2 and S3

133
(C) S3 only
(D) S4 only

There can be two possible serial schedules T1 T2 and T2 T1. The serial schedule T1 T2 has the
following sequence of operations
R1[X] W1[X] W1[Y] R2[X] R2[Y] W2[Y]
And the schedule T2 T1 has the following sequence of operations.
R2[X] R2[Y] W2[Y] R1[X] W1[X] W1[Y]
The Schedule S2 is conflict-equivalent to T2 T1 and S3 is conflict-equivalent to T1 T2.

17) Let R and S be relational schemes such that R={a,b,c} and S={c}. Now consider
the following queries on the database:

FROM R,S
WHERE R.c=S.c

## Which of the above queries are equivalent? (GATE: 2009)

(A) I and II
(B) I and III
(C) II and IV
(D) III and IV

I and II describe the division operator in Relational Algebra and Tuple Relational Calculus
respectively. See Page 3 of this and slide numbers 9,10 of this for more details.

## Suppliers(sid:integer, sname:string, city:string, street:string)

Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)

## Consider the following relational query on the above database:

SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
WHERE C.pid NOT IN (SELECT P.pid

134
FROM Parts P
WHERE P.color<> 'blue'))

Assume that relations corresponding to the above schema are not empty. Which one of the
following is the correct interpretation of the above query? (GATE: 2009)

(A) Find the names of all suppliers who have supplied a non-blue part.
(B) Find the names of all suppliers who have not supplied a non-blue part.
(C) Find the names of all suppliers who have supplied only blue parts.
(D) Find the names of all suppliers who have not supplied only blue parts.

The subquery SELECT P.pid FROM Parts P WHERE P.color<> blue gives pids of parts
which are not blue. The bigger subquery SELECT C.sid FROM Catalog C WHERE C.pid NOT
IN (SELECT P.pid FROM Parts P WHERE P.color<> blue) gives sids of all those suppliers
who have supplied blue parts. The complete query gives the names of all suppliers who have
not supplied a non-blue part

19) Assume that, in the suppliers relation above, each supplier and each street within a
city has a unique name, and (sname, city) forms a candidate key. No other functional
dependencies are implied other than those implied by primary and candidate keys. Which
one of the following is TRUE about the above schema? (GATE: 2009)
(A) The schema is in BCNF
(B) The schema is in 3NF but not in BCNF
(C) The schema is in 2NF but not in 3NF
(D) The schema is not in 2NF

The schema is in BCNF as all attributes depend only on a superkey (Note that primary and
candidate keys are also superkeys).

## 20) Let R and S be two relations with the following schema

R (P,Q,R1,R2,R3)
S (P,Q,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are equivalent?
(GATE: 2008)

## (A) Only I and II

(B) Only I and III
(C) Only I, II and III
(D) Only I, III and IV
135
In I, Ps from natural join of R and S are selected.
In III, all Ps from intersection of (P, Q) pairs present in R and S.
IV is also equivalent to III because (R (R S)) = R S.
II is not equivalent as it may also include Ps where Qs are not same in R and S.

## The minimum number of tables needed to represent M, N, P, R1, R2 is

(A) 2
(B) 3
(C) 4
(D) 5

Many-to-one and one-to-many relationship sets that are total on the many-side can be
represented by adding an extra attribute to the many side, containing the primary key of the
one side. Since R1 is many to one and participation of M is total, M and R1 can be combined
to form the table {M1, M2, M3, P1}. N is a week entity set, so it can be combined with P.

22) Which of the following is a correct attribute set for one of the tables for the correct
answer to the above question? (GATE: 2008)
(A) {M1, M2, M3, P1}
(B) {M1, P1, N1, N2}
(C) {M1, P1, N1}
(D) {M1, P1}

## 23) Consider the following relational schemes for a library database:

Book (Title, Author, Catalog_no, Publisher, Year, Price)
Collection (Title, Author, Catalog_no)

## with in the following functional dependencies:

136
I. Title Author --> Catalog_no
II. Catalog_no --> Title Author Publisher Year
III. Publisher Title Year --> Price

Assume {Author, Title} is the key for both schemes. Which of the following statements is
true? (GATE: 2008)
(A) Both Book and Collection are in BCNF
(B) Both Book and Collection are in 3NF only
(C) Book is in 2NF and Collection is in 3NF
(D) Both Book and Collection are in 2NF only

Table Collection is in BCNF as there is only one functional dependency Title Author >
Catalog_no and {Author, Title} is key for collection. Book is not in BCNF because
Catalog_no is not a key and there is a functional dependency Catalog_no > Title Author
Publisher Year. Book is not in 3NF because non-prime attributes (Publisher Year) are
transitively dependent on key [Title, Author]. Book is in 2NF because every non-prime attribute
of the table is either dependent on the key [Title, Author], or on another non prime attribute.

## 24) Information about a collection of students is given by the relation studinfo(studId,

name, sex). The relation enroll(studId, courseId) gives which student has enrolled for (or
taken) that course(s). Assume that every course is taken by at least one male and at least
one female student. What does the following relational algebra expression represent?

(GATE: 2007)

## (A) Courses in which all the female students are enrolled.

(B) Courses in which a proper subset of female students are enrolled.
(C) Courses in which only male students are enrolled.
(D) None of the above

The expression given in question does following steps in sequence.
a) Select studids of all female students and selects all courseids of all courses.
b) Then the query does a Cartesian Product of the above select two columns from different
tables.
c) Finally it subtracts enroll table from the result of above step (b). This will remove all the
(studid, courseid) pairs which are present in enroll table. If all female students have registered
in a courses, then this course will not be there in the subtracted result.
So the complete expression returns courses in which a proper subset of female students are
enrolled.

studinfo table
studid name sex
137
------------------------
1 a Male
2 c Female
3 d Female

enroll table
studid courseid
------------------
1 1
2 1
3 1
2 2
3 3
3 2

Result of step b
studid courseid
---------------------
2 1
2 2
2 3
3 1
3 2
3 3

Result of step c
studid courseid
-------------------
2 3

25) Consider the relation employee(name, sex, supervisorName) with name as the key.
supervisorName gives the name of the supervisor of the employee under consideration.
What does the following Tuple Relational Calculus query produce? (GATE: 2007)

## (A) Names of employees with a male supervisor.

(B) Names of employees with no immediate male subordinates.
(C) Names of employees with no immediate female subordinates.
(D) Names of employees with a female supervisor.

The query selects all those employees whose immediate subordinate is male. In other words,
it selects names of employees with no immediate female subordinates

26) Consider the table employee(empId, name, department, salary) and the two queries
138
Q1 ,Q2 below. Assuming that department 5 has more than one employee, and we want to
find the employees who get higher salary than anyone in the department 5, which one of
the statements is TRUE for any arbitrary employee table? (GATE: 2007)

Q1 : Select e.empId
From employee e
Where not exists
(Select * From employee s where s.department = 5 and
s.salary >=e.salary)
Q2 : Select e.empId
From employee e
Where e.salary > Any
(Select distinct salary From employee s Where s.department = 5)

## (A) Q1 is the correct query

(B) Q2 is the correct query
(C) Both Q1 and Q2 produce the same answer.
(D) Neither Q1 nor Q2 is the correct query

Consider the following example table.

1 a 4 90k
2 b 5 30k
3 c 5 50k
4 d 5 80k

## Q1 will give empid 1

Q2 will give empid 1, 3, 4
But the correct answer is 4

## 27) Which one of the following statements if FALSE? (GATE: 2007)

(A) Any relation with two attributes is in BCNF
(B) A relation in which every key has only one attribute is in 2NF
(C) A prime attribute can be transitively dependent on a key in a 3 NF relation.
(D) A prime attribute can be transitively dependent on a key in a BCNF relation.

28) Consider the following schedules involving two transactions. Which one of the
following statements is TRUE? (GATE: 2007)

139
(A) Both S1 and S2 are conflict serializable.
(B) S1 is conflict serializable and S2 is not conflict serializable.
(C) S1 is not conflict serializable and S2 is conflict serializable.
(D) Both S1 and S2 are not conflict serializable.

S1 is not conflict serializable, but S2 is conflict serializable

Schedule S1
T1 T2
---------------------
r1(X)
r1(Y)
r2(X)
r2(Y)
w2(Y)
w1(X)
The schedule is neither conflict equivalent to T1T2, nor T2T1.

Schedule S2
T1 T2
---------------------
r1(X)
r2(X)
r2(Y)
w2(Y)
r1(Y)
w1(X)
The schedule is conflict equivalent to T2T1.

29) Consider the following log sequence of two transactions on a bank account, with initial
balance 12000, that transfer 2000 to a mortgage payment and then apply a 5% interest.

1. T1 start
2. T1 B old=12000 new=10000
3. T1 M old=0 new=2000
4. T1 commit
5. T2 start
6. T2 B old=10000 new=10500
7. T2 commit
Suppose the database system crashes just before log record 7 is written. When the system is
restarted, which one statement is true of the recovery procedure? (GATE: 2006)

## (A) We must redo log record 6 to set B to 10500

(B) We must undo log record 6 to set B to 10000 and then redo log records 2 and 3
(C) We need not redo log records 2 and 3 because transaction T1 has committed
(D) We can apply redo and undo operations in arbitrary order because they are idempotent.

Once a transaction is committed, no need to redo or undo operations.
140
30) Consider the relation enrolled (student, course) in which (student, course) is the
primary key, and the relation paid (student, amount) where student is the primary key.
Assume no null values and no foreign keys or integrity constraints. Given the following
four queries:

Query1: select student from enrolled where student in (select student from
paid)
Query2: select student from paid where student in (select student from
enrolled)
Query3: select E.student from enrolled E, paid P where E.student = P.student
Query4: select student from paid where exists
(select * from enrolled where enrolled.student = paid.student)

## Which one of the following statements is correct? (GATE : 2006)

(A) All queries return identical row sets for any database
(B) Query2 and Query4 return identical row sets for all databases but there exist databases for
which Query1 and Query2 return different row sets.
(C) There exist databases for which Query3 returns strictly fewer rows than Query2.
(D) There exist databases for which Query4 will encounter an integrity violation at runtime.

The output of Query2, Query3 and Query4 will be identical. Query1 may produce duplicate
rows. But rowset produced by all of them will be same.

Table enrolled
student course
----------------
abc c1
xyz c1
abc c2
pqr c1

Table paid
student amount
-----------------
abc 20000
xyz 10000
rst 10000

Output of Query 1
abc
abc
xyz

Output of Query 2
abc
xyz

Output of Query 3
141
abc
xyz

Output of Query 4
abc
xyz

31) Consider the relation enrolled(student, course) in which (student, course) is the
primary key, and the relation paid(student, amount), where student is the primary key.
Assume no null values and no foreign keys or integrity constraints. Assume that amounts
6000, 7000, 8000, 9000 and 10000 were each paid by 20% of the students. Consider these
query plans (Plan 1 on left, Plan 2 on right) to list all courses taken by students who have
paid more than x.

A disk seek takes 4ms, disk data transfer bandwidth is 300 MB/s and checking a tuple to
see if amount is greater than x takes 10 micro-seconds. Which of the following statements
is correct? (GATE: 2006)
(A) Plan 1 and Plan 2 will not output identical row sets for all databases.
(B) A course may be listed more than once in the output of Plan 1 for some databases
(C) For x = 5000, Plan 1 executes faster than Plan 2 for all databases.
(D) For x = 9000, Plan I executes slower than Plan 2 for all databases.

Assuming that large enough memory is available for all data needed. Both plans need to load
both tables courses and enrolled. So disk access time is same for both plans.
Plan 2 does lesser number of comparisons compared to plan 1.
1) Join operation will require more comparisons as the second table will have more rows in plan
2 compared to plan 1.
2) The joined table of two tables will will have more rows, so more comparisons are needed to
find amounts greater than x.

142
32) The following functional dependencies are given:

AB CD, AF D, DE F, C G , F E, G A

## Which one of the following options is false? (GATE: 2006)

(A)CF+ = {ACDEFG}
(B)BG+ = {ABCDG}
(C)AF+ = {ACDEFG}
(D)AB+ = {ABCDFG}

Closure of AF or AF+ = {ADEF}, closure of AF doesnt contain C and G.
Option (D) also looks correct. AB+ = {ABCDG}, closure of AB doesnt contain F.

33) Which one of the following statements about normal forms is FALSE? (GATE 2005)
(a) BCNF is stricter than 3NF
(b) Lossless, dependency-preserving decomposition into 3NF is always possible
(c) Lossless, dependency-preserving decomposition into BCNF is always possible
(d) Any relation with two attributes is in BCNF

It is not always possible to decompose a table in BCNF and preserve dependencies. For
example, a set of functional dependencies {AB > C, C > B} cannot be decomposed in BCNF.

34) The following table has two attributes A and C where A is the primary key and C is
the foreign key referencing A with on-delete cascade.

A C
-----
2 4
3 4
4 3
5 2
7 2
9 5
6 4

The set of all tuples that must be additionally deleted to preserve referential integrity
when the tuple (2,4) is deleted is: (GATE
2005)
(a) (3,4) and (6,4)
(b) (5,2) and (7,2)
(c) (5,2), (7,2) and (9,5)
(d) (3,4), (4,3) and (6,4)

When (2,4) is deleted. Since C is a foreign key referring A with delete on cascade, all entries
143
with value 2 in C must be deleted. So (5, 2) and (7, 2) are deleted. As a result of this 5 and 7 are
deleted from A which causes (9, 5) to be deleted.

35) The relation book (title, price) contains the titles and prices of different books.
Assuming that no two books have the same price, what does the following SQL query list?
(GATE 2005)

select title
from book as B
where (select count(*)
from book as T
where T.price > B.price) < 5

## (a) Titles of the four most expensive books

(b) Title of the fifth most inexpensive book
(c) Title of the fifth most expensive book
(d) Titles of the five most expensive books

When a subquery uses values from outer query, the subquery is called correlated subquery. The
correlated subquery is evaluated once for each row processed by the outer query.
The outer query selects all titles from book table. For every selected book, the subquery returns
count of those books which are more expensive than the selected book. The where clause of
outer query will be true for 5 most expensive book. For example count (*) will be 0 for the most
expensive book and count(*) will be 1 for second most expensive book.

36) Let r be a relation instance with schema R = (A, B, C, D). We define r1 = select A,B,C
from r and r2 = select A, D from r. Let s = r1 * r2 where * denotes natural join. Given
that the decomposition of r into r1 and r2 is lossy, which one of the following is TRUE?
(GATE 2005)
(a) s is subset of r
(b) r U s = r
(c) r is a subset of s
(d) r * s = s

Consider the following example with lossy decomposition of r into r1 and r2. We can see that r
is a subset of s.

Table r
A B C D
---------------------------
1 10 100 1000
1 20 200 1000
1 20 200 1001

Table r1

144
A B C
------------------
1 10 100
1 20 200

Table r2
A D
-----------
1 1000
1 1001

## Table s (natural join of r1 and r2)

A B C D
---------------------------
1 10 100 1000
1 20 200 1000
1 20 100 1001
1 20 200 1001

37) Let E1 and E2 be two entities in an E/R diagram with simple single-valued attributes.
R1 and R2 are two relationships between E1 and 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)
(a) 2
(b) 3
(c) 4
(d) 5

The situation given can be expressed with following sample data.

E1
a
b
c

E2
x
y
z

R1
E1 E2
a x
a y
b z

R2
E1 E2
145
a x
a y
b y

## 38) Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional

dependencies hold: {A>B, BC> D, E>C, D>A}. What are the candidate keys of R?

(GATE 2005)
(a) AE, BE
(b) AE, BE, DE
(c) AEH, BEH, BCH
(d) AEH, BEH, DEH

A set of attributes S is candidate key of relation R if the closure of S is all attributes of R and
there is no subset of S whose closure is all attributes of R.
Closure of AEH, i.e. AEH+ = {ABCDEH}
Closure of BEH, i.e. BEH+ = {ABCDEH}
Closure of DEH, i.e. DEH+ = {ABCDEH}

39) Let R1 (A, B, C) and R2 (D, E) be two relation schema, where the primary
keys are shown underlined, and let C be a foreign key in R1 referring to R2.
Suppose there is no violation of the above referential integrity constraint in the
corresponding relation instances r1 and r2 . Which one of the following relational
algebra expressions would necessarily produce an empty relation ?
(GATE:2004)
1) D (r2 ) - C (r1 )
2) C (r1 ) - D (r2 )
3) D (r1 C 1 D r2 )
4) C (r1 C = Dr2)

Explanation:
C is an attribute in R1 but D is a key in K 2 . So consider C (r1)
D (r2) So the result of this query would be all those tuples
which are in C (r1) but not in D (r2).Since D is a key so it has
all the possible values of C . So difference would always be
146
empty.Hence( 2 ) is correct.

## 40) Consider the following relation schema pertaining to a students database:

Enroll (rollno, courseno, coursename)
where the primary keys are shown underlined. The number of tuples in the
Student and Enroll tables are 120 and 8 respectively. What are the maximum and
minimum number of tuples that can be present in (Student * Enroll), where '*'
denotes natural join ?
(GATE: 2004)

1) 8, 8
2) 120, 8
3) 960, 8
4) 960, 120

Explanation:
The boundary cases are when either all the tuples of Enroll
table belong to one roll no. , so there can be at most 8 roll
no & courses no. combinations or the other case is when all
the tuples belong to different roll no. this also has 8 tuples.
So (8,8) = (max, min) Hence (A) is correct option

41) Which of the following scenarios may lead to an irrecoverable error in a database system
?
(GATE: 2003)

## 1) A transaction writes a data item after it is read by an uncommitted transaction

2) A transaction reads a data item after it is read by an uncommitted transaction
3) A transaction reads a data item after it is written by a committed transaction
4) A transaction reads a data item after it is written by an uncommitted transaction

147
42) The following SQL
query select distinct al,
a2,........., an
from r1 , r2,........, rm
where P
For an arbitrary predicate P, this query is equivalent to which of the following
relational algebra expressions
GATE 2003

1.

2.

3.
4.

## 43) Relation R with an associated set of functional dependencies, F, is

decomposed into BCNF. The redundancy (arising out of functional
dependencies) in the resulting set of relations is (GATE: 2002)

(a) Zero
(b) More than zero but less than that of an equivalent 3NF decomposition
(c) Proportional to the size of F+
(d) Indetermine

## Ans: solution (b)

Explanation:
Redundancy in BCNF is low when compared to 3NF.

44) With regard to the expressive power of the formal relational query
languages, which of the following statements is true? (GATE: 2002)

## (a) Relational algebra is more powerful than relational calculus

(b) Relational algebra has the same power as relational calculus.
148
(c) Relational algebra has the same power as safe relational calculus.

## (d) None of the above

SOLUTION
Expressive power is the capacity of formal query languages to express various query
statements, so relational algebra is as powerful as relational calculus only if calculus
is safe relational calculus.Hence (C) is correct option.

45) Consider a relation geq which represents greater than or equal to,
that is, (x,y) geq only if yx.
create table geq
( Ib integer not null ub integer not null primary key 1b foreign key (ub)

## Which of the following is possible if a tuple (x,y) is deleted?

(GATE:2001)
(a) A tuple (z,w) with z > y is deleted
(b) A tuple (z,w) with z > x is deleted
(c) A tuple (z,w) with w < x is deleted
(d) The deletion of (x,y) is prohibited
SOLUTION
Tuple (x, y) is
deleted. Here y
\$x
lb is primary key
ub is foreign key
Since y refer to same key z . & in table A x a primary key is deleted so all enteries
from table B will also be deleted. And also all enteries referencing it in y will also be
deleted.Hence (C) is correct option.

## 46) Suppose the adjacency relation of vertices in a graph is represented in a table

Adj (X, Y).Which of the following queries cannot be expressed by a relational
algebra expression of constant length ? (A) List all vertices adjacent to a given vertex.
(B) List all vertices which have self loops
(C) List all vertices which belong to cycles of less than three vertices
(D) List all vertices reachable from a given vertex
149
SOLUTION

## The database contains the adjacency list of the graph. So

relation algebra with face problems when while calculating the
length of cycle self loops come, then the query would execute
in one tuple only. Hence (C) is correct option.

## 47) Given the relations

employee (name, salary, deptno)
Which of the following queries cannot be expressed using the basic
relational algebra operations (,,, , ,,)? (GATE:2000)

## (a) Department address of every employee

(b) Employees whose name is the same as their department name
(c) The sum of all employees' salaries
(d) All employees of a given department

## 48) Given relations r(w,x) and s(y,z), the result of

select distinct w,x
from r, s
is guaranteed to be same as r, provided (GATE:2000)

## (a) r has no duplicates and s is non-empty

(b) r and s have no duplicates
(c) s has no duplicates and r is non-empty
(d) r and s have the same number of tuples

## 49) In SQL, relations can c o n t a i n null values, and c o m p a r i s o n s with null

v a l u e s are treated as unknown. Suppose all c o m p a r i s o n s with a null
value are treated as false. Which of the following pairs is not equivalent?
(GATE:2000)

## (a) x = 5 not (not (x = 5)

(b) x = 5 x > 4 and x < 6, where x is an integer
(c) x 5 not (x = 5)
(d) None of the above

150

50) Consider the join of a relation R with a relation S. If R has m tuples and
S has n tuples then the maximum and minimum sizes of the join respectively
are (GATE:1999)
(a) m + n and 0
(b) mn and 0
(c) m + n and |m n|
(d) mn and m + n

151
52) Consider the schema R = (S T U V) and the dependencies S T, T U. U V and
V S. Let R = (R1 and R2) be a decomposition such that R1 R2 = . The
decomposition is (GATE:1999)
(a) not in 2NF (b) in 2NF but not 3NF (c) in 3NF
but not in 2NF (d) in both 2NF and 3NF

53) The minimum number of record movements required to merge five files A (with
10 records), B (with 20 records), C (with 15 records), D (with 5 records) and E
(with 25 records) is: (GATE:1999)
(a) 165 (b) 90 (c) 75 (d) 65

## (a) An SQL query automatically eliminates duplicates

(b) An SQL query will not work if there are no indexes on the relations (c) SQL
permits attribute names to be repeated in the same relation

## 55) Consider the set of relations

EMP (Employee-no. Dept-no, Employee-name, Salary)

## DEPT (Dept-no. Dept-name, Location)

Write an SQL query to:
(a) Find all employee names who work in departments located at Calcutta and
whose salary is greater than Rs.50,000.
(b) Calculate, for each department number, the number of employees with a
salary greater than Rs.1,00,000. (GATE:1999)

56) Which normal form is considered adequate for normal relational database Design?
(GATE:1998)
(a) 2 NF (b) 5 NF (c) 4 NF (d) 3 NF

## Ans: solution (d)

Explanation:

152
A relational database table is often described as "normalized" if it is in the Third Normal
Form because most of the 3NF tables are free of insertion, update, and deletion anomalies.

## Name Age Occupatio Categor

Rama 27 n CO y A

Abdul 22 N A
Jeniffe 28 EN B
r 32 G D
Maya 24 DO C
There is an index file
Devassociated with thisC and it contains the values 1,3,2,5 and 4.Which
one of the fields is the index built from? (GATE:1998)
SER
(a) Age (b) Name MUS (c) Occupation (d) Category
58) Suppose we have a database consisting of the following three relations.

## FREQUENTS (student, parlor) giving the parlors each student visits.

SERVES (parlor, ice-cream) indicating what kind of ice-creams each parlor serves.
LIKES (student, ice-cream) indicating what ice-creams each student likes. (Assume that
each student likes at least one ice-cream and frequents at least one parlor)

## Express the following in SQL:

Print the students that frequent at least one parlor that serves some ice- cream
that they like. (GATE:1998)

59) AB+ -tree index is to be built on the Name attribute of the relation STUDENT . Assume
that all student names are of length 8 bytes, disk blocks are of size 512 bytes, and index
pointers are of size 4 bytes. Given this scenario, what would be the best choice of the degree
(i.e. the number of pointers per node) of the B+ -tree ?
(A) 16 (B) 42 (C) 43 (D) 44

SOLUTION
Size of 1 record of index = 8 + 4 = 12 bytes. Let no. of pointers required = P
No. of index values per block = P 1
So (P 1) 8 + 4P= 512
12P= 520

153
P , 44
60) Let r and s be two relations over the relation schemes R and S respectively, and let A
be an attribute in R . Then the relational algebra expression A = a ]r A s g is always equal to :
(A) A = a ]r g (B) r
(C) A = a ]r A s g (D) None of the above

SOLUTION

Given query performs natural join between r & s , & then project
attribute A where A = a . This same result is produced by the query A = a (r) A s . This
query selects attribute A = a from r & then performs join operation results are
same. Hence (C) is correct option.

## 1.The coupling between different modules of a software is categorized as

follows:
I. Content coupling II. Common coupling III. Control coupling IV. Stamp coupling
V. Data coupling
Coupling between modules can be ranked in the order of strongest(least desirable) to
weakest (most desirable) as follows:
1) I-II-III-IV-V
2) V-IV-III-II-I
3) I-III-V-II-IV
4) IV-II-V-III-I
Solution:1

2.

154
Solution: B gate-2010

3.

Solution: A gate-2010

4.

Solution: D gate-2010

## a. implies structure and order

155
b. refers to the manner in which each component functions with other components of the
system
c. means that parts of computer system depends on one another
d. refers to the holism of systems

Solution: D gate-2009

6.What is software?
a. Set of computer programs, procedures and possibly associated document concerned with the
operation of data processing.
b. A set of compiler instructions.
c. A mathematical formulae
d. All of the above
e. None of the above
Solution:A gate-2009
7. Which is the last step in classic life cycle paradigm?
a. System engineering
b. Analysis
c. Design
d. Coding
e. Maintenance.

Solution:E gate-2010

## 8. Which of the following is closer to machine Code

a. Assembly language
b. Machine language
c. High level language
d. All of the above
e. None of the above
Solution:A gate-2010
9. The following are properties of Modularity except

156
a. It implement a single independent function
b. It performs a single logical task.
c. It has a single entry and exit point.
d. It is entirely constructed of modules.
e. None of the above.

Solution:E gate-2011

## 10. The following are characteristics of software expects

a. It is developed or engineered.
b. Software does not wear out
d. Software have dont have spare parts instead it has backup
e. Software consists of physical devices.

Solution:E gate-2011

11. Software genetic development process contains three genetic phrases namely
a. Definition, development, maintenance.
b. Coding, design, Software engineering
c. Software engineering, Definition, Coding
d. Design, Coding, Development
e. Development, Definition, Testing
Solution:A gate-2011

## 12. Which of the following translators convert high-level language on statement-by-statement

basis?
a. Compiler
b. Machine level language converter
c. Interpreter.
d. Assembler
e. None of the above

157
Solution:C gate-2012
13. Which of the following is not an example of Prototype in engineering paradigm?
a. Paper prototype.
b. Existing prototype.
c. Working prototype.
d. Software prototype.
e. Engineering prototype.
Solution:A gate-2012

14. Which of the following Construct in formal model in software engineering execute each
statement in succession.
a. Selection Construct.
b. Sequence Construct. (Correct)
c. Iteration Construct.
e. Statement Construct.
Solution:B gate-2012

## 15.What is software engineering?

a. Set of computer programs, procedures and possibly associated document concerned with the
operation of data processing.
b. Software engineering is Design, Coding, Development
c. Software engineering implement a single independent function
d. Software engineering is the establishment and use of sound engineering practice in order to
produce economical and reliable software that will perform efficiently on real machine (Correct)
e.Software engineering is a step that encompasses the method, tools, procedure used in software

Solution:D gate-2012

## 16. The most important feature of spiral model is

(A) requirement analysis. (B) risk management.
(C) quality management. (D) configuration management.

158
Ans: B

## 17. The worst type of coupling is

(A) Data coupling. (B) control coupling.
(C) stamp coupling. (D) content coupling.

Ans: D

## 18. IEEE 830-1993 is a IEEE recommended standard for

(A) Software requirement specification.
(B) Software design.
(C)Testing.
(D) Both (A) and (B)

Ans: A

## 19. One of the fault base testing techniques is

(A) unit testing. (B) beta testing.
(C) Stress testing. (D) mutation testing.

Ans: D

20. Changes made to an information system to add the desired but not necessarily the
required features is called
(A) Preventative maintenance.
(C) Corrective maintenance.
(D) Perfective maintenance.

Ans: D

21. All the modules of the system are integrated and tested as complete system in the
case of
(A) Bottom up testing (B) Top-down testing
(C) Sandwich testing (D) Big-Bang testing

Ans: D
22. SRS is also known as specification of

Ans: D
(A) White box testing (B) Stress testing
(C) Integrated testing (D) Black box testing

## 23. The model in which the requirements are implemented by category is

(A) Evolutionary Development Model
(B) Waterfall Model
159
(C) Prototyping
(D) Iterative Enhancement Model

Ans: A

## 24. SRD stands for

(A) Software requirements definition
(B) Structured requirements definition
(C) Software requirements diagram
(D) Structured requirements diagram

Ans: B

## 25. Usingpublic 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?
(A) Encryption: Xs private key followed by Ys private key; Decryption: Xs public
key followed by Ys public key
(B) Encryption: Xs private key followed by Ys public key; Decryption: Xs public
key followed by Ys private key
(C) Encryption: Xs public key followed by Ys private key; Decryption: Ys public
key followed by Xs private key
(D) Encryption: Xs private key followed by Ys public key; Decryption: Ys private
key followed by Xs public key

Ans:D 2013

COMPUTER NETWORKS
1. The transport layer protocols used for real time multimedia, file transfer, DNS and email,
respectively are GATE 2013

## (A) TCP, UDP, UDP and TCP

(B) UDP, TCP, TCP and UDP
(C) UDP, TCP, UDP and TCP
(D) TCP, UDP, TCP and UDP
ANS: C
SOL: Multimedia can be unreliable but has to be fast so UDP, File transfer has to be secure &
reliable so uses TCP, DNS can be both TCP and UDP, E mail uses TCP for reliability.

2. 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? GATE 2013
160
(A) Encryption: Xs private key followed by Ys private key; Decryption: Xs public key followed
by Ys public key
(B) Encryption: Xs private key followed by Ys public key; Decryption: Xs public key followed by
Ys private key
(C) Encryption: Xs public key followed by Ys private key; Decryption: Ys public key followed by
Xs private key
(D) Encryption: Xs private key followed by Ys public key; Decryption: Ys private key followed
by Xs public key
ANS: D

3. 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. GATE 2013

## (A) Network layer 4 times and Data link layer 4 times

(B) Network layer 4 times and Data link layer 3 times
(C) Network layer 4 times and Data link layer 6 times
(D) Network layer 2 times and Data link layer 6 times
ANS: C
SOL: Therefore, Network layer 4 times

4. 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. GATE 2013

## (A) 1 (B) 2 (C) 2.5 (D) 5

ANS: B
SOL: Propagation time = Transmission time + Collision signal time

= +

10000 2
=
500 106 / 2 105 /
161
Length = 2 km

5. 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 GATE 2013

## (A) Last fragment, 2400 and 2789

(B) First fragment, 2400 and 2759
(C) Last fragment, 2400 and 2759
(D) Middle fragment, 300 and 689
ANS: C
SOL: Since M bit is 0, so there is no fragment after this fragment. Hence this fragment is the last
fragment.
Now, HLEN defines the length of header in datagram. Since Hlen is 10 so, size of header is 10 *
4 = 40 B
Length of data = Total length Header length
= 400 40
= 360 B
Now, fragment offset of data in original datagram is measured in units of 8 B. so to find first Byte of
this fragment, First byte/8 = fragment offset
First byte = 300 * 8 = 2400 B and since length of data is 360 B.
So, last byte on this datagram will be 2759

6. In the IPv4 addressing format, the number of networks allowed under Class C addresses is
GATE 2012
(A) 214 (B) 27 (C) 221 (D) 224
ANS: C
SOL: For class C address, size of network field is 24 bits. But first 3 bits are fixed as 110; hence
total number of networks possible is 221.

7. Which of the following transport layer protocols is used to support electronic mail?
GATE 2012
(A) SMTP (B) IP (C) TCP (D) UDP
ANS:C
SOL: E-mail uses SMTP in application layer to transfer mail. And SMTP uses TCP to transfer data
in transport layer.
8. The protocol data unit (PDU) for the application layer in the Internet stack is
GATE 2012
(A) Segment (B) Datagram (C) Message (D) Frame
ANS: C
SOL: Protocol Data Unit (PDU)
Application layer Message
Transport layer Segment
Network layer Datagram
Ans = Message
162
9. Consider an instance of TCPs Additive Increase Multiplicative Decrease (AIMD) algorithm where
the window size at the start of the slow start phase is 2 MSS and the threshold at the start of the first
transmission is 8 MSS. Assume that a timeout occurs during the fifth transmission. Find the
congestion window size at the end of the tenth transmission.
GATE 2012
(A) 8 MSS (B) 14 MSS (C) 7 MSS (D) 12 MSS
ANS: C
SOL: Given threshold = 8
Time = 1, during first transmission, window size = 2 (slow start phase)
Time = 2, congestion window size = 4 (double the no. of acknowledgments)
Time = 3, congestion window size is = 8
Time = 4, congestion window size = 9, after threshold (increase by one addictive increase)
Time = 5, transmits 10 MSS, but time out occurs congestion windw size = 10
Hence threshold = (congestion window size)/2=10/2 = 5
Time = 6, transmits 2
Time = 7, transmits 4
Time = 8, transmits 5(threshold is 5)
Time = 9, transmits 6
Time = 10, transmits 7
During 10th transmission, it transmits 7 segments hence at the end of the 10th transmission
the size of congestion window is 7 MSS.

10. Consider a source computer (S) transmitting a file of size 106 bits to a destination
computer (D) over a network of two routers (R1 and R2) and three links (L1, L2, and L3).
L1 connects S to R1; L2 connects R1 to R2; and L3 connects R2 to D. Let each link be
of length 100km. Assume signals travel over each line at a speed of 108 meters per
second. Assume that the link bandwidth on each link is 1Mbps. Let the file be broken down
i n t o 1000 p a c k e t s each of size 1000 bits. Find the total sum o f transmission and
p r o p a g a t i o n delays i n transmitting the file from S to D?
GATE 2012
(A) 1005ms (B) 1010ms (C) 3000ms (D) 3003ms
ANS: A
SOL: L1 L2 L3

R2 D
S R1

Transmission delay for 1st packet from each of S, R1 and R2 will take 1 ms
Propagation delay on each link l1,l2 and l3 for one packet is 1ms
Therefore the sum of transmission delay and propagation delay on each link for one packet is
2ms.
The first packet reaches the destination at 6th ms
The second packet reaches the destination at 7th ms
So, inductively we can say that 1000th packet reaches the destination at 1005th ms.

163
11. Consider the directed graph shown in the figure below. There are multiple shortest paths between
vertices S and T. Which one will be reported by Dijkstras shortest path algorithm? Assume that, in
any iteration, the shortest path to a vertex v is updated only when a strictly shortest path to v is
discovered.

GATE 2012

## (A) SDT (B) SBDT (C) SACDT (D) SACET

ANS: D
SOL: Let d[v] represent the shortest path distance computed from S Initially d[S] = 0, d[A] = ,
d[B] = , - - - - -, d[T] =
and let P[v] represent the predecessor of v in the shortest path from S to v and let P[v] = 1 denote
that currently predecessor of v has not been computed
Let Q be the set of vertices for which shortest path distance has not been computed

Let W be the set of vertices for which shortest path distance has not been computed

## We will use the following procedure

Repeat until Q is empty{
1. u = choose a vertex from Q with minimum d[u] value
2. Q = Q u
3. update all the adjacent vertices of u
4. W = W U{u}
} d[S] = 0, d[A] = , d[B] = , . . . . , d[T] =
Iteration 1: Step 1: u = S
Step 2: Q = {A, B, C, D, E, F, G, T}
Step 3: final values after adjustment
d[S] = 0, d[A] = 4, d[B] = 3, d[C] = , d[D] = 7, d[E] = - - -, d[T] =
P[A] = S, P[B] = S, P[C] = 1, P[D] = S, P[E] = 1 - - - , P[T] = 1
Step 4: W = {S}
Iteration 2: Step 1: u = S
Step 2: Q = {A, C, D, E, F, G, T}
Step 3: final values after adjustment
d[S] = 0, d[A] = 4, d[B] = 3, d[C] = , d[D] = 7, d[E] = - - -, d[T] =
P[A] = S, P[B] = S, P[C] = 1, P[D] = S, P[E] = 1 - - - , P[T] = 1
164
Step 4: W = {S, B}
Iteration 3: Step 1: u = A
Step 2: Q = {C, D, E, F, G, T}
Step 3: final values after adjustment
d[S] = 0, d[A] = 4, d[B] = 3, d[C] = 5, d[D] = 7, d[E] = - - -, d[T] =
P[A] = S, P[B] = S, P[C] = A, P[D] = S, P[E] = 1 - - - , P[T] = 1
Step 4: W = {S, B, A}
Iteration 4: Step 1: u = C
Step 2: Q = {D, E, F, G, T}
Step 3: final values after adjustment
d[S] = 0, d[A] = 4, d[B] = 3, d[C] = 5, d[D] = 7, d[E] = 6, - - -, d[T] =
P[A] = S, P[B] = S, P[C] = A, P[D] = S, P[E] = C, - - - , P[T] = 1
Step 4: W = {S, B, A, C}
Iteration 5: Step 1: u = E
Step 2: Q = {D, F, G, T}
Step 3: final values after adjustment
d[S] = 0, d[A] = 4, d[B] = 3, d[C] = 5, d[D] = 7, d[E] = 6, d[F] = , d[G] = 8,
d[T] = 10 P[A] = S, P[B] = S, P[C] = A, P[D] = S, P[E] = C, P[F] = 1,
P[G] = E, P[T] = E
Step 4: W = {S, B, A, C, E}
After iteration 5, we can observe that P[T] = E, P[E] = C, P[C] = A, P[A] = S, So the shortest
path from S to T is SACET

12. An Internet Service Provider (ISP) has the following chunk of CIDR-based IP addresses available
with it: 245.248.128.0/20. The ISP wants to give half of this chunk of addresses to Organization. A,
and a quarter to Organization B, while retaining the remaining with itself. Which of the following is
a valid allocation of addresses to A and B? GATE 2012

## (D) 245.248.136.0/24 and 245.248.132.0/21

ANS: A
SOL:

th
Since half of 4096 host addresses must be given to organization A, we can set 12 bit to 1 and
include that bit into network part of organization A, so the valid allocation of addresses to A is
245.248.136.0/21

165
th th
Now for organization B, 12 bit is set to 0 but since we need only half of 2048 addresses, 13
bit can be set to 0 and include that bit into network part of organization B so the valid
allocation of addresses to B is 245.248.128.0/22

## 13. Consider different activities related to email.

m1: Send an email from a mail client to a mail server
m3: Checking email in a web browser
Which is the application level protocol used in each activity? GATE 2011

(A) m1: HTTP m2: SMTP m3: POP (B) m1: SMTP m2: FTP m3: HTTP

(C) m1: SMTP m2: POP m3: HTTP (D) m1: POP m2: SMTP m3: IMAP
ANS: C
SOL: Mail client uses SMTP (Simple Mail Transfer Protocol) to send mail. (The client need not be
web based. So, HTTP may not be involved here). POP (Post Office Protocol) is used to retrieve
mail from mail server. HTTP (Hypertext transfer protocol) is used to transfer a HTML page
containing the mail message that can be viewed on a web browser.

14. A layer-4 firewall (a device that can look at all protocol headers up to the transport layer) CANNOT
GATE 2011

## (B) Block all ICMP traffic

(C) Stop incoming traffic from a specific IP address but allow outgoing traffic to the same IP address

(D) Block TCP traffic from a specific user on a multi-user system during 9:00PM and 5:00Am
ANS: A

## Statement for Linked Questions 15 and 16

Consider a network with five nodes, N1 to N5, as shown below.

166
The network uses a Distance Vector Routing protocol. Once the routes have stabilized, the distance
vectors at different nodes are as following.
N1: (0, 1, 7, 8, 4)
N2: (1, 0, 6, 7, 3)
N3: (7, 6, 0, 2, 6)
N4: (8, 7, 2, 0, 4)
N5: (4, 3, 6, 4, 0)
Each distance vector is the distance of the best known path at the instance to nodes, N1 to N5, where
the distance to itself is 0. Also, all links are symmetric and the cost is identical in both directions. In
each round, all nodes exchange their distance vectors with their respective neighbors. Then all nodes
update their distance vectors. In between two rounds, any change in cost of a link will cause the two
incident nodes to change only that entry in their distance vectors.

15. The cost of link N2-N3 reduces to 2(in both directions). After the next round of updates, what will
be the new distance vector at node, N3? GATE 2011

## (A) (3, 2, 0, 2, 5) (B) (3, 2, 0, 2, 6) (C) (7, 2, 0, 2, 5) (D) (7, 2, 0, 2, 6)

ANS: A

16. After the update in the previous question, the link N1-N2 goes down. N2 will reflect this change
immediately in its distance vector as cost, . After the NEXT ROUND of update, what will be the
cost to N1 in the distance vector of N3? GATE 2011

## (A) 3 (B) 9 (C) 10 (D)

ANS: C

17. One of the header fields in an IP datagram is the Time to Live (TTL) field. Which of the following
statements best explains the need for this field? GATE 2010

## (A) It can be used to prioritize packets

(B) It can be used to reduce delays
(C) It can be used to optimize throughput
(D) It can be used to prevent packet looping
ANS: D
SOL: Whenever Time to live field reaches 0 we discard the packet, so that we can prevent it from
looping.

18. Which one of the following is not a client server application? GATE 2010

(A) Internet chat (B) Web browsing (C) E-mail (D) Ping
ANS: D

167
Consider a network with 6 routers R1 to R6 connected with links having weights as shown in the
following diagram

19. All the routers use the distance vector based routing algorithm to update their routing tables. Each
router starts with its routing table initialized to contain an entry for each neighbor with the weight of
the respective connecting link. After all the routing tables stabilize, how many links in the network
will never be used for carrying any data? GATE 2010

## (A) 4 (B) 3 (C) 2 (D) 1

ANS: D
SOL: In Distance vector, the Router will update its routing tables by exchanging the information
from all its neighbors. After all the routing tables stabilize the routing Table for R1 will not
have any entry to Router R6., so that link will not be used. So one link.

20. Suppose the weights of all unused links in the previous question are changed to 2 and the distance
vector algorithm is used again until all routing tables stabilize. How many links will now remain
unused? GATE 2010

## (A) 0 (B) 1 (C) 2 (D) 3

ANS: A

21. Which of the following statement(s) is / are correct regarding Bellman-Ford shortest path algorithm?
P. Always finds a negative weighted cycle, if one exists.
Q. Finds whether any negative weighted cycle is reachable from the source.
GATE 2009

(A) P only (B) Q only (C) both P and Q (D) Neither P nor Q
ANS: B
SOL: The algorithm identifies a negative weight cycle iff it is reachable from Source.

168
22. Consider the following graph:

Which one of the following is NOT the sequence of edges added to the minimum spanning tree
using Kruskals algorithm?
GATE 2009

(A) (b,e) (e,f) (a,c) (b,c) (f,g) (c,d) (B) (b,e) (e,f) (a,c) (f,g) (b,c) (c,d)
(C) (b,e) (a,c) (e,f) (b,c) (f,g) (c,d) (D) (b,e) (e,f) (b,c) (a,c) (f,g) (c,d)
ANS: D
SOL: Weight of edge (a,c) is less than (b,c) . So it cannot come after (b,c)

23. In the RSA public key cryptosystem, the private and public keys are (e, n) and (d, n) respectively,
where n=p*q and p and q are large primes. Besides, n is public and p and q are private. Let M be an
integer such that 0<M<n and (n) = (p 1) (q 1). Now consider the following equations.
I. M' = Me mod n
M = (M')d mod n

II. ed 1 mod n

## IV. M' = Me mod (n)

M = (M')d mod (n)
Which of the above equations correctly represent RSA cryptosystem?
GATE 2009
(A) I and II (B) I and III (C) II and IV (D) III and IV
ANS: B

Frames of 1000 bits are sent over a 106 bps duplex link between two hosts. The propagation time
is 25ms. Frames are to be transmitted into this link to maximally pack them in transit (within the

169
24. What is the minimum number of bits (i) that will be required to represent the sequence numbers
distinctly? Assume that no time gap needs to be given between transmission of two frames.
GATE 2009
(A) i=2 (B) i=3 (C) i=4 (D) i=5
ANS: D

SOL: The transmission time for a frame is 1000/1Mbps = 1 ms .As the propagation time is 25 ms,
the sender can transmit 25 packets before the first packet reaches the destination. Therefore the
number of bits required to represent 25 packets is 5.

25. Suppose that the sliding window protocol is used with the sender window size of 2i, where i is the
number of bits identified in the earlier part and acknowledgements are always piggy backed. After
sending 2i frames, what is the minimum time the sender will have to wait before starting
transmission of the next frame? (Identify the closest choice ignoring the frame processing time.)
GATE 2009
(A) 16ms (B) 18ms (C) 20ms (D) 22ms
ANS: B
SOL: Sliding window size is 32 as i=5. The sender can expect an Ack after one RTT. Here Round
trip time is 50ms. Therefore the sender has to wait at least 50-32= 18ms before transmission of the
next frame.

26. What is the maximum size of data that the application layer can pass on to the TCP layer below?
GATE 2008

## (A) Any size (B) 216 bytes-size of TCP header

(C) 216 bytes (D) 1500 bytes
ANS: A
SOL: Application layer can pass any length data. TCP layer will divide that data into frames.

27. Which of the following system calls results in the sending of SYN packets?
GATE 2008
(A) socket (B) bind (C) listen (D) connect
ANS: D
SOL: In the process of establishing a connection between two endpoints, the user process on active
end point invokes the connect() system call. The active end point then sends a SYN packet. The
passive end point invokes an accept() system call and sends ACK to the other system then the
connection is established.

28. Dijkstras single source shortest path algorithm when run from vertex a in the following graph,
computes the correct shortest path distance to

170
(A) only vertex a (B) only vertices a, e, f, g, h
(C) only vertices a, b, c, d (D) all the vertices
ANS: D

SOL: Even though the graph has negative weights, it correctly computes the shortest path to all the
vertices. There will not be any problem with the Dijkstra's algorithm operating on negative edge
weights as long as the shortest path distance computed for the currently removed vertex is the actual
shortest path distance.

29. In the slow start phase of the TCP congestion control algorithm, the size of the congestion window
GATE 2008

## (A) Does not increase (B) increases linearly

(C) Increases quadratically (D) increases exponentially
ANS: B

30. If a class B network on the Internet has a subnet mask of 255.255.248.0, what is the maximum
number of hosts per subnet? GATE 2008

ANS: C

## Number of hosts = 211-2 = 2046

31. A computer on a 10Mbps network is regulated by a token bucket. The token bucket is filled at a rate
of 2Mbps. It is initially filled to capacity with 16Megabits. What is the maximum duration for which
the computer can transmit at the full 10Mbps? GATE 2008

## (A) 1.6 seconds (B) 2 seconds (C) 5 seconds (D) 8 seconds

ANS: B
SOL: If the capacity of the token bucket is C bytes, Token arrival rate is R bytes/sec, and the
Maximum possible transmission rate is M bytes/sec then the time(S) in seconds it is possible to
transmit is S = C/(M-R) seconds , so 16/(10-2) = 2 seconds.

32. In Ethernet when Manchester encoding is used, the bit rate is: GATE 2007

171
(A) Half the baud rate. (B) Twice the baud rate.
(C) Same as the baud rate. (D) None of the above
ANS: A
SOL: In Ethernet when Manchester encoding is used, the bit rate is half of the baud rate.

33. Which one of the following uses UDP as the transport protocol? GATE 2007

## (A) HTTP (B) Telnet (C) DNS (D) SMTP

ANS: C
SOL: DNS queries are normally short and they need fast responses. Therefore UDP is a better
option as a transport protocol for DNS.

34. There are n stations in a slotted LAN. Each station attempts to transmit with a probability p in each
time slot. What is the probability that ONLY one station transmits in a given time slot?
GATE 2007

## (A) np(1-p)n-1 (B) (1-p)n-1 (C) p(1-p)n-1 (D) 1-(1-p)n-1

ANS: A
SOL: The probability that only one station transmits in a given slot is, probability that station 1
transmits, stations 2 to n are not tranmitting + station 2 is transmitting and
station 1, stations 3 to n are not transmitting + ...............

## which is, p(1-p)(1-P)....... + (1-p)p(1-p)(1-p) ........ + (1-p)(1-p)p(1-p) ......... + ....... ntimes

= p(1-p)(n-1) + p(1-p)(n-1) + p(1-p)(n-1) + p(1-p)(n-1) + p(1-p)(n-1) + ...... n times
= np(1-p)(n-1)

35. In a token ring network the transmission speed is 7 10 bps and the propagation speed is 200
metres/Rs. The 1-bit delay in this network is equivalent to: GATE 2007

## (A) 500 metres of cable. (B) 200 metres of cable.

(C) 20 metres of cable. (D) 50 metres of cable.
ANS: C
SOL: The time taken to transmit 1 bit is 0.1micro second. Propagation speed is
200meters/microsecond.Therefore 1 bit delay implies 20 metres.

36. The address of a class B host is to be split into subnets with a 6-bit subnet number. What is the
maximum number of subnets and the maximum number of hosts in each subnet?
(A) 62 subnets and 262142 hosts. (B) 64 subnets and 262142 hosts.
(C) 62 subnets and 1022 hosts. (D) 64 subnets and 1024 hosts.
ANS: C
SOL: Maximum number of subnets is 26-2 =62. Maximum number of hosts is 210-2 = 1022.
Actually at present , subnets with addresses all 0's and all 1's can also be used.

37. The message 11001001 is to be transmitted using the CRC polynomial 3 x + 1 to protect it from
errors. The message that should be transmitted is: GATE 2007

172
(A) 11001001000 (B) 11001001011
(C) 11001010 (D) 110010010011
ANS: B
SOL: The divisor is 1001. After dividing the given data 11001001 by 1001, the remainder is 011
which is the CRC. Therefore the transmitted data is, data+CRC
which is 11001001011.

38. The distance between two stations M and N is L kilometers. All frames are K bits long. The
propagation delay per kilometer is t seconds. Let R bits/second be the channel capacity. Assuming
that processing delay is negligible, the minimum number of bits for the sequence number field in a
frame for maximum utilization, when the sliding window protocol is used, is:

2+2 2
(A) log 2 (B) log 2

2+ 2+
(C) log 2 (D) log 2
2
ANS: A

## SOL: The distance between the stations is L kilometers.

Propagation delay per kilometer is t seconds. Therefore the total propagation delay is Lt seconds.

## The round trip time is 2*propagation delay = 2Lt seconds.

Maximum utilization can be achieved by transmitting data for the whole round trip time. The
size of data that can be transmitted for Round trip time is Time * bandwidth = 2LtR.

other than round trip time a packet is transmitted, and an ack. is also transmitted when the packet
is received. The size in bits is 2k.

Therefore total size in bits is 2LtR + 2k. Number of packets is (2LtR+2k)/k. Number of bits
required to represent these packets is log(Number of packets).

## 39. Match the following:

(P) SMTP (1) Application layer
(Q) BGP (2) Transport layer
(R) TCP (3) Data link layer
(S) PPP (4) Network layer
(5) Physical layer GATE 2007

(A) P - 2 Q - 1 R - 3 S 5 (B) P - 1 Q - 4 R - 2 S - 3
(C) P - 1 Q - 4 R - 2 S 5 (D) P - 2 Q - 4 R - 1 S 3
ANS: B
SOL: SMTP is an application layer protocol. TCP is the transport layer protocol. BGP is
network layer protocol and PPP is the data link layer protocol.

173
40. For which one of the following reasons does Internet Protocol (IP) use the time-to- live (TTL) field
in the IP datagram header? GATE 2006

## (A) Ensure packets reach destination within that time

(B) Discard packets that reach later than that time
(C) Prevent packets from looping indefinitely
(D) Limit the time for which a packet gets queued in intermediate routers.
ANS: C
SOL: Time to live indicates the time or maximum number of hops the packet is allowed to make
before it is discarded. Normally it is set to twice the maximum length path from source to
destination.

41. Station A uses 32 byte packets to transmit messages to Station B using a sliding window protocol.
The round trip delay between A and B is 80 milliseconds and the bottleneck bandwidth on the path
between A and B is 128 kbps. What is the optimal window size that A should use?
GATE 2006

## (A) 20 (B) 40 (C) 160 (D) 320

ANS: B
SOL: The packet size is 32 bytes = 32*8 bits.

Round trip time is 80ms. Bandwidth is 128kbps. Therefore in 1 RTT, the source a transmit
128kbps * 80ms bits of data.

The data possible to be transmitted divided by the packet size gives the window size, which
is (128k * 80 ms)/(32*8) = 40.

42. Two computers C1 and C2 are configured as follows. C1 has IP address 203.197.2.53 and net mask
255.255.128.0. C2 has IP address 203.197.75.201 and net mask 255.255.192.0. which one of the
following statements is true? GATE 2006

## (A) C1 and C2 both assume they are on the same network

(B) C2 assumes C1 is on same network, but C1 assumes C2 is on a different network
(C) C1 assumes C2 is on same network, but C2 assumes C1 is on a different network
(D) C1 and C2 both assume they are on different networks.
ANS: C
SOL: IP address of C1 is 203.197.2.53 and Subnet mask is 255.255.128.0 ending gives the network
id which is 203.197.0.0.

When C1 sees the ipaddress 203.197.75.201, to find the network id it will and with its subnet

## Similarly, IP address of C2 is 203.197.75.201, subnet mask is 255.255.192.0 ending gives the

network id which is 203.197.64.0.

174
When this computer looks at IP address of C1, to find the network id, it will and with its network

Therefore C1 assumes that C2 is on the same network with C2, but C2 assumes C1 is on a
different network.

43. Station A needs to send a message consisting of 9 packets to Station B using a sliding window
(window size 3) and go-back-n error control strategy. All packets are ready and immediately
available for transmission. If every 5th packet that A transmits gets lost (but no acks from B ever get
lost), then what is the number of packets that A will transmit for sending the message to B?
GATE 2006

## (A) 12 (B) 14 (C) 16 (D) 18

ANS: C

SOL:

Assume that correctly transmitted packet is acknowledged at the same time. When a packet is
lost, the receiver waits for certain duration but the sender can send up to its window size. The
total number of packets sent is 16.

44. Packets of the same session may be routed through different paths in:
(a) TCP, but not UDP (b) TCP and UDP
(c) UDP, but not TCP (d) Neither TCP nor UDP
ANS: B
SOL: Packet is the Network layer Protocol Data Unit (PDU). TCP and UDP are Transport layer
protocols. Packets of same session may be routed through different routes. Most networks dont use

175
static routing, but use some form of adaptive routing where the paths used to route two packets for
same session may be different due to congestion on some link, or some other reason.

45. The address resolution protocol (ARP) is used for: GATE 2005

## (a) Finding the IP address from the DNS

(b) Finding the IP address of the default gateway
ANS: D

46. The maximum window size for data transmission using the selective reject protocol with n-bit frame
sequence numbers is: GATE 2005

## (a) 2n (b) 2n - 1 (c) 2n - 1 (d) 2n-2

ANS: B

47. In a network of LANs connected by bridges, packets are sent from one LAN to another through
intermediate bridges. Since more than one path may exist between two LANs, packets may have to
be routed through multiple bridges. Why is the spanning tree algorithm used for bridge-routing?
GATE 2005

## (a) For shortest path routing between LANs

(b) For avoiding loops in the routing paths
(c) For fault tolerance
(d) For minimizing collisions
ANS: B

48. An organization has a class B network and wishes to form subnets for 64 departments. The subnet

## (a) 255.255.0.0 (b) 255.255.64.0

(c) 255.255.128.0 (d) 255.255.252.0
ANS: D
SOL: The size of network ID is 16 bit in class B networks. So bits after 16th bit must be used to
create 64 departments. Total 6 bits are needed to identify 64 different departments. Therefore, subnet

49. Suppose the round trip propagation delay for a 10 Mbps Ethernet having 48-bit jamming signal is
46.4 ms. The minimum frame size is: GATE 2005

## (a) 94 (b) 416 (c) 464 (d) 512

ANS: C
SOL: Transmission Speed = 10Mbps.
Round trip propagation delay = 46.4 ms
The minimum frame size = (Round Trip Propagation Delay) * (Transmission Speed)
176
= 10*(10^6)*46.4*(10^-3) = 464 * 10^3 = 464 Kbit.

The concept behind the above formula is collision detection. Consider a situation where a
node A wants to send a frame to another node B. When Node A begins transmitting, the signal
must propagate the network length. In the worst-case collision scenario, Node B begins to
transmit just before the signal for Node As frame reaches it. The collision signal of Node A and
Node Bs frame must travel back to Node A for Node A to detect that a collision has occurred.

The time it takes for a signal to propagate from one end of the network to the other is
known as the propagation delay. In this worst-case collision scenario, the time that it takes for
Node A to detect that its frame has been collided with is twice the propagation delay. Node As
frame must travel all the way to Node B, and then the collision signal must travel all the way
from Node B back to Node A. This time is known as the slot time. An Ethernet node must be
transmitting a frame for the slot time for a collision with that frame to be detected. This is the
reason for the minimum Ethernet frame size.

Group 1 Group 2

## R. Transport layer 3.Allows end-to-end communication between two

processes
4. Routes data from one network node to the next
(a) P 1, Q 4, R - 3 (b) P 2, Q 4, R - 1
(c) P 2, Q 3, R - 1 (d) P 1, Q 3, R 2
ANS: A
SOL: Transport layer is responsible for end to end communication, creation of
sockets.Network layer routes the data from one node to other, till it reach to destination.
Datalink layer ensures reliable data transfer by error correction, duplication check ordered
delivery etc.

51. Which of the following is NOT true with respect to a transparent bridge and a router?
(a) Both bridge and router selectively forward data packets
(b) A bridge uses IP addresses while a router uses MAC addresses
(c) A bridge builds up its routing table by inspecting incoming packets
(d) A router can connect between a LAN and a WAN
ANS: B

177
SOL: Bridge is the device which work at data link layer whereas router works at network
layer. Both selectively forward packets, build routing table & connect between LAN & WAN
but since bridge works at data link it uses MAC addresses to route whereas router uses IP

## 52. The routing table of a router is shown below:

On which interface will the router forward packets addressed to destinations 128.75.43.16 and
192.12.17.10 respectively?

## (c) Eth0 and Eth3 (d) Eth1 and Eth3

ANS: C

128.75.43.16. (1)
Eth 0 128.75.43.0. (2)
Equation (1) & (2) both are of same network.
192.12.17.10. (1)
Eth3 192.12.17.5 (2)
Equation (1) & (2) both are of same network.

53. Which of the following assertions is FALSE about the Internet Protocol (IP)? GATE 2003

## (A) It is possible for a computer to have multiple IP addresses

(B) IP packets from the same source to the same destination can take different routes in the network
(C) IP ensures that a packet is discarded if it is unable to reach its destination within a given number
of hops
(D) The packet source cannot set the route of an outgoing packets; the route is determined only by
the routing tables in the routers on the way
ANS: A
SOL: Internet protocol ensures that a packet is forwarded if it is nable to reach its
178
destination within a given no. of hops. One computer can have multiple IP addresses also
packets having same source & destination can take different routes.
Source doesnt decide where to route the packet, but it is decided by the routing tables at
intermediate routers.

54. Which of the following functionalities must be implemented by a transport protocol over and above
the network protocol?GATE 2003

## (A) Recovery from packet losses (B) Detection of duplicate packets

(C) Packet delivery in the correct order (D) End to end connectivity
ANS: D
SOL: Transport protocols are mainly for providing end to end connections by making
sockets. Recovery from packet loss & delivery in correct order, duplication is checked by

WEB TECHNOLOGIES
1. DMSP stands for
A. Distributed Mail System Protocol B. Distributed Message System Pool
C. Distributed Message System Protocol D. Distributed Mai l System Pool

Explanation:

## 2. The term byte stuffing refers to:

A. Data stuffing used with character oriented B. Data stuffing used with bit oriented
hardware. hardware.
C. data stuffing used with both (A) and(B) D. Data stuffing used with byte oriented
hardware.

Explanation:

179
The term byte stuffing refers to data stuffing used with character -oriented hardware

## 3. In 32bit IP Addressing scheme all 1's represent

A. this computer. B. directed broadcast.
C. limited broadcast. D. loop back.

Explanation:

## 4. Which Layer is not present in TCP/ IP model?

A. Application Layer B. Internet Layer
C. Transport Layer D. Presentation Layer

Explanation:

## 5. All exceptions in Java are subclasses of built in class called

A. Exception B. Error.
C. Throwable. D. Raise.

Explanation:

## All exception in Java are subclasses of built in class called Throwable.

6. Unlike Ipv4, Ipv6 does not include the following field in the base header
A. Next Header field. B. Field for Fragmentation information
C. Flow Label. D. Kind field.

180

Explanation:

Unlike Ipv4, Ipv6 does not include the Field for Fragmentation information in the base header.

## 7. Let most segment of a name inn DNS represents

A. Individual Network. B. Individual computer.
C. Domain name D. Network t ype.

Explanation:

## 8. A header in CGI script can specify

A. format of the document. B. new location of the document.
C. (A) and (B) both D. start of the document.

Explanation:

A header in CGI script can specify - Format of the document & New location of the document.

## 9. Address 192.5.48.3 belongs to

A. class A. B. class B.
C. class C. D. class D.

Explanation:

## 10. FDDI (Fiber Distributed Data Interconnect) is an example of

A. token ring. B. token bus
C. star topology D. multipoint network.
181

Explanation:

## 11. CIDR stands for

A. Classified Internet Domain Routing B. Classless Inter Domain Routing
C. Classless Internet Domain Routing D. Classified Inter Domain Routing

Explanation:

## 12. A Network uses a star topology if

A. Computers are arranged in a closed loop. B. All computers attach to a central point.
C. All computers attach to a single long cable. D. Computers attach to multiple
hierarchical cables.

Explanation:

## 13. In IP addressing scheme, class used for multicasting is:

A. Class A B. Class B
C. Class C D. Class D

Explanation:

A. 3. B. 4.
182
C. 5. D. 9.

Explanation:

## 15. In TCP protocol header 'checksum' is of___________

A. 8 bits B. 16 bits
C. 32 bits D. 64 bis

Explanation:

## In TCP protocol header checksum is of 16 bits.

16. Error detecting method that can detect more errors without increasing additional information in
each packet is
A. checksum B. even parity mechanism
C. CRC D. odd parity mechanism.

Explanation:

Error detecting method that can detect more errors without increasing additional information in each
packet is CRC.

## 17. Parent class of all Java classes is

A. java.lang.system B. java.lang.object
C. java.lang.class D. java.lang.reflect.object

Explanation:

## 18. Hardware that calculates CRC(Cyclic Redundancy Check) uses:

A. Shift register B. Xor unit
183
C. Both (A)and (B) D. Instruction register

Explanation:

Hardware that calculates CRC uses shift register and Xor unit.

## 19. Except ions of type error inn JAVA are handled by

A. User program B. Java run time environment
C. Operating system kerne D. Interrupt

Explanation:

Exceptions of type error in JAVA are handled by JAVA run time environment.

## 20. MTU is specified by

A. IP Datagram size B. Hardware technology
C. TCP Segment size D. None of the above.

Explanation:

## MTU is specified by hardware technology.

21. Consider the HTML t able definition given below: (GATE 2009)

## < table border=1>

<tr>
<td rowspan=2> ab </td>
<td colspan=2> cd </td>
</tr>
<tr>
<td> ef </td>
<td rowspan=2> gh </td>
</tr>
<tr> <td colspan=2> ik </td>
</tr>
</table>
184
The number of rows in each column and the number of columns in each row are:
A. (2,2,3) and (2,3,2) B. (2,2,3) and (2,2,3)
C. (2,3,2) and (2,3,2) D. (2,3,2) and (2,2,3)

Explanation:

Here two td command used in the first tr command and three td command used in second tr command,
So required rows in each column is <2,3,2>

22. HTML (HyperText Markup Language) has language elements which permit certain actions other
than describing the structure of the web document. Which one of the following actions is NOT
supported by pure HTML (without any server or client side scripting) pages?(GATE 2011)
A. Embed web objects from different B. Refresh the page automatically after a
sites into the same page specified interval
C. Automatically redirect to another D. Display the client time as

Explanation:

As per Theory.

COMPUTER ORGANIZATION

YEAR 2001

Question. 1
More than one word are put in one cache block to
(E) Exploit the temporal locality of reference in a program
(F) Exploit the spatial locality of reference in a program
(G) Reduce the miss penalty
(H) None of the above

185
SOLUTION

Cache is the small memory which has a very less access time. So it is used for temporal locality of
reference whereas virtual memory is for spatial locality of reference.
Hence (A) is correct option.

Question. 2
A low memory can be connected to 8085 by using
(A) INTER (B) RESET IN

SOLUTION
memory can be connected to 8085 by using READY signal. If READY is set then communication is
possible.Hence (D) is correct option.

Question. 3
Suppose a processor does not have any stack pointer register. Which of the following statements is true ?
(A) It cannot have subroutine call instruction
(B) It can have subroutine call instruction, but no nested subroutine calls.
(C) Nested subroutine calls are possible, but interrupts are not.
(D) All sequences of subroutine calls and also interrupts are possible

SOLUTION

Stack pointer register holds the address of top of stack, which is the location of memory at which the
CPU should resume its execution after servicing some interrupt or subroutine call.
So if SP register not available then no subroutine call instructions are possible.
Hence (A) is correct option.

Question. 4
A processor needs software interrupt to
(E) Test the interrupt system of the processor.
(F) Implement co-routines.
(G) Obtain system services which need execution of privileged instructions.
(H) Return from subroutine.

SOLUTION
186
A CPU needs software interrupt to obtain system services which need execution of privileged
instructions.
Hence (C) is correct opton.

Question. 5
A CPU has two modes-privileged and non-privileged. In order to change the mode from privileged to
non-privileged.
(A) A hardware interrupt is needed.

## (E) A software interrupt is needed.

(F) A privileged instruction (which does not generate an interrupt) is needed.
(G) A non-privileged instruction (Which does not generate an interrupt) is needed.

SOLUTION

A software interrupt is initiated by some program module which need some CPU services, at that time
the two modes can be interchanged. Hence (B) is correct option.

Question. 6
The process of assigning load addresses to the various parts of the program and adjusting the code and
date in the program to reflect the assigned addresses is called
(A) Assembly (B) Parsing
(C) Relocation (D) Symbol resolution

SOLUTION

Load addresses are assigned to various parts of the program, the program can be loaded at any location
in memory. This location is added to all addresses in the code, to get correct references.
This makes a code re-locatable. Hence (C) is correct option.

Question. 7
Which of the following requires a device driver ?
(A) Register (B) Cache
(C) Main memory (D) Disk

SOLUTION

Device driver is the program which co-ordinates with CPU to regulate the devices. Register, cache &
187
main memory are directly connected to CPU.
So only Disk from given options require device drivers. Hence (D) is correct option.
Question. 8
Which is the most appropriate match for the items in the first column with the items in the second
column
(X.) Indirect Addressing (I.) Array implementation
(Y.) Indexed Addressing (II.) Writing re-locatable code
(Z.) Base Register Addressing (III.) Passing array as parameter

(A) (X, III) (Y, I) (Z, II) (B) (X, II) (Y, III) (Z, I)
(C) (X, III) (Y, II) (Z, I) (D) (X, I) (Y, III) (Z, II)

SOLUTION

Indexed addressing is used for array implementation where each element has indexes. Base register is
used to re-locatable code, where starts from base address & then all local addresses as added to base
Indirect addressing is done when array is passed as parameter only name is passed.
Hence (A) is correct option.

Question. 9
Consider the following data path of a simple non-pilelined CPU. The registers A, B, A1, A2, MDR the
bus and the ALU are 8-bit wide. SP and MAR are 16-bit registers. The MUX is of size 8 X (2:1) and the
DEMUX is of size 8 X (1:2). Each memory operation takes 2 CPU clock cycles and uses MAR
(Memory Address Register) and MDR (Memory Date Register). SP can be decremented locally.

## The CPU instruction push r, where = A or B, has the specification

M [ SP] !r

SP ! SP 1
188
How many CPU clock cycles are needed to execute the push r instruction ?
(A) 2 (B) 3
(C) 4 (D) 5

SOLUTION

Push r
Consist of following operations
M [ SP] !r
SP ! SP 1
r is stored at memory at address stack pointer currently is, this take 2 clock cycles.
SP is then decremented to point to next top of stack. So total cycles = 3
Hence (B) is correct option.

Question. 10
Which of the following does not interrupt a running process ?
(A) A device (B) Timer
(C) Scheduler process (D) Power failure

SOLUTION

A device can request interrupt service. A timer when finishes or power failure causes a running process
to stop. But a scheduler process doesnt do this.
Hence (C) is correct option.

YEAR 2002

Question. 11
A device employing INTR line for device interrupt puts the CALL instruction on the data bus while
(A) INTA is active (B) HOLD is active
(C) READY is active (D) None of the above

LUTION

INTR is a signal which if enabled then microprocessor has interrupt enabled it receives high INR signal
& activates INTA signal, so another request cant be accepted till CPU is busy in servicing interrupt.
Hence (A) is correct option.

189
Question. 12
In 8085 which of the following modifies the program counter ?
(E) Only PCHL instruction
(G) Only JMP and CALL instructions
(H) All instructions

SOLUTION

Program counter is the register which has the next location of the program to be executed next. JMP &
CALL changes the value of PC. PCHL instruction copies content of registers H & L to PC.
ADD instruction after completion increments program counter. So program counter is modified in all
cases.
Hence (D) is correct option.

Question. 13
In serial data transmission, every byte of data is padded with a 0 in the beginning and one or two 1s
at the end of byte because
(E) Receiver is to be synchronized for byte reception
(G) Padded bits are useful in parity computation.
(H) None of the above

SOLUTION

In serial data transmission the sender & receiver needs to be synchronized with each other. Receiver
should know when 1 byte of data has been sent. 0 & 1s which are padded tell the receiver to
synchronize.
Hence (A) is correct option.

uestion. 14
Which of the following is not a form of memory ?
(A) Instruction cache (B) Instruction register
(C) Instruction opcode (D) Translation-a-side buffer

SOLUTION

190
Instruction register stores instruction, look-a-side buffer & instruction cache are also memory.
But instruction opcodes are the opcodes related to an instruction which are not part of memory
hierarchy.
Hence (C) is correct option.

Question. 15
In the C language
(3) At most one activation record exists between the current activation record and the activation record
for the main.
(4) The number of activation records between the current activation record and the activation record for
the main depends on the actual function calling sequence.
(5) The visibility of global variables depends on the actual function calling sequence.
(6) Recursion requires the activation record for the recursive function to be saved on a different stack
before the recursive fraction can be called.

SOLUTION

Activation record is the contiguous memory locations where the data needed by the program is kept so
at most one activation record exist between current activation record & the record for the main.
Hence (A) is correct option.

Question. 16
In the absolute the addressing mode
(E) The operand is inside the instruction
(F) The address of the operand is inside the instruction
(G) The register containing the address of the operand is specified

## nside the instruction

(D) The location of the operand is implicit

SOLUTION

In absolute addressing mode, no need of giving operand, the operand are implicit, instruction itself has
knowledge of operands.
Hence (D) is correct option.

Question. 17
The performance of a pipelined processor suffers if

191
(E) The pipelined stages have different delays
(F) Consecutive instructions are dependent on each other
(G) The pipeline stages share hardware resources
(H) All the above

SOLUTION

## Pipelining is a method to execute a program breaking it in several independent sequence of stages.

In that case pipeline stages cant have different delays, no dependency among consecutive instructions
& sharing of hardware resources shouldnt be there. So option (D) is true
Hence (D) is correct option.

Question. 18
Horizontal microprogramming
t Does not require use of signal decoders
t Results in larger sized microinstructions than vertical microprogramming
t Uses one bit for each control signal
t All of the above

SOLUTION

192
In horizontal microprogramming the instruction size is not large, & no
decoding is required. But 1 bit is used for all control signals. Hence (C) is
correct option.

YEAR 2003

Question. 19
For a pipelined CPU with a single ALU, consider the following situations
1. The j + 1 st instruction uses the result of j th instruction as an
operand
2. The execution of a conditional jump instruction
3. The j th and j + 1 st instructions require the ALU at the same time
Which of the above can cause a hazard?
(A) 1 and 2 only (B) 2 and 3 only
(C) 3 only (D) All the three

SOLUTION

Case 1 is here of data dependency, this cant be safe with single ALU so
Case 2 Conditional jumps are always hazardous they create conditional
dependency in pipeline
Case 3 This is write after read problem or concurrency dependency so
hazardous
All the three are hazardous.
Hence (D) is correct option.

Question. 20
Consider an array multiplier for multiplying two n bit numbers. If each
gate in the circuit has a unit delay, the total delay of the multiplier is
(A) (1) (B) (log n)
(C) (n) (D) (n2)

SOLUTION
The no. of gates used in n bit array multiplier (n X n) is 2n 1. So. if
every single gate takes unit delay, then total delay 0(2n 1) = 0(n) It is of
linear order
Hence (C) is correct option.

193
Question. 21
Consider the ALU shown below

If the operands are in 2s complement representation, which of the following operations can be
performed by suitably setting the control lines K and C0 only (+ and - denote addition and subtraction
respectively)?
(A) A + B, and A B,but notA + 1
(B) A + B,and A + 1,but notA B
(C) A + B,but not A B,orA + 1
(D) A + B,and A B,andA + 1

SOLUTION

This is the ckt to add two numbers in 2s complement form. K & C0 are set to 1. So A + B & A B using
bit adders can be done. Also since C0 = 1 & in case B 0, B1........ all are 0 then it gives A + 1.
Hence (D) is correct option.

## Data for Q. 22 & 23 are given below.

Consider the following assembly language program for a hypothetical processor. A,B and C are 8 bit
registers. The meanings of various instructions are shown as comments.
MO
V B, # 0 ; B!0
MO
V C, # 8 ; C!8
Z: CMP C, # 0 ; compare C with 0
SUB C, # 1 ; C!C1

194
RRC A, # 1 ; right rotate A through carry
; by one bit. Thus: if the
; initial values of A and the
; carry flag are a7 ....... a0 and c0
; respectively, their values
; after the execution of this
; instruction will be c0 a7 .....a1
; and a0 respectively.
Y: ADD B, # 1 ; B!B+1
X:

Question. 22
If the initial value of register A is A0, the value of register B after the
program execution will be
(A) the number of 0 bits in A0
(B) the number of 1 bits in A
(C) A0
(D) 8

SOLUTION

## Here value of B incremented by 1 only if carry flag is 1, carry is filled

using right rotation, so B will store the no. of is in A0.
Hence (B) is correct option.

Question. 23
Which of the following instructions when inserted at location X will
ensure that the value of register A after program execution is the same as
its initial value?
(A) RRC A,# 1
(B) NOP ; no operation
(C) LRC A, # 1 ; left rotate A through carry flag by one bit
195
SOLUTION

In the end of program execution to check whether both initial and final value of register A is A0, we need
to right rotate register A through carry by one bit.
Hence (A) is correct option.

YEAR 2004

Question. 24
Which of the following addressing modes are suitable for program relocation at run time?
(A) 1 and 4 (B) 1 and 2
(C) 2 and 3 (D) 1,2 and 4

SOLUTION

Program relocation at run time transfers complete block to some memory locations. This require as base
This require both based addressing and relative addressing mode. Hence (C) is correct option.

Question. 25
Consider a multiplexer with X and Y as data inputs and Z as control input.Z = 0 selects input X , and Z =1
selects input Y . What are the
connection required to realize the 2-variable Boolean function
f = T + R, without using any additional hardware?
(A) R to X, 1 to Y, T to Z (B) T to X, R to Y, T to Z
(C) T to X, R to Y, 0 to Z (D) R to X, 0 to Y, T to Z

196
SOLUTIO
N

We require f = T + R
We have MUX equation
f = Z' x + zy
Now if we make following ckt

Truth table So X = R Y = 1 Z = T

R T F Z
f =T'R+T
0 0 0 0
= (T + T ')(T + R)
0 1 1 1
f =T+R
1 0 1 0
1 1 1 1

## Consider the following program segment for a hypothetical CPU having

197
three user registers R1,R2 and R3.

198
Instruction Operation Instruction Size
(in words)
MOV R1,5000 ;R1Memory 2
MOV R2,R3 ;R2R2+R3 1
MOV 6000,R2 ;MemoryR2 2
HALT ;Machine halts 1

Question. 26
Consider that the memory is byte addressable with size 32 bits, and the program has been loaded starting
from memory location 1000 (decimal). If an interrupt occurs while the CPU has been halted after
executing the HALT instruction, the return address (in decimal) saved in the stack will be
(A) 1007 (B) 1020
(C) 1024 (D) 1028

SOLUTION

## Byte addressable so 1 word require 4 bytes.

1 2 1000-1007
2 1 1008-1011
3 1 1012-1015
4 2 1016-1023
5 1 1024-1027
Next location 1028.
CPU has executed the HALT instruction so next time the CPU will resume at next location i.e. 1028
which would be at the top of stack.

## Hence (D) is correct option.

Question. 27
Let the clock cycles required for various operations be as follows:
Register to/from memory transfer: 3 clock cycles

199
ADD with both operands in register: 1 clock cycle
Instruction fetch and decode: 2 clock cycles per word
The total number of clock cycles required to execute the program is
(A) 29 (B) 24
(C) 23 (D) 20

SOLUTION

The clock cycles are per block so if an instruction size is 2 then it requires
twice no. of clock cycles.
Instruction No. Size No. of clock cycles
1 2 3X2+2 8
2 1 1X3+2 5
4 2 3X2+2 8
5 1 2(fetch & decode) 2

Total 24

## Hence (B) is correct option.

Question. 28
Consider a small two-way set-associative cache memory, consisting of
four blocks. For choosing the block to be replaced, use the least recently
used (LRU) scheme. The number of cache misses for the following
sequence of block addresses is 8, 12,0, 12,8
(A) 2 (B) 3
(C) 4 (D) 5

SOLUTION

200