Beruflich Dokumente
Kultur Dokumente
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.
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?
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)
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
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
SOLUTION
When CPU burst are given to another process, called context switching. The Gantt chart for
shortest remaining time first is.
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;
}
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.
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.
SOLUTION
TLB has 128 page table enteries, each page table would have. 64 bits i.e. 32 +32 virtual
addresses.
27*26
27*26/22 = 211
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?
Since both virtual and physical memory has 32 bit addresses, so there is no need for address
translation hardware is required.
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 = 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
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
Gantt chart
=(6/51)*100
=10.6%
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
deadlock?
(A) min(xp,xq) < maxkp,q yk (B) xp+xq maxkp,q yk (C) min(xp,xq) < 1 (D) min(xp,xq)>1
SOLUTION
Means the min no. of resources allocated should be less than the maximum number of resources
required by any process other than p & q
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?
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
(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).
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.
Question. 37
Consider the following statements about user level threads and kernel level threads. Which one
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
(D) Blocking one kernel level thread blocks all related threads
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
related threads, they are unaffected.
So (D) is false.
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
SOLUTION
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.
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.
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.
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.
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?
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.
So a definite deadlock.
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?
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
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?
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.
113
YEAR 2008
Question. 44
Which of the following system calls results in the sending of SYN packets?
SOLUTION
SYN packets are used for synchronization between sender & receiver, these packets are sent by
sender during connect system call for synchronous connection.
Question. 45
The data block of a very large file in the Unix file system are allocated using
(A) Contiguous allocation
(B) Linked 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.
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 );
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
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.
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
(C) Deadlock avoidance is less restrictive than deadlock prevention
(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.
Question. 49
A process executes the following code for(i = 0;i < n;i ++) fork();
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.
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-
to-physical address translation, where the virtual address is used as follows
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
YEAR 2009
Question. 51
Which one of the following statements is TRUE if all three processes run concurrently starting
at time t = 0 ?
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
Question. 52
In which of the following page replacement policies, Beladys anomaly may occur ?
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
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 :
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?
SOLUTION
Arranging in order.
Question. 55
In the following process state transition diagram for a uniprocessor system, assume that there
are always some processes in the steady state :
(A) I and II (B) I and III (C) II and III (D) II and IV
SOLUTION
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
SOLUTION
I Is true since X is initialized to zero, this cause only 1 process to enter into critical so no
deadlock.
120
II & III Are false, other process which doesnt capture X will wait so ultimately starve.
Question. 57
A multilevel page table is preferred in comparison to a single level page table for translating
virtual address to physical address because
(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
(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.
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.
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.
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 ?
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
(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
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
(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;
}
(A) n=40, k=26 (B) n=21, k=12 (C) n=20 , k=10 (D) n=41, k=19
SOLUTION
Answer (B)
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.
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
Answer (C)
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)
Answer (A)
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
Answer (C)
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:
Answer (B)
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.
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
Answer (A)
Id Name Age
----------------
12 Arun 60
15 Shreya 24
99 Rohit 11
25 Hari 40
98 Rohit 20
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
Answer (B)
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.
128
Answer (A)
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.
Answer (C)
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.
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
Answer (C)
Borrower Bank_Manager
--------------------------
Ramesh Sunderajan
Suresh Ramgqpal
Mahesh Sunderjan
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.
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
Answer (A)
X Y
-------
1 1
130
2 3
3 7
4 15
5 31
6 63
7 127
......
......
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
Answer (C)
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
serialzability and freedom from deadlock?
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
Answer (B)
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.
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
Answer (A)
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
Answer (A)
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
Answer (B)
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:
Answer (A)
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.
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.
Answer (B)
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
Answer (A)
The schema is in BCNF as all attributes depend only on a superkey (Note that primary and
candidate keys are also superkeys).
Answer (A)
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}
Answer (A)
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
Answer (C)
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.
(GATE: 2007)
Answer (B)
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)
Answer (C)
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)
Answer (D)
Consider the following example table.
Answer (D)
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.
Answer (C)
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)
Answer (C)
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)
(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.
Answer (A)
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.
Answer (C)
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
Answer (C)
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
Answer (c)
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)
Answer (C)
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
Answer (d)
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
Answer (c)
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
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
Answer (c)
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
(GATE 2005)
(a) AE, BE
(b) AE, BE, DE
(c) AEH, BEH, BCH
(d) AEH, BEH, DEH
Answer (d)
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)
Answer (2)
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.
1) 8, 8
2) 120, 8
3) 960, 8
4) 960, 120
Answer (1)
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)
Answer (4)
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.
Answer (1)
(a) Zero
(b) More than zero but less than that of an equivalent 3NF decomposition
(c) Proportional to the size of F+
(d) Indetermine
44) With regard to the expressive power of the formal relational query
languages, which of the following statements is true? (GATE: 2002)
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)
references geq on delete cascade)
(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.
150
Answer: (B)
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
Answer: (d)
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
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.
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
Answer: (C)
58) Suppose we have a database consisting of the following three relations.
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.
2.
154
Solution: B gate-2010
3.
Solution: A gate-2010
4.
Solution: D gate-2010
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
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
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
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.
d. Business Construct.
e. Statement Construct.
Solution:B gate-2012
Solution:D gate-2012
158
Ans: B
Ans: D
Ans: A
Ans: D
20. Changes made to an information system to add the desired but not necessarily the
required features is called
(A) Preventative maintenance.
(B) Adaptive 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
Ans: A
Ans: B
Ans:D 2013
COMPUTER NETWORKS
1. The transport layer protocols used for real time multimedia, file transfer, DNS and email,
respectively are GATE 2013
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
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
= +
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
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
Data Link layer Frame
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
Let W be the set of vertices for which shortest path distance has not been computed
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
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
(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
(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
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
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
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
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
Statement for Linked Answer Questions: 19 & 20
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
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
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
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
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
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
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
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
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
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
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
Propagation delay per kilometer is t seconds. Therefore the total propagation delay is Lt 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).
(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
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
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
When C1 sees the ipaddress 203.197.75.201, to find the network id it will and with its subnet
mask, which gives 203.197.0.0.
174
When this computer looks at IP address of C1, to find the network id, it will and with its network
mask giving 203.197.0.0.
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
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
46. The maximum window size for data transmission using the selective reject protocol with n-bit frame
sequence numbers is: GATE 2005
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
48. An organization has a class B network and wishes to form subnets for 64 departments. The subnet
mask would be: GATE 2005
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
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.
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
addresses.
On which interface will the router forward packets addressed to destinations 128.75.43.16 and
192.12.17.10 respectively?
53. Which of the following assertions is FALSE about the Internet Protocol (IP)? GATE 2003
54. Which of the following functionalities must be implemented by a transport protocol over and above
the network protocol?GATE 2003
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
Answer: Option A
Explanation:
Answer: Option A
Explanation:
179
The term byte stuffing refers to data stuffing used with character -oriented hardware
Answer: Option C
Explanation:
Answer: Option D
Explanation:
Answer: Option C
Explanation:
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.
Answer & Explanation
180
Answer: Option B
Explanation:
Unlike Ipv4, Ipv6 does not include the Field for Fragmentation information in the base header.
Answer: Option B
Explanation:
Answer: Option A
Explanation:
A header in CGI script can specify - Format of the document & New location of the document.
Answer: Option C
Explanation:
Answer: Option A
Explanation:
Answer: Option B
Explanation:
Answer: Option B
Explanation:
Answer: Option D
Explanation:
Answer: Option C
Explanation:
Answer: Option B
Explanation:
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.
Answer & Explanation
Answer: Option C
Explanation:
Error detecting method that can detect more errors without increasing additional information in each
packet is CRC.
Answer: Option B
Explanation:
Answer: Option B
Explanation:
Hardware that calculates CRC uses shift register and Xor unit.
Answer: Option B
Explanation:
Exceptions of type error in JAVA are handled by JAVA run time environment.
Answer: Option B
Explanation:
21. Consider the HTML t able definition given below: (GATE 2009)
Answer: Option C
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
page upon download part of the page
Answer & Explanation
Answer: Option D
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
(C) HOLD (D) READY
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.
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
address.
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.
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
(F) Only ADD instructions
(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
(F) Receiver recovers lost 0s and 1 from these padded bits
(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
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
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
read after write.
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.
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
JZX ; jump to X if zero flag is set
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.
JCY ;jump to Y if carry flag is set
JMP Z ; jump to Z
Y: ADD B, # 1 ; B!B+1
JMP Z ; jump to Z
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
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
(D) ADD A, # 1
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?
1. Absolute addressing
2. Based addressing
3. Relative addressing
4. Indirect addressing
(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
address and block should be relatively addressed through this base address.
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
198
Instruction Operation Instruction Size
(in words)
MOV R1,5000 ;R1Memory[5000] 2
MOV R2,R3 ;R2R2+R3 1
ADD R2,R3 ;R2R2+R3 1
MOV 6000,R2 ;Memory[6000]R2 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
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
3 1 1(add only) 1
4 2 3X2+2 8
5 1 2(fetch & decode) 2
Total 24
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