0% found this document useful (0 votes)
1K views426 pages

Gate Question Bank Cs

Uploaded by

sanket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views426 pages

Gate Question Bank Cs

Uploaded by

sanket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 426

GATE QUESTION BANK

for

Computer Science
&
Information Technology

By
GATE QUESTION BANK Contents

Contents
Subject Name Topic Name Page No.
#1. Mathematics 1-112
1 Linear Algebra 1 – 28
2 Probability & Distribution 29 – 57
3 Numerical Methods 58 – 73
4 Calculus 74 – 112

#2. Data Structure and Algorithm 113 – 177


5 Data Structure and Algorithm Analysis 113 – 136
6 Stacks and Queues 137 – 140
7 Trees 141 – 148
8 Height Balanced Trees (AVL Trees, B and ) 149 – 150
9 Priority Queues (Heaps) 151 – 156
10 Sorting Algorithms 157 – 160
11 Graph Algorithms 161 – 174
12 Hashing 175 – 177

#3. Operating System 178 – 210


13 Introduction to Operating System 178
14 Process Management 179 – 186
15 Threads 187
16 CPU Scheduling 188 – 193
17 Deadlocks 194 – 199
18 Memory Management & Virtual Memory 200 – 206
19 File System 207 – 208
20 I/O System 209 – 210

#4. Theory of Computation 211 – 235


21 Finite Automata 211 – 216
22 Regular Expression 217 – 223
23 Context Free grammar 224 – 229
24 Turing Machines 230 – 235

#5. Computer Organization & Architecture 236 – 263


25 Introduction to Computer Organization 236
26 Memory Hierarchy 237 – 246
27 Pipeline 247 – 252
28 Instruction Types 253 – 258
29 I/O Data Transfer 259 – 263

#6. Digital Logic 264 – 289


30 Number Systems & Code Conversions 264 – 268
31 Boolean Algebra & Karnaugh Maps 269 – 275

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page I
GATE QUESTION BANK Contents

32 Logic Gates 276 – 279


33 Logic Gate Families 280
34 Combinational and Sequential Digital Circuits 281 – 289

#7. Discrete Mathematics & Graph Theory 290 – 322


35 Mathematical Logic 290 – 297
36 Combinatorics 298 - 300
37 Sets and Relations 301 – 313
38 Graph Theory 314 – 322

#8. Database Management System 323 – 361


39 ER Diagrams 323 – 324
40 Functional Dependencies & Normalization 325 – 330
41 Relational Algebra & Relational Calculus 331 – 337
42 SQL 338 – 351
43 Transactions and Concurrency Control 352 – 357
44 File Structures (Sequential files, Indexing, 358 – 361
B and trees)

#9. Computer Networks 362 – 396


45 Introduction to Computer Networks 362 – 363
46 Medium Access Sublayer 364 - 367
(LAN Technologies: Ethernet, Token Ring)
47 The Data Link Layer (Flow and Error Control 368 – 373
Techniques)
48 Routing & Congestion Control 374 – 379
49 TCP/IP, UDP and Sockets, IP(V4) 380 – 390
50 Application Layer 391 – 393
51 Network Security 394 – 396

#10. Compiler Design 397 – 409


52 Introduction to Compilers 397
53 Syntax Analysis 398 – 403
54 Syntax Directed Translation 404 – 405
55 Intermediate Code Generation 406 – 409

#11. Software Engineering and Web Technology 410 – 412


56 Introduction to Software and Software 410 – 411
Engineering
57 Process Modeling 412 – 413
58 Project Management 414 – 415
59 Validation and Verification 416 – 418
60 HTML Structure 419 – 420
61 XML and DTDs 421 – 422

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page II
GATE QUESTION BANK Mathematics

Linear Algebra
ME – 2005 5. Match the items in columns I and II.
1. Which one of the following is an Column I Column II
P. Singular 1. Determinant is not
Eigenvector of the matrix[ ]? matrix defined
Q. Non-square 2. Determinant is
matrix always one
R. Real 3. Determinant is
(A) [ ] (C) [ ] symmetric zero
matrix
S. Orthogonal 4. Eigen values are
matrix always real
(B) [ ] (D) [ ] 5. Eigen values are
not defined
(A) P - 3 Q - 1 R - 4 S - 2
(B) P - 2 Q - 3 R - 4 S - 1
2. A is a 3 4 real matrix and Ax=B is an (C) P - 3 Q - 2 R - 5 S - 4
inconsistent system of equations. The (D) P - 3 Q - 4 R - 2 S - 1
highest possible rank of A is
(A) 1 (C) 3 ME – 2007
(B) 2 (D) 4 6. The number of linearly independent
Eigenvectors of 0 1 is
ME – 2006
3. Multiplication of matrices E and F is G. (A) 0 (C) 2
Matrices E and G are (B) 1 (D) Infinite
os sin 7. If a square matrix A is real and symmetric,
E [ sin os ] and
then the Eigenvalues
(A) are always real
G [ ]. What is the matrix F? (B) are always real and positive
(C) are always real and non-negative
os sin (D) occur in complex conjugate pairs
(A) [ sin os ]
ME – 2008
sin os
(B) [ os sin ] 8. The Eigenvectors of the matrix 0 1 are

os sin written in the form 0 1 and 0 1. What is


(C) [ sin os ]
a + b?
sin os (A) 0 (C) 1
(D) [ os sin ] (B) 1/2 (D) 2

4. Eigen values of a matrix 9. The matrix [ ] has one Eigenvalue


p
S 0 1are 5 and 1. What are the
equal to 3. The sum of the other two
Eigenvalues of the matrix = SS? Eigenvalues is
(A) 1 and 25 (C) 5 and 1 (A) p (C) p – 2
(B) 6 and 4 (D) 2 and 10 (B) p – 1 (D) p – 3
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 1
GATE QUESTION BANK Mathematics

10. For what value of a, if any, will the ME – 2012


following system of equations in x, y and z 15. For the matrix A=0 1 , one of the
have a solution
x y normalized Eigenvectors is given as
x y z
x y z
(A) (√ ) (C) (√ )

(A) Any real number
(B) 0
(C) 1
(B) (√ ) (D) ( )
√ √
(D) There is no such value
16. x + 2y + z =4
ME – 2009
2x + y + 2z =5
x–y+z=1
11. For a matrix,M- * +, the transpose
x The system of algebraic equations given
above has
of the matrix is equal to the inverse of the
(A) a unique algebraic equation of x = 1,
matrix ,M- ,M- . The value of x is
y = 1 and z = 1
given by
(B) only the two solutions of ( x = 1,
(A) ( ) (C) ⁄
y = 1, z = 1) and ( x = 2, y = 1, z = 0)
(B) ( ⁄ ) (D) ⁄
(C) infinite number of solutions.
ME – 2010 (D) No feasible solution.
12. One of the Eigenvectors of the matrix
ME – 2013
0 1 is 17. The Eigenvalues of a symmetric matrix
are all
(A) 2 3 (C) 2 3
(A) Complex with non –zero positive
(B) 2 3 (D) 2 3 imaginary part.
(B) Complex with non – zero negative
ME – 2011 imaginary part.
13. Consider the following system of (C) Real
equations: (D) Pure imaginary.
x x x
x x 18. Choose correct set of functions, which are
x x linearly dependent.
The system has (A) sin x sin x n os x
(A) A unique solution (B) os x sin x n t n x
(B) No solution (C) os x sin x n os x
(C) Infinite number of solutions (D) os x sin x n os x
(D) Five solutions ME – 2014
14. Eigen values of a real symmetric matrix 19. Given that the determinant of the matrix
are always
[ ] is 12 , the determinant of
(A) Positive (C) Negative
(B) Real (D) Complex
the matrix [ ] is

(A) (B) (C) (D)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 2
GATE QUESTION BANK Mathematics

20. One of the Eigenvectors of the matrix 2. Consider a non-homogeneous system of


0 1 is linear equations representing
mathematically an over-determined
(A) {– } (C) 2 3 system. Such a system will be
(A) consistent having a unique solution
(B) {– } (D) 2 3
(B) consistent having many solutions
(C) inconsistent having a unique solution
21. Consider a 3×3 real symmetric matrix S (D) inconsistent having no solution
such that two of its Eigenvalues are
with respective Eigenvectors 3. Consider the matrices , - , - and
x y
, - . The order of , ( ) - will be
[x ] [y ] If then x y + x y +x y
x y (A) (2 × 2) (C) (4 × 3)
(B) (3 × 3 (D) (3 × 4
equals
(A) a (C) ab
CE – 2006
(B) b (D) 0
4. Solution for the system defined by the set
22. Which one of the following equations is a of equations 4y + 3z = 8; 2x – z = 2 and
correct identity for arbitrary 3×3 real 3x + 2y = 5 is
matrices P, Q and R? (A) x = 0; y =1; z = ⁄
(A) ( ) (B) x = 0; y = ⁄ ; z = 2
(B) ( ) (C) x = 1; y = ⁄ ; z = 2
(C) et ( ) et et (D) non – existent
(D) ( )
5. For the given matrix A = [ ],
CE – 2005
1. Consider the system of equations ( ) one of the Eigen values is 3. The other two
( ) ( ) where is s l r Let Eigen values are
( ) e n Eigen -pair of an Eigenvalue (A) (C)
and its corresponding Eigenvector for (B) (D)
real matrix A. Let I be a (n × n) unit
matrix. Which one of the following CE – 2007
statement is NOT correct? 6. The minimum and the maximum
(A) For a homogeneous n × n system of
Eigenvalue of the matrix [ ]are 2
linear equations,(A ) X = 0 having
a nontrivial solution the rank of and 6, respectively. What is the other
(A ) is less than n. Eigenvalue?
(B) For matrix , m being a positive (A) (C)
integer, ( ) will be the Eigen - (B) (D)
pair for all i.
7. For what values of and the following
(C) If = then | | = 1 for all i.
simultaneous equations have an infinite
(D) If = A then is real for all i.
of solutions?
X + Y + Z = 5; X + 3Y + 3Z = 9;
X+2Y+ Z
(A) 2, 7 (C) 8, 3
(B) 3, 8 (D) 7, 2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 3
GATE QUESTION BANK Mathematics

i i
8. The inverse of the m trix 0 1 is 14. The inverse of the matrix 0 1
i i
(A) 0 1 (C) 0 1 is
( ) i i
(B) 0 1 (D) 0 1 0 1
i i
i i
( ) 0 1
CE – 2008 i i
9. The product of matrices ( ) is ( ) i i
0 1
i i
(A) (C)
i i
(B) (D) PQ ( ) 0 1
i i
10. The Eigenvalue of the matrix
CE – 2012
[P] = 0 1 are
15. The Eigenvalues of matrix 0 1 are
(A) and 8 (C) n
(A) 2.42 and 6.86
(B) and 5 (D) n
(B) 3.48 and 13.53
11. The following simultaneous equation (C) 4.70 and 6.86
x+y+z=3 (D) 6.86 and 9.50
x + 2y + 3z = 4
x + 4y + kz = 6 CE – 2013
will NOT have a unique solution for k 16. There is no value of x that can
equal to simultaneously satisfy both the given
(A) 0 (C) 6 equations. Therefore, find the ‘le st
(B) 5 (D) 7 squares error’ solution to the two
equations, i.e., find the value of x that
CE – 2009 minimizes the sum of squares of the
12. A square matrix B is skew-symmetric if errors in the two equations.
(A) (C) 2x = 3 and 4x = 1
(B) (D)
17. What is the minimum number of
CE – 2011 multiplications involved in computing the
13. [A] is square matrix which is neither matrix product PQR? Matrix P has 4 rows
symmetric nor skew-symmetric and , - and 2 columns, matrix Q has 2 rows and
is its transpose. The sum and difference of 4 columns, and matrix R has 4 rows and 1
these matrices are defined as column. __________
[S] = [A] + , - and [D] = [A] , - ,
CE – 2014
respectively. Which of the following
statements is TRUE? 18. Given the matrices J = [ ] n
(A) Both [S] and [D] are symmetric
(B) Both [S] and [D] are skew-symmetric
(C) [S] is skew-symmetric and [D] is K [ ], the product K JK is
symmetric
(D) [S] is symmetric and [D] is skew
19. The sum of Eigenvalues of the matrix, [M]
symmetric
is, where [M] = [ ]

(A) 915 (C) 1640


(B) 1355 (D) 2180
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 4
GATE QUESTION BANK Mathematics

4. Let A be a 4x4 matrix with Eigenvalues


20. The determinant of matrix [ ] –5, –2, 1, 4. Which of the following is an
I
Eigenvalue of 0 1, where I is the 4x4
I
is ____________ identity matrix?
(A) (C)
21. The rank of the matrix (B) (D)

[ ] is ________________ CS – 2007
5. Consider the set of (column) vectors
defined by X={xR3 x1+x2+x3=0, where
CS – 2005
XT =[x1, x2, x3]T }. Which of the following is
1. Consider the following system of
TRUE?
equations in three real
(A) {[1, 1, 0]T, [1, 0, 1]T} is a basis for
variables x x n x
the subspace X.
x x x
(B) {[1, 1, 0]T, [1, 0, 1]T} is a linearly
x x x
independent set, but it does not span
x x x
X and therefore, is not a basis of X.
This system of equation has
(C) X is not the subspace for R3
(A) no solution
(D) None of the above
(B) a unique solution
(C) more than one but a finite number of
CS – 2008
solutions
6. The following system of
(D) an infinite number of solutions
x x x
x x x
2. What are the Eigenvalues of the following
x x x
2 2 matrix?
Has unique solution. The only possible
0 1 value (s) for is/ are
(A) n (C) n (A) 0
(B) n (D) n (B) either 0 or 1
(C) one of 0,1, 1
CS – 2006 (D) any real number except 5
3. F is an n x n real matrix. b is an n real
vector. Suppose there are two nx1
7. How many of the following matrices have
vectors, u and v such that u  v , and
an Eigenvalue 1?
Fu=b, Fv=b. Which one of the following
statement is false? 0 1 0 1 0 1 n 0 1
(A) Determinant of F is zero (A) One (C) three
(B) There are infinite number of (B) two (D) four
solutions to Fx=b
CS – 2010
(C) There is an x  0 such that Fx=0
8. Consider the following matrix
(D) F must have two identical rows
A=[ ]
x y
If the Eigen values of A are 4 and 8, then
(A) x = 4, y = 10 (C) x = 3, y = 9
(B) x = 5, y = 8 (D) x = 4, y = 10

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 5
GATE QUESTION BANK Mathematics

CS – 2011 13. The value of the dot product of the


9. Consider the matrix as given below Eigenvectors corresponding to any pair of
different Eigenvalues of a 4-by-4
[ ] symmetric positive definite matrix is
__________.
Which one of the following options
provides the CORRECT values of the
14. If the matrix A is such that
Eigenvalues of the matrix?
(A) 1, 4, 3 (C) 7, 3, 2 [ ], -
(B) 3, 7, 3 (D) 1, 2, 3
Then the determinant of A is equal to
CS – 2012 __________.
10. Let A be the 2 2 matrix with elements
and . 15. The product of the non – zero Eigenvalues
Then the Eigenvalues of the matrix of the matrix
are
(A) 1024 and
(B) 1024√ and √ is __________.
(C) √ n √ [ ]
(D) √ n √
16. Which one of the following statements is
CS – 2013
TRUE about every n n matrix with only
11. Which one of the following does NOT
real eigenvalues?
x x
equal [ ] (A) If the trace of the matrix is positive
y y
and the determinant of the matrix is
z z
x(x ) x negative, at least one of its
(A) | y(y ) y | eigenvalues is negative.
z(z ) z (B) If the trace of the matrix is positive,
x x all its eigenvalues are positive.
(B) | y y | (C) If the determinant of the matrix is
z z positive, all its eigenvalues are
x y x y positive.
(C) | y z y z | (D) If the product of the trace and
z z determinant of the matrix is positive,
x y x y all its eigenvalues are positive.
(D) | y z y z |
z z ECE – 2005
1. Given an orthogonal matrix
CS – 2014
12. Consider the following system of A= [ ]. , - is
equations:
x y

x z

x y z (A) [ ]

x y z ⁄
The number of solutions for this system is
__________.
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 6
GATE QUESTION BANK Mathematics


⁄ 6. The rank of the matrix [ ]
(B) [ ]

⁄ (A) 0 (C) 2
(B) 1 (D) 3
(C) [ ]
ECE – 2007
7. It is given that X1 , X2 …… M are M non-

zero, orthogonal vectors. The dimension

(D) [ ] of the vector space spanned by the 2M

⁄ vector X1 , X2 … XM , X1 , X2 … XM is
(A) 2M
⁄ (B) M+1
2. Let, A=0 1 and = 0 1.
(C) M
Then (a + b)=
(D) dependent on the choice of X1 , X2 …
(A) ⁄ (C) ⁄
(B) ⁄ (D) ⁄ XM.

3. Given the matrix 0 1 the ECE – 2008


8. The system of linear equations
Eigenvector is
4x + 2y = 7, 2x + y = 6 has
(A) 0 1 (C) 0 1 (A) a unique solution
(B) 0 1 (D) 0 1 (B) no solution
(C) an infinite number of solutions
(D) exactly two distinct solutions
ECE – 2006
4. For the matrix 0 1 , the Eigenvalue 9. All the four entries of the 2 x 2 matrix
corresponding to the Eigenvector p p
P = 0p p 1 are non-zero, and one of
0 1 is its Eigenvalues is zero. Which of the
(A) 2 (C) 6 following statements is true?
(B) 4 (D) 8 (A) p p p p
(B) p p p p
5. The Eigenvalues and the corresponding (C) p p p p
Eigenvectors of a 2 2 matrix are given (D) p p p p
by
Eigenvalue Eigenvector ECE – 2009
=8 v =0 1 10. The Eigen values of the following matrix
are
=4 v =0 1
The matrix is [ ]

(A) 0 1 (C) 0 1 (A) 3, 3 + 5j, 6 j


(B) 6 + 5j, 3 + j, 3 j
(B) 0 1 (D) 0 1
(C) 3 + j, 3 j, 5 + j
(D) 3, 1 + 3j, 1 3j

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 7
GATE QUESTION BANK Mathematics

ECE – 2010 ECE – 2014


11. The Eigenvalues of a skew-symmetric 16. For matrices of same dimension M, N and
matrix are scalar c, which one of these properties
(A) Always zero DOES NOT ALWAYS hold?
(B) Always pure imaginary (A) (M ) M
(C) Either zero or pure imaginary (B) ( M ) (M)
(D) Always real (C) (M N) M N
(D) MN NM
ECE – 2011
12. The system of equations 17. A real (4 × 4) matrix A satisfies the
x y z equation I where 𝐼 is the (4 × 4)
x y z identity matrix. The positive Eigenvalue
x y z of A is _____.
has NO solution for values of n
given by 18. Consider the matrix
(A) (C)
(B) (D)
J
ECE\EE\IN – 2012
13. Given that A = 0 1 and I = 0 1, [ ]
Which is obtained by reversing the order
the value of A3 is
of the columns of the identity matrix I .
(A) 15 A + 12 I (C) 17 A + 15 I
(B) 19A + 30 (D) 17A +21 Let I J where is a non-
negative real number. The value of for
ECE – 2013 which det(P) = 0 is _____.
14. The minimum Eigenvalue of the following
matrix is 19. The determinant of matrix A is 5 and the
determinant of matrix B is 40. The
[ ] determinant of matrix AB is ________.

(A) 0 (C) 2 20. The system of linear equations


(B) 1 (D) 3
( )4 5 ( )h s
15. Let A be a m n matrix and B be a n m
matrix. It is given that (A) a unique solution
Determinant(I ) determinant (B) infinitely many solutions
(I ) where I is the k k identity (C) no solution
matrix. Using the above property, the (D) exactly two solutions
determinant of the matrix given below is
21. Which one of the following statements is
[ ] NOT true for a square matrix A?
(A) If A is upper triangular, the
(A) 2 (C) 8 Eigenvalues of A are the diagonal
(B) 5 (D) 16 elements of it
(B) If A is real symmetric, the Eigenvalues
of A are always real and positive

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 8
GATE QUESTION BANK Mathematics

(C) If A is real, the Eigenvalues of A and


are always the same (A) [ ] [ ]
(D) If all the principal minors of A are
positive, all the Eigenvalues of A are (B) [ ] [ ] [ ]
also positive

22. The maximum value of the determinant (C) [ ] [ ] [ ]


among all 2×2 real symmetric matrices
with trace 14 is ___. (D) [ ] [ ] [ ]

EE – 2005
5. The following vector is linearly
1. If R = [ ] , then top row of is dependent upon the solution to the
previous problem
(A) , - (C) , -
(B) , - (D) , - (A) [ ] (C) [ ]

2. For the matrix p = [ ] , one of (B) [ ] (D) [ ]

the Eigenvalues is equal to 2 . Which of


EE – 2007
the following is an Eigenvector?
6. X = [x , x . . . . x - is an n-tuple non-zero
(A) [ ] (C) [ ] vector. The n n matrix V = X
(A) Has rank zero (C) Is orthogonal
(B) Has rank 1 (D) Has rank n
(B) [ ] (D) [ ]
7. The linear operation L(x) is defined by
the cross product L(x) = b x, where
3. In the matrix equation Px = q, which of b =[0 1 0- and x =[x x x - are three
the following is necessary condition for
dimensional vectors. The matrix M
the existence of at least one solution for
of this operation satisfies
the unknown vector x x
(A) Augmented matrix [P/Q] must have L(x) = M [ x ]
the same rank as matrix P x
(B) Vector q must have only non-zero Then the Eigenvalues of M are
elements (A) 0, +1, 1 (C) i, i, 1
(C) Matrix P must be singular (B) 1, 1, 1 (D) i, i, 0
(D) Matrix P must be square 8. Let x and y be two vectors in a 3
dimensional space and <x, y> denote
EE – 2006 their dot product. Then the determinant
Statement for Linked Answer Questions 4 xx xy
det 0 y x yy 1
and 5.
(A) is zero when x and y are linearly
P=[ ] ,Q=[ ] ,R=[ ] are independent
(B) is positive when x and y are linearly
three vectors independent
4. An orthogonal set of vectors having a (C) is non-zero for all non-zero x and y
span that contains P,Q, R is (D) is zero only when either x or y is zero
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 9
GATE QUESTION BANK Mathematics

Statement for Linked Questions 9 and 10. (A) A A+ A = A (C) A+ A = 


Cayley-Hamilton Theorem states that a (B) (AA+ ) = A A+ (D) A A+ A = A+
square matrix satisfies its own
characteristic equation. Consider a 14. Let P be a real orthogonal matrix. x⃗
matrix. is a real vector [x x - with length

A=0 1 ⃗x (x x ) . Then, which one of the


following statements is correct?
9. A satisfies the relation
(A) x⃗ x⃗ where at least one
(A) A + 3 + 2 =0
vector satisfies x⃗ x⃗
(B) A + 2A + 2 = 0
2
(B) x⃗ x⃗ for all vectors x⃗
(C) (A+ ) (A 2) = 0
(C) x⃗ x⃗ where at least one
(D) exp (A) = 0
vector satisfies x⃗ x⃗
(D) No relationship can be established
10. equals between x⃗ and x⃗
(A) 511 A + 510 
(B) 309 A + 104  EE – 2009
(C) 154 A + 155  15. The trace and determinant of a
(D) exp (9A) matrix are known to be –2 and –35
respe tively It’s Eigenv lues re
EE – 2008 (A) –30 and –5 (C) –7 and 5
11. If the rank of a ( ) matrix Q is 4, then (B) –37 and –1 (D) 17.5 and –2
which one of the following statements is
correct? EE – 2010
(A) Q will have four linearly independent 16. For the set of equations
rows and four linearly independent x x x x =2
columns x x x x =6
(B) Q will have four linearly independent The following statement is true
rows and five linearly independent (A) Only the trivial solution
columns x x x x = 0 exists
(C) Q will be invertible (B) There are no solutions
(D) Q will be invertible (C) A unique non-trivial solution exists
(D) Multiple non-trivial solutions exist
12. The characteristic equation of a ( )
matrix P is defined as
17. An Eigenvector of [ ] is
() = | P| =    =0
If I denotes identity matrix, then the (A) , - (C) , -
inverse of matrix P will be (B) , - (D) , -
(A) ( I)
(B) ( I) EE – 2011
(C) ( I) 18. The matrix[A] = 0 1 is decomposed
(D) ( I)
into a product of a lower triangular
matrix [L] and an upper triangular matrix
13. A is m n full rank matrix with m > n and
[U]. The properly decomposed [L] and [U]
 is an identity matrix. Let matrix matrices respectively are
A+ = ( ) , then, which one of the
(A) 0 1 and 0 1
following statements is FALSE?
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 10
GATE QUESTION BANK Mathematics

(B) 0 1 and 0 1 23. Two matrices A and B are given below:


p q p q pr qs
0 1 [ ]
(C) 0 1 and 0 1 r s pr qs r s
If the rank of matrix A is N, then the rank
(D) 0 1 and 0 1
of matrix B is
(A) N (C) N
EE – 2013 (B) N (D) N
x
19. The equation 0 1 0x 1 0 1 has
IN – 2005
(A) No solution
x 1. Identify which one of the following is an
(B) Only one solution 0x 1 0 1.
Eigenvector of the matrix A = 0 1?
(C) Non – zero unique solution
(A) [ 1 1]T (C) [1 1]T
(D) Multiple solution (B) [3 1]T (D) [ 2 1]T
20. A matrix has Eigenvalues – 1 and – 2. The
2. Let A be a 3 3 matrix with rank 2. Then
corresponding Eigenvectors are 0 1 and AX = 0 has
(A) only the trivial solution X = 0
0 1 respectively. The matrix is
(B) one independent solution
(A) 0 1 (C) 0 1 (C) two independent solutions
(D) three independent solutions
(B) 0 1 (D) 0 1

EE – 2014 IN – 2006
21. Given a system of equations: Statement for Linked Answer Questions 3
x y z and 4
x y z A system of linear simultaneous
Which of the following is true regarding equations is given as Ax=B where
its solutions?
(A) The system has a unique solution for [ ] n [ ]
any given and
(B) The system will have infinitely many 3. The rank of matrix A is
solutions for any given and (A) 1 (C) 3
(C) Whether or not a solution exists (B) 2 (D) 4
depends on the given and
(D) The system would have no solution 4. Which of the following statements is true?
for any values of and (A) x is a null vector
(B) x is unique
22. Which one of the following statements is (C) x does not exist
true for all real symmetric matrices? (D) x has infinitely many values
(A) All the eigenvalues are real.
(B) All the eigenvalues are positive. 5. For a given matrix A, it is observed
(C) All the eigenvalues are distinct. that
(D) Sum of all the eigenvalues is zero.
0 1 0 1 n 0 1 0 1
Then matrix A is

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 11
GATE QUESTION BANK Mathematics

 2 1  1 0   1 1  10. Let P 0 be a 3 3 real matrix. There exist


(A) A      linearly independent vectors x and y such
1 1  0 2 1 2
that Px = 0 and Py = 0. The dimension of
1 1  1 0  2 1
(B) A     
the range space of P is
1 2 0 2 1 1 (A) 0 (C) 2
1 1  1 02 1 (B) 1 (D) 3
(C) A   
1 2  0 2 1 1 IN – 2010
0 2 11. X and Y are non-zero square matrices of
(D) A    size n n. If then
1 3
(A) |X| = 0 and |Y| 0
(B) |X| 0 and |Y| = 0
IN – 2007 (C) |X| = 0 and |Y| = 0
6. Let A = [ ] i j n with n n (D) |X| 0 and |Y| 0
= i. j. Then the rank of A is
(A) (C) n 12. A real n × n matrix A = [ ] is defined as
(B) (D) n i i j
follows: {
otherwise
7. Let A be an n×n real matrix such that The summation of all n Eigenvalues of A is
= I and y be an n- dimensional vector. (A) n(n )
Then the linear system of equations Ax=Y (B) n(n )
has ( )( )
(C)
(A) no solution
(D) n
(B) a unique solution
(C) more than one but finitely many IN – 2011
independent solutions
(D) Infinitely many independent 13. The matrix M = [ ] has
solutions
Eigenvalues . An Eigenvector
corresponding to the Eigenvalue 5 is
IN – 2009
, - . One of the Eigenvectors of
8. The matrix P =[ ] rotates a vector the matrix M is
(A) , - (C) , √ -
(B) , - (D) , -
about the axis[ ] by an angle of
IN – 2013
(A) (C) 14. The dimension of the null space of the
(B) (D)
matrix [ ] is
9. The Eigenvalues of a (2 2) matrix X are
2 and 3. The Eigenvalues of matrix (A) 0 (C) 2
( I) ( I) are (B) 1 (D) 3
(A) (C)
(B) (D) 15. One of Eigenvectors corresponding to the
two Eigenvalues of the matrix 0 1 is
j
(A) [ ] 0 1 (C) [ ] 0 1
j j
(B) 0 1 0 1 j
(D) [ ] 0 1
j
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 12
GATE QUESTION BANK Mathematics

IN – 2014
16. For the matrix A satisfying the equation
given below, the eigenvalues are

, -[ ] [ ]

(A) ( 𝑗,𝑗) (C) ( )


(B) (1,1,0) (D) (1,0,0)

Answer Keys and Explanations

ME
1. [Ans. A] and G = [ ]

Now E × F = G
[ ] os sin
∴ ,E- [ sin os ]
h r teristi equ tions is | I|
( )( )( )
4. [Ans. A]
∴ Real eigenvalues are 5, 5 other two are
For S matrix, if Eigenvalues are
complex
… … … … … then for matrix,
Eigenvector corresponding to
the Eigenvalues will be , , ………
is ( I)
For S matrix, if Eigenvalues are 1 and 5
(or) →( )
then for matrix, the Eigenvalues are 1
Verify the options which satisfies relation
and 25.
(1)
Option (A) satisfies.
5. [Ans. A]
2. [Ans. B]
6. [Ans. B]
Given n in onsistent
0 1 Eigenv lues re 2, 2

No ( I) ( I) . /
( ⁄ ) No. of L.I Eigenvectors
( ) n ( ⁄ ) (no of v ri les) ( I)
( ( ) minimum of m n)
For inconsistence
( ) ( ⁄ ) 7. [Ans. A]
∴ he highest possi le r nk of is ( I) .
olving for , Let the symmetric and real
3. [Ans. C] matrix be A = 0 1
os sin
Given , E = [ sin os ] Now | |
Which gives ( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 13
GATE QUESTION BANK Mathematics


x
Hence real Eigen value. [ ][ ] 0 1
x
8. [Ans. B]
Equating the elements x ⁄
Let 0 1 eigenv lues re n
Eigen vector corresponding to 12. [Ans. A]
is ( I) 0 1 → Eigenv lues re
x
. / .y/ . / Eigenve tor is x x verify the options
By simplifying
K 13. [Ans. C]
. / . / y t king K
Eigen vector corresponding to =2 [ ] [ ]
is ( I)
x
. / .y/ . / → [ ]
K
By simplifying ( ) 4 5 by
K ⁄ → [ ]
taking K
( ) infinite m ny solutions

14. [Ans. B]

Eigenvalues of a real symmetric matrix
9. [Ans. C] are always real
Sum of the diagonal elements = Sum of 15. [Ans. B]
the Eigenvalues
⟹ 1 + 0 + p = 3+S 0 1 eigenv lues v lue
⟹ S= p 2 Eigen vector will be . /
10. [Ans. B] Norm lize ve tor

( ⁄ ) [ ] √( ) ( )

[ ] [√( ) ( ) ]

→ * √ +
[ ] ⁄

→ [ ] 16. [Ans. C]
The given system is
If system will h ve solution x y z
x y z
11. [Ans. A] x y z
iven M M → MM I Use Gauss elimination method as follows
Augmented matrix is

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 14
GATE QUESTION BANK Mathematics

, | - [ | ] So, | |

→ [ | ] | |

(Taking 2 common from each row)


→ [ | ] ( )
nk ( )
nk ( | )
20. [Ans. D]
So, Rank (A) = Rank (A|B) = 2 < n (no. of
variables) 0 1 eigen v lues
So, we have infinite number of solutions Eigenve tor is verify for oth
n
17. [Ans. C]
Suppose the Eigenvalue of matrix A is
21. [Ans. D]
( i )(s y) and the Eigenvector is
We know that the Eigenvectors
‘x’ where s the onjug te p ir of
corresponding to distinct Eigenvalues of
Eigenvalue and Eigenvector is ̅ n x̅.
real symmetric matrix are orthogonal.
So Ax = x … ① x y
and x̅ ̅x̅……② x y
[ ][ ] x y x y x y
king tr nspose of equ tion ② x y
x̅ x̅ ̅ … ③
[( ) n ̅ is s l r ] 22. [Ans. D]
x̅ x x̅ x ̅ ( )
x̅ x x̅ ̅x … , - In case of matrix PQ QP (generally)
x̅ x x̅ ̅ x CE
(x̅ x) ̅ (x̅ x) ( ̅ re s l r )
1. [Ans. C]
̅
If = i.e. A is orthogonal, we can
( x x̅ re Eigenve tors they nnot e zero ) only s y th t if is n Eigenv lue of
i i
then also will be an Eigenvalue of A,
i 0
which does not necessarily imply that
| | = 1 for all i.
Hence Eigenvalue of a symmetric matrix
are real 2. [Ans. A]
18. [Ans. C] In an over determined system having
We know that more equations than variables, it is
os x os x sin x necessary to have consistent unique
( ) os x sin x ( ) os x solution, by definition
Hence 1, 1 and 1 are coefficients. They
3. [Ans. A]
are linearly dependent.
With the given order we can say that
19. [Ans. A] order of matrices are as follows:
 3×4
| | Y  4×3
 3×3

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 15
GATE QUESTION BANK Mathematics

( )  3×3 Using Gauss elimination we reduce this to


P 2×3 an upper triangular matrix to find its
 3×2 rank
P( )  (2×3) (3×3) (3×2)
[ | ]→ [ | ]
2×2
( ( ) )  2×2
→ [ | ]
4. [Ans. D]
The augmented matrix for given system is Now for infinite solution last row must be
completely zero
[ | ]→ [ | ] ie –2=0 n –7=0
 n
Then by Gauss elimination procedure

[ | ]→ [ | ] 8. [Ans. A]
Inverse of 0 1 is

→ [ | ] 0 1 0 1
( )
( ⁄ ) ∴0 1 0 1
( ) ( )
( ) ( ⁄ ) 0 1
∴ olution is non – existent for above
system.
9. [Ans. B]
( ) P=( )P
5. [Ans. B]
( )( )
∑ = Trace (A)
=( ) (I) =
+ + = Trace (A)
= 2 + ( 1) + 0 = 1
10. [Ans. B]
Now = 3
∴3+ + =1 A=0 1
 Characteristic equation of A is
Only choice (B) satisfies this condition.
| |=0

6. [Ans. B]  (4 )( 5 ) 2 × 5 =0
∑ = Trace (A)  + 30 = 0
+ + =1+5+1=7 6, 5
Now = 2, = 6
∴ 2+6+ =7 11. [Ans. D]
=3 The augmented matrix for given system is
x
7. [Ans. A] [ | ] 6y7 [ ]
k z
The augmented matrix for given system is
Using Gauss elimination we reduce this to
an upper triangular matrix to find its rank
[ | ]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 16
GATE QUESTION BANK Mathematics

17. [Ans. 16]


[ | ]→ M trix , - , - , -
k The product of matrix PQR is
→ , - , - , -
[ | ]
The minimum number of multiplications
involves in computing the matrix product
[ | ] PQR is 16
Now if k
18. [Ans. 23]
Rank (A) = rank (A|B) = 3
∴ Unique solution [ ][ ] [ ] [ ]
If k = 7, rank (A) = rank (A|B) = 2
which is less than number of variables
K JK , -[ ] , -
∴ When K = 7, unique solution is not
possible and only infinite solution is , -
possible 19. [Ans. A]
Sum of Eigenvalues
12. [Ans. A] = Sum of trace/main diagonal elements
A square matrix B is defined as skew- = 215 + 150 + 550
symmetric if and only if = B = 915

13. [Ans. D] 20. [Ans. 88]


By definition A + is always symmetric The determinant of matrix is
is symmetri
is lw ys skew symmetri [ ]
is skew symmetri

14. [Ans. B]
[ ]
0 1 =( )
0 1
i i →
∴ 0 1
i i
i i
0 1 [ ]
,( i)( i) i - i i
i i
= 0 1
i i →

15. [Ans. B] [ ]
0 1
Sum of the Eigenvalues = 17 Interchanging Column 1& Column 2 and
Product of the Eigenvalues = taking transpose
From options, 3.48 + 13.53 = 17
(3.48)(13.53) = 47 [ ]

16. [Ans. 0.5]


| |
0.5

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 17
GATE QUESTION BANK Mathematics

* ( ) ( )+ ( )( )
= ( )
= 1, 6
21. [Ans. 2] ∴ The Eigenvalues of A are 1 and 6
[ ]
3. [Ans. D]
→ Given that Fu =b and Fv =b
If F is non singular, then it has a unique
[ inverse.
( ) ( ) ( )
Now, u = b and v= b
] Since is unique, u = v but it is given
( ) ( ) th t u v his is contradiction. So F
must be singular. This means that
[ ] (A) Determinant of F is zero is true. Also
(B) There are infinite number of
( ) no. of non zero rows = 2
solution to Fx= b is true since |F| = 0
CS (C) here is n su h the is
1. [Ans. B] also true, since X has infinite number
The augmented matrix for the given of solutions., including the X = 0
solution
system is [ | ] (D) F must have 2 identical rows is false,
since a determinant may become
Using elementary transformation on above zero, even if two identical columns
matrix we get, are present. It is not necessary that 2
identical rows must be present for
[ | ]
|F| to become zero.

4. [Ans. C]
→ [ ⁄ | ] It is given that Eigenvalues of A is
⁄ ⁄ 5, 2, 1, 4
I
→ Let P = 0 1
[ | ] I
Eigenvalues of P : | I|
Rank ([A B]) = 3 I
| |
I
Rank ([A]) = 3
( ) I
Since
I
Rank ([A B]) = Rank ([A]) = number of I
variables, the system has unique solution. Eigenvalue of P is
( 5 +1 ), ( 2+ 1), (1+ 1), (4+1 ),
2. [Ans. B] ( 5 1 ), ( 2 1 ),(1 1), (4 1)
0 1 = 4, 1, 2, 5, 6, 3,0,3
The characteristic equation of this matrix
5. [Ans. B]
is given by |x
X= {x x x +
| I|
= ,x x x - then,
| |

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 18
GATE QUESTION BANK Mathematics

{ [1, 1, 0]T , [1,0, 1 ]T } is a linearly Only one matrix has an Eigenvalue of 1


independent set because one cannot be which is 0 1
obtained from another by scalar
Correct choice is (A)
multiplication. However (1, 1, 0) and
(1,0, 1) do not span X, since all such 8. [Ans. D]
combinations (x1, x2, x3) such that
x1+ x2+ x3 =0 cannot be expressed as | |
x y
linear combination of (1, 1,0) and ( )( y) x
(1,0, 1) When
( y) x
6. [Ans. D]
y x ( )
The augmented matrix for above system
When
is ( y) x
[ | ] → [ | ] y x ( )
x y
Solving (1) & (2)
→ [ | ] x y

Now as long as – 5 0, 9. [Ans. A]


rank (A) =rank (A|B) =3 The Eigenvalues of a upper triangular
∴ can be any real value except 5. Closest matrix are given by its diagonal entries.
correct answer is (D). ∴ Eigenvalues are 1, 4, 3 only

7. [Ans. A] 10. [Ans. D]


Eigenvalues of 0 1 0 1

| | =0 =0,1 Eigenvalues of the matrix (A) are the


roots of the characteristic polynomial
Eigenvalues of 0 1 given below.
| | =0 | |

=0 = 0, 0 ( )( )
( )( )
Eigenvalues of 0 1

| |= 0 √
( ) =0 Eigenvalues of A are √ n √
( ) respectively
= i or 1 So Eigenvalues of
= 1 –i or 1 + i (√ ) n ( √ )
Eigenvalues of 0 1 n
n
| | =0
√ n √
( )( ) =0
( ) =0
= –1, 1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 19
GATE QUESTION BANK Mathematics

11. [Ans. A] 15. [Ans. 6]


→ p q
Since 2 nd & 3rd columns have been
Let A =
swapped which introduces a –ve sign
Hence (A) is not equal to the problem [ ]
x
x
12. [Ans. 1]
Let X = x e eigen ve tor
x y x
x z [x ]
x y z By the definition of eigenvector, AX =
x y z x x
x x
x x
ugmente m trix is [ ] x x
[ ] [x ] [x ]
x x x
[ ] x x x x
x x x x
x x x x
→ →
x x x x x x x

n x x x x x x
(I) If s yx x
[ ] x x x
x x
→ → x x x
(2) If Eigenv lue
[ ] ∴ Three distinct eigenvalues are 0, 2, 3
Product of non zero eigenvalues = 2 × 3 = 6

16. [Ans. A]
If the trace or determinant of matrix is
[ ] positive then it is not necessary that all
eigenvalues are positive. So, option (B), (C),
( ) ( ) no of v ri les (D) are not correct
∴ nique solution exists
ECE
13. [Ans. 0] 1. [Ans. C]
The Eigenvectors corresponding to distinct Since, , -
Eigenvalues of real symmetric matrix are
2. [Ans. A]
orthogonal
We know, =I
14. [Ans. 0] 0 16 7=0 1
[ ]
0 1 0 1
| | ( ) b 1
,  a
Or 2a 0.1b=0,  2a 
10 60
1 1 21 7
 a+b =   
3 60 60 20
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 20
GATE QUESTION BANK Mathematics

3. [Ans. C] 8. [Ans. B]
0 1 Approach 1:
Given 4x + 2y =7
 (A I)=0 and 2x + y =6
 ( 4 ) (3 ) 2 4=0
4 2 x  7
 2 + 20=0  = 5, 4 2 1y   6
    
 x1 
Putting = 5, 0 1   =0 0 0 x  5
 x2  2 1y   6 
    
 x + 2x = 0 x = 2x
On comparing LHS and RHS
x x
 1= 2 0= 5, which is irrelevant and so no
2 1 solution.
Hence, 0 1 is Eigenvector. Approach 2:
4x + 2y =7
4. [Ans. C] 7
or 2x  y=
0 1 We know th t it is Eigenvalue 2
Then Eigenvector is x x 2x+y=6
Verify the options (C) Since both the linear equation represent
parallel set of straight lines, therefore no
5. [Ans. A] solution exists.
Approach 3:
or m trix 0 1 Rank (A)=1; rank (C)=2,
We know |I A|=0 As Rank (A) rank (C) therefore no
| | solution exists.

 2 –I2 +32 =0 9. [Ans. C]


 = 4, 8 (Eigenvalues) Matrix will be singular if any of the
For = 4, ( I )=0 Eigenvalues are zero.
1
|  |= 0
v =0 1 For = 0, P = 0
p p
For = 8, ( I )=0 1  |p p | =0
 p p p p
v =0 1
10. [Ans. D]
6. [Ans. C] Approach1: Eigenvalues exists as complex
conjugate or real
[ ] Approach 2: Eigenvalues are given by

| | =0
[ ]
( )(( ) )=0
( )
 , j j

7. [Ans. C] 11. [Ans. C]


There are M non-zero, orthogonal vectors, Eigenvalue of skew – symmetric matrix is
so there is required M dimension to either zero or pure imaginary.
represent them ’
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 21
GATE QUESTION BANK Mathematics

12. [Ans. B]
Given equations are x y z et of , - et of [ ]
x y z and x y z
If and ,
then x y z have Infinite solution
16. [Ans. D]
If and , then
Matrix multiplication is not commutative
x y z ( ) no solution
in general.
x y z
If n
17. [Ans. *] Range 0.99 to 1.01
x y z will have solution
Let ‘ ’ e Eigenv lue of ‘ ’ hen ‘ ’ will
x y z
e Eigenv lue of ‘ ’
and will also give solution
A. =I=
13. [Ans. B] Using Cauchey Hamilton Theorem,

0 1
Characteristic Equations is
18. [Ans. *] Range 0.99 to 1.01
By Cayley Hamilton theorem I J I J
I I

( I) | |
I
[ ]
14. [Ans. A]

[ ] 19. [Ans. *] Range 199 to 201


From matrix properties we know that the
→ ( ) determinant of the product is equal to the
product of the determinants.
[ ] | | That is if A and B are two matrix with
determinant | | n | | respectively,
| | Product of Eigenvalues = 0
then | | | | | |
∴ Minimum Eigenv lue h s to e ‘ ’
∴| | | | | |
15. [Ans. B]

Let , - [ ] 20. [Ans. B]



[ ] [ ]

I I [ ] → [ ]

( ) ( | ) no of v r les
Infinitely many solutions
Then AB = [4]; BA [ ]

21. [Ans. B]
Here m = 1, n = 4
And et(I ) et(I ) onsi er 0 1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 22
GATE QUESTION BANK Mathematics

whi h is re l symmetri m trix


h r teristi equ tion is | I| =[ ]
( )
∴ Top row of =, -

∴ (not positive)
2. [Ans. D]
( ) is not true
Since matrix is triangular, the Eigenvalues
(A), (C), (D) are true using properties of
are the diagonal elements themselves
Eigenvalues
namely  = 3, 2 & 1.
Corresponding to Eigenvalue  = 2, let
22. [Ans. *] Range 48.9 to 49.1
us find the Eigenvector
Real symmetric matrices are diagnosable
Let the matrix be [A - ] x̂ = 0
x x
0 1 s tr e is [ ][x ] [ ]
x
So determinant is product of diagonal x
entries Putting in above equation we get,
x
So | | x x
[ ][x ] [ ]
∴ M ximum v lue of etermin nt x
x x Which gives the equations,
∴| | 5x x x =0 . . . . . (i)
x =0 . . . . . (ii)
EE 3x = 0 . . . . . (iii)
1. [Ans. B] Since eqa (ii) and (iii) are same we have
5x x x =0 . . . . . (i)
R= [ ]
x =0 . . . . . (ii)
j( ) , of tor( )- Putting x = k, we get
x = 0, x = k and 5x k =0
| | | |
x = k
| |=| | ∴ Eigenvectorss are of the form
x k
= 1(2 + 3) – 0(4 + 2) – 1 (6 – 2) = 1
x
[ ] * k +
Since we need only the top row of , we x
need to find only first column of (R)
which after transpose will become first i.e. x x x = k : k : 0
row adj(A). = :1:0
cof. (1, 1) = + | |=2+3=5 =2:5:0
x
cof. (2, 1) = | |= 3 x
∴ [ ]=[ ] is an Eigenvector of matrix p.
x
cof. (2, 1) = + | |= +1
3. [Ans. A]
∴ cof. (A) = [ ] Rank [P|Q] = Rank [P] is necessary for
existence of at least one solution to
Adj (A) =, of ( )-
x q.
=[ ]

Dividing by |R| = 1 gives


th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 23
GATE QUESTION BANK Mathematics

4. [Ans. A] 
We need to find orthogonal vectors, verify  ( )
the options. i i
Option (A) is orthogonal vectors
8. [Ans. B]
( )( ) xy xy xx x n xy yx
xx xy x xy
Option (B), (C), (D) are not orthogonal | yx y y | |y x y |
x y (x y)
5. [Ans. B]
The vector ( ) is linearly = Positive when x and y are linearly
dependent upon the solution obtained in independent.
Q. No. 4 namely , - and , - 9. [Ans. A]
We can easily verify the linearly
A=0 1
dependence as
|A – | = 0
| | 
| | =0

A will satisfy this equation according to
6. [Ans. B] Cayley Hamilton theorem
hen n n m trix xx i.e. I=0
x x x x x x Multiplying by on oth si es we get
x x x x x x
* + I=0
x x x x x x I =0
Take x common from 1st row,
x common from 2nd row …… 10. [Ans. A]
x common from nth row. To calculate
It h s r nk ‘ ’ Start from I = 0 which has
derived above
7. [Ans. D] I

k
L(x) = | | ( I)( I)
x x x I
= (x ) ( ) ⃗(
k x ) ( I) I
x I
= x ⃗ =[
x k ]
x ( I)( I)
x
I
L(x) = M [x ]
x ( I) I
Comparing both , we get, I

M=[ ] ( I)

Hence Eigenvalue of M : | M | ( I)
I
| |

 ( ) ( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 24
GATE QUESTION BANK Mathematics

11. [Ans. A] x
If rank of (5 6 ) matrix is 4,then surely x
* + *x + * +
it must have exactly 4 linearly x
independent rows as well as 4 linearly
independent columns.
Argument matrix C =* +

12. [Ans. D]
If characteristic equation is
→ , * +
   =0
Then by Cayley – Hamilton theorem,
I=0 nk ( ) nk( )
= Number of variables = 4
Multiplying by on both sides, Since, Rank (A) = Rank(C) < Number of
variables
= I = ( I)
Hence, system of equations are consistent
and there is multiple non-trivial solution
13. [Ans. D]
exists.
Choice (A) = A is correct
Since =A[( ) -A
17. [Ans. B]
= A[( ) -
Characteristic equation | I|
Put =P
Then A [ ] = A. = A | |
Choice (C) =  is also correct since
=( )  (1 ) ( )( )
= I 
Eigenve tors orrespon ing to is
14. [Ans. B] ( I)
Let orthogonal matrix be x
os in [ ] [x ] [ ]
P=0 1 x
in os
By Property of orthogonal matrix A 2x x  x x
I At x x
x os x in x x  x x
So, x⃗ = [ ]
x in x os At x ,x
|| x⃗ || =
Eigenvectors = c[ ]{Here c is a constant}
√(x os x in ) (x in x os )

|| x⃗ || = √x x 18. [Ans. D]
, - ,L-, - ⟹ Options D is correct
|| x⃗ || = || x̅|| for any vector x̅
19. [Ans. D]
15. [Ans. C] x x … (i)
Trace = Sum of Principle diagonal } (i) n (ii) re s me
x x … (ii)
elements. ∴x x
So it has multiple solutions.
16. [Ans. D]
On writing the equation in the form of
AX =B

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 25
GATE QUESTION BANK Mathematics

20. [Ans. D] |A I|= | |


Eigen value
i.e., (1 ) (2 )
2
Eigenvectors 0 1 n 0 1 Thus the Eigenvalue are 1, 2.
Let matrix 0 1 If x, y, be the component of Eigenvectors
corresponding to the Eigenv lues we
x x
have
0 10 1 0 1 x
[A- I- 0 1 0y1=0
0 10 1 0 1
For =1, we get the Eigenvector as 0 1
Hence, the answer will be , -

2. [Ans. B]
AX=0 and (A) = 2
Solving
n=3
0 1 0 1 No. of linearly independent solutions
= n r
21. [Ans. B] = 3
Since there are 2 equations and 3 variables =1
(unknowns), there will be infinitely many
solutions. If if then 3. [Ans. C]
x y z x y z x z y There are 3 non-zero rows and hence
For any x and z, there will be a value of y. rank (A) = 3
∴ Infinitely many solutions
4. [Ans. C]
22. [Ans. A] Rank (A) = 3 (This is Co-efficient matrix)
For all real symmetric matrices, the Rank (A:b) =4(This is Augmented matrix)
Eigenvalues are real (property), they may s r nk( ) r nk ( ) olution oes
be either ve or ve and also may be same. not exist.
The sum of Eigenvalues necessarily not be
zero.
5. [Ans. C]
We know Hen e from the given
23. [Ans. C]
p q problem, Eigenvalue & Eigenvector is
0 1 known.
r s
( pplying → p q 1 1
→r s element ry tr nsform tions) X1    , X2  2 , 1  1, 2  2
p q pr qs 1  
[ ] We also know that , where
pr qs r s
∴ hey h ve s me r nk N 1 1
P  X1 X2    
1 2
IN
1 0  1 0 
1. [Ans. B] & D=   
 0 2   0 2
Given: 0 1
Hence
Characteristic equation is,

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 26
GATE QUESTION BANK Mathematics

 1 1  1 0   2 1  12. [Ans. A]


A       A=[ ]
1 2  0 2 1 1
i if i j
6. [Ans. B] = 0 otherwise.
For n n matrix
A= [ ]=[ ]
A=[ ]
Using elementary transformation
n
[ ] For diagonal matrix Eigenvalues are
diagonal elements itself.
Hence, rank (A) =1 n(n )
∴ n
7. [Ans. B]
Given I 13. [Ans. B]
Hence rank (A) = n If AX = →
Hence AX= Y will have unique solution From this result [1, 2, - is also vector
for M
8. [Ans. C]
14. [Ans. B]
9. [Ans. C] Dim of null space [A]= nullity of A.
Approach 1:
For given A = [ ]
Assume, 0 1 I 0 1
∴A ( I) ( I) Apply row operations

0 1 0 1 [ ]

0 10 1 0 1
→ [ ]
Now | I |
| |
→ [ ]
( )( )=0
∴ ( )
Approach 2: By rank – nullity theorem
Eigenvalues of ( I) is = 1, 1/2 Rank [A]+ nullity [A]= no. of columns[A]
Eigenvalues of (X+5I) is = 3, 2 Nullity [A]= 3
Eigenvalues of ( I) (X+5I) is = , ∴ Nullity , -

10. [Ans. D] 15. [Ans. A]


A=| |
11. [Ans. C]
A null matrix can be obtained by Characteristics equation | I|
multiplying either with one null matrix or | |
two singular matrices.
j
j

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 27
GATE QUESTION BANK Mathematics

j x
[ ] 0x 1 0 1
j
x
x j
j
j x
[ ] 0x 1 0 1
j
x j
x

16. [Ans. C]

A[ ]=[ ]

→| | | | | |

→| |

( | |

| | two rows ounter lose thus | |

| |)

=Product of eigenvalues
Verify options
Options (C) correct answer

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 28
GATE QUESTION BANK Mathematics

Probability and Distribution

ME - 2005 ME - 2008
1. A single die is thrown twice. What is the 6. A coin is tossed 4 times. What is the
probability that the sum is neither 8 nor probability of getting heads exactly 3
9? times?
(A) ⁄ (C) ⁄ (A) ⁄ (C) ⁄
(B) ⁄ (D) ⁄ (B) ⁄ (D) ⁄

2. A lot has 10% defective items. Ten items ME - 2009


are chosen randomly from this lot. The 7. The standard deviation of a uniformly
probability that exactly 2 of the chosen distributed random variable between 0
items are defective is and 1 is
(A) 0.0036 (C) 0.2234 (A) √ (C) ⁄√
(B) 0.1937 (D) 0.3874 (B) √ (D) √
ME - 2006 8. If three coins are tossed simultaneously,
3. Consider a continuous random variable the probability of getting at least one head
with probability density function is
f(t) = 1 + t for 1  t  0 (A) 1/8 (C) 1/2
= 1 t for 0  t  1 (B) 3/8 (D) 7/8
The standard deviation of the random
ME - 2010
variable is:
9. A box contains 2 washers, 3 nuts and 4
(A) ⁄√ (C) ⁄
bolts. Items are drawn from the box at
(B) ⁄√ (D) ⁄
random one at a time without
4. A box contains 20 defective items and 80 replacement. The probability of drawing
non-defective items. If two items are 2 washers first followed by 3 nuts and
selected at random without replacement, subsequently the 4 bolts is
what will be the probability that both (A) 2/315 (C) 1/1260
items are defective? (B) 1/630 (D) 1/2520
(A) ⁄ (C) ⁄ ME - 2011
(B) ⁄ (D) ⁄ 10. An unbiased coin is tossed five times. The
ME - 2007 outcome of each toss is either a head or a
5. Let X and Y be two independent random tail. The probability of getting at least one
variables. Which one of the relations head is________
between expectation (E), variance (Var) (A) ⁄ (C) ⁄
(B) ⁄ (D) ⁄
and covariance (Cov) given below is
FALSE? ME - 2012
(A) E (XY) = E (X) E (Y) 11. A box contains 4 red balls and 6 black
(B) Cov (X, Y) = 0 balls. Three balls are selected randomly
(C) Var (X + Y) = Var (X) + Var (Y) from the box one after another, without
(D) (X Y ) ( (X)) ( (Y)) replacement. The probability that the
selected set has one red ball and two
black balls is
(A) 1/20 (C) 3/10
(B) 1/12 (D) 1/2
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 29
GATE QUESTION BANK Mathematics

ME - 2013 the probability of obtaining red colour on


12. Let X be a normal random variable with top face of the dice at least twice is _______
mean 1 and variance 4. The probability
(X ) is 17. A group consists of equal number of men
(A) 0.5 and women. Of this group 20% of the men
(B) Greater than zero and less than 0.5 and 50% of the women are unemployed.
(C) Greater than 0.5 and less than 1.0 If a person is selected at random from this
(D) 1.0 group, the probability of the selected
person being employed is _______
13. The probability that a student knows the
correct answer to a multiple choice 18. A machine produces 0, 1 or 2 defective
question is . If the student dose not know pieces in a day with associated
probability of 1/6, 2/3 and 1/6,
the answer, then the student guesses the
respectively. The mean value and the
answer. The probability of the guessed
variance of the number of defective pieces
answer being correct is . Given that the
produced by the machine in a day,
student has answered the questions respectively, are
correctly, the conditional probability that (A) 1 and 1/3 (C) 1 and 4/3
the student knows the correct answer is (B) 1/3 and 1 (D) 1/3 and 4/3
(A) ⁄ (C) ⁄
(B) ⁄ (D) ⁄ 19. A nationalized bank has found that the
daily balance available in its savings
ME - 2014 accounts follows a normal distribution
14. In the following table x is a discrete with a mean of Rs. 500 and a standard
random variable and P(x) is the deviation of Rs. 50. The percentage of
probability density. The standard savings account holders, who maintain an
deviation of x is average daily balance more than Rs. 500
x 1 2 3 is _______
P(x) 0.3 0.6 0.1
(A) 0.18 (C) 0.54 20. The number of accidents occurring in a
(B) 0.3 (D) 0.6 plant in a month follows Poisson
distribution with mean as 5.2. The
15. Box contains 25 parts of which 10 are probability of occurrence of less than 2
defective. Two parts are being drawn accidents in the plant during a randomly
simultaneously in a random manner from selected month is
the box. The probability of both the parts
(A) 0.029 (C) 0.039
being good is (B) 0.034 (D) 0.044
( ) ( )
CE - 2005
( ) ( ) 1. Which one of the following statements is
NOT true?
16. Consider an unbiased cubic dice with (A) The measure of skewness is
opposite faces coloured identically and dependent upon the amount of
each face coloured red, blue or green such dispersion
that each colour appears only two times
on the dice. If the dice is thrown thrice,

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 30
GATE QUESTION BANK Mathematics

(B) In a symmetric distribution the value CE - 2008


of mean, mode and median are the 5. If probability density function of a random
same variable x is
(C) In a positively skewed distribution x for x nd
f(x) {
mean > median > mode for ny other v lue of x
(D) In a negatively skewed distribution Then, the percentage probability
mode > mean > median P. x / is
(A) 0.247 (C) 24.7
CE - 2006 (B) 2.47 (D) 247
2. A class of first years B. Tech students is
composed of four batches A, B, C and D 6. A person on a trip has a choice between
each consisting of 30 students. It is found private car and public transport. The
that the sessional marks of students in probability of using a private car is 0.45.
Engineering Drawing in batch C have a While using the public transport, further
mean of 6.6 and standard deviation of 2.3. choices available are bus and metro out of
The mean and standard deviation of the which the probability of commuting by a
marks for the entire class are 5.5 and 4.2 bus is 0.55. In such a situation, the
respectively. It is decided by the course probability, (rounded upto two decimals)
instruction to normalize the marks of the of using a car, bus and metro, respectively
students of all batches to have the same would be
mean and standard deviation as that of (A) 0.45, 0.30 and 0.25
the entire class. Due to this, the marks of a (B) 0.45, 0.25 and 0.30
student in batch C are changed from 8.5 (C) 0.45, 0.55 and 0.00
to (D) 0.45, 0.35 and 0.20
(A) 6.0 (C) 8.0
(B) 7.0 (D) 9.0 CE - 2009
7. The standard normal probability function
3. There are 25 calculators in a box. Two of can be approximated as
them are defective. Suppose 5 calculators
are randomly picked for inspection (i.e. (x )
exp( |x | )
each has the same chance of being Where x = standard normal deviate. If
selected). What is the probability that mean and standard deviation of annual
only one of the defective calculators will precipitation are 102 cm and 27 cm
be included in the inspection? respectively, the probability that the
(A) ⁄ (C) ⁄ annual precipitation will be between
(B) ⁄ (D) ⁄
90 cm and 102 cm is
(A) 66.7% (C) 33.3%
CE - 2007
(B) 50.0% (D) 16.7%
4. If the standard deviation of the spot speed
of vehicles in a highway is 8.8 kmph and CE - 2010
the mean speed of the vehicles is 8. Two coins are simultaneously tossed. The
33 kmph, the coefficient of variation in probability of two heads simultaneously
speed is appearing is
(A) 0.1517 (C) 0.2666 (A) 1/8 (C) 1/4
(B) 0.1867 (D) 0.3646 (B) 1/6 (D) 1/2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 31
GATE QUESTION BANK Mathematics

CE - 2011 14. A traffic office imposes on an average 5


9. There are two containers with one number of penalties daily on traffic
containing 4 red and 3 green balls and the violators. Assume that the number of
other containing 3 blue and 4 green balls. penalties on different days is independent
One ball is drawn at random from each and follows a poisson distribution. The
container. The probability that one of the probability that there will be less than 4
balls is red and the other is blue will be penalties in a day is ____.
(A) 1/7 (C) 12/49
(B) 9/49 (D) 3/7 15. A fair (unbiased) coin was tossed four
times in succession and resulted in the
CE - 2012 following outcomes:
10. The annual precipitation data of a city is (i) Head (iii) Head
normally distributed with mean and (ii) Head (iv) Head
standard deviation as 1000mm and The prob bility of obt ining ‘T il’ when
200 mm, respectively. The probability the coin is tossed again is
that the annual precipitation will be more (A) 0 (C) ⁄
than 1200 mm is (B) ⁄ (D) ⁄
(A) < 50 % (C) 75 %
(B) 50 % (D) 100 % 16. An observer counts 240 veh/h at a
specific highway location. Assume that
11. In an experiment, positive and negative the vehicle arrival at the location is
values are equally likely to occur. The Poisson distributed, the probability of
probability of obtaining at most one having one vehicle arriving over a
negative value in five trials is 30-second time interval is ____________
(A) (C)
CS - 2005
(B) (D)
1. Box P has 2 red balls and 3 blue balls and
box Q has 3 red balls and 1 blue ball. A
CE - 2013
ball is selected as follows: (i) select a box
12. Find the value of such that the function
(ii) choose a ball from the selected box
f(x) is a valid probability density function
such that each ball in the box is equally
____________________
likely to be chosen. The probabilities of
f(x) (x )( x) for x
otherwise selecting boxes P and Q are 1/3 and 2/3
respectively. Given that a ball selected in
CE - 2014 the above process is red, the probability
13. The probability density function of that it comes from box P is
evaporation E on any day during a year in (A) 4/19 (C) 2/9
a watershed is given by (B) 5/19 (D) 19/30

f( ) { mm d y 2. Let f(x) be the continuous probability


otherwise density function of a random variable X.
The probability that E lies in between 2 The probability that a  X  b , is
and 4 mm/day in a day in the watershed (A) f(b a) (C) ∫ f(x)dx
is (in decimal) ______
(B) f(b) f( ) (D) ∫ x f(x)dx

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 32
GATE QUESTION BANK Mathematics

CS - 2006 CS - 2008
3. For each element in a set of size 2n, an 7. Let X be a random variable following
unbiased coin is tossed. The 2n coin normal distribution with mean +1 and
tosses are independent. An element is variance 4. Let Y be another normal
chosen if the corresponding coin toss variable with mean of 1 and variance
were head. The probability that exactly n unknown If (X ) (Y≥ ) the
elements are chosen is standard deviation of Y is
(A) ( n ⁄ ) (C) ( ⁄ n ) (A) 3 (C) √
(B) ( n ⁄ ) (D) ⁄ (B) 2 (D) 1

8. Aishwarya studies either computer


CS - 2007
science or mathematics every day. If she
Linked Data for Q4 & Q5 are given below.
studies computer science on a day, then
Solve the problems and choose the correct
the probability that she studies
answers.
mathematics the next day is 0.6. If she
Suppose that robot is placed on the
studies mathematics on a day, then the
Cartesian plane. At each step it is easy to
probability that she studies computer
move either one unit up or one unit right,
science the next day is 0.4. Given that
i.e if it is at (i,j) then it can move to either
Aishwarya studies computer science on
(i+1,j) or (i,j+1)
Monday, what is the probability that she
4. How many distinct paths are there for the
studies computer science on Wednesday?
robot to reach the point (10,10) starting
(A) 0.24 (C) 0.4
from the initial position (0,0)? (B) 0.36 (D) 0.6
(A) (C) 210
(B) 2 20 (D) None of these CS - 2009
9. An unbalanced dice (with 6 faces,
5. Suppose that the robot is not allowed to
numbered from 1 to 6) is thrown. The
traverse the line segment from (4,4) to
probability that the face value is odd is
(5,4). With this constraint, how many
90% of the probability that the face value
distinct paths are there for the robot to
is even. The probability of getting any
reach (10,10) starting from (0,0)?
even numbered face is the same. If the
(A) 29
probability that the face is even given that
(B) 219
it is greater than 3 is 0.75, which one of
(C) . / . / the following options is closest to the
probability that the face value exceeds 3?
(D) . / . / . /
(A) 0.453 (C) 0.485
6. Suppose we uniformly and randomly (B) 0.468 (D) 0.492
select a permutation from the 20! CS - 2010
ermut tions of ………… Wh t is 10. Consider a company that assembles
the probability that 2 appears at an computers. The probability of a faulty
earlier position than any other even assembly of any computer is p. The
number in the selected permutation? company therefore subjects each
(A) ⁄ (C) ⁄ computer to a testing process. This
(B) ⁄ (D) none of these testing process gives the correct result for
any computer with a probability of q.
What is the probability of a computer
being declared faulty?
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 33
GATE QUESTION BANK Mathematics

(A) pq+(1 – p)(1 – q) 15. If two fair coins flipped and at least one of
(B) (1 – q)p the outcomes is known to be a head, what
(C) (1 – p)q is the probability that both outcomes are
(D) pq heads?
(A) 1/3 (C) 1/4
11. What is the probability that a divisor of (B) 1/2 (D) 2/3
is a multiple of ?
(A) 1/625 (C) 12/625 CS - 2012
(B) 4/625 (D) 16/625 16. Suppose a fair six – sided die is rolled
once. If the value on the die is 1,2, or 3 the
12. If the difference between the expectation
die is rolled a second time. What is the
of the square if a random variable ( ,x -)
probability that the some total of value
and the square if the exopectation of the
that turn up is at least 6?
random variable ( ,x-) is denoted by R,
(A) 10/21 (C) 2/3
then (B) 5/12 (D) 1/6
(A) R = 0 (C) R≥
(B) R< 0 (D) R > 0 17. Consider a random variable X that takes
CS - 2011 values +1 and 1 with probability 0.5
13. A deck of 5 cards (each carrying a distinct each. The values of the cumulative
number from 1 to 5) is shuffled distribution function F(x) at x = and
thoroughly. Two cards are then removed +1 are
one at a time from the deck. What is the (A) 0 and 0.5 (C) 0.5 and 1
probability that the two cards are (B) 0 and 1 (D) 0.25 and 0.75
selected with the number on the first card
CS - 2013
being one higher than the number on the
18. Suppose p is the number of cars per
second card?
minute passing through a certain road
(A) ⁄ (C) ⁄
junction between 5 PM and 6 PM, and p
(B) ⁄ (D) ⁄
has a Poisson distribution with mean 3.
14. Consider a finite sequence of random What is the probability of observing
values X = [x1, x2 … xn].Let be the fewer than 3 cars during any given
me n nd σx be the standard deviation of minute in this interval?
X. Let another finite sequence Y of equal (A) ⁄ e (C) ⁄ e
length be derived from this as yi, a*xi+b, (B) ⁄ e (D) ⁄ e
where a and b are positive constants. Let
μy be the me n nd σy be the standard CS - 2014
deviation of this sequence. Which one of 19. Suppose you break a stick of unit length
the following statements is INCORRECT? at a point chosen uniformly at random.
(A) Index position of mode of X in X is Then the expected length of the shorter
the same as the index position of stick is ________ .
mode of Y in Y.
(B) Index position of median of X in X is 20. Four fair six – sided dice are rolled. The
the same as the index position of probability that the sum of the results
median of Y in Y. being 22 is x/1296. The value of x is
(C) μy μx + b ____________
(D) σy σx + b

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 34
GATE QUESTION BANK Mathematics

21. The security system at an IT office is ECE - 2006


composed of 10 computers of which 3. A probability density function is of the
exactly four are working. To check form (x) e || x ( ).
whether the system is functional, the The value of K is
officials inspect four of the computers (A) 0.5 (C) 0.5a
picked at random (without replacement). (B) 1 (D) A
The system is deemed functional if at
least three of the four computers 4. Three Companies X, Y and Z supply
inspected are working. Let the computers to a university. The percentage
probability that the system is deemed of computers supplied by them and the
functional be denoted by p. Then 100p = probability of those being defective are
_____________. tabulated below
Company % of Probability
22. Each of the nine words in the sentence computers of being
“The quick brown fox jumps over the l zy supplied defective
dog” is written on sep r te piece of X 60% 0.01
paper. These nine pieces of paper are kept Y 30% 0.02
in a box. One of the pieces is drawn at Z 10% 0.03
random from the box. The expected Given that a computer is defective, the
length of the word drawn is _____________. probability that it was supplied by Y is
(The answer should be rounded to one (A) 0.1 (C) 0.3
decimal place.) (B) 0.2 (D) 0.4

23. The probability that a given positive


ECE - 2007
integer lying between 1 and 100 (both
5. If E denotes expectation, the variance of a
inclusive) is NOT divisible by 2, 3 or 5 is
random variable X is given by
__________.
(A) E[X2] E2[X] (C) E[X2]
(B) E[X2] + E2[X] (D) E2[X]
24. Let S be a sample space and two mutually
exclusive events A and B be such that
6. An examination consists of two papers,
∪ S If ( ) denotes the prob bility
Paper1 and Paper2. The probability of
of the event, the maximum value of
failing in Paper1 is 0.3 and that in Paper2
P(A) P(B) is _______
is 0.2.Given that a student has failed in
ECE - 2005 Paper2, the probability of failing in
1. A fair dice is rolled twice. The probability paper1 is 0.6. The probability of a student
that an odd number will follow an even failing in both the papers is
number is (A) 0.5 (C) 0.12
(B) 0.18 (D) 0.06
( ) ( )

( ) ( )

2. The value of the integral


1   x2 
2 0
I exp  dx is
 8
(A) 1 (C) 2
(B) (D)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 35
GATE QUESTION BANK Mathematics

ECE - 2008 8. (x) exp( |x|) exp( |x|) is


7. The probability density function (PDF) of the probability density function for the
a random variable X is as shown below. real random variable X, over the entire x
PDF axis. M and N are both positive real
1 PDF
numbers. The equation relating M and N
is
(A) 1
1 0 x (B) 2M N=1
11
The -1
corresponding
0
cumulative (C) M + N = 1
distribution function (CDF) has the form (D) M + N = 3

CDF ECE - 2009


(A)
1 9. Consider two independent random
variables X and Y with identical
x distributions. The variables X and Y take
value 0, 1 and 2 with probabilities
and respectively. What is the
1 0 1 x conditional probability
(x y |x y| )
(B) 1 CD
C
F (A) 0 (C) ⁄
D
F (B) ⁄ (D) 1
1

10. A fair coin is tossed 10 times. What is the


probability that ONLY the first two tosses
will yield heads?
1 0
1 x 2 10
1 1
(A)   (C)  
-1 0 CDF 1  2  2
(C) 1 0 2 10
10 1 10 1
(B) C2   (D) C2  
 2  2

11. A discrete random variable X takes values


x from 1 to 5 with probabilities as shown in
0 1 the table. A student calculates the mean of
1
X as 3.5 and her teacher calculates the
variance of X as 1.5. Which of the
(D) CDF following statements is true?
1
k P(X=k)
1
1 0.1
0 1 x 2 0.2
1
0 1 3 0.4
1 4 0.2
5 0.1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 36
GATE QUESTION BANK Mathematics

(A) Both the student and the teacher are (C) ( (x) (x)) x
right (D) ( (x) (x)) x ≥
(B) Both the student and the teacher are
wrong ECE - 2014
(C) The student is wrong but the teacher 17. In a housing society, half of the families
is right have a single child per family, while the
(D) The student is right but the teacher is remaining half have two children per
wrong family. The probability that a child picked
at random, has a sibling is _____
ECE - 2010
12. A fair coin is tossed independently four 18. Let X X nd X , be independent and
times. The prob bility of the event “the identically distributed random variables
number of times heads show up is more with the uniform distribution on [0, 1].
th n the number of times t ils show up” is The probability P{X is the largest} is _____
(A) ⁄ (C) ⁄
(B) ⁄ (D) ⁄
19. Let X be a random variable which is
uniformly chosen from the set of positive
ECE - 2011
odd numbers less than 100. The
13. A fair dice is tossed two times. The
expectation, E[X], is __________.
probability that the second toss results in
a value that is higher than the first toss is
20. An unbiased coin is tossed an infinite
(A) 2/36 (C) 5/12
number of times. The probability that the
(B) 2/6 (D) 1/2
fourth head appears at the tenth toss is
(A) 0.067 (C) 0.082
ECE\EE\IN - 2012
(B) 0.073 (D) 0.091
14. A fair coin is tossed till a head appears for
the first time probability that the number 21. A fair coin is tossed repeatedly till both
of required tosses is odd , is head and tail appear at least once. The
(A) 1/3 (C) 2/3 average number of tosses required is
(B) 1/2 (D) 3/4 _______.

ECE - 2013 22. Let X X and X be independent and


15. Let U and V be two independent zero identically distributed random variables
mean Gaussian random variables of with the uniform distribution on [0, 1].
variances ⁄ and ⁄ respectively. The The probability P{X X X } is ______.
probability ( V ≥ U) is
23. Let X be a zero mean unit variance
(A) 4/9 (C) 2/3
Gaussian random variable. ,|x|- is equal
(B) 1/2 (D) 5/9
to __________
16. Consider two identically distributed zero-
24. Parcels from sender S to receiver R pass
mean random variables U and V . Let the
sequentially through two post-offices.
cumulative distribution functions of U
Each post-office has a probability of
and 2V be F(x) and G(x) respectively.
Then, for all values of x losing an incoming parcel, independently
(A) ( (x) (x)) of all other parcels. Given that a parcel is
lost, the probability that it was lost by the
(B) ( (x) (x)) ≥
second post-office is ____________.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 37
GATE QUESTION BANK Mathematics

EE - 2005 EE - 2008
1. If P and Q are two random events, then 5. X is a uniformly distributed random
the following is TRUE variable that takes values between 0 and
(A) Independence of P and Q implies that 1. The value of E{X } will be
probability (P Q) = 0 (A) 0 (C) 1/4
(B) Probability (P ∪ Q)≥ Probability (P) (B) 1/8 (D) 1/2
+Probability (Q)
EE - 2009
(C) If P and Q are mutually exclusive,
6. Assume for simplicity that N people, all
then they must be independent
born in April (a month of 30 days), are
(D) Probability (P Q) Probability (P)
collected in a room. Consider the event of
2. A fair coin is tossed three times in atleast two people in the room being born
succession. If the first toss produces a on the same date of the month, even if in
head, then the probability of getting different years, e.g. 1980 and 1985. What
exactly two heads in three tosses is is the smallest N so that the probability of
(A) ⁄ (C) ⁄ this event exceeds 0.5?
(B) ⁄ (D) ⁄ (A) 20 (C) 15
(B) 7 (D) 16
EE - 2006
3. Two f ir dice re rolled nd the sum “ r ” EE - 2010
of the numbers turned up is considered 7. A box contains 4 white balls and 3 red
(A) Pr (r > 6) = balls. In succession, two balls are
randomly selected and removed from the
(B) Pr (r/3 is an integer) = box. Given that the first removed ball is
(C) Pr (r = 8|r/4 is an integer) = white, the probability that the second
removed ball is red is
(D) Pr (r = 6|r/5 is an integer) =
(A) 1/3 (C) 1/2
(B) 3/7 (D) 4/7
EE - 2007
4. A loaded dice has following probability ECE\EE\IN - 2012
distribution of occurrences 8. Two independent random variables X and
Dice Value Probability Y are uniformly distributed in the interval
1 ⁄ , -. The probability that max , - is
2 ⁄ less than 1/2 is
3 ⁄ (A) 3/4 (C) 1/4
(B) 9/16 (D) 2/3
4 ⁄
5 ⁄ EE - 2013
6 ⁄ 9. A continuous random variable x has a
If three identical dice as the above are probability density function
thrown, the probability of occurrence of f(x) e x . Then *x + is
values, 1, 5 and 6 on the three dice is (A) 0.368 (C) 0.632
(A) same as that of occurrence of 3, 4, 5 (B) 0.5 (D) 1.0
(B) same as that of occurrence of 1, 2, 5
(C) 1/128
(D) 5/8

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 38
GATE QUESTION BANK Mathematics

EE - 2014 IN - 2005
10. A fair coin is tossed n times. The 1. The probability that there are 53 Sundays
probability that the difference between in a randomly chosen leap year is
the number of heads and tails is (n – 3) is (A) ⁄ (C) ⁄
(A) (C) (B) ⁄ (D) ⁄
(B) (D)
2. A mass of 10 kg is measured with an
11. Consider a dice with the property that the instrument and the readings are normally
probability of a face with n dots showing distributed with respect to the mean of
up is proportional to n. The probability of 10 kg. Given that
the face with three dots showing up is ∫ exp . / d =0.6

_______________ and that 60per cent of the readings are
found to be within 0.05 kg from the mean,
12. Let x be a random variable with
the standard deviation of the data is
probability density function
(A) 0.02 (C) 0.06
for |x| (B) 0.04 (D) 0.08
f(x) { for |x|
otherwise 3. The measurements of a source voltage are
The probability P(0.5 < x < 5) is_________ 5.9V, 5.7V and 6.1V. The sample standard
deviation of the readings is
13. Lifetime of an electric bulb is a random (A) 0.013 (C) 0.115
variable with density f(x) kx , where x (B) 0.04 (D) 0.2
is measured in years. If the minimum and
maximum lifetimes of bulb are 1 and 2 IN - 2006
years respectively, then the value of k 4. You have gone to a cyber-cafe with a
is__________ friend. You found that the cyber-café has
only three terminals. All terminals are
14. The mean thickness and variance of unoccupied. You and your friend have to
silicon steel laminations are 0.2 mm and make a random choice of selecting a
0.02 respectively. The varnish insulation terminal. What is the probability that
is applied on both the sides of the both of you will NOT select the same
laminations. The mean thickness of one terminal?
side insulation and its variance are (A) ⁄ (C) ⁄
0.1 mm and 0.01 respectively. If the (B) ⁄ (D) 1
transformer core is made using 100 such
5. Probability density function p(x) of a
varnish coated laminations, the mean
random variable x is as shown below. The
thickness and variance of the core
value of  is
respectively are
p(x)
(A) 30 mm and 0.22
(B) 30 mm and 2.44
(C) 40 mm and 2.44 α
(D) 40 mm and 0.24

0 α α b α c

(A) c (C)
( )
(B) c (D)
( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 39
GATE QUESTION BANK Mathematics

6. Two dices are rolled simultaneously. The measurements, it can be expected that the
probability that the sum of digits on the number of measurement more than 10.15
top surface of the two dices is even is mm will be
(A) 0.5 (C) 0.167 (A) 230 (C) 15
(B) 0.25 (D) 0.125 (B) 115 (D) 2

IN - 2007 IN - 2011
7. Assume that the duration in minutes of a 12. The box 1 contains chips numbered 3, 6,
telephone conversation follows the 9, 12 and 15. The box 2 contains chips
exponential distribution f(x) = e ,x≥ numbered 6, 11, 16, 21 and 26. Two chips,
one from each box, are drawn at random.
The probability that the conversation will
The numbers written on these chips are
exceed five minutes is
multiplied. The probability for the
(A) e (C) product to be an even number is
(B) e
(D) e (A) ⁄ (C) ⁄
(B) ⁄ (D) ⁄
IN - 2008
8. Consider a Gaussian distributed random IN - 2013
variable with zero mean and standard 13. A continuous random variable X has
deviation . The value of its cummulative probability density f(x) = .
distribution function at the origin will be Then P(X > 1) is
(A) 0 (C) 1 (A) 0.368 (C) 0.632
(B) 0.5 (D) σ (B) 0.5 (D) 1.0

9. A random variable is uniformly IN - 2014


distributed over the interval 2 to 10. Its 14. Given that x is a random variable in the
variance will be r nge , - with prob bility density
(A) ⁄ (C) ⁄
(B) 6 (D) 36 function the value of the constant k is
___________________
IN - 2009
10. A screening test is carried out to detect a 15. The figure shows the schematic of
certain disease. It is found that 12% of the production process with machines A,B
positive reports and 15% of the negative and C. An input job needs to be pre-
reports are incorrect. Assuming that the processed either by A or by B before it is
probability of a person getting a positive fed to C, from which the final finished
report is 0.01, the probability that a product comes out. The probabilities of
person tested gets an incorrect report is failure of the machines are given as:
(A) 0.0027 (C) 0.1497
(B) 0.0173 (D) 0.2100

IN - 2010
11. The diameters of 10000 ball bearings
were measured. The mean diameter and Assuming independence of failures of the
standard deviation were found to be machines, the probability that a given job
10 mm and 0.05mm respectively. is successfully processed (up to third
Assuming Gaussian distribution of decimal place)is ______________

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 40
GATE QUESTION BANK Mathematics

Answer Keys and Explanations

ME 4. [Ans. D]
1. [Ans. D] ( oth defective)
( oth defective)
The number of ways coming 8 and 9 are S mple sp ce
(2,6),(3,5),(4,4),(5,3),(6,2),(3,6),(4,5),
(5,4),(6,3)
Total ways =9
So Probability of coming 8 and 9 are 5. [Ans. D]
X and Y are independent
∴ ( ) ( ) ( ) re true
So probability of not coming these Only (D) is odd one

6. [Ans. A]
Number of favourable cases are given by
2. [Ans. B]
HHHT
Probability of defective item = HHTH
Probability of not defective item = 1 0.1 HTHH
= 0.9 THHH
So, Probability that exactly 2 of the Total number of cases
chosen items are defective = 2C1 2C1 2C1 2C1 =16
= ( ) ( ) ∴ Probability =

3. [Ans. B] 7. [Ans. A]
Mean (t)̅ = ∫ t f(t) dt A uniform distribution and density
function
∫ t( t)dt ∫ t( t)dt
0,x  a
x x  a

6
t t
7 6
t t
7 f(x)   f  x dx   , axb
0 b  a

0, xb
[ ] [ ]
Density function
 1 a,x  b

f(x)   b  a
Variance = ∫ t f(t)dt  0 a  x,x  b
=∫ t ( t)dt ∫ t ( t)dt b
ab
=∫ (t t )dt ∫ t ( t)dt
 Mean E(x)= x(F(x)) 
x a 2
 Variance = F(x)2  f(x)
2
=0 1 0 1
2
b
b 
 x F(x)  xF(x)
= 2

Standard deviation = √v ri nce x a  x a 


= Put the value of F(x), we get
√ 2
1
b
b 1 
Variance  x dx  x.
2
dx 
x a ba  x a b  a 

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 41
GATE QUESTION BANK Mathematics

b 2 3
 x3   xL  1 7
     (3  3  1)  
3(b  a) a  2 b  a    2 8
b3  a3 (b2  a2 )2
 
3(b  a) 4 b  a 2 9. [Ans. C]
Probability of drawing 2 washers, first
(b  a)(b2  ab  a2 ) (b  a)2(b  a)2 followed by 3 nuts, and subsequently the
 
3(b  a) 4 b  a
2
4 bolts
4b2  4ab  4a2  3a2  3b2  6ab

12
b2  a2  2ab
 10. [Ans. D]
12
Required probability = . / . /
(b  a)2

12
Standard deviation = √v ri nce
(b  a)2 11. [Ans. D]

12 Given 4R and 6B
(b  a) , -

12
Given: b=1, a=0
10 1
 Standard deviation = 
12 12

8. [Ans. D]
Let probability of getting atleast one head 12. [Ans. C]
= P(H) then
P (at least one head) = 1 P(no head)
 P(H)=1 P(all tails)
But in all cases, 23=8
1 7 X=0
X=1
 P (H) = 1  
8 8 Below X (X ) is
Alternately (X ) has to be less than 0.5 but
Probability of getting at least one head greater than zero
( ) ( )
13. [Ans. D]
1 7 A event that he knows the correct
1  
8 8 answer
Alternately B event that student answered
From Binomial theorem correctly the question P(B) = ?
Probability of getting at least one head ( ) ( )
pq

( ) ( ) ( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 42
GATE QUESTION BANK Mathematics

( ) No. of employed men = 80% of men = 80


No. of employed women
⏟ ⏟
= 50% of women = 50
he knows e does not know Probability if the selected one person
correct nswer correct nswer being employed
so he guesses = probability of one employed women
+probability of one employed man

( ) ( ) ( ⁄ )
( ) ⁄
( ⁄ )
( ) ⁄ 18. [Ans. A]

14. [Ans. D]
x 1 2 3
P(x) 0.3 0.6 0.1
(x) x (x)
So from figure
(x)
Mean value = 1
x (x) V ri nce : μ me n x defective pieces
(x μ)
σ V(x) (x ) , (x)- σ
n(n )
x (x) ( x (x)) ( ) ( ) ( )
( ) ( ) ( )
σ √
( )
15. [Ans. A]
19. [Ans. *](Range 49 to 51)

16. [Ans. *] Range 0.25 to 0.27


p
orm l distribution
q Given that μ σ
Using Binomial distribution x μ x
z
σ
(x ≥ ) ( ) ( ) ( ) ( ) ere x μ , s x gre ter th n -
z
ence prob bility (z )

∫ e dz
17. [Ans. *] Range 0.64 to 0.66 σ√
Let number of men = 100 ∴ of s ving ccount holder
Number of women = 100

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 43
GATE QUESTION BANK Mathematics

20. [Ans. B] 25 Calculators


Mean m = np = 5.2
me m 2 Defective 23 Non-defective
(x ) e
e

e 5 Calculators
(x )
1 Defective 4 Non-defective
CE p( defective in c lcul tors)
1. [Ans D]
A, B, C are true
(D) is not true. Since in a negatively
skewed distribution
4. [Ans. C]
mode > median > mean
σ
μ
2. [Ans. D]
Let the mean and standard deviation of
5. [Ans. B]
the students of batch C be μ and σ
Given f(x) = x for x
respectively and the mean and standard
= 0 else where
deviation of entire class of first year
students be μ and σ respectively
Now given, μ ( x ) ∫ f(x)dx ∫ x dx
σ
and μ
σ =0 1
In order to normalise batch C to entire
The probability expressed in percentage
class, the normalize score must be
equated P=
since Z = = 2.469% = 2.47%

Z = =
6. [Ans. A]
Now Z = = Given
Equation these two and solving, we get P(private car) = 0.45
= P(bus 1 public transport) = 0.55
Since a person has a choice between
 x = 8.969 ≃ 9.0
private car and public transport
P(public transport) = 1 – P(private car)
3. [Ans. B]
= 1 – 0.45 =0.55
Since population is finite, hypergeometric
P(bus) = P(bus public transport)
distribution is applicable
(bus public tr nsport)
(public tr nsport)
= 0.55 × 0.55
= 0.3025 ≃ 0.30
Now P(metro)
= 1 [P(private car) + P(bus)]
= 1 (0.45 + 0.30) = 0.25

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 44
GATE QUESTION BANK Mathematics

∴ P(private car) = 0.45 12. [Ans. 6]


P(bus) = 0.30 ∫ f(x)dx
and P(metro) = 0.25 ( x x ) x
f(x) {
otherwise
7. [Ans. D] ∴∫ ( x x )dx
ere μ cm; σ cm
x x
( x 102) 6 x7
=P. x /
=P( x ) [ ( ) ( ) ( )]
This area is shown below:
[ ]

[ ]
-0.44
The shades area in above figure is given
by F(0) –F ( 0.44)
= ( )( )
( ) ( )
= 0.5 – 0.3345 13. [Ans. 0.4]
= 1.1655 ≃ 16.55%
Closest answer is 16.7% ( ) ∫ f( )d ∫ d

8. [Ans. C]
( )| ( )
P(2 heads) =

9. [Ans. C]
P(one ball is Red & another is blue) 14. [Ans. *] Range 0.26 to 0.27
= P(first is Red and second is Blue) Avg= 5
= Let x denote penalty
(x ) (x ) (x )
(x ) (x )
10. [Ans. A]
Given μ = 1000, σ = 200 e
ew (x n)
x
We know that Z
e e e e
p(x )
When X= 1200, Z
Req. Prob = P (X ) e [ ]
(Z )
( Z )
Less than 50%
15. [Ans. B]
S * T+
11. [Ans. D]
n( )
(X ) (X ) (X ) ( )
n(S)
( ) ( )
16. [Ans. *] Range 0.25 to 0.28
e ( t)
(n t)
n

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 45
GATE QUESTION BANK Mathematics

no of vehicles veh km m ke ex ctly ‘ ’ moves nd ‘U’ moves


in any order.
e . /
( ) Similarly to reach (10, 10) from (0,0) the
robot h s to m ke ‘ ’ moves nd ‘U’
= 2.e
moves in any order. The number of ways
= 0.2707
this can be done is same as number of
CS permutations of a word consisting of 10
1. [Ans. A] ‘ ’ s nd ’U’s
P: Event of selecting Box P, Applying formula of permutation with
Q: Event of selecting Box P limited repetitions we get the answer
P(P)=1/3, P(Q)=2/3 as
P(R/P)=2/5, P(R/Q)=3/4
P(R/P).P(P)
P(P/R)= 5. [Ans. D]
P(R/P).P(P)  P(R/Q)P(Q)
2/51/3 The robot can reach (4,4) from (0,0) in
  4/19 8C ways as argued in previous problem.
2/51/3  3/ 4  2/3 4
Now after reaching (4,4) robot is not
allowed to go to (5,4)
2. [Ans. C]
Let us count how many paths are there
If f (x) is the continuous probability
from (0,0) to (10,10) if robot goes from
density function of a random variable X
(4,4) to (5,4) and then we can subtract
then,
this from total number of ways to get the
( x b) P( x b)
b
answer.
= f  x  dx
 Now there are 8C4 ways for robot to reach
a (4,4) from (0,0) and then robot takes the
3. [Ans. A] ‘U’ move from ( ) to ( ) ow from
The probability that exactly n elements (5,4) to (10,10) the robot has to make 5
are chosen ‘U’ moves nd ‘ ’ moves in ny order
=The probability of getting n heads out of which can be done in 11! ways
2n tosses = 11C5 ways
= ( ) . / (Binomial formula) Therefore, the number of ways robot can
move from (0,0) (10,10) via (4,4) – (5,4)
= ( ) ( )
move is
=
 8   11
8C
4
11C
5 =    
4. [Ans. A]  4 5 
Consider the following diagram No. of ways robot can move from (0,0) to
(3,3) (10,10) without using (4,4) to (5,4) move
is
 20  8   11
       ways
 10   4   5 
(0,0)
which is choice (D)
The robot can move only right or up as
defined in problem. Let us denote right
move by ‘ ’ nd up move by ‘U’ ow to
reach (3, 3), from (0,0) , the robot has to

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 46
GATE QUESTION BANK Mathematics

6. [Ans. D] 8. [Ans. C]
umber of permut tions with ‘ ’ in the Let C denote computes science study and
first position =19! M denotes maths study.
Number of permutations with ‘ ’ in the P(C on Monday and C on Wednesday)
second position = 10 18! = P(C on Monday, M on Tuesday and C on
(Fill the first space with any of the 10 odd Wednesday)
numbers and the 18 spaces after the 2 + P(C on Monday, C on Tuesday and C on
with 18 of the remaining numbers in 18! Wednesday)
ways) =1 0.6 0.4+ 1 0.4 0.4
umber of permut tions with ‘ ’ in rd = 0.24 + 0.16 = 0.40
position =10 9 17!
9. [Ans. B]
(Fill the first 2 place with 2 of the 10 odd
It is given that
numbers and then the remaining 17
P (odd) = 0.9 P (even)
places with remaining 17 numbers)
Now since 𝜮P(x) = 1
nd so on until ‘ ’ is in th place. After
∴ P (odd) + P (even) = 1
that it is not possible to satisfy the given
0.9 P (even) + P (even) = 1
condition, since there are only 10 odd
numbers v il ble to fill before the ‘ ’ P(even) = = 0.5263
So the desired number of permutations Now, it is given that P(any even face) is same
which satisfies the given condition is i.e. P(2) = P(4) = P(6)
Now since,
… P(even) = P(2) or P(4) or P(6)
Now the probability of this happening is = P(2) + P(4) + P(6)
given by = ∴ P(2) = P(4) = P(6) = P(even)
( … )
= (0.5263)
Which are clearly not choices (A), (B) or (C) = 0.1754
It is given that
7. [Ans. A]
P(even | face > 3) = 0.75
Given μ = 1, σ = 4 σ =2 ( )
and μ = 1, σ is unknown = 0.75
( )
Given, P(X ) = P (Y ≥ 2 ) ( )
= 0.75
( )
Converting into standard normal variates, ( ) ( )
P(f ce ) = =0.468
.z / = P (z ≥ )
( ) 10. [Ans. A]
.z / = P (z ≥ )
The tree diagram of probabilities is
shown below
(z ) = P (z ≥ ) _____(i)
q decl red f ulty
Now since we know that in standard f ulty
p
normal distribution
q decl red not f ulty
P (z ) = P (z ≥ 1) _____(ii) decl red f ulty
not q
Comparing (i) and (ii) we can say that p
f ulty
=1 σ =3
q decl red not f ulty

From above tree


(decl red f ulty) pq ( q)( p)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 47
GATE QUESTION BANK Mathematics

11. [Ans. A]
( )
If b c …
Then, no. of divisors of ( ∪ ) ( t le st one he d)
(x )(y )(z )… ( TT )
iven
∴ o of ivisors of
So required prob bility
( )( )
( )( )
16. [Ans. B]
No. of divisors of which are multiples Required Probability
of = P (getting 6 in the first time)
o of divisors of + P (getting 1 in the first time and getting
( )( ) 5 or 6 in the second time)
+ P (getting 2 in the first time and getting
4 or 5 or 6 in the second time)
+ P (getting 3 in the first time and getting
∴ equired rob bility
3 or 4 or 5 or 6 in the second time)

( ) ( ) ( )
12. [Ans. C]
V(x) (x ) , (x)-
17. [Ans. C]
Where V(x) is the variance of x,
The p.d.f of the random variable is
Since variance is σ and hence never
x +1
negative, ≥
P(x) 0.5 0.5
The cumulative distribution function F(x)
13. [Ans. A]
is the probability upto x as given below
The five cards are * +
x +1
Sample space ordered pairs F(x) 0.5 1.0
P (1 card = 2 card + 1)
st nd
So correct option is (C)
*( )( )( )( )+
18. [Ans. C]
e
(k)
k
14. [Ans. D] P is no. of cars per minute travelling.
𝛔y = a 𝛔x is the correct expression
Since variance of constant is zero. For no cars. (i.e. k = 0)
For no cars. P(0) e
15. [Ans. A] So P can be either 0,1,2. (i.e. k = 0,1,2)
Let A be the event of head in one coin. B For k = 1, p(1)=e
be the event of head in second coin.
For k = 2 , P(2)=
The required probability is
* ) ( ∪ )+ Hence
( )| ∪ ) ( ) ( ) ( )
( ∪ )
( ) e e e
( ∪ )
( ) (both coin he ds) 4 5
e

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 48
GATE QUESTION BANK Mathematics

( ) ( ) ( ) ( ) ( )
( ⁄ )
e ( ) ( )
( )
e e ∴ equired prob bility is
( ) ( ∪ ∪ )
19. [Ans. *] Range 0.24 to 0.27
The smaller sticks, therefore, will range in
24. [Ans. 0.25]
length from almost 0 meters upto a
( ∪ ) P(S) = 1
maximum of 0.5 meters, with each length
( ) ( ) ( )
equally possible.
utu lly exclusive ( )
Thus, the average length will be about
( ) ( )
0.25 meters, or about a quarter of the
et ( ) x; ( ) x
stick.
P(A) P(B) = x( x)
Maximum value of y = x ( x)
20. [Ans. 10]
dy
22 occurs in following ways ( x) x
dx
6 6 6 4 w ys
= 2x = 1
6 6 5 5 w ys
x
equired prob bility (max)
x ximum v lue of y ( )

21. [Ans. *] Range 11.85 to 11.95


For functioning 3 need to be working ECE
1. [Ans. D]
(function)
3 1
P(Odd number)  
6 2
3 1
P(even number )  
6 2
Since events are independent, therefore
1 1 1
p  P(odd/even)   
2 2 4
22. [Ans. *] Range 3.8 to 3.9
Expected length = Average length of all 2. [Ans. A]
words ( )
I ∫ e dx

omp ring with
( )
∫ e dx
σ√
23. [Ans. *] Range 0.259 to 0.261 ut μ
Let A = divisible by 2, B = divisible by 3
and C = divisible by 5, then ∫ e dx …
√ σ
n(A) = 50, n(B) = 33, n(C) = 20 rom nd
n( ) n( ) n( ) x x
n( ) σ
P( ∪ ∪ ) σ

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 49
GATE QUESTION BANK Mathematics

Put σ in equ tion Probability of failing in paper 2,


P (B) = 0.2
∫ e
√ Probability of failing in paper 1, when
A
student has failed in paper 2, P  0.6
3. [Ans. C] B
 A  P A  B

 P x.dx  1

We know that, P  
 B PB

∴ ( ) ( ) ( )
 Ke .dx  1
ax

 = 0.6 0.2
or ∫ e dx ∫ e dx = 0.12

 x x,for x  0 
  7. [Ans. A]
  x for x  0 x

K K CDF: F x    PDF dx
  1 
a a x
 For x<0, F x     x  1 dx
1

4. [Ans. D] 0 1 conc ve upw rds


. / ( )
P (Y/D) = 1
. / ( ) . / ( ) . / ( ) F0 
2
= =0.4 x
For x>0, F x   F0   x  1 dx
0
5. [Ans. A]
var[x]=σ =E[(x x)2] 1  x2 
   x  concave downwards
Where, x=E[x] 2  2 
x= expected or mean value of X defining Hence the CDF is, shown in the figure (A).

E[X] =  xf  xdx

x 8. [Ans. A]
 Given: Px  x   Me2|x|  Ne3|x|
 
  x P xi   x  xi dx 
  i 
 P  xdx  1
x
 xiP xi  
 

   
i

Variance σ is a measure of the spread of Me2|x|  Ne3|x| dx  2 Me2|x|  Ne3|x| dx  1


 0
the values of X from its mean x.
Using relation , E[X+Y]= E[X]+E[Y] By simplifying
2
And E[CX]=CE[X]  M N 1
On var[x]= σ =E[(x x)2] 3
σ = ,X- x2
9. [Ans. B]
= E[X2] [ ,X-]
x+y=2
x y=0
6. [Ans. C] => x =1, y = 1
Probability of failing in paper 1, P(x=1,y=1) = ¼ ¼ = 1/16
P (A) = 0.3
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 50
GATE QUESTION BANK Mathematics

10. [Ans. C] 14. [Ans. C]


Probability of getting head in first toss = P(no. of tosses is odd)
(no of tosses is …)
Probability of getting head in second toss
P(no. of toss is 1) = P(Head in 1st toss)
= and in all other 8 tosses there should
P(no. of toss is 3) = P(tail in first toss, tail
be tail always.
in second toss and head in third toss)
So probability of getting head in first two
tosses
( )( )( )…………… ( )
P(no. of toss is 5) = P(T,T,T,TH)
= (1/2)10
. / … etc
11. [Ans. B]
So,
Both the teacher and student are wrong
P(no. of tosses in odd)
Mean = ∑ k
= 0.1 + 0.4 + 1.2 + 0.8 + 0.5
= 3.0 ⁄
E(x2) = ∑ k


Variance(x)= E(x2) – * (x)+ =10.2 9=1.2

12. [Ans. D] 15. [Ans. B]


P(H, H, H, T) +P (H, H, H, H ) ( V ≥ V)
= . / . / . / = ( V V≥ )
*z v v+ Linear combination of
Gaussian random variable is Gaussian
∴ (z ≥ ) and not mean till zero
13. [Ans. C]
because both random variables has mean
Total number of cases = 36
zero hence ( )
Favorable cases:
Hence Option B is correct
(1, 1) (2, 1) (3, 1) (4, 1) (5, 1)
(6, 1)
16. [Ans. D]
(1, 2) (2, 2) (3, 2) (4, 2) (5, 2)
F(x) = P{X x}
(6, 2)
(x) * X x+
(1, 3) (2, 3) (3, 3) (4, 3) (5, 3) x
(6, 3) 2X 3
(1, 4) (2, 4) (3, 4) (4, 4) (5, 4) For positive value of x,
(6, 4) (x) (x) is always greater than zero
(1, 5) (2, 5) (3, 5) (4, 5) (5, 5) For negative value of x
(6, 5) (x) (x)is ve
(1, 6) (2, 6) (3, 6) (4, 6) (5, 6) ut , (x) (x)- x ≥
(6, 6)
Total number of favorable cases

Then probability
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 51
GATE QUESTION BANK Mathematics

17. [Ans. *] Range 0.65 to 0.68


et ‘ ’ be different types of f milies nd ‘S’ (x) ∑ x (x)
be there siblings.
S …
S S (siblings)
Probability that child chosen at random et S …… (I)
having sibling is 2/3
S …… (II)
18. [Ans. *] Range 0.32 to 0.34 (I II)gives
This is a tricky question, here, X X X
( )S ……
independent and identically distributed
random variables with the uniform
distribution , -. So, they are S
equiprobable. So X X or X have chances
being largest are equiprobable. S
(x)
So, [P {X is largest}] or [P {X is largest}]
or [P {X is largest}] =1 i.e. The expected number of tosses (after
and P {X is largest} = P {X is largest} = first head) to get first tail is 2 and same
P {X is largest} can be applicable if first toss results in
tail.
∴ *X is l rgest + Hence the average number of tosses is

19. [Ans. *] Range 49.9 to 50.1


Set of positive odd number less than 100 22. [Ans. *] Range 0.15 to 0.18
is 50. As it is a uniform distribution X X X X X X
f(x) et z X X X
(X X X ) (z )
∴ (x) ∑x f(x) ∑x Pdf of z we need to determine. It is the
convolution of three pdf
, … -

20. [Ans. C]

21. [Ans. *] Range 2.9 to 3.1


Let the first toss be head. z z
(z ) ∫ dz |
Let x denotes the number of tosses(after
getting first head) to get first tail.
We can summarize the even as
Event(After x Probability
getting first H) 23. [Ans. *] Range 0.79 to 0.81
T 1 1/2 |x|
,|x|- ∫ e dx
HT 2 1/2 1/2=1/4 √
HHT 3 1/8
nd so on…
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 52
GATE QUESTION BANK Mathematics

x ∴pr(P ∪ Q) pr(P) + pr(Q)


∫ |x| exp 4 5 dx
√ (D) is true
x since P Q P
∫ |x| exp 4 5 dx n(P Q) n(P)

x pr(P Q) pr(P)
∫ x exp 4 5 dx
√ 2. [Ans. B]
x ( )
∫ x exp 4 5 dx P(A|B) =
( )

∴ P(2 heads in 3 tosses | first toss is
x
∫ x exp 4 5 dx head)
√ ( he ds in tosses nd first toss in he d)
(first toss is he d)
√ [ exp ( x ) dx]
Also, P(first toss is head) =
( he d in tosses nd first toss in he d)
√ , - √ = P(HHT) + P(HTH)

24. [Ans. *] Range 0.43 to 0.45


Pre flow diagram is
Parcel is ∴ Required probability = =
sent to R
Parcel is sent to 4/5 R
3. [Ans. C]
4/5
If two fair dices are rolles the probability
S 1/5
Parcel is lost distribution of r where r is the sum of the
1/5
Parcel is lost numbers on each die is given by
Probability that parcel is lost r P(r)
2
Probability that parcel is lost by
3

Probability that parcel is lost by 4


provided that the parcel is lost
5

EE 6
1. [Ans. D]
(A) is false since of P & Q are 7
independent
8
pr(P Q) = pr(P) pr(Q)
which need not be zero.
9
(B) is false since
pr(P ∪ Q) 10
= pr(P) + pr(Q) – pr(P Q)
(C) is false since independence and 11
mutually exclusion are unrelated
properties. 12

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 53
GATE QUESTION BANK Mathematics

The above table has been obtained by P(1, 5, 6) = =


taking all different all different ways of
P(3, 4, 5) = =
obtaining a particular sum. For example, a
sum of 5 can be obtained by (1, 4), (2, 3), P(1, 2, 5) = =
(3, 2) and (4, 1). ∴ Choice (C) P(1, 5 and 6) = is correct.
∴ P(x = 5) = 4/36
Now let us consider choice (A)
5. [Ans. C]
Pr(r > 6) = Pr(r ≥ 7)
x is uniformly distributes in [0, 1]
= ∴ Probability density function
= = f(x) = = =1
∴ Choice (A) i.e. pr(r > 6) = 1/6 is wrong. ∴ f(x) = 1 0 < x < 1
Consider choice (B) Now E(x ) = ∫ x f(x)dx
pr(r/3 is an integer)
= pr(r = 3) + pr (r = 6) + pr (r = 9)
∫x dx
+ pr (r = 1)
=
6. [Ans. B]
= =
Let N people in room. So no. of events that
∴ Choice (B) i.e. pr (r/3) is an integer at least two people in room born at same
= 5/6 is wrong.
date
Consider choice (C)

Now, ≥
N
pr(r/4 is an integer) = pr(r = 4)
Solving, we get N = 7
+ pr (r = 8) + pr (r = 12)
= + 7. [Ans. C]
= = (II is red|I is white)
(II is red nd I is white)
pr(r = 8) = (I is white)
∴ pr(r = 8 | r/4 is an integer) = = (I is white nd II is red)
(I is white)
=
∴ Choice (C) is correct.

4. [Ans. C]
Dice value Probability
1
8. [Ans. B]
2 and is the entrie
rectangle
3
The region in which maximum of {x, y} is
4 less than ⁄ is shown below as shaded
region inside this rectangle
5

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 54
GATE QUESTION BANK Mathematics

y 12. [Ans. *] Range 0.35 to 0.45


( ) ( )

( x ) ∫ f(x)dx

∫ dx ∫ dx ∫ dx

x| x|

( ) ( )
13. [Ans. *] Range 0.4 to 0.5

p .m x,x y- / ∫ f(x) dx by property

∴ ∫ kx dx

x
k | k ∴k

9. [Ans. A] 14. [Ans. D]

(x ) ∫ e dx , e - IN
,e e - e 1. [Ans. D]
Since leap chosen will be random, so, we
assume it being the case of uniform
10. [Ans. B] probability distribution function.
Let number of heads = x, Number of days in a leap year=366 days
∴ Number of tails n x =52 weeks and 2 days are extra. Out of
∴ ifference x (n x)or (n x) x
7, (SUN MON) (or) (SAT SUN) are
x n or n x
favorable.
If x n n x n
So, Probability of this event=
x n
If n x n x or x 2. [Ans. C]
As x and n are integers, this is not Since the reading taken by the instrument
possible is normally distributed, hence
( )
∴ Probability 0 P(x x ) ∫ e .dx

Where, μ e n of the distribution
11. [Ans. *] Range 0.13 to 0.15 σ St nd rd devi tion of the
Let proportionality constant = k distribution.
∴ ( dot) k ( dots) k
Now ∫ exp( )dx
( dots) k √

( dots) k ( dots) k where, n=x 10 (∴μ kg)


( dots) k and from the data given in question
∴k k k k k k ∫ e dx

k ∴k On equating, we get 0.05=0.84 σ
∴ rob bility of showing dots k σ

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 55
GATE QUESTION BANK Mathematics

3. [Ans. D] 8. [Ans. B]
Mean= =5.9 V. By definition of Gaussian distribution,
total area under the curve =1. Hence half
( ̅) ( ̅) ( ̅)
S √ of the area =0.5
V
(closest answer is 0.2) 9. [Ans. A]
P(x)= =
4. [Ans. C] Mean = μ ∫ x (x)dx = ∫ x dx = 6
( ) ( )
Var(x)= ∫ (x μ) (x)dx
1 2
 =∫ (x ) dx =
3 3

5. [Ans. A] ] 10. [Ans. C]


 Probability of incorrect report
 P(x)dx  1


c
 Area under triangle = 1
2 11. [Ans. C]
α σ mm
μ mm
6. [Ans. A] Then probability
Probability that the sum of digits of two X μ
(X ) ( )
σ
dices is even is same either both dices
where x mm
shows even numbers or odd numbers on
the top of the surface ( ) ( )
∴ ( ) ( ) ( )
Where e

( ) Probability of occurring even
number of both the dices e

( ) Probability of occurring odd
number of both the dices So, number of measurement more than
( ) 10.15mm
P Total number of measurement
nd ( )

∴ ( )
12. [Ans. D]
7. [Ans. A] For the product to be even, the numbers
from both the boxes should not turn out
∫ f(x) dx=P
to be odd simultaneously.
or ∫ e .dx =P
∴ ( ) ( )( )
or e |
or P = .

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 56
GATE QUESTION BANK Mathematics

13. [Ans. A]
∫ f(x)dx ∫ e dx
e | e

14. [Ans. 2]
For valid pdf ∫ pdf dx ;

∫ dx ;k

15. [Ans. *] Range 0.890 to 0.899


Probability that job is successfully
processed = ( )( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 57
GATE QUESTION BANK Mathematics

Numerical Methods

ME – 2005 ME – 2010
1. Starting from x = 1, one step of Newton – 6. Torque exerted on a flywheel over a cycle
Raphson method in solving the equation is listed in the table. Flywheel energy (in
x³ +3x 7=0 gives the next value (x₁) as J per unit cycle) using impson’s rule is
(A) x₁=0.5 (C) x₁ = .5 Angle (degree) Torque (N-m)
(B) x₁= . 0 (D) x₁=2 0 0
60 1066
2. With a 1 unit change in b, what is the
change in x in the solution of the system 120 323
of equation = 2 .0 0. = 180 0
(A) Zero (C) 50 units 240 323
(B) 2 units (D) 100 units 300 55
360 0
ME – 2006 (A) 542 (C) 1444
3. Match the items in columns I and II. (B) 992.7 (D) 1986
Column I Column II
(P) Gauss-Seidel (1) Interpolation ME – 2011
method 7. The integral ∫ dx, when evaluated by
(Q) Forward (2) Non-linear using impson’s / rule on two equal
Newton-Gauss differential subintervals each of length 1, equals
method equations (A) 1.000 (C) 1.111
(R) Runge-Kutta (3) Numerical (B) 1.098 (D) 1.120
method integration
(S) Trapezoidal (4) Linear algebraic ME – 2013
Rule equation 8. Match the correct pairs.
(A) 2 Numerical Order of Fitting
(B) 2 Integration Scheme Polynomial
(C) 2 . impson’s / 1. First
(D) 2 Rule
Q. Trapezoidal Rule 2. Second
4. Equation of the line normal to function . impson’s / 3. Third
f(x) = (x ) at (0 5) is Rule
(A) y = x 5 (C) y = x 5 (A) P – 2 , Q – 1, R – 3
(B) y = x 5 (D) y = x 5 (B) P – 3, Q – 2 , R – 1
(C) P – 1, Q – 2 , R – 3
ME – 2007 (D) P – 3, Q – 1 , R – 2
5. A calculator has accuracy up to 8 digits
2
ME – 2014
after decimal place. The value of  sinxdx
0
9. Using the trapezoidal rule, and dividing
the interval of integration into three equal
when evaluated using this calculator by
sub intervals, the definite integral
trapezoidal method with 8 equal
intervals, to 5 significant digits is ∫ |x|dx is ____________
(A) 0.00000 (C) 0.00500
(B) 1.0000 (D) 0.00025

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 58
GATE QUESTION BANK Mathematics

10. The value of ∫ . ( ) calculated using “value approximate value”) in the


the Trapezoidal rule with five sub estimate?
intervals is _______ (A) – (C) –
(B) 0 (D)
11. The definite integral ∫ is evaluated
using Trapezoidal rule with a step size of CE – 2007
1. The correct answer is _______ 4. The following equation needs to be
numerically solved using the Newton-
12. The real root of the equation Raphson method
5x 2cosx = 0 (up to two decimal x3 + 4x – 9 = 0 the iterative equation for
accuracy) is _______ the purpose is (k indicates the iteration
level)
13. Consider an ordinary differential (A) x =
equation = t .If x =x at t = 0 , the
(B) x =
increment in x calculated using Runge-
Kutta fourth order multi-step method (C) x =x x
with a step size of Δt = 0.2 is (D) x =
(A) 0.22 (C) 0.66
(B) 0.44 (D) 0.88
5. Given that one root of the equation
CE – 2005 x 10x + 31x – 30 = 0 is 5, the other
Linked Answer Question 1 and 2 two roots are
Give a>0, we wish to calculate its (A) 2 and (C) and
reciprocal value 1/a by using Newton (B) 2 and (D) 2 and
Raphson Method for f(x) = 0.
CE – 2008
6. Three values of x and y are to be fitted in
1. The Newton Raphson algorithm for the
a straight line in the form y = a + bx by
function will be
the method of least squares. Given
(A) x = (x ) ∑x = 6, ∑y = 2 ∑x = and ∑xy =
(B) x = (x x ) the values of a and b are respectively
(A) 2 and 3 (C) 2 and 1
(C) x = 2x ax
(B) 1 and 2 (D) 3 and 2
(D) x =x x
CE – 2009
2. For a = 7 and starting with x = 0.2 the 7. In the solution of the following set of
first two iteration will be linear equation by Gauss elimination
(A) 0.11, 0.1299 (C) 0.12, 0.1416 using partial pivoting 5x + y + 2z = 34;
(B) 0.12, 0.1392 (D) 0.13, 0.1428 4y – 3z = 12; and 10x – 2y + z = 4; the
pivots for elimination of x and y are
CE – 2006 (A) 10 and 4 (C) 5 and 4
3. A 2nd degree polynomial f(x) has values of (B) 10 and 2 (D) 5 and 4
1, 4 and 15 at x = 0, 1 and 2 respectively.
The integral ∫ f(x) dx is to be estimated
by applying the trapezoidal rule to this
data. What is the error (define as true
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 59
GATE QUESTION BANK Mathematics

CE – 2010 CE – 2013
8. The table below given values of a function 12. Find the magnitude of the error (correct
F(x) obtained for values of x at intervals to two decimal places) in the estimation
of 0.25. of following integral using impson’s ⁄
x 0 0.25 0.5 0.75 1.0 Rule. Take the step length as 1.___________
F(x) 1 0.9412 0.8 0.64 0.50
∫ (x 0) dx
The value of the integral of the function
between the limits 0 to using impson’s
rule is CS – 2007
(A) 0.7854 (C) 3.1416 1. Consider the series =
(B) 2.3562 (D) 7.5000
= 0.5 obtained from the Newton-
CE 2011 Raphson method. The series converges to
9. The square root of a number N is to be (A) 1.5 (C) 1.6
obtained by applying the Newton (B) √2 (D) 1.4
Raphson iterations to the equation
CS – 2008
x = 0. If i denotes the iteration
2. The minimum number of equal length
index, the correct iteration scheme will be
subintervals needed to approximate
(A) x = (x ) 2
1
 xe dx
x
to an accuracy of at least 106
(B) x = (x ) 1 3
using the trapezoidal rule is
(C) x = (x )
(A) 1000e (C) 100e
(D) x = (x ) (B) 1000 (D) 100

3. The Newton-Raphson iteration


10. he error in f(x)| for a continuous
1 R
xn1   xn   can be used to compute
function estimated with h=0.03 using the 2 xn 
central difference formula the
( ) ( )
f(x)| = is 2 0 . (A) square of R
(B) reciprocal of R
The values of and ( ) are 19.78 and
(C) square root of R
500.01, respectively. The corresponding
(D) logarithm of R
error in the central difference estimate
for h = 0.02 is approximately
CS – 2010
(A) . 0 (C) .5 0
(B) .0 0 (D) .0 0 4. Newton-Raphson method is used to
compute a root of the equation
CE – 2012 x 13 = 0 with 3.5 as the initial value.
11. The estimate of ∫ .
.
obtained using The approximation after one iteration is
(A) 3.575 (C) 3.667
impson’s rule with three – point function (B) 3.677 (D) 3.607
evaluation exceeds the exact value by
(A) 0.235 (C) 0.024
(B) 0.068 (D) 0.012

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 60
GATE QUESTION BANK Mathematics

CS – 2012 (B) Only II


5. The bisection method is applied to (C) Both I and II
compute a zero of the function (D) Neither I nor II
f(x) = x x x in the interval
[1,9]. The method converges to a solution 9. With respect to the numerical evaluation
after ___________ iterations. of the definite integral, = ∫ x dx
(A) 1 (C) 5 where a and b are given, which of the
(B) 3 (D) 7
following statements is/are TRUE?
(I) The value of K obtained using the
CS – 2013
trapezoidal rule is always greater
6. Function f is known at the following
then or equal to the exact value of
points:
the defined integral
x f(x)
(II) The value of K obtained using the
0 0
impson’s rule is always equal to the
0.3 0.09
exact value of the definite integral
0.6 0.36
(A) I only
0.9 0.81
(B) II only
1.2 1.44
(C) Both I and II
1.5 2.25
(D) Neither I nor II
1.8 3.24
2.1 4.41 ECE– 2005
2.4 5.76 1. Match the following and choose the
2.7 7.29 correct combination
3.0 9.00 Group I Group II
he value of ∫ f(x)dx computed using (A) Newton- 1. Solving non-
Raphson linear equations
the trapezpidal rule is method
(A) 8.983 (C) 9.017 (B) Runge-Kutta 2. Solving linear
(B) 9.003 (D) 9.045 method simultaneous
equations
CS – 2014
(C) impson’s 3. Solving ordinary
7. The function f(x) = x sin x satisfied the
Rule differential
following equation:
equations
( ) + f(x) + t cos x = 0.
(D) Gauss 4. Numerical
The value of t is _________.
elimination integration
method
8. In the Newton-Raphson method, an initial
5. Interpolation
guess of = 2 made and the sequence
6. Calculation of
x x x .. is obtained for the function
Eigen values
0.75x 2x 2x =0
(A) A-6, B-1, C-5, D-3
Consider the statements
(B) A-1, B-6, C-4, D-3
(I) x = 0.
(II) The method converges to a solution
(C) A-1, B-3, C-4, D-2
in a finite number of iterations. (D) A-5, B-3, C-4, D-1
Which of the following is TRUE?
(A) Only I

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 61
GATE QUESTION BANK Mathematics

ECE– 2007 (B) 2 x x . ..


2. The equation x3 x2+4x 4=0 is to be
solved using the Newton-Raphson (C) 2 x x . ..
method. If x=2 is taken as the initial (D) 2 x x . ..
approximation of the solution, then the
next approximation using this method
7. Match the application to appropriate
will be
numerical method.
(A) 2/3 (C) 1
(B) 4/3 (D) 3/2 Application Numerical
Method
ECE– 2008 P1:Numerical M1:Newton-
3. The recursion relation to solve x= integration Raphson Method
using Newton-Raphson method is P2:Solution to a M2:Runge-Kutta
(A) =e transcendental Method
(B) = e equation
eXn P3:Solution to a M : impson’s
(C) Xn1  1  Xn  system of linear 1/3-rule
1  eXn
equations
X2  eXn 1  Xn   1
(D) Xn1  n P4:Solution to a M4:Gauss
Xn -eXn differential equation Elimination
Method
ECE– 2011 (A) P1—M3, P2—M2, P3—M4, P4—M1
4. A numerical solution of the equation (B) P1—M3, P2—M1, P3—M4, P4—M2
f(x) = x √x = 0 can be obtained (C) P1—M4, P2—M1, P3—M3, P4—M2
using Newton – Raphson method. If the (D) P1—M2, P2—M1, P3—M3, P4—M4
starting value is x = 2 for the iteration,
the value of x that is to be used in the next 8. The series ∑ converges to
step is
(A) 2 ln 2 (C) 2
(A) 0.306 (C) 1.694 (D) e
(B) √2
(B) 0.739 (D) 2.306
EE– 2007
ECE– 2013
1. The differential equation = is
5. A polynomial
f(x) = a x a x a x a x a discretised using Euler’s numerical
with all coefficients positive has integration method with a time step
(A) No real root T > 0. What is the maximum permissible
(B) No negative real root value of T to ensure stability of the
(C) Odd number of real roots solution of the corresponding discrete
(D) At least one positive and one time equation?
negative real root (A) 1 (C)
(B) /2 (D) 2
ECE– 2014
EE– 2008
6. The Taylor expansion of sin x 2 cos x
2. Equation e = 0 is required to be
is
solved using ewton’s method with an
(A) 2 x x . .. initial guess x = . Then, after one

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 62
GATE QUESTION BANK Mathematics

step of ewton’s method estimate x of EE– 2013


the solution will be given by 7. When the Newton – Raphson method is
(A) 0.71828 (C) 0.20587 applied to solve the equation
(B) 0.36784 (D) 0.00000 f(x) = x 2x = 0 the solution at the
end of the first iteration with the initial
3. A differential equation dx/dt = e u(t) guess value as x = .2 is
has to be solved using trapezoidal rule of (A) 0.82 (C) 0.705
integration with a step size h = 0.01 sec. (B) 0.49 (D) 1.69
Function u(t) indicates a unit step
function. If x(0)= 0, then value of x at EE– 2014
t = 0.01 s will be given by 8. The function ( ) = is to be
(A) 0.00099 (C) 0.0099 solved using Newton-Raphson method. If
(B) 0.00495 (D) 0.0198 the initial value of is taken as 1.0, then
the absolute error observed at 2nd
EE– 2009 iteration is ___________
4. Let x 7 = 0. The iterative steps for
the solution using Newton – aphson’s IN– 2006
method is given by 1. For k = 0 2 . the steps of
(A) x = (x ) Newton-Raphson method for solving a
non-linear equation is given as
(B) x =x
2 5
(C) x =x xk 1  xk  xK2 .
3 3
(D) x =x (x ) Starting from a suitable initial choice as k
tends to , the iterate tends to
(A) 1.7099 (C) 3.1251
EE– 2011
(B) 2.2361 (D) 5.0000
5. Solution of the variables and for the
following equations is to be obtained by IN– 2007
employing the Newton-Raphson iterative 2. Identify the Newton-Raphson iteration
method scheme for finding the square root of 2.
equation(i) 0x inx 0. = 0
(A) x = (x )
equation(ii) 0x 0x cosx 0. = 0
Assuming the initial values = 0.0 and (B) x = (x )
= .0 the jacobian matrix is
0 0. 0 0. (C) x =
(A) * + (C) * +
0 0. 0 0. (D) x = √2 x
0 0 0 0
(B) * + (D) * +
0 0 0 0
3. The polynomial p(x) = x + x + 2 has
(A) all real roots
6. Roots of the algebraic equation (B) 3 real and 2 complex roots
x x x = 0 are (C) 1 real and 4 complex roots
(A) ( ) (C) (0 0 0) (D) all complex roots
(B) ( j j) (D) ( j j)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 63
GATE QUESTION BANK Mathematics

IN– 2008 IN– 2013


4. It is known that two roots of the 8. While numerically solving the differential
nonlinear equation x3 – 6x2 +11x 6 = 0 equation 2xy = 0 y(0) = using
are 1 and 3. The third root will be
Euler’s predictor – corrector (improved
(A) j (C) 2
Euler – Cauchy )method with a step size
(B) j (D) 4
of 0.2, the value of y after the first step is
(A) 1.00 (C) 0.97
IN – 2009
(B) 1.03 (D) 0.96
5. The differential equation = with
x(0) = 0 and the constant 0 is to be IN– 2014
numerically integrated using the forward 9. The iteration step in order to solve for the
Euler method with a constant integration cube roots of a given number N using the
time step T. The maximum value of T such Newton- aphson’s method is
that the numerical solution of x converges (A) x =x ( x )
is
(C) (B) x = (2x )
(A)
(D) 2 (C) x =x ( x )
(B)
(D) x = (2x )
IN– 2010
6. The velocity v (in m/s) of a moving mass,
starting from rest, is given as =v t.
Using Euler’s forward difference method
(also known as Cauchy-Euler method)
with a step size of 0.1s, the velocity at 0.2s
evaluates to
(A) 0.01 m/s (C) 0.2 m/s
(B) 0.1 m/s (D) 1 m/s

IN– 2011
7. The extremum (minimum or maximum)
point of a function f(x) is to be
( )
determined by solving = 0 using the
Newton-Raphson method.
Let f(x) = x x and x = 1 be the initial
guess of x. The value of x after two
iterations (x ) is
(A) 0.0141 (C) 1.4167
(B) 1.4142 (D) 1.5000

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 64
GATE QUESTION BANK Mathematics

Answer Keys and Explanations

ME y = sin ( ) =
1. [Ans. C] 2
( )
By N-R method , =x – x = y = sin ( ) = 0.70 0
( )
f(x) = x x 7 y = sin( ) = 0
 f( ) = 5
y = sin ( ) = 0.70 0
( )
x =x ( )
y = sin ( )=
 f (x) = x
f ( )= , 7
y = sin ( ) = 0.70 0
( )
 =1 = (0.5) = .5
y = sin ( )=0
2. [Ans. C] Trapezoidal rule
Given x y = 2 (i) ∫ f(x)dx = [(y y ) 2(y y
.0 x 0.0 y = b (ii)
y )]
Multiply 0.99 is equation (i) and subtract
∫ sinx dx = [(0 0) 2(0.70 0
from equation (ii); we get
( .0 0. )x = b (2 0. ) 0.70 0 0.70 0 0.70 0 0=0
0.02x = b .
0.02Δx = Δb 6. [Ans. B]
ower = ω = Area under the curve.
Δx = = 50 units h
0.02 = [(y y ) (y y y )

3. [Ans. D] 2(y y )]
= [(0 0) ( 0 0 55)
4. [Ans. B]
/ 2( 2 2 )]
Given f(x) = (x )
= 2.7 /unit cycle.
2
f (x) = (x )
Slope of tangent at point (0, 5) 7. [Ans. C]
2 x 1 2 3
m = (0 ) / = 1
y=
Slope of normal = 3 x 2
h
(∵ roduct of slopes = 1) ∫ dx = (y y y )
x
Slope of normal at point (0, 5)
y 5 = (x 0) = ( )
2
y= x 5
= .

5. [Ans. A]
8. [Ans. D]
b a 2 0
h= = = By the definition only
n
y = sin(0) = 0
y = sin ( ) = 0.70 0

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 65
GATE QUESTION BANK Mathematics

9. [Ans. *] Range 1.10 to 1.12 By intermediate value theorem roots lie


be between 0 and 1.
∫ |x|dx is et x = rad = 57. 2
By Newton Raphson method
h f(x )
∫ ydx = [y 2(y y .) y ] x =x
2 f (x )
2x sin x 2 cos x
y y y y x =
5 2 sin x
x 1 0.33 0.33 1 x = 0.5 2
x = 0.5 25
y 1 0.33 0.333 1 x = 0.5 2
2
∫ |x|dx = [ 2(0. 0. )] 13. [Ans. D]
2
The variation in options are much, so it
= . 0 can be solved by integrating directly
dx
10. [Ans. *] Range 1.74 to 1.76 = t
dt
2.5 .
h= = 0. ∫ dx = ∫ ( t )dt
5
y 2y 2y 2y
∫ . ln (x)dx = [ 2y y
] . .
t
. Δx = t| = 2t t|
= [ln(2.5) 2(ln2. ) 2 ln( . ) 2
2ln( . ) 2ln( .7) ln( )] Δx = 0.0 0. = 0.
= .75
CE
11. [Ans. *]Range 1.1 to 1.2 1. [Ans. C]
To calculate using N-R method
∫ dx by trapezoidal rule
x
Set up the equation as x =
rapezoidal rule
i.e. = a
∫ f(x)dx = [y y 2(y y ..y )]
a=0
h= iven in question
0 1 2 i.e. f(x) = a=0
x 1 2 3 Now f (x) =
y 1 0.5 0.33
f(x ) = a

∫ dx = [y y 2(y )] f (x ) =
x 2
For N-R method
= [ 0. 2 0.5] x =x
( )
2 ( )
= . ( )
x =x
12. [Ans. *] Range 0.53 to 0.56
Let f(x) = 5x 2 cos x Simplifying which we get
f (x) = 5 2 sin x x = 2x ax
f(0) = f( ) = 2.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 66
GATE QUESTION BANK Mathematics

2. [Ans. B] f(x )
x =x
For a = 7 iteration equation f (x )
Becomes x = 2x 7x (x x )
=x
with x = 0.2 ( x )
x = 2x 7x = 2× 0.2 – 7(0.2) = 0.12 x x x x
and x = 2x 7x = 2× 0.12 7(0. 2) =
( x )
= 0.1392 2x
x =
x
3. [Ans. A]
f(x) = 1, 4, 15 at x = 0, 1 and 2
5. [Ans. A]
respectively
Given
∫ f(x)dx = (f 2f f ) x – 10 x + 31x 30 = 0
(3 points Trapezoidal Rule) One root = 5
Here h = 1 Let the roots be α β and γ of equation
∫ f(x)dx = (1 + 2(4) + 15) = 12 ax + bx + cx + d = 0
Approximate value by rapezoidal ule αβγ=
= 12 and α β βγ γα =
Since f(x) is second degree polynomial, let ( )
α βγ = 5 βγ = = 30
f(x) = a0 + a x + a x
f(0) = 1  βγ = (i)
a 0 0= Also
a = αβ βγ γα = 5β βγ 5γ = =
f(1) = 4  5 (β γ) βγ =
a a a = ince βγ = from (i)
 1+ a a = 5 (β γ) =
a a = β γ=5
 f(2) = 15 βγ =
a 2a a = 5 olving for β and γ
 2a a = 5 β (5 β) =
 2a a = β 5β =0
Solving (i) and (ii) a = and a =  β = 2 and γ =
f(x) = 1 – x + 4 x Alternative method
Now exact value ∫ f(x)dx 5 1 0 31 0
0 5 25 30
=∫ ( x x )dx
1 5 6 0
= *x + = (x 5)(x 5x )=0
Error = exact – Approximate value (x 5)(x 2)(x )=0
x=2 5
= 2=

4. [Ans. A ] 6. [Ans. D]
Y = a + bx
Given f(x) = x x =0
Given
f (x) = x
n= ∑x = ∑y = 2 ∑x = 14
Newton – Raphson formula is
and ∑xy =

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 67
GATE QUESTION BANK Mathematics

Normal equations are 9. [Ans. A]


∑y = na b∑x f(x )
x =x
∑xy = a∑x b∑x f(x )
Substitute the values and simply x
=x ( )
a= b=2 2x
x
= = [x ]
7. [Ans. A] 2x 2 x
The equation is
5x + y + 2z = 34 10. [Ans. D]
0x + 4y – 3z = 12 Error in central difference formula is
and 10x – 2y + z = (h)
The augmented matrix for gauss This means, error
elimination is If error for h = 0.03 is 2 0
5 2 then
[0 | 2] Error for h = 0.02 is approximately
0 2 (0.02)
Since in the first column maximum 2 0 0
(0.0 )
element in absolute value is 10 we need
to exchange row 1 with row 3 11. [Ans. D]
5 2 ( )
0 2 .
[0 | 2] → [0 | 2] Exact value of ∫ . dx = .0
0 2 5 2 Using impson’s rule in three – point
So the pivot for eliminating x is a = 10
form,
Now we eliminate x using this pivot
b a .5 0.5
as follows : h= = = 0.5
n 2
0 2
So,
[0 | 2]
5 2 x 0.5 1 1.5
5 y 2 1 0.67
0 2
0 ∫ = [ ]
→ [0 2]
0 2 /2 0.5
= [2 0. 7 ]
Now to eliminate y, we need to compare
the elements in second column at and = .
below the diagonal element Since a = 4 So, the estimate exceeds the exact value by
is already larger in absolute value Approximate value – Exact value
compares to a = 2 = 1.1116 1.0986
The pivot element for eliminating y is =0.012(approximately)
a = 4 itself.
12. [Ans. *](Range 0.52 to 0.55)
The pivots for eliminating x and y are
Using impson’s ule
respectively 10 and 4
X 0 1 2 3 4
Y 10 11 26 91 266
8. [Ans. A]
I = h(f f 2f f f ) ∫ (x 0)dx

= 0.25( 0. 2 2 = [( 0 2 ) 2(2 ) ( )]
0. 0. 0.5) = 2 5.
= 0.7 5 The value of integral

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 68
GATE QUESTION BANK Mathematics

x = = 1000 e
∫ (x 0) dx = * 0x+ ( )/
5
3. [Ans. C]
= 0 =2 .
5 x = (x )
Magnitude of error
= 2 5. 2 . = 0.5 At convergence
x =x =α
CS α= (α )
1. [Ans. A] 2α=α+
Given x = + , x = 0.5
2α =
when the series converges x =x =α
2α = α + R
α= +
α =R
α= α=√
8α = 4α +9 So this iteration will compute the square
root of R
α =
α = = 1.5 4. [Ans. D]
y=x
2. [Ans. A] dy
= 2x
Here, the function being integrated is dx
f(x)= x
f(x) = xe
.
f (x) = xe + e = e (x + 1) x = .5
.
f’ (x) = xe + e + e = e (x + 2) = . 07
Since, both are increasing
functions of x, maximum value of f ( ) in 5. [Ans. B]
interval 1 2, occurs at = 2 so f( ) = 5
max |f ( )| =e (2 2) = e f( ) = 5 72 = 57 7 0
Truncation Error for trapezoidal rule f( ) 0 f( ) 0
= TE (bound) x =( )=5 f(x ) 0
2
= max |f ( )|
oot lies between and
Where is number of subintervals
x =( )=2 f(x ) 0
= 2
After ' ' interations we get the root
= max |f ( )|
6. [Ans. D]
= (b – a) max |f ( )| 1 2
h
= (2 – 1) [e (2 + 2)] ∫ f(x)dx = [f(0) f( ) 2(∑f )]
2
= e . 0 2(0.0 0.
= [ ]
Now putting = 0 0. . . 7.2 )
( )
.
= [ 5 . ]
=
= 9.045
h=
Now, No. of intervals, =

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 69
GATE QUESTION BANK Mathematics

7. [Ans. – ] 8 4
x1  2  
Given (x) + f(x) + t cos x = 0 12 3
and f(x) = x sin x
f (x) = x cos x + sin x 3. [Ans. C]
f (x) = x ( sin x) + cos x + cos x Given : f(x)= x e
= 2 cos x – x sin x By Newton Raphson method,
= 2 cos x – f (x) f(x ) x e
x =x =x
2 cos x – f (x) + f(x) +t cos x = 0 f (x ) e
2 cos x = tcos x t = 2 e xn
 1  x n 
1  exn
8. [Ans. A]
f(x) = 0.75x 2x 2x 4. [Ans. C]
f (x) = 2.25x x 2 f(x )
x =2 f = 2 f = x =x
f (x )
f f(2) = (2 ) = √2 and
x =x =0 √2
f √
f = f = 2 f (2) = =
√ √
f x =2
(√ )
= .
x =x =2 √
f √

f = 2 f =
f 5. [Ans. D]
x =x =0 f(x) = a x a x a x a x a
f
Also, root does not lies between 0 and 1 If the above equation have complex roots,
So, the method diverges if x = 2 then they must be in complex conjugate
nly ( )is true. pair, because it’s given all co-efficients are
positive ( they are real )
9. [Ans. C] So if complex roots are even no. (in pair)
For value of K if trapezoidal rule is used then real roots will also be even.
then the value is either greater than ption ( )is wrong
actual value of definite integral and if From the equation
impson’s rule is used then value is exact roduct of roots = ( 0)
Hence both statements are TRUE As no. of roots = 4,
Product of roots < 1
ECE
either one root 0
1. [Ans. C]
(or)
By definition (& the application) of
Product of three roots < 0
various methods
ption ( )is rong.
2. [Ans. B] Now, take option (A),
y(t) =x3 x2 + 4x 4=0 Let us take it is correct .
x0 = 2 Roots are in complex conjugate pairs
f  x0  =
Next approximation x1  x0 
f ' x0 
Product of roots
0
x03  x02  4x0  4 | | | | 0 which is not possible
x1  x0 
3x02  2x0  4 ption (A) is wrong
orrect answer is option ( )
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 70
GATE QUESTION BANK Mathematics

6. [Ans. A] Now put i=0


sin x 2 cos x ( )
x =
x x
= (x – ) 2( – ) Put x = as given,
2
x = [e ( 2) ]/e
= 0.71828
7. [Ans. B]

8. [Ans. D] 3. [Ans. C]
=e u(t)
∑ = . .. = e
n 2 x
x x
as e = . . . x in
2

EE t
1. [Ans. D] x = ∫ e u(t) dt = ∫ f(t) dt
Here, = At t = 0.01, x = Area of trapezoidal
.
x = [f(0) f(0.0 )] = [ e .
]
f(x y) =
= 0.0099
Euler’s method equation is
x = x h. f(x y )
4. [Ans. A]
x ( )
x = x h( ) x =x
( )
h h
x =( )x = x
h = *x +
or stability | |
h 5. [Ans. B]
u(x x ) = 0x sin x 0. = 0
since h = Δ here v(x x ) = 0x 0x cosx 0. = 0
Δ
The Jacobian matrix is
u u
Δ 2
x x
o maximum permissible value of Δ is 2 .
v v
[ x x ]
2. [Ans. A]
Here f(x) = e 0x cos x 0sinx
=[ ]
0x sinx 20x 0cosx
f (x) = e
The Newton Raphson iterative equation is The matrix at x = 0 x = is
( )
x =x 0 0
( ) =* +
0 0
f(x ) = e
f’(x ) = e 6. [Ans. D]
x =x x x x =0
–( ) (x )(x )=0
i.e. x =
x =0 x =0
( )
= x= x= j

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 71
GATE QUESTION BANK Mathematics

7. [Ans. C] Hence, it will have atleast 5 (0+1)= 4


f(x ) complex roots.
x =x
f (x )
( .2) 2( .2) 4. [Ans. C]
= .2 Approach- 1
( .2) 2
= 0.705 Given, x3 – 6x2 + 11x – 6 = 0
Or (x – 1)(x – 3)(x – 2) = 0
8. [Ans. *] Range 0.05 to 0.07 x= 1, 2, 3.
Clearly, x = 0 is root of the equation
f(x) = e =0 Approach- 2
f (x) = e and x = .0 For ax3 +bx2 + cx +d = 0
Using ewton raphson method If the three roots are p,q,r then
f(x ) (e . ) Sum of the roots= p+q+r= b/a
x =x = = Product of the roots= pqr= d/a
f (x ) e. e
pq+qr+rp=c/a
f(x ) (e )
and x = x =
f (x ) e e 5. [Ans. D]
dx x
= =
e
e dt
= 0. 7 0. = 0.0 f(x, y) =
Absolute error at 2nd itteration is x
x =x h (x y ) = x h( )
|0 0.0 | = 0.0
h h
=( )x ( )
IN
1. [Ans. A] h
or stability | |
As k ∞ xk+1 ≈xk
h
xk = x x
x = x Δ

x =5
Δ 2
/
x =5 = 1.70
6. [Ans. A]
2. [Ans. A] dv
Assume x = √ =v t
dt
f(x) = x =0 t v dv
=v t
f(x ) 2 dt
x =x = [x ] 0 0 0 0+0 0. = 0
f (x ) 2 x
0.1 0 0+0.1 0. = 0.0
3. [Ans. C]
Given p(x) = x + x + 2 7. [Ans. C]
There is no sign change, hence at most 0 f(x) = x x
positive root ( rom escarte’s rule of f (x) = x = g(x)
signs) x = initial guess
p( x) = x x+2 g (x) = x
g (x )
There is one sign change, hence at most 1 x =x
negative root ( rom escarte’s rule of g (x )
signs)
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 72
GATE QUESTION BANK Mathematics

( )
= = .5
g(x )
x =x
g (x )
0.75
= .5
= . 7

8. [Ans. D]
dy
= 2xy x = 0 y = h = 0.2
dx
y =y h. f(x y )
= (0.2)f(0 ) =
and y = y [f(x y ) f(x y )]
= (0. )[f(0 ) f(0.2 )]
= 0.
is the value of y after first step, using
Euler’s predictor – corrector method

9. [Ans. B]
For convergence
x = x =x x= (2x )
x
x = x= √

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 73
GATE QUESTION BANK Mathematics

Calculus
ME – 2005 ME – 2006
1. The line integral ∫ ⃗ ⃗⃗⃗⃗ of the vector 2x2  7x  3
7. If f( x ) = , then limf(x) will
function ⃗ ( ) 2xyz ̂+ x²z + ̂ k²y ̂ from 5x2  12x  9 x 3

the origin to the point P (1,1,1) be


(A) is 1 (A) ⁄ (C) 0
(B) is Zero (B) ⁄ (D) ⁄
(C) is 1
(D) cannot be determined without 8. Assuming i = 1 and t is a real number,
specifying the path
∫ dt is:
2. The right circular cone of largest volume (A)

(C)

that can be enclosed by a sphere of 1 m


√ √
radius has a height of (B) (D) . /
(A) √
(C)
9. Let x denote a real number. Find out the
(B) (D)
INCORRECT statement
(A) S * + represents the set if all
3. By a change of variables
real numbers greater then 3
x(u,v) = uv, y(u,v) = v/u is double
(B) S * + represents the empty
integral, the integral f(x,y) changes to
set
f(uv, u/v) ( ). Then, ( )
(C) S * + represents the
(A) 2 v/u (C) v²
union of set A and set B
(B) 2 u v (D) 1
(D) S * + represents the set
4. Changing the order of the integration in of all real umbers between a and b,
the double integral I = ∫ ∫ ( ) where and b are real number

leads to
ME – 2007
I =∫ ∫ ( ) What is q?
( )
(A) 4y (C) X 10.
(B) 16y² (D) 8 (A) 0 (C)
(B) ⁄ (D) 1
5. ∫ ( ) is equal to
(A) ∫ 11. The area of a triangle formed by the tips
(B) 2∫ of vectors a , b and c is
(C) 2∫ ( ) (A) ( )( )
(D) Zero (B) |( ) ( )|

6. Stoke’ theorem connects (C) | |


(A) A line integral and a surface integral (D) ( )
(B) Surface integral and a volume
integral
(C) A line integral and a volume integral
(D) Gradient of function and its surface
integral
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 74
GATE QUESTION BANK Mathematics

19. In the Taylor series expansion of ex about


12. If √ √ √ , then x = 2, the coefficient of (x 2)4 is
y (2) = (A) ⁄ (C) ⁄
(A) 4 or 1 (C) 1 only (B) ⁄ (D) ⁄
(B) 4 only (D) Undefined
20. The divergence of the vector field
13. The minimum value of function y = x2 in (x y) ̂ ( )̂ ( ) ̂ is
the interval [1, 5] is (A) 0 (C) 2
(A) 0 (C) 25 (B) 1 (D) 3
(B) 1 (D) Undefined
21. Let What is at x=2, y=1?
ME – 2008
(A) 0 (C) 1
14. The length of the curve
(B) ln2 (D) 1/ln2
between x = 0 and x = 1 is
(A) 0.27 (C) 1 ME – 2009
(B) 0.67 (D) 1.22 22. The area enclosed between the curves
y2  4x and x2  4y is
15. Which of the following integrals is
unbounded? (A) ⁄ (C) ⁄
(B) 8 (D) 16
(A) ∫ (C) ∫
(B) ∫ (D) ∫ 23. The distance between the origin and the
point nearest to it on the surface
16. The directional derivative of the scalar z2  1  xy is
function f(x, y, z) = x2  2y2  z at the (A) 1 (C) √
point P = (1, 1, 2) in the direction of the (B) √ ⁄ (D) 2
vector ⃗ ̂ ̂ is
(A) 4 (C) 1 24. A path AB in the form of one quarter of a
(B) 2 (D) 1 circle of unit radius is shown in the figure.
Integration of  x  y  on path AB
2
17. Consider the shaded triangular region P
shown in the figure. What is∬ xydxdy? traversed in a counter-clockwise sense is
y Y

B
x+2y=2
1

P x X
A
0 2
(A) ⁄ (C) ⁄ (A) (C)
(B) ⁄ (D) 1 (B) (D) 1

18. The value of is 25. The divergence of the vector field


( )
̂ ̂ ̂ at a point (1,1,1) is
(A) ⁄ (C) ⁄
⁄ ⁄ equal to
(B) (D)
(A) 7 (C) 3
(B) 4 (D) 0
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 75
GATE QUESTION BANK Mathematics

ME – 2010 ME – 2012
26. Velocity vector of a flow field is given as 33. Consider the function ( ) in the
⃗ ̂ .̂ The vorticity vector at interval . At the point x = 0,
(1, 1, 1) is f(x) is
(A) 4 ̂ ̂ (C) ̂ ̂ (A) Continuous and differentiable.
(B) 4 ̂ ̂ (D) ̂ ̂ (B) Non – continuous and differentiable.
(C) Continuous and non – differentiable.
27. The function (D) Neither continuous nor
(A) o o ∀ R differentiable.
∀ R
(B) o o ∀ R 34. . / is
∀ R
(A) 1/4 (C) 1
except at x = 3/2
(B) 1/2 (D) 2
(C) o o ∀ R
∀ R
35. At x = 0, the function f(x) = has
except at x = 2/3
(A) A maximum value
(D) o o ∀ R except at x = 3
(B) A minimum value
∀ R
(C) A singularity
28. The value of the integral ∫ is (D) A point of inflection
(A) –π (C) π
36. For the spherical surface
(B) –π (D) π
the unit outward
29. The parabolic arc √ is normal vector at the point
revolved around the x-axis. The volume of . /
√ √
the solid of revolution is (A) ̂ ̂
(A) π (C) π √ √

(B) π (D) π (B) ̂ ̂


√ √
(C) ̂
ME – 2011
(D) ̂ ̂ ̂
30. If f(x) is an even function and is a positive √ √ √

real number, then ∫ ( )dx equals


37. The area enclosed between the straight
(A) 0 (C)
(B) line y = x and the parabola y = in the
(D) ∫ ( )
x – y plane is
(A) 1/6 (C) 1/3
31. What is equal to? (B) 1/4 (D) 1/2
(A) (C) 0
(B) (D) 1 ME – 2013
38. The following surface integral is to be
32. A series expansion for the function is evaluated over a sphere for the given
(A) steady velocity vector field
defined with respect to a
(B) cartesian coordinate system having i, j and
(C) k as unit base vectors.
∫∫ ( )
(D)
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 76
GATE QUESTION BANK Mathematics

Where S is the sphere, 45. If a function is continuous at a point,


and n is the outward unit normal vector to (A) the limit of the function may not exist
the sphere. The value of the surface at the point
integral is (B) the function must be derivable at the
(A) π (C) π⁄ point
(B) π (D) π (C) the limit of the function at the point
tends to infinity
39. The value of the definite integral (D) the limit must exist at the point and
∫ √ ( ) is the value of limit should be same as
the value of the function at that point
(A) √ (C) √
(B) √ (D) √ 46. Divergence of the vector field
̂ ̂ ̂ ( ) is
ME – 2014 (A) 0 (C) 5
40. is (B) 3 (D) 6
(A) 0 (C) 3
47. The value of the integral
(B) 1 (D)Not defined
( ) ( )
∫ ( ) ( )
41. Which one of the following describes the (A) 3 (C) 1
relationship among the three vectors (B) 0 (D) 2
̂ ̂ ̂ +
̂ ̂ ̂
+ ̂ ̂ ̂
(A) The vectors are mutually 48. The value of the integral ∫ ∫
perpendicular
is
(B) The vectors are linearly dependent
(C) The vectors are linearly independent (A) ( ) (C) ( )
(D) The vectors are unit vectors (B) ( ) (D) . /

42. . ( )
/ is equal to CE – 2005
(A) 0 (C) 1 1. Value of the integral ∮ ( ).
(B) 0.5 (D) 2 Where, c is the square cut from the first
quadrant by the lines x = 1 and y = 1 will
43. Curl of vector ( G ’ h o o h h
⃗ ̂ ̂ ̂ line integral into double integral)
(A) ( )̂ ̂ ̂ (A) ⁄ (C) ⁄
(B) ( )̂ ̂ ̂ (B) 1 (D) ⁄
(C) ̂ ̂ ̂
(D) ̂ ̂ ̂ 2. A rail engine accelerates from its
stationary position for 8 seconds and
44. The best approximation of the minimum travels a distance of 280 m. According to
value attained by (100x) for ≥ the Mean Value theorem, the
is _______ speedometer at a certain time during
acceleration must read exactly.
(A) 0 kmph (C) 75 kmph
(B) 8 kmph (D) 126 kmph

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 77
GATE QUESTION BANK Mathematics

CE – 2006 10. The value of ∫ ∫ ( ) is


3. What is the area common to the circles (A) 13.5 (C) 40.5
o (B) 27.0 (D) 54.0
(A) 0.524 a 2 (C) 1.014 a2
(B) 0.614 a2 (D) 1.228 a2 CE – 2009
11. For a scalar function
4. The directional derivative of f(x, y, z) = + 3 + 2 the gradient at
f(x, y, z) = 2 + 3 + at the point the point P (1, 2, 1) is
P (2, 1, 3) in the direction of the vector
(A) 2 + 6 + 4⃗ (C) 2 + 12 + 4⃗
a= k is
(A) (C) (B) 2 + 12 – 4⃗ (D) √
(B) (D)
12. For a scalar function
CE – 2007 f(x, y, z) = the directional
derivative at the point P(1, 2, 1) in the
5. Potential function  is given as
direction of a vector ⃗ is
= . When will be the stream
function () with the condition (A) (C) √
 = 0 at x = y = 0? (B) √ (D) 18
(A) 2xy (C)
(B) + (D) 2 CE – 2010
13. A parabolic cable is held between two
supports at the same level. The horizontal
6. Evaluate ∫
span between the supports is L. The sag at
(A) π (C) π⁄ the mid-span is h. The equation of the
(B) π⁄ (D) π⁄
parabola is y = 4h where x is the
7. A velocity is given as horizontal coordinate and y is the vertical
̅ = 5xy + 2 y2 + 3yz2⃗ . The divergence coordinate with the origin at the centre of
the cable. The expression for the total
of this velocity vector at (1 1 1) is
length of the cable is
(A) 9 (C) 14
(B) 10 (D) 15 (A) ∫ √

CE – 2008 (B) 2∫ √
8. The equation + = 0 can be
(C) ∫ √
transformed to + = 0 by substituting
(D) ∫ √
(A) (C) √
(B)
(D) √ . /
14. The  is
(A) 2/3 (C) 3/2
9. The inner (dot) product of two vectors ⃗ (B) 1 (D)
and ⃗ is zero. The angle (degrees)
between in two vectors is 15. Given a function
(A) 0 (C) 90 ( )
(B) 30 (D) 120 The optimal value of f(x, y)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 78
GATE QUESTION BANK Mathematics

(A) Is a minimum equal to 10/3 CE – 2013


(B) Is a maximum equal to 10/3 21. The value of ∫ o
(C) Is a minimum equal to 8/3 (A) 0 (C) 1
(D) Is a maximum equal to 8/3 (B) 1/15 (D) 8/3

CE – 2011 CE – 2014

16. ∫ ? 22. . / o
√ √
(A) 0 (C) a (A) (C) 1
(B) a/2 (D) 2a (B) (D)

17. Wh ho h o λ such that 23. With reference to the conventional


the function defined below is continuous Cartesian (x, y) coordinate system, the
π ? vertices of a triangle have the following
π coordinates:
f(x)={ ( ) ( ) ( ) ( )
π
( ) ( ). The area of the
(A) 0 (C) 1
triangle is equal to
(B) π (D) π
(A) ⁄ (C) ⁄
(B) ⁄ (D) ⁄
18. If ⃗ and ⃗ are two arbitrary vectors with
magnitudes a and b respectively. |⃗ ⃗ | 24. A particle moves along a curve whose
will be equal to parametric equation are :
(A) – (⃗ ⃗ ) (C) + (⃗ ⃗ ) and z = 2 sin (5t), where x, y
(B) ab ⃗ ⃗ (D) ab + ⃗ ⃗ and z show variations of the distance
covered by the particle (in cm) with time
CE – 2012 t (in s). The magnitude of the acceleration
19. For the parallelogram OPQR shown in the of the particle (in cm ) at t = 0 is
sketch, ̅̅̅̅ ̂ ̂ and ̅̅̅̅
R ̂ .̂ ___________
The area of the parallelogram is
25. If {x} is a continuous, real valued random
Q
variable defined over the interval
( ) and its occurrence is defined
R by the density function given as:
. /
P ( ) wh ‘ ’ ‘ ’

the statistical attributes of the random
O variable {x}. The value of the integral
(A) ad –bc (C) ad + bc ∫
. /
dx is

(B) ac+bd (D) ab – cd
(A) 1 (C) π
(B) 0.5 (D) π⁄
20. The infinity series

o o o 26. The expression o


(A) sec (C) o (A) log x (C) x log x
(B) (D) (B) 0 (D)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 79
GATE QUESTION BANK Mathematics

CS – 2005 CS – 2010
1 
1. Let G(x)    g(i)xi where |x|<1. 7. What is the value of . / ?
(1  x) i0
2
(A) 0 (C)
What is g(i)?
(B) (D) 1
(A) i (C) 2i
(B) i+1 (D) 2i
CS – 2011
8. Given i = √ , what will be the
CS – 2007
evaluation of the definite integral
2. Consider the following two statements
about the function f(x) =|x|: ∫
P: f(x) is continuous for all real values of x (A) 0 (C) –i
Q: f(x) is differentiable for all real values (B) 2 (D) i
of x
Which of the following is true? CS – 2012
(A) P is true Q is false 9. Consider the function f(x)= sin(x) in the
(B) P is false Q is true interval x ,π⁄ π⁄ -. The number and
(C) Both P and Q are true location(s) of the local minima of this
(D) Both P and Q are false function are
(A) One , at π⁄
CS – 2008 (B) One , at π⁄
x sinx (C) Two , at π⁄ and π
3. Lim equals
x   x cosx (D) Two , at π⁄ and π
(A) 1 (C)
CS – 2013
(B) 1 (D)
10. Which one the following function is
continuous at x =3?
4. Let
P=∑ ∑
(A) ( ) {
where k is a positive integer. Then
(A) (C)
(B) ( ) 2
(B) (D)
(C) ( ) 2
5. A point on a curve is said to be extreme if
it is a local minimum or a local maximum. (D) ( )
The number of distinct extrema for the
CS – 2014
curve 3x  16x  24x  37 is
4 3 2

11. Let the function


(A) 0 (C) 2
o
(B) 1 (D) 3 ( ) | (π ) o (π ) (π )|
(π ) o (π ) (π )
CS – 2009
Where 0 1 and ( ) denote the
6. ∫ evaluates to derivation of f with respect to . Which of
(A) 0 (C) ln2 the following statements is/are TRUE?
(B) 1 (D) ln 2 (I) There exists
. / h h ( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 80
GATE QUESTION BANK Mathematics

(II) There exists (A)


. / h h ( )
(A) I only
(B) II only
(C) Both I and II (B)
(D) Neither I nor II

12. A function f (x) is continuous in the


interval [0, 2]. It is known that
(C)
f(0) = f(2) = 1 and f(x) = 1. Which one
of the following statements must be true?
(A) There exists a y in the interval (0,1)
such that f(y) = f(y + 1) (D)
(B) For every y in the interval (0, 1),
f(y) = f(2 y)
(C) The maximum value of the function
in the interval (0, 2) is 1
(D) There exists a y in the interval (0, 1) ECE – 2006
such that f(y) ( ) 2. As x is increased from to , the
x
e
function f  x  
13. If and are 4 – dimensional subspace 1  ex
of a 6 – dimensional vector space V, then (A) monotonically increases
the smallest possible dimension of (B) monotonically decreases
is ____________. (C) increases to a maximum value and
then decreases
14. If ∫ dx = π, then the value of k (D) decreases to a minimum value and
is equal to_______. then increases


The integral sin  d is given by
3
3.
15. The value of the integral given below is 0

1 4
∫ o (A) (C)
2 3
(A) π (C) – π 2 8
(B ) (D)
(B) π (D) π 3 3

ECE – 2005 4.   P  ds , where P is a vector, is


1. The derivative of the symmetric function
equal to
drawn in given figure will look like
(A) ∮ P  dl (C) ∮  P  dl
(B) ∮  P dl (D)   Pdv
5.  P , where P is a vector, is equal to
(A) P P  P (C) 2P  P
2

(B)  P P
2
(D)  P 2P

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 81
GATE QUESTION BANK Mathematics

ECE – 2007 ECE – 2008


6. For the function , the linear 12. Consider points P and Q in the x –y plane,
approximation around = 2 is with P=(1,0) and Q=(0,1). The line
(A) (3 x) Q

(B) 1 x integral 2  xdx  ydy  along the



 
P
(C) 3  2 2  1  2 x e 2
  semicircle with the line segment PQ as its
(D) diameter
(A) is 1
7. For x <<1, coth(x) can be (B) is 0
approximated as (C) is 1
(A) x (D) depends on the direction (clockwise
(C)
(B) x2 or anticlockwise) of the semicircle
(D)
13. In the Taylor series expansion of
8. Consider the function f(x) = x – 2. exp(x)+sin(x) about the point x=π the
The maximum value of f(x) in the closed coefficient of (x π)2 is
interval [ 4,4] is (A) (π) (C) (π)
(A) 18 (C) 2.25 (B) (π) (D) (π)
(B) 10 (D) Indeterminate
14. Which of the following functions would
9. Which one of the following function is have only odd powers of x in its Taylor
strictly bounded? series expansion about the point x=0?
2 (A) sin(x3) (C) cos(x3)
(A) (C) x
(B) e x (B) sin(x )
2 (D) cos(x2)
(D)
15. The value of the integral of the function
sin   /2 g(x, y)=4x3+10y4 along the straight line
10. lim is
0  segment from the point (0,0) to the point
(A) 0.5 (C) 2 (1,2) in the x y plane is
(B) 1 (D) not defined (A) 33 (C) 40
(B) 35 (D) 56
11. The following Plot shows a function y
which varies linearly with x. The value of 16. For real values of x, the minimum value of
2
the function f(x)=exp(x)+ exp( x) is
the integral I  ydx is
1
(A) 2 (C) 0.5
Y
(B) 1 (D) 00

3 17. Consider points P and Q in the x-y plane,


with P=(1, 0) and Q= (0, 1).
2

1
h ∫ ( ) along

1
X the semicircle with the line segment PQ as
1 2 3
its diameter
(A) 1.0 (C) 4.0
(A) Is
(B) 2.5 (D) 5.0
(B) Is 0
(C) Is 1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 82
GATE QUESTION BANK Mathematics

(D) Depends on the direction 21. If , then has a


(clockwise or anti-clockwise) of the (A) maximum at
semicircle (B) minimum at
(C) maximum at
ECE – 2009
(D) minimum at
18. The Taylor series expansion of
sinx
at x   is given by ECE – 2011
x 
22. Consider a closed surface S surrounding a

(A) 1 
 x  2  ..... volume V. If is the position vector of a
3! point inside S, with ̂ the unit normal of S,

1 
 x  
2

 .....
the value of the integral ∯ ̂⃗ is
(B) (A) 3V (C) 10V
3!
(B) 5V (D) 15V
1
 x  
2

 .....
(C)
3! ECE\IN – 2012
 x   2
23. The direction of vector A is radially
(D) 1   ..... outward from the origin, with
3!
where and K is
19. If a vector field ⃗ is related to another constant. The value of n for which
. A = 0 is
vector field ⃗ through ⃗ = ⃗ , which
(A) 2 (C) 1
of the following is true? Note: C and
(B) 2 (D) 0
refer to any closed contour and any
surface whose boundary is C.
ECE\EE – 2012
(A) ∮ ⃗ ⃗ = ∬ ⃗ ⃗
24. The maximum value of
(B) ∮ ⃗ ⃗ = ∬⃗ ⃗ ( ) in the interval
⃗ ⃗ = [1,6] is
(C) ∮ ∬⃗ ⃗
(A) 21 (C) 41
(D) ∮ ⃗ ⃗ = ∬⃗ ⃗ (B) 25 (D) 46

ECE – 2010 ECE – 2013


20. If ⃗ ̂ ̂ , then ∮ ⃗ ⃗⃗⃗ over the 25. The maximum value of unit which the
path shown in the figure is approximation holds to within
10% error is
(A) (C)
(B) (D)

26. The divergence of the vector field


⃗ ̂ ̂ ̂ is
(A) 0 (C) 1
(B) 1/3 (D) 3
√ √

(A) 0 (C) 1
(B) ⁄√ (D) 2√

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 83
GATE QUESTION BANK Mathematics

27. Consider a vector field ⃗ ( ) The closed 34. The magnitude of the gradient for the
loop line integral ∮ ⃗  can be expressed function ( ) at the
as point (1,1,1) is_______.
(A) ∯( ⃗ )  over the closed
35. The directional derivative of
surface boundary by the loop
( ) ( ) ( )in the direction
(B) ∰(  ⃗ )dv over the closed volume √

bounded by the loop of the unit vector at an angle of with


(C) ∭(  ⃗ )dv over the open volume y axis, is given by ________________.
bounded by the loop
(D) ∬( ⃗ ) over the closed surface EE – 2005
bounded by the loop 1. For the scalar field u = , magnitude
of the gradient at the point (1, 3) is
ECE – 2014 (A) √ ⁄ (C) √
28. The volume under the surface (D) ⁄
(B) √ ⁄
z(x, y) = x+y and above the triangle in
the x-y plane defined by
2. For the function f(x) = , the
{0 y x and 0 x 12} is______
maximum occurs when x is equal to
(A) 2 (C) 0
29. For the maximum value of the
(B) 1 (D) 1
function ( ) occurs at
(A) o (C)
(B) o (D) o 3. If S = ∫ , then S has the value
(A) ⁄ (C) ⁄
(B) ⁄ (D) 1
30. The value of . / is
(A) (C) EE – 2006
(B) (D) 4. A surface S(x, y) = 2x + 5y – 3 is
integrated once over a path consisting of
31. The maximum value of the function the points that satisfy
( ) ( ) (wh ) (x+1)2+ (y 1)2 =√ . The integral
occurs at x =____. evaluates to
(A) 17√ (C) √ /17
32. The maximum value of
(B) 17/√ (D) 0
( ) in the interval
0 x 3 is ______.
5. The expression V = ∫ πR ( h ) h
33. For a right angled triangle, if the sum of for the volume of a cone is equal to
the lengths of the hypotenuse and a side (A) ∫ πR ( h )
is kept constant, in order to have
(B) ∫ πR ( h ) h
maximum area of the triangle, the angle
between the hypotenuse and the side is (C) ∫ π ( R) h
(A) 12 (C) 60 (D) ∫ π ( ⁄R )
(B) 36 (D) 45

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 84
GATE QUESTION BANK Mathematics

EE – 2007 EE – 2010
6. The integral ∫ ( ) o 11. At t = 0, the function ( ) has
equals (A) a minimum
(A) o (C) (1/2) o (B) a discontinuity
(B) 0 (D) (1/2) (C) a point of inflection
(D) a maximum
EE – 2008
7. Consider function f(x)= ( ) where 12. Divergence of the three-dimensional
x is a real number. Then the function has radial vector field is
(A) only one minimum (A) 3 (C) ̂ ̂ ̂
(B) only two minima (B) 1/r (D) ̂( ̂ ̂)
(C) three minima
(D) three maxima 13. The value of the quantity P, where
∫ , is equal to
EE – 2009
(A) 0 (C) e
8. f(x, y) is a continuous function defined
(B) 1 (D) 1/e
over (x, y) [0, 1] [0, 1]. Given the two
constraints, x > and y > , the
EE – 2011
volume under f(x, y) is
14. The two vectors [1, 1, 1] and [1, a, ],

(A) ∫ ∫ ( ) √
where a = . /, are
(B) ∫ ∫ ( ) (A) orthonormal
(C) ∫ ∫ ( ) (B) orthogonal
(C) parallel
√ √
(D) ∫ ∫ ( ) (D) collinear

9. A cubic polynomial with real coefficients 15. The function f(x) = 2x – has
(A) can possibly have no extrema and no (A) a maxima at x = 1 and a minima at
zero crossings x=5
(B) may have up to three extrema and (B) a maxima at x = 1 and a minima at
upto 2 zero crossings x= 5
(C) cannot have more than two extrema (C) only a maxima at x = 1
and more than three zero crossings (D) only a minima at x = 1
(D) will always have an equal number of
extrema and zero crossings EE – 2013
16. Given a vector field
10. F(x, y) = ( )̂ ( )̂ ’ , the line integral
line integral over the straight line from ∫ evaluated along a segment on the x-
( ) = (0, 2) to ( ) = (2, 0) axis from x = 1 to x = 2 is
evaluates to (A) 2.33 (C) 2.33
(A) –8 (C) 8 (B) 0 (D) 7
(B) 4 (D) 0
17. The curl of the gradient of the scalar field
defined by
(A)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 85
GATE QUESTION BANK Mathematics

(B) 23. ( ) Where f and


(C) ( ) ( ) v are scalar and vector fields respectively.
( ) If h is
(D) (A)
(B)
EE – 2014 (C)
18. Let ( ) . The maximum value of (D)
the function in the interval ( ) is
(A) (C) 24. The minimum value of the function
(B) (D) ( ) 0 in the
interval , - is
19. The line integral of function , in the (A) 20 (C) 16
counterclockwise direction, along the (B) 28 (D) 32
circle is
(A) π (C) π IN – 2005
(B) π (D) π 1. A scalar field is given by f = x2/3 + y2/3,
where x and y are the Cartesian
20. Minimum of the real valued function coordinates. The derivative of f along the
( ) ( ) occurs at x equal to line y = x directed away from the origin,
(A) (C) 1 at the point (8, 8) is
√ (C)
(B) (D) (A) √

(B)
√ (D)
21. To evaluate the double integral √
( ⁄ )
∫ .∫ . / / dy, we make the
2. Given a real-valued continuous function
substitution u = ( ) and . The f(t) defined over [0,1], ∫ ( ) is
integral will reduce to (A) (C) f(1)
( ) ∫ (∫ ) (B) 0 (D) f(0)

3. The value of the integral ∫ is


( ) ∫ (∫ )
(A) 2 (C) 2
(B) does not exist (D)
( ) ∫ (∫ )
4. ̅(t) has a constant magnitude,
If a vector R
( ) ∫ (∫ ) then
̅ ̅
̅
(A) R ̅ R
(C) R ̅
22. A particle, starting from origin at t = 0 s, ̅
̅
̅ ̅
̅
(B) R (D) R R
is traveling along x-axis with velocity
π π
o . / 5. If f = + ……
At t = 3 s, the difference between the + where ai (i = 0 to n) are constants,
distance covered by the particle and the then is
magnitude of displacement from the (A) ⁄ (C) nf
origin is _________ (B) ⁄ (D) n√

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 86
GATE QUESTION BANK Mathematics

6. The plot of a function f(x) is shown in the (B) once differentiable but not twice
following figure. A possible expression for (C) twice differentiable but not thrice
the function f(x) is (D) thrice differentiable
f(x)
11. For real x, the maximum value of is.
1 (A) 1 (C) √

(B) e 1 (D)

x IN – 2008
0 12. Consider the function y = x2 6x + 9. The
(A) ( ) (C) ( ) maximum value of y obtained when x
(B) . / (D) . / varies over the interval 2 to 5 is
(A) 1 (C) 4
IN – 2006 (B) 3 (D) 9
7. The function ( ) is
approximated as where is in 13. The expression for x > 0 is equal to
radian. The maximum value of for (A) – (C)
which the error due to the approximation (B) x (D)
is within
(A) 0.1 rad (C) 0.3 rad 14. Given y = + 2x + 10, the value of |
(B) 0.2 rad (D) 0.4 rad
is equal to
(A) 0 (C) 12
8. The solution of the integral equation
(B) 4 (D) 13
()

() ( )∫ ( ) ( ) 15.
(A) Indeterminate (C) 1
(A) ( () ( )) (B) 0 (D)

(B) ( () ( )) IN – 2009
( () ( )) 16. A sphere of unit radius is centered at the
(C)
( () ( )) origin. The unit normal at a point (x, y, z)
( () ( )) on the surface of the sphere is
(D) ( ( ) ( ))
(A) (x, y, z) (C) . /
√ √ √
(B) . /
IN – 2007
√ √ √ (D) . /
√ √ √
9. The value of the integral
∫ ∫ dx dy is. IN – 2010
(C) Π 17. The electric charge density in the region
(A) √π⁄
(D) π⁄ R: is given as
(B) √π
σ( ) , where x and y are in
meters. The total charge (in coulomb)
10. Consider the function f(x) = , where x
contained in the region R is
is real. Then the function f(x) at x = 0 is
(A) π (C) π⁄
(A) continuous but not differentiable
(B) π (D) 0

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 87
GATE QUESTION BANK Mathematics

18. The integral ∫ . / sin(t) dt 23. A scalar valued function is defined


as ( ) , where A is a
evaluates to
symmetric positive definite matrix with
(A) 6 (C) 1.5
dimension n× n ; b and x are vectors of
(B) 3 (D) 0
dimension n×1. The minimum value of
( ) will occur when x equals
19. The infinite series
(A) ( ) (C) . /
( ) ………… (B) – ( )
converges to (D)
(A) cos (x) (C) sinh(x) 24. Given
(B) sin(x) (D) () ( π)
π
() o . π /
IN – 2011
The o w
20. The series ∑ ( ) converges
(A) A circle
for (B) A multi-loop closed curve
(A) (C) (C) Hyperbola
(B) (D) (D) An ellipse

IN – 2013
21. For a vector E, which one the following
statement is NOT TRUE?
(A) E E o o
(B) If E E is called conservative
(C) If E E is called irrotational
(D) E E -rotational

IN – 2014
22. A vector is defined as
̂ ̂ ̂
Where ̂ ̂ ̂ are unit vectors in
Cartesian ( ) coordinate system.
The surface integral ∯ f.ds over the
closed surface S of a cube with vertices
having the following coordinates:
(0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1),
(1,0,1),(1,1,1),(0,1,1) is________

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 88
GATE QUESTION BANK Mathematics

Answer Keys and Explanations

ME = 0 o 1
1. [Ans. A]
√ √
Since, potential function of ⃗ is x²yz = 0 1
( ) ( ) ( )
9. [Ans. B]
2. [Ans. D]
o h 10. [Ans. B]

π h π o ( ) ( )

For V to be max
This is of the form . /
Hence, h Applying L hospital rule
( )
. /
3. [Ans. A]
=
( ) | | | | =
=

11. [Ans. B]
Let the vectors be
4. [Ans. A]
After changing order ∫ ∫ ( )

5. [Ans. A] ( )(⃗ )(⃗ )


I= ∫ ( )
=2∫ [ ∫ ]
= 2∫
Now Area vector will be perpendicular to
plane of i.e.
6. [Ans. A] will be the required unit vector.
A Line integral and a surface integral is And option (A), (D) cannot give a vector
connected by stokes theorem
product
|(⃗ ⃗ ) (⃗ )|
7. [Ans. B]

12. [Ans. B]
Applying ’ Hospital rule, we get
Given: √ √ √
I=
( ) √
I=
( )

8. [Ans. A]
For
∫ 0 1 [ ]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 89
GATE QUESTION BANK Mathematics

But y is always greater than x. = ∫ ( )


Hence y= 4 only.
= ∫ ( )
13. [Ans. B] = 0 1
Since interval given is bounded, so
minimum value of functions is 1. =

14. [Ans. D] 18. [Ans. B]


L=
( )
h h ∫√ ( )
Let x= a3 ⇒ a=2
( )
L =∫ (√ ).dx
Now by partial fractions,
= ( ) | (a3 8) = (a 2)(a2+2a+4)
=1.22 ⇒L= =

15. [Ans. D] 19. [Ans. C]


To see whether the integrals are bounded Taylor series expansion of f(x) about a is
or unbounded, we need to see that the given by
o ’ h h ( )
( ) ( ) ( ) ( )
interval of integration. Let us write down ( )
the range of the integrands in the 4 Coefficient of (x- )⁴
options, Now f(x)= ex
A (0,1); B (0,1); C (0, ); D (0, ) ⇒ (x)= ex
⇒ (a)= ea
Thus, (D) , i.e., ∫ dx is unbounded. ( )
Hence for a=2,

16. [Ans. B]
h o o o Φ 20. [Ans. D]
⃗⃗ div {( )̂ ( )̂ ( )̂}
along a vector ⃗ ( Φ)
( ) ( ) ( )
Hence directional derivative is
( ̂ ̂) =3
(grad (x2+2y2+z)).

̂ ̂)
(2x ̂ ̂ ̂ ). ( 21. [Ans. C]

=
Hence at (1,1,2),

Directional derivative =

⇒ ( )
17. [Ans. A]
I = ∬ .dx dy
⇒ ( )
The limit of y is form 0 to and limit
of x from 0 to 2 ( )( )
I =∫ ∫ ∫ . /

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 90
GATE QUESTION BANK Mathematics

22. [Ans. A] 23. [Ans. A]


Given: Short method:
y2  4x Take a point on the curve z = 1, x = 0,
y=0
x2  4y
Length between origin and this point
√( ) ( ) ( ) =1
(4,4) This is minimum length because all
(0,0) options have length greater than 1.

24. [Ans. B]
x4
  4x Y
16
or x4  64x B

or x(x  64)  0
3

or x3  64 A
X

or x  4 x = cos 
 y 4 y=sin 
 Required area = ∫ .√ / Path is x2  y2  1

 2 x3 
4
R  e
 2 x3 2   
 3 120 (x  y)2  1  2sin  cos 
2 2
4 64  cos2 
 (4)3 2    (1  sin2)d  
3 12 0  2 0
32 16 16  1 1 
   =    1
3 3 3 2 2 2 2
Alternately Alternately
For point where both parabolas cut each Given: x2  y2  1
other
Put x=cos  , and y=sin 
y2  4x, x2  4y
 x  4 4x
2
 x  y 2  cos2  sin2  2sincos
= 1  sin2
or x2  8 x
or x4  64x
∫ ( )
or x3  64
 x  4,0 ,(4,0)  cos2    1 1
2

      
 Required area  2 0  2 2 2 
4 4
x2  
  4x   dx    1
0 0 4 2 
4
 2 x3  16
 2 x3 2     25. [Ans. C]
 3 120 3
F  3xzi  2xyj  yz2k
⃗ ⃗

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 91
GATE QUESTION BANK Mathematics

( ) ( ) ( ) √
 3z  2x  2yz
π ∫ π* +
At point (1, 1, 1), divergence =3+2 2=3
π
π( )
26. [Ans. D]

o ⃗ ⃗ 30. [Ans. D]
̂ ̂ ̂ If f(x) even function
∫ ( ) ∫ ( )
|| ||

31. [Ans. D]
̂ ( )̂ Standard limit formulae
o ( ) ̂ ̂
32. [Ans. B]
27. [Ans. C]

⇒ 33. [Ans. C]
The function is continuous in [ 1, 1]
It is also differentiable in [ 1, 1] except at
x = 0.
Since Left derivative = 1 and
Right derivative = 1 at x = 0
1 1 2

34. [Ans. B]
o
y is continuous for all x R, and
differentiable for all x R, except at , Using this standard limit, here a = 1 then
since at o o ’ h = ( ) /2 =1/2
value towards the left and right side of
35. [Ans. D]
( )
( )
28. [Ans. D] ( )
( )
∫ , - π
f(x) has a point of inflection at x =0.

29. [Ans. D] 36. [Ans. A]

∫ π ( )

Volume from x = 1 to x = 2, ̂ ̂ ̂

̂ ̂ ̂
∫π
( )
√ √
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 92
GATE QUESTION BANK Mathematics

̂ 38. [Ans. A]
̂ ̂
√ √ By Gauss Divergence theorem,
√ ̂ √ ̂ ̂
√ √ ∬( ̅ ̅) ∭( )
The unit outward normal vector at point
P is (Surface Integral is transformed to
volume Integral)
( )
( ) ( ) ( )
(√ ̂ √ )̂

̂ ̂
√ √
∭( ) ∭

37. [Ans. A]
The area enclosed is shown below as
shaded π
π

( ) ∬( ̅ ̂) ∭( )

( π)
( ) π
The coordinates of point P and Q is
obtained by solving 39. [Ans. C]
y = x and y = simultaneously,
i.e. x = ∫(√ ) ( )
⇒ ( )
⇒ Using Integration by parts
Now, x = 0 ⇒ which is point Q(0,0) ∫ ∫
and x = 1 ⇒ which is point
P(1,1) Here,
So required area is f=ln(x) and dg=√
and g=
∫ ∫ o

∫(√ ) ( )
* + * +

[ ] ∫ ( )

[ ] [ ]

( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 93
GATE QUESTION BANK Mathematics

40. [Ans. A] π
0 o 1
So the minimum value is
[Differentiating both . /
=
o o o w ’
Hospital method]
. / 45. [Ans. D]
o o o o ( ) o
o o
( ) ( )
otherwise it is said to be discontinuous.
41. [Ans. B] So the most appropriate option is D.
G o
46. [Ans. C]
̂ ̂ ̂ ( )
| |
Div
Vectors are linearly dependent

42. [Ans. B]

( )
) (
( ) 47. [Ans. B]
, ho - Let
o ( )( )
( )
( ) ( )
o ( )( ) ∫
( ) o ( )
43. [Ans. A] ∫
̂ ̂ ̂ o
( ) () o o

[ ]
48. [Ans. B]
̂[ ( ) ( )]
∫ ∫ ∫ |
̂[ ( ) ( )]
∫ , -
̂[ ( ) ( )]

,̂ - ,̂ - ̂, - ∫ ( ) |
( )̂ ( )̂ ( )̂
[ ]
44. [Ans. *] Range 1.00 to 0.94
h o , - , -
π

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 94
GATE QUESTION BANK Mathematics

CE a =2a cos i.e, cos ⇒


1. [Ans C]
R
G ’ theorem is ( )

∮(  ) ∬( ) ( )

Here I = ∮ ( )
, ∫ ∫ -
∮ (( ) ( ) )

 = xy =∫ ∫ ( o )

= y and = 2y o
∫( )
’ h o w
I= ∫ ∫ , ( )-
π
. / | |
=∫ ∫
=∫ ∫ π π π √
. / ( )

2. [Ans. D] π π √
* ( )+
Since the position of rail engine S(t) is
continuous and differentiable function π π √
* +
according to Lagrange’s mean value
theorem more π √
( ) ( ) ( )
(t) = v(t) =
( )
= m/sec
= × kmph 4. [Ans. C]
= 126 kmph f = 2 +3 ( )⃗
Where v(t) is the velocity of the rail
engine.
= 4xi + 6yj + 2zk
3. [Ans. D] At P (2, 1, 3)
h ’ o h
r=2acos Directional derivation ̂
(i) r = a represents a circle with centre ( )
( )
( ) ‘ ’ √ ( )
(ii) r = 2acos represents a circle ( ) ( ) ( )
symmetric about OX with centre at

( ) ‘ ’
The circles are shown in figure below. At

h o o o ‘ ’
P 5. [Ans. A]
y Q
Potential function,
π 3
x
O A

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 95
GATE QUESTION BANK Mathematics

8. [Ans. D]

Put √
Integrating ∫ ∫
 =√
wh o
 =√ …… ( )

Now given equation is
……….. (ii)
6. [Ans. B] h h h
Let I(α) ∫ dx …( ) ( ) ( )

=∫ ( ) . / = ( √ ) [ from eqn(i)]
= ∫
h
Then Integrating by parts we get, √ ( )
= 0 ( α o )1
h h
= . / √ ( ( ) )
=
h
dI = √ ( √ )
Integrating, I = α
( ) o () ( ) h

+C=0
C=
π Now substitute in eqn (ii) we get
(α) α
h h
π
 ( )
I(0) = h h

But from equation (i), I(0) = ∫ dx
h h

∫ dx =
Which is the desired form
7. [Ans. D]
√ is the correct transformation.
̅=5 +2 + 3y ⃗

(⃗ ) 9. [Ans. C]
̅ ̅=0
= 5y + 4y + 6yz
̅ ̅ o
At(1, 1, 1)
If ̅ ̅ = 0
div ( ) = 5.1 + 4.1 + 6.1.1
= 15  o
Since P and Q are non-zero vectors
 o
 0

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 96
GATE QUESTION BANK Mathematics

10. [Ans. A] √
Since the limit is a function of x. We first √
√ √
integrate w.r.t. y and then w.r.t. x √

∫ ∫( )
13. [Ans. D]
Length of curve f(x) between x = a and
x = b is given by
∫ ∫( )

∫√ ( )
∫ * +
Here, 4h … … ( )
= 8h
∫ ( )
Since
and y = h at x =
∫ ( )
(As can be seen from equation (i), by
substituting x = 0 and x = L/2)
* ( ) ( )+
(Length of cable)

* + =∫ √ . /

h
ho ∫ √

11. [Ans. B]
f = + 3 +2 14. [Ans. A]
f = grad f = i +j +k
= i(2x) + j(6y) + k(4z)
The gradient at P(1, 2, 1) is
= i(2×1) + j(6×2) + k(4 ( ))
= 2i + 12j – 4k 15. [Ans. A]
( )
12. [Ans. B]

( )

⃗ ̂
⃗ Putting,


o ̂ Given,

( ) . / is the only stationary point.



* +
. /

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 97
GATE QUESTION BANK Mathematics

Since the limit is in form of , we can use


* +
. / ’ ho o o o ()
and get
* + λ
. /

Since, π
⇒λ
Since, ⇒λ
We have either a maxima or minima at
. / 18. [Ans. A]

Also since, r=0 1 = 8 > 0, the point ( )


. / o
o
( ) o o ( )
The minimum value is , o -

( )
19. [Ans. A]
Area = |̅ ̅ |
̅̅̅̅ ̅̅̅̅
R ( ) ( )

So the optimal value of f(x, y) is a | |


minimum equal to
̅̅̅̅ ̅̅̅̅
R ( ) ( ) ̅( )
̅̅̅̅ ̅̅̅̅
R
16. [Ans. B]

Let I = ∫ …( )
√ √ 20. [Ans. B]
Since ∫ ( ) ∫ ( )

I=∫ …( )
√ √
√ √
(i) + (ii)  2I = ∫ 21. [Ans. B]
√ √
 2I = ∫ ∫ o

2I = |
∫ o o
 I = a/2
⇒ o
17. [Ans. C]
For a function f(x) to be continuous, ⇒ ∫ ( )
at x=a
( ) ( ) ∫ ( )
If f(x) is continuous at x=
π λ o * +
. /
[ ]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 98
GATE QUESTION BANK Mathematics

( ) ( ) ( )
[ ] | |

Substituting the values we get


( ) ( ) ( )
| |

24. [Ans. 12]

π π

∫ o

∫ o ( o )

( )
∫ o o
o ( )
∫ o
( )
[ ] ⇒
Magnitude of acceleration
22. [Ans. C] =√ ( )

( ) 25. [Ans. B]
We have
⇒ ( )
∫ ( )

, ow - ∫ ( ) ∫ ( )
=1+0=1
Hence correct option is (C)
∫ ( )
23. [Ans. A]
(4, 3)
a
(2, 2)
c
b x ( )μ

(1, 0) 0.5 0.5


o ∆ wh o –ordinate points are
given is given by

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 99
GATE QUESTION BANK Mathematics

26. [Ans. A]
=
α = =1
Use L – hospital Rule

4. [Ans. A]
α
P=∑ … ( –1)
o
= log x ‘ ’ w h a =1, l=2k 1
P= ( ) ( )
CS =
1. [Ans. B] Q=∑ … k
1 
  n 1 r
Cr xr ‘ ’ w h k
1  x  r0
n

( ) ( )
1 
Putting n=2,   21 r
Cr xr
1  x 2 r0
 
  r1 Cr xr   r1 C1xr ⇒
r 0 r 0
 
  r  1 xr   i  1 xi 5. [Ans. D]
r 0 i 0 y = 3 – 16 – 24 + 37
(since r is a dummy variable, r can be = 12 48 – 48 x = 0
replaced by i)
x (12 – 48x 48 ) = 0
x = 0 or 12 – 48x – 48 = 0
∑ ()
4x – 4 = 0
g(i) =i+1 √ √ √
x= = =
=2 √
2. [Ans. A]
f(x)= |x| = 36 96x 48
Continuity: In other words, Now at x = 0
f(x) = x o ≥ = 48 0
x for x< 0
Since, = =0 , At 2 ± √ also 0 (using
f (x) is continuous for all real values of x calculator)
Differentiability: There are 3 extrema in this function
( ) ( )

( ) 6. [Ans. D]
( )
Since ∫ ( ) =∫ ( )
R h 
I =∫
So |x| is continuous but not differentiable
 ( )
at x=0 =∫
( )

Since tan (A B) =
3. [Ans. A]

= ⁄

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 100
GATE QUESTION BANK Mathematics


[ ]

[ ]
 9. [Ans. B]
0 1
∫ f(x) = sin x
0 1 ⇒ ( ) o
 ( ) ⇒ o
( ) ( ) π π π π
∫ [ ]
( ) ( )
  ( )
∫ ∫ At . / gives maximum
value
=, ( )- At . / gives minimum
= ln ( sec ) – ln (sec 0) value
= ln (√ ) ( )
= ln ( )–0= 10. [Ans. A]
For x = , f(x) =
7. [Ans. B] For x = , f(x) = 3 – 1 = 2
For x = 3, f(x) = 2
( ) *( ) + ( ) ( ) = f(3)

* ( ) + 11. [Ans. C]
By Mean value theorem
. /
( ) [ ]
12. [Ans. A]
Define g(x) = f(x) – f(x + 1) in [0, 1]. g(0)
is negative and g(1) is positive. By
8. [Ans. D] intermediate value theorem there is
€( ) h h g(y) = 0
o That is f(y) = f(y + 1)

o Thus Answer is (A)

∫ 13. [Ans. 2]
* w +
* w +
∫ For min maximum non – common
elements must be there
⇒ * +
* + must be common to any 2 elements
of V1
[ ] ( )minimum value = 2

, -( o π π )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 101
GATE QUESTION BANK Mathematics

14. [Ans. 4]
∫ | ∫∫
∫ π
o ( )
oπ π o (π)
π o π π
Hence option (A) is correct
∫ ∫( )
ECE
1. [Ans. C]

∫ ∫ (∫ )

dy
o ∫ o  0 for x< 0
dx
o dy
 0 for x> 0
Substituting the limits dx
π o (π) o ( )
π 2. [Ans. A]
ex
∫ Given, f x 
1  ex

 f ' x  
1  e .e  e
x x 2x


ex
0
1  e  x 2
 
∫ | ∫∫ 2
1  ex
= x cos 3. [Ans. C]

= π o ( π) π o π ∫
= π
LHS = I + II = π π π⇒
∫( o )

15. [Ans. A] Let cos = t ⇒


At o
∫ o
π o π
o
∫ o | ∫ ∫ o
∫( ) ∫( )


| |

∫ ( ) ( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 102
GATE QUESTION BANK Mathematics

8. [Ans. A]
Given, f  x   x2  x  2
df  x 
0
dx
4. [Ans. A]  2x 1=0
o ’ h o 1
 x
∬( ) ∮ 2
d2f  x 
 = 2 ve
5. [Ans. D] dx2
From vector triple product So it shows only minima for interval
( ) ( ) ( ) [ 4, 4], it contains a maximum value that
Here, will be at x= 4 or x=4
⇒ ( ) ( ) ( )  f( 4)=18 and f(+4)=10
( ) ( )
9. [Ans. D]
6. [Ans. A] y  f  x ; x  0, 
( )
For strictly bounded, 0  limy  
 x  x0  f' x0   x  x0  f'' x0 
2 x0

 f  x0     ...... or 0  lim y  
1 2 x

 x  22 2
So, y  e x is strictly bounded
 e  (x  2)(e
2 2
)
2
e ......
2


 e2  3  x 
 x  22  ......  10. [Ans. A]
 2  sin  /2 1  sin  /2
  lim  lim  
0  0 2
  /2 
(Neglecting higher power of x)
1  sin  /2 1
= lim 
7. [Ans. C] 2  0  /2  2
ex  e x
coth (x)= =
ex  ex
11. [Ans. B]
x x2 x3 Two points on line are ( 1, 0) and (0, 1)
e  1     ..........
x

1 2 3 Hence line equation is,


x x2 x3  y y 
ex  1     .......... y   2 1 x  c
1 2 3  x2  x1 
x2 x4 y  x c
1
  ..........
ex  ex 2 4 y  x 1 … ( )
 x x 
e e x3 x5 2 2
x    .......... 5
3 5 I   ydx    x  1dx   2.5
1 1 2
1
or cot h (x)= (Since at x=1,y=2)
x
(Neglecting x2 and higher order)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 103
GATE QUESTION BANK Mathematics

12. [Ans. B] 15. [Ans. A]


Taking f(x, y)= xy, we can show that, Given : g  x,y   4x3  10y 4
xdx+ydy, is exact. So, the value of the
The straight line can be expressed as
integral is independent of path
y=2x
(0, 1) Then g(x,y)=4x3+ 10 (2x)4

1 1


4
 
I   4x3  10 2x   dx   4x3  160x4 dx 
0 0
1
 4x4 160 5 
=   x  33
5 0
(1, 0)
 4

∫( ) 16. [Ans. A]
f(x)= +
(x)= =0 x=0
∫ ∫ (x)= + >0  x R.
Hence minimum at x=0
f(0)=1+1=2
[ | | ] Alternatively:
For any even function the maxima &
minima can be found by
13. [Ans. B] A.M. >= GM
Let f(x)  ex  sinx => exp(x) + exp( x) ≥ 2
o ’ Hence minimum value = 2

f  x   f a    x  a f'a  
 x  a
2

f''a  17. [Ans. B]


2!
where, a= Q

f  x   f     x   f'  
 x  
2

f'' 
2!
f ''  P
Coefficient of (x )2 is
2
f''   ex  sinx |at x   e
 Coefficient of (x )2=0.5 exp () ∫( )

14. [Ans. A]
∫ ∫

o [ | | ]
Thus, ( )w h o ow
( )w h ow
o ( )w h ow
o ( )w h ow

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 104
GATE QUESTION BANK Mathematics

18. [Ans. D] 21. [Ans. A]


sinx = x ....
sin (x –π ) y= o
( ) ( )
= (x – π ) – .... o  o
or sin x = (x – π ) –
( ) ( )
... 
( ) ( ) o
or =1 – ....
( )
( )
( ) ( )  = o
or = 1 ....
( )
Since
19. [Ans. D] Therefore, at has a maximum.
o ’ h o
∮ ⃗ ⃗ = ∬⃗ ⃗ 22. [Ans. D]
Apply the divergence theorem
According Stokes Theorem
∮ ⃗ ⃗ =∮ ⃗⃗⃗ ⃗
∯ ⃗ ∭

20. [Ans. C] ( )∭
̂ ̂ ( and is the position vector)
⃗⃗⃗ ̂ ̂
⃗⃗⃗ ⃗⃗⃗ 23. [Ans. A]
Y
̂ ̂
S R
3 ̅ ( )]
⇒ [
1 Q
P ⇒ [ ( )]

X ⇒ ( )
√ √
⇒ ( ) ⇒
∮ ⃗ ⃗⃗⃗

∫ ⃗ ⃗⃗⃗ ∫ ⃗ ⃗⃗⃗ ∫ ⃗ ⃗⃗⃗ ∫ ⃗ ⃗⃗⃗


24. [Ans. C]

∫ ⃗ ⃗⃗⃗ ∫ * + [ ] ( ) , -
√ √ ( ) ( )
= [ along PQ y =1 dy =0] ( ) ⇒
are the stationary points
∫ ⃗ ⃗⃗⃗ ∫ .√ / , - ( )
( ) ( )
∫ ⃗ ⃗⃗⃗

∫√ . / and f(2) = 25 and f(4)=21
√ √
M o ( ) , -
[ ] f(6)=41

∫ ⃗ ⃗⃗⃗ ∫ .√ / ( )
25. [Ans. B]
∮ ⃗ ⃗⃗⃗

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 105
GATE QUESTION BANK Mathematics

o 30. [Ans. C]
E o
( )
π

31. [Ans. *] Range to 0.01
E o o ( ) ( )

26. [Ans. D] ( )
̅ ̂ ̂ ̂ ⇒

( )
= ( )
=1+1+1 ( )
=3 o h

27. [Ans. D] 32. [Ans. *] Range 5.9 to 6.1


o ’ h o “ h integral of a Maximum value is 6

vector around a closed path L is equal ( )
( )
to the integral of curl of ⃗ over the open
o h o h ”
( )
∮⃗ ⃗ ∬( ⃗ )⃗ ( )
( )
28. [Ans. *] Range 862 to 866 ( )
Volume under the surface
33. [Ans. C]
∫ ∫ ∫ Let x (opposite side), y (adjacent side)
and z (hypotenuse side) of a right angled
∫ ∫ ( ) triangle

∫ * +


Given o …
( )( o )
29. [Ans. A]
o o
( )
̇( ) ⇒ ( ) o ⇒
⇒ ( ) o
Since ( ) is negative, maximum value of ⇒
o
f(x) will be where ( )
0( )
1
⇒ ⇒
o oh
⇒ ( ) ( ) ( ) ( ( )( ))
( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 106
GATE QUESTION BANK Mathematics

By trial and error method using options Now at x = 2


π (2) = ( )
= ( )
= 2 <0
34. [Ans. *] Range 6.8 to 7.2 At x = 2 we have a maxima.
⃗ ̂ ̂ ̂ = 0 1
̂ ̂ ̂
At (1, 1, 1) ⃗ ̂ ̂ ̂ 3. [Ans. C]
|⃗ | √ =∫ , - , -
= . /

35. [Ans. *] Range 2.99 to 3.01


4. [Ans. D]
( ) ( )
√ √
⃗ ( )̂ ( )̂ 5. [Ans. D]
√ √
We consider options (A) and (D) only
At (1, 1), ⃗ (̂ ̂ )
√ because which contains variable r.
Given unit vector, ̂ (̂ ̂ ) By integrating (D), we get

So, directional derivative π , which is volume of cone.
⇒ ⃗ ̂ (̂ ̂ ) (̂ ̂ )
√ √
6. [Ans. D]
=3
By property of definite integral

EE ∫ ( ) ∫ ( π )
1. [Ans. C] On simplification we get option (D)
Grad u = ̂ ⁄
7. [Ans. B]
At (1, 3) Grad u = √ ,( ⁄ ) - f(x) = ( )
(x) = 2( )
=√ =4x( ) =0
x = 0, x = 2 and x = 2 are the stationary
2. [Ans. A] points.
f(x) = (x) = 4[x(2x) +( ) ]
(x) = ( ) = 4[2 -
= ( ) = 4 [3 -
Putting ( (x) = 0 = 12
( )=0 (0) = < 0, maxima at x = 0
( )=0 (2) =(12)
x = 0 or x = 2 are the stationary points. = 32 > 0, minima at x =
Now, ( 2) =12( )
(x) = ( ) ( )( ) = 32 > 0; minima at x =
= ( ( )) There is only one maxima and only two
= ( ) minima for this function.
At x = 0, (0) = ( )=2
Since (x) = 2 is > 0 at x = 0 we have a
minima.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 107
GATE QUESTION BANK Mathematics

8. [Ans. A] = , -
=, ( )-
= ( ) ( ) =1
1
14. [Ans. B]
0 Dot product of two vectors
=1+a+ =0
So orthogonal

15. [Ans. C]
∫ ∫ ( ) f(x) =
( )
( )
9. [Ans. C] So the equation f(x) having only maxima
( ) at x = 1
( )
( ) 16. [Ans. B]
( )
( ) ̇̂
̂
̂ ̂ ̂
10. [Ans. D]
̅=( ̂ ̂ ̂
)̂ ( )̂
( ) = (0, 2) ∫ ∫
( ) = (2, 0)
Along x axis ,y=0,z=0
Equation of starting line = The integral reduces to zero.
⇒ y = 2 – x , dy = – dx
̅ ̅ =( ) ( ) 17. [Ans. D]
Putting y = 2 – x and dy = – dx
∫̅ ̅ ∫ ∫ ( ) C o o ‘ ’
( )
11. [Ans. B] .( )̂ ( )̂
( )̂ /
( )
̂ ̂ ̂
But at is undefined
Discontinuous || ||

( ) ( ) ( )
12. [Ans. A] ̂ ( ) ̂ ( ) ̂ ( )
̂ ̂ ̂
=0
Div ( ) ⃗
̂
=. ̂ ̂ /( ̂ ̂ ̂) 18. [Ans. A]
= 1+1+1= 3 ( ) ( ) ( )
o ( ) ( )
13. [Ans. B] ⇒
M
P=∫

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 108
GATE QUESTION BANK Mathematics

19. [Ans. B] π
0 . /1
∫⃗

∫ [ ]
⇒ o o π 23. [Ans. A]
( ⃗) ⃗ ⃗
∫ ( )( )( )
( ) ( )

o
∫ ( ) [ ]

π 24. [Ans. B]
( )
20. [Ans. C] ( ) ⇒

( ) ( )
⇒( )( )
( ) ⇒
( )
( ) w , -
For number of values of ( )
⁄ ( )
o ( ) ( )
( )
( ) ( )
( ) ( )
M ( )

21. [Ans. B] IN
G 1. [Ans. A]

o h o

o o
( )
⇒ o
Unit vector along y = x is
G ∫ (∫ ) π
̂ o

∫ (∫ ) ̂
√ √
o ̂
22. [Ans. 2] . /. /
( ) √ √

π π π √ √
∫ ∫ o . / . /

2. [Ans. D]
Using L Hospital Rule., numerator
()
becomes = = ( )
From the graph, distance at

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 109
GATE QUESTION BANK Mathematics

3. [Ans. B] When
Given integral is, I=∫ ( ) ( )
Let f(x) = so curve of 1/ will be And when
f(x)
( ) ( )
The possible expression for f(x) is
1 . /

7. [Ans. B]
-1 0 1 x
Error,
This curve will be discontinuous at x=0
o ’ w o For error to be minimum
( o ) ( )
4. [Ans. A]
Let R ̂ z (t) ̂
̅ (t) =x (t) ̂+y (t) + ⇒ o
̅( ) =K (constant)
|R ⇒
i.e., (t) + (t) + (t) = constant.

On analyzing the given (A) option, we find √
̅( )
̅(t)
that R will give constant magnitude,
so first differentiation of the integration will √

be zero.

5. [Ans. C] 1
Given : G
f= + …… + o
where, (i=0 to n) are constant.
= +(n 1) ……
+ ⇒

and =0+ + ……
(n 1) +n ⇒

+
⇒ ( )
= , + + -
= nf ⇒

6. [Ans. B]
8. [Ans. B]
( ) ( )
When () ∫ ( ) …( )

( ) ( ) Differentiating the above equation


When
( ) ( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 110
GATE QUESTION BANK Mathematics

() 14. [Ans. B]
, ()
Given y = x2 + 2x + 10
= 2x + 2
∫ ( ) -
|

From equation (i)


() 15. [Ans. C]
() () By definition
()
⇒ ()
16. [Ans. A]
This is Leibnitz linear equation Unit vector= =xi+yj+zk
Integrating factor I.F = ∫ and
the solution is
17. [Ans. C]
() ∫ R:
Y
( )

1 +1 X
1
, - o

9. [Ans. D]
Area = ( )
Total charge = σ
10. [Ans. A]
This is a standard question of =
differentiability & continuity = coulomb.

11. [Ans. C] 18. [Ans. B]


y= We know that
=( ).(cos x + sin x) = 0
∫ () ( ) ( )wh
⇒ tan x = 1
Or x = π π
∫ . / . /
y will be maximum at x =
y= 19. [Ans. B]
= = √
Expansion of sin x
........
12. [Ans. C]
y(2) = ( )
20. [Ans. B]
y(5) = ( )
In a G.P ( )
13. [Ans. C] For a G.P to converge
( )
y= ⇒ ⇒ ( )
y= ⇒

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 111
GATE QUESTION BANK Mathematics

21. [Ans. D]
.E=0 is not irrational (it is solenoidal)

22. [Ans. 1]
From Gauss divergence theorem, we have
∫ ̅ ̅ ∫ ̅ ∫ ̅

∫. /dxdydz

∫ ∫ ∫ ( )

̅ ̂ ̂ ̂
[ ]

23. [Ans. C]

24. [Ans. D]
/
π
π
o .

( π )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 112
GATE QUESTION BANK DSA

Data Structure and Algorithm Analysis

CS- 2005 5. What does the following C-statement


1. Suppose T (n) = 2T (n/2) + n, declare?
T(0) = T(1)=1. Which one of the int(*f) (int *);
following is FALSE? (A) A function that takes an integer
(A) T(n) = O(n2) pointer as argument and returns an
(B) T(n) = (n log n) integer
(C) T(n) = Ω(n2) (B) A function that takes an integer
(D) T(n) = O(n log n) pointer as argument and returns an
integer pointer
Linked Data Questions 2 and 3. (C) A pointer to a function that takes an
Consider the following C- function: integer pointer as argument and
double foo(int n) { returns an integer
int i; (D) A function that takes an integer
double sum; pointer as argument returns a function
if (n = = 0) return 1.0; pointer
else {
sum = 0.0; 6. An Abstract Data Type (ADT) is
for( i=0; i < n; i++) (A) Same as an abstract class
sum += foo(i); (B) A data type that cannot be
return sum; instantiated
}} (C) A data type for which only the
operations defined on it can be used,
2. The space complexity of the above but none else
function is (D) All of the above
(A) O(1) (C) O(n!)
(B) O(n) (D) 7. A common property of logic programming
languages and functional languages is
3. Suppose we modify the above function (A) both are procedural language
foo( ) and store the values of foo(i), (B) both are based on - l ulus
0 < = I < n, as and when they are (C) both are declarative
computed. With this modification, the (D) both use Horn-clauses
time complexity for function foo( ) is
significantly reduced. The space 8. Which of the following are essential
complexity of the modified function features of an object-oriented
would be: programming language?
(A) O(1) (C) O(n2) 1. Abstraction and encapsulation
(B) O(n) (D) O(n!) 2. Strictly-typedness
3. Types-safe property coupled with
4. The time complexity of computing the sub-type rule
transitive closure of a binary relation on a 4. Polymorphism in the presence of
set of n elements is known to be inheritance
(A) O(n) (C) O(n3/2) (A) 1 and 2 only (C) 1, 2 and 4 only
(B) O(n log n) (D) O(n3) (B) 1 and 4 only (D) 1, 3 and 4 only

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 113
GATE QUESTION BANK DSA

9. Consider the following C-program the best way for P to score the
double foo (double);/* Line 1 */ frequencies?
int main () { (A) An array of 50 numbers
double da, db; (B) An array of 100 numbers
// input da (C) An array of 500 numbers
db = foo(da);} (D) A dynamically allocated array of 550
double foo(double a){ numbers
return a;
} Linked data Questions Q 12 & Q 13
The above code complied without any We are given 9 tasks are , , , .
error or warning. If Line 1 is deleted, the The execution of each task requires one
above code will show unit of time. We can execute one task at a
(A) no compile warning or error time. has a profit and a deadline
(B) some complier-warnings not leading profit is earned if the task is completed
to unintended results before the end of the unit of time.
(C) Some complier-warnings due to Task Profit Deadline
type-mismatch eventually leading to 15 7
unintended results 20 2
(D) Complier errors 30 5
18 3
10. Consider the following C-program 18 4
void foo (int n,int sum 0) { 10 5
int k = 0, j = 0; 23 2
if (n = = 0) return;
16 7
k = n % 10;
25 3
j = n / 10;
sum = sum + k;
12. Are all tasks completed in the schedule
foo (j, sum);
that gives maximum profit?
print “% d”, k ;
(A) All tasks are completed
}
(B) nd are left out
int main () {
(C) nd are left out
int a = 2048, sum = 0;
(D) nd are left out
foo(a, sum);
printf “%d\n” sum ;
13. What is maximum profit earned?
}
(A) 147 (C) 167
What does the above program print?
(B) 165 (D) 175
(A) 8, 4, 0, 2, 14
(B) 8, 4, 0, 2, 0
CS- 2006
(C) 2, 0, 4, 8, 14
14. Consider the polynomial
(D) 2, 0, 4, 8, 0
p(x) = a0 + a1x + a2x2 + a3x3,where
ai 0, i. The minimum number of
11. A program P reads in 500 integers in the
multiplications needed to evaluate p on
range [0, 100] representing the scores of
an input x is
500 students. It then prints the frequency
(A) 3 (C) 6
of each score above 50. What would be
(B) 4 (D) 9

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 114
GATE QUESTION BANK DSA

15. An element in an array X is called a leader (A) n = (log log n)


if it is greater than all elements to the (B) n = (log n)
right of it in X. The best algorithm to find (C) n = (√n)
all leaders in an array. (D) T (n) = (n)
(A) Solves it in linear time using a left to
right pass of the array 19. Consider the following code written in a
(B) Solves in linear time using a right to pass-by-reference language like FORTAN
left pass of the array and these statements about the code.
(C) Solves it is using divide and conquer Subroutine swap (ix,iy)
in time n log n it = ix
(D) Solves it in time n2) L1 : ix = iy
L2 : iy = it
16. Consider the following C program end
fragment in which i, j and n are integer ia = 3
variables. ib = 8
for (i = n, j = 0; i > 0; i / = 2, j +=i); call swap (ia, ib + 5)
Let Val (j) denotes the value stored in the print *, ia, ib
variable j after termination of the for loop. end
Which one of the following is true? S1: The compiler will generate code to
(A) Val (j) = (log n) allocate a temporary nameless cell,
(B) Val (j) = (√n) initialize it to 13, and pass the address of
(C) Val (j) = (n) the cell to swap
(D) Val (j) = (n log n) S2: On execution the code will generate a
runtime error on line L1
17. A set X can be represented by an array S3: On execution the code will generate a
x[n] as follows runtime error on line L2
; if i X S4: The program will print 13 and 8
x [i] = {
; , otherwise S5: The program will print 13 and 2
Consider the following algorithm in which Exactly the following set of statement (s)
x, y and z are boolean arrays of size n: is correct:
algorithm zzz (x[], y[], z[]) (A) S1 and S2 (C) S3
{ (B) S1 and S4 (D) S1 and S5
int i;
for ( i =0; i < n; ++i) 20. Consider the following C-function in
z[i] =( x[i] ~ y[i]) (~x[i] y[i]) which a[n] and b[m] are two sorted
} integer arrays and c [n + m] be another
The set Z computed by the algorithm is integer array.
(A) ( X Y ) void xyz (int a[ ], int b[ ], int c[ ]) {
(B) ( X Y ) int i, j, k;
(C) ( X – Y ) ( Y – X ) i = j = k = 0;
(D) ( X – Y ) ( Y – X ) while ((i <n) && (j < m))
if (a[i] < b[j]) c[k++] = a[i++];
18. Consider the following else c[k ++] = b[j ++];
T (n) = 2T ([√n])+ 1, T(1) = 1 }
Which one of the following is true? Which of the following condition (s)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 115
GATE QUESTION BANK DSA

hold (s) after the termination of the while CS- 2007


loop? 23. In the following C function , let n m,
(i) j < m, k = n + j – 1, and a [n – 1] < b [j] int gcd(n, m)
if i = n {
(ii) i < n, k = m+i– 1, and b [m – 1] if (n % m == 0) return m;
if j = m n = n % m;
(A) Only (i) return gcd(m, n);
(B) Only (ii) }
(C) Either (i) or (ii) but not both How many recursive calls are made by
(D) Neither (i) nor (ii) this function?
(A) log n (C) (log log n)
21. Consider this C code to swap integers and (B) Ω(n) (D) (√n )
these five statements : the code
void swap (int *px, int *py) { 24. What is the time complexity of the
*px = *px *py; following recursive function?
*py = *px + *py; int DoSomething ( int n ) {
*px = *py *px; if ( n < = 2 )
} return 1;
S1: will generate a compilation error else
S2: may generate a segmentation fault at return (DoSomething (floor(sqrt(n))) + n);
runtime depending on the arguments passed }
S3: Correctly implements the swap (A) (n2)
procedure for all input pointers referring to (B) (n log2 n)
integers stored in memory locations (C) (log2 n)
accessible to the process (D)  (log2 log2 n)
S4: implements the swap procedure
correctly for some but not all valid input 25. Consider the following C code segment :
pointers int IsPrime(n)
S5: may add or subtract integers and {
pointers int i, n;
(A) S1 (C) S2 and S4 for (i =2; i < = sqrt(n); i++)
(B) S2 and S3 (D) S2 and S5 {
if (n % i == 0)
22. Given two arrays of numbers , , and {
, , where each number is 0 or 1, the printf “Not Prime \n” ; return ;
fastest algorithm to find the largest }
span (i, j) such that }
= , return 1;
or report that there is no such span, }
(A) Takes O( and time if Let T(n) denote the number of times the
hashing is permitted for loop is executed by the program on
(B) Takes O(n and n time in the input n.Which of the following is TRUE?
key comparison model (A) T (n) = O √n nd n = √n
(C) Takes n time and space (B) T (n) = O √n nd n =
(D) Takes O √n time only if the sum of (C) n = O n nd n = √n
the 2n elements is an even number (D) None of the above

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 116
GATE QUESTION BANK DSA

26. Consider the following C function: order. What will be the contents of the list
int f(int n) after the function completes execution?
{ struct node {
static int r=0; int value;
if(n<=0) return 1; struct node * next;};
if(n>3) void rearrange (struct node *list)
{ {
r = n; struct node *p, *q;
return f(n 2)+2; int temp;
} if (!list || !list next) return;
return f(n 1)+r; p = list; q = list next;
} while (q) {
What is the value of f(5)? temp = p value;
(A) 5 (C) 9 p value = q value;
(B) 7 (D) 18 q value = temp;
p = q next;
27. An array of n numbers is given, where n is q = p ? p next: 0;
an even number. The maximum as well as }
the minimum of these n numbers needs }
to be determined. Which of the following (A) 1, 2, 3, 4, 5, 6, 7
is true about the number of comparisons (B) 2, 1, 4, 3, 6, 5, 7
needed? (C) 1, 3, 2, 5, 4, 7, 6
(A) At least n comparisons, for some (D) 2, 3, 4, 5, 6, 7, 1
constant c, are needed
(B) At most n comparisons are 30. The minimum number of comparisons
needed. required to determine, if an integer
(C) At least n log n comparisons are appears more than n/2 times in a sorted
needed array of n integers is
(D) None of the above (A) n) (C) (1)
(B) (log n) (D) (log n)
28. Consider the following segment of C-code
int j, n; 31. Consider the following functions:
j=1; f(n) =
while (j<=n) g(n) = n!
j=j*2; h(n) =
The number of comparisons made in the Which of the following statements about
execution of the loop for any n>0 is the asymptotic behavior of f(n), g(n) and
(A) log n (C) log n h(n) is true?
(B) n (D) log n (A) f(n) = O(g(n)); g(n) = O(h(n))
(B) f n = g n ; g n = O h n
CS- 2008 (C) g(n) = O(f(n)); h(n) = O(f(n))
29. The following C function takes a singly- (D) h(n) = O(f(n)); g(n) = f n
linked list of integers as a parameter and
rearranges the elements of the list. The
function is called with the list containing
the integers 1, 2, 3, 4, 5, 6, 7 in the given

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 117
GATE QUESTION BANK DSA

Common data for Questions 32 & 33 5. k = ( i + j)/2;


Consider the following C functions: 6. if (Y[k] < x) i = k; else j = k;
int f1(int n) 7. } while ((Y[k] != x) && (i < j));
{ 8. if Y k == x printf “x is in the rr y” ;
if (n == 0 || n == 1) 9 else printf “x is not in the rr y” ;
return n; 10. }
else
return (2*f1( n – 1 ) + 3 * f1(n – 2)); 34. On which of the following contents of Y
} and x does the program fail?
int f2(int n) (A) Y is [ 1 2 3 4 5 6 7 8 9 10] and
{ x < 10.
int i; (B) Y is [ 1 3 5 7 9 11 13 15 17 19]
int X[n], Y[n], Z[n]; and x < 1.
X[0] = Y[0] = Z[0] =0; (C) Y is [ 2 2 2 2 2 2 2 2 2 2 ] and
X[1] = 1; Y[1] = 2; Z[1] =3; x > 2.
for ( i = 2; i < = n; i++ ) (D) Y is [ 2 4 6 8 10 12 14 16 18 20]
{ and 2 < x < 20 and x is even.
X[i] = Y[i – 1] + Z[ i – 2 ];
Y[i] = 2 * X[i]; 35. The correction needed in the program to
Z[i] = 3 * X[i]; make it work properly is
} (A) change line 6 to :
return X[n]; if (Y[k])<x)i=k+1;else j=k 1;
} (B) change line 6 to :
if(Y[k])<x)i=k 1;else j=k+1;
32. The running time of f1(n) and f2(n) are (C) change line 6 to :
(A) (n) and (n) if(Y[k])<=x)i=k; else j=k;
(B)   (D) change line 7 to :
(C) (n) and ( ) } while ((Y[k]==x)&&(i<j));
(D) ( ) and ( )
36. When n = for some k 0, the
33. f1(8) and f2(8) return the values recurrence relation
(A) 1661 and 1640 T(n) = √ T(n / 2) + √n , T (1) = 1
(B) 59 and 59 evaluates to
(C) 1640 and 1640 (A) √n (log n +1) (C) √n log √n
(D) 1640 and 1661 (B) √n log n (D) n log √n

Statement for the Linked Answer 37. Arrange the following function in
Questions 34 & 35 increasing asymptotic order:
Consider the following C program that
A. n
attempts to locate an element x in an array
B. e
Y [ ] using binary search. The program is
erroneous. C. n
1. f(int Y[10], int x) { D. n log n
2. int i, j, k; E. 1.0000001n
3. i = 0; j = 9; (A) A,D,C,E,B (C) A,C,D,E,B
4. do { (B) D,A,C,E,B (D) A,C,D,B,E

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 118
GATE QUESTION BANK DSA

38. Which combination of the integer (B) ? is = get h r ! = ‘\n’


variables x, y and z makes the variable a ? 2 is getchar (c)
get the value 4 in the following (C) ? is ! =’\n’
expression? ? 2 is putchar (c);
a (D) ? is = get h r ! = ‘\n’
= (x > y) ? ((x > z) ? x : z) : ((y>z) ? y : z) ? 2 is putchar (c);
(A) x = , y = , z =
(B) x = , y = , z = CS- 2009
(C) x = , y = , z = 41. The running time of an algorithm is
(D) x = , y = , z = represented by the following recurrence
relation:
39. What is printed by the following C n n
T(n)={
program ? ( ) n otherwise
int f(int x, int *py, int ** ppz) Which one of the following represents the
{ time complexity of the algorithm?
int y, z; (A) (n) (C) n
**ppz + = 1; z = *ppz; (B) (n log n) (D) n logn
*py + = 2; y = *py;
x + = 3; 42. Consider the program below:
return x + y + z; #include<stdio.h>
} int fun (int n, int *f_p)
void main( ) {
{ int t, f;
int c, *b, **a; if ( n<= 1)
c = 4; b = &c; a = & b; {
printf “%d”, f , , ; *fp = 1 ;
} return 1 ;
(A) 18 (C) 21 }
(B) 19 (D) 22 t = fun n ,f p ;
f = t+ * f_p ;
40. Choose the correct option to fill ?1 and ?2 *fp = t;
so that program below prints an input return f ;
string in the reverse order .Assume that }
the input string is terminated by a new int main( )
line character. {
void reverse(void){ int x = 15 ;
int c; printf “%d\n”, fun , &x ;
if(?1)reverse ( ); return 0;
?2 }
} The value printed is
main( ){ (A) 6 (C) 14
printf “enter text” ; printf “\n” ; (B) 8 (D) 15
reverse ;printf “\n” ;
}
(A) ? is get h r != ‘\n’
? 2 is getchar (c);

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 119
GATE QUESTION BANK DSA

CS- 2010 Node *move_to_front (Node *head) {


43. What does the following program print? Node *p, *q;
# include <stdio . h> if((head = = NULL)|| (head next = = NULL))
void f ( int *p, int *q) return head;
{ q = NULL;
p = q; *p = 2; p = head;
} while (p next ! = NULL) {
int i = 0, j = 1 ; q = p;
int main ( ) p=p next;
{ }
f( &i, &j); _______________
printf “%d %d\n”, i, j ; return head;
return 0; }
} Chose the correct alternative to replace
(A) 2 2 (C) 0 1 the blank line.
(B) 2 1 (D) 0 2 (A) q = NULL; p next = head;
head = p;
44. What is the value printed by the following (B) q next = NULL; head = p;
C program? p next = head;
# include <stdio . h> (C) head = p ; p next = q;
int f(int *a, int n) q next = NULL;
{ (D) q next = NULL;
if (n < = 0 ) return 0; p next = head; head = p;
else if (*a % 2 = = 0 )
return *a + f (a + 1, n – 1) ; 46. The following program is to be tested for
else return *a – f (a + 1, n – 1); statement coverage:
} begin
int main ( ) if(a = = b) {S1; exit;}
{ else if(c = = d) {S2;}
int a [ ] = {12, 7, 13, 4, 11, 6} ; else {S3; exit;}
printf “%d”, f , ; S4;
return 0; end.
} The test cases T1, T2, T3 and T4 given
(A) 9 (C) 15 below are expressed in terms of the
(B) 5 (D) 19 properties satisfied by the values of
variables a, b, c and d. The exact values
45. The following C function takes a singly- are not given.
linked list as input argument. It modifies T1: a, b, c and d are all equal
the list by moving the last element to the T2: a, b, c and d are all distinct
front of the list and returns the modified T3: a = b and c != d
list. Some part of the code is left blank. T4: a! = b and c = d
typedef struct node { Which of the test given below ensures
int value; coverage of statements S1, S2, S3 and S4?
struct node *next; (A) T1, T2, T3 (C) T3, T4
} Node; (B) T2, T4 (D) T1, T2, T4

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 120
GATE QUESTION BANK DSA

CS- 2011 pqr + rst + prt. When multiplied as


Common Data for Question 47 and 48: ( ) , the total
Consider the following recursive C number of scalar multiplications is
function that takes two arguments. pqr+ prs + pst.
unsigned int foo (unsigned int n, unsigned If p = 10, q = 100, r = 20, s = 5 and
int r) { t = 80, then the minimum number of
if (n>0)return ((n%r)+foo (n/r, r)); scalar multiplications needed is
else return 0; (A) 248000 (C) 19000
} (B) 44000 (D) 25000

47. What is the return value of the function CS- 2012


foo when it is called as foo (345, 10)? 52. What will be the output of the following C
(A) 345 (C) 5 program segment?
(B) 12 (D) 3 ch r inCh r = ‘A’ ;
switch (inChar) {
48. What is the return value of the function case ‘A’ :printf “Choice A\ n” ;
foo when it is called as foo (513,2)? c se ‘B’ :
(A) 9 (C) 5 c se ‘C’ : printf “Choi e B” ;
(B) 8 (D) 2 c se ‘D’ :
c se ‘E’ :
49. Which of the given options provides the def ult : print f “No Choi e” ; }
increasing order of asymptotic complexity (A) No choice
of functions f1, f2, f3 and f4? (B) Choice A
f1 (n)=2n f2 (n)=n3/2 (C) Choice A
f3 (n)=n log2n f4 (n)=n Choice B No choice
(A) f3,f2,f4,f1 (C) f2,f3,f1,f4 (D) Program gives no output as it is
(B) f3,f2,f1,f4 (D) f2,f3,f4,f1 erroneous

50. Which does the following fragment of C 53. Let W(n) and A(n) denote respectively,
program print? the worst case and average case running
h rt = “GATE ”; time of an algorithm executed on an input
char *p = c; of size n. Which of the following is
printf % s, p p p ; ALWAYS TRUE?
(A) GATE2011 (C) 2011 (A) A n = W n
(B) E2011 (D) 011 (B) A n = W n
(C) A (n) = O (W(n))
51. Four matrices , , nd of (D) A (n) = o (W(n))
dimensions p q, q r, r s nd s t
respectively can be multiplied with 54. The recurrence relation capturing the
several ways with different number of optimal execution time of the Towers of
total scalar multiplications. For example Hanoi problem with n discs is
when multiplied as (A) T(n) = 2T(n 2) + 2
( ), the total (B) T(n) = 2T(n 1) + n
number of scalar multiplications is (C) T(n) = 2T(n/2) + 1
(D) T(n) = 2T(n 1) + 1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 121
GATE QUESTION BANK DSA

Common Data for Question 55 and 56: End A1


Consider the following C code segment. Procedure A2;
int a, b, c = 0; V r
void prtFun (void) ; Procedure A21;
main ( ) V r
{static int a =1; /* line 1 */ Call A1;
prtFun ( ); End A21
a + = 1; Call A21;
prtFun ( ); End A2
printf “ \n %d %d “ , , ; Call A1;
} End main;
void prtFun (void) Consider the calling chain:
{static int a = 2; /* line 2 */ m in A A A A
int b = 1; The correct set of activation records along
a + = ++b; with their access links is given by
printf “ \n %d %d “ , , ; (A)
}
(A) Main

55. What output will be generated by the A1


given code segment?
A2
(A) (C)
A21

(B) (D) FRAME ACCESS


A1
POINTER LINKS
(B)
56. What output will be generated by the
Main
given code segment if:
Line 1 is replaced by auto int a = 1; A1
Line 2 is replaced by register int a = 2;
A2
(A) (C)
A21
FRAME ACCESS
(B) (D) A1
POINTER LINKS
(C)
57. Consider the program given below, in a Main
block-structured pseudo-language with
A1
lexical scoping and nesting of procedures FRAME
permitted POINTER
A2
Program main;
V r A21
Procedure A1; ACCESS
V r LINKS
Call A2;

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 122
GATE QUESTION BANK DSA

(D) Main 323 gm. Then the product of the labels of


the bags having 11 gm coins is _________.
A1
61. The minimum number of comparisons
A2
required to find the minimum and the
maximum of 100 numbers is ____________
A21

A1 62. Which one of the following correctly


FRAME ACCESS determines the solution of the recurrence
POINTER LINKS relation with T(1) = 1?
n = ( ) log n
CS- 2013 (A) n (C) n )
58. Consider the following function; (B) n log n (D) log n
int unknown (int n){
int i, j, k=0
63. Consider two strings A = “qpqrr” nd
for (i =n/2; i<=n; i++)
B = “pqprqrp” Let x e the length of the
for (j=2; j<=n; j=j*2)
longest common subsequence (not
k=k+n/2;
necessarily contiguous) between A and B
return (k ) ;
and let y be the number of such longest
}
common subsequences between A and B.
The return value of the function is
Then x + 10y = _________.
(A) n ) (C) n
(B) n log n (D) n log n 64. Consider the expression tree shown. Each
leaf represents a numerical value, which
59. What is the return value of f(p,p), if the can either be 0 or 1. Over all possible
value of p is initialized to 5 before the choices of the value at the leaves, the
call? Note that the first parameter is maximum possible value of the
passed by reference, whereas the second expression represented by the tree is
parameter is passed by value. _________.
int f (int &x, int c){ +
c = c – 1;
if (c = = 0) return 1; +
x = x +1;
return f (x, c) * x; +
+
}
(A) 3024 (C) 55440
0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1
(B) 6561 (D) 161051

CS- 2014 65. Which of the following statements are


60. There are 5 bags labeled 1 to 5. All the CORRECT?
coins in a given bag have the same weight. 1) Static allocation of all data areas by a
Some bags have coins of weight 10 gm, compiler makes it impossible to
others have coins of weight 11 gm. I pick implement recursion.
1, 2, 4, 8, 16 coins respectively from bags 2) Automatic garbage collection is
1 to 5. Their total weight comes out to essential to implement recursion.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 123
GATE QUESTION BANK DSA

3) Dynamic allocation of activation 68. Consider the following C function in


records is essential to implement which size is the number of elements in
recursion. the array E:
4) Both heap and stack are essential to int MyX (int *E, unsigned int size)
implement recursion {
(A) 1 and 2 only (C) 3 and 4 only int Y = 0;
(B) 2 and 3 only (D) 1 and 3 only int Z;
int i, j, k;
66. Suppose you want to move from 0 to 100 for(i = 0; i < size; i++)
on the number line. In each step, you Y = Y + E[i];
either move right by a unit distance or for(i = 0; i < size; i++)
you take a shortcut. A shortcut is simply a for(j = i; j < size; j++)
pre-specified pair of integers i, j with i< j. {
Given a shortcut i, j if you are at position i Z = 0;
on the number line, you may directly for(k = i; k <= j; k++)
move to j. Suppose T(k) denotes the Z = Z + E[k];
smallest number of steps needed to move if (Z > Y)
from k to 100. Suppose further that there Y = Z;
is at most 1 shortcut involving any }
number, and in particular from 9 there is return Y;
a shortcut to 15. Let y and z be such that }
T(9) = 1 + min(T(y), T(z)). Then the The value returned by the function MyX is the
value of the product yz is _____. (A) maximum possible sum of elements
in any sub-array of array E.
67. Consider the following program in C (B) maximum element in any sub-array
language: of array E.
#include <stdio.h> (C) sum of the maximum elements in all
main() possible sub-arrays of array E.
{ (D) the sum of all the elements in the
int i; array E.
int *pi = &i;
69. Consider the following pseudo code. What is
s nf “%d”,pi ;
the total number of multiplications to be
printf “%d\n”, i ;
performed?
}
D=2
Which one of the following statements is
for i = 1 to n do
TRUE?
for j = i to n do
(A) Compilation fails.
for k = j + 1 to n do
(B) Execution results in a run-time
D=D*3
error.
(A) Half of the product of the 3
(C) On execution, the value printed is 5
consecutive integers.
more than the address of variable i.
(B) One-third of the product of the 3
(D) On execution, the value printed is 5
consecutive integers.
more than the integer value entered.
(C) One-sixth of the product of the 3
consecutive integers.
(D) None of the above.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 124
GATE QUESTION BANK DSA

70. Consider the function func shown below: Give a value q (to 2 decimals) such that
int func(int num) { f (q) will return q: ___________.
int count = 0;
while (num) { 74. Consider the C function given below.
count++; int f(int j)
num>>= 1; {
} static int i = 50;
return (count); int k;
} if (i == j)
The value returned by func(435)is {
__________. printf “something” ;
k = f(i);
71. Suppose n and p are unsigned int return 0;
variables in a C program. We wish to set p }
to C . If n is large, which one of the else return 0;
following statements is most likely to set }
p correctly? Which one of the following is TRUE?
(A) p = n n n ; (A) The function returns 0 for all values
(B) p = n n n ; of j.
(C) p = n n n ; (B) The function prints the string
(D) p = n n n ; something for all values of j.
(C) The function returns 0 when j = 50.
72. For a C program accessing X[i][j][k], the (D) The function will exhaust the
following intermediate code is generated runtime stack or run into an infinite
by a compiler. Assume that the size of an loop when j = 50.
integer is 32 bits and the size of a
character is 8 bits. 75. Let A be a square matrix of size n × n.
t = i Consider the following pseudocode. What
t = j is the expected output?
t = k c = 100;
t = t t for i = 1 to n do
t = t t for j = 1 to n do
t = Xt {
Which one of the following statements Temp = A[i] [j] + c;
about the source code for the C program A [i] [j] = A[j] [i];
is CORRECT? A [j] [i] = Temp – c;
(A) X is de l red s “int X 8” }
(B) X is de l red s “int X ” for i = 1 to n do
(C) X is de l red s “ h r X 8” for j = 1 to n do
(D) X is de l red s “ h r X ” output (A [i] [j]);
(A) The matrix A itself
73. Consider the following function (B) Transpose of the matrix A
double f (double x) { (C) Adding 100 to the upper diagonal
if (abs (x*x – 3) < 0.01) return x; elements and subtracting 100 from
else return f (x/2 + 1.5/x); lower diagonal elements of A
} (D) None of the above

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 125
GATE QUESTION BANK DSA

76. Consider the C function given below. if (listA[k] == x)


Assume that the array listA contains return(k);
n(>0) elements, sorted in ascending else
order. return ;
int ProcessArray(int *listA, int x, int n) }
{ Which one of the following statements
int i, j, k; about the function ProcessArray is
i = 0; CORRECT?
j = n 1; (A) It will run into an infinite loop when
do { x is not in list A.
k = (i+j)/2; (B) It is an implementation of binary
if (x <= listA[k]) search.
j = k 1; (C) It will always find the maximum
if (listA[k] <= x) element in list A.
i = k+1; (D) It will return even when x is
}while (i <= j); present in list A.

Answer Keys and Explanations

1. [Ans. C] 3. [Ans. B]
n = n n It would require n rr y of size ‘n’ to
By M ster’s method, = , = store temporary results.
n =n =n 0< = I<n
f n = (n )
4. [Ans. D]
n = (n logn)
The time complexity of computing the
= nlogn
transitive closure of a binary relation on a
So, it is also O nlogn & O n
set of n elements is O(n3). Apply the
but not n
w rsh ll’s algorithm to compute the
transitive closure. The algorithm contains
2. [Ans. C]
three nested for loops each having
double foo (int n)
frequency n so time complexity is O(n3)
{
int i ;
5. [Ans. C]
double sum ;
int (*f) (int *);
if (n ==0)return;
returns type int, (*f) is a pointer to a
else {sum = 0;
function and the argument is (int *), an
for (i = 0 ; i <n; i++)
integer pointer. So, int (*f) (int *) means a
sum = sum +foo (i);
pointer to a function that takes an integer
return (sum);
pointer as an argument and returns an
}
integer.
}
The size of recursion stack space is not
more th n ‘n!’

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 126
GATE QUESTION BANK DSA

6. [Ans. C] made inside the called function foo will


The abstract data type (ADT) refers to a not be reflected back in the calling
programmer defined data type together function main. So, from main, value 0 will
with a set of operations that can be be printed as sum
performed on that data So, the choice (C)
is correct. 11. [Ans. A]
There are 500 students and the score
7. [Ans. C] range is 0 to 100. We need to print the
A common property of logic programming frequency of those students whose score is
languages and functional languages is both above 50. So frequency range contains
are declarative because we declare any scores from 50 to 100, so an array of 50
statement before we will use it. numbers is suitable for representing the
frequency.
8. [Ans. B]
Properties of object – oriented 12. [Ans. D]
Programming language The given problem is job scheduling
- Abstraction problem 9 tasks are , , , .
- Inheritance J is initially empty then according to
- Polymorphism deadlines it includes
- Encapsulation { , , , , , , }.
So nd n’t e in lude in J
9. [Ans. C]
When we don’t de l re fun tion spe ify 13. [Ans. A]
the prototype), the default rule is that the Total profit earned by an algorithm
function (foo in our case) would have = 8
been assumed to be int, even though it =
really returns a double. This will generate
compiler warning and our program will 14. [Ans. A]
have undefined behavior. Use the Hornor algorithm.
1st iter a3*x ----------------- 1 multiplication
10. [Ans. D] 2nd iter (a2 + a3*x)*x ----------------- 1
The function foo is recursive function multiplication
When we call foo(a, sum) = foo (2048, 0) 3rd iter (a1 + (a2 + a3*x)*x)*x ------ 1
k j sum multiplication
k = 2048%10 j = 204 sum = 0+8 = 8 4th iter a0 + (a1 + (a2 + a3*x)*x)*x
= foo(204, 8)
k = 204%10 = 4 j = 20 sum = 8+4 = 12 15. [Ans. B]
foo(20, 12) Scan each element from right to left.
k = 20%10 = 0 j=2 sum = 12+0 = 12 Make First element as largest element.
foo(2,12) If any other larger elements found, then
k = 2%10 = 2 j=0 sum = 12+2 = 14 mark it as leader element & make this
foo(0,14) function will be terminated and element as largest element.
value of k will print in stack way i.e. 2, 0, 4, Repeat above steps for rest of the
8. Value of sum as computed within the elements
fun tion foo is From s it is ‘ ll y
value’ parameter passing, the change

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 127
GATE QUESTION BANK DSA

16. [Ans. C] 20. [Ans. C]


If n is a power of 2, then Given i < n, j < m and a [i] < b[j] for
j = n+ this a[n – 1] < b[j]
If n is not a power of 2 , then there will be So if i<n
then k = m + i – 1 b[m – 1} i
minor differences of 1 at wherever
and if i < m
is odd.
then k = n + j – 1 a[n – 1] < b[j]
Hence the Val (j) computed on the basis of It means either one of these two are
n = will give a fair answer applicable
j=n GP It is the code for merging two sorted
arrays
n (( ) )
= = n
21. [Ans. B]
S2 and S3 are correct statements.
17. [Ans. D]
The statement inside the for loop is 22. [Ans. C]
similar to X – OR operation such that the If each and is either 0 or 1 and the
set o t ined is X Y X Y numbers are stored in an array then the
It is equivalent to (X – Y Y – X ). algorithm can find the largest span (i, j) on
average in n time because this is only
18. [Ans. B] need of search.
n = ([√n]) ; =
23. [Ans. A]
m = logn
Just draw the recursion tree for some
=
value of n and m. You will observe that the
en me S m =
height of this tree never going to be more
S m = S m
than logn.
S m = m ording to master's theorem
So, S m = logn s m = logn
24. [Ans. D]
Get the recurrence relation initially and
19. [Ans. B]
solving it will give you the order.
Sw p
T(n) = T(√n) + n O(log log n)
ix
i 25. [Ans. B]
iy T(n) = O √n quite clear as loop will run
for √n in worst case if number is prime
i 8
number. However if number is divisible by
S1: The compiler will generate code to , , et ) then loop will run only
allocate a temporary nameless cell, for one iteration. That means number of
initialize it to 13, and pass the address of iterations is varied from 1, √n . Thus B is
the cell to swap the answer.
S4: The program will print ia = 13 and
ib = 8
Option (B) is correct.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 128
GATE QUESTION BANK DSA

26. [Ans. D] 30. [Ans. C]


To compute f(5), initially r=5. To find an integer appears more than n/2
f = 8 n :f n times minimum comparisons are of order
just check first,last and middle
f = f n r element and 1/4 ,3/4 index element

f = f n r 31. [Ans. D]
So we need to identify the correct order of
f = f n r relative growth rates of the given
functions
1 n Either we use L hospital rule to compute
the above or we may simplify the
27. [Ans. B] functions so that growth rate can be
When we apply the divide and conquer proved with obvious reasons.
method such that dived n into two parts of h(n) can be written in form of as
n/2 then recurrence equations is follows:
T(n) = 1 for n = 2 h(n) =
T(n) = 2T(n/2)+2 for n > 2 The following is the growth rates in
The solution of T(n) is increasing order, h(n) < f(n) < g(n). Thus
D is the answer.
n = n
= n omp risons 32. [Ans. B]
Function f1 contain recursive function so
28. [Ans. D] its running time must be O(2n) but f2 have
Let the increment of j is , , , , for not.
some value of i so according to the Alternately
question for f1 has complexity of O(2n), while f2 has a
while loop: n or i log n loop from 2 to N , so the complexity of it is
One extra comparison required for the O(n)
termination of while loop. So total number
of comparisons 33. [Ans. C]
=i = log n When solved .
f =
29. [Ans. B] f = f f =
If there are even number of nodes in the f = f f =
linked list , given program interchanges f = f f =
values of successive numbered nodes .
respectively i.e. interchanges values of .
nodes. If there are odd number of nodes in .
the linked list last node value remain f 8 =
unchanged, all other nodes values are Now for f ,
interchanged as given in program. x = y = z =
Current values are x = y = z =
1,2,3,4,5,6,7 In loop
After interchange x = y = z =
2,1,4,3,6,5,7 x = y = z =

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 129
GATE QUESTION BANK DSA

x = y = z =60
log = log √ =

. f n
h n =
. n
x8 = √n
= =
√n
34. [Ans. C] n = , Where i =0
In C option when we give x =4 (say )the n = log n
working is as follows. n =f n n
I iteration
= √n log n
k = (0+9)/2=4
(y[4]<x) true
37. [Ans. C]
i=4 [j =9]
Here, n< n log9 n< en
II iteration So
k= (4+9)/2=6
(y[6]<x) true n n n log n e
i=6 [j =9] e n log n
n
III iteration
k= (6+9)/2 =7
(y[7]<x) true
i =7 [j=9] Fig. Plot of function values
IV iteration
k= (7+9)/2=8
38. [Ans. A]
(y[8]<x) true
a= (x > y) ? ((x > z) ? x : z) : ((y>z) ? y : z)
i =8 [j = 9]
In C “? : “ is tern ry oper tor the synt x
V iteration
is (exp 1 ? exp2 : exp3). It means if exp 1 is
K=(8+9)/2=8
true print exp2 else exp3.
(y[8]<x) true
Let x = 3, y = 4, z = 2.
i =8 [j = 9]
= ?( ? ): ((4 > 2) ? 4 : 2)
remains in loop forever as condition
(4[8]! = x &&i<j) is always true. a = (3 > 4) ? 3 : 4
a=4
35. [Ans. A]
If increase i to k+1 when y [k] <x and 39. [Ans. B]
f(c, b, a ) is called by the main () function
decrease j to k–1 then the program works
the graphical execution of the program is
properly. Otherwise, above scenario does
given below.
not happen and moreover the element at k
position will be checked for equality in
the while condition.
in

36. [Ans. A] f
T(n)= √ n⁄ √n x py ppz
T(1)=1 z y
Comparing it with T(n) = aT (n/b) +f(n)
x y z= = 9
We get , a= √ ; = ; f n = √n

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 130
GATE QUESTION BANK DSA

int y, z; 43. [Ans. D]


ppz = ppz ; i, j variables are global to main function p
z = ppz = ; and q will also be pointing to same
py = py ; memory location where i and j
y = py = respectively, when f (& i , & j) is called up.
x= = Now p = q statement will move p to the
return x y z = 9 memory location being pointed by q
Thus, * p = 2 will replace 1 by 2.
40. [Ans. D] There is no change in the value of variable
Here we re using the ‘=’ oper tor whi h i (which is still 0);
h s less priority th n ‘! =’ oper tor
So (C = getchar( ) ) has to be in brackets 44. [Ans. C]
and reversing the string we use function a [ ]= 12 7 13 4 11 6
putchar(c) for printing the character. So , first this call
Thus the number stored in the array & we
41. [Ans. A] can access these by using
Complexity is decided for large values of n
only. So, T(n) = T( )+ cn for n>3. f ,
Using ster’s theorem,
Here, a=1, b=3, log = log = so f ,n {even}
f n = n= n
Sin e log = n is elow f n = n f ,n {odd}
his elongs to se III of m ster s theorem,
Where the solution is f ,n {odd}
n = (f n ) = n
f ,n {even}
42. [Ans. B]
f ,n {odd}
x = 15
fun , &x let &x =
f , {even}
fun ,
t = 5, f = 5+3, *f_p = 5
return 8
= [ * [ ]+]
fun ,
t = 3, f = 3+2, *f_p = 3 = * [ ]+
return 5
fun , = * [ ]+
t = 2, f = 2+1, *f_p = 2
=
return 3
fun , =
t = 1, f =1+ 1, *f_p = 1
return 2 45. [Ans. D]
fun , *f_p = 1 q p
return 1
So fun (5, &x) will return 8 and it will be
printed.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 131
GATE QUESTION BANK DSA

When ‘while’ loop is over, the st tes of =1+1+foo(0,2)


p and q variables are as given in the =2
diagram. Now node q will become last
node, hus, q next = NULL will e 49. [Ans. A]
required nlogn n (sin e logn n )
Since, p is inserting in the front of the list p
next = he d is required nd p e ome n n (sin e logn)
first node of the modified list hence
n exponenti l
head = p is required for the successful
operation. n logn n n
f ,f ,f ,f
46. [Ans. D]
In given program we take the test cases 50. [Ans. C]
and apply p = E
From If all values are equal means p = A
a = b = c = d, a = b condition satisfied. S1 p –p =
and S4 executed p p –p = p
From When all a, b, c, d distinct: It prints the su string of “GA E ”
S , S not execute, S and executes. starting at index 4.
From When a = b, S execute but c = d.
S will not execute but S and S executes. 51. [Ans. C]
Here no need of because we get these We get minimum number of
result from above two. multiplications ((M1 (M2 M3)) M4).
From If a! = b and c = d, S will not Total number of multiplications
execute and S and S execute. = 8
All of S , S , S , S will execute and = 9
covered by , nd .
52. [Ans. C]
47. [Ans. B] Switch statement case A matches initially
foo(345, 10) and all other cases are executed from
=5+foo(34,10) there on as there is no ‘Bre k’ in ses
=5+4+foo(3,10) Output C Choi e A
=5+4+3+foo(0,10) Choice B No Choice
=12 There is no break in between the case
statements.
48. [Ans. D]
foo(513,2) 53. [Ans. C]
=1+foo(256,2) Avg case running time always less than
=1+foo(128,2) (or) equal to worst case Time.
=1+foo(64,2) A n =O w n
=1+foo(32,2) By definition of asymptotic notation.
=1+foo(16,2) Average lies always between the best and
=1+foo(8,2) the worst case inclusive.
=1+foo(4,2)
=1+foo(2,2)
=1+foo(1,2)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 132
GATE QUESTION BANK DSA

54. [Ans. D] In every iteration of inner loop is added


OH n, L, ,
to k.
Return Value
= no of outer loops no of inner loops
OH MOV OH n n
n , L, , (L-R) n , , L, = ( ) logn
n = n = O n logn .

55. [Ans. C] 59. [Ans. B]


If any variable is static, then it retains its f(5, 5)
v lue ross fun tion lls V ri le ‘ ’ in {
ptrFun is static and local, so the update of c = 4;
this variable is available across different x = 6;
invocations of function ptrFun, but as it is return f(6, 4) * x;
a local variable its update will not affect }
the value of variable a present in main. f(6 , 4){
Uninitialized global variables have 0 as c = 3;
their default value. x = 7;
return f(7, 3) * x;
56. [Ans. D] }
If the variables are auto, these variables f(7, 3)
will be reinitialized in every function calls. {
Now the variables are all auto storage c = 2;
class. Their lifetime is local. x = 8;
f( 8, 2) * x
57. [Ans. D] }
Main f(8, 2)
A1 {
c=1;
A2
x=9;
A21 f(9, 1) * x;
A1 }
FRAME ACCESS
POINTER LINKS
f (9,1){
c = 0;
Given calling sequence from the program
return 1;
is:
}when c=1, x=9
main A A A A
So, 9* 9 * 9 * 9 = 6561
A1 & A2 are defined in main, so A1 & A2
access links are pointed to main A21
60. [Ans. 12]
definition is available in A2, hence A21
No. of coins picked having 10 gm weight
access link points to A2
= 18
No. of coins picked having 11 gm weight
58. [Ans. B]
= 13
Outer loop execute for Iter tions .
1 + 4 + 8 = 13 (Bag no. 1, 3, 4 are having
Inner loop executes for log n ite r tions . 11 gm coins)
So =
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 133
GATE QUESTION BANK DSA

61. [Ans. *] Range 147.1 to 148.1 3. Dynamic allocation of activation


If we use comparison in pair method then records is mandatory of recursion
no. of comparisons will be implementation (TRUE).
( ) 4. Heap & stack are not mandatory for
recursion implementation
If n = 100 then
1 and 3 are correct.
=
= 8 66. [Ans. 150]
From 9 you can go to either 10 or 15
62. [Ans. A] (shortcut)
n
n = ( ) logn So
T(9) = 1 + min (T(10), T(15))
By ster’s method, = , =
So
So, log =1
y = 10, z = 15
So, = n log
or y = 15, z = 10
So, se of m ster’s theorem pplies
So yz = 150
T(n)= (n)
67. [Ans. D]
63. [Ans. 34]
Statement
x=4
s nf “% d”, & i ;
A = qpqrr
and
B = pqpr qrp
s nf “% d”, pi ;
B = pqprqrp are equivalent, because, of the statement
B = pqp rqrp int *pi = & i;
y=3 So execution of the program will print 5
So x + 10y = 4 + (10 × 3) = 34 more than the integer value entered

64. [Ans. 6] 68. [Ans. A]


+
First loop is calculating sum of all element
of the array in Y.
+ Second loop is calculating sum of sub –
array in Z and if it is greater than Y, then it
+ + is updating Y by new larger sum.
So till the end we will have maximum sum
of element Y of any sub array of array E.
1 1 0 1 1 0 1 1

69. [Ans. C]
2 1 2 Let n=4
= When i=1; j=1: number of multiplications:
=3+3=6 3
When i=1; j=2; number of multiplications:
65. [Ans. D] 2
1. Recursion cannot be implemented When i=1; j=3; number of multiplications:
with only static allocation (TRUE) 1
2. Garbage collection is not essential for When i=1; j=4; number of multiplications:
recursion implementation 0

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 134
GATE QUESTION BANK DSA

When i=2; j=2: number of multiplications: This expression works only when n is
2 small
When i=2; j=3: number of multiplications: (ii) C is also wrong because in left to right
1 evaluate on n n may not
When i=2; j=4: number of multiplications: give exact integer. It may be fractional
0 value. But C – language ignores
When i=3; j=3: number of multiplications: fractional part and multiples it with
1 (n – 2) then divided by 2. So it will
When i=3; j=4: number of multiplications: not give correct result.
0 (iii) B is correct. n(n – 1) will be divided
When i=4; j=4: number of multiplications: by 2 exactly because n or (n – 1) is
0 even; then multiply with (n – 2) then
Total number of multiplications: 10 divide by 3.
The 3 consecutive numbers are: 3,4,5
One-sixth of product of 3 consecutive 72. [Ans. A]
numbers is: )/6 = 60/6 = 10 Three address code to access arr [n]
t = size of word
70. [Ans. 9] t =t n
num = num t = rr t
me ns divide num er y . In given ode in question
while : count = 1; num = 217 t =i
while : count = 2; num = 108 It is equivalent to
while 8 : count = 3; num = 56 t =
while : count = 4; num = 27 t =i t
while : count = 5; num = 13 So the rr y is de l red s ‘int’ nd first
while : count = 6; num = 6 index is of 32 size
while : count = 7; num = 3 So Option (A) is correct
while : count = 8; num = 1
while : count = 9; num = 0 73. [Ans. *] Range 1.72 to 1.74
while meout of loop f(q) must give q
Count = 9 So f(x) must give x
if condition must be tree
71. [Ans. B] ie abs (x * x – 3) < 0.01
n n n n ! So x must be almost equal to 3
p=n =
n ! ! x=
n n n
= 74. [Ans. D]
But all the 4 options give the same When j = 50
expression as above i = j printf statement executes;
(i) A & D are wrong because, it is given k = f (50)
that n is large so the multiplication of So j = 50 again and the recursion
n n– n result is must continues for ever.
also be unsigned int and its result will untime stack exhaust & it will run into
be very large & cannot fit in unsigned infinite loop.
int variable.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 135
GATE QUESTION BANK DSA

75. [Ans. A]
Initially A[i][j] is interchanged with A[j][i].
But again when processing A[j][i], it is
again interchange A[i][j]. So the matrix
remains the same once block is executed.

76. [Ans. B]
3 7 9 10 13 16 18
0 1 2 3 4 5 6
Case 1: (found case)
Let x = 10
i = 0, j = 6
k = 6/2 = 3
10 < = list A[3]
j= =
list A[3] < =10
i = 3 + 1 =4
i = j exit loop
list A [3] = = 10
return
Bin ry se r h
Case 2: (not found case)
Let x = 11
i = 0, j = 6
1st iteration: k = 6/2 = 3
11 = list A
list A[3] < = 11
i=3+1=4
i = j (true)
2nd iteration: k = (6 + 4)/2 = 5
11< = list A[5]
j=5–1=4
list A =
i==j
3rd iteration:
k = (4 + 4)/2 = 2
11 < = list A[4]
j=4–1=3
i = j (exit loop)
list A [k] ! = x
return
(Binary search)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 136
GATE QUESTION BANK DSA

Stacks and Queues

CS-2005 CS-2007
1. A function f defined on stacks of integers 3. The following postfix expression with
satisfies the following properties. single digit operand is evaluated using a
f(ф) = 0 and stack
f(push(S, i)) = max (f(S), 0) + i for all 8 2 3 ^ / 2 3 * + 5 1 *
stacks S and integers i. If a stack S Note that ^ is the exponentiation
contains the integers 2, 3, 2, 1, 2 in operator. The top elements of the stack
order from bottom to top, what is f(S)? after the first * is evaluated are
(A) 6 (C) 3 (A) 6, 1 (C) 3, 2
(B) 4 (D) 2 (B) 5, 7 (D) 1, 5

CS-2006 4. Suppose you are given an implementation


2. An implementation of a queue Q, using of a queue of integers. The Operations
two stacks S1 and S2, is given below that can be performed on the queue are:
void insert(Q, x) i. isEmpty(Q) – returns true if the
{ queue is empty, false otherwise.
push (S1,x); ii. delete (Q) – deletes the element
} at the front of the queue &
void delete (Q) returns its value .
{ iii. insert (Q , i ) – insert the integer i
if (stack-empty(S2)) then at the rear of the queue.
if (stack-empty(S1)) then Consider the following function:
{ void f (queue Q) {
printf(“Q is empty”); int i;
return; if (! isEmpty (Q)) {
} i = delete (Q);
else while(!stack-empty (S1)) f(Q);
{ insert (Q, i) ;
x = pop (S1); }
push (S2, x); }
} What operation is performed by the
x = pop (S2); above function f?
} (A) Leaves the queue Q unchanged
Let n insert and m ( n) delete operations (B) Reverses the order of the elements in
be performed in an arbitrary order on an the queue Q
empty queue Q. Let x and y be the number (C) Deletes the elements at the front of
of push and pop operations performed the queue Q & inserts it at the rear
respectively in the process. Which one of keeping the other elements in the
the following is true for all m and n? same order.
(A) n + m x < 2n and 2m y n+m (D) Empties the queue Q
(B) n m n and m y n
(C) 2m x < 2n and 2m y n + m
(D) 2m x < 2n and 2m y 2n

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 137
GATE QUESTION BANK DSA

CS-2012 CS-2014
5. Suppose a circular queue of capacity 7. Suppose a stack implementation supports
(n 1) elements is implemented with an an instruction REVERSE, which reverses
array of n elements. Assume that the the order of elements on the stack, in
insertion and deletion operations are addition to the PUSH and POP
carried out using REAR and FRONT as instructions. Which one of the following
array index variables, respectively. statements is TRUE with respect to this
Initially, REAR = FRONT = 0. The modified stack?
conditions to detect queue full and queue (A) A queue cannot be implemented
empty are using this stack.
(A) full: (REAR+1) mod n = = FRONT (B) A queue can be implemented where
empty: REAR = = FRONT ENQUEUE takes a single instruction
(B) full: (REAR+1) mod N = = FRONT and DEQUEUE takes a sequence of
empty: two instructions.
(FRONT+1) mod n = = REAR (C) A queue can be implemented where
(C) full: REAR = = FRONT ENQUEUE takes a sequence of three
empty: instructions and DEQUEUE takes a
(REAR+1) mod n = = FRONT single instruction.
(D) full: (FRONT+1) mod n = = REAR (D) A queue can be implemented where
empty: REAR = = FRONT both ENQUEUE and DEQUEUE take a
single instruction each.
CS-2013
6. Consider the following operation along 8. The minimum number of arithmetic
with Enqueue and Dequeue operations on operations required to evaluate the
queues, where k is a global parameter. polynomial P(X) = for
MultiDequeue (Q){ a given value of X, using only one
m = k; temporary variable is _________.
while (Q is not empty) and (m >0) {
Dequeue (Q)
m=m–1
}
}
What is the worst case time complexity of
a sequence of n queue operations on an
initially empty queue?
(A) (n) (C) (n )
(B) (n ) (D) (n )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 138
GATE QUESTION BANK DSA

Answer Keys and Explanations

1. [Ans. C] stack operation, the queue will be reversed


To push f(s) at the end).
2 ma (f(s) 0) =
3 ma (f(s) 0) ( )= 5. [Ans. A]
2 ma (f(s) 0) = So given condition can be specified as
1 ma (f(s) 0) ( )= full: (REAR + 1) mod n = FRONT
2 ma (f(s) 0) = empty : REAR = FRONT
FRONT REAR
2. [Ans. A]
queue
The order in which insert and delete a b c d e f g full
operations are performed matters here.
queue
The best case: insert and delete operations empty
are performed alternatively. In every
FRONT/REAR
delete operation , 2 pop and 1 push
operations are performed. So, total m+n
6. [Ans. A]
push (n push for insert () and m push for
Since the queue is empty initially, the
delete ()) operations and 2m pop
condition of while loop never becomes
operations are performed.
true. So, for n operations, the time
The worst case: First n elements are
complexity is (n)
inserted and then m elements are deleted.
In first delete operation, n+1 pop
7. [Ans. C]
operations and n push operation are
Queue can be implemented as below
performed. Other than first, in all delete
ENQUEUE: REVERSE; PUSH; REVERSE (3
operations, 1 pop operation is performed.
instructions)
So, total m+n pop operations and 2n push
DEQUEUE: pop (single instruction)
operations are performed (n push for
insert () and m push for delete ())
8. [Ans. 7]
( )=
3. [Ans. A]
an e e itten as fo o s
P(x) = ( )
3 3
Now using only one temporary variable t
2 2 8 2 2 6 and any number of data transfers as well as
8 8 8 8 1 1 1 1 memory related operations, the polynomial
8 2 3 / 2 3 * can be evaluated as follows
^
2 ^3 8 8 2 3
=1
a. t = x * x
=8 =6
[Evaluate and store in memory]
⟹ The top two elements are 6, 1
b. t = t
[Evaluate ( ) and store in memory]
4. [Ans. B]
c. t =
As the elements are deleted from front and
[Retrieve from memory]
inserted from the rear in the reverse order
d. t = t * x
in which element are deleted (because of
[Evaluate and store in memory]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 139
GATE QUESTION BANK DSA

e. t=t*( )
[Evaluate ( ) and store in
memory]
f. t=6*x
[Evaluate 6x and store in memory]
g. t=t+5
[Evaluate 6x + 5 and store in memory]
t = t + ( )
[Retrieve ( ) from memory
and evaluate { ( ) ]
In the above 8 steps of evaluation, the
total number of arithmetic operation
required are 7
[4 Multiplications, 3 Additions]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 140
GATE QUESTION BANK DSA

Trees

CS-2005 If the height of the tree is h > 0, then the


1. How many distinct binary search trees minimum number of nodes in the tree is:
can be created out of 4 distinct keys? (A) (C)
(A) 5 (C) 24 (B) (D) 2h
(B) 14 (D) 42
6. The numbers 1, … n are inserted in a
2. In a complete k-ary tree, every internal binary search tree in some order. In the
node has exactly k children. The number resulting tree, the right subtree of the
of leaves in such a tree with n internal root contains p nodes. The first number to
nodes is be inserted in the tree must be
(A) n k (C) n(k – 1) + 1 (A) p (C) n p
(B) (n – 1) k + 1 (D) n(k – 1) (B) p + 1 (D) n p + 1

3. Postorder traversal of a given binary CS-2006


search tree, T produces the following 7. A scheme for storing binary trees in an
sequence of keys array X is as follows. Indexing of X starts
10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29 at 1 instead of 0. The root is stored at
Which one of the following sequences of X [1]. For a node stored at X[i], the left
keys can be the result of an inorder child, if any is stored in X [2i] and the
traversal of the tree T? right child, if any in X [2i + 1]. To be able
(A) 9, 10, 15, 22, 23, 25, 27, 29, 40, 50, to store any binary tree on n vertices, the
60, 95 minimum size of X should be
(B) 9, 10, 15, 22, 40, 50, 60, 95, 23, 25, (A) log2 n (C) 2n + 1
27, 29 (B) n (D)
(C) 29, 15, 9, 10, 25, 22, 23, 27, 40, 60,
50, 95 8. Suppose that we have numbers between
(D) 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 1 and 100 in a binary search tree and
15, 29 want to search for the number 55. Which
of the following sequences CANNOT be
4. A binary search tree contains the the sequence of nodes examined?
numbers 1, 2, 3, 4, 5, 6, 7, 8. When the tree (A) {10, 75, 64, 43, 60, 57, 55}
is traversed in pre-order and the values in (B) {90, 12, 68, 34, 62, 45, 55}
each node printed out, the sequence of (C) {9, 85, 47, 68, 43, 57, 55}
values obtained is 5, 3, 1, 2, 4, 6, 8, 7. If the (D) {79, 14, 72, 56, 16, 53, 55}
tree is traversed in post-order, the
sequence obtained would be 9. In a binary tree, the number of internal
(A) 8, 7, 6, 5, 4, 3, 2, 1 nodes of degree 1 is 5 and the number of
(B) 1, 2, 3, 4, 8, 7, 6, 5 internal nodes of degree 2 is 10. The
(C) 2, 1, 4, 3, 6, 7, 8, 5 number of leaf nodes in the binary tree is
(D) 2, 1, 4, 3, 7, 8, 6, 5 (A) 10 (C) 12
(B) 11 (D) 15
5. In a binary tree, for every node the
difference between the number of nodes
in the left and right subtrees is at most 2.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 141
GATE QUESTION BANK DSA

CS-2007 The postorder traversal of the binary tree


10. Consider the following C program is
segment where Cell Node represents a (A) d e b f g c a
node in a binary tree (B) e d b g f c a
struct CellNode { (C) e d b f g c a
struct CellNode * leftchild; (D) d e f g b c a
int element;
struct CellNode *rightchild; 14. A complete n-ary tree is a tree in which
}; each node has n children or no children.
int GetValue (struct CellNode * ptr) { Let I be the number of internal nodes and
int value = 0; L be the number of leaves in a complete
if(ptr != NULL) { n-ary tree. If L = 41 and I = 10, what is
if((ptr leftchild == NULL) && the value of n?
(ptr rightchild == NULL)) (A) 3 (C) 5
value =1; (B) 4 (D) 6
else CS-2008
value 15. You are given the post-order traversal, P
= value + GetValue(ptr leftchild) of a binary search tree on the n elements
+GetValue(ptr rightchild); , , ……., n. You have to determine the
} unique binary search tree that has P as its
return(value); post-order traversal. What is the time
} complexity of the most efficient algorithm
The value returned by GetValue when a for doing this?
pointer to the root of a binary tree is (A) (log n)
passed as its arguments is
(B) (n)
(A) The number of nodes in the tree
(C) (n log n)
(B) The number of internal nodes in the
(D) none of the above, as the tree cannot
tree
be uniquely determined
(C) The number of leaf nodes in the tree
(D) The height of the tree 16. The following three are known to be the
preorder, in-order and post-order
11. The height of a binary tree is the sequence of a binary tree. But it is not
maximum number of edges in any root to known which one is which binary tree.
leaf path. The maximum number of nodes I. MBCAFHPYK
in a binary tree of height h is II. KAMCBYPFH
(A) 2h (C) 2h+1 – 1 III. MABCKYFPH
(B) (D) Pick the true statement from the
following
12. The maximum number of binary trees (A) I and II are preorder and inorder
that can be formed with three unlabeled sequences, respectively
nodes is (B) I and III are preorder and postorder
(A) 1 (C) 4 sequences, respectively
(B) 5 (D) 3 (C) II is the inorder sequence, but
nothing more can be said about the
13. The inorder and preorder traversal of a other two sequences
binary tree are d b e a f c g and (D) II and III are the preorder and
a b d e c f g respectively inorder sequences, respectively

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 142
GATE QUESTION BANK DSA

Common Data questions 17, 18 and 19: CS - 2011


A Binary search Tree (BST) store value in 21. We are given a set of n distinct elements
the range 37 to 573. Consider the and an unlabeled binary tree with n
following sequences of keys. nodes. In how many ways we can
I. 81, 537,102,439,285,376,305 populate the tree with the given set so
II. 52,97,121,195,242,381,472 that it becomes a binary search tree?
III. 142,248,520,386,345,270,307 (A) 0 (C) n!
IV. 550,149,507,395,463,402,270 (B) 1 (D) .

17. Suppose the BST has been unsuccessfully CS-2012


searched for key 273. Which all of the 22. The worst case running time to search for
above sequences list nodes in the order in an element in a balanced binary search
which we could have encountered them tree with n2n elements is
in the search? (A) Θ(n log n) (C) Θ (n)
(A) II and III only (B) Θ (n n) (D) Θ (log n)
(B) I and III only
(C) III and IV only 23. The height of a tree is defined as the
(D) III only number of edges on the longest path in
the tree. The function shown in the
18. Which of the following statements is pseudocode below is invoked as height
TRUE? (root) to compute the height of a binary
(A) I, II and IV are inorder sequences of tree rooted at the tree pointer root.
three different BSTs int height (treeptr n)
(B) I is preorder sequence of some BST { if (n = = NULL) return 1;
with 439 as the root if(n left = = NULL)
(C) II is an inorder sequence of some if (n right = = NULL) return 0;
BST where 121 is the root and 52 is a
else return // Box 1
leaf
else { h1 = height (n left);
(D) IV is a postorder sequence of some
if (n right = = NULL) return (1 + h1);
BST with 149 as the root
else * h = height (n right);
return ; //Box 2
19. How many distinct BSTs can be
}
constructed with 3 distinct keys?
}
(A) 4 (C) 6
}
(B) 5 (D) 9
The appropriate expression for the two
boxes Bl and B2 are
CS-2010
(A) :( height(n right))
20. In a binary tree with n nodes, every node
B2:(1 +max(hl,h2))
has an odd number of descendants. Every
(B) : (height(n right))
node is considered to be its own
B2 :(1+max(hl,h2))
descendant. What is the number of nodes
(C) : height(n right)
in the tree that have exactly one child?
B2 : max(h1,h2)
(A) 0 (C) (n 1)/2
(D) :( height(n right))
(B) 1 (D) n 1
B2: max (h1,h2)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 143
GATE QUESTION BANK DSA

CS-2013 Struct treeNode


24. The preorder traversal sequence of a {
binary search tree is 30, 20, 10, 15, 23, 25, treeptr leftMostChild, rightSibling;
39, 35, 42. Which one the following is the };
postorder traversal sequence of the same int DoSomething (treeptr tree)
tree? {
(A) 10, 20, 15, 23, 25, 35, 42, 39, 30 int value=0;
(B) 15, 10, 25, 23, 20, 42, 35, 39, 30 if (tree != NULL) {
(C) 15, 20, 10, 23, 25, 42, 35, 39, 30 if (tree leftMostChild == NULL)
(D) 15, 10, 23, 25, 20, 35, 42, 39, 30 value = 1;
else
25. Which one of the following is the tightest value
upper bound that represents the time = DoSomething(tree leftMostChild);
complexity of the inserting an object into value = value +
a binary search tree of n nodes? DoSomething(tree rightSibling);
(A) O(1) (C) O(n) }
(B) O(log n) (D) O(n log n) return(value);
}
CS-2014 When the pointer to the root of a tree is
26. Consider the following rooted tree with passed as the argument to DoSomething,
the vertex labeled P as the root: the value returned by the function
P corresponds to the
(A) number of internal nodes in the tree.
(B) height of the tree.
Q R (C) number of nodes without a right
sibling in the tree.
(D) number of leaf nodes in the tree.

S T U V

W
The order in which the nodes are W visited
during an in – order traversal of the tree
is
(A) SQPTRWUV (C) SQPTWUVR
(B) SQPTUWRV (D) SQPTRUWV

27. Consider the pseudo code given below. The


function DoSomething() takes as argument a
pointer to the root of an arbitrary tree
represented by the leftMostChild-rightSibling
representation. Each node of the tree is of
type tree Node.
typedef struct treeNode* treeptr;

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 144
GATE QUESTION BANK DSA

Answer Keys and Explanations

1. [Ans. B] be p numbers after x, because right


n subtree of root contains p nodes.
= = = x is n – p
n

2. [Ans. C] 7. [Ans. B]
The number of internal nodes of a The root of the tree is stored at X [1]
complete k- ary tree of height h is Left X[i] stored at X[2i]
…… Right X[i] stored at X [2i+1]
If tree is complete Binary tree minimum it
= =n require n consecutive memory locations
= n( ) of
Here is the number of leaves at height x, x[1],…..x[n 1], x[n].
h
8. [Ans. C]
3. [Ans. A] 0 0
The inorder traversal of a binary search
tree is always in sorted order or in
increasing order of a given sequence. So,
the in order traversal of the tree T is
9,10,15,22,23,25,27,29,40,50,60,95 0

4. [Ans. D]
5
( ) possi le ( ) Possible
6 possible( )
3
Possible
8
1 4

2 7

5. [Ans. B]
Draw the tree as per the definition and
count the nodes.
dif =2 dif =2
dif =2 ( ) not Possible ( ) Possible
dif =1 dif =0
dif =2
dif =2 dif =2 Because 43 is less than 47, but placed in
dif =0 dif =1
dif =1 right subtree of 47
dif =2 dif =0
dif =0 dif =1
dif =0 9. [Ans. B]
dif =0
If a tree of height 4 will be down.
In which at third level 3 nodes can have
6. [Ans. C] 2- children 5- nodes can have one
If we insert the number x, first it becomes children to fulfill the given requirement.
the root of resulting B.S.T. There should No. of leaf nodes will be 11

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 145
GATE QUESTION BANK DSA

Tree will be like:- a

dbe fcg
nodes in nodes in right
left subtree subtree
Second node in preorder is b, so again
1 2 3 4 5 6 7 8 9 10 11 dividing,
a
10. [Ans. C]
The given routine will return the number b c
of leaf nodes in the tree
Since the function is recursive, the left d e f g
child invoked function of a node will Postorder will be : d e b f g c a
return number of leaves in left subtree,
right child invoked function will return 14. [Ans. C]
number of leaves in right subtree. For a complete n – ary tree where each
Both will e added and returned ⇒ node has n children or no children,
total number of leaves. following relation holds L = (n 1) *I +1,
where L is the number of leaf nodes and
11. [Ans. C] I is the number of internal nodes. Let us
Maximum nodes in binary tree of height find out the value of n for the given data :
0= 1= ( ) L = 41, I = 10 implies
Maximum nodes in binary tree of height 41 = 10* (n ) n=
1= 3= ( )
Maximum nodes in inary tree of height 15. [Ans. B]
h=( ) We have post order traversal and the tree
is Binary Search tree. So, in order
12. [Ans. B] traversal of Binary Search Tree is
sequence order , , ,………..,n. By using
inorder, postorder can construct unique
Binary Tree with in O (n) time.
3 unlabeled nodes
Possible Binary tress total = 5 16. [Ans. D]
Formula = Last element of postorder search must
match with the first element of pre-order
( )
= = = = search. That means first is postorder,
second is preorder and third one is
inorder.
13. [Ans. A]
Inorder : d b e a f c g
Preorder : a b d e c f g
As a is the first node in pre-order, it must
be the root of the tree So, according to
inorder,

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 146
GATE QUESTION BANK DSA

17. [Ans. A] 273 is smaller than 395. So it should be


I. searched in left subtree instead of going
for 463.
0
18. [Ans. C]
(A) It is incorrect because in order
sequence of BST gives sorted list in
increasing order.
0
ncorrect
(B) In preorder sequence of BST, root
will be processed first. So 439 should
Incorrect, 273 is smaller than 285. So,
be the first no in sequence. So it is
from 285, search should proceed in the
not true
left subtree
(C) Corrrect.
121
II.
97 195
52 242
381
1 472

(D) Incorrect
149 root, then it should come at the
0
end of sequence.
But option C can be possible, where
orrect 97 is left child of root and 52 is left
child of it.
.
52 will be leaf node

19. [Ans. B]
0 Consider keys 3, 4, 5
3,4,5 3,4,5 3,4,5 3,4,5 3,4,5
5 5
3 4
3
3
0
5 5 4
4 3
4
4 3
5
0

orrect

Number of distinct BSTs: 5


V 0

20. [Ans. A]
0 Now, if any of the nodes is having exactly
one child then, it will be having even
number of descendant (2) because each
node is also its own descendent, which is
0
not possible in this tree structure. Hence,
0 zero is right.
ncorrect

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 147
GATE QUESTION BANK DSA

21. [Ans. B] 30
n = {1 , 2 , 3}
20
2 39

⇒ 10
23

42
1 35
3 15

22. [Ans. C] 25. [Ans. C]


Time = O (log2n 2n) Upper bound is O(n), because if the BST is
= O (log n log ) skewed tree then time is equal to number
= O (log ) of elements
= O (n)

23. [Ans. A]
E.g.
h = max(0, 0) h = 0 ,
return max(h , h )
26. [Ans. A]
Inorder traversal of m – ary tree:
f T , T , ……, Tm are su trees then
h = 0, h = 0 Return ‘0’
inorder traversal is
visit (T1)
0 visit (root)
Return ‘0’ visit (T ,……,Tm)
Follow inorder for T ,…..,Tm.
Return ‘0’ According to this logic, inorder traversal
of given tree is
another e.g. SQPTRWUV
return ( (height(n right)

27. [Ans. D]
At every node, if left sibiling = null,
( height(n right))
value =1 & it is added to Dosomething
return ‘ ’ (right sibiling).
If right sibiling = null then value = 0 is
returned & it is added to value.
return 0,
Value = 1 + 0 = 1
It is counting number of leaf nodes.
Option ‘ ’ is correct y going through
options.

24. [Ans. D]
Postorder travel sequences
15, 10 ,23, 25, 20, 35, 42, 39, 30
Preorder
30, 20, 10, 15, 23, 25, 39, 35, 42

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 148
GATE QUESTION BANK DSA

Height Balanced Trees (AVL Trees, B and )


CS-2008 6. Suppose we have a balanced binary
1. A B-tree of order 4 is built from scratch by search tree T holding n numbers. We are
10 successive insertions. What is the given two numbers L and H and wish to
maximum number of node splitting sum up all the numbers in T that lie
operations that may take place? between L and H. Suppose there are m
(A) 3 (C) 5 such numbers in T. If the tightest upper
(B) 4 (D) 6 bound on the time to compute the sum is
the value of
2. Which of the following is TRUE? a + 10b + 100c + 1000d is _______________.
(A) The cost of searching an AVL tree is
(log n) but that of a binary search
tree is O(n).
(B) The cost of searching an AVL tree is
(log n) but that of a complete
binary tree is (n log n).
(C) The cost of searching a binary search
tree is (log n) but of an AVL tree is
(n).
(D) The cost of searching an AVL tree is
(n log n) but that of a binary search
tree is O(n).

CS-2009
3. What is the maximum height of any
AVL-tree with 7 nodes? Assume that the
height of a tree with a single node is 0.
(A) 2 (C) 4
(B) 3 (D) 5

CS-2010
4. Consider a -tree in which the maximum
number of keys in a node is 5. What is the
minimum number of keys in any non-root
node?
(A) 1 (C) 3
(B) 2 (D) 4

CS-2014
5. Consider a rooted n node binary tree
represented using pointers. The best
upper bound on the time required to
determine the number of subtrees having
exactly 4 nodes is ( ) Then the
value of a + 10b is _________.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 149
GATE QUESTION BANK DSA

Answer Keys and Explanations


1. [Ans. A] 5. [Ans. 1]
Consider a B –tree of order 4. To find subtrees from a tree of n nodes, it
takes O(n) [Dynamic Programming]
So
( )

a = 1 and b = 0
A B – tree of order m contains n records So
and if each node contains b records on the a + 10 b = 1 + (10 0) = 1
average then the tree has about ⌈ ⌉
leaves. If we split k nodes along the path 6. [Ans. 110]
from leave then Out of n number of balanced binary
⌈ ⁄ ⌉ search trees, to search for a number L in
tree, the time required is = O(log n).
In given problem n = 10 , b =3, m=4 So From L, to sum up of m elements the time
⌈ ⌉ needed is = m
Total time complexity = O
The given function
=
a = 0, b =1, c = 1, d = 0
2. [Ans. A]
Cost of searching BST :
Best case O (min height);
Worst case O (max height ) = O(n)
where n is total number of nodes. Worst
case can occur if the BST is skewed, but
AVL tree is always height balanced

3. [Ans. B]
+
1
+ 1
1
1 + 1
+
0 1 1
0
0 1 0
OR
0 0
x hei ht →
3

4. [Ans. C]
As per tree definition each node has to
be full or atleast 50% of its total capacity.
Here, order of B+ tree
= maximum of keys in a node +1 =6 (say b)
So, minimum number of keys in any
internal node is ceiling(b/2)=3

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 150
GATE QUESTION BANK DSA

Priority Queues

CS – 2005 4. Suppose the elements 7, 2, 10 and 4 are


1. A priority-Queue is implemented as a inserted in that order into the valid 3-ary
Max-Heap. Initially it is 5 elements. The max heap found in the above question,
level- order traversal of the heap is given Q.3. Which one of the following is the
below: 10, 8, 5, 3, 2. sequence of items in the array
Two new elements ‘1’ and ‘7’ are inserted representing the resultant heap?
in the heap in that order. The level-order (A) 10, 7, 9, 8, 3, 1, 5, 2, 6, 4
traversal of the heap after the insertion of (B) 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
the element is (C) 10, 9, 4, 5, 7, 6, 8, 2, 1, 3
(A) 10, 8, 7, 5, 3, 2, 1 (D) 10, 8, 6, 9, 7, 2, 3, 4, 1, 5
(B) 10, 8, 7, 2, 3, 1, 5
(C) 10, 8, 7, 1, 2, 3, 5 Common Data for Questions 5, 6, 7
(D) 10, 8, 7, 3, 2, 1, 5 An array X of n distinct integers is
interpreted as a complete binary tree. The
2. Suppose there are ⌈lo n⌉ sorted lists of index of the first element of the array is 0.
⌊ ⌋ elements each. The time complexity
of producing a sorted list of all these 5. The index of the parent of element
elements is: X [i] , i ≠0, is
(Hint: Use a heap data structure) (A) ⌊i 2⌋ (C) ⌈i 2⌉
(A) O(n log log n) (C) (n log n) (B) ⌈ i 2 2⌉ (D) ⌈ ⌉ 1
(B) (n log n) (D) (n3/2)
6. If only the root node does not satisfy the
CS – 2006
heap property, the algorithm to convert
Statement for Linked answer-questions
the complete binary tree into a heap has
3&4
the best asymptotic time complexity of
A 3-ary max heap is like a binary max
(A) O(n) (C) O(n log n)
heap, but instead of two children, nodes
(B) O(log n) (D) O(n log log n)
have 3 children. A 3-ary heap can be
represented by an array as follows: The 7. If the root is at level 0, the level of
root is stored in the first location, a[0], element X[i], i ≠0, is
nodes in the next level, from left to right, (A) ⌊lo i⌋ (C) ⌊lo i 1 ⌋
is stored from a[1] to a[3]. The nodes (B) ⌈lo i 1 ⌉ (D) ⌈lo i⌉
from the second level of the tree from left
to right are stored from a[4] location 8. Which of the following sequences of array
onward. An item x can be inserted into a elements forms a heap?
3-ary heap containing n items by placing x (A) {23, 17, 14, 6, 13, 10, 1, 12, 7, 5}
in the location a[n] and pushing it up the (B) {23, 17, 14, 6, 13, 10, 1, 5, 7, 12}
tree to satisfy the heap property. (C) {23, 17, 14, 7, 13, 10, 1, 5, 6, 12}
(D) {23, 17, 14, 7, 13, 10, 1, 12, 5, 7}
3. Which one of the following is a valid
sequence of elements in an array 9. In a binary max heap counting n numbers
representing 3-ary max heap? the smallest element can be found in time
(A) 1, 3, 5, 6, 8, 9 (C) 9, 3, 6, 8, 5, 1 (A) n (C) lo
(B) 9, 6, 3, 1, 8, 5 (D) 9, 5, 6, 8, 3, 1 (B) lo lo n (D) 1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 151
GATE QUESTION BANK DSA

CS – 2007 (A) 10
10. Consider the process of inserting an
element into a Max Heap, where the Max
Heap is represented by an array. Suppose, 8
6
we perform binary search on the path
from the new leaf to the root to find the
4 5 2
position for the newly inserted element,
the number of comparisons performed is 1
(A) (log2 n) (C) (n)
(B)
(B) (log2 log2 n) (D) (n log2 n) 10

CS – 2008
11. We have a binary heap on n elements and
8 6
wish to insert n more elements (not
necessarily one after another) into this
heap. The total time required for this is 4 5 1 2
(A) (log n) (C) (n log n)
(C)
(B) (n) (D) (n2) 10

CS – 2009
Statement for linked answer Questions
5 6
12 & 13
Consider a binary max-heap implemented
using an array
4 8 2 1
(D)
12. Which one of the following array 5
represents a binary max- heap?
(A) {25, 12, 16, 13, 10, 8, 14}
(B) {25, 14, 13, 16, 10, 8, 12} 2 8
(C) {25, 14, 16, 13, 10, 8, 12}
(D) {25, 14, 12, 13, 10, 8, 16}
1 4 6 10
13. What is the content of the array after two
delete operations on the correct answer CS - 2014
to the previous question? 15. A priority queue is implemented as a
(A) {14, 13, 12, 10, 8} Max-Heap. Initially, it has 5 elements. The
(B) {14, 12, 13, 8, 10} level-order traversal of the heap is: 10, 8,
(C) {14, 13, 8, 12, 10} 5, 3, 2. Two new elements 1 and 7 are
(D) {14, 13, 12, 8, 10} inserted into the heap in that order. The
level-order traversal of the heap after the
CS – 2011 insertion of the elements is:
14. A max-heap is a heap where the value of (A) 10, 8, 7, 3, 2, 1, 5
each parent is greater than or equal to (B) 10, 8, 7, 2, 3, 1, 5
value of its children. Which of the (C) 10, 8, 7, 1, 2, 3, 5
following is a max-heap? (D) 10, 8, 7, 5, 3, 2, 1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 152
GATE QUESTION BANK DSA

Answer Keys & Explanations

1. [Ans. D] 3. [Ans. D]
root The 3 ary max heap
10 9
Heap after
inserting the 5 5
elements
8
5 6 8

2
3
3 1
root
10 So the valid sequence is 9, 5, 6, 8, 3, 1

Heap after inserting 1 4. [Ans. A]


5
After inserting 7, 2, 10, 4 the resultant
8 heap become
10, 7,9, 8, 3, 1, 5, 2, 6, 4
2 1
3 10

root
Heap after inserting 7 10
and heapify 7 9 8
7
8

3 1 5 2
2 1 5 6 4
3

5. [Ans. D]
2. [Ans. A] Complete binary tree ⇒ array
The algorithm as follows: representation
Prepare a heap of lists that means each 0
node will have a list. And treat the first
element as the key of each respective node.
Perform deleteMin, which will return list
1 2
whose first element is smallest among all.
Then delete the current list first element
4 5 6
and insert the same list now based on next
list element. Perform these steps 3
repeatedly until heap is empty completely. 9
Preparing heap step will take O(logn) as 7
8 1
there are logn list. Each deleteMin and
0
insert will take O(loglogn) as the height of
heap is O(loglogn). There will be n such
operation. Thus, A is correct choice.
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 153
GATE QUESTION BANK DSA

The index of parent element of x[1] =0 Index min


x[2] =0 = (20 + 21+22+ 23 + ------------+ 21-1)
x[3] =1 since index starts with “0”
x[4] =1 Indexmin = 2 2 1
x[5] =2
The level ‘1’ will have at most 2 elements
x[6] =2
so indexmax will be
i.e. for
Indexmax = 2 1 2 1
Index of the parent of x[i] ⇒ ⌈ 2⌉ 1
2 2 1
2 1 index 2 2 1
6. [Ans. B]
i=2 –1
1 When index is max
It is the complexity to adjust the tree to
⇒i 1 21 log (21+1 – 2+1)
satisfy heap property that will be equal to
⇒ lo 2(i +1)= 1 = log 2(21+1 – 1)< 1 + 1
the height of the tree.
when index is min
That is O(logn)
=1
So, to get value as an integer and equal to 1,
7. [Ans. C]
we need to apply floor operator.
0
evel 0 = 20 ⇒ So, the expression level is ⌊lo 1 ⌋

1 2 8. [Ans. C]
Level 1 = 2
= 21 {23, 17, 14, 7, 13, 10, 1, 5, 6, 12}
3 4 5 6
Level 2 = 4
23
= 22

7 8 9 10 11 12 13 14
0 1 3
Level 3 = 8 17 14
= 23
15 16 17 18
Level 4 = 16
Maximum no. of nodes at level 1 is 21 = 24 7 13 10 1
Since elements are stored in an array
To place an element at level ‘1’ we need to
put (completely all possible) max 5
6 12
possible elements at level “1-1” i.e. 21-1.
i.e. if we have to put an elements at level 4 Max heap
all the above 3 levels have max possible
capacities.
9. [Ans. A]
i.e. level’0’ → 1 MAX heap used to identity max element in
O (1) time. So, to identify min element
level’1’ → 2 require O (n), to apply the linear search.
level’2’ → 4
10. [Ans. A]
Inserting an element into a max heap
level’3’ → 8
takes O(1) times. When we perform a
So, the least index of an element at the binary search on the path from the new
level ‘1’ will be leaf to the root to find the position for the
newly inserted element takes (log n) as
expected.
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 154
GATE QUESTION BANK DSA

11. [Ans. B] Delete 16: Replace it by 8


If we have a binary heap on n elements 8
and we wish to insert n more elements
then we call a recursive function to build
heap which is responsible for
constructing the heap 14 12
The time spend by build heap is of the
order of the sum of heights of all the 13 10
vertices. But at most ⌈ 2 ⌉ vertices are
After heafying:
of height i. so the total time spent by build
heap is 14

n
∑ i n
2 13 12
= {14, 13, 12, 8, 10}
12. [Ans. C]
8 10
In a max-heap, parent node should have
value greater than or equal to both its
children 14. [Ans. B]
The structure of a heap is near-complete
25 binary tree. All levels except the last level
must be completely full. Option A does
not have this property, whereas options C
14 16 and D violate max-heap property that
every node must have higher value than it
children.
13 10 8 12
15. [Ans. A]
13. [Ans. D] Level order traversal is: 10, 8, 5, 3, 2
Delete 25 : Replace it by 12 So the tree will be
12 10

8 5
14 16
3 2
13 10 8
After inserting 1 the tree is
After heafying: 10
16
8 5

14 12 3 2 1

13 10 8

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 155
GATE QUESTION BANK DSA

After inserting 7 the tree is


10 10
Heapify
8 5 8 7

3 2 1 7 3 2 1 5

Final tree

Level order traversal of final tree


= 10, 8, 7, 3, 2, 1, 5

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 156
GATE QUESTION BANK DSA

Sorting Algorithms

CS – 2006 is the worst case time complexity of the


1. Which one the following inplace sorting quick sort?
algorithms needs the minimum number (A) (n) (C) ( )
of swaps? (B) (n log n) (D) ( g )
(A) Quick-sort (C) Selection sort
(B) Insertion sort (D) Heap sort CS-2011
7. An algorithm to find the length of the
2. The median of n elements can be found in longest monotonically increasing
O(n) time. Which one of the following is sequence of number in an array A[0 :n 1]
correct about the complexity of quick is given below.
sort, in which median is selected as pivot? Let denote the length of the longest
(A) (n) (C) (n2) monotonically increasing sequence
(B) (n log n) (D) (n3) starting at index i in the array.
Initialize
CS-2007 F r a i such that 0 i 2
3. Which of the following sorting algorithms if [i] [i ]
{
has the lowest worst case complexity? ther ise
(A) Merge sort (C) Quick sort Finally the length of the longest
(B) Bubble sort (D) Selection sort monotonically increasing sequence is
Max( )
CS-2008 Which of the following statements is
4. Consider the Quicksort algorithm. TRUE ?
Suppose there is a procedure for finding a (A) The algorithm uses dynamic
pivot element which splits the list into programming paradigm
two sub lists each of which contains at (B) The algorithm has a linear
least one-fifth of the elements. Let T(n) be complexity and uses branch and
the number of comparisons required to bound paradigm
sort n elements. Then (C) The algorithm has a non-linear
(A) T(n) 2T (n/5) + n polynomial complexity and uses
(B) T(n) T(n/5) + T(4n/5) + n branch and bound paradigm
(C) T(n) 2T (4n/5) + n (D) The algorithm uses divide and
(D) T(n) 2T (n/2) + n conquer paradigm.

CS-2009 CS-2012
5. What is the number of swaps required to 8. A list of n strings, each of length n, is
sort n elements using selection sort, in the sorted into lexicographic order using the
worst case? merge-sort algorithm. The worst case
(A) (n) (C) ( ) running time of this computation is
(B) (n log n) (D) ( g ) (A) O(n log n) (C) O (n2 + log n)
(B) O(n2 log n) (D) O(n2)
6. In quick sort, for sorting n elements, the
( ) the smallest element is selected as
pivot using an O(n) time algorithm. What

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 157
GATE QUESTION BANK DSA

CS-2013 12. Suppose P, Q, R, S, T are sorted sequences


9. Which one of the following is the tightest having lengths 20,24,30,35,50
upper bound that represents the number respectively. They are to be merged into
of swaps required to sort n numbers a single sequence by merging together
using selection sort? two sequences at a time. The number of
(A) ( g ) (C) ( g ) comparisons that will be needed in the
(B) ( ) (D) ( ) worst case by the optimal algorithm for
doing this is ____.
10. The number of elements that can be
s rted i Θ( g ) time usi g heap s rt is 13. You have an array of n elements. Suppose
(A) Θ( ) (C) Θ ( ) you implement quicksort by always
(B) Θ(√ g ) choosing the central element of the array
(D) Θ( g )
as the pivot. Then the tightest upper
bound for the worst case performance is
CS-2014
(A) O( ) (C) Θ( g )
11. Let P be a quick sort program to sort
(B) O(n log n) (D) O( )
numbers in ascending order using the
first element as the pivot. Let t and t be
the number of comparisons made by P for
the inputs [1 2 3 4 5 ] and [4 1 5 3 2]
respectively. Which one of the following
holds?
(A) t (C) t t
(B) t t (D) t t

Answer Keys and Explanations


1. [Ans. C] records with key less than v appear in
In selection sort, minimum number of [ ] … [j 1] and all those with keys v
swaps taken compared to other sorting r greater appear i [j ] … [ ] we
techniques. then apply quicksort recursively to
No. of swaps = O(n) [ ] … A[j 1] a d [j ] … [ ]
No. of comparisons = O( ) The recursion equation becomes for some
In every pass, it constructs sorted sub- value of i
arrays and places the next element in
proper position in the sorted sub array. ( ) ∑( (i ) ( ))
So, we need only 1 swap in every pass
he s uti f the ( ) ( g )
But to calculate median every time [pass]
2. [Ans. C]
it require at least (n2) time. Total time
If the median of n elements can be found
requireme t ( 2).
in O(n) time and we select the median as
pivot. Then quicksort of n elements of an
array [ ] …… [ ] as f s We
permute the elements in the array so that
for some index j with value v all the

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 158
GATE QUESTION BANK DSA

3. [Ans. A] 9. [Ans. B]
Sorting Worst case complexity Selection sort
Algorithm (with n input) Selects the next big element and swaps
Merge sort O(nlogn) with initial elements
Comparisons – O ( )
Bubble sort ( )
Swaps – O(n)
Quick sort ( )
10. [Ans. C]
Selection sort ( )
If we have an array of x elements then
time complexity to sort x elements using
4. [Ans. B] heap sort is (x g x).
If we want to sort n elements with the We need to find value of x so that time
help of Quicksort algorithm. If pivot complexity to sort x elements gets ( g )
elements which split the list into two sub- We can direct discard option (A) & (D).
lists each in which one list contains one Now check option (C)
fifth element or n/5 and other list g g
[ g( )]
contains 4n/5 and balancing takes n. So g g g g
( ) ( / ) (4 / )
[Note : n ] g( )
g [ ]
g g

5. [Ans. A] ( )
In each pass there can be at most 1 swap. ( g )
There are n such passes in selection sort ∴ pti (C) is c rrect
i.e. maximum n swaps will happen in
worst case. 11. [Ans. C]
First input [1 2 3 4 5 ] is the worst case of
6. [Ans. B] quicksort and it will require more no.of
The relation T(n) = T(n/4)+T(3n/4)+n comparisons than input 2 [4 1 5 3 2]
The pivot element is selected in a such
way that it will divide the array into 1/4th 12. [Ans. 358]
and 3/4th always solving this relation When we are merging two sorted lists of
given (n log n). lengths m and n, the maximum number of
comparisons will be m+n 1. Also the
7. [Ans. A] worst case merging is done by merging
The algorithm uses dynamic program the two smallest length sequences.
paradigm. The given lengths of sequences are: L1:20,
L2:24, L3:30, L4:35, L5:50.
8. [Ans. B] Step1: The number comparisons in
In merge – sort algorithm no. of splits are merging sequences L1, L2 is
proportional to height and in each level ( 0 4 ) 4 (Sequence L6)
work done is . Step2: The number comparisons in
∴ ta ime C mp exity ( log n) merging sequences L3, L4 is
(30+35 1)=64 (sequence L7)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 159
GATE QUESTION BANK DSA

Step 3: The number comparisons in


merging sequences L6, L5 is
(44+50 1)=93 (sequence L8)
Step4: The number comparisons in
merging sequences L8, L7 is
(94+65 1)=158 (final sequence)
So the total number of comparisons:
43+64+93+158 = 358

13. [Ans. A]
The worst case time complexity of quick
sort is ( ) irrespective of whether pivot
element is first element or middle element
or last element. If the input array is such
that middle element is the minimum or
maximum one, then the worst case can
occur

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 160
GATE QUESTION BANK DSA

Graph Algorithms

CS – 2005 5. To implement Dijkstra’s shortest path


1. An undirected graph G has n nodes. Its algorithm on unweighted graphs so that it
adjacency matrix is given by an n × n runs in linear time, then data structure to
square matrix whose be used is
(i) diagonal elements are 0’s and (A) Queue (C) Heap
(ii) non-diagonal elements are 1’s. (B) Stack (D) B-tree
Which one of the following is TRUE?
(A) Graph G has no minimum spanning 6. Consider the following graph:
tree (MST). 2

(B) Graph G has a unique MST of cost


b d
n – 1. 4
(C) Graph G has multiple distinct MST’s, 1
1
each of cost n – 1.
a 3 2 3 f
(D) Graph G has multiple spanning trees
of different costs. 5
6
4
2. Let G (V, E)be an undirected graph with c e

positive edge weights. Dijkstra’s single


7
source shortest path algorithm can be
implemented using the binary heap data Which one of the following can’t be the
structure with time complexity? sequence of edges added, in that order to
(A) O( |V|2 ) a minimum spanning tree using Kruskal’s
(B) O( |E| + |V| log|V|) algorithm?
(C) O(|V|log|V|) (A) ( a – b), (d – f), (b – f), (d – c), (d – e)
(D) O((|E| + |V|) log |V|) (B) ( a – b), (d – f), (d – c), (b – f), (d – e)
(C) ( d – f), (a – b), (d – c), (b – f), (d – e)
3. In a depth first traversal of a graph G with (D) ( d – f), (a – b), (b – f), (d – e), (d – c)
n vertices, k edges are marked as tree
edges. The number of connected 7. Let T be a depth first search tree in an
components in G is undirected graph G. Vertices u and v are
(A) k (C) n k – 1 leaves of this tree T. The degrees of both u
(B) k + 1 (D) n – k and v in G are at least 2. Which one of the
following statements is true?
(A) There must exist a vertex w adjacent
CS – 2006
to both u and v in G
4. Consider a weighted complete graph G on
(B) There must exist a vertex w whose
the vertex set {v1, v2, …. , vn} such that the
removal disconnect u and v in G
weight of the edge (vi, vj) is 2| i – j|. The
(C) There must exist a cycle in G
weight of a minimum spanning tree of G is
containing u and v
(A) n – 1 (C) . / (D) There must exist a cycle in G
(B) 2n – 2
(D) n2 containing u and all its neighbor in G

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 161
GATE QUESTION BANK DSA

8. Consider the depth-first-search of an 12. Let be the minimum weight among all
undirected graph with 3 vertices P, Q and edge weights in an undirected connected
R. Let discovery time d(u) represent the graph. Let e be a specific edge of weight
time instant when the vertex u is first w. Which of the following is FALSE?
visited and finish time f(u) represents the (A) There is a minimum spanning tree
time instant when the vertex u is last containing e.
visited. Given that (B) If e is not in minimum spanning tree
d(P) = 5 units f(P) = 12 units T, then in the cycle formed by adding
d(Q) = 6 units f(Q) = 10 units e to T, all edges have the same
d(R) = 14 units f(R) = 18 units weight.
Which one of the following statements is (C) Every minimum spanning tree has an
TRUE about the graph? edge of weight .
(A) There is only one connected component (D) e is present in every minimum
(B) There are two connected components spanning tree
and P and R are connected
(C) There are two connected components Linked data for Q.13 & Q.14
and Q and R are connected Suppose the letters a, b, c, d, e, f have
(D) There are two connected components probabilities , , , , ,
and P and Q are connected
respectively.
CS - 2007 13. Which of the following is the Huffman
9. In an unweighted, undirected connected code for the letters a, b, c, d, e, f?
graph, the shortest path from a node S to (A) 0, 10, 110, 1110, 11110, 11111
every other node is computed most (B) 11, 10, 011, 010, 001, 000
efficiently, in terms of time complexity by (C) 11, 10, 01, 001, 0001, 0000
(A) Dijkstra’s algorithm starting from S (D) 110, 100, 010, 000, 001, 111
(B) Warshall’s algorithm
14. What is the average length of the correct
(C) Performing a DFS starting from S
answer to above question?
(D) Performing a BFS starting from S
(A) 3 (C) 2.25
(B) 2.1875 (D) 1.9375
10. What is the largest integer m such that
every simple connected graph with n 15. Consider the DAG with
vertices & n edges contains at least m V = {1, 2, 3, 4, 5, 6}, shown below
different spanning trees? 2 5
(A) 1 (C) 3
(B) 2 (D) n
1
11. A depth-first search is performed on a
directed acyclic graph. Let d[u] denote the
time at which vertex u is visited for the 3 6
first time & f[u] the time at which the dfs Which of the following is NOT a
call to the vertex u terminates. Which of topological Ordering?
the following statements is always true (A) 1 2 3 4 5 6
for all edges (u,v) in the graph? (B) 1 3 2 4 5 6
(A) d[u] < d[v] (C) f[u] < f[v] (C) 1 3 2 4 6 5
(B) d[u] < f[v] (D) f[u] > f[v] (D) 3 2 4 1 6 5

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 162
GATE QUESTION BANK DSA

CS – 2008 a 5 d 10 g
1 3
16. The most efficient algorithm for finding 2
b 6 f
the number of connected components in 7 i
an undirected graph on n vertices and m 6 3 8 8
edges has time complexity:
c e h
(A) (n) (C) (m + n) 7 12

(B) (m) (D) (mn) (A) (a, h ), (d ,f ), (f ,c ), (g ,i ), ( d ,a ),


(g, h), ( c ,e ), (f ,h )
17. The Breadth First Search algorithm has (B) (c ,e ), (c, f ), (f, d ), (d ,a ), (a ,b ),
been implemented using the queue data (g ,h ), (h ,f ), (g ,i )
structure. One possible order of visiting (C) (d ,f ), (f ,c ), (d ,a ), ( a ,b ), (c ,e ),
the nodes of the following graph is (f ,h ), (g ,h ), (g ,i )
M O
(D) (h ,g), (g ,i ), (h ,f ), (f ,c ), (f ,d ),
N
(d ,a ), (a ,b ), (c, e)

20. G is a graph on n vertices and 2n 2


R Q
edges. The edges of G can be partitioned
P
into two edge-disjoint spanning trees.
(A) MNOPQR (C) QMNPRO Which of the following is NOT true for G?
(B) NQMPOR (D) QMNPOR (A) For every subset of k vertices, the
induced sub graph has a most 2k 2
18. edges.
3
b e (B) The minimum cut in G has a least two
2
2 1 edges
1
a c
5 h f (C) There are two edges-disjoint paths
1
3 2 between every pair of vertices
2 3

d 2 g (D) There are two vertex-disjoint paths


between every pair of vertices
Dijkstra’s single source shortest path
algorithm when run from vertex a in the
21. The subset-sum problem is defined as
above graph, computes the correct
follows: Given a set S of n positive
shortest path distance to
integers and a positive integer W,
(A) Only vertex a
determine whether there is a subset of S
(B) Only vertices a, e, f, g, h
whose elements sum to W.
(C) Only vertices a, b, c, d
An algorithm Q solves this problem in
(D) All the vertices
O(nW) time. Which of the following
statement is false?
19. For the undirected, weighted graph given
(A) Q solves the subset-sum problem in
below, which of the following sequences
polynomial time when the input is
of edges represents a correct execution of
encoded in unary.
Prim’s algorithm to construct a Minimum
(B) Q solves the subset-sum problem in
Spanning Tree?
polynomial time when the input is
encoded in binary.
(C) The subset sum problem belongs to
the class NP
(D) The subset sum problem is NP-hard

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 163
GATE QUESTION BANK DSA

Linked Answers Questions Q.22 and Q.23 Q. Finds whether any negative weighted
The subset-sum problem is defined as cycle is reachable from the source.
follows. Given a set of n positive integers, (A) P only (C) Both P and Q
S *a , a , a , . . . . . , a + and a positive (B) Q only (D) Neither P nor Q
integer W is there a subset S whose
elements sum of W? A dynamic program Common Data for Question Q.26 and Q.27
for solving this problem uses a A subsequence of a given sequence is just
2-dimensional Boolean array, X with n the given sequence with some elements
rows and W 1 columns X[i, j], (possibly none or all) left out. We are
1 i n, 0 j W, is TRUE if and only given two sequences X[m] and Y[n] of
if there is a subset of *a , a . . . . . , a + lengths m and n, respectively , with
whose elements sum to j. indexes of X and Y starting from 0.
22. Which of the following is valid for 26. We wish to find the length of the longest
2 i n and a j W common subsequence (LCS) of X[m] and
(A) ,i, j- ,i 1, j- ,i, j a - Y[n] as (m, n), where an incomplete
(B) ,i, j- ,i 1, j- ,i 1, j a - recursive definition for the function (I, j)
(C) ,i, j- ,i 1, j- ,i, j a - to compute the length of the LCS of X[m]
(D) ,i, j- ,i 1, j- ,i 1, j a - and Y[n] is given below:
(i, j) = 0, if either i = 0 or j = 0
23. Which entry of the array X, if TRUE, = expr1, if i, j>0 and x[i 1] = ,j 1-
implies that there is a subset whose = expr2, if i, j>0 and x[i 1] ,j 1-
elements sum to W? Which one of the following option is
(A) X[1, W] (C) X[n, W] correct?
(B) X[n, 0] (D) X[n 1, n] (A) expr1 (i 1, j) 1
(B) expr1 (i, j 1)
CS – 2009 (C) expr2 max( (i 1, j), (i, j 1))
24. Consider the following graph: (D) expr2 max( (i 1, j 1), (i, j))
5 b 2 e 5
6 27. The values of (i, j) could be obtained by
a 4 6 d g
6 3 dynamic programming based on the
5 correct recursive definition of (i, j) of the
3 c f 4
6 form given above, using an array L[M, N],
c
Which of the following is NOT the where M = m + 1 and N = n + 1, such
sequence of edges added to the minimum that L[I, j] = (i, j).
spanning tree using Kruskal’s algorithm Which of the following statements would
(A) (b,e) (e,f) (a,c) (b,c) (f,g) (c,d) be TRUE regarding the dynamic
(B) (b,e) (e,f) (a,c) (f,g) (b,c) (c,d) programming solution for the recursive
(C) (b,e) (a,c) (e,f) (b,c) (f,g) (c,d) definition of (i, j) ?
(D) (b,e) (e,f) (b,c) (a,c) (f,g) (c,d) (A) All elements of L should be initialized
to 0 for the values of (i, j) to be
25. Which of the following statement (s) properly computed
is/are correct regarding Bellman-Ford (B) The values of (i, j) may be computed
shortest path algorithm? in a row major order or column major
P. Always find a negative weighted cycle, order of L[M, N]
if one exists.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 164
GATE QUESTION BANK DSA

(C) The values of (i, j) cannot be the same. Let X denote the maximum possible
computed in either row major order or weight of a subsequence of a , a , … , a
column major order of L[M, N] and Y is the maximum possible weight of a
(D) L[p, q] needs to be computed before subsequence of a , a … a . Then X is equal
L [r, s] if either p < r or q < s to
(A) max( , a )
28. Let be a problem that belongs to the (B) max( , a 2)
class NP. Then which one of the following (C) max( , a 2 )
is TRUE? (D) a 2
(A) There is no polynomial time
algorithm for CS - 2011
(B) If can be solved deterministically Linked Answer Question Q.32 and Q.33
in polynomial time, then P = NP An undirected graph G(V, E) contains
(C) If is NP-hard, then it is NP n(n>2) nodes named v , v , … , v . Two
complete nodes v , v are connected if and only if
(D) may be undecidable 0<| i j | 2. Each edge (v , v ) is
assigned a weight i + j. A sample graph
CS – 2010 with n = 4 is shown below.
Common Data for Questions 29 and 30: 7
Consider a complete undirected graph
with vertex set {0, 1, 2, 3, 4}. Entry in
the matrix W below is the weight of the
edge {i,j}. 4 5
0 1 8 14 6
1 0 12 4 9
W = 8 12 0 7 3
1 4 7 02 3
[4 9 3 2 0]
32. What will be the cost of the Minimum
29. What is the minimum possible weight of a Spanning Tree (MST) of such a graph with
spanning tree T in this graph such that n nodes?
vertex 0 is a leaf node in the tree T? (A) (11n 5n) (C) 6n 11
(A) 7 (C) 9 (D) 2n 1
(B) n n 1
(B) 8 (D) 10
33. The length of the path from v to v in the
30. What is the minimum possible weight of a MST of previous question with n = 10 is
path P from vertex 1 to vertex 2 in this (A) 11 (C) 31
graph such that P contains at most 3 (B) 25 (D) 41
edges?
CS – 2012
(A) 7 (C) 9
34. Consider the directed graph shown in the
(B) 8 (D) 10
figure below. There are multiple shortest
31. The weight of a sequence a , a , … , a of paths between vertices S and T. Which
real numbers is defined as .A one will be reported by Dijkstra’s shortest
path algorithm? Assume that, in any
subsequence of a sequence is obtained by
iteration, the shortest path to a vertex v is
deleting some elements from the sequence,
keeping the order of the remaining elements
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 165
GATE QUESTION BANK DSA

updated only when a strictly shorter path 3. If a problem A is NP-Complete, there


to v is discovered. exists a non-deterministic polynomial
2 time algorithm to solve A
2 G (A) 1, 2 and 3 (C) 2 and 3 only
1
1
(B) 1 and 2 only (D) 1 and 3 only
1
4
7
4
3
CS – 2014
S 38. Let G be a graph with n vertices and m
D
4
3 edges. What is the tightest upper bound
5
on the running time of Depth First Search
3 5
T on G, when G is represented as an
adjacency matrix?
(A) SDT (C) SACDT
(A) (n) (C) ( )
(B) SBDT (D) SACET
(B) (n m) (D) ( )
35. Let G be a weighted graph with edge
weights greater than one and G be the 39. Suppose a polynomial time algorithm is
graph constructed by squaring the discovered that correctly computes the
weights of the edge in G. Let T and T be largest clique in a given graph. In this
the minimum spanning trees of G and G scenario, which one of the following
respectively, with total weights t and t . represents the correct venn diagram of
Which of the following statements are the complexity classes P, NP and NP
TRUE? Complete (NPC)?
(A) T = T with total weight t = t (A) NP
P
(B) T = T with total weight t t
(C) T T but total weight t t
(D) None of the above NPC

CS – 2013 (B)
36. What is the time complexity of Bellman – P NP
Ford single – source shortest path NPC
algorithm on a complete graph of n
vertices?
(A) ( ) (C) ( )
(B) ( log ) (D) ( log )
(C) P = NP
37. Which of the following statements are NPC
TRUE?
1. The problem of determining whether
there exists a cycle in an undirected
graph is in P. (D)
2. The problem of determining whether P = NP = NPC
there exists a cycle in an undirected
graph is in NP.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 166
GATE QUESTION BANK DSA

40. Consider the tree arcs of a BFS traversal (C) Solvable in constant time since any
from a source node W in an unweighted, input instance is satisfiable.
connected, undirected graph. The tree T (D) NP-hard, but not NP-complete.
formed by the tree arcs is a data structure
for computing
(A) the shortest path between every
pair of vertices.
(B) the shortest path from W to every
vertex in the graph.
(C) the shortest paths from W to only
those nodes that are leaves of T.
(D) the longest path in the graph.

41. Suppose depth first search is executed on


the graph below starting at some
unknown vertex. Assume that a recursive
call to visit a vertex is made only after
first checking that the vertex has not been
visited earlier. Then the maximum
possible recursion depth (including the
initial call) is__________.

42. Consider the decision problem 2CNFSAT


defined as follows:
{ϕ | ϕ is a satisfiable propositional
formula in CNF with at most two literals
per clause}
For example,
ϕ (x x ) (x x ) (x x ) is a
Boolean formula and it is in 2CNFSAT.
The decision problem 2CNFSAT is
(A) NP-Complete.
(B) Solvable in polynomial time by
reduction to directed graph
reachability.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 167
GATE QUESTION BANK DSA

Answer Keys and Explanations


1. [Ans. C] According to the question the weight of
Use induction on the number of vertices. edge in G is
Consider 4 4 matrix and the | v1 – v2 |, | v2 –v3|, …….|v , v | is 1.
corresponding graph G. In the case of minimum spanning tree of a
011 0 graph G we will add upto (n – 1) vertices,
100 1 so, the weight of a minimum spanning
100 1 tree of G
01 10
1 2 3 4 ∑ 2| |

2∑| |

This graph has more than one minimum 2 ∑|1|


spanning trees that are structurally
different and each of them will have cost 2|n 1|
3. 2(n 1) 2n 2

2. [Ans. D] 5. [Ans. C]
In Dijkstra’s algorithm for single – source Heap or priority queue are very neat data
shortest path when we implement the structures allowing :
algorithm using the binary heap data  Add an element to heap with an
structure then total updates of E edges associated priority.
require O(logv) time and total spent time  Remove the element from the heap or
becomes O(|E|log|V|) but of |E| is much priority queue that has the highest
less than |V|2 then time priority, and return it.
O(E+ V) log V  Peak at the element with highest
priority without removing it.
3. [Ans. D] A simple way to implement a heap or
If k edges are marked as tree edges then priority queue data type is to keep a list of
k + 1 vertices are connected to each elements, and search through the list for
other. That means n – k 1 vertices are the highest priority which taken O(n)
not connected with any of k + 1 vertices. time to implement Dijkstra’s shortest
Now we can maximize number of path algorithm on unweighted graph.
components only if all n – k – 1 vertices
are isolated. 6. [Ans. D]
Therefore, n – k – 1 + 1 = n – k In the Kruskal’s algorithm we will start
This 1 is for the component having k+1 with the edge with minimum weight and
vertices add the edges in non-decreasng order if it
does not form a cycle.
4. [Ans. B] (A) (a b), (d f), (b f), (d c), (d, e)
Given vertex set of G = {v1 , v2 , ……, vn} 1 + 1 + 2 + 2 + 3 =9
Weight of an edge = 2 |i j| : (vi , vj) ϵ G (B) (a b), (d f), (d c), (b f), (d, e)
1 + 1 + 2 + 2 + 3 =9

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 168
GATE QUESTION BANK DSA

(C) (d f), (a b), (d c), (b f), (d, e) 9. [Ans. D]


1 + 1 + 2 + 2 + 3 =9 In an unweighted graph performing a BFS
(D) (d f), (a b), (b f), (d e), (d c) starting from S takes O(n) time if graph
1 + 1 + 2 + 3 + 2 =9 contains n vertices. Dijkstra’s algorithm
In choice (D), we add (d e) before (d c) only finds the single source shortest path
which violets the algorithm. and takes O(n ) time but it is good for
weighted graph. Warshall’s algorithm for
7. [Ans. D] all pair shortest path takes O( ) time but
Let the node u has some ‘n’ adjacent it is also applicable for weighted graph.
nodes, numbered 1 to n. In that case, to
make u as a leaf node of the tree. 10. [Ans. D]
⇒ We must discover all the adjacent Consider the following graph. Only one
nodes of (u) first and next come to (u) edge is needed to be removed for
⇒ In that process let us say we have first converting it into spanning tree. We have
discovered the node (1) [Each of the n choices for removing the edges.
nodes 1, 2, 3 ……….. n must be of at least a b c d f
2nd degree nodes. Since if any one of them,
say node p is of degree 1 it is already a
leaf node and it can’t be. If its is , then our
node u can’t be a leaf node then we have
to go through u to get to p] 11. [Ans. D]
⇒ fter discovering the first adjacent Termination time of vertex which is
node , we have to go on discovering nodes coming earlier is more than that of the
except u till al the adjacent nodes of u are vertex which is coming later
discovered.
12. [Ans. D]
6 w be the minimum weight among all edge
5
u weights in an undirected connected
graph. e is the specific edge of weight w. It
5 may be possible that another edge in the
1 2
3 graph having weight w which had been
4 added to minimum spanning tree and
when we add e to minimum spanning tree
it from a simple circuit. So we can’t
⇒ So there must be a path in G having all
include e in every minimum spanning
the adjacent nodes of u connected.
tree.
⇒ As shown in the figure, then there will be
a cycle consisting u and all the neighbors of
13. [Ans. A]
node u
The probabilities are , , , , , .
8. [Ans. D] So, the Huffman code according to tree is
As per the time slices, the discovery time unique.
for Q is before the exit of P. And discovery 0, 10, 110, 1110, 111110,11111
of R happens only when Q and P finishes, represents a, b, c, d, e and f respectively.
which clearly indicates that the P and Q
are connected but not R

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 169
GATE QUESTION BANK DSA

source shortest path algorithm when run


1 from vertex a in the graph it includes all
0
the vertices. Dijkstra’s don’t work
1 a
0 properly in the edge that has negative
1
weight (b,e), (c, h). So algorithm results
0 b
correct result only for b,c,d.
1 c
0 19. [Ans. C]
1
d Prim’s algorithm
Prim’s algorithm starts at an random
f e vertex. Then edges added to this tree one
by one. The next edge (i, j) to be added is
14. [Ans. D] such that i is a vertex already included the
The average length of the tree is tree, j is a vertex not yet included and the
1 2 3 4 5 cost of (i, j) is minimum among all edges.
Here, when we start with the minimum
5
cost edge (a,b) so after (a,b) , (b,c) must
1.9375 be added to the tree in (A) option (d,f) is
added which is according to Krushkal’s
15. [Ans. D] algorithm and not Prim’s.
In topological sorting the partial ordering So, we take next minimum edge, i.e. (d,f).
of the DAG, must be preserved i.e, if a b Now starting with this, we select
in the DAG, then in the topological order, minimum cost edge from which is (f,c).
b must come after a, not before. Consider Thus, in this way , we move we move on
the ordering 3 2 4 1 6 5 . selecting next minimum cost edge at each
1 4 in the given DAG but 4 comes before node such that circuit is formed.
1 in 3 2 4 1 6 5 order which means that 3 Hence answer is (d,f), (f,c), (d,a), (a,b),
2 4 1 6 5 is not a topological order of the (c,e), (f, h), (g,h), (g,i)
given DAG.
20. [Ans. A]
16. [Ans. C] A vertex-induced subgraph (sometimes
The most efficient algorithm for finding simply called an "induced subgraph") is a
the number of connected components subset of the vertices of a graph G
(articulation point) in an undirected together with any edges whose endpoints
graph on n vertices and m edges using are both in this subset.
depth – first search take O(m + n) time. Now take any graph with 4 or 5 vertices
ssume n m. that follows given properties and you can
observe that the option (A) is not true.
17. [Ans. C]
The BFS using Queue data structure is
21. [Ans. B]
QMNPRO
When the input is encoded in binary,
subset sum problem is NP complete.
18. [Ans. C]
In given graph, the graph is directed and
22. [Ans. B]
from vertex a to all the vertices there exist
X[i, j] (2< = i < = n and a < =j<=w), is
a weighted path. So Dijkstra’s single
true , if any of the following is true

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 170
GATE QUESTION BANK DSA

1. Sum of weights excluding a is equal to 29. [Ans. D]


j, i.e., if x,i 1, j- is true. 0 1 2 3 4
2. Sum of weights including a is equal to 0 0 1 8 1 4
j, i.e., if x,i 1, j a - is true so that we 1 1 0 12 4 9
W 2 8 12 0 7 3
get (j a ) a as j
3 1 4 7 0 2
4 [4 9 3 2 0]
23. [Ans. C] We draw a graph
The entry X[n, W] is true, because we find 0
the weight W of subset of S which 8
1
contains n elements. 1
1 2
12
24. [Ans. D]
4 9 3
After adding (b,e) one can add either (e,f) 4
or (a,c)
7
Kruskals algorithm works based on
3 2 4
greedy strategy (picks minimum weight
We have to make minimum possible
edge).
spanning tree having vertex 0 as a leaf
Weight of edge (a,c) is less than (b,c). So it
node.
cannot come after (b,c) 0

25. [Ans. B]
Bellman-Ford shortest path algorithm 1
always finds whether any negative 4 3

weighted cycle which is reachable from


the source. 2
So minimum possible weight = 4+1+2+3
26. [Ans. C] = 10
l(i, j)
0 if either i 0 or j 0 30. [Ans. B]
l(i 1, j 1); From vertex 1 to vertex 2 we choose the
if i, j>0 and x,i 1- ,j 1- path
max(l(i 1, j), l(i, j 1));
if i, j>0 and x,i 1- ,j 1- 1
expr2 max(l(i 1, j), l(i, j 1))

4 3
27. [Ans. B]
(i, j) values can be computed in a row
major order or column major order of
L[M, N]. So weight = 1+4+3 = 8

28. [Ans. C] 31. [Ans. B]


It is given that NP If X and Y be two different maximum
If is NP-hard, and since it is given possible weights then we can say like
that NP this means that is either X and Y both will be equal or the
NP-complete difference between them will be because
Choice C is correct. of a . Because all other numbers are

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 171
GATE QUESTION BANK DSA

having some positive values in The recurrence can be written as sum of


denominator in weight. So those series
denominators will be decreasing weight. (2n – 2) + (2n 4) + (2n 6) + (2n 8) ….
Therefore 3 and solution of this recurrence is n – n + 1.
max( , a )

32. [Ans. B]
Minimum spanning tree for 2 nodes 4 6 here cost
would be 13

(v1) (v2)
Total weight 3
3
Minimum spanning tree for 3 nodes
n n 1 16 4 1 13
would be
(v1) (v2)
33. [Ans. C]
|
Any MST which has more than 5 nodes
(v3)
will have the same distance between v5
Total weight= 3 + 4 = 7
and v6 as the basic structure of all MSTs
Minimum spanning tree for 4 nodes
(with more than 5 nodes) would be
would be
following.
(v1) (v2) (v4)
(v1) (v2) (v4) (v6) …. (more even
|
numbered nodes)
(v3)
|
Total weight= 3 + 4 + 6 = 13
(v3)
Minimum spanning tree for 5 nodes
|
would be
(v5)
(v1) (v2) (v4)
|
|
.
(v3)
.
|
(more odd numbered nodes)
(v5)
Distance between v5 and v6
Total weight= 3 + 4 + 6 + 8 = 21
= 3 + 4 + 6 + 8 + 10 = 31
Minimum spanning tree for 6 nodes
would be
34. [Ans. D]
(v1) (v2) (v4) (v6)
A B C D E F G h
|
S 4 ③ ∞ 7 ∞ ∞ ∞ ∞
(v3)
B ④ ∞ 7 ∞ ∞ ∞ ∞
|
A ⑤ 7 ∞ ∞ ∞ ∞
(v5)
C 7 ⑥ ∞ ∞ ∞
Total weight= 3 + 4 + 6 + 8 + 10 = 31
E 7 ∞ 8 ⑩
We can observe from above examples that
when we add kth node, the weight of S T
spanning tree increases by 2k 2. Let T(n)
be the weight of minimum spanning tree. The shortest path from S T is SACET
T(n) can be written as
T(n) = T(n 1) + (2n 2) for n > 2
T(1) = 0, T(2) = 0 and T(2) = 3

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 172
GATE QUESTION BANK DSA

35. [Ans. D] For a complete graph time complexity


E.g. n(n 1)
O (n ) O(n )
2 2
a b

37. [Ans. A]
2 2 3 1. We can use “Depth irst Search”
Algorithm to check it there is a cycle
in an undirected graph. If we
d c encounter any “back edge” in “Depth
3
first search” then given undirected
4 graph has a cycle. DFS can be done in
a b
O(| | | |) time for graph G ( , ).
So, it is in P.
4 4 9 2. P NP,So, it is also in NP
3. NP-Complete problem NP by
definition every problem in NP can be
d c
solved in polynomial time using non-
9 deterministic alogrithms.
MST So, Answer is (A) i.e., 1, 2 and 3 are true.
a 2 b a 4 b
38. [Ans. C]
2 T 2 4
4 T DFS visits each vertex once and as it visits
c
each vertex, we need to find all of its
c c c
neighbors to figure out where to search
E.g. next. Finding all its neighbors in an
2 4
adjacency matrix requires O(V) times, so
overall the running time will be O( )
2 G 2 4 4

39. [Ans. D]
2 4
Then all NP & NPC problems can be
MST reduced to P problems. Because to
2 compute the largest clique is NPC
2 T 4 T 4 problem.

2 4
40. [Ans. B]
We can make different as well as same BFS is used in shortest path problems. So
MST also. it finds the shortest path from source
Option (D) is correct vertex to each and every vertex of a graph

36. [Ans. C] 41. [Ans. 19]


In a complete graph total no of edges is 15 8
21 18 5 2
n(n 1) 1
12
2 20 17 14
9
6 3
Time complexity of Bellman-ford
algorithm for a graph having n vertices 19
16 13 11 10 7 4
and m edges = O (nm)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 173
GATE QUESTION BANK DSA

Given that we have to call a function to


visit the node only after checking whether
node was visited or not. Now we start to
call a function from node 1, then the order
of visiting in order to get maximum
number of recursive calls is
1 3 4 7 6 5 8 9 10
11 13 14 15 18 17 16
19 20 21.
If we try to visit remaining nodes 12 & 2
in this series, the initial condition fails. So
maximum possible recursive calls depth
is 19.

42. [Ans. B]
2CNFSAT problem is solvable in
polynomial time by reduction to Directed
Graph Reachability.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 174
GATE QUESTION BANK DSA

Hashing
CS – 2007 CS – 2010
1. Consider a hash table of size seven, with Statement for Linked Answer Questions
starting index zero, and a hash function 3 and 4:
(3x+4) mod 7. Assuming the hash table is A hash table of length 10 uses open
initially empty, which of the following is
addressing with hash function
the contents of the table when the
sequence 1, 3, 8, 10 is inserted into the h(k) = k mod 10, and linear probing.
table using closed hashing? Note that – After inserting 6 values into an empty
denotes an empty location in the table hash table, the table is as shown below.
(A) 0
(B) 1
(C) 2 42
(D) 3 23
4 34
CS – 2009
2. The keys 12, 18, 13, 2, 3, 23, 5 and 15 are 5 52
inserted into an initially empty hash table 6 46
of length 10 using open addressing with 7 33
hash function h(k) = k mod 10 and linear 8
probing. What is the resultant hash table? 9
(A) 0 (B) 0
1 1 3. Which one of the following choices gives a
2 2 2 12 possible order in which the key values
3 23 3 13 could have been inserted in the table?
4 4 (A) 46, 42, 34, 52, 23, 33
5 15 5 5 (B) 34, 42, 23, 52, 33, 46
6 6 (C) 46, 34, 42, 23, 52, 33
7 7 (D) 42, 46, 33, 23, 34, 52
8 18 8 18
9 9 4. How many different insertion sequences
of the key values using the same hash
(C) 0 (D) 0 function and linear probing will result in
1 1 the hash table shown above?
2 12 2 12,2
(A) 10 (C) 30
3 13 3 13,3,23
(B) 20 (D) 40
4 2 4
5 3 5 5,15
6 23 6 CS – 2014
7 5 7 5. Consider a hash table with 9 slots. The
8 18 8 18 hash function is ℎ(k) = k mod 9. The
9 15 9 collisions are resolved by chaining. The
following 9 keys are inserted in the order:
5, 28, 19, 15, 20, 33, 12, 17, 10. The
maximum, minimum and average chain
lengths in the hash table, respectively, are
(A) 3, 0, and 1 (C) 4,0 and 1
(B) 3, 3, and 3 (D) 3,0 and 2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 175
GATE QUESTION BANK DSA

6. Consider a hash table with 100 slots.


Collisions are resolved using chaining.
Assuming simple uniform hashing, what
is the probability that the first 3 slots are
unfilled after the first 3 insertions?
(A) (
(B) (
(C) (
(D) ( (

Answer Keys and Explanations


1. [Ans.B] (7+1) mod 10 = 8 collision
Size of hash table = 7 (8+1) mod 10 = 9
h(x) = (3x+4) mod 7 So resulting hash table.
h(1) = (3.1+4) mod 7 = 7 mod 7 0
= 0; insert at 0th location. 1
h(3) = (3.3+4) mod 7 =13 mod 7
2 12
= 6; insert at 6th location.
h(8) = (3.8+4) mod 7 =28 mod 7 3 13
= 0; 0th position is already filled by 4 2
element 3 so insert 8 at next free 5 3
location which is 1st position
6 23
h(10) = (3.10+4) mod 7 =34 mod 7 = 6
but 6th position is already filled with 7 5
element 3. So insert 10 at next free 8 18
location which is 2nd position 9 15
1 8 10 3
0 1 2 3 4 5 6 3. [Ans. C]
h (46) = 6, location 6 is free hence get
2. [Ans. C]
12 mod 10 = 2 placed
18 mod 10 = 8 h (34) = 4, location 4 is free hence get
13 mod 10 = 3 placed
2 mod 10 = 2 collision h (42) = 2, location 2 is free hence get
(2+1)mod 10 = 3 again collision placed
(using linear probing) h (23) = 3, location 3 is free hence get
(3+1)mod 10 = 4
placed
3 mod 10 = 3 collision
(3+1) mod 10 = 4 collision h (52) = 2, location 2 is not free as 42 is
(using linear probing) already there. Linear probing will return
(4+1) mod 10 = 5 index 5. Hence, 52 will be placed at 52.
23 mod 10 = 3 collision h (33) = 3, linear probe will return
(3+1) mod 10 = 4 collision index 7
(4+1) mod 10 = 5 again collision
(5+1) mod 10 = 6
5 mod 10 = 5 collision 4. [Ans. C]
(5+1) mod 10 = 6 again collision Please notice 52 cannot be appear in any
(6+1) mod 10 = 7 of first three position of any input
15 mod 10 = 5 collision sequence otherwise we will not get the
(5+1) mod 10 = 6 collision needed hash table. Also, 33 can only
(6+1) mod 10 = 7 collision appear in the last position.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 176
GATE QUESTION BANK DSA

52 can appear only at 4th position and


5th position.
Thus, we will need to consider counting
as follows:
If 52 appears at 4th position then first
three number will have to be 42 23 34.
We can arrange these numbers in
fact(3) = 6.
Thus, we count all sequences where 52
appears at 4th position and 5th and 6th
positions are occupied by 46 and 33
respectively.
If 52 appears at 5th position then first
four numbers will have to be 42 23 34 46.
We can arrange these numbers in
fact(4) = 24.
Thus, total counting are 30.

5. [Ans. A]
Slot Keys Collisions
at slots
0 17 8
1 28
2 19 1
3 20 2
4 10 1, 2, 3
5 5
6 15
7 33 6
8 12 5, 6, 7
Total no of collision = 10
Average =

6. [Ans. A]
Collision resolution method: Chaining
As the 1st 3 slots must be empty
Probability to fill 1st element =
( )
Probability to fill 2nd element
= ( Collision resolution is chaining.
Same slot call be filled again )
Probability to fill 3rd element =
( ollision resolution is chaining. Same
slot call be filled again
Total probability

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 177
GATE QUESTION BANK Operating System

Introduction to Operating System


CS - 2005
1. The shell command
find-name password-print
is executed in /etc directory of a
computer system running Unix. Which of
the following shell commands will give
the same information as the above
command when executed in the same
directory?
(A) Is passwd
(B) cat passwd
(C) grep name passwd
(D) grep print passwd

2. A user level process in UNIX traps the


signal sent on a Ctrl-C input, and has a
signal handling routine that saves
appropriate files before terminating the
process. When a Ctrl-C input is given to
this process, what is the mode in which
the signal handling routine executes?
(A) kernel mode
(B) superuser mode
(C) privileged mode
(D) user mode

Answer Keys and Explanations


1. [Ans. A]
ls passwd will give the same information.

2. [Ans. A]
SIGKILL is signal which is generated by
Ctrl-C and this signal will execute in
kernel mode.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 178
GATE QUESTION BANK Operating System

Process Management
CS – 2005 P1 must complete use of R2 before P2
1. Consider the following code fragment: gets access to R2.
if (fork( ) == 0) P2 must complete use of R3 before P1
* a = a + 5; printf (“%d, %d\n”, a, &a); + gets access to R3.
else { a= a – 5; P1 must complete use of R4 before P2
printf (“%d, %d\n”, a, &a); + gets access to R4.
Let u and v be the values printed by the There are no other scheduling constraints
parent process and x and y be the values between the processes. If only binary
printed by the child process. Which one of semaphores are used to enforce the above
the following is TRUE? scheduling constraints, what is the
(A) u = x + 10 and v = y minimum number of binary semaphores
(B) u = x +10 and v y needed?
(C) u + 10 = x and v = y (A) 1 (C) 3
(D) u + 10 = x and v y (B) 2 (D) 4

2. Given below is a program which when CS – 2006


executed spawns two concurrent 4. The atomic fetch–and set x, y instruction
processes: unconditionally sets the memory location
Semaphore X:=0; x to 1 and fetches the old value of x in y
/* Process now forks into concurrent without allowing any intervening access
processes P1 & P2 */ to the memory location x. Consider the
P1 : repeat forever P2:repeat forever following implementation of P and V
V(X); P(X); functions on a binary semaphore S.
Compute; Compute; void P(binary_semaphore *S) {
P(X); V(X); unsigned y;
Consider the following statements about unsigned *x = & (S value); }
processes P1 and P2: do {
I: It is possible for process P1 to starve. fetch – and – set x, y;
II. It is possible for process P2 to starve. } while (y);
Which of the following holds? }
(A) Both I and II are true void V(binary_semaphore *S) {
(B) I is true but II is false S value = 0;
(C) II is true but I is false }
(D) Both I and II are false Which one the following is true?
(A) The implementation may not work if
3. Two concurrent processes P1 and P2 use context switching is disabled in P
four shared resources R1, R2, R3 and R4, (B) Instead of using fetch- and- set, a pair
as shown below. of normal load/ store can be used
P1: P2: (C) The implementation of V is wrong
Compute: Compute: (D) The code does not implement a
Use R1; Use R1; binary semaphore
Use R2; Use R2;
Use R3; Use R3;
Use R4; Use R4; 5. The process state transition diagram of an
Both processes are started at the same operating system is as given below.
time, and each resource can be accessed Which of the following must be FALSE
by only one process at a time. The about the above operating system?
following scheduling constraints exist
between the access of resources by the
processes:
P2 must complete use of R1 before P1
gets access to R1.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 179
GATE QUESTION BANK Operating System

Create a new (C) Lines 6 to 10 need not be inside a


process Schedule Exit critical section
Start Ready Running Terminated
(D) The barrier implementation is
I/O Complete Wait for I/O
correct if there are only two
or Resource completion or processes instead of three
released resource
7. Which one of the following rectifies the
Blocked
problem in the implementation?
(A) It is a multi-programmed operating (A) Lines 6 to 10 are simply replaced by
system process_arrived
(B) It uses preemptive scheduling (B) At the beginning of the barrier the
(C) It uses non- preemptive scheduling first process to enter the barrier
(D) It is a multi-user operating system waits until process_arrived becomes
zero before proceeding to execute
Common Data for Q. 6 & 7 P(S)
Barrier is a synchronization construct (C) Context switch is disabled at the
where a set of processes synchronizes beginning of the barrier and re-
globally i.e. each process in the set arrives at enabled at the end
the barrier and waits for all others to arrive (D) The variable process_left is made
and then all processes leave the barrier. Let private instead of shared
the number of processes in the set be three
and S be a binary semaphore with the usual CS - 2007
P and V functions. Consider the following C 8. Two processes P1 and P2 need to access a
implementation of a barrier with line critical section of code. Consider the
numbers shown on the left. following synchronization construct used
void barrier (void) { by the processes:
1 : P (S); /* P1 */
2 : process_arrived + +; while (true) {
3 : V (S) ; wants1 = true;
4 : while (process_arrived ! = 3); while (wants2 == true);
5 : P (S) ; /* Critical Section */
6 : process_left + + ; wants1 = false;
7 : if (process_left = = 3){ }
8 : process_arrived = 0; /* Remainder section */
9 : process_left = 0;
10: } /* P2 */
11 : V (S); while (true) {
} wants2 = true;
The variable process_arrived and while (wants1 == true);
process_left are shared among all /* Critical Section */
processes and are initialized to zero. In a wants2 = false;
concurrent program all the three
}
processes call the barrier function when
/* Remainder section */
they need to synchronize globally.
Here, wants1 and wants2 are shared
variables,which are initialized to false.
6. The above implementation of barrier is
Which one of the following statements is
incorrect. Which one of the following is
TRUE about the above construct?
true?
(A) It does not ensure mutual exclusion
(A) The barrier implementation is wrong
(B) It does not ensure bounded waiting
due to the use of binary semaphore S
(C) It requires that processes enter the
(B) The barrier implementation may
critical section in strict alternation
lead to a deadlock if two barrier
(D) It does not prevent deadlocks but
invocations are used in immediate
ensures mutual exclusion
succession

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 180
GATE QUESTION BANK Operating System

9. Processes P1 and P2 use critical_flag in 11. The contents of the text file t1.txt
the following routine to achieve mutual containing four lines are as follows:
exclusion. Assume that critical_flag is a1 b1
initialized to FALSE in the main program. a2 b2
get_exclusive_access ( ) a3 b2
{ a4 b1
if ( critical_flag == FALSE) The contents of the text file t2. txt
{ containing five lines are as follows:
critical_flag = TRUE; a1 c1
critical_region ( ); a2 c2
critical_flag = FALSE; a3 c3
} a4 c3
} a5 c4
Consider the following statements. Consider the following Bourne shell
(i) It is possible for both P1 and P2 to script:
access critical_region concurrently. awk – (Print $1, $2) ‘ t1.txt
(ii) This may lead to a deadlock. while read a b ;
Which of the following holds? do awk – v aV = $ a – v by = $b –
(A) (i) is false and (ii) is true ‘a V = = $1 (print aV, bV, $2) ‘ t2.txt
(B) Both (i) and (ii) are false done
(C) (i) is true and (ii) is false Which one of the following strings will
(D) Both (i) and (ii) are true NOT be present in the output generated
when the above script in run? (Note that
10. Synchronization in the classical readers the given strings may be substrings of a
and writers problem can be achieved printed line.)
through use of semaphores. In the (A) “b1 c1” (C) “b1 c2”
following incomplete code for readers- (B) “b2 c3” (D) “b1 c3”
writers problem, two binary semaphores
mutex and wrt are used to obtain CS - 2008
synchronization 12. A process executes the following code for
wait ( wrt ) (i = 0; i < n; i ++) fork ( );
writing is performed The total number of child processes
signal (wrt) created is
wait (mutex) (A) n (C) 2
readcount = readcount + 1 (B) 2 1 (D) 2 1
if readcount = 1 then S1
S2 13. The P and V operations on counting
reading is performed semaphores, where s is a counting
S3 semaphore, are defined as follows:
readcount = readcount – 1 P (s): s = s – 1;
if readcount = 0 then S4 if s < 0 then wait;
signal (mutex) V (s): s = s + 1;
The values of S1, S2, S3 and S4 (in that if s < = 0 then wakeup a process
order) are
waiting on s;
(A) signal (mutex), wait (wrt),
signal (wrt), wait (mutex) Assume that Pb and Vb, the wait and signal
(B) signal (wrt), signal (mutex), operations on binary semaphore are
wait (mutex), wait (wrt) provided. Two binary semaphores Xb and
(C) wait (wrt), signal (mutex), Yb are used to implement the semaphore
wait ( mutex), signal (wrt) operations P (s) and V (s) as follows:
(D) signal (mutex), wait (mutex), P(s): Pb (Xb);
signal (mutex) , wait (mutex)
s = s – 1;

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 181
GATE QUESTION BANK Operating System

if (s < 0) { Which one of the following statements


Vb (Xb); describes the properties achieved?
Pb(Yb); (A) Mutual exclusion but not progress
(B) Progress but not mutual exclusion
}
(C) Neither mutual exclusion nor progress
else Vb(Xb); (D) Both mutual exclusion and progress
V(s): Pb(Xb);
s = s + 1; 16. The following program consists of 3
if (s <= 0) concurrent processes and 3 binary
Vb (Yb); semaphores. The semaphores are
Vb (Xb); initialized as S0= 1, S1 = 0, S2 = 0
Process P0 Process P1 Process P2
The initial values of Xb and Yb are
while (true) { wait (S1); wait (S2)
respectively wait (S0); release (S0); release (S0);
(A) 0 and 0 (C) 1 and 0 print ‘0’
(B) 0 and 1 (D) 1 and 1 release (S1);
release (S2);
CS – 2009 }
14. In the following process state transition
How many times will process P0 print ‘0’?
diagram for a uniprocessor system,
(A) At least twice (C) Exactly thrice
assume that there are always some
(B) Exactly twice (D) Exactly once
processes in the ready state:
B
CS - 2012
A D
Start Ready Running Terminated 17. A process executes the code
fork ();
E C F
fork ();
Blocked
fork ();
Now consider the following statements: The total number of child processes
I. If a process makes a transition D, it created is
would result in another process (A) 3 (C) 7
making transition A immediately (B) 4 (D) 8
II. A process P2 in blocked state can take
transition E while another process P1 18. Fetch_And_Add (X, i) is an atomic Read-
is in running state Modify-Write instruction that reads the
III. The OS uses preemptive scheduling value of memory location X, increments it
IV. The OS uses non-preemptive by value i, and returns the old value of X it
scheduling is used in the pseudocode shown below to
Which of the above statements are TRUE? implement a busy-wait lock. L is unsigned
(A) I and II (C) II and III integer shared variable initialized to 0.
(B) I and III (D) II and IV The value of 0 corresponds to lock being
available, while any non-zero value
corresponds to the lock being not
CS – 2010
available.
15. Consider the methods used by processes AcquireLock (L) {
P1 and P2 for accessing their critical while ( Fetch_And_Add ( L, 1 ) )
sections whenever needed, as given L = 1;
below. The initial values of shared }
boolean variables S1 and S2 are randomly ReleaseLock (L) {
assigned. L = 0;
Method used by P1 Method used by P2 }
This implementation
while (S1 = = S2); while (S1 ! = S2); (A) fails as L can overflow
critical Section critical Section (B) fails as L take on a non-zero value
S1= S2; S2 = not (S1); when the lock is actually available
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 182
GATE QUESTION BANK Operating System

(C) works correctly but may starve some (C)


processes ExitX(R, S) {
(D) works correctly without starvation P(S);
V(R);
CS – 2013 }
19. A certain computation generates two EntryY(R, S){
arrays a and b such that V(S);
a[i]=f(i) for 0≤i<n and P(R);
b[i]=g(a[i]) for 0≤i<n. Suppose this }
computation is decomposed into two (D)
concurrent processes X and Y such that X ExitX(R, S) {
computes the array a and Y computes the V(R);
array b. The processes employ two binary P(S);
semaphores R and S, both initialized to }
zero. The array a is shared by the two EntryY(R, S){
processes. The structures of the V(S);
processes are shown below. P(R);
Process X: }
private i;
for (i=0; i<n; i++) {
a[i] = f(i); 20. A shared variable x, initialized to zero, is
ExitX(R, S); operated on by four concurrent processes
} W,X,Y,Z as follows. Each of the process W
Process Y: and X reads x from memory , increments
private i; by one, stores it to memory and then
for (i=0; i<n; i++) { terminates. Each of the processes Y and Z
EntryY(R, S); reads x from memory , decrements by
b[i] = g(a[i]); two, stores it to memory and then
} terminates. Each processes before
Which one of the following represents the reading x invokes the P operation (i.e.,
CORRECT implementations of ExitX and wait) on a counting semaphore S and
EntryY? invokes the V operation (i.e., signal) on
(A) the semaphore S after storing x to
ExitX(R, S) { memory. Semaphore S is initialized to
P(R); two. What is the maximum possible value
V(S); of x after all processes complete
} execution?
EntryY(R, S) { (A) 2 (C) 1
P(S); (B) 1 (D) 2
V(R);
}

(B)
ExitX(R, S) {
V(R);
V(S);
}
EntryY(R, S) {
P(R);
P(S);
}

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 183
GATE QUESTION BANK Operating System

CS - 2014 Which one of the following is TRUE?


21. Consider the procedure below for the (A) The producer will be able to add an
Producer-Consumer problem which uses item to the buffer, but the consumer
semaphores:
can never consume it.
semaphore n = 0;
(B) The consumer will remove no more
semaphore s = 1;
than one item from the buffer.
void producer() void consumer()
(C) Deadlock occurs if the consumer
{ {
while (true) while(true) succeeds in acquiring semaphore s
{ { when the buffer is empty.
Produce(); semWait(s); (D) The starting value for the semaphore
SemWaits(s); semWait(n); n must be 1 and not 0 for deadlock-
addToBuffer(); removeFromBuffer(); free operation.
semSignal(s); semsignal(s);
semSignal(n); consume();
} }
} }

Answer Keys and Explanations


1. [Ans. C] Signal(Y) useR2
fork ( ) will returns 0 for child . So, parent wait(X) use R3
is printing 5 less than ‘a’ & child is use R3 signal(X)
printing 5 more. So, regarding the values use R4 wait(Y)
u +10 =x Signal (Y) use R4
Regarding the addresses v = y, though the ∴ Total no. of binary semaphore = 2
physical addresses of child Process &
Parent Process are different, yet “&a” 4. [Ans. A]
refers to the logical addresses of the void P (binary- semaphore * S){
process which will be same for both Child unsigned y;
& Parent Processes. Physical Address will unsigned * x = & (S value);
be generated at runtime and it will be do {
known to Memory Management Unit Only fetch – and – set x, y;
and CPU is totally unaware of Physical } while(y);
address. }
void V(binary- semaphore * S)
2. [Ans. C] * S value = 0;+
As semaphore X = 0, the process calling }
P(X) must wait until another process calls fetch – and – set instruction always sets
V(X). the memory location x = 1 and fetches the
P1 calling V(X) first, So P1 need not old value of x and y. The
starve and it is independent and can run binarysemaphore * S takes only two value
multiple times. either 0 and 1. When we initialize S = 0
P2 calling P(X) first, So P2 must wait then in statement 3 this value will be
until P1 comes. So P2 will starve. started at location x and fetch – and-set
instruction change the value of x= 0 to
3. [Ans. B] x = 1 and y becomes 0. If there are more
Consider the possible solution than two processes and context switching
X 𝑎𝑛𝑑 Y=0 between processes is disabled in P then
P1 P2 this implementation doesn’t work
wait(X) use R1 properly and can’t synchronize the
use R1 signal (X) processes
use R2 wait (Y)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 184
GATE QUESTION BANK Operating System

5. [Ans. C] 12. [Ans. B]


As Switching from Running to Ready is Fork ( ) system call creates the child
not allowed It is not a non-Preemptive process initially number of processes is 0.
Scheduling. After first fork ( ), it creates a single
process. After second fork ( ), it creates
6. [Ans. B] one parent and two child processes. After
The barrier implementation may lead to a n fork ( ), the total number of processes is
deadlock if two barrier invocations are 2 but we subtract the main process then
used in immediate succession which is the total number of child processes is
due to line 3 and 7. 2 1.
7. [Ans. B] 13. [Ans. C]
At the beginning of the barrier the first In given code, P(s) decrements the value
process to enter in the line 8 the barrier of semaphore and V(s) increment the
waits until process_arrived becomes zero
value of semaphore. P &V are wait and
before proceeding to execute P(S)
signal operations on binary semaphore.
8. [Ans. D] X &Y are binary semaphores. To avoid
It ensures Mutual Exclusion, but it doesn’t the mutual exclusion condition if the
prevent deadlock. value of X is 1 and the value of Y = 0
Wants1 Wants2 RESULT
then P(s) and V(s) work properly.
True True Deadlock
True False P1
14. [Ans. C]
False True P2
Transition C indicates that OS uses
False False No Process will enter
preemptive scheduling. II is also true.
into Critical Section

9. [Ans. C] 15. [Ans. A]


After execution of It ensures Mutual Exclusion.
if (critical_flag== False). If P1 preempts S1 S2 RESULT
and P2 starts . Then for P2 also line 1 1 P2
if (critical_ flag == False) 1 0 P1
Condition will be true. And P1, P2 both 0 1 P1
will access critical_ region concurrently. 0 0 P2
But here there is no any deadlock chance It doesn’t ensure progress, consider the
following cases:-
10. [Ans. C] If “P1” is the only process if (S1=S2), then
S1 = Wait (wrt) To block writers it must wait indefinitely for “P2”
accessing the buffer. If “P1” is the only process if (S1! = S2),
S2 = Signal (mutex) To allow other then it will execute only once and makes
readers to access the readcount shared (S1 = S2), if “P1” wants to execute for the
variable. second time, then it must wait indefinitely
S3 wait (mutex) To block other for “P2”
readers in accessing the readcoun shared We can conclude the Progress condition is
variable not achieved .
S4 = Signal (wrt) To allow writer to
proceed as all readers are done with 16. [Ans. A]
reading. When S =1, S = 0
So firstly the value of S and S = 0, P and
11. [Ans. C] P not execute. The value of S = 1, So it
So, its output is : can execute, process P . Now value of
a1 b1 c1 S = 0 and it prints zero one time when it
a2 b2 c2 calls release (S1) call then the value of S1
a3 b2 c3 increases by 1. So P executes. It makes
a4 b1 c3

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 185
GATE QUESTION BANK Operating System

value of S again zero and S = 1, then it 2. Start with Y


release (S ) make value of S = 0 by P(s)
applying wait and (S ) means it decrease s=0
by one so it prints zero and this process
ead x = 0 ,old value-
continue. So P prints zero at least twice.
x=x 2 x= 2
17. [Ans. C] Store it to memory
fork (); 1 V(s) s = 1
fork (); 2 = 7 3. Again start with X,
fork (); 4 So it will write
Total no of child processes after n fork ( ) x = 1 in memory.
calls = (2 1)
V(s) s = 2
18. [Ans. B] 4. Same procedure for W and Z.
Assume P1 executes until while condition Start with W.
and preempts before executing L = 1. Preempt after read and then execute Z
Now P2 executes all statements, hence and again execute W.
L = 0. Then P1 without checking L it So final value in x will be 2.
makes L = 1 by executing the statement
where it was preempted. 21. [Ans. C]
∴It takes a non-zero value (L = 1) when semaphore n = 0;
the lock is actually available (L = 0). semaphore s = 1;
19. [Ans. C] The given solution will lead to deadlock in
Here take any sequence of operations of the following case: if consumer starts
process X and process Y, first process X first.
will wait for S which is incremented by Consumer calls
process Y and then process Y waits for R semWait(s) s = s – 1 = 0 Consumer
which is incremented by process X. is allowed
There is no sequence of operations in
Consumer calls
which the value of R or S overlaps.
Hence both process executes one after semWait(n) n = n – 1 =0 1 = 1
another. Consumer is Blocked on semWait (n)
So option (C) is correct. Now producer started and called
[X & Y] should run in strict alteration semWait(s) s = s 1 = 0 1= 1
manner Blocked on semWait(s)
Now Both producer & Consumer are
20. [Ans. D]
blocked Deadlock.
X W Y Z
1 P(s) P(s) P(s) P(s)
2 R(x) R(x) R(x) R(x)
3 x=x+1 x=x+1 x=x 2 x=x 2
4 Store Store Store Store
to MM to MM to MM to MM
5 V(s) V(s) V(s) V(s)
1. Start with X.
P(s)
S=1
ead x = 0
x=x+1 x=1
Before storing it to memory, preempt
this process

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 186
GATE QUESTION BANK Operating System

Threads

CS – 2007 3. A thread is usually defined as a “light


1. Consider the following statements about weight process” because an operating
user level threads and kernel level system (OS) maintains smaller data
threads. Which one of the following structures for a thread than for a process.
statements is FALSE? In relation to this, which of the following
(A) Context switch time is longer for is TRUE?
kernel level threads than for user (A) On per-thread basis, OS maintains only
level threads CPU register state
(B) User level threads do not need any (B) The OS does not maintain a separate
hardware support stack for each thread
(C) Related kernel level threads can be
scheduled on different processors in
(C) On per-thread basis, the OS does not
a multiprocessor system maintain virtual memory state
(D) Blocking one kernel level thread (D) On per-thread basis, the OS maintains
blocks all related threads only scheduling and accounting
information
CS - 2011
2. Let the time taken to switch between user CS – 2014
and kernel modes of execution be t1 while 4. Which one of the following is FALSE?
the time taken to switch between two (A) User level threads are not scheduled
processes be t2. Which of the following is by the kernel.
TRUE? (B) When a user level thread is blocked,
(A) t1 > t2
all other threads of its process are
(B) t1 = t2
(C) t1 < t2 blocked.
(D) nothing can be said about the relation (C) Context switching between user level
between t1 and t2 threads is faster than context
switching between kernel level
threads.
(D) Kernel level threads cannot share the
code segment

Answer Keys and Explanations

1. [Ans. D] 3. [Ans. A]
In kernel level threads, if the blocking Threads are called light weight processes
system call comes, the kernel can because they only need storage for stack
schedule another thread in the and registers. They don’t need separate
application for execution. So, statement space for other things.
(D) is false about kernel level threads. It
is true for user level threads 4. [Ans. D]
All types of threads share code segment.
2. [Ans. C] So operation (D) is false
Process switching includes mode All other statements are true.
switching. Context switching can occur
only in kernel mode. So t2 will include t1
in itself

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 187
GATE QUESTION BANK Operating System

CPU Scheduling
CS – 2005 giving priority to the process with the
1. We wish to schedule three processes lowest process id. The average
P1, P2 and P3 on a uni-processor system. turnaround time is
The priorities, CPU time requirements (A) 13 units (C) 15 units
and arrival times of the processes are as (B) 14 units (D) 16 units
shown below.
Process Priority CPU Arrival 4. Consider three processes, all arriving at
time time time zero, with total execution time of
required (hh:mm:ss) 10, 20 and 30 units respectively. Each
P1 10 20 sec 00:00:05 process spends the first 20% of execution
(highest)
time doing I/O, the next 70% of time
P2 9 10sec 00:00:03
doing computation and the last 10% of
P3 8 15 sec 00:00:00 time doing I/O again. The operating
(lowest) system uses a shortest remaining
We have a choice of preemptive or non- compute time first scheduling algorithm
preemptive scheduling. In preemptive and schedules a new process either when
scheduling, a late-arriving higher priority the running process get blocked on I/O or
process can preempt a currently running when the running process finishes its
process with lower priority. In non- compute burst. Assume that all I/O
preemptive scheduling, a late arriving operations can be overlapped as much as
higher priority process must wait for the possible. For what percentage of time
currently executing process to complete does the CPU remain idle?
before it can be scheduled on the (A) 0% (C) 30.0%
processor. (B) 10.6% (D) 89.4%
What are the turnaround times (time
from arrival till completion) of P2 using 5. The arrival time, priority and durations
preemptive and non-preemptive of the CPU and I/O bursts for each of
scheduling respectively? three processes P1, P2, and P3 are given
(A) 30 sec, 30 sec (C) 42 sec, 42 sec in the table below. Each process has a
(B) 30 sec, 10 sec (D) 30 sec, 42 sec CPU burst followed by an I/O burst
followed by another CPU burst. Assume
CS – 2006 that each process has its own I/O
2. Consider three CPU intensive processes, resource.
which require 10, 20 and 30 time units Process Arrival Priority Burst
and arrive at times 0, 2 and 6 time durations
respectively. How many context switches (CPU,
are needed if the operating system I/O,CPU)
implements a shortest remaining time P1 0 2 1, 5, 3
first scheduling algorithm? Do not count P2 2 3(lowest) 3, 3, 1
the context switches at time zero and at P3 3 1(highest) 2, 3, 1
the end The multi- programmed operating
(A) 1 (C) 3 system uses preemptive priority
(B) 2 (D) 4 scheduling. What are the finish times of
the processes P1, P2 and P3?
3. Consider three processes (process id 0, 1, (A) 11, 15, 9 (C) 11, 16, 10
2 respectively) with compute time bursts (B) 10, 15, 9 (D) 12, 17, 11
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

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 188
GATE QUESTION BANK Operating System

CS – 2007 (A) I only


6. Group-1 contains some CPU scheduling (B) I and III only
algorithms and Group-2 contains some (C) II and III only
applications. Match entries in Group-1 (D) I, II and III
entries in Group-2
Group-1 Group-2 CS - 2011
P. Gang 1. Guaranteed 10. Consider the following table of arrival
scheduling Scheduling time and burst time for three processes
Q. Rate 2. Real time P0, P1 and P2.
Monotonic Scheduling Process Arrival time Burst time
Scheduling P0 0 ms 9 ms
R. Fair Share 3. Thread P1 1 ms 4 ms
Scheduling Scheduling P2 2 ms 9 ms
(A) P – 3; Q – 2; R – 1 The pre-emptive shortest job first
(B) P – 1; Q – 2; R – 3 scheduling algorithm is used. Scheduling
(C) P – 2; Q – 3; R – 1 is carried out only at arrival or
(D) P – 1; Q – 3; R – 2 completion of processes. What is the
average waiting time for the three
7. An operating system uses Shortest processes?
Remaining Time First (SRTF) process (A) 5.0 ms (C) 6.33 ms
scheduling algorithm. Consider the arrival (B) 4.33 ms (D) 7.33 ms
times and execution times for the
following processes CS – 2012
Process Execution time Arrival time 11. Consider the 3 processes, P1, P2 and P3
P1 20 0
shown in the table
P2 25 15
P3 10 30 Process Arrival Time unit
P4 15 45 time required
Which is the total waiting time for P1 0 5
process P2? P2 1 7
(A) 5 (C) 40 P3 3 4
(B) 15 (D) 55 The completion order of the 3 processes
under the policies FCFS and RR2 (round
CS – 2008 robin scheduling with CPU quantum of 2
8. If the time – slice used in the round – time units) are
robin scheduling policy is more than (A) FCFS: P1, P2, P3 RR2: P1, P2, P3
the maximum time required to execute (B) FCFS: P1, P3, P2 RR2: P1, P3, P2
any process ,then the policy will (C) FCFS: P1, P2, P3 RR2: P1, P3, P2
(A) degenerate to shortest job first (D) FCFS: P1, P3, P2 RR2: P1, P2, P3
(B) degenerate to priority scheduling
(C) degenerate to first come first CS – 2013
serve 12. A scheduling algorithm assigns priority
(D) none of the above proportional to the waiting time of a
process. Every process starts with
CS – 2010 priority zero (the lowest priority ). The
9. Which of the following statements are scheduler reevaluates the process
true? priorities every T time units and decides
I. Shortest remaining time first the next process to schedule. Which one
scheduling may cause starvation of the following is TRUE if the processes
II. Preemptive scheduling may cause have no I/O operations and all arrive at
starvation time zero?
III. Round robin is better than FCFS in (A) This algorithm is equivalent to the
terms of response time first – come first – serve algorithm.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 189
GATE QUESTION BANK Operating System

(B) This algorithm is equivalent to the 15. An operating system uses shortest
round – robin algorithm remaining time first scheduling algorithm
(C) This algorithm is equivalent to the for pre – emptive scheduling of processes.
shortest – job – first algorithm Consider the following set of processes
(D) This algorithm is equivalent to the with their arrival times and CPU bust
shortest – remaining – time – first times (in milliseconds)
algorithm Process Arrival Time Burst Time
P1 0 12
CS – 2014 P2 2 4
13. Consider the following set of processes
P3 3 6
that need to be scheduled on a single CPU.
All the times are given in milliseconds. P4 8 5
Process Arrival Execution The average waiting time (in
Name Time Time milliseconds) of the processes is __________.
A 0 6
B 3 2
C 5 4
D 7 6
E 10 3
Using the shortest remaining time first
scheduling algorithm, the average process
turnaround time (in msec) is ___________

14. Three processes A, B and C each execute a


loop of 100 iterations. In each iteration of
the loop, a process performs a single
computation that requires CPU
milliseconds and then initiates a single
I/O operation that lasts for
milliseconds. It is assumed that the
computer where the processes execute
has sufficient number of I/O devices and
the OS of the computer assigns different
I/O devices to each process. Also, the
scheduling overhead of the OS is
negligible. The processes have the
following characteristics:
Process id
A 100 ms 500 ms
B 350 ms 500 ms
C 200 ms 500 ms
The processes A, B, and C are started at
times 0, 5 and 10 milliseconds
respectively, in a pure time sharing
system (round robin scheduling) that
uses a time slice of 50 milliseconds. The
time in milliseconds at which process C
would complete its first I/O operation is
___________.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 190
GATE QUESTION BANK Operating System

Answer Keys and Explanations


1. [Ans. D] The Gantt chart is
For non pre emptive.

e e e
Total time spent = 47
Idle time = 2+3 = 5
Percent of time CPU is IDLE =
Total time = 45 – 3(arrival time) = 42
=
For Preemptive
5. [Ans. A]
idle no pro e

v
Total time = 33 3 = 30 k idle
u y in
k
2. [Ans. B] d
Let three processes are 6. [Ans. A]
k
Process Arrival time
Burst Group 1
time P. dGang scheduling
0 10 Q.k Rate Monotonic Scheduling
2 20 R. Fair show scheduling.
6 30
The Gannt chart for SRTF scheduling Group 2
algorithm is 3. Thread scheduling
2. Real time scheduling
1. Guaranteed scheduling

7. [Ans. B]
So there is only two context switches at The Gantt chart for SRTF scheduling
time unit 10 context switch from o algorithm is
and at time unit 30 context switch from P1 P2 P3 P2 P4
o
0 20 30 40 55 70

3. [Ans. A] So, the waiting time for


The Gantt chart for LRTF CPU cheduling P2 = (20 – 15) + (40 – 30)
algorithm is = 15

8. [Ans. C]
If the time used in RR scheduling is more
Turn around time for P0 = 12 0=12
than the maximum time required to
Turn around time for P1 =13 0 = 13
execute any process. Then the policy will
Turn around time for P2 = 14 0 = 14
degenerate to first come first serve
∴ Average urnaround ime = =
9. [Ans. D]
4. [Ans. B] All three options are correct
Process Burst I/O CPU I/O
Time Time Time Time
P1 10 2 7 1
P2 20 4 14 2
P3 30 6 21 3

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 191
GATE QUESTION BANK Operating System

10. [Ans. A] 14. [Ans. 1000]


Total No of Processes = 3 = {A, B, C}
{A, B, C} Processes Executes a loop of
100 iterations.
In each iteration of a loop
ime in milli e ond Computation[ m ]
Average waiting time Operation m
w w w
= I/O of processes can proceed in parallel
since there are sufficient no. of I/O
= devices.
= m Process Id Arrival
_Time
11. [Ans. C]
A 0 100 500
RR Queue
P1 P2 P1 P3 P2 P1 P3 P2 B 5 350 500
0 1 2 3 4 6 8 10 C 10 200 500
CPU Scheduling Algorithm = Round Robin
with quantum = 50 milliseconds
When ro e “ ” will omple e i fir
I/O operation?
P1,P2,P3 A eA
Therefore option (C) is correct.
FCFS:P1,P2,P3 ro e “ ” fini hed i exe u ion for
RR2:P1,P3,P2
first Iteration at 500 ms
12. [Ans. B] Af er fini hing exe u ion ro e “ ”
Every process arrives at time zero and will go for I/O
priority is proportional to waiting time I/O time = 500 ms
quantum T time units. Every process is ro e “ ” will fini h i ir
given equal chance, all are arrived at operation in first Iteration
same time. This is equal to round – robin = =
algorithm. Because after each T time
waiting time of all process will increase 15. [Ans. 5.5]
P2 P3 P4 P1
(except running process) done done done done

13. [Ans. 7.2]


Gantt chart P1 P1 P2 P2 P2 P2 P3 P3 P3 P4 P1
A B A C E D 0 1 2 3 4 5 6 7 8 12 17 27

0 3 5 8 12 15 21
Turn around line of (A) = (8 – 0) = 8 P2[4] P4[5] P4[5] P1[10]
Turn around line of (B) = (5 – 3) = 2 P1[10] P3[4] P1[10]
P1 [10]
Turn around line of (C) = (12 – 5) = 7
P3[6]
Turn around line of (D) = (21 – 7) = 14 P2[3]
Turn around line of (E) = (15 – 10) = 5 P1 [10]
Average urn around ime

= = 7.2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 192
GATE QUESTION BANK Operating System

Process Arriva Burst Completion Waiting Time


l Time Time Time
P1 0 12 27 27 12 0 = 15
P2 2 4 6 6 4 2 =0
P3 3 6 12 =
P4 8 5 17 =
Average waiting time
= (15 + 0 + 3 + 4)/4 = 5.5 milliseconds

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 193
GATE QUESTION BANK Operating System

Deadlocks
CS – 2005 (A) min (xp, xq) < maxkp,q yk
1. Suppose n processes, P1, ……, Pn share m (B) xp + xq minkp, qyk
identical resource units, which can be (C) max ( xp, xq) < 1
reserved and released one at time. The (D) min ( xp, xq) > 1
maximum resource requirement of
process Pi is si, where si > 0. Which one of CS - 2007
the following is a sufficient condition for 4. A single processor system has three
ensuring that deadlock does not occur? resource types X, Y and Z, which are
(A) i, si < m shared by three processes. There are 5
(B) i, si < n units of each resource type. Consider the
(C) ∑ following scenario, where the column
(D) ∑ alloc denotes the number of units of each
resource type allocated to each process
2. Two shared resource R1 and R2 are used and the column request denotes the
by processes P1 and P2. Each process has number of units of each resource type
a certain priority for accessing each requested by a process in order to
resource. Let Tij denote the priority of complete execution. Which of the
for accessing Rj. A process Pi can snatch processes will finish LAST?
a resource Rh from process if Tik is alloc request
greater than Tjk. X Y Z X Y Z
Given the following: P0 1 2 1 1 0 3
I. T11 > T21 P1 2 0 1 0 1 2
II. T12 > T22 P2 2 2 1 1 2 0
III. T11 < T21 (A) P0
IV. T12 < T22 (B) P1
Which of the following conditions ensures (C) P2
that P1 and P2 can never deadlock? (D) None of the above, since the system
(A) I and IV is in a deadlock
(B) II and III
(C) I and II CS - 2008
(D) None of the above 5. The following is a code with two threads,
producer and consumer, that can run in
CS – 2006 parallel. Further, S and Q are binary
3. Consider the following snapshot of a semaphores equipped with the standard
P and V Operations.
system running n processes. Process i is
Semaphore S = 1, Q = 0 ;
holding xi instances of a resource R, for integer x ;
1 i n. Currently all instances of R are producer: consumer:
occupied. Further, for all i, process i has while (true) do while (true) do
placed a request for an additional yi P(S) ; P(Q) ;
instances while holding the instances it x = produce ( ) ; consume (x) ;
V(Q) ; V(S) ;
already has. There are exactly two
done done
processes p and q such that yp = yq = 0. Which of the following is true about the
Which one of the following can serve as a program above?
necessary condition to guarantee that the (A) The process can deadlock
system is not approaching a deadlock? (B) One of the threads can starve

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 194
GATE QUESTION BANK Operating System

(C) Some of the items produced by the initialized to 0. Now consider the
producer may be lost following statements
(D) Values generated and stored in ‘ ’ by I. The above solution to CS problem is
the producer will always be
deadlock-free
consumed before the producer can
generate a new value II. The solution is starvation free
III. The processes enter CS in FIFO order
6. Which of the following is NOT true of IV. More than one process can enter CS
deadlock prevention and deadlock at the same time
avoidance schemes?
Which of the above statements are TRUE?
(A) In deadlock prevention, the request
for resources is always granted if the (A) I only (C) II and III
resulting state is safe. (B) I and II (D) IV only
(B) In deadlock avoidance, the request 9. Consider a system with 4 types of
for resources is always granted if the resources R1 (3 units), R2 (2 units),
resulting state is safe. R3 (3 units), R4 (2 units).
(C) Deadlock avoidance is less restrictive A non-preemptive resource allocation
than deadlock prevention policy is used. At any given instance, a
(D) Deadlock avoidance requires request is not entertained if it cannot be
knowledge of resource requirements completely satisfied. Three processes
a priori P1,P2,P3 request the resources as follows if
7. An operating system implements a executed independently.
policy that requires a process to
units of R1
unit of R4
t = 0 : requests 1

t = 2 : requests 2

t = 7 : requests 1
release all resources before making a

t = 8 :requests 1
Process P3 :

units of R1
t = 5:releases 2

unit of R2

unit of R3
t = 9 : Finishes
request for another resource . Select the
TRUE statement from the following:
(A) Both starvation and deadlock can
occur.
(B) Starvation can occur but deadlock
cannot occur.
units of R3

unit of R4

unit of R1

unit of R3
t = 0 : requests 2

t = 2 : requests 1

t = 4 : requests 1

(C) Starvation cannot occur but deadlock


t = 6 : releases 1
Process P2 :

t = 8 : Finishes

can occur.
(D) Neither starvation nor deadlock can
occur

CS - 2009
8. The enter_CS( ) and leave_CS( ) functions
t = 8 : requests 2
and 1 unit of
units of R2

unit of R3

to implement critical section of a process


t = 0 : requests 2

t = 1 : requests 1

t = 3 : requests 2
units of R1
t = 5 : releases 1

t = 7 : releases 1
Process P1 :

unit of R2

unit of R3
t = 10: Finishes

are realized using test-and-set instruction


units of R4

as follows:
R1

void enter_CS ( X)
{
while (test-and-set (X)) Which one of the following statements is
} TRUE if all three processes run
void leave_CS (X) concurrently starting at time t = 0?
{ (A) All processes will finish without any
X = 0; deadlock
(B) Only P1 and P2 will be in a deadlock
}
(C) Only P1 and P3 will be in deadlock
In the above solution, X is a memory
(D) All three processes will be in deadlock
location associated with the CS and is

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 195
GATE QUESTION BANK Operating System

CS - 2010 CS – 2014
10. A system has n resources , .. 12. An operating system uses the Banker’s
and k processes , .. . The algorithm for deadlock avoidance when
implementation of the resource request managing the allocation of three resource
types X, Y and Z to three processes P0, P1,
logic of each process , is as follows:
and P2. The table given below presents
if ( i % 2 = = 0) { the current system state. Here, the
if ( i <n) request ; Allocation matrix shows the current
if ( i + 2 < n)request ;} number of resources of each type
else { allocated to each process and the Max
if ( i <n) request ; matrix shows the maximum number of
if ( i + 2<n) request ; resources of each type required by each
process during its execution.
}
In which one of the following situations is Allocation Max
a deadlock possible? X Y Z X Y Z
(A) n = 40, k = 26 P0 0 0 1 8 4 3
(B) n = 21, k = 12 P1 3 2 0 6 2 0
(C) n = 20, k = 10 P2 2 1 1 3 3 3
(D) n = 41, k = 19 There are 3 units of type X, 2 units of type
Y and 2 units of type Z still available. The
CS - 2013 system is currently in a safe state.
11. Three concurrent processes X, Y and Z Consider the following independent
execute three different code segments requests for additional resources in the
that access and update certain shared current state:
variables. Process X execute the REQ1: P0 requests 0 units of X, 0 units of
P operation (i.e., wait) on semaphores a, b Y and 2 units of Z
and c; process Y executes the P operation REQ2: P1 requests 2 units of X, 0 units of
on semaphores b, c and d; process Z Y and 0 units of Z
executes the P operation on semaphores Which one of the following is TRUE?
c, d and a before entering the respective (A) Only REQ1 can be permitted.
code segments. After completing the (B) Only REQ2 can be permitted.
execution of its code segments, each (C) Both REQ1 and REQ2 can be
process invokes the V operation (i.e., permitted.
signal) on its three semaphores. All (D) Neither REQ1 nor REQ2 can be
semaphores are binary semaphores permitted.
initialized to one. Which one of the
following represents a deadlock – free 13. A system contains three programs and
order of invoking the P operations by the each requires three tape units for its
processes? operation. The minimum number of tape
(A) X: P(a)P(b)P(c) units which the system must have such
Y: P(b)P(c)P(d) that deadlocks never arise is ____.
Z: P(c)P(d)P(a)
(B) X: P(b)P(a)P(c)
Y: P(b)P(c)P(d)
Z: P(a)P(c)P(d)
(C) X: P(b)P(a)P(c)
Y: P(c)P(b)P(d)
Z: P(a)P(c)P(d)
(D) X: P(a)P(b)P(c)
Y: P(c)P(b)P(d)
Z: P(c)P(d)P(a)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 196
GATE QUESTION BANK Operating System

Answer Keys and Explanations


1. [Ans. C] 4. [Ans. C]
No. of processes = n 1, 2……. n Consider the matrix
alloc Request
No. of identical resources = m.
X Y Z X Y Z
The maximum resource requirement 1 2 1 1 0 3
for a process Pi is SP, where Si > 0 P1 2 0 1 0 1 2
If all process is in safe state then system 2 2 1 1 2 0
can allocate resources to each process The available matrix is (0 1 2) and
requirement of process P1 is (0 1 2). So
Pi in some order and still avoid a
P1 can uses the available resources after
deadlock. We can avoid the deadlock if release the resources, the matrix becomes
each Pi request can be satisfied by the Alloc Request
current available resource plus the X Y Z X Y Z
resources held by process Pj such that P0 1 2 1 1 0 3
P1 0 0 0 0 0 0
j<i. The maximum resource
P2 2 2 1 1 2 0
requirement of n processes is ∑ Si In this time available matrix is (2 1 3) and
and this amount must be less than required matrix of P0 is (1 0 3) so P0 uses
m + n. the resources of the releasing resources.
So, ∑ m n The available matrix is (3 3 4). So, P2 will
use the resource. So, P2 will finish last.
2. [Ans. C]
5. [Ans. D]
Here I and II says Since, after every produce function; it
T11>T21 calls consume function. Producer and
T12>T22 consumer will run in strict alteration.
P1 P2 So (D) is true
Required R1 required R1
Required R2 required R2 6. [Ans. A]
In deadlock prevention, OS tries to
Assume that P1 is running and after a
prevent system from deadlock by not
context switch P2 goes to running state
allowing any one of the four necessary
that it cannot snatch resource from P1, conditions to hold
because has high priority for both So, option A is not true
resources. Hence no deadlock.
7. [Ans. B]
3. [Ans. B] If a process release all resources before
There is no any additional requirement making a request for another resource,
for both processes. So both p & q should starvation may or may not occur but
deadlock cannot occur; because hold and
be executed with all allocated resources
wait condition will not hold
so should be sufficient for p & q
and should be at least (min , y ). 8. [Ans. A]
The given solution is deadlock free

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 197
GATE QUESTION BANK Operating System

9. [Ans. A]
Initially available resources
R1 R2 R3 R4
3 3 3 2

Process Allocate Available


t=0 R1 R2 R3 R4 R1 R2 R3 R4
request 2 unit of 2 P1 0 2 0 0 3 0 1 1
request 2 unit of 3 P2 0 0 2 0
request 1 unit of 4 P3 0 0 0 1
=
request 1 unit of 3 P1 0 2 1 0 3 0 0 1
P2 0 0 2 0
P3 0 0 0 1
=
request 1 unit of 4 P1 0 2 1 0 1 0 0 0
request 2 unit of 1 P2 0 0 2 1
P3 2 0 0 1
=
request 1 unit of 2 P1 1 2 1 0 0 0 0 0
ait for 1 unit of 1 P2 1 0 2 1
P3 2 0 0 1
=
request 1 unit of 4
(wait)
=
request 1 unit of 2 P1 1 1 1 0 1 1 0 0
and 1 unit of R1 P2 1 0 2 1
P3 0 0 0 1
release 2 units of 1
now request of , 1 unit of R1 will be granted and request of , 1 unit of R1 will be granted
=
request 1 unit of 3 P1 1 1 1 0 1 1 1 0
P2 1 0 1 1
P3 0 0 0 1
=
request 1 unit of 3 P1 1 1 0 0 1 0 2 0
request 1 unit of 2 P2 1 0 1 1
P3 0 1 0 1
=
finish P1 1 1 0 0 2 0 3 1
P3 0 1 0 1
request 2 unit of 4(wait) 1 1 0 0 2 0 2 1
request 1 unit of 3 0 1 1 1
=
finish P1 1 1 0 0 2 1 3 2
request of 2 unit of R4 by P1 will be granted
P1 1 1 0 2 2 1 3 0
=
finish 3 2 3 2
All processes will finish without any deadlock

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 198
GATE QUESTION BANK Operating System

10. [Ans. B] 13. [Ans. 7]


According to the given program, in all the Total no of programs = 3 = {P1, P2, P3}
cases for even sequences of processes Each program requires = 3 tape drives
only corresponding sequence number of Now just allocate one less than the
resource will be allotted except case (B),
required resources
where n = 21, k = 12,
For can only be allotted and for Program No. of tap drives
can be allotted. P1 3 1=2
allotted and for odd sequence of P2 3 1=2
process i.e. that never conflict in P3 3 1=2
any case except (B), when a same 6 tape drives
resource is requested by more than one
process at the same time may lead to the To avoid Deadlock, we need minimum
deadlock. = 6 + 1 = 7 tape drives

11. [Ans. B]
Suppose X performs P(b) and preempts, Y
gets chance, but cannot do its first wait
i.e., so waits for X, now Z gets the chance
and performs P(a) and preempts, next X
get chance. X cannot continue as wait on
‘a’ is done by Z already, so X aits for Z. At
this time Z can continue its operations as
down on c and d. Once Z finishes, X can do
its operations and so Y. In any of
execution order of X, Y, Z one process can
continue and finish, such that waiting is
not circular. In option (A), (C) and (D) we
can easily find circular wait, thus
deadlock

12. [Ans. B]
Allocation Max Need
X Y Z X Y Z X Y Z
P0 0 0 1 8 4 3 8 4 2
P1 3 2 0 6 2 0 3 0 0
P2 2 1 1 3 3 3 1 2 2
Need = Max – Allocation
Available = [3, 2, 2]
REQ 2 can be permitted because needed
resources by P1 are [3, 0, 0] and after that
there is no any condition for unsafe state.
REQ 1 can not be permitted because P0
and P2 can not be completed in available
resources [3, 2, 2]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 199
GATE QUESTION BANK Operating System

Memory Management & Virtual Memory


CS - 2006 CS - 2007
1. A CPU generates 32-bit virtual addresses. 4. A virtual memory system uses First In
The page size is 4 KB. The processor has a First Out (FIFO) page replacement policy
translation look-aside buffer (TLB) which and allocates a fixed number of frames to
can hold a total of 128 page table entries a process. Consider the following
and is 4-way set associative. The statements:
minimum size of the TLB tag is P: Increasing the number of page frames
(A) 11 bits (C) 15 bits allocated to a process sometimes
(B) 13 bits (D) 20 bits increases the page fault rate
Q: Some program do not exhibit locality of
2. A computer system supports 32-bit reference.
virtual addresses as well as 32-bit Which one of the following is TRUE?
physical addresses. Since the virtual (A) Both P and Q are true and Q is the
address space is of the same size as the reason for P
physical address space, the operating (B) Both P and Q are true, but Q is not
system designers decide to get rid of the the reason for P
virtual memory entirely. Which one of the (C) P is false, but Q is true
following is true? (D) Both P and Q are false
(A) Efficient implementation of multi-
user-support is no longer possible 5. Let a memory have four free blocks of
(B) The processor cache organization sizes 4k, 8k, 20k, 2k. These blocks are
can be made more efficient now allocated following the best-fit strategy.
(C) Hardware support for memory The allocation requests are stored in a
management is no longer needed queue as shown below.
(D) CPU scheduling can be made more Request Request Usage
efficient now No sizes time
J1 2k 4
3. For each of the four processes P1, P2, P3 and
P4. The total size in kilobytes (KB) and the J2 14k 10
number of segments are given below. J3 3k 2
Process Total size (in Number of J4 6k 8
KB) segments
J5 6k 4
P1 195 4
P2 254 5 J6 10k 1
P3 45 3 J7 7k 8
P4 364 8 J8 20k 6
The page size is 1 KB. The size of an entry in The time at which the request for J7 will
the page table is 4bytes. The size of an entry be completed will be
in the segment table is 8 bytes. The (A) 16 (C) 20
maximum size of the segment is 256KB. The (B) 19 (D) 37
paging method for memory management
uses two-level paging and its storage 6. The address sequence generated by
overhead is P. The storage overhead for the tracing a particular program executing in
segmentation method is S. The storage a pure demand paging system with 100
overhead for the segmentation and paging bytes per page is
method is T. What is the relation among the 0100, 0200, 0430, 0499, 0510, 0530,
overheads the different methods of memory 0560, 0120, 0220, 0240, 0260, 0320,
management in the concurrent execution of 0410.
the above four processes? Suppose that the memory can store only
(A) P < S < T (C) S < T < P one page and if x is the address which
(B) S < P < T (D) T < S < P causes a page fault then the bytes from

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 200
GATE QUESTION BANK Operating System

addresses x to x + 99 are loaded on to 10. Match the following flag bits used in
the memory. the context of virtual memory
How many page faults will occur? management on the left side with the
(A) 0 (C) 7 different purpose on the right side of
(B) 4 (D) 8 the table below.
Name of the bit Purpose
Common Data for Q. 7 & 8 i. Dirty a. Page initialization
A process has been allocated 3 page ii. R / W b. Write–back policy
frames. Assume that none of the pages of
iii. Reference c. Page protection
the process are available in the memory
initially. The process makes the following iv. Valid d. Page replacement
sequence of page references (reference policy
string) : 1, 2, 1, 3, 7, 4, 5, 6, 3, 1. (A) i – d , ii – a , iii – b , iv – c
7. If optimal page replacement policy is (B) i – b , ii - c , iii – a , iv – d
used, how many page faults occur for the (C) i – c , ii – d , iii – a , iv – b
above reference string? (D) i – b , ii – c , iii - d , iv – a
(A) 7 (C) 9 CS - 2009
(B) 8 (D) 10
11. In which one of the following page
8. Least Recently Used (LRU) page replacement policies, Belady’s anomaly may
replacement policy is a practical occur?
approximation to optimal page (A) FIFO (C) LRU
replacement. For the above reference (B) Optimal (D) MRU
string, how many more page faults occur
12. The essential content(s) in each entry of a
with LRU than with the optimal page
page table is/are
replacement policy?
(A) Virtual page number
(A) 0 (C) 2
(B) Page frame number
(B) 1 (D) 3
(C) Both virtual page number and page
CS - 2008 frame number
9. A processor uses 36-bit physical (D) access right information
addresses and 32-bit virtual addresses,
with a page frame size of 4 Kbytes. Each 13. A multilevel page table is preferred in
page table entry is of size 4 bytes. A three comparison to a single level page table for
level page table is used for virtual-to- translating virtual address to physical
physical address translation, where the address because
virtual address is used as follows (A) It reduces the memory access time to
read or write a memory location
 bits 30-31 are used to index into the
(B) It helps to reduce the size of page table
first level page table
needed to implement the virtual
 bits 21-29 are used to index into the
address space of a process
second level page table
(C) It is required by the translation look a
 bits 12-20 are used to index into the
side buffer
third level page table
(D) It helps to reduce the number of page
 bits 0-11 are used as offset within faults in page replacement algorithms.
the page
The number of bits required for CS - 2010
addressing the next level page table (or 14. A system uses FIFO policy for page
page frame) in the page table entry of the replacement. It has 4 page frames with no
first, second and third level page table are pages loaded to begin with. The system
respectively first accesses 100 distinct pages in some
(A) 20, 20 & 20 (C) 24, 24 & 20 order and then accesses the same 100
(B) 24, 24 & 24 (D) 25, 25 & 24 pages but now in the reverse order. How
many page faults will occur?
(A) 196 (B) 192 (C) 197 (D) 195

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 201
GATE QUESTION BANK Operating System

CS - 2011 18. What is the minimum number of page


15. Let the page fault service time be 10 ms in colors needed to guarantee that no two
a computer with average memory access synonyms map to different sets in the
time being 20 ns. If one page fault is processer cache of this computer?
generated for every memory (A) 2 (C) 8
accesses, what is the effective access time (B) 4 (D) 16
for the memory?
(A) 21 ns (B) 30 ns (C) 23 ns (D) 35 ns CS - 2014
19. Assume that there are 3 page frames
CS - 2012 which are initially empty. If the page
16. Consider the virtual page reference string reference string is
1, 2, 3, 2, 4, 1, 3, 2, 4, 1 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6, the number of
On a demand paged virtual memory page faults using the optimal replacement
system running on a computer system policy is__________.
that has main memory size of 3 page
frames which are initially empty. Let LRU, 20. A system uses 3 page frames for storing
FIFO and OPTIMAL denote the number of process pages in main memory. It uses
page faults under the corresponding page the Least Recently Used (LRU) page
replacement policy. Then replacement policy. Assume that all the
(A) OPTIMAL < LRU < FIFO page frames are initially empty. What is
(B) OPTIMAL < FIFO < LRU the total number of page faults that will
(C) OPTIMAL = LRU occur while processing the page reference
(D) OPTIMAL = FIFO string given below?
4, 7, 6, 1, 7, 6, 1, 2, 7, 2
CS - 2013
Statement for linked Answer Questions 17 21. Consider a paging hardware with a TLB.
and 18: Assume that the entire page table and all
A computer uses 46- bit virtual address, the pages are in the physical memory. It
32 – bit physical address, and a takes 10 milliseconds to search the TLB
three – level paged page table and 80 milliseconds to access the physical
organization. The page table base register memory. If the TLB hit ratio is 0.6, the
stores the base address of the first – level effective memory access time (in
table (T1), which occupies exactly one milliseconds) is _________.
page. Each entry of T1 stores the base
address of the second – level table (T2). 22. A computer has twenty physical page
Each entry of T2 stores the base address frames which contain pages numbered
of a page of the third – level table (T3). 101 through 120. Now a program
Each entry of T3 stores a page table entry accesses the pages numbered , 2, …,
(PTE). The PTE is 32 bits in size. The in that order, and repeats the access
processor used in the computer has a sequence THRICE. Which one of the
1 MB 16- way set associative virtually following page replacement policies
indexed physically tagged cache. The experiences the same number of page
cache block size is 64 bytes. faults as the optimal page replacement
17. What is the size of a page in KB in this policy for this program?
computer? (A) Least-recently-used
(A) 2 (C) 8 (B) First-in-first-out
(B) 4 (D) 16 (C) Last-in-first-out
(D) Most-recently-used

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 202
GATE QUESTION BANK Operating System

Answer Keys and Explanations


1. [Ans. A] complete in 1 unit time. So total time 11
No. of pages = 128 = 2 units is taken to process request of J7 and
∴ Bits needed for page table entry = 7 J7 takes 8 unit time to complete the
request
page size = 4 KB = 4.2 byte.
∴Total time taken by J7 = 10+1+8
= 12 bits. = 19 unit times.
For 4 way associative memory cell needs
2- bit (2 6. [Ans. D]
∴ Total engaged bits = 7+12+2=21 bits Page reference string is
1, 2, 4, 5, 1, 2, 3, 4
∴Minimum size of TLB = 32 21= 11 bits
So,
2. [Ans. C] 2
Since both memory are equal. Therefore No. of page faults = 8
address translation from virtual to 7. [Ans. A]
physical is not needed. And it is done by Number of page frames = 3
MMU. So, hardware support for memory Consider the optimal page replacement
management is no longer needed algorithm as follows:
1, 2, 1, 3, 7, 4, 5, 6, 3, 1.
Page
3. [Ans. C]
Frame 2 2 2
T = storage overhead for segmentation
and paging method Referring
2
String Page Page
S= storage overhead for segmentation Page
Page Page Page Page Page Page Page
method Fault Fault Fault Fault Fault Fault FaultFault Fault
P = storage overhead for paging method So total number of page faults = 7
= 4×8+5×8+3×8+8×8 = 160 𝑏𝑦𝑡𝑒𝑠 8. [Ans. C]
T = Stores the software programs needed Consider the LRU page replacement
hus , and policy
𝑃 = 95×4+254×4+45×4+364×4=3432 Page
∴𝑆<𝑇<𝑃. Frame 2 2 2
Referring
4. [Ans. B] 2
String Page Page Page Page Page Page Page
P and Q both are true but Q is not the Page
Fault Fault FaultFault Fault Fault Fault
reason for P because increasing the
So total number of page fault = 9
number of page frames allocated to a Number of page fault in LRU Number of
process sometime increases the page fault page fault in optional = 9 7 = 2 more
rate or it is not concern with replacement page faults.
policy.
9. [Ans. B]
5. [Ans. B] Number of bits required for first level
There are four block of size 4k, 8k, 20k, 2k page table = 24
Request Allocated Remaining Usage Number of bits required for 2nd level
No block block time page table = 24
4k, 8k, Number of bits required for 3rd level page
J1 2k 20k 4 table = 24
J2 20k 4k, 8k, 6k 10 10. [Ans. D]
J3 4k k, 8k, 6k 2 Dirty write-back policy,
J4 6k k, 8k 8 R/W page protection,
It will wait to free block used by J2. So it Reference page replacement policy,
will wait for 10 units, then J6 will valid page initialization.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 203
GATE QUESTION BANK Operating System

11. [Ans. A] 16. [Ans. B]


Belady’s anomaly can occur only in FIFO. OPTIMAL FIFO
Which means with increment in page 3 3 3 3 3 2 2 2
3 3 3 3 3 2 2 2
frames, sometimes no. of pages faults also
2 2 2 4 4 4 4 4 4 2 2 2 2 1 1 1 1 1
increases
1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4

M
M
H
M

M
H
HIT

M
H
M
M
M

M
H
12. [Ans. B]

H
H
H
HIT
MISS
MISS
MISS
MISS
Page frame numbers are most important,
virtual page number may not be stored 5 MISS 6 MISS
entirely. LRU
3 3 3 1 1 1 4 4
13. [Ans. B] 2 2 2 2 2 3 3 3 1
Multilevel page table is preferred to 1 1 1 1 4 4 4 2 2 2
M M M H M M M M M M
reduce the size of page table needed to
implement the virtual address space of a
process. So optimal < FIFO < LRU

14. [Ans. A] 17. [Ans. C]


FIFO policy for page replacement used. Let page size = 2 bytes
Access 100 distinct pages by taking some Page offset = X bits
example 2 3 4 5 6 7 8 9. 46 X X
So by loading it get 2 2
i e of 2
5 2
4 = 4 page faults B 2 B
3 Size of 2
2
Size of 2
9 & 2 2
8 occupies e actly one page
= 4 page faults
7
6
and now access these pages in reverse so age si e 2 B
⏟ ⏟ 2 B
o, no page fault for these page fault for these
9 5 18. [Ans. C]
8 4 4 page faults Page size = 2 Bytes
7 3 Divide cache size by page size & group 16
6 2 pages in one set.
So total = 4+4+4=12 page faults
For 8 pages = 2 8 4=12 No. of pages in caches 2 pages
So for n pages = 2n 4 No. of sets in cache = sets
For 100 pages = 2 ( =196
So all pages which will be mapped to one
15. [Ans. B] set, will be colored with same color
Effective access time So 8 sets = 8 colors required.
= [(1 – p) access time when no page
fault +p access time during page fault]
[ ( )] 2 ns ( ) ms

( ) 2 ns ( ) ns
ns

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 204
GATE QUESTION BANK Operating System

19. [Ans. 7]
1 2 3 4 2 1 5 3 2 4 6
1 1 1 1 1 1 5 3 3 3 3
2 2 2 2 2 2 2 2 2 6
3 4 4 4 4 4 4 4 4
No. of page faults = 7

20. [Ans. 6]
Total frames = 3
LRU page replacement algorithm: Least recently used page has to be replaced
4 7 6 1 7 6 1 2 7 2
4 4 4 1 1 1
7 7 7 2 2
6 6 6 7
Total no. of page faults = 6

21. [Ans. 122]


Page Table is in Main Memory
Time to access TLB = 10 milliseconds
Time to access Memory = 80 milliseconds
TLB hit ratio = 0.6
Time to access Page from Memory
Time to access Page from Memory
Time to search TLB Time to search TLB

Effective Access Time [EAT] = 0.6 (10 + 80) + 0.4 (10 + 80 + 80)
= 54 + 68
= 122 milliseconds

Time to access page Table


22. [Ans. D]
Total no.of physical page frames = frames in main memory = 20 , 2, … 2
Pages of a program = pages in Hard Disk = 100 , 2, … ,
rogram accesses the page numbered , 2, ……, 100} THRICE in the order. [3 times]
Which page replacement algorithm gives the same no. of page faults when Optimal page
replacement policy is used?
Page Replacement Algorithm = Optimal Page Replacement
“Replace the age that will not be used for a longest period of time in future”

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 205
GATE QUESTION BANK Operating System

Page
numbered
, 2, …2 in
main
Memory Page : 21 Page : 22 Page : 23 Page : 24
occupying
20 Free
Frames
101 1 101 1 101 1 101 1 101 1
102 2 102 2 102 2 102 2 102 2
103 3 103 3 103 3 103 3 103 3
104 4 104 4 104 4 104 4 104 4
105 5 105 5 105 5 105 5 105 5
106 6 106 6 106 6 106 6 106 6
107 7 107 7 107 7 107 7 107 7
108 8 108 8 108 8 108 8 108 8
109 9 109 9 109 9 109 9 109 9
110 10 110 10 110 10 110 10 110 10
111 11 111 11 111 11 111 11 111 11
112 12 112 12 112 12 112 12 112 12
113 13 113 13 113 13 113 13 113 13
114 14 114 14 114 14 114 14 114 14
115 15 115 15 115 15 115 15 115 15
116 16 116 16 116 16 116 16 116 16
117 17 117 17 117 17 117 17 117 17
118 18 118 18 118 18 118 18 118 18
119 19 119 19 119 19 119 19 119 19
120 20 120 21 120 22 120 23 120 24
For every Fault Optimal Algorithm will be selecting the Most Recently Used Page a Replacement.
Both Optimal & Most recently Used will generate same no of Page Faults.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 206
GATE QUESTION BANK Operating System

File System
CS – 2005 CS – 2014
1. In a computer system, four files of size 4. A FAT (file allocation table) based file
11050 bytes, 4990 bytes, 5170 bytes and system is being used and the total
12640 bytes need to be stored. For overhead of each entry in the FAT is 4
storing these files on disk, we can use bytes in size. Given a bytes
either 100 byte disk blocks or 200 byte disk on which the file system is stored
disk blocks (but can‘t mix block sizes). and data block size is bytes, the
For each block used to store a file, 4 bytes maximum size of a file that can be stored
of bookkeeping information also needs to on this disk in units of bytes is
be stored on the disk. Thus, the total ____________.
space used to store a file is the sum of the
space taken to store the file and the space
taken to store the bookkeeping
information for the blocks allocated for
storing the file. A disk block can store
either bookkeeping information for a file
or data from a file, but not both. What is
the total space required for storing the
files using 100 byte disk blocks and 200
byte disk blocks respectively?
(A) 35400 and 35800 bytes
(B) 35800 and 35400 bytes
(C) 35600 and 35400 bytes
(D) 35400 and 35600 bytes

CS - 2008
2. 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

CS – 2012
3. A file system with 300 Gbyte disk uses a
file descriptor with 8 direct block
addresses, 1 indirect block address and 1
doubly indirect block address. The size of
each disk block is 128 Bytes and the size
of each disk block address is 8Bytes. The
maximum possible file size in this file
system is
(A) 3 Kbytes
(B) 35 Kbytes
(C) 280 Bytes
(D) Dependent on the size of the disk

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 207
GATE QUESTION BANK Operating System

Answer Keys and Explanations


1. [Ans. C] Size of Block = bytes
locks fo file Total no. of Blocks in Disk = Total Size of
Disk / Size of Block
Blocks for book keeping = = 100 / = Blocks
For 100 bytes blocks:- Size of FAT table = Total No of Blocks
File Book keeping Size of each entry in FAT
F1 111 5 = ×4 = 0.4× bytes
F2 50 2 Max Size of File = Total Size of Disk - Size
F3 52 3 of FAT
F4 127 6 = (100 × ) (0.4 × ) = 99.6 ×
Total 340 16 bytes
) ) Answer = 99.6 bytes 99.6 in
units of bytes
For 200 block size
Blocks for Blocks for
file Book keeping
F1 55 2
F2 25 1
F3 26 1
F4 64 3
Total 170 7
) )

2. [Ans. D]
The data blocks of a very large file in the
unix file system are allocated using an
extension of indexed allocation or EXT2
file system.

3. [Ans. B]
Maximum possible size =
add ess pointed b doubl indi ect block)
add ess pointed b single add ess)
add ess pointed b single di ect add ess)
block size

[( ) ( ) ]

k k k

4. [Ans. *] Range 99.55 to 99.65


In FAT based file system FAT table will
be maintained for each partition.
Total no. of entries in FAT table = Total
no. of Blocks in the Disk. [one entry in
FAT per Block]
Size of each entry in FAT = 4 bytes
Total Size of Disk = 100 bytes

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 208
GATE QUESTION BANK Operating System

I/O System
CS - 2009 CS - 2013
1. Consider a disk system with 100 3. Consider a hard disk with 16 recording
cylinders. The requests to access the surfaces (0-15) having 16384 cylinders
cylinders occur in the following sequence: (0-16383) and each cylinder contains 64
4, 34, 10, 7, 19, 73, 2, 15, 6, 20 sectors (0-63). Data storage capacity in
Assuming that the head is currently at each sector is 512 bytes. Data are
cylinder 50, what is the time taken to organized cylinder – wise and the
satisfy all requests if it takes 1 ms to move addressing format is <cylinder no.,
from one cylinder to adjacent one and surface no., sector no>. A file of size
shortest seek time first policy is used? 42797 KB is stored in the disk and the
(A) 95 ms (C) 233 ms starting disk location of the file is
(B) 119 ms (D) 276 ms < 1200, 9, 40>. What is the cylinder
CS - 2011 number of the last sector of the file, if it is
2. An application loads 100 libraries at stored in a contiguous manner?
startup. Loading each library requires (A) 1281 (C) 1283
exactly one disk access. The seek time of (B) 1282 (D) 1284
the disk to a random location is given as
10 ms. Rotational speed of disk is
6000rpm. If all 100 libraries are loaded
from random locations on the disk, how
long does it take to load all libraries? (The
time to transfer data from the disk block
once the head has been positioned at the
start of the block may be neglected.)
(A) 0.50 s (C) 1.25 s
(B) 1.50 s (D) 1.00 s

Answer Keys and Explanations


1. [Ans. B]
Head is currently at cylinder 50,

Total moves = 16 + 14 + 1 + 4 + 5 + 3
+1 + 2 + 2 + 71
= 119
So for each move time taken = 1ms
So for 119 moves time =119 ms

2. [Ans. B]
Rotation speed = 6000 rpm

Seek time = 10 ms

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 209
GATE QUESTION BANK Operating System

1 access time = seek tome + latency


=10+5
=15 ms
So, for 100 accesses = 15 ms
= 1.5 sec

3. [Ans. D]
Each surface contains = 64 sectors
Each cylinder contains = 64
sectors
42797 KB =
Current cylinder 1200, can have
24+(6 64) = 408 sectors more for this
file
Remaining sectors = 85186
No. of sectors in one cylinder = 1024
So, to store remaining sectors cylinders
needed

Means 83 complete cylinders and some


portion of 84th cylinder. So, last sector of
the file will be at 1200+84=1284
cylinders.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 210
GATE QUESTION BANK TOC

Finite Automata

CS – 2005 Consider the strings u = abbaba, v = bab


1. Consider the machine M and w = aabb. Which of the following
b b statements is true?
a (A) The automaton accepts u and v but
a b b
not w
a a (B) The automaton accepts each of u, v
and w
a, b
(C) The automaton rejects each of u, v
and w
The language recognized by M is
(D) The automaton accepts u but rejects
(A) {w { }*|every a in w is followed
v and w
y x tly two s}
(B) {w {a, b}*|every a in w is followed CS – 2007
y t l st two ’s} 4. A minimum state deterministic finite
(C) {w {a, b}*|w does not contains the automation accepting the language
su string ‘ ’} L = {w w ϵ {0,1}*, number of 0s & 1s in
(D) {w {a,b}*|w ont ins ‘ ’ s w are divisible by 3 and 5, respectively}
substring} has
(A) 15 states (C) 10 states
2. The following diagram represents a finite
state machine which takes as input a
(B) 11 states (D) 9 states
binary number from the least significant 5. Consider the following DFA in which s is
bit the start state and s , s are the final
0/0 0/1
1/0
states.
1/1
x s y

Which one of the following is TRUE? y


x
(A) It omput s 1’s ompl m nt of th s s
input number y
x
(B) It omput s 2’s ompl m nt of th
input number x
y s
(C) It increments the input number
(D) It decrements the input number What language does this DFA recognize?
CS – 2006 (A) All strings of x and y
3. In the automaton below, s is the start (B) All strings of x and y which have
state & t is the only final state. either even number of x and even
number of y or odd number of x and
odd number of y
s t (C) All strings of x and y which have
equal number of x and y
(D) All strings of x and y with either even
r number of x and odd number of y or
odd number of x and even number
of y.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 211
GATE QUESTION BANK TOC

CS – 2009 CS – 2011
6. Given the following state table of an FSM 9. Definition of a language L with alphabet
with two states A and B, one input and {a} is given as following
one output: L={ k n n is positiv int g r
Present Present Input Next Next Out constant}
State A State B State State put What is the minimum number of states
A B
needed in a DFA to recognize L?
0 0 0 0 0 1
(A) k + 1 (C) 2n+1
0 1 0 1 0 0
(B) n + 1 (D) 2k+1
1 0 0 0 1 0
1 1 0 1 0 0 10. A deterministic finite automaton (DFA) D
0 0 1 0 1 0 with alphabet ∑ {a,b} is given below:
0 1 1 0 0 1
1 0 1 0 1 1 p q r
1 1 1 0 0 1
If the initial state is A = 0, B = 0, what is
the minimum length of an input string
which will take the machine to the state
A = 0, B = 1 with Output = 1? t
(A) 3 (C) 5
Which of the following finite state
(B) 4 (D) 6
machines is a valid minimal DFA which
accepts the same language as D?
7. The following DFA accepts the set of all
strings over {0,1} that
1
1 0 p q r

0 0
1
(A) Begin either with 0 or 1 s
(B) end with 0
(C) end with 00
(D) contain the substring 00 s

CS – 2010
8. Let w be any string of length n in {0, 1}*. p q r
Let L be the set of all substrings of w.
What is the minimum number of states in
a non-deterministic finite automaton that
accepts L?
(A) n 1 (C) n+1
(B) n (D) 2 p q r

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 212
GATE QUESTION BANK TOC

than 3 are also in the language. A partially


completed DFA that accepts this language
p q is shown below.

1
1

1 q 1
s
1 1 1

11. The lexical analysis for a modern 11


1
computer language such as Java needs the
power of which one of the following The missing arcs in the DFA are
machine models in a necessary and (A)
sufficient sense? 00 01 10 11 q
(A) Finite state automata 00 1 0
(B) Deterministic pushdown automata 01 1
(C) Non-deterministic pushdown 10 0
automata 11 0
(D) Turing machine
(B)
12. Let P be a regular language and Q be a 00 01 10 11 q
context-free language such that Q ⊆ P. 00 0 l
(For example, let P be the language 01 1
represented by the regular expression 10 0
p*q* and Q be {p q n } Then which 11 0
of the following always regular?
(A) P ∩ Q (C) Σ* P (C)
(B) P – Q (D) Σ* Q 00 01 10 11 q
00 1 0
CS – 2012 01 1
13. What is the complement of the language
10 0
accepted by the NFA shown below?
11 0
ssum ∑ { } n is the empty string
(D)
a
00 01 10 11 q
00 1 0
01 1
(A) (B) { } (C) (D) { } 10 0
11 0
14. Consider the set of strings on {0,1} in
which, every substring of 3 symbols has
at most two zeros. For examples, 001110
and 011001 are in the language, but
100010 is not. All strings of length less

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 213
GATE QUESTION BANK TOC

CS – 2013 CS – 2014
15. Consider the DFA A given below. 16. Consider the finite automaton in the
1 following figure
1 1

1 1 1
1 q
q q q

What is the set of reachable states for the


input string 0011?
(A) {q q q } (C) {q q q q }
(B) {q q } (D) {q }
1
17. L tΣ finit non-empty alphabet and
Which of the following are FALSE?
let 2 th pow r s t of Σ* Whi h on
1. Complement of L(A) is context – free.
of the following is TRUE?
2. L(A)= L((11*0+0)(0+1)*0*1*)
3. For the language accepted by A,A is (A) Both 2 n Σ* are countable
the minimal DFA. (B) 2 is ount l n Σ* is un ount l
4. Accepts all strings over {0, 1} of (C) 2 is un ount l n Σ* is ount l
length at least 2. (D) Both 2 n Σ* r un ount l
(A) 1 and 3 (C) 2 and 3
(B) 2 and 4 (D) 3 and 4

Answer Keys and Explanations

1. [Ans. B] Transition table for the diagram is


(A) is f ls sin M is pting “ bbb” PS Next state
(B) is true. 0 1
(C) is false since the string abb is 1
accepted by M. 1 1
(D) is false, since abb does not contain
“ ” s su string ut abb is being Output function z is
rejected by M. PS Start state
0 1
2. [Ans. B] q0 0 1
To onv rt in ry num r to 2’s q1 1 0
complement fom, all the digits from LSB The output z computes th 2’s
are directly copied upto the 1st occurance complement of the input number.
of 1. After that all digits are
complemented 3. [Ans. D]
0/0 0/1
At the end of string u, automaton will be
1/0
1/1 at the final state t, but the automaton will
be at the state s after the end of both the
strings v and w.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 214
GATE QUESTION BANK TOC

4. [Ans. A] Thus the corresponding NFA looks like as


L={w w { 1} number of ’s n 1’s in follows:
w are divisible by 3 and 5 respectively} 0/1 0/1 0/1

The minimum number of states for the


0/1
state deterministic finite automation
accepting the language L has Dead state
3 × 5 = 15 states.
9. [Ans. B]
5. [Ans. D]
The following DFA that accepts a
As s and s are both final states, the
s qu n of ’s whos l ngth is positiv
strings accepted are x, y, xyx, yxx etc.
multiple of a constant n. It has n + 1
states q0 through qn.
6. [Ans. A]
String 1 0 1 will bring m/c to specified
state.
The transition diagram is given below:
0/1
1/0
10. [Ans. A]
1 The language accepted by given DFA is
L
1/1 Choice (A)is accepting same language and
1/1 0/0 1/1, 0/0 is minimal “ ” is r j t y hoi
and it belongs to L. So choice (B) is
11 1 incorrect.
0/0 Choice (C) is an NFA and hence not the
right answer
00 –----------1(0) --------> 01 –-----0(0) --- “ ” is pt y hoi n is
---> 10 –---1(1) -----> 01 rejected by L. So choice (D) is incorrect.
(Highlighted text is input followed by
output). 11. [Ans. A]
Lexical analysis uses express regular
7. [Ans. C] expressions. So, finite state automata is
(A) says that all strings that start with necessary and sufficient to perform
either 0 or 1, which is not true because lexical analysis.
1001 is one of this string which is not the
member of given DFA. 12. [Ans. C]
(B) imil rly string “ ” is n ing string Complement of a regular language is
and not acceptable by given DFA. always regular.
(D) lso n’t orr t s 1 is not
accepted by given DFA. 13. [Ans. B]
Any string of {0, 1} that ends with 00
certainly acceptable by this DFA.

8. [Ans. C] Language for NFA L =


Since L is set of all substrings of w, that Now L̅ Σ* L
mean L has strings of Length ⟹L̅
0, 1, 2, 3 ---------- n. ⟹L̅ { }

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 215
GATE QUESTION BANK TOC

14. [Ans. D] Minimal DFA is


Notice that the state names are given 1 1
based on ending bits of the string, which
has been processed.
Th r from l l “ ” shoul go to
trap state q (since at most 2 zeros are 4. A accepts all strings over {0,1} of
allowed in any substring). length at least 2-False. The given DFA
Based on this fact, option (A) and (B) are accepts the string ‘ ’ which is of
incorrect. length less than 2.
Between option (C) and (D), if you look at
r l l “1” from st t 1 this r
16. [Ans. A]
should go to state 11 since the string at
this point is ending with 11. So option (C) (Current state, input) = next state
is wrong and option (D) is correct. q q
The DFA corresponding to correct option q q
(D) is shown below missing arrow shown q 1 q or q
in dotted lines. q 1 q
So set of reachable states
1 {q q q }
1
1
17. [Ans. C]
1 q 1
2 is the power set of Σ
1 1 1 Σ is countability infinite.
1
1 1 The power set of countable infinite set is
uncountable.
1 11
So 2 is uncountable, and Σ is countable

15. [Ans. D]
1. Complement of L(A) is context – free
– True
As there exist a DFA , L(A) is regular.
Regular languages are closed under
complement
∴Complement of L(A) is regular and
therefore context free.
2. L(A)= L((11*0+0)(0+1)*0*1*) –
True
As L(A)=L((11*0+0)(0+1)*) is
equivalent to
L((11*0+0)(0+1)*0*1*).
3. For the language accepted by A, A is
minimal DFA – False

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 216
GATE QUESTION BANK TOC

Regular Expression
CS – 2005 CS – 2007
1. Which of the following statements is 6. Which of the following languages is
TRUE about the regular expression 01*0? regular?
(A) It represents a finite set of finite (A) *ww w * + +
strings. (B) *ww x x w * + +
(B) It represents an infinite set of finite (C) *wxw x w * + +
strings. (D) *xww x w * + +
(C) It represents a finite set of infinite
strings. Common Data for Q.7 & Q.8
(D) It represents an infinite set of infinite Consider the following Finite state
strings. Automation

2. The language * n + is q3
b
b
(A) Regular a b
(B) context free but not regular a

(C) context free but its complement is q0 q1 q2 b


a
not context free
a
(D) not context free
7. The language accepted by this automaton
CS – 2006 is given by the regular expression
3. Consider the regular language (A) b* ab* ab* ab* (C) b*a(a + b)*
L= (111+11111)*. The minimum number (B) (a + b)* (D) b * ab* ab*
of states in any DFA accepting this
languages is: 8. The minimum state automaton equivalent
(A) 3 (B) 5 (C) 8 (D) 9 to the above FSA has the following
number of states
4. Which regular expression best describes
(A) 1 (B) 2 (C) 3 (D) 4
the language accepted by the non-
deterministic automaton below? 9. Which of the following is TRUE?
(A) Every subset of a regular set is
regular
q q q q (B) Every finite subset of a non-regular
(A) (a + b) * a(a + b)b set is regular
(B) (abb)* (C) The union of two non-regular sets is
(C) (a + b) * a(a + b) * b(a + b)* not regular
(D) (a + b)* (D) Infinite union of finite sets is regular

5. Which of the following statements about


regular languages is NOT true?
(A) Every language has a regular superset
(B) Every language has a regular subset
(C) Every subset of a regular language is
regular
(D) Every subset of a finite language is
regular

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 217
GATE QUESTION BANK TOC

CS – 2008 Q. 1
10. Given below are two finite state automata
( indicates the start state and F 0
1
indicates a final state) 0
0
Y: Z:
a b a b
1 2 2 2
2(F) 2 1 2(F) 1 1
R. 1
Which of the following represents the
product automaton Z Y? 0
(A) 1
1
a b 0
P S R
Q R S
R(F) Q P
S Q P
(B) S.
1
a b
P S Q 0
1
Q R S 1
0
R(F) Q P
S P Q
(C)
a b
. ε + ( * + )* *
P Q S
. ε + ( * + )*
Q R S
3. ε + ( * + )*
R(F) Q P
4. ε + ( * + )* *
S Q P
(A) P–2, Q-1, R-3, S-4
(D)
(B) P-1. Q-3, R-2, S-4
a b
(C) P-1, Q-2, R-3, S-4
P S Q (D) P-3, Q-2, R-1, S-4
Q S R
R(F) Q P 12. Which of the following are regular sets?
S Q P 1. { n 0, m 0 }
2. { n=2m}
11. Match the following NFAs with the
3. { n m}
regular expressions they correspond to.
4. * x y x y є * +*+
P. 1 (A) 1 and 4 only (C) 1 only
1 (B) 1 and 3 only (D) 4 only
0
0 0

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 218
GATE QUESTION BANK TOC

13. Consider the following two finite CS – 2010


automata. M1 accepts L1 and M2 accepts 16. Let L = {w (0 + 1)* | w has even
L2. num er of ’s+ i.e. is the set of ll it
strings with even num er of ’s.
0 0,1
Which one of the regular expressions
below represents L?
1 1 (A) (0*10*1) * (C) 0*(10*1)*0*
(B) 0*(10*10*)* (D) 0*1(10*1)*10*
0

CS -2012
0,1 0,1 17. Given the language L = {ab, aa, baa},
which of the following strings are in L*?
1 1 1. abaabaaabaa
2. aaaabaaaa
3. baaaaabaaaab
Which one of the following is TRUE? 4. baaaaabaa
(A) (C) L1 (A) 1, 2 and 3 (C) 1, 2 and 4
(B) (D) L1 (B) 2, 3 and 4 (D) 1, 3 and 4

14. Which of the following regular CS – 2013


expressions describes the language over 18. Consider the languages n
{0, 1} consisting of strings that contain * +. Which one of the following
ex tly two ’s? represents ?
(A) (0 +1)* 11(0 +1)* (A) *ε+ (B) (C) (D) *ε +
(B) 0 * 110*
(C) 0*10*10* CS – 2014
(D) (0 +1)* 1(0 +1)* 1 (0 +1)* 19. Which one of the following is TRUE?
(A) The language L ={ n + is
CS – 2009 regular
15. Which one of the following languages (B) The language
over the alphabet {0, 1} is described by L = * n is prime+ is regul r
the regular expression: (C) The language
( + ) ( + ) ( + )? L=*w w h s 3 + s for some with
(A) The set of all strings containing the * + + is regul r
substring 00 (D) The language
(B) The set of all strings containing at L = *ww w with * ++
most two ’s is regul r.
(C) The set of all string containing at
le st two ’s 20. Let L be a language and be its
(D) The set of all strings that begin and complement. Which one of the following
end with either 0 or 1 is NOT a viable possibility?
(A) Neither L nor is recursively
enumerable (r.e.).
(B) One of L and is r.e. but not
recursive; the other is not r.e.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 219
GATE QUESTION BANK TOC

(C) Both L and are r.e. but not 25. Let A B denotes that language A is
recursive. mapping reducible (also known as many-
(D) Both L and are recursive. to-one reducible) to language B. Which
one of the following is FALSE?
21. Which of the regular expressions given (A) If A B and B is recursive then A is
below represent the following DFA? recursive.
0 0 1
(B) If A B and A is undecidable then B
is undecidable.
(C) If A B and B is recursively
enumerable then A is recursively
enumerable.
1 (D) If A B and B is not recursively
enumerable then A is not recursively
I) 0*1(1 + 00* 1)*
enumerable.
II) 0*1* 1+ 11* 0* 1
III) (0 + 1)* 1
(A) I and II only (C) II and III only
(B) I and III only (D) I, II and III

22. If = * n + n * n +,
consider
(I) is regul r l ngu ge
(II) * n +
Which one of the following is CORRECT?
(A) Only (I)
(B) Only (II)
(C) Both (I) and (II)
(D) Neither (I) nor (II)

23. Let *w * +* w h s t le st s
m ny o urren es of ( )’s s ( )’s+.
et *w * + w has at least as
m ny o urren es of ( )’s s ( )’s+.
Which one of the following is TRUE?
(A) is regular but not
(B) is regular but not
(C) Both and are regular
(D) Neither nor are regular

24. The length of the shortest string NOT in


the language (over Σ * +) of the
following regular expression is
( ) ______________.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 220
GATE QUESTION BANK TOC

Answer Keys and Explanations

1. [Ans. D] middle of wwR. Hence only C seems to be


correct answer.
2. [Ans. A] The r.e for (C) is 1(0 + 1)*1 + 0(0 + 1)*0.
Every finite language is regular. Given That is language of strings starts and ends
language is finite hence it is regular with same symbol. Here acts as a marker
[Finite language or those which have to denote the end of w.
finite string of finite length is always
regular] 7. [Ans. C]
q
3. [Ans. D]
Note that 1, 11(length 2), 1111(length 4),
1111111(length 7) are not in L, while
and any string q q q
length >= 8(since all words more than 8
length can be formed using any
Here, in all strings accepted by this
combination of 111 and 11111) are in L.
automation, at least one a is necessary to
The corresponding DFA is given below:
take from initial state to first final state q1
1 1 1 1 1 1
but another a is not mandatory because
1 string a is perfectly acceptable by this
automaton.
1 q is the initial state. From q to q the
regular expression is b* a. After that, every
1
combination of a and b is accepted by q
or q
4. [Ans. A] r ( + ).
We will use Arden theorem to solve this.
So the derivation is as follows: 8. [Ans. B]
= q0 (a + b) + - - - -(1) The minimum state FSA contains 2 states
Then using Arden, we as given below for the regular expression
q0 = ( + ) = (a + b)* - - - - (2) b*a(a+b)*
q1 = q0 a = (a + b)*a - - - - - (3)
b a, b
q2 = q1 (a + b) = (a + b)*a(a + b)- - - -(4)
q3 = q2 b = (a + b)*a(a + b)b
Since q3 is final state hence r.e for it is
q a q
correct choice.

5. [Ans. C]
9. [Ans. B]
6. [Ans. C] (A) is false. Consider L = {w | where w is
A B D n’t etermine the en of w n in {a, b} *} and L1 = {anbn| where
start of w . n > = 0};
If language is regular then an FA Clearly is a subset of L and L1 is not a
definitely exists for it. Let us try to design regular.
FA for each option. No FA can remember (B) is true; since all finite sets are regular.
(C) is false; consider non-regular set
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 221
GATE QUESTION BANK TOC

L1 = {anbn| where n > = 0} and its 16. [Ans. B]


complement . Choice (A) (0*10*1)* will always
The union over these two is {a, b}* which generate strings ending with 1. But we
is regular. want an expression for bit strings with
Every finite set must be regular, so (B) even num er of ’s whi h in lu es
must be true. strings li e “ ” whi h en s with .
So choice (A) is not correct.
10. [Ans. A] Choice (C) 0* (1 0 *1)* 0*
Draw the two automata and use product “ ” *( * )* * ut “ ”
construction. h s even num er of ’s
So choice (C) is incorrect
11. [Ans.C] Choice (D) *1(10*1)*10* but is a
Either you n use Ar en’s theorem or y it string with even num er of ’s (zero
careful observation we can solve this. ’s). So hoi e (D) is in orre t.
[Q] accepts string ending with 0. Choice (B) can generate all bit strings
[R] accepts strings ending with 1. Thus with even num er of ’s. So choice (B) is
only [C] is the suitable choice correct.

12. [Ans. A] 17. [Ans. C]


Set [1] is regular as FA exists and we can L = {ab, aa, baa}
write r.e also. The r.e is a*(bb)* The breakdown of the strings 1, 2, 4, in
(b symbol should occur in multiple of 2). terms of ab, aa and baa is shown below:
Set [2] and [3] are not regular as there is 1. ab aa baa ab aa
no finite automaton exists that can 2. aa aab aa aa
remember the count of a as to compare 3. baa aa ab aa
with count of b. String no. 3 has no breakdown in terms of
Set [4] again is regular. The r.e for it is strings in L and hence string 3 does not
(a + b)* c (a +b)*. belong to L*.
Only 1, 2 and 4 belongs to L*.
13. [Ans. A]
Both automata epts ll strings of ’s 18. [Ans. A]
n ’s th t h ve two onse utive ’s.
* +
14. [Ans. C] As is empty language so multiplication
(A) and (D) cannot be the answer of with any language will give .
because in each case minimum 2 number So .
of ’s is gu r ntee not ex tly one . Also ,ε- for all language
(B) also cannot be the answer because it Also [ -* ε
imposes one restri tion th t oth the ’s So gives ε
should be consecutive. So *ε+
Option (A) is correct.
15. [Ans. C]
The string generates all the strings which 19. [Ans. C]
ont ins tle st zero’s * n +is not regular because
n FS nnot e written th t will ‘ ount’
i enti l sequen es of ‘ ’ n symbols

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 222
GATE QUESTION BANK TOC

* n is prime+is not regular


because an FSM cannot be written that
will determine n is prime number or not
*ww w with * + is not
regular because an FSM cannot be
written that can remember w and repeat
the same for ww
So
*w w h s 3 + s for with
* + + is regular, because for this
language an FSM can be written.

20. [Ans. C]
Because if both L and are recursive
enumerable then L is recursive.
So option (C) is not possible

21. [Ans. B]
Option II will not accept 10101 but it is
accepted by given DFA. So regular
expression II does not represent the given
DFA
R.E I & III do

22. [Ans. A]
. is concatenation of languages and it
is regular
. is not* n +

23. [Ans. D]
None of the languages are regular because
both need counting and DFA lacks
memory element.

24. [Ans. 3]
R.E = a * b *(ba)* a *
Length 0 is present as it accepts , all
length of 1 string are present (a, b) also
n re present ut ‘ ’ is
not present. So it is 3

25. [Ans. D]
If A B and B is not recursively
enumerable then A will surely be not
recursively enumerable.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 223
GATE QUESTION BANK TOC

Context Free Grammar

CS – 2005 (B) ̅ is recursive and ̅ is not


1. Consider the languages recursively enumerable
={ nm } and (C) ̅ and ̅ are recursively enumerable
={ nm } (D) ̅ is recursively enumerable and ̅ is
Which one of the following statement is recursive.
false?
(A) is a context-free language 5. Consider the languages
(B) is a context-free language = *ww w * ++
(C) and are context-free languages = {w # w w * + + (Where # is a
(D) is a context sensitive special symbol)
language = *ww w * + +
Which one of the following is true?
2. Let L be a regular language and M be a (A) is a deterministic CFL
context free language, both over the (B) is a deterministic CFL
lph et Σ. et and denote the (C) is a CFL, but not a deterministic
complements of L and M respectively. CFL
Which of the following statements about (D) is a deterministic CFL
the language is TRUE?
(A) It is necessarily regular but not CS – 2006
necessarily context free 6. Let L1 = { nm +,
(B) It is necessarily context free * nm + and
(C) It is necessarily non-regular L3 * nm + which
(D) None of the above of these languages are NOT context free?
(A) L1 only (C) L1 and L2
3. Let and denote the classes of (B) L3 only (D) L2 and L3
languages accepted by non-deterministic
finite automata and non-deterministic 7. If s is a string over (0 +1)*, then let n (s)
push-down automata, respectively. Let D denote the num er of ’s in s nd n1(s)
and D denote the classes of languages the num er of ’s in s. Which one of the
accepted by deterministic finite automata following languages is not regular?
and deterministic push-down automata, (A) L = {s ϵ (0 + 1)* | n0(s) is a 3-digit
respectively. Which one of the following is prime}
TRUE? (B) L = {s ϵ ( + )* for every prefix’s
(A) D and D of s, | n0 (s ) – n1(s ) | 2}
(B) D and D = (C) L = {s ϵ (0 +1)* | n0(s) – n1(s) 4}
(C) D = and D = (D) L = {s ϵ (0 + 1)* | n0(s) mod 7
= n1(s) mod 5 = 0}
(D) D = and D

8. Consider the following statements


4. Let be a recursive language, and let
be a recursively enumerable but not a
about the context-free grammar,
recursive language. Which one of the G *S →SS S → S→ S→ }
following is TRUE? 1. G is ambiguous
(A) ̅ is recursive and ̅ is recursively 2. G produces all strings with equal
enumerable num er of ’s nd ’s

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 224
GATE QUESTION BANK TOC

3. G can be accepted by a deterministic CS – 2009


PDA. 13. S → S | bSb| a| b
Which combination below expresses all The language generated by the above
the true statements about G? grammar over the alphabet {a, b} is the
(A) 1 only set of
(B) 1 and 3 only (A) All palindromes
(C) 2 and 3 only (B) All odd length palindromes
(C) Strings that begin and end with the
(D) 1, 2 and 3
same symbol
9. For s ( + )* let d(s) denote the (D) All even length palindromes
decimal value of s (e.g.d(101) = 5). Let
*s ( + )* d(s) mod 5 2 nd 14. Which one of the following is FALSE?
d(s) mod 7 4}? (A) There is a unique minimal DFA for
Which one of the following statements is every regular language
true? (B) Every NFA can be converted to an
(A) L is recursively enumerable, but not equivalent PDA
recursive (C) Complement of every context-free
(B) L is recursive, but not context-free language is recursive
(C) L is context-free, but not regular (D) Every nondeterministic PDA can be
(D) L is regular converted to an equivalent
deterministic PDA
10. Let L1 be regular language, L2 be a
deterministic context-free language and 15. Let L = L1 where L1 and are
L3 a recursively enumerable, but not languages as defined below:
recursive, language. Which one of the * mn +
following statements is false? 2 * ijk +
(A) L1 is a deterministic CFL Then L is
(B) L3 is recursive (A) Not recursive
(C) L1 L2 is context free (B) regular
(D) L1 is recursively (C) context – free but not regular
enumerable (D) recursively enumerable but not context-
CS – 2007 free
11. The language L={0i 21i | i 0} over the
alphabet {0, 1, 2) is CS – 2010
(A) not recursive 16. Consider the language L1 = { i j+
(B) is recursive and is a deterministic L2 = { i j+ ( |i 2j + +
CFL L4 = { i 2j+. Which one of the
(C) is a regular language following statements is true?
(D) is not a deterministic CFL but a CFL (A) Only L2 is context free
(B) Only L2 and L3 are context free
CS – 2008 (C) Only L1 and L2 are context free
12. If L and ̅ and recursively enumerable (D) All are context free
then L is
(A) Regular
(B) Context –free
(C) Context –sensitive
(D) Recursive
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 225
GATE QUESTION BANK TOC

17. Let L1 be a recursive language. Let L2 and L3 CS - 2014


language that are recursively enumerable but 19. Consider the following languages over the
not recursive. Which of the following alphabet ∑ * +
statements is not necessarily true? * n +
(A) L2 L1 is recursively enumerable *w w wϵ* + +
(B) L1 L3 is recursively enumerable *ww wϵ* + +
(C) 2 is recursively enumerable Here, w is the reverse of the string w.
(D) 2 is re ursively enumer le Which of these languages are
deterministic Context-free languages?
CS – 2013 (A) None of the languages
18. Consider the following languages. (B) Only
* pqr + (C) Only and
* pqr p r+ (D) All the three languages
Which one the following statement is
FALSE?
(A) is context – free
(B) is context – free
(C) Complement of is recursive
(D) Complement of is context – free
but not regular

Answer keys and Explanations

1. [Ans. A] 3. [Ans. D]
and are both context free languages. : Non-Deterministic finite automata.
Context free languages are not closed : Non-Deterministic push-down
under intersection. automata.
D : Deterministic finite automata.
2. [Ans. D] D : Deterministic push down automata.
The complement of CFL need not be a A ording to “Su set Constru tion”
CFL. theorem every language accepted by Non-
[A] is false; Let us consider Mc as a CFL, deterministic-finite automata. ( ) is also
now remember not every CFL is regular. accepted by some Deterministic-Finite
Therefore it is not necessary that union is automata (D ) so D = .
regular. Deterministic push-down automata (D )
[B] is false; as we know complement may
recognizes a proper subset of the
not CFL. Thus union over non-CFL with
language of context-free languages and
regular will result into non-CFL.
the non-deterministic push down
[C] is false; it is not necessarily as argued
automata recognizes the context-free
in previously.
languages.
Thus [D] is most appropriate choice
So D

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 226
GATE QUESTION BANK TOC

4. [Ans. B] same as * x + which is


Given that is REC and is RE but not context sensitive
REC
Consider choice (A) ̅ is REC and ̅ is RE. 7. [Ans. C]
Since is REC, clearly ̅ is also REC. Choice (A) is regular since it is finite.
Since is RE but not REC, its Choice (B) is regular since although
complement has to be not RE. omp rison is m de etween ’s nd ’s
∴ But (A) l ims th t ̅ is RE. Therefore it is for all prefixes and this can be done
(A) is false by DFA.
Consider (B) ̅ is REC and ̅ is not RE. Note: |n (s ) n (s ) 2 is s me s
If is REC, then ̅ is REC. n (s ) n (s ) 2 or n (s ) n (s ) 2.
Also, if is RE but not REC, then ̅ is not Chose (C) involves comparison of number
RE of ’s nd ’s ut for the string as a
∴(B) is true. whole, and this cannot be done by a DFA,
Clearly (C) and (D) false since ̅ is not RE. since it has finite memory and has no
stack for counting upto infinity.
5. [Ans. B] Therefore, choice (C) is not regular
is CFL but not a DCFL, since accepting Choice (D) is regular since
ww necessarily involves finding the n (s) mod 7 = n (s) mod 5 = 0 means
middle of the string, which involves non- num er of ’s is divisi le by 7 and
determinism. num er of ’s is divisi le y 5 nd this
∴ (A) is false. can be accepted by a DFA with 7 × 5 = 35
is DCF is true sin e “#” is spe i l states.
symbol and middle of string can now be A DFA that will accept the language of
surely found y using “#” there y choice (B) is shown below:
1 1 0, 1
eliminating the need for non-
0 0 0
deterministic guessing. So (B) is true.
is a CSL and not a CFL. So (C) is false.
1 0
is not a DCFL either. So (D) is false.

6. [Ans. D] 1 0
* nm + is context free
(first n+m ’s re pushed into the st k
0, 1
then for each of the 1s and 0s following,
we will pop the 0s in the stack one by one
until at the end of the word. If the stack is 8. [Ans. B]
empty then the word is accepted). G *S → SS S → S→ S→ }
* nm + is not 1. “G is m iguous” is true sin e “ ”
context free, since two comparisons have has infinite number of derivations
to be made here to determine if w . some of which are shown below:
. s nd s are equal
2. Since m <n+m, we have to ensure that,
’s whi h ome fter are less
in number, compared to n+m.
* nm +is clearly
context sensitive since 2 comparisons
have to be made. Infact this language is
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 227
GATE QUESTION BANK TOC

S S on regular union, we can say that


S
is surely CFL.
S D. is RE” is true sin e ll
S S S
ε three are surely RE and RE languages
are closed under intersection.
ε ε ε S S

11. [Ans. B]
ε ε * 2 i } is a DCFL since, a DPDA can
ept this l ngu ge. ’s re pushed into
2. “G produ es ll strings with equ l the stack and then when 2 appears in
num er of ’s nd ’s” is f lse sin e input, state is changed and immediately
L(G) = (ab + ba)* and this language after that for every 1, a zero is popped out
cannot produce all strings with equal of the stack. In the end, if stack has start
num er of ’s nd ’s. For ex mple stack symbol only, then the string is
aabb h s equ l num er of ’s nd ’s accepted, else it is rejected. Since every
ut ∉ (G). DCFL is recursive, we can say that the
3. “G n e epted y DPDA” is language is recursive, and is a DCFL.
true, since L(G) = (ab + ba)* and this
is a regular language, since we have 12. [Ans. D]
written a regular expression for it. There is a theorem which states that
Since every regular language is also a whenever L and are both RE, then both
DCFL, a DPDA exists, which accepts will be REC.
this language.
13. [Ans. B]
9. [Ans. D] S→ S S is the grammar
There is a DFA corresponding to corresponding to all odd length
d(s) mod 5 = 2 as well as d(s) mod 7 = 4. palindromes.
Therefore, both of them are regular Notice that choice (C)is not correct since
languages. Let they be and . The "abaa" is a string that begins and ends
given language is . with the same symbol but cannot be
Since regular languages are closed under generated by above grammar.
intersection and complementation, the Since all strings generates by this
given language is also regular. grammar have odd length, choices (A)
and (D) are also incorrect.
10. [Ans. B]
Given be regular, is DCFL and is 14. [Ans. D]
RE but not REC. The set of DCF ’s re proper su l ss of
A. “ is DCF ” is true sin e DCF ’s the set of CF ’s of PDA’s. So, choice (D)
are closed under regular intersection. is false.
B. “ is re ursive” is f lse sin e is
RE but not REC and therefore 15. [Ans. C]
is surely RE according to closure of RE * m n 0}
under regular intersection, but we { |i j k +
cannot be sure that is REC. L=
C. “ is CF ” is true sin e is is context free language and ia
DCFL and hence a CFL and is regular language, as intesection of and
regul r. Therefore y losure of CF ’s
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 228
GATE QUESTION BANK TOC

is context free language, L is a context 19. [Ans. C]


free. For = *ww wϵ( ) +
It can not be predicted that where w is
16. [Ans. D] ending and where w is starting
L1 = { i j+ But in
L2= { i j+ * n +
L3 * i 2j + + Both inputs are different and in
L4 = { i 2j+ L2 = *w w wϵ( ) +
All of nd are context free, w and w are separated by an alphabet c.
since, each of these language is a linear
comparison between i & j and any linear
comparison between i & j can be
performed, in a PDA.

17. [Ans. B]
L2 and L3 are recusively enumerable
languages, r.e. languages are closed under
intersection and union. So, option (C) and
(D) are not correct. All recursive
languages are also recursive languages.
So, L2-L1 must be recusively enumerable.
So, Option (A) is not correct.

18. [Ans. D]
* pqr + regular
language
* pqr p r+ CFL
A. is CFL : True
B. is context free : True because
CFL is closed on regular intersection.
C. Complement of is recursive : true,
because CFL is not closed under
complement. Any language which is
CFL is also REC and complement of
REC is REC so it is true.
D. Complement of is context free but
not regular : false because regular
language are closed under
complement.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 229
GATE QUESTION BANK TOC

Turing Machines
CS – 2005 (C) DHAM3 is NP-hard, but SHAM3 is not
1. Consider three decision problems (D) Neither DHAM3 nor SHAM3 is
n . It is known that is NP-hard
decidable and is undecidable. Which
one of the following is TRUE? CS – 2007
(A) is decidable if is reducible to 5. Which of the following problems is
(B) is undecidable if is reducible to undecidable?
(A) Membership problem for CFGs
(C) is undecidable if is reducible to (B) Ambiguity problem for CFGs
(C) Finiteness problems for FSAs
(D) is decidable if is reducible to (D) Equivalence problem for FSAs
’s complement
CS – 2008
2. Consider the following two problems on 6. Which of the following is true for the
undirected graphs language {ap| p is a prime} ?
: Given G (V, E), does G have an (A) It is not accepted by a Turning
in epen ent set of size ∣V∣ 4? Machine
: Given G (V, E), does G have an (B) It is regular but not context-free
independent set of size 5? (C) It is context-free but not regular
Which one of the following is TRUE? (D) It is neither regular nor context-free,
(A) is in the P and is NP-complete but accepted by a Turning Machine
(B) is NP-complete and is in P
(C) Both and are NP-complete 7. Which of the following are decidable?
(D) Both and are in P 1. Whether the intersection of two
regular languages is infinite
CS – 2006 2. Whether a given context – free
3. Let S be an NP –complete problem and Q language is regular
and R be two other problems not known 3. Whether two push –down automata
to be in NP. Q is polynomial-time accept the same language
reducible to S and S is polynomial-time 4. Whether a given grammar is context
reducible to R. Which one of the following – free
statements is true? (A) 1 and 2 (C) 2 and 3
(A) R is NP-complete (B) 1 and 4 (D) 2 and 4
(B) R is NP-hard
8. Which of the following statement is false?
(C) Q is NP-complete
(A) Every NFA can be converted to an
(D) Q is NP-hard
equivalent DFA
(B) Every non –deterministic Turing
4. Let SHAM3 be the problem of finding a
machine can be converted to an
Hamiltonian cycle in a graph G = (V,E)
equivalent deterministic Turing
with |V| divisible by 3 and DHAM3 be the
machine
problem of determining if a Hamiltonian
(C) Every regular language is also a
cycle exists in such graphs. Which one of
context –free language
the following is true?
(D) Every subset of a recursively
(A) Both DHAM3 and SHAM3 are NP-hard
enumerable set is recursive
(B) SHAM3 is NP-hard, but DHAM3 is not

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 230
GATE QUESTION BANK TOC

9. Which of the following statements are CS – 2011


true? 11. Consider the languages L1, and as
1. Every left –recursive grammar can be given below.
converted to a right – recursive L1 = * |p q ∈ +
grammar and vice –versa = * |p q ∈ n p q+ n
2. All ε- productions can be removed =* |p q r ∈ n p q r+
from any context – free grammar by Which of the following statements is
suitable transformations NOT TRUE?
3. The language generated by a context – (A) Push Down Automata (PDA) can be
free grammar all of whose productions used to recognize L1 and
are of the from X w or X wY (B) L1 is a regular language
(where, w is a string of terminals and (C) All the three languages are context
Y is a non–terminal), is always regular. free
4. The derivation trees of strings (D) Turing machines can be used to
generated by a context –free grammar recognize all the languages
in Chomsky Normal from are always
binary trees 12. Which of the following pairs have
(A) 1 ,2,3, and 4 DIFFERENT expressive power?
(B) 2, 3 and 4 only (A) Deterministic finite automata (DFA)
(C) 1, 3 and 4 only and Non-deterministic finite
(D) 1, 2 and 4 only automata (NFA)
(B) Deterministic push down automata
10. Match List-I with List–II and select the (DPDA) and Non-deterministic push
correct answer using the codes given down automata (NPDA)
below the list: (C) Deterministic single-tape Turing
List -I machine and Non-deterministic
a. Checking that identifiers are single-tape Turing machine
declared before their use (D) Single-tape Turing machine and
b. Number of formal parameters in the multi-tape Turing machine
declaration of a function agrees with
the number of actual parameters in a CS – 2012
use of that function 13. Which of the following problems are
c. Arithmetic expression with matched decidable?
pairs of parentheses 1. Does a given program ever produce an
d. Palindromes output?
List –II 2. If L is a context-free language, then ̅
1. L = * c |n m + also context-free?
2. X X b X| Xc XC d X f| g 3. If L is a regular language, then is ̅ also
3. L = {wcw| w ∈ (a | b) *} regular?
4. X b X b| c X c| ε 4. If L is a recursive language, then, is ̅
also recursive?
Codes: (A) 1, 2, 3, 4 (C) 2, 3, 4
a b c d (B) 1, 2 (D) 3, 4
(A) 1 3 2 4
(B) 3 1 4 2
(C) 3 1 2 4
(D) 1 3 4 2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 231
GATE QUESTION BANK TOC

14. Assuming ≠ N which of the following 18. Which one of the following problems is
is TRUE? undecidable?
(A) NP-complete = NP (A) Deciding if a given context-free
(B) NP-complete ∩ ∅ grammar is ambiguous.
(C) NP-hard = NP (B) Deciding if a given string is
(D) P = NP-complete generated by a given context-free
grammar.
CS – 2013 (C) Deciding if the language generated
15. Which of the following statement is/are by a given context-free grammar is
FALSE? empty.
1. For every non – deterministic Turing (D) Deciding if the language generated
machine, there exists an equivalent by a given context-free grammar is
deterministic Turning machine. finite.
2. Turing recognizable languages are
closed under union and
complementation
3. Turing decidable languages are
closed under intersection and
complementation
4. Turing recognizable languages are
closed under union and intersection
(A) 1 and 4 (C) 2 only
(B) 1 and 3 (D) 3 only

16. Which of the following is/are


undecidable?
1. G is a CFG. Is L(G)= ?
2. G is a CFG. Is L(G)=∑*?
3. M is a Turing machine. Is L(M)regular?
4. A is a DFA and N is an NFA. Is L(A)=L(N)?
(A) 3 only (C) 1, 2 and 3 only
(B) 3 and 4 only (D) 2 and 3 only

CS – 2014
17. Let <M> be the encoding of a Turing
machine as a string over ∑ = {0,1}. Let
L = {<M>| M is a Turing machine that
accepts a string of length 2014}. Then, L is
(A) decidable and recursively enumerable
(B) undecidable but recursively enumerable
(C) undecidable and not recursively
enumerable
(D) decidable but not recursively
enumerable

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 232
GATE QUESTION BANK TOC

Answer Keys and Explanations


1. [Ans. C] and
Note that in general if , Since
decidable ⟹ decidable and S is NP-complete ⟹ R is NP-complete.
undecidable ⟹ is undecidable. ∴ (A) is true
Given that is decidable and is
undecidable. 4. [Ans. A]
Consider (A) is decidable if is HA be the problem of finding
reducible to i.e and if is Hamiltonian cycle in a graph G = (V, E)
undecidable, then would be with |V| is divisible by 3 contains three
undecidable. But it is given that and remainders either 0, 1 and 2 can be
decidable, therefore we cannot use this reduced to this problem 3SAT and hence
theorem. (A) is false. HA is NP-complete problem. DHA
Consider (B) is undecible if is be the problem of determining if a
reducible to i.e. Hamiltonian cycle exists is also a
Now if is undecidable then is reduction from 3SAT and hence it is also
undecidable but nothing is given NP-complete problem. So both DHA
regarding . Also if is decidable, then and HA are NP complete and hence
would be decidable, but it is given that NP Hard also.
is un eci le so we c n’t use this
(B) is false. 5. [Ans. B]
Consider (C) is undecidable if is (A) em ership pro lem of CFG’s is
reducible to i.e decidable (CYK algorithm exists).
Now if is undecidable, this would mean (B) Ambiguity problem of CFG’s is
is undecidable. Since it is given that undecidable.
is undecidable, therefore, surely is (C) Finiteness pro lem of F A’s is
undecidable is correct. decidable, since there exists an
Choice (C) is correct algorithm to check if a given regular
language L is finite or infinite.
2. [Ans. C] (D) Equiv lence pro lem for F A’s is
Consider the statement. decidable, since there exists an
: Given G(V E) oes G h ve n algorithm to check where
independent set of size |V| : L( ) ( ) or not.
Let G contains n nodes and assume
|n| = K for some constant K so there 6. [Ans. D]
is a polynomial time reduction from 3SAT Let L = { | p is a prime} the statement
then is lso N -complete. (D) is true. There is no DFA which
: Given G(V E) oes G h ve n recognizes the L or apply the pumping
independent set of size 5 is also lemma then we can say that is not a
NP-complete, reduction from 3SAT. regular language. It is not context free
either, but L is surely accepted by a
3. [Ans. A] (linearly bounded) Turning machine.
Note: then
is NP-complete ⟹ is NP-complete.
Given S, is NP-complete.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 233
GATE QUESTION BANK TOC

7. [Ans. B] S
1. “Intersection of two regul r
l ngu ges is infinite” is eci le
since we can construct a product A B
DFA of the 2 given DFA’s and then,
using the algorithm to check
finiteness or infiniteness on this
a C D
DFA’s, we can solve the problem.
2. “Whether given CF is regul r” is
undecidable.
3. “Whether two PDA’s ccept the s me c d
l ngu ge” is un eci le since
equiv lence of CF ’s is un ecidable.
10. [Ans. C]
4. “Whether given gr mmar is context
In *w c w | w ∈ ( | )*+ leftmost w is the
– free” is eci le since we c n
identifier checking and rightmost w is the
easily check using a TM, whether the
use of w.
LHS of every production has a single
In c the actual parameters are
variable and, then it is a CFG, else it is
and and the formal parameters and c
not a CFG.
and such that the number of
∴ n re eci le
arguments of a and b are equal to c and d
respectively.
8. [Ans. D]
The gr mm r *X X X|XcX| Xf|g+
(A) True
generates the arithmetic expressions with
(B) True
matched pair of parentheses.
(C) True
The gr mm r *X X |cXc|ε} generates
(D) Every subset of a recursively
the palindromic string.
enumerable set is recursive, is false,
since a set is a subset of itself and
11. [Ans. C]
there are RE languages, which are
is not context free. (It fails to satisfy
not recursive.
pumping lemma for context free
languages.) One can also infer the answer
9. [Ans. C]
by observing that options A, B and D
1. True
which are true.
2. All ε - productions can be removed
from only context free grammars
12. [Ans. B]
th t pro uce λ – free CF ’s
DFA ≡ NFA
If λ ε L(G), then all ε - productions D DA ≠ N DA
cannot be successfully removed. So 2 DT ≡ NT
is false ingle t pe T ≡ ulti-tape TM
3. True
4. True, since is Chomsky normal form, 13. [Ans. D]
every production is of the form of If L is regular, ̅ is surely regular.
So statement number (3) is trivially
A BC or A
decidable.
An example of a binary tree generated by
Also if L is recursive, ̅ is also surely
CNF derivation is shown below: recursive. So statement number (4) is
also trivially decidable.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 234
GATE QUESTION BANK TOC

Complement of a context free language, 16. [Ans. D]


may or may not be context free. So 1. G is CFG, Is L(G) = ? Decidable,
statement number (2) is not only a non because in CFG there exits a algorithm
trivial problem but is also undecidable.
to check whether L(G) = .
Statement (1) is undecidable.
Correct option is (D) i.e. only 3 and 4 are 2. G is CFG, Is L(G) = ∑* un eci le
decidable. no algorithm exits.
3. M is turning machine, Is L(M) regular,
14. [Ans. B] undecidable.
L is NP complete iff 4. A is a DFA and N is NFA, Is
( ) ∈N H (2) ∈ N L(A) =L(N), Trivially true so
∴ ption (A) c n t e s N -complete is decidable.
‘N ’ ut not ‘ ’
ption C: 17. [Ans. B]
NPH can be NP or not be NP Undecidable because
∴ ption C lso not correct L = {< M >|M is a turing machine}
∴ ption B : N complete ∩ P= is And halting of a turing machine is
correct answer. undecidable problem.
Recursively enumerable because given
15. [Ans. C] that turing machine accepts a string of
1. Non-deterministic turning machine length 2014.
can be simulated into an equivalent
deterministic turing machine. So for 18. [Ans. A]
every non deterministic turing There were algorithm to find the
machine there exits an equivalent membership of CFG (using CYK
deterministic turing machine. So algorithm) and finiteness of CFG (using
true. CNF graph) and emptiness. But there is
2. Turing recognizable language are no algorithm for ambiguity of CFG, so it is
closed under complementation so undecidable.
false.
3. Turing decidable languages are
closed under intersection and
complementation. If and are
two turing decidable languages then
we can easily construct turing
machine for and ∩ . So
true.
4. Turing recognizable language are
closed under union and intersection.
So true.
So option (C) is correct.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 235
GATE QUESTION BANK Computer Organization

Introduction to Computer Organization


CS – 2012
1. The decimal value 0.5 in IEEE single
precision floating point representation
has
(A) Fraction bits of 000…000 and
exponent value of 0
(B) Fraction bits of 000…000 and
exponents value of 1
(C) Fraction bits of 100…000 and
exponents value of 0
(D) No exact representation

Answer Keys and Explanations


1. [Ans. B]
0 (0 1000) 2
1 0000 2
As 1 is obvious and we don’t represent in
IEEE format
Exponent = 1
antissa 0000
Hence Option B is correct

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 236
GATE QUESTION BANK Computer Organization

Memory Hierarchy
CS – 2005 6. A computer system has a level 1
1. What is the swap space in the disk used instruction cache (I cache), a level 1
for? data cache (D-cache) and a level 2
(A) Saving temporary html pages cache (L2 – cache) with the following
(B) Saving process data specifications:
(C) Storing the super-block Capacity Mapping Block
(D) Storing device drivers method size
I- 4K Direct 4
2. Increasing the RAM of a computer
cache words mapping words
typically improves performance because
D- 4K 2-way set- 4
(A) Virtual memory increases
cache words associative words
(B) Larger RAMs are faster
mapping
(C) Fewer page faults occur
L2- 64K 4-way set- 16
(D) Fewer segmentation faults occur
cache words associative words
3. Consider a direct mapped cache of size mapping
32KB with block size 32 bytes. The CPU The length of the physical address of a
generates 32 bit addresses. The number word in the main memory is 30 bits. The
of bits needed for cache indexing and the capacity of the tag memory in the
number of tag bits are respectively I-cache, D-cache and L2-cache is,
(A) 10, 17 (C) 15, 17 respectively,
(B) 10, 22 (D) 5, 17 (A) 1 K×18-bit, 1K ×19-bit, 4K×16-bit
(B) 1K ×16-bit, 1K × 19-bit, 4K×18-bit
4. Consider a 2-way set associative cache
(C) 1K ×16-bit, 512×18-bit, 1K×16-bit
memory with 4 sets and total 8 cache
(D) 1K ×18-bit, 512 ×18-bit, 1K ×18-bit
blocks (0-7) and a main memory with
128 blocks (0-127). What memory
7. A CPU has a cache with block size
blocks will be present in the cache after
64 bytes. The main memory has k banks,
the following sequence of memory block
each bank being c bytes wide.
references if LRU policy is used for cache
Consecutive c-byte chunks are mapped
block replacement. Assuming that
on consecutive banks with warp-around.
initially the cache did not have any
All the k banks can be accessed in
memory block from the current job?
parallel, but two accesses to the same
0 5 3 9 7 0 16 55
bank must be serialized. A cache block
(A) 0 3 5 7 16 55
(B) 0 3 5 7 9 16 55 access may involve multiple iterations of
(C) 0 5 7 9 16 55 parallel bank accesses depending on the
(D) 3 5 7 9 16 55 amount of data obtained by accessing all
the k banks in parallel. Each iteration
CS – 2006
requires decoding the bank numbers to
5. A cache line is 64 bytes. The main
be accessed in parallel and this takes
memory has latency 32ns and
k/2 ns. The latency of one bank access is
bandwidth 1GBytes/s. The time required
80 ns. If c = 2 and k = 24, then latency of
to fetch the entire cache line from the
retrieving a cache block starting at
main memory is
address zero from main memory is
(A) 32 ns (C) 96 ns
(A) 92 ns (C) 172 ns
(B) 64 ns (D) 128 ns
(B) 104 ns (D) 184 ns
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 237
GATE QUESTION BANK Computer Organization

Common Data for Q.8& Q.9 10. The value of is


Consider two cache organizations: The (A) 0 (C) 16384
first one is 32 KB 2-way set associative (B) 2048 (D) 262144
with 32-byte block size. The second one
is of the same size but direct mapped. 11. The value of the ratio is
The size of an address is 32 bits in both (A) 0 (C) 1/8
cases. A 2-to- 1 multiplexer has latency
(B) 1/16 (D) 16
of 0.6 ns while a k-bit comparator has a
12. A CPU has 24-bit instructions. A program
latency of k/10 ns. The hit latency of the
starts at address 300(in decimal). Which
set associative organization is h while
one of the following is a legal program
that of the direct mapped one is h .
counter (all values in decimal)?
8. The value of h is
(A) 400 (C) 600
(A) 2.4 ns (C) 1.8 ns (B) 500 (D) 700
(B) 2.3 ns (D) 1.7 ns
CS – 2007
9. The value of h is
13. Consider a Direct Mapped Cache with 8
(A) 2.4 ns (C) 1.8 ns cache blocks (numbered 0 7). If the
(B) 2.3 ns (D) 1.7 ns memory block requests are in the
following order
Linked Answer Questions Q.10 & Q.11 3, 5, 2, 8, 0, 63, 9, 16, 20, 17, 25, 18, 30,
A CPU has a 32 KB direct mapped cache 24, 2, 63, 5, 82, 17, 24.
with 128-byte block size. Suppose A is a Which of the following memory blocks
two dimensional array of size 512 512 will not be in the cache at the end of the
with elements that occupy 8-bytes each. sequence?
Consider the following two C code (A) 3 (C) 20
(B) 18 (D) 30
segments, P1 and P2
P1 : for (i i i ) Statement for Linked Answer Questions
{ 14 and 15:
for(j j j ) Consider a machine with a byte
{ addressable main memory of bytes.
x [i][j] Assume that a direct mapped data cache
} consisting of 32 lines of 64 bytes each is
} used in the system. A 50
two-dimensionalarray of bytes is stored
P2 : for (i i i ) in the main memory starting from
{ memory location 1100 H. Assume that
for(j j j ) the data cache is initially empty. The
{ complete array is accessed twice.
{x [j][i] Assume that the contents of the data
} cache do not change in between the two
} accesses.

P1 and P2 are executed independently 14. How many data cache misses will occur
with the same initial state, namely, the in total?
array A is not in the cache and i, j, x are (A) 48 (C) 56
in registers. Let the number of cache (B) 50 (D) 59
misses experienced by P1 be and
that for P2 be
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 238
GATE QUESTION BANK Computer Organization

15. Which of the following lines of the data 3. The associativity of L2 must be
cache will be replaced by new blocks in greater than that of L1
accessing the array for the second time? 4. The L2 cache must be at least as
(A) line 4 to line 11 large as the L1 cache
(B) line 4 to line 12 (A) 4 only
(C) line 0 to line 7 (B) 1 and 4 only
(D) line 0 to line 8 (C) 1, 3 and 4 only
(D) 1, 2, 3 and 4
16. Consider a 4-way set associative cache
consisting of 128 lines with a line size of Common Data For Q.20, Q.21& Q.22
64 words. The CPU generates a 20-bit Consider a machine with a 2-way set
address of a word in main memory. The associative data cache of size 64K bytes
number of bits in the TAG, LINE and and block size 16 bytes.The cache is
WORD fields are respectively managed using 32 bit virtual addresses
(A) 9, 6, 5 (C) 7, 5, 8 and the page size is 4 Kbytes. A program
(B) 7, 7, 6 (D) 9, 5, 6 to be run on this machine begins as
follows:
CS – 2008
double ARR [ ][ ];
17. For a magnetic disk with concentric
int i, j;
circular tracks, the seek latency is not
/* initialize array ARR to 0.0 */
linearly proportional to the seek distance
for (i=0; i 1024;i++)
due to
for (j=0, j 1024; j ++)
(A) Non - uniform distribution of
ARR [i] [j] = 0.0;
requests
The size of double is 8 bytes. Array ARR
(B) Arm starting and stopping inertia
is located in memory starting at the
(C) Higher capacity of tracks on the
beginning of virtual page 0 x FF000 and
periphery of the platter
stored in row major order. The cache is
(D) Use of unfair arm scheduling
initially empty and no pre-fetching is
policies
done. The only data memory references
made by the program are those to array
18. In an instruction execution pipeline , the
ARR.
earliest that the data TLB (Translation
20. The total size of the tags in the cache
Look aside Buffer) can be accessed is
directory is
(A) Before effective address calculation
(A) 32 Kbits (C) 64 Kbits
has started (B) 34 K bits (D) 68 K bits
(B) During effective address calculation
(C) After effective address calculation 21. Which of the following array elements
has completed has the same cache index as ARR [0] [0]?
(D) After data cache lookup has (A) ARR [0] [4] (C) ARR [0][5]
completed (B) ARR [4][0] (D) ARR [5][0]

19. For inclusion to hold between two cache 22. The cache hit ratio for this
level L1 and L2 in a multilevel cache initialization loop is
hierarchy, which of the following are (A) 0% (C) 50%
necessary? (B) 25% (D) 75%
1. L1 must be a write –through cache
2. L2 must be write –through cache

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 239
GATE QUESTION BANK Computer Organization

CS – 2009 for L1 cache, L2 cache and main memory


Common Data for Question 23 and 24 unit respectively.
A hard disk has 63 sectors per track, 10 Data Bus Data Bus
L1 L2 Main
platters each with 2 recording surfaces Cache Cache memory
and 1000 cylinders. The address of a 4 words 4 words

sector is given as a triple〈 h 〉, where c


is the cylinder number, h is the surface 27. When there is a miss in L1 cache and a
number and s is the sector number. hit in L2 cache, a block is transferred
Thus, the sector is addressed as from L2 cache to L1 cache. What is the
〈 〉 , the 1st sector as 〈 〉 and so time taken for this transfer?
on. (A) 2 nanoseconds
23. The address 〈 〉 corresponds to (B) 20 nanoseconds
sector number: (C) 22 nanoseconds
(A) 505035 (C) 505037 (D) 88 nanoseconds
(B) 505036 (D) 505038
28. When there is miss in both L1 cache and
24. The address of 103 sector is L2 cache, first a block is transferred from
(A) 〈 〉 (C) 〈 〉 main memory to L2 cache, and then a
(B) 〈 〉 (D) 〈 〉 block is transferred from L2 cache L1
cache. What is the total time taken for
25. How many 32K × 1 RAM chips are
these transfers?
needed to provide a memory capacity of
(A) 222 nanoseconds
256 K-bytes =
(B) 888 nanoseconds
(A) 8 (C) 64
(B) 32 (D) 128 (C) 902 nanoseconds
(D) 968 nanoseconds
26. Consider a 4-way set associative cache
(initially empty) with total 16 cache 29. A main memory unit with a capacity of
blocks. The main memory consists of 256 4 megabytes is built using 1M 1-bit
blocks and the request for memory DRAM chips. Each DRAM chip has 1K
blocks is in the following order: rows of cells with 1K cells in each row.
0,255,1,4,3,8,133,159,216,129,63,8,48, The time taken for a single refresh
32, 73, 92,155 operation is 100 nanoseconds. The time
Which one of the following memory required to perform one refresh
block will not be in cache if LRU operation on all the cells in the memory
replacement policy is used? unit is
(A) 3 (C) 129 (A) 100 nanoseconds
(B) 8 (D) 216 (B) 100 nanoseconds
(C) 100 nanoseconds
CS - 2010 (D) 3200 nanoseconds
Common Data for Questions 27 and 28:
A computer system has an L1 and an L2 CS - 2011
cache, and a main memory unit 30. An 8KB direct-mapped write-bank
connected as shown below. The block cache is organized as multiple blocks,
size in L1 cache is 4 words. The block each of size 32-bytes. The processor
size in L2 cache is 16 words. The generates 32-bit addresses. The cache
memory access times are 2 nanoseconds, controller maintains the tag
20 nanoseconds and 200 nanoseconds

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 240
GATE QUESTION BANK Computer Organization

information for each cache block The lines in set s are sequenced before
comprising of the following. the lines in set (s+1). The main memory
1 Valid bit blocks are numbered 0 onwards. The
1 Modified bit main memory block numbered j must be
As many bits as the minimum needed mapped to any one of the cache lines
to identify the memory block mapped from
in the cache. (A) (j mod v ) k to (j mod v) k+(k 1)
(B) (j mod v ) to (j mod v) +(k 1)
What is the total size of memory
(C) (j mod k) to (j mod k) +(v 1)
needed at the cache controller to store
(D) (j mod k ) v to (j modk) v+(v 1)
meta-data (tags) for the cache?
(A) 4864 bits (C) 6656 bits
CS - 2014
(B) 6144 bits (D) 5376 bits
35. An access sequence of cache block
addresses is of length N and contains n
CS - 2012
unique block addresses. The number of
Statement for linked Answer Question
unique block addresses between two
31 and 32:
consecutive accesses to the same block
A computer has a 256Kbyte, 4-way set
addresses is bounded above by k. What
associative, write back data cache with is the miss ratio if the access sequence is
block size of 32 Bytes. The processor passed through a cache of associatively
sends 32 bit addresses to the cache A k exercising least – recently – used
controller. Each cache tag directory replacement policy?
entry contains, in addition to address (A) n/N (C) 1/A
tag, 2 valid bits, 1 modified bit and 1 (B) 1/N (D) k/n
replacement bits
31. The number of bits in the tag field of an 36. A 4-way set-associative cache memory
unit with a capacity of 16 kB is built
address is
using a block size of 8 words. The word
(A) 11 (C) 16
(B) 14 (D) 27 length is 32 bits. The size of the physical
address space is 4 GB. The number of
32. The size of the cache tag directory is bits for the TAG field is ________________.
(A) 160 Kbits (C) 40 Kbits
(B) 136 Kbits (D) 32 Kbits 37. In de igning a omputer’ a he y tem
the cache block (or cache line) size is an
CS - 2013 important parameter. Which one of the
33. A RAM chip has a capacity of 1024 words following statements is correct in this
of 8 bits each (1K 8). The number of context?
2 decoders with enable line needed (A) A smaller block size implies better
to construct a 16K 16 RAM from spatial locality
1K RAM is (B) A smaller block size implies a
(A) 4 (C) 6 smaller cache tag and hence lower
(B) 5 (D) 7 cache tag overhead
(C) A smaller block size implies a larger
34. In a k – way set associative cache, the cache tag and hence lower cache hit
cache is divided into v sets, each of which time
consists of k lines. The lines of a set are (D) A smaller block size incurs a lower
placed in sequence one after another. cache miss penalty

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 241
GATE QUESTION BANK Computer Organization

38. If the associativity of a processor cache is modules may overlap in time, but only
doubled while keeping the capacity and one request can be on the bus at any
block size unchanged, which one of the time. The maximum number of stores (of
following is guaranteed to be NOT one word each) that can be initiated in 1
affected? millisecond is ____________
(A) Width of tag comparator
(B) Width of set index decoder 40. The memory access time is
(C) Width of way selection multiplexor 1 nanosecond for a read operation with a
(D) Width of processor to main memory hit in cache, 5 nanoseconds for a read
data bus operation with a miss in cache,
2 nanoseconds for a write operation with
39. Consider a main memory system that a hit in cache and 10 nanoseconds for a
consists of 8 memory modules attached write operation with a miss in cache.
to the system bus, which is one word Execution of a sequence of instructions
wide. When a write request is made, the involves 100 instruction fetch
bus is occupied for 100 nanoseconds operations, 60 memory operand read
(ns) by the data, address, and control operations and 40 memory operand
signals. During the same 100 ns, and for write operations. The cache hit-ratio is
500 ns thereafter, the addressed 0.9. The average memory access time (in
memory module executes one cycle nanoseconds) in executing the sequence
accepting and storing the data. The of instructions is __________.
(internal) operation of different memory

Answer keys and Explanations


1. [Ans. B] 5. [Ans. C]
Saving process data. Latency time = 32 ns.
Bandwidth = 1GB / sec
2. [Ans. C] 1 sec = bytes
Increasing the RAM means increase the Or bytes = 1sec
primary memory which reduces the 64 bytes = 64 n sec
swapping so fewer page faults occur Total time = 64 + 32 = 96 ns

3. [Ans. A] 6. [Ans. A]
Size of cache = 32 KB For I cache: Number of block = 1 k
= 32 bytes 10 bits can be used to distinguish
= yte between blocks
yte it 1 block = 4 Words
Size of tag = 32 – 15 = 17 bits 2 bits to recognize between words
Cache indexing size = 10 bits
30
4. [Ans. C]
Notice here conflict occurs in placement 18 10 2
of block 55
Tag memory
3 is come first and never refuse so in this
set 3 is only victim for replacement Capacity of I – cache = 18 1k

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 242
GATE QUESTION BANK Computer Organization

D – cache: Number of blocks = For the next 15 address, there will be hit
as A [0] [0] to A [0] [15] are there in the
= 1k block
cache.Then again there will be a miss at
10 bits are enough to recognize b/w
A [0] [16] and hit at next 15 accesses.
blocks.
2 bits are required to recognize among & There for every = 16384 blocks
words within a block and it uses 2 way transfer during , there will be one
set mapping miss and 15 hits
19 9 2
Since the # of tags are always same 11. [Ans. B]
= k = 262144 (Because every access to
The size of tag memory is 19 × k array element is a miss)
Capacity of cache = 18 512

7. [Ans. D]
The main memory consists of 24 banks, 12. [Ans. C]
each of c bytes. Since parallel accesses to Size of instruction 24 bits
all banks are possible. Only two parallel Starting address of the program is 300.
accesses of all banks are needed to The size of instruction is 3 bytes long. So
traverse the whole data. the address is always the multiple of 3
For one parallel access, byte next address is 600 it is also the
Total time next instruction of the program
= Decoding time + latency time
= + 80 = 92 ns 13. [Ans. B]
0 8,0,16,24
Hence, for 2 such accesses,
time = 2 92 = 184 ns
1 9,17,25,17,
2 2,18,2,82
8. [Ans. A] 3 3
Tag Set Block 4 20
18 9 5 5 5
h = 6 30
= 2.4 ns 7 63
So, 18 is not present in final map shown
9. [Ans. D] of cache memory
Tag Set Block
17 10 5 14. [Ans. C]
56 data cache misses will occur.
h = 1.7 ns
There are 32 lines in the 50 × 50 array,
Because multiplexer is not required in therefore initial 32 misses + 8 misses
case of direct-mapping (this will replace initial 8 lines data). In
second round initial lines needs to be
10. [Ans. C]
reloaded again so 8 more misses i.e. 48
Cache is 32 KB with 128 bytes block size.
M1: When the first element A[0] [0] is 15. [Ans. A]
accessed , 128 byte block consisting of Line 4 to line 11.
At the last, while accessioning last 8 lines
(33 40) aging initial 8-lines 4-11 of the
Elements is brought into the cache.
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 243
GATE QUESTION BANK Computer Organization

cache has to be reloaded has 8 more Tag memory size


misses i.e. 48+8 = 56. = No. of sets No. of lines in a set No. of
tag bits
16. [Ans. D] it
No. of blocks in cache it
No. of blocks in main memory it

No. of sets in cache ⁄ 21. [Ans. B]
TAG bits log( ⁄ ) = 9bits After every two elements the index
LINE offset log(no of et )
increases once, therefore after 4048
log( ) it
WORD offset log( ) it elements the index will increment 2096
( ) which is index size.
17. [Ans. C] Hence, ARR[0] [0] and ARR [4] [0] has
Due to higher capacity of tracks on the the same.
periphery of the platter
22. [Ans. C]
18. [Ans. C] Row major access
Data TLB can be accessed only after a[0] [0] = Miss
effective address calculation has a[0] [1] = hit
completed a[0] [2] = Miss
a[0] [3] = hit
19. [Ans. A] ⋮
Considering the following diagram Every miss is followed by a hit
it ratio

23. [Ans. C]
The address < 400, 16, 29> corresponds
So cache must be at least large as the to sector no.
cache is very necessary. Because 400 2 10 63 + 16 63 + 29
and both are write through cache = 505037
this is not the sufficient condition.
24. [Ans. C]
20. [Ans. D]
The address < 0, 16, 31> corresponds to
2 way set associative
sector no. 16 63 + 31 = 1039
Cache memory size = 64 kB
Block size = 16 B
25. [Ans. C]
k
line k Basic RAM = 32k 1
Design RAM = 256k 8
et No. of RAM = = 64
it virtual addre It requires 8 parallel line and in each
32 bits
parallel line 8 parallel lines& in each
TAG SO WO parallel line 8 serial RAM chips are
required.
(
⇓ )

log ( )

log ( )
=17 bits = 11 bits it

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 244
GATE QUESTION BANK Computer Organization

26. [Ans. D] of L1 is 4 words. So only 4 words will be


There are total 4 sets in the cache and transferred.Then it takes time
each set contains 4 blocks. 20 + 2 = 22 nano seconds
0 48
28. [Ans. C]
4 32
From main memory, now again time of
Set 0 8
access is 200ns. So access means for L2
216 92
came from main memory
1
time ( ) ( )n
133
ano e ond
Set 1 73
Similarly for cache to access from
129
cache.
L1 time ano e ond
Totoal time required
Set 2 = 880 +22 = 902Nano seconds

255 155 29. [Ans. D]


3 Main memory unit has capacity = 4MB
Set 3 159 um er of hip
63 it
0 mod 4 = 0 set 0 it it
hip ha ( ) rows and
255 mod 4 = 3 set 3
1 K( ) cells
1 mod 4 = 1 set 1
In ea h row
4 mod 4 = 0 set 0
3 mod 4 = 3 set 3
8 mod 4 = 0 set 0
Time taken in one refresh operation
133 mod 4 = 1 set 1
= 100ns
159 mod 4 = 3 set 3
Time required to perform one refresh
216 mod 4 = 0 set 0
operation on all the ell in unit ‘
129 mod 4 = 1 set 1
63 mod 4 = 3 set 3
n
8 mod 4 = 0 set 0 (already in cache)
48 mod 4 = 0 set 0 48 will replace 30. [Ans. D]
block 0 using LRU
No of blocks =
32 mod 4 = 0 set 0 32 will replace
block Address format
73 mod 4 = 1 set 1 19 8 5
92 mod 4 = 0 set 0 92 will replace Tag Block offset
block 216 No. of tag bits per cache entry
155 mod 4 = 3 set 3 155 will replace = 19 + 1 + 1 = 21
255 So total =

27. [Ans. C] 31. [Ans. C]


When a miss in in L1, then it goes to L2 o of a he line
and access the word but in 1 time only 4
words can be transferred because data o of et
bus can take 4 words at a time.Block size

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 245
GATE QUESTION BANK Computer Organization

32 38. [Ans. D]
16 11 5 Width of processor to main memory data
Tags So Word bus is independent of cache associativity
offset
No. of Tag bits are 16 bits 39. [Ans. 10000]
For 1 store time required
32. [Ans. A] = 100ns(because of overlape)
Tag directory size = So in 1ns no. of stores =
Number of sets no of tags in each set
(no. of tag bits in each tag + valid bits + In 1 ms no. of stores =
modified bit + replacement bit) = 10000
( ) it
ption i orre t 40. [Ans. 1.68]
Total instructions
33. [Ans. B] = 100 instruction fetch operations
+60 memory operand read operations
At 1st level we need 4 decoders to select
+40 memory operand write operations
16 RAMS. At second level we need
= 200 instructions (operations)
1 decoder to select the 4 decoders of 1st
Time taken for fetching 100 instructions
level.
(equivalent to read)
= 90 × 1 ns + 10 × 5 ns = 140 ns
34. [Ans. A]
Memory operand Read operation
ain memory lo k ‘j’ mapped to any of
time = 90%(60) × 1ns +10%(60)×5 ns
cache line. Cache line range is:
= 54 ns + 30 ns = 84 ms
(j mod v)*k to (j mod v)*k + (k 1)
Memory operand write operation
35. [Ans. A] time = 90% (40)×2 ns+10%(40)×10 ns
As given n N =72 ns + 40 ns = 112 ns
And the miss ratio will not be dependent Total time taken for execution 200
on associativity and k and LRU policy will instructions = 140 + 84 + 112 = 336 ns
lead to n/N n
verage memory a e time

36. [Ans. 20] = 1.68 ns


No. of sets = k
No. of Blocks = lo k
Address length of memory = ( )
Address format:-
TAG Block Word Byte
20 7 3 2
TAG bits = 20

37. [Ans. D]
If a block size is smaller then less no. of
words will be replaced into cache from
main memory. So cache miss penalty will
be less.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 246
GATE QUESTION BANK Computer Organization

Pipeline
CS - 2005 fetching new instructions following a
1. A 5 stage pipelined CPU has the conditional branch until the branch
following sequence of stages: outcome is known. A program executes
IF – Instruction fetch from instruction 10 instructions out of which 20% are
memory, conditional branches. If each instruction
RD – Instruction decode and register takes one cycle to complete on average,
read, then total execution time of the program
EX – Execute: ALU operation for data and is
address computation, (A) 1.0 sec (C) 1.4 sec
MA – Data memory access – for write (B) 1.2 sec (D) 1.6 sec
access, the register read at RD
CS - 2007
stage it used,
4. Consider a pipelined processor with the
WB – Register write back.
following four stages
Consider the following sequence of
IF : Instruction Fetch
instructions:
ID: Instruction Decode and Operand
: L R0, Loc 1; R0 ← M [Loc 1]
Fetch
: A R0, R0; R0 ← R0 + R0
EX : Execute
:S R2, R0; R2 ← R2 – R0
WB : Write Back
Let each stage take one clock cycle.What
The IF, ID and WB stages take one clock
is the number of clock cycles taken to
cycle each to complete the operation.
complete the above sequence of
The number of clock cycles for the EX
instructions starting from the fetch of ?
stage depends on the instruction. The
(A) 8 (C) 12
ADD and SUB instructions need 1 clock
(B) 10 (D) 15
cycle and the MUL instruction need 3
2. We have two designs D1 and D2 for a clock cycles in the EX stage. Operand
synchronous pipeline processor. D1 has forwarding is used in the pipelined
5 pipeline stages with execution times of processor. What is the number of clock
3 nsec, 2 nsec, 4 nsec, 2 nsec and 3 nsec cycles taken to complete the following
while the design D2 has 8 pipeline stages sequence of instructions?
each with 2 nsec execution time. How ADD R2,R1,R0 R2←R1+R0
much time can be saved using design D2 MUL R4,R3,R2 R4←R3*R2
SUB R6,R5,R4 R6←R5 R4
over design D1 for executing 100
(A) 7 (C) 10
instructions? (B) 8 (D) 14
(A) 214 nsec (C) 86 nsec
(B) 202 nsec (D) 200 nsec CS - 2008
5. Which of the following are NOT true in a
CS – 2006 pipelined processor?
3. A CPU has five-stage pipeline and runs at 1. Bypassing can handle all RAW
1 GHz frequency. Instruction fetch hazards.
happens in the first stage of the pipeline. 2. Register renaming can eliminate all
A conditional branch instruction register carried WAR hazards.
computes the target address and 3. Control hazard penalties can be
evaluates the condition in the third stage eliminated by dynamic branch
of the pipeline. The processor stops prediction

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 247
GATE QUESTION BANK Computer Organization

(A) 1 and 2 only What is the number of cycles needed to


(B) 1 and 3 only execute the following loop?
(C) 2 and 3 only for (i=1 to 2) {I1; I2; I3; I4 ;}
(D) 1,2 and 3 (A) 16 (C) 28
(B) 23 (D) 30
Linked Answer Questions Q.6& Q. 7
Delayed branching can help in the CS - 2010
handling of control hazards 9. A 5-stage pipelined processor has
6. For all delayed conditional branch Instruction Fetch (IF), Instruction
instructions, irrespective of whether Decode (ID), Operand Fetch (OF),
the condition evaluates to true or false, Perform Operation (PO) and Write
(A) The instruction following the Operand (WO) stages. The IF, ID, OF and
conditional branch instruction in WO stages take 1 clock cycle each for any
memory is executed instruction. The PO stage takes 1 clock
(B) The first instruction in the fall cycle for ADD and SUB instructions, 3
through path is executed clock cycles for MUL instruction, and 6
(C) The first instruction in the taken clock cycles for DIV instruction
path is executed respectively. Operand forwarding is used
(D) The branch takes longer to execute in the pipeline. What is the number of
than any other instruction clock cycles needed to execute the
following sequence of instructions?
7. The following code is to run on a Instruction Meaning of instruction
pipelined processor with one branch : MUL R , R , R R ← R *R
delays slot : DIV R , R , R R ←R R
I1: ADD R2 ←R7 +R8 : ADD R , R , R R ← R +R
I2: SUB R4 ←R5 R6 : SUB R , R , R R ←R R
I3: ADD R1 ←R2 + R3 (A) 13 (C) 17
I4: STORE Memory [R4] ←R 1 (B) 15 (D) 19
BRANCH to Label if R1 = = 0
CS - 2011
Which of the instruction I1, I2, I3 or I4
10. Consider an instruction pipeline with
can legitimately occupy the delay slot
four stages (S1, S2, S3 and S4) each with
without any other program
combinational circuit only. The pipeline
modification?
registers are required between each
(A) I1 (C) I3
stage and at the end of the last stage.
(B) I2 (D) I4
Delays for the stages and for the pipeline
CS - 2009 registers are as given in the figure
8. Consider a 4 stage pipeline processor.
The number of cycle needed by the four
instructions I1,I2,I3,I4 in stages S1, S2,
S3, S4 is shown below:
S1 S2 S3 S4
I1 2 1 1 1
I2 1 3 2 2
I3 2 1 1 3
I4 1 2 2 2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 248
GATE QUESTION BANK Computer Organization

Stage S1 Delay stage and the delay of each buffer is 1 ns.


5ns A program consisting of 12 instructions
I1,I2, I3,…., 12 is executed in this pipelined
Pipeline Register (Delay 1ns) processor. Instruction I4 is the only
branch instruction and its branch target
Stage S2 Delay is I9. If the branch is taken during the
6ns execution of this program , the time (in
ns) needed to complete the program is
Pipeline Register (Delay 1ns) (A) 132 (C) 176
(B) 165 (D) 328
Stage S3 Delay 11ns
CS – 2014
13. Consider a 6-stage instruction pipeline,
Pipeline Register (Delay 1ns) where all stages are perfectly balanced.
Assume that there is no cycle-time
Stage S4 Delay 8ns overhead of pipelining. When an
application is executing on this 6-stage
pipeline, the speedup achieved with
Pipeline Register (Delay 1ns)
respect to non-pipelined execution if
25% of the instructions incur 2 pipeline
What is the approximate speed up of the
stall cycles is ______________________.
pipeline in steady state under ideal
conditions when compared to the
14. Consider the following processors (ns
corresponding non-pipeline
stands for nanoseconds). Assume that
implementation?
the pipeline registers have zero latency.
(A) 4.0 (C) 1.1
P1: Four-stage pipeline with stage
(B) 2.5 (D) 3.0
latencies 1 ns, 2 ns, 2 ns, 1 ns.
P2: Four-stage pipeline with stage
CS - 2012
latencies 1 ns, 1.5 ns, 1.5 ns, 1.5 ns.
11. Register renaming is done in pipelined
P3: Five-stage pipeline with stage
processors
latencies 0.5 ns, 1 ns, 1 ns, 0.6 ns, 1 ns.
(A) as an alternative to register
P4: Five-stage pipeline with stage
allocation at compile time
latencies 0.5 ns, 0.5 ns, 1 ns, 1 ns, 1.1 ns.
(B) for efficient access to function
Which processor has the highest peak
parameters and local variables
clock frequency?
(C) to handle certain kinds of hazards
(A) P1 (C) P3
(D) as part of address translation
(B) P2 (D) P4
CS – 2013 15. An instruction pipeline has five stages,
12. Consider an instruction pipeline with namely, instruction fetch (IF),
five stages without any branch instruction decode and register fetch
prediction: Fetch Instruction (FI), (ID/RF), instruction execution (EX),
Decode Instruction (DI), Fetch Operand memory access (MEM), and register
(FO), Execute Instruction (EI) and Write write back (WB) with stage latencies
Operand (WO). The stage delays for FI, 1 ns, 2.2 ns, 2 ns, 1 ns, and 0.75 ns,
DI, FO, EI and WO are 5ns, 7ns, 10ns, 8ns respectively (ns stands for
and 6ns, respectively. There are nanoseconds). To gain in terms of
intermediate storage buffers after each
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 249
GATE QUESTION BANK Computer Organization

frequency, the designers have decided to of one in both the designs. The execution
split the ID/RF stage into three stages times of this program on the old and the
(ID, RF1, RF2) each of latency 2.2/3 ns. new design are P and Q nanoseconds,
Also, the EX stage is split into two stages respectively. The value of P/Q is
(EX1, EX2) each of latency 1 ns. The new __________.
design has a total of eight pipeline
stages. A program has 20% branch 16. Consider two processors P and P
instructions which execute in the EX executing the same instruction set.
stage and produce the next instruction Assume that under identical conditions,
pointer at the end of the EX stage in the for the same input, a program running
old design and at the end of the EX2 on P takes 25% less time but incurs
stage in the new design. The IF stage 20% more CPI (clock cycles per
stalls after fetching a branch instruction instruction) as compared to the program
until the next instruction pointer is running on P . If the clockfrequency of P
computed. All instructions other than the is 1GHz, then the clock frequency of P
branch instruction have an average CPI (in GHz) is _________.

Answers Keys and Explanations


1. [Ans. B] Total time
Clock cycles 80 20
10 ( 10 1+ 10 3)
1 2 3 4 5 6 7 8 9 10 100 100
I R E M W = + = 1.4 second
F D X A B
4. [Ans. B]
I R M W
Pipelined processor has four stages IF, ID,
F D A B
EX, WB
IF R E M W
Clock cycles Instruction
D X A B
1 ADD
So, it requires 10 clock cycles 1 SUB
3 MVL
2. [Ans. B] Consider the following diagram
Time required by design D1 Clock cycles 1 2 3 4 5 6 7 8

(100 + 5 1) × 4 = 416nsec R ←R +R IF ID EX WB
Time required by design D2 R ←R R IF ID EX EX EX WB
(100 + 8 1) × 2 = 214nsec IF ID EX WB
R ←R R
So time saved using design D2 =
416 – 214 = 202nsec So total required clock cycle is 8.

3. [Ans. C] 5. [Ans. D]
For 80% of 10 instructions a single cycle All statements 1, 2 and 3 are false for a
is sufficient as there is no conditional pipelined processor.
branch. For the rest 20%, one extra cycle
will be needed making the number of 6. [Ans. B]
cycles required to 3.
For all delayed conditional branch
Total time will be computed as below
instruction the first instruction in the fall
One cycle takes = 10
through path is executed and evaluates to
true of false.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 250
GATE QUESTION BANK Computer Organization

7. [Ans. B] 10. [Ans. B]


Instruction 2 occupy the delay slot No c o T
S
because data dependency of P c o T
instruction 4 Non pipeline Execution time
S1 + S2 + S3
8. [Ans. B] + S4
By showing cycle vs stage data for each 5 + 6 + 11 + 8 30
instruction, it can be seen that the loop P c o
takes 23 cycles. M ( )+
M (5 , 6 , 11 , 8 ) + 1
9. [Ans. B] 11 + 1
IF ID OF PO WO 12
MUL 1 1 1 3 1 c 30 12
V 1 1 1 6 1 2.5
A 1 1 1 1 1
SU 1 1 1 1 1
11. [Ans. C]
Register renaming is used to handle data
WO
15

hazards.
OW

PO
14

12. [Ans. B]
Given: Five stage instruction pipeline
WO

PO
13

delays for FI, DI, FO, EI and WO are


5,7,10,8,6ns resp.
PO

PO

PO
12

To find: since the maximum time taken by


PO

PO

PO
11

any stage is 10ns and additional 1 ns is


required for delay of buffer
PO

PO
10

Therefore total time for an instruction to


PO

PO

PO

pass from one stage to another is 11ns


9

Now instructions are executed as follows


PO

PO

PO

, , , , , , ,
8


WO

PO

c o
O
7

Now when I4 is in its execution stage we


PO

PO

PO

PO

detect the branch and when I4 is in WO


6

stage we fetch I9 so time for execution of


PO

PO

PO

PO
5

instructions from I1 to I4 is
PO

= 11 5 + (4 1) 11 =88 ns
O
4

And time for execution of instructions


O
3

from I9 to I12 is
= 11 5 + (4 1) 11 = 88 ns
2

But we have 11ns when fetching of 55 ns


because time for fetching I9 can be
1

overlap with WO of I4
Hence total times is
No. of cycles required = 15 cycles. = 88 +88 11 = 165 ns

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 251
GATE QUESTION BANK Computer Organization

13. [Ans. 4] Q [80 (1c oc )


S
S 1
1+( ) + 20 (
c c c o co
6 5
+ )] T
c oc
1 + (2 ) P (0.8 + 0.12) 1 2
6 6 6 P 3.08
2 4 So o 1.54
1+ 3 2 3 Q 2

16. [Ans. 1.6]


14. [Ans. C]
Support n = 100 tasks. So time required 1 cycle time P 1
for processing 100 tasks in processors: Assume P takes 5 cycles for a program
T ( + 1) (100 + 4 1)2 then P taken 20% more, means 6 cycles.
206 P Takes 25% less time, means, if P takes
T ( + 1) (100 + 4 1)1.5 5 n.s, then P takes 3.75 ns.
154.6 Assume P clock frequency is x GHz.
T ( + 1) (100 + 5 1)1 P T 6c c ,
104 6 10
o 3.75, 1.6
T ( + 1) (100 + 5 1)1.1
114.4
Best time = 104
[Here k = no.of stages,
c oc c c ]

15. [Ans. *] Range 1.50 to 1.60


Old New
design design
No. of 5 8
stages
Stall 2 5
cycle
Stall 20% 20%
frequency
Clock 2.2 ns 1 ns
period
Avg. access P Q
time
P [80 (1c oc )
1
+ 20 (
co o
2
+ )] T
c oc
P (0.8 + 0.6) 2.2 3.08

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 252
GATE QUESTION BANK Computer Organization

Instruction Types
CS – 2005 Common Data Questions Q.3 & Q.4
1. Consider a three word machine Consider the following data path of a CPU.
instruction “ADD A[ ], @B” MAR MD
R
The first operand (destin tion) A [ ]
uses indexed addressing mode with R0 as
the index register. The second operand S T
(source) “@B” uses indirect ddressing IR PC
mode. A and B are memory addresses GPRS
ALU
residing at the second and the third
words, respectively. The first word of the
The, ALU, the bus and all the registers in
instruction specifies the opcode, the index
the data path are of identical size. All
register designation and the source and
operations including incrementation of
destination addressing modes. During
the PC and the GPRs are to be carried out
execution of ADD instruction, the two
in the ALU. Two clock cycles are needed
operands are added and stored in the
for memory read operation – the first one
destination (first oper nd). The number
for loading address in the MAR and the
of memory cycles needed during the
next one for loading data from the
execution cycle of the instruction is
memory bus into the MDR.
(A) 3 (C) 5
(B) 4 (D) 6
3. The instruction “ dd , ” has the
register transfer interpretation
2. Match List I(high level language
R0 ⇐ R0 + R1. The minimum number of
statements) and List II(addressing modes)
clock cycles needed for execution cycle of
and pick the correct options .
this instruction is
List I List II
( high level language (addressing modes) (A) 2 (C) 4
statements) (B) 3 (D) 5
1. A [I] = B[J]; a. Indirect
addressing 4. The instruction “c ll n, sub” is two
2. while (* A ++); b. Indexed word instruction. Assuming that PC is
addressing incremented during the fetch cycle of the
3. int temp = *x; c. Auto increment first word of the instruction, its register
(A) (1,c), (2,b), (3,a) transfer interpretation is
(B) (1,a), (2,c), (3,b) Rn< = PC + 1;
(C) (1,b), (2,c), (3, a) PC < = M [PC];
(D) (1,a), (2,b), (3,c) The minimum number of CPU clock cycles
needed during the execution cycle of this
instruction is
(A) 2 (C) 4
(B) 3 (D) 5

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 253
GATE QUESTION BANK Computer Organization

CS - 2006 CS - 2007
5. Consider a new instruction named Common Data for Q.8 , Q.9 & Q10.
branch-on-bit-set (mnemonic bbs). The Consider the following program segment.
instruction “bbsreg, pos, l bel” jumps to Here R1, R2 and R3 are the general purpose
label if bit in position pos of register registers.
operand reg is one. A register is 32 bits Instruction Operation Instruction
wide and the bits are numbered 0 to 31, size
(no. of words)
bit in position 0 being the least
MOV R1,( ) R1 2
significant. Consider the following [ ]
emulation of this instruction on a LOOP:
processor that does not have bbs MOV R2, M[R3] R2 [ ] 1
implemented. ADD R2, R1 R2 1
temp reg and mask
Branch to label if temp is non-zero MOV ( ), M [R3] 1
INC R3 R3 R3 + 1 1
The variable temp is a temporary register.
DEC R1 R1 R1 – 1 1
For correct emulation,the variable mask
BNZ LOOP Branch on 2
must be generated by not zero
(A) mask 0 pos HALT `Stop 1
(B) mask 0 ffffffff>> pos Assume that the content of memory
(C) mask pos location 3000 is 10 and the content of the
(D) mask 0 f register R3 is 2000. The content of each of
the memory locations from2000 to 2010
6. The memory locations 1000, 1001 and is 100. The program is loaded from the
1020 have data values 18, 1 and 16 memory location 1000. All the numbers
respectively before the following program are in decimal.
is executed.
8. Assume that the memory is word
MOVI Rs, 1;Move immediate
addressable. The number of memory
LOAD Rd, 1000(Rs); Load from memory
references for accessing the data in
ADDI Rd, 1000;Add immediate
executing the program completely is
STOREI 0(Rd), 20;Store immediate
(A) 10 (C) 20
Which of the statements below is TRUE (B) 11 (D) 21
after the program is executed?
(A) Memory location 1000 has value 20 9. Assume that the memory is word
(B) Memory location 1020 has value 20 addressable. After the execution of this
(C) Memory location 1021 has value 20 program, the content of memory location
(D) Memory location 1001 has value 20 2010 is
(A) 100 (C) 102
7. Which of the following statements about (B) 101 (D) 110
relative addressing mode is FALSE?
(A) It enables reduced instruction size 10. Assume that the memory is byte
(B) It allows indexing of array elements addressable and the word size is 32 bits.
with same instruction If an interrupt occurs during the
(C) It enables easy relocation of data e ecution of the instruction “INC ”,
(D) It enables faster address calculations what return address will be pushed on to
than absolute addressing the stack?
(A) 1005 (C) 1024
(B) 1020 (D) 1040

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 254
GATE QUESTION BANK Computer Organization

11. Following table indicates the latencies (A) 1 only


of operations between the instruction (B) 2 only
producing the result and instruction (C) 3 only
using the result. (D) 2 and 3 only
Instruction Instruction Latency
13. Which of the following must be true for the
producing using the
RFE (Return From Exception)
the result result
instruction on a general purpose processor
ALU ALU 2
I. It must be a trap instruction
operation operation
II. It must be a privileged instruction
ALU Store 2 III. An exception cannot be allowed to
operation occur during execution of an RFE
Load ALU 1 instruction
operation (A) I only
Load Store 0 (B) II only
Consider the following code segment. (C) I and II only
Load R1, Loc1; Load R1 from memory (D) I , II and III only
location Loc1
14. The use of multiple register windows
Load R2, Loc2; Load R2 from memory
with overlap causes a reduction in the
location Loc2
number of memory accesses for
Add R1, R2, R1; Add R1 and R2 and save
1. function locals and parameters
result in R1 2. register saves and restores
Dec R2; Decrement R2 3. instruction fetches
Dec R1; Decrement R1 (A) 1 only
Mpy R1, R2, R3; Multiply R1 and R2 and (B) 2only
save result in R3 (C) 3 only
Store R3, Loc3; Store R3 in memory (D) 1,2 and 3
location Loc 3
What is the number of cycles needed to CS - 2010
execute the above code segment 15. The program below uses six temporary
assuming each instruction takes one variables a, b, c, d, e, f.
a=1
cycle to execute?
b = 10
(A) 7 (C) 13
c = 20
(B) 10 (D) 14
d= a+b
CS - 2008 e=c+d
12. Which of the following is/are true of the f=c+e
auto increment addressing mode? b=c+e
1. It is useful in creating self relocating e=b+f
code d=5+e
2. If it is included in an Instruction Set return d + f
Architecture, then an additional ALU Assuming that all operations take their
is required for effective address operands from registers, what is the
calculation minimum number of registers needed to
3. The amount of increment depends execute this program without spilling?
on the size of the data item accessed (A) 2 (C) 4
(B) 3 (D) 6
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 255
GATE QUESTION BANK Computer Organization

CS - 2011
16. Consider a hypothetical processor with an
instruction of type LW R1, 20(R2), which
during execution reads a 32-bit word
from memory and stores it in a 32-bit
register R1. The effective address of the
memory location is obtained by the
addition of a constant 20 and the contents
of register R2. Which of the following best
reflects the addressing mode
implemented by this instruction for the
operand in memory?
(A) Immediate Addressing
(B) Register Addressing
(C) Register Indirect Scaled Addressing
(D) Base Indexed Addressing

CS – 2013
17. Consider the following sequence of micro
– operations.
B C
A
C
emor B
Which one of the following is a possible
operation performed by this sequence?
(A) Instruction fetch
(B) Operand fetch
(C) Conditional branch
(D) Initiation of interrupt service

CS - 2014
18. A machine has a 32-bit architecture, with
1-word long instructions. It has 64
registers, each of which is 32 bits long. It
needs to support 45 instructions, which
have an immediate operand in addition to
two register operands. Assuming that the
immediate operand is an unsigned
integer, the maximum value of the
immediate operand is ____________.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 256
GATE QUESTION BANK Computer Organization

Answer Keys and Explanations


1. [Ans. D] 5. [Ans. A]
ADD A [ ], @B bbsreg,pos, label
A [ ] uses index addressing mode as temp reg and mark
follow such that as the index register Branch to label if temp is nonzero. If we
Regs [ ] Regs [ ] +Mem [Regs [B] shift one position left by pos of 0x1 then it
+Regs [ ]…….. ( ) evaluate the bbs instruction and
And @B uses indirect as follow mask 1<<pos
ADD A [ ], @B
Regs [ ] Regs [ ] + 6. [Ans. D]
Mem [Mem[(B)]]………….. ( ) Content of register as program will be
So the first instruction needed 3 memory execute are
cycles and the second needed 2 and one
memory cycles in needed for writing the = content of 1000
result into the memory. So, total 6 (1) = 1000 + 1 = 10001 memory address
memory cycles are needed to execute =1
ADD A [ ], @B = content of 1000 (1)
= 1000 + 1
2. [Ans. C] = 1001 memory address
A [I] = B[J] indexed, Add I. , 1000
While(*A++) Auto increment.
int temp = Indired Addressing mode store ( ), means store 20 in the
address value 1001
3. [Ans. B]
7. [Ans. B]
The sequence of microinstruction take It does not allow indexing of array
place in following cycles : element with same instruction.
I. Cycle : ,
II. Cycle : ,T 8. [Ans. D]
III. Cycle : ,T ,A , Given M[3000]=10
3 cycles will be required to execute. Instruction Required Memory
Reference
4. [Ans. B] [ ] 1
n C [ ]or [ ] 10
T
C ( C) [ ] 10
The sequence of microinstruction take Tot l
place in following cycles.
9. [Ans. A]
I cycle: C , , A
The register contain the memory
( A c n be lo ded with C ) location 2010 whose value is 100 at the
II cycle: ,A , in end of loop BNZ loop
III cycle: D , C ( D can be
performed once A has been 10. [Ans. C]
performed) Location Operation
c cles will be required to e ecute. 1000 [ ]
1004
1008 [ ]
1012
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 257
GATE QUESTION BANK Computer Organization

1016 [ ] R2 R3+R1 ………… (f c e)


1020 R3 R3+R1 ………… (b c e)
So if an interrupt occurs during the R2+R3 ………… (e b f)
execution of the instruction “INC 3” the R3 5+R1 ………… (d 5 e)
return address 1024 will be pushed onto return (R2+R3) ……… return (d + f)
the stack. Hence 3 registers needed only.
(Address of next instruction)
16. [Ans. D]
LW R1, 20(R2) Instruction shows the
11. [Ans. B]
source address can be formed by adding
All seven installations take 1 clock
the constant with the R2 content. It is the
cycles.
MIPS instruction. R2 points the base
But 1 clock cycle latency needed b/w address of an array and 20 points the
load index address of an array. Hence the
R2, Loc 2, and Add R1, R2,1 addressing mode used for the above is
lso, 2 clock cycles latency needed b/w based indexed Addressing mode. This
Mpy R1, R2, R1 and addressing mode is used to implement
store R3 ,Loc 3 the arrays
S𝑜, 7 + 1 + 2 = 10
17. [Ans. D]
12. [Ans. C] PC holds the value of next instruction to
The amount of increment depends on the be executed we store the value of PC to
size of data item accessed MBR and then to memory. We are saving
the value of PC in memory and new
13. [Ans. D] address value is loaded into PC.
A RFE (Return From Exception) This can be done only in interrupt service
instruction contains a trap instruction, option (D) is correct.
privileged instruction and an exception
c n’t be llowed to occur during the 18. [Ans. 16383]
execution of an REF instruction. Instruction format of 32 – bit
Opcode Reg Reg Immediate
14. [Ans. C] 1 2 operand
The use of multiple register windows 6 – bit 6– 6– 14 – bit
with overlap causes a reduction in the bit bit
number of memory accesses for the Opcode = 6 – bit
instruction fetches only. ( 5 intructions to support)
Reg 1, Reg 2 = 6 – bit
15. [Ans. B] ( no. of registers)
Register operations
So, Immediate operand bits
………… ( )
b ………… (b ) = 32 – (6 + 6 + 6) = 14
c ………… (c ) Max value to be represented by 14 bits
R1+R2 ………… (d b) is =
R3+R1 ………… (e c d)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 258
GATE QUESTION BANK Computer Organization

I/O Data Transfer

CS - 2005 mode over operating it under program


1. Which one of the following is true for a controlled mode?
CPU having a single interrupt request line (A) 15 (C) 35
and a single interrupt grant line? (B) 25 (D) 45
(A) Neither vectored interrupt nor
multiple interrupting devices are 4. A hardwired CPU uses 10 control signals
possible S1 to S10 in various time steps T1 to T5 to
(B) Vectored interrupts are not possible implement 4 instructions I1 to I4 as
but multiple interrupting devices are shown below.
possible I1 I2 I3 I4
(C) Vectored interrupts and multiple S1, S3, S1, S3, S1, S3, S1, S3,
interrupting devices are both T1 S5 S5 S5 S5
possible S2, S4, S8, S9, S7, S8, S2, S6,
(D) Vectored interrupt is possible but T2 S6 S10 S10 S7
multiple interrupting devices are not S5, S6, S2, S6, S5,
possible T3 S1, S7 S7 S9 S10
T4 S10 S6 S10 S6, S9
2. Normally user programs are prevented
T5 S3, S8 S10 S1, S3 S10
from handling I/O directly by I/O
Which of the following pairs of
instructions in them. For CPUs having
expressions represent the circuit for
explicit I/O instructions, such I/O
generating control signals S5 and S10
protection is ensured by having the I/O
respectively. [Ij + Ik] Tn indicates that the
instructions privileged. In a CPU with
control signal should be generated in time
memory mapped I/O, there is no explicit
step Tn if the instruction being executed
I/O instruction. Which one of the
is Ij or Ik ?
following is true for a CPU with memory
(A) S5 = T1 + I2. T3 &
mapped I/O?
(A) I/O protection is ensured by S10 = (I1 + I3). T4 + (I2 + I4). T5
(B) S5 = T1 + (I2 + I4). T3 &
operating system routine( )
S10 = (I1 + I3). T4 + (I2 + I4). T5
(B) I/O protection is ensured by a
(C) S5 = T1 + (I2 + I4). T3 &
hardware trap
S10 = (I2 + I3 + I4). T2 +
(C) I/O protection is ensured during
(I1 + I3).T4 + (I2+ I4). T5
system configuration
(D) S5 = T1 + (I2 + I4). T3 &
(D) I/O protection is not possible
S10 = (I2 + I3). T2 + I4. T3 +
(I1 + I3).T4 + (I2 + I4). T5
3. A device with data transfer rate
10 KB/sec is connected to a CPU. Data is
5. An instruction set of a processor has 125
transferred byte-wise. Let the interrupt
signals which can be divided into 5
overhead be 4 μsec. The byte transfer
groups of mutually exclusive signals as
time between the device interface register
follows:
and CPU or memory is negligible. What is
Group 1: 20 signals, Group 2: 70 signals,
the minimum performance gain of
Group 3: 2 signals, Group 4: 10 signals,
operating the device under interrupt
Group 5: 23 signals.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 259
GATE QUESTION BANK Computer Organization

How many bits of the control words can read 1 MB contiguous data starting from
be saved by using vertical micro- the sector 4 of the outer-most track?
programming over horizontal (A) 13.5 ms (C) 9.5 ms
microprogramming? (B) 10 ms (D) 20 ms
(A) 0 (C) 22
CS - 2007
(B) 103 (D) 55
9. Consider a disk pack with 16 surfaces,
6. Consider a disk drive with the following 128 tracks per surface and 256 sectors
specifications: per track. 512 bytes of data are stored in a
16 surfaces, 512 tracks/surface, bit serial manner in a sector. The capacity
512 sectors/track, 1 KB/sector, rotation of the disk pack and the number of bits
speed 3000 rpm. The disk is operated in required to specify a particular sector in
cycle stealing mode whereby whenever the disk are respectively
one 4 byte word is ready it is sent to (A) 256 Mbyte, 19 bits
memory; smilarly, for writing, the disk (B) 256 Mbyte, 28 bits
interface reads 4-byte word from the (C) 512 Mbyte, 20 bits
memory in each DMA cycle. Memory cycle (D) 64 Gbyte, 28 bits
time is 40 nsec. The maximum percentage
CS - 2008
of time that the CPU gets blocked during
10. Which of the following statements about
DMA operation is
synchronous and asynchronous I/O is
(A) 10 (C) 40
NOT true?
(B) 25 (D) 50
(A) An ISR is invoked on completion of
Statement for Linked Answer Questions 7 I/O in synchronous I/O but not in
and 8 asynchronous I/O
A disk has 8 equidistant tracks. The (B) In both synchronous and
diameters of the innermost and asynchronous I/O an ISR ( Interrupt
outermost tracks are 1cm and 8 cm Service Routine) is invoked after
respectively. The innermost track has a completion of the I/O
storage capacity of 10MB. (C) A process making a synchronous I/O
7. What is the total amount of data that can call waits until I/O is complete, but a
be stored on the disk if it is used with a process making an asynchronous I/O
drive that rotates it with call does not wait for completion of
(i) Constant Linear Velocity the I/O
(ii) Constant Angular Velocity? (D) In the case of synchronous I/O, the
(A) (i) 80 MB (ii) 2040 MB process waiting for the completion of
(B) (i) 2040 MB (ii) 80 MB I/O is woken up by the ISR that is
(C) (i) 80 MB (ii) 360 MB invoked after the completion of I/O
(D) (i) 360 MB (ii) 80 MB
CS - 2009
11. A CPU generally handles an interrupt by
8. If the disk has 20 sectors per track and is
executing an interrupt service routine
currently at the end of the 5th sector of the
(A) as soon as an interrupt is raised
inner-most track and the head can move
(B) by checking the interrupt register at
at a speed of 10 meters/sec and it is
the end of fetch cycle
rotating at constant angular velocity of
6000 RPM, how much time will it take to

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 260
GATE QUESTION BANK Computer Organization

(C) by checking the interrupt register instruction. The load-store instructions


after finishing the execution of the take two clock cycles to execute.
current instruction The designer of the system also has an
(D) by checking the interrupt register at alternate approach of using the DMA
fixed time intervals controller to implement the same
transfer. The DMA controller requires 20
CS – 2011 clock cycles for initialization and other
12. A computer handles several interrupt overheads. Each DMA transfer cycle takes
sources of which of the following are two clock cycles to transfer one byte of
relevant for this question. data from the device to the memory.
• Interrupt from CPU temperature What is the approximate speedup when
sensor (raises interrupt if CPU the DMA controller based design is used
temperature is too high) in place of the interrupt driven program
• Interrupt from Mouse (raises based input-output?
interrupt if the mouse is moved or a (A) 3.4 (C) 5.1
button is pressed) (B) 4.4 (D) 6.7
• Interrupt from Keyboard (raises
interrupt when a key is pressed or 14. An application loads 100 libraries at
released) startup. Loading each library requires
• Interrupt from Hard Disk (raises exactly one disk access. The seek time of
interrupt when a disk read is the disk to a random location is given as
completed) 10 ms. Rotational speed of disk is
Which one of these will be handled at the 6000 rpm. If all 100 libraries are loaded
HIGHEST priority? from random locations on the disk, how
(A) Interrupt from Hard Disk long does it take to load all libraries? (The
(B) Interrupt from Mouse time to transfer data from the disk block
(C) Interrupt from Keyboard once the head has been positioned at the
(D) Interrupt from CPU temperature start of the block may be neglected.)
sensor (A) 0.50 s (C) 1.25 s
(B) 1.50 s (D) 1.00 s
13. On a non-pipelined sequential processor,
a program segment, which is a part of the CS - 2012
interrupt service routine, is given to 15. The amount of ROM needed to implement
transfer 500 bytes from an I/O device to a 4 bit multiplier is
memory. (A) 64 bits (C) 1 kbits
Initialize the address register (B) 128 bits (D) 2 kbits
Initialize the count to 500
LOOP: Load a byte from device CS - 2013
Store in memory at address given 16. Consider a hard disk with 16 recording
by address register surfaces (0 15) having 16384 cylinders
Increment the address register (0 – 16383) and each cylinder contains
Decrement the count 64 sectors (0-63). Data storage capacity
If count! = 0 go to LOOP in each sector is 512 bytes. Data is
Assume that each statement in this organized cylinder-wise and the
program is equivalent to a machine addressing format is <cylinder no.,
instruction which takes one clock cycle to surface no, sector no>. A file of size
execute if it is a non-load/store 42797 KB is stored in the disk and the
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 261
GATE QUESTION BANK Computer Organization

starting disk location of the file is <1200,


9, 40>. What is the cylinder number of
the last sector of the file, if it is stored in a
contiguous manner?
(A) 1281 (C) 1283
(B) 1282 (D) 1284

Answer Keys and Explanations

1. [Ans. B] So, total no of bits required for vertical


Vectored interrupts are not possible but microprogramming = 22 bits
multiple interrupting devices are With horizontal approach = 125 bits
possible. So, no. of bits saved = 125 – 22 =103 bits

2. [Ans. A] 6. [Ans. B]
Memory mapped I/O requires that Time takes for 1 rotation
memory locations and I/O ports share the = 60 sec = 3000 rotations
same set of addresses, so address bit 60/3000 sec= 1 rotation
pattern that is assign to memory cannot In 1 rotation it reads –
also be assigned to an I/O port and vice- 1/50 sec
versa. I/O protection in this approach in ? = 4 bytes
ensured by operating system macros and Time it takes to read 4 bytes = 153 ns
routines. % of time CPU gets blocked

3. [Ans. B]
Data transfer rate = 10KB/sec
Total transfer = 25 7. [Ans. D]
Data transfer rate = For Constant Linear Velocity, density of
So perform gain = 25 % bits per track will increase as the head
moves towards outside of the disk.
4. [Ans. D]
So the disk capacity
Notice here that S5 have to be activated
= 10 + 20 + 30 + 40 + 50 + 60 + 70 +80
on T1 for all instructions and for I2 and I3
=360MB
on T3.
For Constant Angular Velocity, density of
S10 have to be activated
bits per track is uniform.
for I2 and I4 on T5
So the disk capacity = 10 × 8 = 80MB
for I1 and I3 on T4
for I4 on T3 8. [Ans. A]
for I2 and I3 on T2 To move from 1st sector to 8th sector, the
distance covered by head
5. [Ans. B] =(8 1)/2=3.5cm
As head can move at 10m/s, the above
movement will take 3.5ms
After this movement head arrives at the
end of 5th sector. So to read 1MB data
from starting of 4th sector to ending of

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 262
GATE QUESTION BANK Computer Organization

5th sector, the head needs to take entire 14. [Ans. B]


one rotation. As head can rotate at Time for one library
6000RPM, one rotation will take 10ms Rotational latency ½ resolution time
Total time = 3.5 + 10 = 13.5ms
6000 rpm = 10 ms, ½ revolution = 5ms
9. [Ans. A] 100(10ms+5ms)= 100 15ms
No. of surfaces = 16 = 1500 ms = 1.5 sec.
No. of track/sectors = 128
No. of sector/tracks = 256 15. [Ans. D]
Total size of disk
= 16 bytes
= 256 MB =2 k bits
Total no. of sectors in the disk
= 16 bytes 16. [Ans. D]
= bytes.
So, 19 bits are needed.

10. [Ans. B]
Statement (B) is not true because an ISR
(Interrupt Service Routine) is invoked on
before completion of I/O in synchronous
as well as in asynchronous I/O.

11. [Ans. C]
By checking interrupt register after
finishing the execution of the current
instruction.

12. [Ans. D]
Higher priority interrupt levels are When head is moving then it is reading
assigned to requests which, if delayed or data from all 16 surfaces simultaneously.
interrupted, could have serious Currently head is on 9th surface, sector no.
consequences. Interrupt from CPU 40.
temperature sensor would have serious Data it read from 9th surface
consequences if ignored. So it has the
highest priority. Data it read from surface 10th to 15th

13. [Ans. A] Data it read from cylinder 1201 to 1283


Non pipelined system require
= (2+2+1+1+1) Total data read from 1200th to 1283th
cylinder
DMA clock need = 20 + 2 500 12288 + 163840 + 42991616
= 1020 cycles =13167744 bytes = 42156 KB
Speed up = 3500/1020= 3.43 But we need to read 42797 KB. So we
need to go 1284th cylinder.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 263
GATE QUESTION BANK Digital Logic

Number Systems & Code Conversions


CS – 2005 CS -2006
1. The range of integers that can be 6. Consider numbers represented in 4-bit
represented by an n bit 2’s complement gray code. Let h h h h be the gray code
number system is representation of a number n and let
(A) 2 to ( 2 –1) g g g g be the gray code of
(B) 2 1 ) to (2 – 1) (n + 1) (modulo 16) value of the number.
(C) 2 to 2 Which one of the following functions is
(D) 2 + 1 ) to (2 ) correct?
(A) g h h h h )
2. The hexadecimal representation of 657 = Σ , 2, 3, 6, 0, 3, 4, 5)
is (B) g h h h h )
(A) 1AF (C) D71 = Σ(4, 9, 10, 11, 12, 13, 14,15)
(B) D78 (D) 32F (C) g h h h h )
= Σ 2, 4, 5, 6, 7, 2, 3, 5)
Linked Answer Questions for Q 3 & Q 4 (D) g h h h h )
Consider the following floating point = Σ 0, , 6, 7, 0, , 2, 3)
format
15 14 8 7 0 7. The addition of 4-bit, two’s complement,
binary numbers 1101 and 0100 results in
(A) 0001 and an overflow
Sign bit Excess – 64 Mantissa (B) 1001 and no overflow
Exponent
(C) 0001 and no overflow
Mantissa is a pure fraction is sign – (D) 1001 and an overflow
magnitude form.
CS - 2007
3. The decimal number 0.239 2 has the 8. (C012.25)H (10111001110.101)B =
following hexadecimal representation (A) (135103.412)8 (C) (564411.205)8
(without normalization and rounding off): (B) (564411.412)8 (D) (135103.205)8
(A) 0D 24 (C) 4D 0D
(B) 0D 4D (D) 4D 3D CS - 2008
9. In the IEEE floating point representation
4. The normalized representation for the the hexadecimal value 0x00000000
above format is specified as follows. The corresponds to
mantissa has an implicit 1 preceding the (A) The normalized value 2
binary radix) point. Assume that only 0’s (B) The normalized value 2
are padded in while shifting a field. The (C) The normalized value + 0
normalized representation of the above (D) The special value + 0
number (0.239 2 ) is:
(A) 0A 20 (C) 4D D0 10. Let ‘r’ denote number system radix. The
(B) 11 34 (D) 4A E8 only value s) of ‘r’ that satisfy the
equation √ 2 = is/are
5. (34.4)8 (23.4)8 evaluates to (A) decimal 10
(A) (1053.6)8 (C) (1024.2)8 (B) decimal 11
(B) (1053.2)8 (D) None of these
(C) decimal 10 and 11
(D) any value > 2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 264
GATE QUESTION BANK Digital Logic

11. The following bit pattern represents a biased exponent and 23 bits for mantissa.
floating point number in IEEE 754 single A float type variable X is assigned the
precision format decimal value of 4.25. The
1 10000011 representation of X in hexadecimal
10100000000000000000000 notation is
The value of the number in decimal form (A) C1640000H (C) 41640000H
is (B) 416C0000H (D) C16C0000H
(A) 10
(B) 13
(C) 26
(D) None of the above

CS - 2009
12. (1217) is equivalent to
(A) (1217) (C) (2297)
(B) (028F) (D) (0B17)

CS - 2010
13. P is a 16-bit signed integer. The 2’s
complement representation of P is
87 ) . The 2’s complement
representation of 8*P is
(A) 3 8) (C) 878)
(B) 87 ) (D) 987 )

CS - 2013
14. The smallest integer that can be
represented by an 8- bit number in 2’s
complement form is
(A) 256 (C) 127
(B) 128 (D) 0

CS - 2014
15. The base (or radix) of the number system
such that the following equation holds is
________
3 2
= 3.
20

16. Consider the equation 23) = x8)


with x and y as unknown. The number of
possible solutions is _____________.

17. The value of a float type variable is


represented using the single-precision
32-bit floating point format of IEEE-754
standard that uses 1 bit for sign, 8 bits for

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 265
GATE QUESTION BANK Digital Logic

Answer Keys and Explanations


1. [Ans. A] Representation biased exponent 74 in
2’s complement of a number represents binary
the negative number. If a number is n-bit 74) = 00 0 0)
long the most significant digit is a sign bit Floating point representation of number
so starting from 2 because only n – 1 is as follows:
place and addition of 1 and LSB we Sign Exponent Mantissa
represent the magnitude. 0 1001010 1101000
So the range is 2 to (2 )
0100 1010 1110 1000
including 0.

2. [Ans. A] 4 A E 8
657) = 0 0 ) = 4A 8)
000 0 0 )
= 5. [Ans. A]
A
657) = A ) 34.4) 23.4) = 053.6)

6. [Ans. C]
3. [Ans. D]
Let b , b , b , b are binary and
The decimal number is 0.239 2
h , h , h , h , g , g , g , g as discussed in
We have to find hexadecimal
Question then
representation without normalization.
b b b b h h h h g g g g
Biased exponent = 13 + 64 = 77
0 0 0 0 0 0 0 0 0 0 0 1
Representing 77 in binary 0 0 0 1 0 0 0 1 0 0 1 1
77) = 00 0 ) 0 0 1 0 0 0 1 1 0 0 1 0
Representing mantissa in binary 0 0 1 1 0 0 1 0 0 1 1 0
0.239) = 0.00 0 000 0 0 1 0 0 0 1 1 0 0 1 1 1
Floating point representation is an 0 1 0 1 0 1 1 1 0 1 0 1
follows: 0 1 1 0 0 1 0 1 0 1 0 0
0 1 1 1 0 1 0 0 1 1 0 0
Sign Exponent Mantissa
1 0 0 0 1 1 0 0 1 1 0 1
0 1001101 00111101 1 0 0 1 1 1 0 1 1 1 1 1
0100 1101 0011 1101 1 0 1 0 1 1 1 1 1 1 1 0
1 0 1 1 1 1 1 0 1 0 1 0
1 1 0 0 1 0 1 0 1 0 1 1
4 D 3 D 1 1 0 1 1 0 1 1 1 0 0 1
= 4 3 ) 1 1 1 0 1 0 0 1 1 0 0 0
1 1 1 1 1 0 0 0 0 0 0 0
4. [Ans. D] Now clearly g is high at position 0, so
The decimal number is 0.239 2 option (A) is wrong, also g is high at
We have to find hexadecimal position 1, so option (B) is also wrong, for
representation with normalization. g h , h , h , h )g is high at
Binary representation of 0.239 is g h , h , h , h ) = Σm 2,6,7,5,4, 2, 3, 5)
0.00111101000101 g h , h , h , h ) = Σm 2,4,5,6,7, 2, 3, 5)
is 0.00 0 000 0 ) 2 Hence option (C) is correct answer.
After normalization we have
1.11101000101 × 2
Then, biased exponent = 10 + 64 = 74

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 266
GATE QUESTION BANK Digital Logic

7. [Ans. C] 0
Overflow condition is check with the 0
expression x yz yxz where x is MSB of 0
first number, y is MSB of second and z is 0
0
MSB of output (all in same size, 4 bit
0
here) 0
Here x =1 0
y=0& 0
z=0 0
So x yz xyz = 0 0
0
So no overflow will be there.
Checking options.
8. [Ans. A] (a) 10
0 2.2 5) = 400 22. 2) Sign = 1
0 0 00 0. 0 ) = 2 7 6 .5 ) 0) = 0 0 = .0 0 2
40022. 2) 27 6.5) The exponent is biased by 2 ,
= 35 03.4 2) where ‘e’ is the number of bits used
for the exponent field which is 8.
9. [Ans. D] 2 = 27
Hexadecimal value 0x00000000 in binary For the 32 bit IEEE 754 format, the
bias is + 127 and so 3 + 127 = 130.
0 0 0 0 0 0 0 0
In binary (130) is encoded as 1 0 0
0 0 0 0 0 0 0 0 00010.
0 0 0 0 0 0 0 0 Thus, it is not equal to exponent field.
(b) 13
0 0 0 0 0 0 0 0
Sign = 1
3) = 1101 = 1.101 × 2
10. [Ans. D] 3 27 = 30
√ 2 = ) √ r 2r )= r ) Hence 30) = 00000 0 exponent
r 2r ) = r ) (c) 26
r 2r =r 2r 26) = 0 0 = . 0 0 2
Given equation will satisfy for every vale 27 4 = 3 and 3 )
of r, however with radix r = 2 we cannot = 00000
have sign 2 in it. So answer is r > 2. But fraction part does not match

11. [Ans. D] 12. [Ans. B]


sign Exponent Fraction 2 7) = 028 )
1 1 1 (1 2 1 7)8
0 0
0 1
0 0 001 010 001 111
0 0
0 0 2 8 F
1 0
1 0
0 13. [Ans. A]
0
2’s complement of P is given as 87 )
0
0 2’s complement of 8 P = 2 87 )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 267
GATE QUESTION BANK Digital Logic

Left shift by 3 bits = 3 8) So binary representation is


87 ) = 000 0 0 1100 C
00 00 0 000 0001 1
0110 6
3 8)
0100 4
0000 0
14. [Ans. B]
Range of 2’s complement number is for n 0000 0
bit is from 2 ) to 2 ) so 0000 0
smallest number is 2 = 2 = 28 0000 0

15. [Ans. 5]
Given
3 2)
= 3. )
20)
3r r 2
=r 3
2r r
3
r =r 3
2 2 r r
r 5
=
2 2
r=5

16. [Ans. 3]
Given 23) = x 8)
5 2 5 3 5 ) = x y 8)
38 = xy 8
xy = 30
So possible combination of (x, y) are
(1, 30); (2, 15); (3, 10); (5, 6); (6, 5);
(10, 3); (15, 2); (30, 1)
However 8 is a symbol in base y, so y
must be > 8. So that means only three
combination of (x, y) are only possible.

17. [Ans. A]
4.25
Sign bit = 1
4.25
= .78 25
2
So exponent = 3 + 127 (biased)
= 30)
= 00000 0)
antissa = 0.78 25 = 00

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 268
GATE QUESTION BANK Digital Logic

Boolean Algebra & Karnaugh Maps

CS – 2005 (A) f (x1, x2 …. xn) = x f (x1, x2 …. xn) +


1. The switching expression corresponding x1f (x1, x2 ….. xn)
to f(A,B,C,D) = (1,4,5,9,11,12) is (B) f (x1, x2 …. xn) = x2f (x1, x2 …. xn) +
(A) B + D+ A D x f (x1, x2 ….. xn)
(B) AB +ACD+ D (C) f (x1, x2 …. xn) = x f (x1, x2 …. 0) +
(C) AC + B + A xn f (x1, x2 ….. 1)
(D) BD+ AC +BC (D) f (x1, x2 …. xn) = f (0, x2 …. xn) +
f (1,x2 ….. xn)
2. A line L in a circuit is said to have a stuck
at 0 fault if the line permanently has a 5. The Boolean function for a
logic value 0. Similarly a line L in a circuit combinational circuit with four inputs is
is said to have a stuck – at - 1 fault if the represented by the following Karnaugh
line permanently has a logic value 1. A map.
circuit is said to have a multiple stuck-at PQ
fault if one or more lines have stuck at RS 00 01 11 10
faults. The total number of distinct
00 1 0 0 1
multiple stuck - at faults possible in a
circuit with N lines is 01 0 0 1 1
(A) 3N (C) 2N 1
(B) 3N 1 (D) 2N 11 1 1 1 0

CS - 2006 10 1 0 0 1
3. Consider a Boolean function f(w, x, y, z).
Which of the product terms given below
Suppose that exactly one of its inputs is
is an essential prime implicant of the
allowed to change at a time. If the
function?
function happens to be true for two
(A) QRS (C)
input vectors i w x y z
(B) PQS (D)
n i w x y z w would like
the function to remain true as the input CS - 2007
changes from i to i i n i differ in 6. What is the maximum number of
exactly one bit position), without different Boolean functions involving n
becoming false momentarily. Let Boolean variables?
f(w, x, y, z,) = (5, 7, 11, 12, 13, 15). (A) n (C) 2
Which of the following cube covers of (B) 2 (D) 2
f will ensure that the required property
is satisfied? 7. Consider the following Boolean function
(A) w ̅ x z w x y̅ x y̅z x y z w y z of four variables
(B) w x y , w ̅ xz wyz f w x y z) 1 3 4 6 9 11 12 14)
(C) w x ̅̅̅̅,
y z x z, w x̅ y z The function is
(D) w z y, w y z, w ̅ x z x y̅ z x y z (A) Independent of one variable
(B) Independent of two variables
4. Given a Boolean function f (x1, x2 ….. xn),
(C) Independent of three variables
which of the following equation is NOT
(D) Dependent on all the variables
true

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 269
GATE QUESTION BANK Digital Logic

8. Let f(w, x y z) 0 4 5 7 8 9 13 15). )


Which of the following expressions are NOT
equivalent to f? ̅̅ ̅ c̅
(P) x y z + w x y + w y z + x z
(Q) w y z + w x y + x z ̅̅
(R) w y z + w x y + x y z + x y z
̅
(S) x y z + w x y + w y
(A) P only (C) R and S
(B) Q and S (D) S only
̅
9. Define the connective * for the Boolean )
variable X and Y as: X* Y = X Y +
Let Z = X * Y. ̅̅ ̅ c̅
Consider the following expression P, Q
and R. ̅̅
P: X = Y * Z Q:Y=X*Z
̅
R: X * Y * Z = 1
Which of the following is TRUE?
(A) Only P and Q are valid
̅
(B) Only Q and R are valid
)
(C) Only P and R are valid
(D) All P, Q, R are valid
̅̅ ̅ c̅

Statement for Linked Answer Questions ̅̅


10 and 11.
̅
Consider the expression
+ +
10. Which of the following Karnaugh Maps
̅
correctly represents the expression?
)
11. Which of the following expressions does
̅̅ ̅ c̅ not correspond to the Karnaugh Map
obtained in Q.10?
̅̅ (A) ̅ ̅ + a ̅ + ab̅+ ̅ ̅d
(B) ̅ ̅ + ̅ ̅ + ̅ + ̅d
̅
(C) ̅ ̅ + ̅ + ̅ + ̅d
(D) ̅ ̅ ̅ + ̅+̅̅+ ̅

̅ CS - 2008
12. In the Karnaugh map shown below, X
denotes on’t r t rm. Wh t is th
minimal form of the function
represented by the Karnaugh map

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 270
GATE QUESTION BANK Digital Logic

ab CS – 2010
cd 00 01 11 10 16. The minterm expansion of
00 1 1 1 f (P, Q, R) = PQ + Q̅ + P̅ is
(A) m + m + m + m
X (B) m + m + m + m
01
(C) m + m + m + m
X
11 (D) m + m + m + m

10 1 1 X
CS - 2011
̅. ̅ + 17. The simplified SOP (Sum Of Product)
(A) ̅. ̅
form of the Boolean expression
(B) ̅. ̅ + ̅ . ̅ + ̅. . ̅
(P+ ̅ + ̅).(P+ ̅ +R). (P+Q+̅)
(C) ̅. ̅ + ̅. . ̅ (A) (̅. + ̅) (C) (̅. + )
(D) ̅. ̅ + ̅ . ̅ + ̅. ̅
(B) (P+ ̅ . ̅) (D) (P.Q+R)

13. Given f f and f in canonical sum of CS - 2012


products form (in decimal) for the 18. The truth table
circuit X Y f(X, Y)
f1 0 0 0
f2 f 0 1 0
1 0 1
1 1 1
represents the Boolean function
f3 (A) X (C)
f m 45678) (B) X + Y (D) Y
f m 1 6 15)
f m 1 6 8 15) CS - 2013
Then f is 19. Which one the following expressions
(A) m 4 6) (C) m 6 8) does NOT represent exclusive NOR of
(B) m 4 8) (D) m 4 6 8) x and y ?
(A) xy + x y (C) x y
14. P, Q, R are Boolean variables, then (B) x y (D) x y
(P + ̅ ) (P. ̅ + P.R) (̅. ̅ + ̅ ) simplifies to
(A) P. ̅ (C) P. ̅ + R CS - 2014
(B) P. ̅ (D) P. ̅ + Q 20. Consider the following Boolean
expression for F:
15. Consider the following Boolean function F(P, Q, R, S) = PQ + +
of four variables The minimal sum-of-products form of F is
f(A, B, C, D) = (2, 3, 6, 7, 8, 9, 10, 11, 12, 13) (A) PQ + QR + QS (C) + + +
The function is (B) P + Q + R + S (D) + +
(A) Independent of one variable
(B) Independent of two variables 21. The dual of a Boolean function
(C) Independent of three variables x x … . x + . ) written as is
(D) Dependent on all the variables the same expression as that of F with +
and swapped. F is said to be self – dual if
. The number of self – dual
function with n Boolean variables is

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 271
GATE QUESTION BANK Digital Logic

(A) 2 (C) 2 23. L t not th Ex lusiv O O )


(B) 2 (D) 2 op r tion. L t ‘1’ n ‘0’ not th
binary constants. Consider the following
22. Consider the following minterm Boolean expression for F over two
expression for F: variables P and Q:
) 0 2 5 7 8 10 13 15 )
Th mint rms 2 7 8 n 13 r ‘ o not ( 1 ) )) ) 0))
r ’ t rms. Th minim l sum – of – The equivalent expression for F is
products for F is (A) P + Q (C) P Q
(A) + (B) + (D)
(B) +
(C) + + +
(D) + + +

Answer Keys and Explanations

1. [Ans. A] wxz 0101 (5)


f(A, B, C, D) = (1, 4, 5, 9, 11, 12) wxy 1100 12)
The K – map for f is xyz 0101 5)
CD xyz 0111 7)
AB 00 01 11 10 wyz 1011 11)
00
1
4. [Ans. D]
01 1 A is true statement
1
f x x … x )
11 1
x f x x … x )+x f x x … x )
10
f x x … x ) x +x )
1 1
f x x … x )
B + + Similarly B is also true
To prove (C) and (D)
2. [Ans. C] Let f x x x ) x + x + x
Total no. of distinct multiple stuck at Then (C) f x x x ) x + x + x
faults in a circuit with N lines is 2 1.
x x + x + 0) + x x + x + 1)
x x +x )+x
3. [Ans. A]
x x +x x +x
f (w, x, y, z) = (5, 7, 11, 12, 13, 15)
x +x +x
Draw the K – map
f x x x )
yz
10 01 11 10
So (C) can be true, let check for D
wx
1 f x x x ) f 0 x x )+ 1 x x )
00
0+x +x )+ 1+x +x )
01 1 1 =1
f x x x )
11 1 1 1 It is not true, and we know that if a
statement is not true even for one
10 1 om in tion it n’t g n r l
statement

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 272
GATE QUESTION BANK Digital Logic

5. [Ans. D] 8. [Ans. A]
PQ Consider a simple method let w = 1,
RS
00 01 11 10 x = 1, y = 1, z = 1 then the value of f is 1.
Consider each statement
00 1 0 0 1
(P) x y z + w xy + wy z + xz
01 0 0 1 1 =000+010+101+11=1
11 1 1 1 0 (Q) w y z + wx y + xz
1 0 0 1 000+100+11=1
10
(R) w y z + wx y + xyz + xy z
So is essential prime implicants. =000+100+111+101=1
(S) x y z + wx y + w y
6. [Ans. C] =000+100+01=0
Let the binary constant be the value of So statement (S) is false because w = 1,
the function f(x x … … x ) for the x = 1, y = 1, z = 1 the value of f is 0. (S)
combination of variables whose decimal is not contain the essential minterms.
code is i. Then every switching function So option not containing S is answer
can be expressed in form. which is option (A)
f (x x … . x ) = x́ x́ … x́ +
x́ x́ … x́ + … + x x … x . 9. [Ans. D]
A factor is either 0 or 1 if the +
corresponding minterm is contained in Z = X*Y
canonical form of the function. Then y + from eq. (i)
there are r = 2 coefficients each of P:X=
which can have values either 0 or 1 = YZ + by eq.(i)
hence there are 2 possible =Y(XZ + X Z ) + Y Z
assignments. = XYZ + X YZ + Y Z
Q:Y=
7. [Ans. B] Y = XZ + X Z by eq.(i)
Given Y =XZ + X Z
f(w, x, y, z) =  (1, 3, 4, 6, 9, 11, 12, 14) R: = 1 if we will take the truth
Corresponding K – map for f is table for P, Q, R, then all are valid
formulas
yz
wx 00 01 11 10
10. [Ans. A]
00 1 1
cd a + +
01 ab 00 01 11 10
1 1
00 1 1
11 1 1 01 1
1
11 1 1 1
10
1 1
10 1 1

f(w, x, y, z) = xz + x z
So f (w, x, y, z) is independent of two
variables w and y.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 273
GATE QUESTION BANK Digital Logic

11. [Ans. A] It depends on 3 variables A, B and C.


Option (A) does not correspond to K- So it is independent of one variable.
map option in question 10.
+ + + 16. [Ans. A]
+ +
12. [Ans. A] ( + )+( + ) + + )
The K-Map is
+ + + +
ab +
cd 00 01 11 10
+ + + +
00 1 1 1 111) 110) 010) 100)
m +m +m +m
01 x
17. [Ans. B]
11 + + ) + + ) + + )
x
(( + ) + ) + + )
10 1 x + ) + + )
1
+ + + +
+ +

13. [Ans. C] 18. [Ans. A]


f and f are connected with AND gate so X Y f(X, Y)
when f = m(6, 8) then f is true for 0 0 0
m (1, 6, 8, 15) 0 1 0
1 0 1
1 1 1
14. [Ans. A]
+ ) + ) + ) Now equation for f(X, Y) = X +
+ + + ) + ) ( + )
+ + ) + )
( + 1 + )) + ) 19. [Ans. D]
+ ) + ) Exclusive NOR of x and y (x y)
+ (x y)
xy + x y)
1+ ) x + y) x + y ))
x y + xy … … … … . i)
Option (A): is same as (i)
15. [Ans. A] Option (B): x y x y + xy same as (i)
f (A, B, C, D = (2, 3, 6, 7, 8, 9, 10, 11, 12, 13) Option (C): x y xy + x y same as (i)
CD Option (D): x y x y + xy not same
AB 01 11 as (i)
00 10
00 Option (D) is not correct.
1 1
01 1 1
11
1 1
10 1 1 1 1
+ +

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 274
GATE QUESTION BANK Digital Logic

20. [Ans. A]
K-map for given expression
RS 00 01 11 10
PQ
00
01 1 1 1
11 1 1 1 1
10

QS
PQ QR

So minimal sum of products is PQ + QR + QS

21. [Ans. D]
A function F is self dual if it has equal
number of minterms and maxterms, also
mutually exclusive term should not be
included.
The number of mutually exclusive terms
(pair wise) is 2
Number of function possible by taking any
of the one term from the above mentioned
mutually exclusive pair is = 2

22. [Ans. B]
RS
PQ 00 01 11 10
00 1 x
01 1 x QS
11 x 1
10 x 1

All four corner =


Minimal sum of products for F is
QS +

23. [Ans. D]
1 ) ) ) 0)
) ) { 1
0
1 ) 0) { 1
0
{ 1
0
+
)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 275
GATE QUESTION BANK Digital Logic

Logic Gates

CS – 2005 CS - 2007
1. A two-way switch has three terminals a, b 4. The following expression was to be realized
and c. In ON position (logic value 1), a is using 2 input AND and OR gates. However,
connected to b, and in OFF position, a is during the fabrication all 2 input AND
connected to c. Two of these two way gates were mistakenly substituted by
switches S1 and S2 are connected to a 2 input NAND gates.
bulb as shown below. (a. b).c + (̅.c).d + (b.c).d + a.d
b b What is the function finally realized?
a a (A) 1
c c
(B) ̅ + ̅ + ̅ + ̅
Switch
c S1 Switch
c S2 (C) ̅ + b + ̅ + ̅
(D) ̅ + ̅ + c + ̅
Bulb
5. The line T in the following figure is
Which of the following expressions, if
permanently connected to the ground.
true, will always result in the lighting of X1
the bulb? X2
X3
(A) S1. ̅̅̅ (C) ̅̅̅̅̅̅̅̅̅̅ X2
X4
X3
(B) S1+ S2 (D) S1 S2 X3 T

2. Which of the following expressions is X4


Which of the following inputs (X1 X2 X3 X4)
X4
equivalent to (A B) C will detect the fault?
X4
(A) (A + B + C) ( ̅ ̅ ̅ ) (A) 0000
(B) (A + B + C) ( ̅ ̅ ) (B) 0111
̅ ̅
(C) ABC + (B C) + (A C) (C) 1111
(D) None of these (D) None of these

CS - 2006 CS - 2009
3. The majority function is a Boolean 6. What is the minimum number of gates
function f (x, y, z) that takes the values 1 required to implement the Boolean
whenever a majority of the variables x, y function (AB + C) if we have to use only
and z. In the circuit diagram for the 2-input NOR gates?
majority function shown below, the logic (A) 2 (C) 4
gates for the boxes labeled P and Q are, (B) 3 (D) 5
respectively
z y
P 1

f
Q 0

(A) XOR, AND (C) OR, OR


(B) XOR, XOR (D) OR, AND

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 276
GATE QUESTION BANK Digital Logic

CS – 2010 CS – 2014
7. What is the Boolean expression for the 10. Consider the following combinational
output f of the combinational logic circuit of function block involving four Boolean
NOR gates given below? variables x, y, a, b where x, a, b are inputs
P and y is the output.
Q
f (x, y, a, b)
Q {
R if (x is 1) y = a;
f
R
RP
else y = b;
R }
R Which one of the following digital logic
QR
R blocks is the most suitable for
R implementing this function?
R
(A) ̅̅̅̅̅̅̅̅ (C) ̅̅̅̅̅̅̅ (A) Full adder
(B) ̅̅̅̅̅̅̅ (D) ̅̅̅̅̅̅̅̅̅̅̅̅̅̅
(B) Priority encoder
CS – 2011 (C) Multiplexer
8. Which one of the following circuits is NOT (D) Flip-flop
equivalent to a 2-input XNOR (exclusive
NOR) gate?
(A)

(B)

(C)

(D)

CS - 2012
9. What is the minimal form of the Karnaugh
map shown below? Assume that X
enotes on’t re term

(A) ̅ ̅ (C) ̅ ̅ +a ̅ ̅
(B) ̅ ̅ ̅̅ (D) ̅ ̅ + ̅ ̅ ̅ ̅

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 277
GATE QUESTION BANK Digital Logic

Answers Keys and Explanations

1. [Ans. C] ( )
Either both ON or OFF i.e. ( ( ))
( )

2. [Ans. C] ( )
Given ( )
( ) ( )
4. [Ans. C]
( ) ( ) ( )
Now (A),
Replace AND gate with NAND gate,
( )( )
( ) ( ) ( )
( ) ( ) ( ) ( )
( )
So A is false (not correct option)
(B) ( )( )
( )

( )
( )( )
So B is false (not correct option)
(C) ( ) ( )
( )

( )
So option C is correct 5. [Ans. D]
X1
X2
3. [Ans. D] X3
X2 X4
X3 X4 y
f= () X3 X3
X3 T
where ( ) X4
( ) X4
Now we know a 3 variable majority X4
X3 X4 X4 + y
X4
circuit is given as
( ) 0 1
0
Now on comparing, we get that there is 0 1 0
no on actual expression, so we have to
1 0 0
eliminate from equation (i) we know
that 1 1 0
( )
So the eliminate , Q must also be present But both n
in P and in addition P must contain some c n’t o ur t s me t me so none o these
other terms so by observation option A, B
& C are eliminated
Now option (D)
( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 278
GATE QUESTION BANK Digital Logic

6. [Ans. B] (B)
= AB + C
= (A + C) (B + C)
(( ) ( )) (C)
A ( )
C

(D)
(( ) +( ) ( )

B
C
( )

7. [Ans. A] ( )( )
̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅
̅̅̅̅̅̅̅ ̅̅̅̅̅̅̅̅
P ( ) ( )
(P + Q) (Q+R) = Q+RP
Q

Q
∴ pt on s not
R
P 9. [Ans. B]
R ab 00 01 11 10
cd
Q
̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ 00 1 x x 1
R ̅̅̅̅̅̅̅ ̅̅̅̅̅̅̅̅
(P + R) (Q+R) = R+PQ
01 x 1

( ) 11
( )
10 1 x
∴C=
∴ ( )
8. [Ans. D]
(A) 10. [Ans. C]
x
y nput nes output ne

( )( )

se e t ne

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 279
GATE QUESTION BANK Digital Logic

Logic Gate Families


CS - 2005
1. Consider the following circuit
x

z
Which one of the following is TRUE?
(A) f is independent of x
(B) f is independent of y
(C) f is independent of z
(D) None of x, y, z is redundant

Answer Keys and Explanations

1. [Ans. D]
The given circuit is
x

+ yz
y

f = x + yz
=x ( ) ( ) [∵ = 1]
=x
K – map:
yz
x 00 01 11 10

0 1

1 1 1 1

( )
So none of x, y, z is redundant.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 280
GATE QUESTION BANK Digital Logic

Combinational and Sequential Digital Circuits


CS – 2005 3. How many pulses are needed to change
1. Consider the following circuit involving a the contents of a 8-bit upcounter from
positive edge triggered D FF. 10101100 to 00100111 (rightmost bit is
A the LSB)?
X (A) 134 (C) 124
(B) 133 (D) 123
D Q
Y
4. Which of the following input sequences
CLK will always generate a 1 at the output z at
the end of the third cycle?
A
Consider the following timing diagram. B Z
Let represent the logic level on the line Clock ̅
A in the i-th clock period.

CL C
0 1 2 3 4 5
KX Clock ̅

A B C
Let represent the complement of A. The (A) 1 0 1
correct output sequence on Y over the 0 0 1
clock periods 1 through 5 is 0 1 0
(A) (C) (B) 1 0 1
(B) (D) 1 1 0
1 1 1
2. Consider the following circuit
(C) 0 1 1
1 0 1
1 1 1

CLK (D) 0 0 1
The flip-flops are positive edge triggered 1 1 0
D FFs. Each state is designated as a two 1 1 1
bit string . Let the initial state be 00. 5. The circuit shown below implements a
The state transition sequence is 2-input NOR gate using two 2 1 MUX
(A) 00→11→01 (control signal 1 selects the upper input).
What are the values of signals x, y and z?
(B) 00→11
x 1

(C) 00→10→01→11 y
0
A 1
(D) 00→11→01→10 B
0

0z
(A) 1, 0, B (C) 0, 1, B
(B) 1, 0, A (D) 0, 1, A

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 281
GATE QUESTION BANK Digital Logic

CS - 2006 8. Given two three bit numbers


6. You are given a free running clock with a and c, the carry in,
duty cycle of 50% and a digital waveform the function that represents the carry
f which changes only at the negative edge generate function when these two
of the clock. Which one of the following numbers are added is
circuits (using clocked D-flip-flops) will (A) + +
delay the phase of f by 180 ? + + + +
(A)
D D (B) + +
f D Q
+ + + +
̅
clk (C) + +( )[ + +
( ) ( + )]
(B)
(D) + ̅̅̅ + +
f D Q D Q ̅̅̅ ̅̅̅ + ̅̅̅ + ̅ ̅̅̅ +
g ̅ ̅
clk

9. We co si er the itio of two 2’s


(C) complement numbers

f D Q D Q binary adder for adding unsigned


clk binary numbers is used to add the two
numbers. The sum is denoted by
c c c and the carry out by c .
Which one of the following options
(D) correctly identifies the overflow
D D Q condition?
f
(A) c (̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅)
̅
(B) c̅̅̅̅̅̅ + ̅̅̅̅̅̅̅̅̅̅̅̅c
(C) c c
clk (D) c

7. Consider the circuit below . Which one CS - 2007


of the following options correctly 10. How many 3-to-8 line decoders with an
represents f(x,y,z)? enable input are needed to construct a
x 6-to-64 line decoder without using any
0 MUX
other logic gates?
1 (A) 7 (C) 9
y̅ (B) 8 (D) 10

z 0 MUX 11. Suppose only one multiplexer and one


f
1 inverter are allowed to be used to
x
implement any Boolean function of n
y variables. What is the minimum size of
the multiplexer needed?
(A) xz̅ + xy + y̅z (C) xz + xy + yz
̅̅̅
(B) xz̅ + xy +yz ̅̅̅ (D) xz + xy̅ + y̅z

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 282
GATE QUESTION BANK Digital Logic

(A) 2 i e to 1 i e The counter is connected as follows


(B) 2 i e to 1 i e A4 A3 A2 A1
(C) 2 i e to 1 i e
(D) 2 i e to 1 i e

12. In a look-ahead carry generator, the carry Count = 1


generate function the carry 4-bit counter Load = 0
Clear Clock
propagate function for inputs,
re give y Clear
Inputs
0 0 1 1
The expressions for the sum bit and the
carry bit of the look-ahead carry Assume that the counter and gate delays
adder are given by are negligible. If the counter starts at 0,
then it cycles through the following
where is the input carry. Consider a sequence
two-level logic implementation of the (A) 0, 3, 4 (C) 0, 1, 2, 3, 4
look-ahead carry generator. Assume that (B) 0, 3, 4, 5 (D) 0, 1, 2, 3, 4, 5
all are available for the carry
generator circuit and that the AND and 14. The following circuit implements a two –
OR gates can have any number of inputs. input AND gate using two 2-1
The number of AND gates and OR gates multiplexers.
needed to implement the look-ahead a 1 1
carry generator for a 4-bit adder with ab
as its outputs are 0 0
b
respectively
(A) 6, 3 (C) 6, 4
(B) 10, 4 (D) 10, 5
What are the values of X1, X2, and X3?
13. The control signal functions of a 4-bit (A) 0
binary counter are given below ( where X (B) 1
is “ o ’t c re”) (C) 1
Clear Clock Load Count Function (D) 0
1 X X X Clear to
0 15. Which of the following input sequences
0 X 0 0 No for a cross – coupled R – S flip – flop
change realized with two NAND gates may lead to
0 ↑ 1 X Load an oscillation?
input (A) 11, 00 (C) 10, 01
0 ↑ 0 1 Count (B) 01, 10 (D) 00, 11
next

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 283
GATE QUESTION BANK Digital Logic

16. What is the final value stored in the linear 20. The Boolean expression for the output f of
feedback shift register if the input is the multiplexer shown below is
101101?
R 0

101101 ̅ 1
f
+ 0 1 1 0
̅ 2
XOR ̅
(A) 0110 (C) 1101 R 3
(B) 1011 (D) 1111 R

CS - 2008 R P Q
17. What Boolean function does the circuit ̅
below realize? (A) ̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ (C) P + Q + R
(B) (D) ̅̅̅̅̅̅̅̅̅̅̅̅̅̅
z
3 to 8
CS - 2011
y f (x, y, z) Common data for questions 21 and 22:
Decoder
Consider the following circuit involving
x three D-type flip-flops used in a certain
type of counter configuration.
(A) xz + x z (C) x y + yz
(B) xz xz (D) xy + y z
D Q
clock ̅
18. The two numbers given below are
mu tip ie usi g the ooth’s gorithm
Multiplicand: 0101 1010 1110 1110 Q
D Q
Multiplier: 0111 0111 1011 1101
How many additions/Subtractions are clock ̅
required for the multiplication of the
above two numbers?
R
(A) 6 (C) 10 D Q
(B) 8 (D) 12 clock ̅

CS - 2010
19. In the sequential circuit shown below, if
the initial value of the output is 00, 21. If some instance prior to the occurrence
what are the next four values of ? of the clock edge, P, Q and R have a value
0, 1 and 0 respectively, what shall be the
value of PQR after the clock edge?
1 T Q T Q
(A) 000 (C) 010
Clock (B) 001 (D) 011

(A) 11,10,01,00 (C) 10,00,01,11


(B) 10,11,01,00 (D) 11,10,00,01

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 284
GATE QUESTION BANK Digital Logic

22. If all the flip-flops were reset to 0 at (A)


power on, what is the total number of (B)
distinct output (states) represented by
(C)
PQR generated by the counter?
(D) PQ
(A) 3 (C) 5
(B) 4 (D) 6
26.

23. The minimum number of D flip-flops


needed to design a mod-258 counter is C C C

(A) 9 (C) 512


(B) 8 (D) 258

The above synchronous sequential circuit


CS - 2013
built using JK flip – flops in initialized
24. In the following truth table, V = 1 if and
with 000 The state sequence
only if the input is valid.
for this circuit for the next 3 clock cycles
Inputs Outputs
is
V
(A) 001, 010, 011 (C) 100, 110, 111
0 0 0 0 x x 0
(B) 111, 110, 101 (D) 100, 011, 001
1 0 0 0 0 0 1
x 1 0 0 0 1 1
27. Let 2 . A circuit is built by giving the
x x 1 0 1 0 1
output of an n bit binary counter as
x x x 1 1 1 1 input to an to 2 bit decoder. This
What function does the truth table circuit is equivalent to a
represent? (A) k bit binary up counter.
(A) Priority encoder (B) k bit binary down counter.
(B) Decoder (C) k bit ring counter.
(C) Multiplexer (D) k bit Johnson counter
(D) Demultiplexer

CS - 2014
25. Consider the 4 – to – 1 multiplex with two
select lines and given below
0 0
1 1 4 – to – 1
Multiplexer
2
3

The minimal sum of – products form of


the Boolean expression for the output F of
the multiplexer is

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 285
GATE QUESTION BANK Digital Logic

Answer Keys and Explanations


1. [Ans. A]
Let initially Q = 5. [Ans. D]
x 1
Now
x x y 0
Given x = 1 1 0 1 1 0
Clock = 0 1 2 3 4 5 and A 1
A= B 0 P(let)
Then
Clock A D
Z
1 P=A +B
2 C = xP + y
3
x( ) y )
4
x( ) y )
5
x x y y y
2. [Ans. D] Also given (required)

NS from emorg theorem)


00 11 Now from option (A)
11 01 Put x = 1, y = 0, = B we get
01 10 0 0 0 0
10 00 From option (B)
00 11 Put x = 1, y = 0 & = A
11 01 0 0 0
⋮⋮ ⋮⋮
⋮⋮ ⋮⋮ From option (C)
Put x = 0, y = 1 & = B
3. [Ans. D] 0 0
Upcounter will go upto its highest count
first then it will start from clear and go
upto required value so from
→ 1 0 1 0 1 1 0 0 to → 1 1 1 1 1 1 1 1 3
rom optio )
then from
Put x = 0, y = 1 & = A
1 1 1 1 1 1 1 1 →00000000→
0 0 1 0 0 1 1 1 40 0 0 0
So total = 83 + 40 = 123
Which is required
4. [Ans. A] So correct option is (D)
A B C Z
1 0 1 1 0 6. [Ans. B]
0 0 1 0 1 0 0 Hint: Invertor provides 1 0 phase
0 1 0 1 0 1 1 FF with Q output 360 or 0
We got answer with first option no need FF with ̅ output gives 1 0 phase
to check for other options.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 286
GATE QUESTION BANK Digital Logic

7. [Ans. A] 9. [Ans. C]
x B=
0 A=
f
S=c c c
1
The over flow condition V

V= c c
c is c so
z 0
f V=c c
1
x So the over flow condition is
c c
y

Let the output of first uppermost Mux is f 10. [Ans. C]


f xz yz For the construction of a 6 × 64 decoder
The output of second Mux is by using 3 × 8 line decoder
f = (xz y z)y xy 1 extra decoder for combining
= xy z y y z xy
the result 6 × 64 → 3×8
= xy z + y z xy [
= y z xy z xy z z ) [a + = 1] 11. [Ans. C]
= y z xy z xyz xyz To implement n variable function, we
= y z xy z + xyz xyz xyz require a data selector with n 1 select
[a + a = a] inputs and 2 data inputs. So minimum
= y z + xz y y) xy z z) size of multiplexer needed is 2 line to
= y z xz xy [a + = a] 1 line
= xz xy y z
12. [Ans. B]
8. [Ans. D] A 4-bit adder with and as
Consider and its output require 2 – 1 bit adder and a
single one bit adder require 5 AND gates
000 000 and 2 OR gates in two level logic. So the
001 001 required gate are 10 AND gate and 4 OR
010 010 gates.
011 011
13. [Ans. D]
100 100
If load = 0 and count = 1 then counter
101 101
count the sequence 0000, 0001, 0010,
110 110
0011, 0100, 0101, 0000 in decimal if
111 111
count 0, 1, 2, 3, 4, 5 and then 0 and repeat
So the carry c will be generated if
the sequence. After 0101 clear = 1
1
So again 0000 as count output.
1 or 1 or
1 14. [Ans. A]
1 or 1 a
1 1 ab
So the statement (D) generate a carry c
always
b
0 0

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 287
GATE QUESTION BANK Digital Logic

So, a.b = (a + b ) + xyz


If = b, = 0, = a xyz
z x yz
then RHS = (a . b + b . ) a + 0 .
xy z
=a.b.a 3 × 8
y
=a.b decodes xy z

xy z
15. [Ans. B] x xyz
S xyz

= xz xz)
= (x z ) xz)
R = (x + z) (x z)
S R = xx xz x z zz
= xz xz
1 1
1 0 0
18. [Ans. B]
0 1 1
ooth’s gorithm requires ex mi tio
0 0 Invalid
of the multiplier bits and shifting of the
Now since 00 leads to invalid state it
partial product. Prior to the shifting, the
cannot lead to an oscillation
multiplicand may be added to the partial
So (A) & (D) are wrong options
product, subtracted from the partial
In both option B & C oscillation will occur
but in option (C) oscillation will start after product or left unchanged according to
one clock cycle however in option (B) the following rules.
oscillation will state with first clock cycle 1. The multiplicand is subtracted from
so B is more correct answer the partial product upon
encountering the first least
16. [Ans. A]
significant 1 in a string of 1’s i the
Clock Output
multiplier.
0 0110
2. The multiplicand is added to the
1 1011
partial product upon encountering
2 1101
the first 0 i stri g of 0’s i the
3 0110 multiplier.
4 1011 3. The partial product does not change
5 1101 when the multiplier bit is identical to
6 0110 the previous multiplier bit.
As in multiplier we see that a change
101101 occurs in bit as 0 changes to 1 and 1
+ changes to 1.
Multiplier:
So option A 0111 0111 1011 1101
1 1 1 1 1 1 1 ↑
17. [Ans. B]
f xyz x yz xy z xyz
=x z y y) xz y y )
= x z 1) xz 1)
=x z xz
f=f

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 288
GATE QUESTION BANK Digital Logic

19. [Ans. A] 26. [Ans. C]


Clock to next flipflop is by Q and +ve edge Values of J and K in each flip – flop from
trigger so it will be a down counter left to right will be
J = 1, 0, 0
Initial 0 0 K = 0, 1, 1
After 1st Clock 1 1 According to these inputs will be
After 2nd Clock 1 0 100
After 3rd Clock 0 1 Now based on new outputs J – K will be
After 4th Clock 0 0 J = 1, 1, 0
K = 0, 0, 1
20. [Ans. B] And will be 110
Now new J – K
( ) ( ) J = 1, 1, 1
L = 0, 0, 0
) )
And will be 110

21. [Ans. D] 27. [Ans. C]

) 2
n - bit
bit
binary
f ) 0 1 0) the ext st te counter decode
r 1
) 0 1 1)
)
22. [Ans. B]
So output of n-bit binary counter move
There are four distinct states.
from 1, 2, 3, and so on according to that
000 →010→011→100 →000)
and so on output will be high.
23. [Ans. A]
Mod 258 counter has 258 different states.
So minimum number of bits required
each state is ceiling of og 25 , each
of which requires one flip-flop.

24. [Ans. A]
Truth table given represent the priority
encoder i.e, 4 2 priority encoder V = 0
indicates output is invalid and V = 1
indicates output is valid

25. [Ans. A]
0 1

( )

So answer

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 289
GATE QUESTION BANK DMGT

Mathematical Logic
CS - 2005 5. Which one of the first order predicate
1. What is the first order predicate calculus calculus statements given below correctly
statement equivalent to the following? expresses the following English
Every teacher is liked by some student statement?
(A) ( ), ( ) Tigers and lions attack if they are hungry
( ), ( ) ( )-] of threatened.
(B) ( ), ( ) (A) [( ( ) ( ))
( ), ( ) ( )-- {( ( ) ( ))
(C) ( ) ( ), ( ) ( )}]
, ( ) ( )--
(B) [( ( ) ( ))
(D) ( ), ( ) ( )
{( ( ) ( ))
, ( ) ( )--
( )}]
2. Let P, Q and R be three atomic (C) [( ( ) ( ))
propositional assertions. Let X denote { ( ) ( ( )
( ) and Y denote ( ))}]
( ) ( ). Which one of the
(D) [( ( ) ( ))
following is a tautology?
*( ( ) ( ))
(A) X Y (C) Y X
( )+]
(B) X Y (D) Y X
6. A logical binary relation ⨀, is defined as
3. Let P(x) and Q(x) be arbitrary predicates.
follows :
Which of the following statements is
always TRUE? A B A⨀B
(A) (( ( ) ( ))) True True True
(( ( )) ( ( ))) True False True
(B) ( ( ( ) ( ))) False True False
(( ( ( )) ( ( ))) False False True
(C) ( ( ( )) ( ( ))) Let ~ be the unary negation (NOT)
(( ( ( ) ( ))) operator, with higher precedence, than
⨀. Which one of following is equivalent
(D) . ( ( ))/ ( ( )))
A B?
( ( ( ) ( ))) (A) (~A ⨀ B) (C) ~(~A⨀~B)
(B) ~(A⨀~B) (D) ~(~A⨀B)
CS - 2006
4. Consider the following propositional CS - 2007
statements: 7. Which of the following is TRUE about
P1: ((A  B)  C) ((A  C)  (B  C)) formulae in Conjunctive Normal Form?
P2: ((A  B)  C) ((A  C)  (B  C)) (A) For any formula, there is a truth
Which one of the following is true? assignment for which at least half the
(A) P1 is a tautology, but not P2. clauses evaluate to true.
(B) P2 is a tautology, but not P1. (B) For any formula, there is a truth
(C) P1 and P2 are both tautologies assignment for which all the clauses
(D) Both P1 and P2 are not tautologies evaluate to true.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 290
GATE QUESTION BANK DMGT

(C) There is a formula such that for each Each finite state automaton has an
truth assignment, at most one-fourth equivalent pushdown automaton
of the clauses evaluate to true. (A) ( ( ))
(D) None of the above. ( ( ) ( ))
(B) ( ( )
8. Let Graph (x) be a predicate which denotes ( ( ) ( ))
that x is a graph. Let Connected (x) be a (C) ( ( ) ( ) ( ))
predicate which denotes that x is connected. (D) ( ( ) ( ) ( ))
Which of the following first order logic
sentences DOES NOT represent the 12. Which of the following is the negation of
statement. “N every graph is connec ”? [ ( ( ))-
(A) ¬ (Graph(x) ⇒ Connected (x)) (A) [ ( ( ))-
(B)  x(Graph (x)  Connected (x)) (B) [ ( ( ))-
(C) (¬Graph(x) Connected (x)) (C) [ ( ( ))-
(D) (Graph (x)  ¬ Connected (x)) (D) [ ( ( ))-

9. Which one of these first-order logic 13. Which of the following first order
formulae is valid? m ?H ( )
(A) ( ( ) Q(x)) (( ( ( )) first order formula with x as free variable,
( ( ))) and is a first order formula with no free
(B) ( ( ) Q(x)) (( ( ( )) variable
( ( ))) (A) [ ( x, (x))] [ x, (x)]
(C) ( ( ) Q(x)) (B) [ x, (x)] [ ( x, (x))]
(( ( ( )) ( ( ))) (C) [( ( )) - , x, ( ) -
(D) ( ) ( ) (D) [( ( )) - , ( ) -

CS - 2008 CS - 2009
10. P and Q are two propositions. Which of 14. Consider the following well-formed
the following logical expressions are formulae:
equivalent? i. x  P x  
1)
2) ( ) ii. xP x
3) ( ) ( ) ( ) iii. x  P x  
4) (P Q) (P ~Q) (~P  Q)
iv. xP x
(A) Only 1 and 2
(B) Only 1, 2 and 3 Which of the above are equivalent?
(C) Only 1, 2 and 4 (A) i and iii (C) ii and iii
(D) All of 1, 2, 3 and 4 (B) i and iv (D) ii and iv

11. Let fsa and pda be two predicates such 15. Which one of the following is the most
that fsa(x) means x is a finite state appropriate logical formula to represent
automaton, and pda(y) means that y is a the statement:
pushdown automaton. Let equivalent be “G m ”.
another predicate such that equivalent The following notations are used:
(a, b) means a and b are equivalent. G(x): x is a gold ornament
Which of the following first order logic S(x): x is a silver ornament
statement represents the following: P(x): x is precious

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 291
GATE QUESTION BANK DMGT

(A) x(P(x) (G(s) S(x))) CS - 2012


(B) x((G(x) S(x) P(x)) 19. Consider the following logical inferences.
(C) x ((G(x) S(x)) P(x)) I1: If it rains then the cricket match will
(D) x((G(x) S(x)) P(x)) not be played
The cricket match was played
16. The binary operation is defined as Inference: There was no rain
follows ; I2: If it rains then the cricket match will
P Q P Q not be played
T T T It did not rain
T F T Inference: The cricket match was played
F T F Which of the following is True?
F F T (A) Both I1 and I2 are correct inferences
Which one of the following is equivalent (B) I1 is correct but I2 is not correct
to P Q? inference
(A) (C) (C) I1 is not correct I2 is a correct
(B) (D) inference
(D) Both I1 and I2 are not correct
CS – 2010 inference
17. Suppose the predicate F(x, y, t) is used to
20. What is the correct translation of the
represent the statement that person x can
following statement into mathematical
fool person y at time t. Which one of the
logic?
statements below expresses best the
“ m mb ”
meaning of the formula
(A) ( ( ) rational(x))
(F(x, y, t))?
(B) ( ( ) ( ))
(A) Everyone can fool some person at
(C) ( ( ) rational(x))
some time.
(D) ( ( ) real(x))
(B) No one can fool everyone all the time.
(C) Everyone cannot fool some person
CS - 2013
all the time.
21. Which one of the following is NOT logically
(D) No one can fool some person at some
equivalent to  ( ( ) ( ))?
time.
(A) ( ( ) ( ))
(B) ( ( ) ( ))
CS - 2011
(C) ( ( ) ( ))
18. Which of the following option is correct
(D) ( ( ) ( ))
given three positive integers x, y and z,
and a predicate
P(x) = (x = 1)  y ( z(x = y * z) 22. What is the logical translation of the
following statement?
 (y = x)  (y = 1))
“N m .”
(A) P(x) being true means that x is a
prime number (A) (F( )  ( ))
(B) P(x) being true means that x is (B) (F( ) ( ))
number other than 1 (C) (F( )  ( ))
(C) P(x) is always true irrespective of the (D)  (F( ) ( ))
value of x
(D) P(x) being true means that x has
exactly two factors other than 1 and x

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 292
GATE QUESTION BANK DMGT

CS - 2014
23. Consider the statement
“N ”
Predicate glitter (x) is true if x glitters and
predicate gold (x) is true if x is gold.
Which one of the following logical
formulae represents the above
statement?
(A) : ( )⇒ ( )
(B) : ( )⇒ ( )
(C) : ( ) ( )
(D) : ( ) ( )

24. Which one of the following propositional


logic formulas is TRUE when exactly two
of p, q and r are TRUE?
(A) (( ) ) ( )
(B) ( ( ) ) ( )
(C) (( ) ) ( )
(D) ( ( ) ) ( )

25. Which of the following Boolean


expressions is NOT a tautology?
(A) (( b) (b )) ( )
(B) ( ) ( b ( ))
(C) ( b ) ( )
(D) (b )

26. Consider the following statements:


P: Good mobile phones are not cheap
Q: Cheap mobile phones are not good
L: P implies Q
M: Q implies P
N: P is equivalent to Q
Which one of the following about L, M and
N is CORRECT?
(A) Only L is TRUE.
(B) Only M is TRUE.
(C) Only N is TRUE.
(D) L, M and N are TRUE.

27. The CORRECT formula for the sentence,


“ ”
(A) ( ( ) C ( ))
(B) ( ( ) C ( ))
(C) ( ( ) C ( ))
(D) ( ( ) C ( ))

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 293
GATE QUESTION BANK DMGT

Answer Keys and Explanations

1. [Ans. B] is not a tautology


“E b m ”: : ((A B) C) ((A C) (B C))
then the logical expression is LHS ((A+ B) C)
(x)[teacher (x)  (A B) C
(y) [student ( ) ( )-- AB C
Where likes (y, x) means y likes x, such HS (A C) (B C)
that y represent the student and x (A C) (B C)
represents the teacher. A B C
C LHS ≠ HS is also not a
2. [Ans .B] tautology
X: ( )R Therefore both and are not
Y: (P ) ( R) tautologies. Correct choice is (D).
X: P + QR  (P+Q) + R  P Q + R
Y: (P +R) + (Q + R)  P + Q + R 5. [Ans. D]
Clearly XY T m b “I
an animal is a tiger or lion, then (if the
Consider XY
animal is hungry or threatened, then it
 (P Q + R)(P + Q + R)
will attacks). Therefore the correct
 (P Q + R) + P + Q + R
translation is
 (P Q ) .R + P + Q + R
[( ( ) ( ))
 (P + Q).R + P + Q + R
{( ( ) ( )) ( )}]
 PR + QR + P + Q + R
Which is choice (D)
(PR + R) + (QR + Q ) + P
(P + R) (R + R) + (Q + Q ) × (R + Q ) + P
6. [Ans. D]
(P + R) + (R + Q ) + P
By using min terms we can define
P + P + R + R + Q
A B AB AB AB
1+1+ Q
A AB
1 (A A ). (A B )
∴ XY is a tautology A B
(A) A B A B A B
3. [Ans. A] (B) (A B) (A B )
(A (B ) ) (A B) AB
4. [Ans. D] (C) ( A B) (A B)
: ((A B) C) ((A C) (B C)) (A (B ) ) (A B) AB
LHS: (D) ( A B) (A B)
(A B) C (A B ) A. B A B
AB C ∴ (D) A B
(A B) C
A B C 7. [Ans. D]
RHS: In conjunctive normal form, for any
(A C) (B C) particular assignment of truth values, all
(A + C) (B + C) except one clause, will always evaluate to
AB+C true, So (D) is correct answer
C LHS ≠ HS

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 294
GATE QUESTION BANK DMGT

8. [Ans. A] ( ( ))
T m “N ( ( ) ( )) is the logical
” m “T m representation.
w ” which is
the same as 12. [Ans. D]
* ( ) ( )+ [ ( ( ))]
Which is choice (B)
[ ( (  (  ))]
Alternate solution
, x, ( ( u, v,  ))]
We can translate the given statement
“N T ( )”
13. [Ans .C]
( ( ) ( ))
Consider ,( ( )) - , ( ) -
( ( ) ( ))
If ( ( )) is FALSE, then ( ) is
( ( ) ( ))
TRUE, and hence the entire statement is
( ( ) ( ))
TRUE. If ( ( )) is TRUE and
Which is choice (B)
,( ( )) - is TRUE, then is TRUE,
and hence the entire statement is TRUE.
9. [Ans. A]
When ( ( )) FALSE, then the
14. [Ans .B]
formula
 ( )  ( )
F: ( ( ) ( )) ( ( ( ))
& iv ( ( ))
( ( ( )))becomes TRUE. If
Clearly, choices i and iv are equivalent.
( ( )) TRUE and
ii  ( )  ( )
( ( ) ( )) TRUE, then and iii  , ( )- ( )
( ( )) TRUE, and Clearly ii & iii are not equivalent to each
∴ F TRUE. Hence formula F is valid. other or to i & iv.

10. [Ans .B] 15. [Ans. D]


( ) . T “G
( ) ( ) ( ) m ” (D)
( ) ( )
((G( ) S( )) ( ))
( )
w “ m
( ) ( )
”. N w
given ornament cannot be both gold and
( ) ( ) ( )
silver at the same time.
( ) ( )
Choice (B) ((G( ) S( )) ( )) is
( )
incorrect.
( ) ( )

Hence only statements 1, 2 and 3 are


equivalent.

11. [Ans. A]
“F w fsa, there exists a y
which is a pda and which is equivalent to
.”

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 295
GATE QUESTION BANK DMGT

16. [Ans. A]
~Q I : ⇒
~P

T
F

Which corresponds , ⇒ -⇒
,( ) -⇒
T

F
, -⇒
)
̅̅̅̅̅̅̅̅̅̅̅̅


~P Q

T
F

F
( )
(

which is not a tautology.


~Q ~P
(̅̅̅̅̅̅̅)

So I is incorrect inference
T
F

20. [Ans. C]
P Q

Some real numbers are rational


T
F

, ( ) ( )-
T

F
Q

21. [Ans. A and D]


( ( ) ( ))
T

F
P

, ( ) ( )- “C”
, ( ) ⇒ -
~Q

T
F

, ( ) ( )- Option “B”
, ⇒ ⇒ -
~P

T
F

, ( ) ( )-
, ( ) ⇒( ))-
17. [Ans. B]
(F( ))
22. [Ans. D]
( F( )), which means
None of my friends are perfect
there does not exist a person who can fool
i.e., All of my friends are not perfect
every one at all times.
((F( )  ( ))
(F( )  ( ))
18. [Ans. A]
 (F( ) ( ))
The given statement reads,
P(x) is true whenever x is not 1 and for Alternatively
every y, if there is a z such that x = y*z, (F( ) ( )) gives there exist some of
then either x = y or y = 1 my friends who are perfect.
In other words, P(x) is true whenever x is  (F( ) ( )) there does not exists
prime. any friend who is perfect i.e., none of my
friends are perfect.
19. [Ans. B] So (D) is correct.
Let p : It rains
q : cricket match will not be played 23. [Ans. D]
I : ⇒ (A) For all x, which glitter are not gold
(B) For all x, which are gold, glitter
∴ (C) There are few x, which are gold and
Clearly I is correct since it is in the form not glitter
of Modus Tollens (rule of contrapositive) (D) There are few x, which glitters and
not gold.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 296
GATE QUESTION BANK DMGT

24. [Ans. B] 26. [Ans. D]


1. If p is false, q and r are true Now let us assume
( (F T) T) (F T T) m b
(T T) F b m b
T P statement implies that
2. If q is false, p and r are true  b (  b)
( (T F) T) (T F T) Q statement implies that
(T T) F b  ( b  )
T ∴ P and Q are equivalent and the imply
3. If r is false, p and q are true each other thus option (D) is the correct
( (T T) F) (T T F) option
(F F) T
F T 27. [Ans. D]
T Given statement is not all rainy days are
In all case it is giving true. cold
This means all rainy days need not be cold
25. [Ans. B] So there is atleast one day which is
(rainy) and (not cold)
))

So the representation is
)

T
T
T
T
T
T
T
F

( ( ) C ( ))
(
(
(

Option (D) is correct


)

T
T

T
T
T
F
F

F
(

T
F
F
F
F
F

F
T
T

T
T
F
F

F
F
T

T
F

F
F

F
T

T
F

F
c

T
T

T
T
F
F

F
F
b

T
T
T
T
F
F
F
F
a

Hence this not a tautology

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 297
GATE QUESTION BANK DMGT

Combinatorics
CS - 2005 5. Suppose that the robot is not allowed to
1. What is the minimum number of ordered traverse the line segment from (4,4) to
pairs of non-negative numbers that (5,4). With this constraint , how many
should be chosen to ensure that there are distance paths are there for the robot to
two pairs (a, b) and (c, d) in the chosen reach (10,10)starting from (0,0)
set such that a ≡ c mod 3 and (A)
b ≡ d mod 5 (B)
(A) 4 (C) 16 (C) ( ) ( )
(B) 6 (D) 24 5
(D) ( ) ( ) ( )
5
2. Let G(x)=1/(1 x)2=∑ g(i) where
| | . What is g(i)?
CS - 2008
(A) i (C) i
Statement for Linked Answer Questions 6
(B) i + 1 (D)
&7
Let Xn denote the number of binary
CS - 2006
strings of length n that contain no
3. For each element in a set of size 2n, an
consecutive 0s.
unbiased coin is tossed. The 2n coins
6. Which of the following recurrences does
tosses are independent. An element is
Xn satisfy?
chosen if the corresponding coin toss
(A) Xn  2Xn1 (C) Xn  X n/2  n  
were head. The probability that exactly n
elements are chosen is (B) Xn  Xn/2  1 (D) Xn  Xn1  Xn2
( ) (C)
(A) ( )
7. The value of X5 is
( ) (D)
(B) (A) 5 (C) 8
(B) 7 (D) 13
CS - 2007
Statement for Linked Answer Questions 4 8. In how many ways can b blue balls and r
and 5 red balls be distributed in n distinct
Suppose that a robot is placed on the boxes?
( )( )
Cartesian plane. At each step is allowed to (A) ( ) ( )
move either one unit up or one unit right, ( ( ) )
(B)
i.e., if it is at (i, j) then it can move to ( )( )( )

either (i j)o (i j ) (C)


4. How many distinct paths are there for the ( ( ) )
(D) ( )
robot to reach the point (10,10) starting
from the initial position(0,0)?
CS – 2014
(A) ( )
9. The number of distinct positive integral
(B) factor of 2014 is __________.
(C)
(D) None of these

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 298
GATE QUESTION BANK DMGT

Answer Keys and Explanations

1. [Ans. C]
( ) ( )
The number of pairs ( a mod 3, b mod 5 )
is 3 × 5 = 15
(since a mod 3 can be 0, 1, or 2 and ( )
b mod 5 can be 0, 1, 2, 3, or 4)
∴ If 16 ordered pairs are chosen at least 2 4. [Ans. A]
of them must have (a mod 3, b mod 5) the Each path from (0,0) to (10,10) consists
same (basic pigeon hole principle). of 20 steps which contains 10 horizontal
Let such two pairs be (a, b) and (c, d) moves and 10 vertical moves. The 10
then horizontal moves, we can choose in
a mod 3  c mod 3 ac mod 3 ways.
and b mod 5  d mod 5 bd mod 5
5. [Ans. C]
2. [Ans. B] The number of paths from (0,0)to (10,10)
( )
via the line segment from (4,4) to (5,4)
∑ = C(8,4).C(11,5)
( )
Put n = 2
6. [Ans. D]

( ) There are only two possibilities for the
( ) strings counted by . First is that the
sequence ends in 1 and the second
( )
∑ possibility is that ending in 0. If a string
ends in 1, then the number of possibilities
( ) for the first bits such that there are

no consecutive 0s is . If a n-bit string
ends in 0, then the (n 1) st bit must be 1
∑( ) and the number of possibilities for the
first n 2 bits such that there are no
consecutive 0s is .
∑(i )
∴ = 3.
(Since r is a dummy variable, r can be
replaced by i) 7. [Ans. D]
, 3, 5,
∑ g(i) , 3.

∴ g(i) i 8. [Ans. A]
The number of ways to distribute b blue
3. [Ans. A] balls in n distinct boxes is equal to the
The probability that exactly n elements number of solutions of the equation
are chosen b, which is
= the probability of getting n heads out distribution of the r red balls
2n tosses is . Since the distribution of red
( ) ( ) ( inomia fo mu a) balls and blue balls are independent, the

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 299
GATE QUESTION BANK DMGT

required number of ways


( )( )
is ( ) ( )

9. [Ans. 8]
Resu t : If ‘n’ is a powe of p ime
(n p ) then n has x + 1 factors (they
are ( p p p p ))
Result 2: Every number can be written as
product of powers of primes
(n p p p ) then by product rule
the no.of factors
=( )( ) ( )
The given number is 2014
2014 = 53
So the no. of integral factors
=( )( )( )

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 300
GATE QUESTION BANK DMGT

Sets and Relations


CS – 2005 a
1. Consider the set H of all 3×3 matrices of
the type

[ ]
b c d
Where a, b, c, d, e and f are real numbers
and abc ≠ . Under the matrix
multiplication operation, the set H is
(A) a group e
(B) a monoid but not a group The poset is
(C) a semigroup but not a monoid (A) not a lattice
(D) neither a group nor a semigroup (B) a lattice but not a distributive lattice
(C) a distributive lattice but not a
2. The set {1, 2, 4, 7, 8, 11, 13, 14} is a group Boolean algebra
under multiplication modulo 15. The (D) a Boolean algebra
inverses of 4 and 7 are respectively
(A) 3 and 13 (C) 4 and 13 6. Let A, B and C be non-empty sets and let
(B) 2 and 11 (D) 8 and 14 X=(A B) C and Y=(A C) (B C).
Which one of the following is TRUE?
3. Let R and S be any two equivalence (A) X=Y
relations on a non-empty set A. (B)
Which one of the following statements is (C)
TRUE? (D) none of these
(A) , are both equivalence 7. Let A be a set with n elements. Let C be a
relations collection of distinct subsets of A such
(B) is an equivalence relation that for any two subsets S1 and S2 in C,
(C) is an equivalence relation either S1 S2 or S2 S1 . What is the
(D) Neither nor is an equivalence maximum cardinality of C?
relation (A) n (C)
(B) n+1 (D) n!
4. Let f:B  C and g:A  B be two functions
and let h=f o g . Given that h is an onto 8. Let f be a function from a set A to a set B, g
function. Which one of the following is is a function from B to C, and h is a
TRUE? function from A to C, such that
(A) f and g should both be onto functions h(a)= g(f(a)) for all a ϵ A. Which of the
(B) f should be onto but g need not be following statements is always true for all
onto such functions f and g?
(C) g should be onto but f need not be (A) g is onto h is onto
onto (B) h is onto f is onto
(D) both f and g need not be onto (C) h is onto g is onto
5. The following is the Hasse diagram of the (D) h is onto f and g are onto
poset [{a, b, c, d, e}, ≺]. CS - 2006
9. Given a set of elements N=* , ,……,n+ and
two arbitrary subsets A ⊆ N and B ⊆ N,
how many of the n! permutations π from
N to N satisfy min ,π(A)-= min ,π(B)-,
where min (S) is the smallest integer in
the set of integers , and π( ) is the set of
integers obtained by applying
permutation π to each element of ?
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 301
GATE QUESTION BANK DMGT

(A) (n |A B|)|A|| B| 15. What is the cardinality of the set of


(B) (|A| |B| )n integers X defined below?
| | X = {n | 1 n 123, n is not divisible by
(C) ! | |
| |
either 2, 3 or 5}
(D) (A) 28 (C) 37
.| /
|
(B) 33 (D) 44
10. Let = * , , 3, ……………, m+,m>3. Let 16. Let P, Q and R be sets. Let denote the
X1 ,............Xn be subsets of S each of size symmetric difference operator defined as
3. Define a function f from S to the set P Q = (P Q) – (P Q). Using Venn
of natural numbers as, f(i) is the diagrams, determine which of the
number of sets that contains the following is/are TRUE?
element i. That is f(i) = |{ j|i |}.Then (I) P ( )=( ) ( )
m (II) P ( ) = ( ) ( )
 f (i) is (A) I only
i 1
(B) II only
(A) 3m (C) 2m + 1 (C) Neither I nor II
(B) 3n (D) 2n + 1 (D) Both I and II

11. Let X, Y, Z be sets of sizes x, y and z 17. For the set N of natural numbers and a
respectively. Let W=X Y and E be the binary operation f: N×N N, an element
set of all subsets of W. The number of z ϵ N is called an identity for f,
functions from Z to E is if f(a, z) = a = f(z, a), for all a ϵ N. Which
(A) (C) of the following binary operations have
(B) Z (D) an identity?
(I) f(x, y) = x + y – 3
12. A relation R is defined on ordered pairs of (II) f(x, y) = max(x, y)
integers as follows (III) f(x, y) = xy
(x, y) R (u, v) if x<u and y>v. Then R is (A) I and III only
(A) Neither a partial order nor an (B) II and III only
Equivalence Relation (C) I and II
(B) A Partial order but not a Total order (D) None of these
(C) A Total Order
(D) An Equivalence Relation CS - 2007
18. How many different non-isomorphic
13. The set {1, 2, 3, 5, 7, 8, 9} under Abelian groups of order 4 are there?
multiplication modulo 10 is not a group. (A) 2 (C) 4
Given below are four possible reasons. (B) 3 (D) 5
Which one of them is false?
(A) It is not closed 19. Consider the set S={a, b, c, d}. Consider
(B) 2 does not have an inverse the following 4 partitions , , ,
(C) 3 does not have an inverse on
(D) 8 does not have an inverse ̅̅̅̅̅̅}, π = {ab
: π1={abcd ̅̅̅, cd
̅̅̅}, π = {abc
̅̅̅̅̅, d̅},
14. Let E, F and G be finite sets.
̅ ̅
π = *a̅, b, c̅, d+
Let = (E F) (F G) and Let be the partial order on the set of
Y = (E – (E G)) (E – F ). partitions ’= (π , 2 3 , 4 ), defined
Which one of the following is true ? as follows: πi πj if and only if πi
(A) refines πj . The poset diagram for ( , )
(B) ⊃ is
(C) X = Y
(D) X – ≠ ∅ and – ≠ ∅

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 302
GATE QUESTION BANK DMGT

(A) π Consider the following ordered pairs


(i) (101,22)
π (ii) (22,101)
(iii) (145,265)
π (iv) (0,153)
Which of these ordered pairs of natural
numbers are contained in P.
π
(A) (i ) and (iii) (C) (i) and (iv)
(B) π (B) (ii) and (iv) (D) (iii) and (iv)

22. Consider the set of (columm)vectors


π π defined by X = *xϵ |x x x = ,
where x = ,x , x , x - +.
Which of the following is TRUE?
(A) *, , , - , , , , - + is a basis for
π the subspace X.
(B) *, , , - , , , , - + is a linearly
(C) π independent set , but it does not span
X and therefore is not a basis of X.
(C) is not a subspace of .
(D) None of the above.
π
π CS - 2008
23. A set of Boolean connectives is
functionally complete if all Boolean
π functions can be synthesized using those.
Which of the following sets of connectives
π is NOT functionally complete?
(D) π π (A) EX-NOR
(B) Implication, negation
(C) OR, negation
(D) NAND

24. If P, Q, R are subsets of the universal set U,


π then (P Q R) ( Q R) is
(A)
(B) P
20. Let S be a set of n elements. The number (C)
of ordered pairs in the largest and the (D) U
smallest equivalence relations on S are
25. Consider the following Hasse diagrams.
(A) n and n (C) n2 and 0
(B) n and n
2 (D) n and 1

21. A partial order P is defined on the set of


natural numbers as follows. Here x/y
denotes integer division.
i. (0, 0)ϵ P.
i.
ii. (a, b)ϵ if and only a % b%
and (a/10, b/10)ϵ P.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 303
GATE QUESTION BANK DMGT

28. Consider the binary relation


R = {(x, y),(x,z), (z,x),(z,y)} on the set
{x,y,z}. Which one the following is TRUE ?
(A) R is symmetric but NOT antisymmetric.
(B) R is NOT symmetric but antisymmetric
(C) R is both symmetric and antisymmetric
(D) R is neither symmetric nor antisymmetric
ii. CS - 2010
29. Consider the set S = {1, , }, where
and are cube roots of unity. If *
denotes the multiplication operation,
the structure {S, *} forms
(A) a group
iii. (B) a ring
(C) an integral domain
(D) a field
30. What is the possible number of reflexive
relations on a set of 5 elements?
(A) (C)
(B) (D)
iv.
CS - 2012
Which all of the above represents a 31. How many onto (or surjective)
lattice functions are there from n- element
(A) (i) and (iv) only (n≥2) set to a 2-element set?
(B) (ii) and (iii) only (A) (C)
(C) (iii) only (B) (D) ( )
(D) (i), (ii) and (iv) only
CS - 2013
CS – 2009 32. A binary operation ⨁ on a set of integers
26. For the composition table of a cyclic is defined as ⨁y = x . Which one
group shown below of the following statement is TURE about
* a b c d ⨁?
a a b c d (A) Commutative but not associative
b b a d c (B) Both commutative and associative
c c d b a (C) Associative but not commutative
d d c a b (D) Neither commutative nor associative
Which one of the following choices is
correct? CS - 2014
(A) a, b are generators 33. A pennant is a sequence of numbers, each
(B) b, c are generators number being 1 or 2. An n-pennant is a
(C) c, d are generators sequence of numbers with sum equal to n.
(D) d, a are generators For example, (1,1,2) is a 4-pennant. The
set of all possible 1-pennants is {(1)}, the
27. Which one of the following is NOT set of all possible 2-pennants is {(2),
necessarily a property of a Group? (1,1)} and the set of all 3-pennants is
(A) Commutativity {(2,1), (1,1,1), (1,2)}. Note that the
(B) Associativity pennant (1,2) is not the same as the
(C) Existence of inverse for every element pennant (2,1). The number of 10-
(D) Existence of identity pennants is ______________.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 304
GATE QUESTION BANK DMGT

34. Let S denote the set of all functions Which one of the following is CORRECT?
* , + * , +. Denote by N the (A) P, Q and R are true
number of functions from S to the set (B) Only Q and R are true
{0,1}. The value of log log is ______. (C) Only P and Q are true
35. A non-zero polynomial f(x) of degree 3 (D) Only R is true
has roots at x = 1, x = 2 and x =3. Which
one of the following must be TRUE? 39. There are two elements x, y in a group
(A) f( )f( ) (G,∗) such that every element in the group
can be written as a product of some
(B) f( )f( )
number of x's and y's in some order. It is
(C) f( ) f( ) known that
(D) f( ) f( ) ∗ = ∗ = ∗ ∗ ∗ = ∗ ∗ ∗
=
36. Consider the following relation on subsets Where e is the identity element. The
of the set of integers between 1 and 2014. maximum number of elements in such a
For two distinct subsets U and V of S we group is ____.
say U<V if the minimum element in the
symmetric difference of the two sets is in
U.
Consider the following two statements:
S1: There is a subset of S that is larger
than every other subset.
S2: There is a subset of S that is smaller
than every other subset.
Which one of the following is CORRECT?
(A) Both S1 and S2 are true
(B) S1 is true and S2 is false
(C) S2 is true and S1 is false
(D) Neither S1 nor S2 is true

37. Let and be finite sets and f: be a


function. Which one of the following
statements is TRUE?
(A) For any subsets A and B of X,
|f(A B)| = |f(A)| |f(B)|
(B) For any subsets A and B of X,
f(A B) = f(A) (B)
(C) For any subsets A and B of X ,
|f(A B)| = min * |f(A)|,|f(B)|+
(D) For any subsets S and T of Y,
f ( T) = f ( ) f (T)

38. Consider the set of all functions


f:* , ,…, + * , ,…, + such that
f(f(i)) = i, for all i . Consider
the following statements:
P. For each such function it must be the
case that for every i, f(i) = i.
Q. For each such function it must be the
case that for some i, f(i) = i.
R. Each such function must be onto.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 305
GATE QUESTION BANK DMGT

Answer Keys and Explanations


1. [Ans. A] S is reflexive.
The set H is closed, since multiplication of Now, (x, y)  R S
upper triangular matrices will result only  (x, y) R and (x, y)  S
in upper triangular matrix.  (y, x) R and (y, x) S (Since R and S are
Matrix multiplication is associative, i.e. symmetric)
A (B C) = (A B) C.  (y, x) R S
(iii)The identity element is (x, y) R S
(y, x) R S
I should be = [ ]
Therefore R S is symmetric.
and this belongs to H as I is an upper Now consider
triangular as well as lower triangular (x, y) and (y, z) R S
matrix.  (x, y) and (y, z) R
If AH, then |A = abc. Since it is given that and (x, y) and (y, z) S
abc 0, this means that |A 0 i.e., every  (x, z) R and (x, z)S (Since R and S are
transitive)
matrix belonging to H is non-singular and
has a unique inverse.  (x, z) R S
 The set H along with matrix R S is transitive also
multiplication is a group. Since is reflexive, symmetric and
transitive.
2. [Ans .C] R S is equivalence relation.
The set S = {1, 2, 4, 7, 8, 11, 13, 14} is a Note: A similar argument cannot be made
group under multiplication modulo 15. for R S.
The identity element for this group is
e = 1 since, x , ∙x mod 5 = x 4. [Ans. B]
Now let the inverse of 4 be . Consider the arrow diagram shown below
Therefore ( ∙ ) mod 15 = e = 1 A B C
(by the definition of inverse) g f
ince ( ∙ ) mod 5 = a 1
 = 4 (This inverse is unique) b 2
Similarly let the inverse of 7 be 7 . 3
(7∙7 ) mod 15 = 1 h
(7.7 ) mod 15 =1 inverse clearly 1,2
h (a) = f∙(g (a)) = 
cannot be 7
7. 5 h (b) = f∙(g (b)) = 
7. 5 Here f is onto but g is not onto, yet h is
onto.
Putting each element of the set as 7 by
As can be seen from the diagram for h to be
trial and error we get (7.1) mod 15= 7,
onto
(7.2) mod 15 =14; (7.4) mod 15 = 13;
f should be onto, but g need not be onto.
(7.7) mod 15 = 4; (7.8) mod 15 = 11;
Answer is (B).
(7.11) mod 15 = 2; (7.14) mod 15 = 8,
(7∙ 3) mod 5 = 9 mod 5 =
5. [Ans. B]
7 =13 a
So and 7 are respectively 4 and 13.
Correct choice is (C).

3. [Ans. C] b c d
R S is an equivalence relation as can be
[{a, b, c, d, e+,≺-
seen from proof given below.
Let xA (x, x)R and (x, x)S(since R
e
and S are reflexive)
(x, x)R S also.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 306
GATE QUESTION BANK DMGT

The poset [{a, b, c, d, e},≺] is a lattice (since | |


Only the choice n! | |
equal to n !. Hence
every pair of elements has LUB and GLB) | |
but it is not a distributive lattice. Because the correct answer must be n! | |
distributive lattice satisfies the following
conditions. For any x, y, z, 10. [Ans. B]
x (y  z) = (x  y)  (x  z) ∑ f(i)just represents | | | | ∙∙∙
x (y  z) = (x  y)  (x  z) | |, because f(i) equals the total number
Where  and  are meet and join of occurrences of element i in the set .
operations respectively.
For given poset [{a, b, c, d, e}≺] ∑ f(i) = 3n ( | | = 3).
b (c  d) = b  a = b
(b c)  (b d) = e e = e
So it is not distributive. (Also, the element 11. [Ans. D]
b has 2 complements c and d, which is not Given | | = x, | | = y and | | = z
possible in a distributive lattice, since, in a =
distributive lattice, complement if exists, is So| | = xy
always unique). Hence it is not a Boolean |E| = | | =
algebra. So the number of distinct functions from Z to
E
6. [Ans. A] = |E|| |
Let A denote the complement of set A. =( ) =
= (A B) C = (A B ) C
= A (B C) 12. [Ans. A]
= (A C) (B C) (x, y) R(u, v) iff x < u and y > v
= (A C ) (B C ) (x, x̅) (x, x) since x x and x x
= (A C ) (B C) So R is not reflexive,
= (A C B ) (A C C) R is neither a partial order, nor an
= A (B C) ( A C C = ∅) equivalence relation.
=
13. [Ans. C]
7. [Ans. B] Let A= {1, 2, 3, 5, 7, 8, 9}
The set C with the subset relation ⊆ is a Construct the Cayley table for any x, y A
total order. Hence the elements of C can be such that
ordered as ⊆ ⊆ ⊆ . We have x * y = (x.y) mod 10
| | | |if i j.  1 2 3 5 7 8 9
The longest possible chain is 1 1 2 3 5 7 8 9
⊆ ⊆ ⊆ ⊆ = A. Hence the 2 2 4 6 0 4 6 8
maximum cardinality of C is n . 3 3 6 9 5 1 4 7
5 5 0 5 5 5 0 5
8. [Ans. C] 7 7 4 1 5 9 6 3
If g is not ONTO, then no way h can be 8 8 6 4 0 6 4 2
ONTO. 9 9 8 7 5 3 2 1
h is ONTO g is ONTO. We know that 0 A. So it is not closed.
Let A = {1}, B = {1, 2}, C = {1}, ( ) = , ( .5)mod A
g(1) = 1, g(2) = 2, shows that h = g of need Therefore, (A) is true.
not be ONTO even when g is ONTO. The identity element = 1
Option ‘A’ is wrong ( ) mod 10 = 1
9. [Ans. C] From the table we see that does not
If A = B, then for any π, exist.
min ,π (A)- = min,π (B)-. Since, (3 7)mod =
7 is the inverse of 3 and 7ϵ A.
Hence the number of permutation π which
(C)is false
satisfy the criterion in this special case is n
!. (D) is true since 8 does not have inverse.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 307
GATE QUESTION BANK DMGT

14. [Ans. C] Again the number of elements divisible by


Consider the following Venn diagram for 5 will be in multiples of 5
= (E F) (F G) i.e., = elements
E Total number of elements divisible by 2
F
and 3 or 5 is 20 + 24 = 44

16. [Ans. B]
E F ( )
U
F G

= (E (E G)) (E F)
= (E (E G)) (E F)
E F

( )
(shaded)

E F

G E G
So X=Y
Or alternatively the solution can be
obtained ( )
From Boolean algebra as follows:
= (E F) (F G)
= EF FG
= EF (FG) Now
= EF (F G) ( )is
= EFF EFG
= EFG
imilarly, = (E (E G)) (E F)
= (E EG) (E F )
= E (EG) EF
= E (E G ) EF , EE = -
= EG EF
= EG (EF )
= EG (E F) And
= EE G EFG
= EFG
X=Y

15. [Ans. D]
=
*n| n 3,
n is divisinle by either , 3 or 5+
The number of elements divisible 2 and 3
must be in a multiple of 6
i.e., 6, , 8, , 3 , …..
The no. of such elements = =

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 308
GATE QUESTION BANK DMGT

And Now ( ) ( ) =?

( ) ( )

=
… . . (A)

And
And is
( ) ( )

… . . (B)

17. [Ans. C]
Now ( ) ( )= f: N N N
If f (a, z) = a = f(z, a) then on element
z N is called the identity
(i). f(x, y) = x y 3 Now f(a, y) = a y 3
f(y, a ) = y + a 3
Clearly f(a, y) = a = f(a, y)for y = 3 and a N
(ii). f(x, y) = max (x, y)
Now f(a, y) = max(a, y)
( )= and f(y, a) = max(y, a)
If we take y = 1 then f(y, a) = f(a, y) = a
always
The identity exists
(iii). f(x, y) = x f(a, y) = a
f(y, a) = y no identity is there but
f(a, y) ≠ f(y, a )for all a N
‘C’ is correct

18. [Ans. A]
And = Let G = {e, a, b, c} be an Abelian group of
order 4, where e is the identity element and
∙ is the group operation. ince the order of
each element divides the order of the
group, ord (a), ord (b) and ord (c) can be
either 2 or 4. If any of the orders is 4 then
the group is cyclic and hence isomorphic to
(the group {0, 1, 2, 3} under addition
modulo 4).
Otherwise, if ord (a) = ord (b) = ord (c) = 2,
then a ∙ a = b ∙ b = c ∙ c = e.
a ∙ b can only be c and similarly
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 309
GATE QUESTION BANK DMGT

b ∙ c = a and c ∙ a = b. 22. [Ans. A]


Hence only two non-isomorphic Abelian = *x |x x x = ,
groups of order 4 exist. where x = (x ,x ,x } )
Let = ( , , ) ( , , )
19. [Ans. C] Clearly ( , , ) ( , , )=( , , )
A partition is called a refinement of the ( , . , . )=( , , )
partition if every set in , is a subset of =
one of the sets in . = } = =
π is a refinement of π , π and π =
π and π are refinements of π contains L. I vectors also
π and π are not comparable since neither For any x
is a refinement of the other. x= ( , , ) ( , , )
So the poet diagram for ( , ≺) is (x , x , x ) = ( , , ) ( , , )
π
forms a basis for the subspace ,
(x , x , x ) = ( , , )
=
π Clearly S spans X
π

23. [Ans. A]
The remaining 3 sets are functionally
π complete
Which is choice (C).
24. [Ans. D]
20. [Ans. B] Let
Let S be a set of n elements say A=( ) ( )
* , , 3,……., n+. Now the smallest = .( ) ( )/ ( )
equivalence relation on S must contain all
the reflexive pairs *( , ), ( , ), (3, 3) …., = ( ) , = U]
(n, n)} and its cardinality is therefore n. = U.
The largest equivalence relation on S is
S × S, which has cardinality n × n = n . 25. [Ans. A]
The largest and the smallest equivalence a
relations on S have cardinalities n and n
respectively. The correct choice is (B).
b
21. [Ans. D] c
It can be seen that ( , ) if and only if
the decimal digit of b at the 10th place is d
greater than or equal to that corresponding It is a lattice because for each pair
to , ≥ . This follows from the fact that supremum and infimum exists
% returns the decimal digit at unit’s a
place and truncates the digit at the
unit’s place.
b c
The rule % % specifies that the
decimal digit of b at the unit’s place must
be decimal digit of b at the unit’s place d
must be greater than or equal to that of a.
The rule ( , ) respectively
specifies this rule for all the other digit
e
positions.
Hence, only (145, 265) and (0, 153) P. is not a lattice because lub (e, d) does not
exist (b and c are not comparable).

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 310
GATE QUESTION BANK DMGT

a 27. [Ans. A]
Group properties are closure, associativity
existence of identity and existence of
b c inverse for every element. Commutativity
is not required for a mathematical
structure to a group.
d e 28. [Ans. D]
Given, R={(x, y),(x, z),(z, x),(z, y)} on the set
{x, y, z}, here (x, y) R but x = z (y, x) R.
f is not symmetric.
is not a lattice since lub (e, d) does not Also (x, z) R and (z, x) R.
exist. is not antisymmetric.
R is neither symmetric nor anti-symmetric.
a
29. [Ans. A]
{S, *} is a group. To be a ring, an integral
c domain, or a field, there must be two
b
binary operations.
d 30. [Ans. C]
e
Let S be a set of n elements. A relation
is a lattice since every pair has lub as well R S×S is reflexive if (r, r) R r S.
as glb. Each of the remaining elements of S×S may
or may not be present in R. Hence the
26. [Ans. C]
number of reflexive relations on S is .
If an element is a generator, all the
When n = 5, the answer is .
elements must be obtained as powers of
that element. 31. [Ans. C]
Try a, b, c, d one by one to see which are Let n = 2. There are only 2 onto functions
the generators. as shown below:
a=a A B
a = a. a = a
a = a. a = a. a = a and so on. a
a is not the generator.
b=b
b = b. b = a b
b = b. b = b. a = b
b = b. b = b. b = a and so on
b is not the generator A B
c=c
c = c. c = b a
c = c. c = c. b = d
c = c. c = c. d = a
Since all of a, b, c, d have been generated as b
powers of c,
c is a generator of this group.
Similarly For n = 2
d=d Option (A) = =
d = d. d = b Option (B) = =3
d = d. d = d. b = c Option (C) = =
d = d. d = d. c = a Option (D) ( )= ( )=
d is the other generator. So only the option (C) gives the correct answer.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 311
GATE QUESTION BANK DMGT

32. [Ans. A] 35. [Ans. A]


x y=x y Since, the roots of f(x) = 0 i.e., x =1 2, 3
x y=y x lies between 0 and 4 and f(x) is of degree 3
As ‘ ’ sign in commutative so x y is f( ) and f(4) are of opposite signs
equal to y x so x y is commutative. f( ). f( ) .
Now check associativity
x (y z) = x (y z ) 36. [Ans. A]
=x (y z ) For statements , (empty set) is example
=x y z y z is larger than all the elements
(x y) z = (x y ) z For statement , (itself * , , ……. +
= (x y ) z is example)
=x y x y z S is smaller than all the elements
x (y z) ≠ (x y) z So option (A) is correct
So not associative
Option (A) is Correct. 37. [Ans. D]
f: defined by f(a) = , f(b) = ,
33. [Ans. *] Range 88.9 to 89.1 f(c) = where
For 10 – pennants we need to consider X = *a, b, c+ = * , +
minimum 5 coordinates, maximum 10 Let A = {a, c}, B = {b, c} be subsets of X
coordinates in n – tuple Then |f(A B)| = 2; |f(A)| = 2 ; |f(B)| = 2
For 5 – tuple all entries are 2 [i.e (2, 2, 2, 2,2)] f(A B) = * + f(A) = * , + f(B) = * , +
So no. of 5 – tuples = 1 f(A) f(B) = * , +
For 6 – tuple 4 entries are 2 (remaining are |f(A B)| = 1
1) So no.of 6 – tuples 6 = 5 ptions (A), (B)and (C) are not true
For 7 – tuple 3 entries are 2 (remaining are Hence, option (D) is correct
1) so no.of 7 – tuples 7 = 35
38. [Ans. B]
For 8 – tuple 2 entries are 2 (remaining are a. Since f(f(i)) = i
1) so no.of 8 – tuples 8 = 8
Every element in codomain has some
For 9 – tuple 2 entries are 2 (remaining are
pre image. So f is onto. So R is true
1) so no.of 9 – tuples 9 = 9
b. To have this type function we can have
For 10 – tuple all entries are [ie. (1, 1, 1, 1,
either
1, 1, 1, 1, 1, 1) so no.of 10 – tuples = 1]
No.of 10 pennants ption f(i) = i i
= 5 35 8 9 = 89 In this case P, Q are both true
Option 2 Take any pair x, y in
34. [Ans. 16] * , , ……. + and map f(x) = y, f(y) = x
If |A| = m, |B| = n then the no. of functions Do like this for all pairs
from A to B is …..( ) ince * , , , ……. + contains odd of
And | | = ….( ) elements, one element ‘z’ will be left finally
Given S is set of all function of For that element we must have f(z) = z
f: * , + * , + So in this case only Q is true
(A) (B) P is false
By (2) domain (A) contains elements nly , are true
So S contains function (by (1)) o option (B) is correct
Given N is the no.of function from S to {0, 1}
39. [Ans. 4]
So N = (by( )) Given x ∗ x = e y ∗ y = e, x ∗ y ∗ x ∗ y = e,
So y ∗ x ∗ y ∗ x = e ………( )
log log N From (1) we can observe for any number
= log log of x, y’s (in any order) the result of binary
operation ∗ is e except for one x, y
= log = = 6 [for example x ∗ y ∗ y ∗ x = x ∗ e ∗ x = x ∗
x = e]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 312
GATE QUESTION BANK DMGT

And also we can observe that the group is


abelian. So the possible elements
x
y
}
e 3
x y
And for any other combination of x, y’s.
So the group contains almost 4 elements

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 313
GATE QUESTION BANK DMGT

Graph Theory
CS – 2005 CS - 2006
1. Let G be a directed graph whose vertex set Common Data for Questions 4, 5, 6:
is the set of numbers from 1 to 100. There The vertices of a graph G correspond
is an edge from a vertex i to a vertex j iff to all subsets of a set of size n, for n 6.
either j = i + 1 or j = 3i. The minimum Two vertices of G are adjacent if and only
number of edges in a path in G from if the corresponding sets intersect in
vertex 1 to vertex 100 is: exactly two elements.
(A) 4 (C) 23 4. The number of vertices of degree zero in
(B) 7 (D) 99 G is
(A) 1 (C) n +1
2. Let G be a simple connected planar graph (B) n (D)
with 13 vertices and 19 edges. Then, the
number of faces in the planar embedding 5. The maximum degree of a vertex in G is
of the graph is (A) ( ) (C)
(A) 6 (C) 9 (B) (D)
(B) 8 (D) 13
6. The number of connected components in
3. Which one of the following graphs is NOT G is
planar? (A) n (C)
( )
(B) n +2 (D)

7. Consider the undirected graph G defined


as follows. The vertices of G are bit
strings of length n. We have an edge
between vertex u & vertex v only if u and
( ) v differ in exactly one bit position (in
other words, v can be obtained from u by
flipping a single bit). The ratio of the
chromatic number of G to the diameter of
G is
(A) (C) 2 / n
(D) 3 / n
(B) 1 / n
( ) CS - 2007
8. Which of the following graphs has an
Eulerian circuit?
(A) Any k-regular graph where k is an
even number
(B) A complete graph on 90 vertices
(C) The complement of a cycle on 25
( )
vertices
(D) None of the above

9. Let G be the non-planar graph with the


minimum possible number of edges.
Then G has
(A) 9 edges and 5 vertices
(B) 9 edges and 6 vertices
(C) 10 edges and 5 vertices
(D) 10 edges and 6 vertices

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 314
GATE QUESTION BANK DMGT

CS- 2008 (A) I and II


10. What is the chromatic number of the (B) III and IV
following graph? (C) IV only
(D) II and IV

15. Let G = (V, E) be a graph. Define


(G) = id  d where is the number of
d

vertices of degree d in G. If S and T are


two different trees with (S) = (T), then
(A) | S | = 2| T |
(B) | S | = | T | 1
(C) | S | = | T |
(A) 2 (C) 4 (D) | S | = | T | + 1
(B) 3 (D) 5
CS - 2011
11. G is a simple undirected graph. Some 16. K4 and Q3 are graph with the following
vertices of G are of odd degree. Add a structures.
node v to G and make it adjacent to each K4 Q3
odd degree vertex of G. The resultant
graph is sure to be
(A) Regular
(B) Complete
(C) Hamiltonian
(D) Euler

CS - 2009 Which one of the following statements is


12. Which one of the following is TRUE for any TRUE in relation to these graphs?
simple connected undirected graph with (A) K4 is planar while Q3 is not
more than 2 vertices? (B) Both K4 and Q3 are planar
(A) No two vertices have the same (C) Q3 is planar while K3 is not
degree (D) Neither K4 nor Q3 is planar
(B) At least two vertices have the same
degree CS – 2012
(C) At least three vertices have the same 17. Let G be a simple undirected planar graph
degree on 10 vertices with 15 edges. If G is a
(D) All vertices have the same degree connected graph, then the number of
bounded faces in any embedding of G on
13. What is the chromatic number of an the plane is equal to
n-vertex simple connected graph which (A) 3 (C) 5
does not contain any odd length cycle? (B) 4 (D) 6
Assume n
(A) 2 (C) n – 1 18. Which of the following graphs is
(B) 3 (D) n isomorphic to

CS - 2010
14. The degree sequence of a simple graph is
the sequence of the degrees of the nodes
in the graph in decreasing order. Which of
the following sequences cannot be the
degree sequence of any graph?
I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III. 7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 315
GATE QUESTION BANK DMGT

( ) ( ) CS – 2014
23. Let G=(V,E) be a directed graph where V
is the set of vertices and E is the set of
edges. Then which one of the following
graphs has the same strongly connected
( ) components as G ?
( ) ( )
(A)
*( ) ( ) +
(B) ( )
*( ) ( ) +
(C) ( )
19. Let G be a complete undirected graph on
6 vertices. If vertices of G are labeled, then *( )
the number of distinct cycles of length 4 }
in G is equal to (D) ( ) is the set of
(A) 15 (C) 90 vertices in
(B) 30 (D) 360
24. Consider the direct graph given below
CS - 2013
20. Which of the following statement is/are P Q
TRUE for undirected graphs?
P: Number of odd degree vertices is even.
Q: Sum of degrees of all vertices is even
(A) P only
(B) Q only R S
(C) Both P and Q
(D) Neither P nor Q Which one of the following is true?
(A) The graph does not have any
21. Consider an undirected random graph of topological ordering
eight vertices. The probability that there (B) Both PQRS and SRQP are topological
is an edge between a pair of vertices is
ordering
1/2. What is the expected number of
unordered cycles of length three? (C) Both PSRQ and SPRQ are topological
(A) 1/8 (C) 7 ordering
(B) 1 (D) 8 (D) PSRQ is the topological ordering

22. The line graph L(G) of a simple graph G is 25. Consider an undirected graph G where
defined as follows: self-loops are not allowed. The vertex set
 There is exactly one vertex v(e) in of G is
L(G) for each edge e in G. *( ) +. There is
 For any two edges e and e' in G, L(G) an edge between (a, b) and (c, d)
has an edge between v(e) and v(e'), if b .T b
and only if e and e' are incident with of edges in this graph is __________.
the same vertex in G.
Which of the following statements is/are 26. An ordered n tuple ( ) with
TRUE? is called graphic if there
P. The line graph of a cycle is a cycle. exists a simple undirected graph with n
Q. The line graph of a clique is a clique. vertices having degrees
R. The line graph of a planar graph is planar. respectively. Which of the following
S. The line graph of a tree is a tree. 6-tuples is NOT graphic?
(A) P only (A) (1, 1, 1, 1, 1, 1)
(B) P and R only (B) (2, 2, 2, 2, 2, 2)
(C) R only (C) (3, 3, 3, 1, 0, 0)
(D) P, Q and S only
(D) (3, 2, 1, 1, 1, 0)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 316
GATE QUESTION BANK DMGT

27. The maximum number of edges in a


bipartite graph on 12 vertices is __________.

28. A cycle on n vertices is isomorphic to its


complement. The value of n is ________.

29. The number of distinct minimum


spanning trees for the weighted graph
below is ________
2

2 1 1
2

2 2
2 1
1 1

2 2

30. Let G be a group with 15 elements. Let L


be a subgroup of G. I k L≠
and that the size of L is at least 4. The size
of L is __________.

31. If G is a forest with n vertices and k


connected components, how many edges
does G have?
(A) ⌊ k⌋
(B) ⌈ k⌉
(C) n – k
(D) n – k + 1

32. L δ
vertex in a graph. For all planar graphs
δ
following is TRUE?
(A) In any planar embedding, the
number of faces is at least
(B) In any planar embedding, the
number of faces is less than
(C) There is a planar embedding in
which the number of faces is less
than
(D) There is a planar embedding in
which the number of faces is at most

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 317
GATE QUESTION BANK DMGT

Answer Keys and Explanations


1. [Ans. B] Since we want exactly 2 elements in
Since along any path, at each step the common, we can choose these in
vertex labels can atmost be triple and ways and then we can add or not add
since ⌈ ⌉ , we must have the remaining n 3 elements.
shortest path length from vertex 1 to 100 This can be done in ways.
greater than or equal to 5. The path ∴ Total number of subsets with at least 2
elements in common with {1, 2, 3} is
shows that the shortest path length is less given by and for 4 elements
than or equal to 7. It can be shown that subsets is for 5 elements
the shortest path length cannot be 5 or 6,
subsets is and so on.
hence it is 7.
Out of these
is less than
2. [Ans. B]
Given V = 13, E = 19
Let R be the number of regions. Then is same as
R = E – V +2
and is greater
than
3. [Ans. A]
is same as which is known to be ∴ The maximum degrees in this graph is
non-planar. G2, G3 and G4 can be redrawn occurring for 3 element and 4 element
as follows so they are planar. subsets both of which have
degrees which is correct answer.

6. [Ans. B]
The number of connected components
in G is determined by the degree of
vertices and edges of vertices. There are
vertices whose degree is zero, so
4. [Ans. C] they can form connected
The vertices of degree zero are vertex
components. The remaining vertices of
corresponding to the empty set, and those
the graph G are all connected as a single
corresponding to the singleton sub-sets of
component. So the total number of
the given set of n elements. Hence the
number of vertices of degree 0 is n + 1. connected component is .

7. [Ans. C]
5. [Ans. C]
The shortest distance between two
L b S * 4 . +
vertices u and v whose corresponding
Consider a subset containing 2 elements
bit strings are at hamming distance d is
of the form {1, 2}. Now {1, 2} will be
adjacent to any subset with which it has of length d. Hence, the diameter of G is
exactly 2 elements in common. These sets n. Also, since all the paths between any
can be formed by adding zero or more two given vertices are all of odd length
elements from remaining n 2 elements and are all of even length, we get that
to the set {1, 2}. Since each of these the chromatic number of G is 2. Hence
elements may be either added or not the required ratio is .
added, number of ways of making such
sets containing 1 and 2 is . 8. [Ans. A]
∴ The vertices with 2 elements will have Any k regular graph for k (even no)
degrees. Eulerian circuit because we have a result
Now consider the subsets of 3 elements y “
say {1, 2, 3}
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 318
GATE QUESTION BANK DMGT

every vertex has even degree, then it has (B) Complete graph on 90 vertices does
” not contains Euler circuit, because
And since k – regular graph where k-even every vertex has odd degree odd(89)
number is connected and every vertex is (C) The complement of a cycle on 25
of even degree ∴ Option (A) is correct vertices must contain Euler circuit,
where of each vertex is even (22)
9. [Ans. B]
K5 and are the smallest non planar 13. [Ans. A]
graphs. K5 has 5 vertices and = 10 If a n-vertex simple connected graph
contains no cycles of odd length, then its
edges and has 6 vertices and
chromatic number is two. Since the
edges. So, the non planar graph
vertices can be alternately colored with
with the minimum number of edges is
the first color, the second color, then the
with 9 edges and 6 vertices.
first color and the second color and so on.
Note: K5 is the non planar graph with the
Alternatively, since a simple connected
minimum number of vertices.
graph with no cycles of odd length must
10. [Ans. B] be bipartite, and since the chromatic
number of bipartite graph is always 2 (in
b b
a c a bipartite graph each partition requires
one color there are no edges within a
partition of a bipartite graph and there
d
are only two partitions).
14. [Ans. D]
e
The length of a degree sequence gives the
Let us try to color the graph with two number of vertices in the corresponding
colors. graph. All the given sequences have
From the path (a, b, c, d, e), we see that a length equal to 8, since graphs are simple,
and e must be colored with the same no vertex can have degree more than 7.
color. But this is not possible since there ∴ The sequence 8, 7, 7, 6, 4, 2, 1, 1 is not
is an edge between a and e. It is easy to possible.
see that 3 colors sufficient. A pattern of A vertex can have degree 6 when it is
coloring is given and we can observe that connected to every other, except one.
the chromatic number of the given graph When there are four vertices of degree six
is 3. each, then there are at most two vertices
of degree two each (if no vertex is of
11. [Ans. D] degree 1), in which case other vertices
A connected graph has an Euler circuit if are of degree at least 4. Hence the
and only if every vertex is of even degree. sequence 6, 6, 6, 6, 3, 3, 2, 2 cannot be
A K-regular graph has all vertices of possible.
degree K each. Hence if K is even, a The other two sequences are possible.
connected K-regular graph has an Euler
circuit. 15. [Ans. C]
Given, ( ) = i  d = Sum of degrees
d
d
12. [Ans. C]
Whenever in a graph of vertices have By handshaking lemma, ( )
even degrees, it will surely have an Euler where, is the number of edges in G.
circuit. If S and T are two trees with (S) (T).
(A) Since in a k-regular graph, every
vertex has exactly k degrees and if k
is even, every vertex in the graph has In a tree, S and T
even degrees. k-regular graph need Where |S| is the number of vertices of
not be connected, hence k-regular tree S and |T| is the number of vertices of
graph may not contain Euler circuit tree T.
∴ S T S T

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 319
GATE QUESTION BANK DMGT

16. [Ans. B] 20. [Ans. C]


Both the graphs are planar as can be seen P : Number of odd degree vertices is even
from their planar representation. Q : Sum of degree of all vertices is even
Q is true.
Reason: Calculating the sum of degrees of
all vertices. Take any edge, it is joining
two vertices (not necessarily distinct),
hence contribution 2 in the sum of
17. [Ans. D]
n = 10 degrees.
e = 15 H ‘ ’
In a simple connected planar graph, all vertices is 2e (is even)
’ b Note: It is valid even in case of self loops
regions as e P is also true:
Out of this, one region is unbounded and
Reason: We have established that sum of
the other 6 are bounded.
So correct answer is 6, which is Option (D). degree of all vertices is even
Let us assume, that the number of odd
18. [Ans. B] degree vertices is odd, so, the
Check invariants are one by one. contribution of odd degree vertices in
Step 1: All 4 choices have same number of
total sum is odd
vertices and edges as given graph.
Step 2: So we find degree sequence of Now the contribution of even degree
given graph which is (1, 1, 2, 2, 2, 2, 2, 4). vertices is also even (whether the number
Degree sequence of graph in option (A) is is even or odd). So, total sum becomes
(1, 1, 1, 2, 2, 2, 3, 4). odd, which is not possible. Hence P is true
Degree sequence of graph in option (B) is Note: Include vertex of degree zero in
(1, 1, 2, 2, 2, 2, 2, 4). even degree vertices.
Degree sequence of graph in option (C) is
(1, 1, 2, 2, 2, 2, 3, 3). 21. [Ans. C]
Degree sequence of graph in option (D) is
We need to find unordered cycles of
(1, 1, 2, 2, 2, 2, 2, 4).
So only options (A) and (C) are not length 3 so we choose any 3 vertices from
isomorphic to given graph, since degree 8 vertices. This can be done in ways.
sequence of these graphs is not same as To make a cycle we need to choose edge
given graph. between the selected vertices. The
Step 3: Now to decide between option (B) probability of choosing any edge is 1/2.
and (D), which one is isomorphic to given
graph, we check the number of cycles. So for three edges =
In given Graph there is one cycle of length 5. Expected no. of cycle = ∑ ( )
But in Graph (B) has one cycle of length 5.
So only Graph (B) can be isomorphic to
given Graph.

19. [Ans. C] 22. [Ans. A]


The graph given is K6 L ‘ ’b y .I L( )
In K6, every cycle of length 4 corresponds 1. There will be an edge between two
to selecting 4 vertices out of 6 vertices, vertices corresponding to the
which can be done in ways and then adjacent edges in the cycle
ordering the 4 vertices in circular 2. Degree of each vertex in L(C) will be z.
permutation in 3! ways (since vertices are
3. L(C) will be connected.
labeled). So final answer is .
Hence L(C) will also be a cycle So, (P) is True

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 320
GATE QUESTION BANK DMGT

(Q) L ‘ n’ b q ‘ ’ . matrix (1). Out of 144 vertices, 100


Consider line graph L(Kn). vertices are like this no.of edges for these
 L(Kn) has vertices = 800
 For n>3, there will be two edges say Out of the remaining 44 vertices, the
e1, e2 “ n” corner vertices [ie. (1, 1), (1, 12), (12, 1),
“ n” (12, 12)] has 3 edges as shown in matrix
 So V(e1), V(e2) will not be adjacent in (2) so 4
L(Kn). The remaining 40 vertices has 5 edges as
 Hence L(Kn) is not always a clique shown in matrix (3) so 4 5=200
(Q) is False So total no of edges
=
23. [Ans. B] Since the graph is undirected no.of edges
Take an example for Graph G =
. .
A B 26. [Ans. C]
Then option A and D will be eliminated. Apply Havel – Hakimi algorithm to the
Let G is below graph four options
A B Option (A)
Then is a graph with below structure
( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1)

A B ( 1, 1, 1, 1) ( 1, 1)
In G the number of strongly connected
( 0, 0)
components are 2 ,where as in it is (1, 1)
only one.
Got all zeros so graphic
24. [Ans. C]
PQRS is not a topological ordering Option (B)
because no edge is there from Q to R
( 2, 2, 2, 2, 2, 2) ( 1, 1, 2, 2, 2)
PSRQ and SPRQ are topological
ordering because ( 1, 1, 1, 1)
( 2, 2, 2, 1, 1)
S Q and
Q exits ( 1, 1,)
( 1, 1, 1, 1)
b y y ( 0, 0)
(1, 1)
25. [Ans. 506]
Given vertex set is Got all zeros so graphic
V = {(i, j)|1 } Option (C)
Imagine vertex set as a matrix as follows 2 2 0
(3, 3, 3, 1, 0, 0) (2, 2, 0, 0, 0)
( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( ) 1
( ) ( ) ( ) ( ) ( ) ( ) (2, 2, 0, 0, 0) (1, 0, 0)
( ) ( )
( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( ) Got negative number. So it is not graphic
( ) ( ) ( ) ( ) ( ) ( )
Option (C) is correct
[ ( ) (4) ]

All the vertices (except in 1st row, 1st


column, last row, last column) has 8 edges
to the neighboring vertices as shown in

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 321
GATE QUESTION BANK DMGT

27. [Ans. 36] group is not equal to given group. Thus the
Max no.of edges in bipartite graph on n order cannot be 3 or 5. Hence it is 5.
vertices is given by ⌊ ⌋
31. [Ans. C]
If G is a tree with n vertices then
. ⌊ ⌋
4 no.of edges = n – 1
If G is forest (collection of trees) with k
28. [Ans. 5] connected components then the edges
Result 1: In a cycle graph = n – k.
no.of vertices = n, edges = n ∴Option (C) is correct
Result 2: If a graph G is isomorphic to its
( ) 32. [Ans. A]
complement then E(G) =
( ) By Euler formula
S
.( )
4=n–1 By Hand shaking theorem.
n=5
∑ ( )

29. [Ans. 6] δ
In graph portion δ .
δ
2 1
, δ -
2 2 From (1) we have
Two ST are possible f=2+e–v
2 1 =2+e–n

2 2 2
And in subgraph
∴ So no. of faces is atleast
2
Option (A)is answer
2 1
1

2
Three ST possible
2
1 1 1 1
1 2 1 2
So these two sub graphs are divided by only
single edge
So total no. of ST

30. [Ans. 5]
L ’
subgroup divides order of group.
3, 5, 15 can be the order of subgroup in this
problem since there are 4 elements and the

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 322
GATE QUESTION BANK DBMS

ER Diagrams
CS – 2005 (A) Person
1. Let and be two entities in an ER (B) Hotel Room
diagram with simple single-valued (C) Lodging
attributes. R1 and R2 are two relationships (D) None of these
between and , where R1 is
one-to-many and R2 is many-to-many. R1 CS - 2008
and R2 do not have any attributes of their Linked Answer Questions 4 & 5
own. What is the minimum number of Consider the following ER diagram
tables required to represent this situation
in the relational model?
(A) 2 (C) 4
(B) 3 (D) 5

2. The following table has two attributes A 4. The minimum number of tables needed to
and C where A is the primary key and C is represent M, N, P, R1, R2 is
the foreign key referencing A with (A) 2 (C) 4
on-delete cascade. (B) 3 (D) 5
A C
2 4 5. Which of the following is a correct
3 4 attribute set for one of the tables for the
4 3 correct answer to the above question?
5 2 (A) {M1, M2, M3, P1}
7 2 (B) {M1, P1, N1, N2}
9 5 (C) {M1, P1, N1}
6 4 (D) {M1, P1}
The set of all tuples that must be
additionally deleted to preserve CS - 2012
referential integrity when the tuple (2, 4) 6. Given the basic ER and relational models,
is deleted is: which of the following is INCORRECT?
(A) (3,4) and (6,4) (A) An attributes of an entity can have
(B) (5,2) and (7,2) more than one value
(C) (5, 2) (7, 2) and (9, 5) (B) An attribute of an entity can be
(D) (3, 4) (4, 3) and (6, 4) composite
(C) In a row of a relational table, an
3. Consider the entities ‘hotel room’, and attribute can have more than one
‘person’ with a many to many relationship value
‘lodging’ as shown below: (D) In a row of a relational table, an
attribute can have exactly one value
HotelRoom Lodging Person or a NULL value

If we wish to store information about the


rent payment to be made by person(s)
occupying different hotel rooms, then this
information should appear as an attribute
of

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 323
GATE QUESTION BANK DBMS

Answer Keys and Explanations

1. [Ans. B] 4. [Ans. B]
1: N M, P ⟶ Entity sets, will become tables
N ⟶ Weak Entity set, will become a table
R1 ⟶ Relationship set with cardinality
E1 E2 N:1, will not be a table
R2 ⟶ Identifying Relationship set, will
not be a table
Total No of tables = 3
N: N
1) M=(M1, M2, M3, P1)
E1, E2 are entities will become tables 2) P =(P1, P2)
Relationship with cardinality 1:N 3) N =(N1, P1, N2)
will not be a table
[Primary key of 1- side [E1] will be 5. [Ans. A]
included as foreign key of N – side [E2]] The correct attribute set is
Relationship with cardinality N:N {M1, M2, M3, P1}
will become a table.
Total No of tables = 3 = {E1, E2, } 6. [Ans. C]
⟶ An attribute of an Entity can be atomic,
2. [Ans. C] Multi-valued, and composite.
A rimary key Parent column ⟶ An attribute (or) column of a table
C Foreign key Child column must take exactly one value (or) a NULL
“C” refers to “A” O -DELETE CASCADE, value.
when parent gets deleted, all Option A ⟶Correct, Multivalued
corresponding child rows will be deleted Attribute
automatically. Option B ⟶Correct, Composite Attribute
(2, 4) is deleted [Parent =2] (5, 2) and Option C ⟶Incorrect, since column
(7, 2) will get deleted cannot take multiple values
(5, 2) is deleted [Parent = 5] (9, 5) will Option D ⟶ Correct, column in a table
get deleted takes single value (or) NULL.
(9, 5) is deleted [Parent = 9] no child
rows for parent = 9
(7, 2) is deleted [Parent = 7] no child
rows for parent = 7
Total no. of parents deleted = {2, 5, 9, 7}
Total no. of rows deleted
= {(5, 2), (7, 2), (9, 5)}

3. [Ans. C]
“rent payment” is a descriptive attribute,
because it is related to the Lodging
Relationship.
“rent ayment” neither belongs to
Hotel Room nor to a Person Entity Sets.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 324
GATE QUESTION BANK DBMS

Functional Dependencies & Normalization

CS – 2005 CS - 2006
1. Which-one of the following statements 5. The following functional dependencies
about normal forms is FALSE? are given:
(A) BCNF is stricter than 3NF AB→ CD, AF →D, DE→ F, C →G, F→ E,
(B) Lossless, dependency-preserving G→ A
decomposition into 3NF is always Which one of the following options is
possible false?
(C) Lossless, dependency-preserving (A) {CF}+ = {ACDEFG}
decomposition into BCNF is always (B) {BG}+ = {ABCDG}
possible (C) {AF}+ = {ACDEFG}
(D) Any relation with two attributes is in (D) {AB}+ = {ABCDG}
BCNF
6. Consider a relation R with five attributes
2. Consider a relation scheme V, W, X, Y and Z. The following functional
R= (A, B, C, D, E, H) on which the dependencies hold:
following functional dependencies hold: VY → W, WX → Z, and ZY → V. which of
*A→ B, BC →D, E →C, D →A+. What are the the following is a candidate key for R?
candidate keys of R? (A) VXZ (C) VWXY
(A) AE, BE (B) VXY (D) VWXYZ
(B) AE, BE, DE
(C) AEH, BEH, BCH CS - 2007
(D) AEH, BEH, DEH 7. Which one of the following statements is
FALSE?
3. A table has fields F1, F2, F3, F4, F5 with (A) Any relation with two attributes is in
the following functional dependencies BCNF.
F1 → F3; F2 → F4; (F1. F2) → F5 (B) A relation in which every key has
In terms of Normalization, this table is in only one attribute is in 2NF.
(A) 1 NF (C) 3 NF (C) A prime attribute can be transitively
(B) 2 NF (D) None of these dependent on a key in a 3NF relation.
(D) A prime attribute can be transitively
4. In a schema with attributes A, B, C, D and dependent on a key in a BCNF
E following set of functional dependencies relation.
are given
8. Consider the following implications
A B
relating to functional and multivalued
A C
dependencies given below, which may or
CD E
may not be correct.
B D
E A i) If A B and A C then A → BC
Which of the following functional ii) If A→B and A→C then A BC
dependencies is NOT implied by the iii) If A BC and A →B and A → C
above set? iv) If A →BC and A B and A C
(A) CD AC (C) BC CD Exactly how many of the above
(B) BD CD (D) AC BC implications are valid?
(A) 0 (C) 2
(B) 1 (D) 3
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 325
GATE QUESTION BANK DBMS

CS - 2008 (C) UID is a candidate key if all students


9. Consider the following relational schemes are from the same country
for a library database: (D) If S is a superkey such that S∩UID is
Book (Title, Author, Catalog_no, NULL then S UID is also a superkey
Publisher, Year, Price)
Collection (Title, Author, Catalog_no) CS - 2012
With the following functional 11. Which of the following is TRUE?
dependencies: (A) Every relation in 3NF is also in BCNF
i) Title Author→ Catalog_no (B) A relation R is in 3NF if every non-prime
ii) Catalog_no →Title, Author, Publisher, attribute of R is fully functionally
Year dependent on every key of R
iii) Publisher, Title, Year → Price (C) Every relation in BCNF is also in 3NF
Assume {Author, Title} is the key for both (D) No relation can be in both BCNF and
schemes. Which of the following 3NF
statements is true?
(A) Both Book and Collection are in CS - 2013
BCNF Statement for Linked Answer Questions 12
(B) Both Book and Collection are in 3NF and 13
only Relation R has eight attributes
(C) Book is in 2NF and Collection is in ABCDEFGH. Fields of R contain only
3NF atomic values.
(D) Both Book and Collection are in 2NF F={CH →G, A →BC, B → CFH, E →A,
only F→EG+ is a set of functional dependencies
(FDs) so that F is exactly the set of FDs
CS - 2011 that hold for R.
10. Consider a relational table with a single 12. How many candidate keys does the
record from each registered student with relation R have?
the following attributes. (A) 3 (C) 5
1. Registration_Num: Unique (B) 4 (D) 6
registration number of each
registered student 13. The relation R is
2. UID: Unique identity number, unique (A) In 1NF, but not in 2NF
at the national level for each citizen (B) In 2 NF, but not in 3 NF
3. BankAccount_Num: Unique account (C) In 3NF, but not in BCNF
number at the bank. A student can (D) In BCNF
have multiple accounts or joint
accounts. This attribute stores the CS - 2014
primary account number 14. Consider the relation scheme
4. Name: Name of student R = (E, F, G, H, I, J, K, L, M, N) and the set
5. Hostel_Room: Room number of the of functional dependencies {*E, F+ → *G+,
hostel *F+ → *I, J+, *E, H+ → *K, L+, *K+ → *M+,
Which of the following options is *L+ → *N+} on R. What is the key for R?
INCORRECT? (A) {E, F} (C) {E, F, H, K, L}
(A) BankAccount_Num is a candidate key (B) {E, F, H} (D) {E}
(B) Registration_Num can be a primary
key

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 326
GATE QUESTION BANK DBMS

15. Given the following statements:


S1: A foreign key declaration can always
be replaced by an equivalent check
assertion in SQL.
S2: Given the table R(a, b, c) where a and
b together form the primary key, the
following is a valid table definition.
CREATE TABLE S (
a INTEGER,
d INTEGER,
e INTEGER,
PRIMARY KEY (d),
FOREIGN KEY (a) references R)
Which one of the following statements is
CORRECT?
(A) S1 is TRUE and S2 is FALSE.
(B) Both S1 and S2 are TRUE.
(C) S1 is FALSE and S2 is TRUE.
(D) Both S1 and S2 are FALSE.

16. Given the following two statements:


S1: Every table with two single-valued
attributes is in 1NF, 2NF, 3NF and BCNF.
S2: AB → C, D → E, E → C is a minimal
cover for the set of functional
dependencies AB → C, D → E, AB → E,
E → C.
Which one of the following is CORRECT?
(A) S1 is TRUE and S2 is FALSE.
(B) Both S1 and S2 are TRUE.
(C) S1 is FALSE and S2 is TRUE.
(D) Both S1 and S2 are FALSE.

17. The maximum number of superkeys for


the relation schema R(E,F,G,H) with E as
the key is _____________.

18. A prime attribute of a relation scheme R is


an attribute that appears
(A) in all candidate keys of R.
(B) in some candidate key of R.
(C) in a foreign key of R.
(D) only in the primary key of R.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 327
GATE QUESTION BANK DBMS

Answer Keys and Explanations

1. [Ans. C] Highest normal form of Relation =


2NF, 3NF decomposition ⟶ guarantees Least normal form among all FD’s
both dependency preservation and loss NF
less join.
BCNF decomposition ⟶ Only guarantees 4. [Ans. B]
loss less join. Relation = R(A, B, C, D)
BCNF decomposition, at times satisfies F Set of FD’s *( ) A → B
dependency preservation and at times ( )A→C
not. ( ) CD → E
BCNF wont guarantee the dependency ( )B→D
preservation property. ( ) E → A+
Option (A):- CD → AC→ Correct
2. [Ans. D] ( )CD → E
] By transitivity
Relation = R(A, B, C, D, E, H) ( )E → A
Set of FD’s are CD → A CD → C
] ] CD → AC
( )A → C CD → A
(By union rule)
1)A⟶B
Option (B):- BD →CD Cannot be
2)BC⟶D
derived from given set of FD’s
3)E⟶C
Option (C):- BC→CD can be derived
4)D⟶A
(4)B→D, By Augmentation rule BC→CD
A B C D E H
AEH       Option (D):- AC→BC Can be derived
BEH       ( )A→B+→By augmentation rule
DEH       AC → BC
Candidate key = {AEH, BEH, DEH}
5. [Ans. C]
3. [Ans. A] Relation=R(ABCDEFG)
Table has fields Simple attributes Set of FD’s F are
= F1, F2, F3, F4, F5
F=set of FD’s 1) AB → CD
2) AF → D
( )F → F Candidate key 3) DE → F
( )F → F ] =(F1, F2)[F1+F2] 4) C→G
( )F , F → F Prime Attribute 5) F→E
= {F1, F2} 6) G→A
A B C D E F G
Now we will assign the highest normal
CF       →ACDEFG
form to each FD BG      →ABCDG
1) FD : F → F is in 1NF, since it violated AF     →ADEF
NF. “F is part of key. AB      →ABCDG
2) FD : F → F also violated NF, since As closure of AF = AF = {ADEF}
“F ” is part of key. Option (C) is incorrect.
3) FD : F , F , → F is in BCNF, since
(F1, F2) is key

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 328
GATE QUESTION BANK DBMS

6. [Ans. B] 10. [Ans. A]


Relation = R(V, W, X, Y, Z) Since students can have joint accounts,
F Set of FD’s *VY → W, WX → Z, ZY→ V+ two students can have same bank account
V W X Y Z number. So, BankAccount_Num can not be
VXZ      candidate key.
VXY     
Candidate key VXY 11. [Ans. C]
A table is said to be in BCNF if it is already
7. [Ans. D] in 3 NF and all determinants are keys
Statement (D) is false because in BCNF
relation a prime attribute can’t be 12. [Ans. B]
transitively dependent on a key. Relation = R(ABCDEFGH)
F Set of FD’s are
8. [Ans. C]
In DBMS, we can see that 1) CH→G
If A ⟶⟶ B and A ⟶⟶ C then A ⟶ BC 2) A→BC
and A ⟶⟶ BC then A ⟶ B and A ⟶ C 3) B→CFH
Hence answer is (C). 4) E→A
5) F→EG
9. [Ans. C] A B C D E F G H
1) Book (Title, Author, Catalog-NO, CH   
Publisher, Year, Price) A        
FD’s on book are B        
I. Title, Author → Catalog-NO E        
II. Catalog-NO → Title, Author, F        
Publisher, Year Candidate keys are *AD, BD, ED, FD+
III. Publisher, Title, Year → Price
Key = {Author, Title} 13. [Ans. A]
Prime Attributes = {Author, Title} Candidate keys = {AD, BD, ED, FD}
FD1: Title, Author → Catalog-NO is in Prime attributes = {A, B, D, E, F}
BCNF. Let’s assign highest Normal form to each
FD2: Catalog-NO → Title, Author, FD
Publisher, Year has to be decomposed 1) CH → G is in NF
→ FD . : Catalog-NO→ Title is in NF 2) A → BC can be treated as
A → B is in NF
→ FD . : Catalog-NO → Author is in 2NF
A → C is in NF,A is part of key-
→ FD . : Catalog-NO → Publisher is in NF
3) B → CFH can be written as
→ FD . : Catalog-NO → Year is in 2NF
B → C is in NF
FD3: Publisher, title, year→ Price is in 2NF B → F is in NF
Book is in 2NF B → H is in NF
2) Collection (Title, Author, Catalog-NO) 4) E → A is in NF, Since “A” is prime
FD’s on collection are 5) F → EG can be written as
( ) Title, Author → Catalog-NO F → E is in NF
Key = {Author, Title} F → G is in NF
Prime Attributes = {Author, Title} Relation is in 1NF only.
FD : Title, Author → Catalog-NO is in BCNF
Collection is in BCNF
[In 3NF, 2NF, 1NF also]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 329
GATE QUESTION BANK DBMS

14. [Ans. B] which is a single valued attribute and it is


Relation = R (EFGHIJKLMN) referencing the primary key (ab) of
F Set of FD’s are relation R (a, b, c), which is a composite
key.
1) EF → G A single value attribute cannot refer a
2) F → IJ composite key.
3) EH → KL
S is false
4) K→M
5) L→N
16. [Ans. A]
E F G H I J K L M N S1 is true because if R(a, b) is relation
E  and a → b is dependency then this
EF      relation is in 1NF, 2NF, 3NF and BCNF
EFH           S2 is false because AB → E cannot be
removed from minimal cover.
Key EFH
17. [Ans. 8]
15. [Ans. D] Given Relation = R (E, F, G, H)
S1: Manager (Name, DeptID) Key = E
Department (Dept Name, Deptid) Maximum no. of Super Keys = ?
In a given relation Manager DeptID is a SNo SUPER KEYS
foreign key referencing Deptid (P.K) of 1 {E}
relation Department. 2 {E, F}
Let’s declare the foreign key by an 3 {E, G}
equivalent check assertion as follows:-
4 {E, H}
CREATE TABLE Manager (Name
5 {E, F, G}
Varchar (10),
6 {E, G, H}
DeptID INT (6), check (DeptID IN (select
7 {E, F, H}
Deptid from Department)),
8 {E, F, G, H}
PRIMARY KEY (Name));
The above use of check assertion is good
18. [Ans. B]
to declare the foreign key as far as
Prime Attribute = Part of some candidate
insertion is considered for relation
key.
manager (will not insert any tuple in
Relation = R (ABCDEF)
Manager containing such DeptID value
Candidate keys are {AB, CD}
which is not present in any tuple of
Total No of prime Attributer = 4
Department).
= {A, B, C, D}
But the above declaration will fail to
implement changes done in Department
relation in terms of deletion & updation.
For an instance if a deptid present in
Department gets deleted, then respective
reference in Manager should also be
deleted.
S is false
S : The given table definition is not valid
due to invalid foreign key declaration.
Attribute a is declared as foreign key

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 330
GATE QUESTION BANK DBMS

Relational Algebra & Relational Calculus

CS - 2005 (B) Courses in which a proper subset of


1. Let r be a relation instance with schema female students are enrolled
R= (A, B, C, D). We define r1=∏A,B,C(R) (C) Courses in which only male students
and r2= ∏ r Let S =r1 * r2 where * are enrolled
denotes natural join. Given that the (D) None of the above.
decomposition of r into r1 and r2 is lossy,
which one of the following is TRUE? 5. Consider the relation employee (name,
(A) s ⊂ r (C) r ⊂ s sex, supervisorName) with name as the
(B) r ∪ s=r (D) r*s=s key. supervisorName-gives the name of
the supervisor of the employee under
CS - 2006 consideration. What does the following
2. Consider the relations r1 (P, Q, R) and Tuple Relational Calculus query
r2 (R, S, T) with primary keys P and R produce? {e name|employee e ∧
respectively. The relation n contains ∀x [¬ employee x ∨
2000 tuples and r2 contains 2500 tuples. x. supervisorName≠e name ∨
The maximum size of the join r1 r2 is x sex=”male”]}
(A) 2000 (C) 4500 (A) Names of employees with a male
(B) 2500 (D) 5000 supervisor
(B) Names of employees with no
3. Which of the following relational query immediate male subordinates
languages have the same expressive (C) Names of employees with no
power? immediate female subordinates
(I) Relational algebra (D) Names of employees with a female
(II) Tuple relational calculus restricted supervisor
to safe expressions
(III) Domain relational calculus 6. Consider a selection of the form
restricted to safe expressions A≤100(r), where r is a relation with 1000
(A) II and III only (C) I and III only tuples. Assume that the attribute values
(B) I and II only (D) I, II and III for A among the tuples are uniformly
distributed in the interval [0,500]. Which
CS - 2007 one of the following options is the best
4. Information about a collection of estimate of the number of tuples
students is given by the relation studInfo returned by the given selection query?
(studId, name, sex). The relation enroll (A) 50 (C) 150
(studId, CourseId) gives which student (B) 100 (D) 200
has enrolled for (or taken) what course
(s). Assume that every course is taken by 7. Consider the following relation schemas:
at least one male and at least one female -Schema = ( -name, -city, assets)
student. What does the following a-Schema = (a-num, -name, bal)
relational algebra expression represent? -Schema = ( -name, a-number)
courseld(( studld( sex=“female”(studInfo)) Let branch, account and depositor be
courseld(enroll)) enroll) respective instances of the above
(A) Courses in which all the female schemas. Assume that account and
students are enrolled

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 331
GATE QUESTION BANK DBMS

depositor relations are much bigger than IV. Select R.a, R.b
the branch relation. from R, S
Consider the following query: Where R.c = S.c
∏c-name b-city= “Agra” ∧ al<0 (branch Which of the above queries are
(account depositer))) equivalent?
Which one of the following queries is the (A) I and II (C) II and IV
most efficient version of the above (B) I and III (D) III and IV
query?
(A) c-name bal< 0 b-city = “Agra” branch CS - 2010
account) depositer) 10. The following functional dependencies
(B) c-name b- ity = “Agra” branch hold for relations R(A, B, C) and
bal< 0 account depositer)) S(B, D, E):
(C) c-name b- ity = “Agra” branch B A,
b- ity = “Agra” ∧ al< 0 account A C
depositer) The relation R contains 200 tuples and
(D) c-name b- ity = “Agra branch the relation S contains 100 tuples. What
b- ity = “Agra” ∧ al< 0 account is the maximum number of tuples
depositer)) possible in the natural join R S?
(A) 100 (C) 300
CS - 2008 (B) 200 (D) 2000
8. Let R and S be two relations with the
following schema CS - 2011
R(P,Q,R1, R2, R3) 11. Consider a relational table r with
S(P,Q ,S1, S2) sufficient number of records, having
attributes A1, A2…… An an let 1 ≤ p ≤ n
Where {P,Q} is the key for both schemas.
Two queries Q1 and Q2 are given below.
Which of the following queries are
Q1: π …… ( )
where c is a
equivalent?
I. R S constant
II. R (S) Q2: π …… ( )
where and
III. P( R ∩ (S)) are constants. The database can be
IV. P( (R) ( P,Q (R) (S))) configured to do ordered indexing on A
(A) Only I and II or hashing on A . Which of the following
(B) Only I and III statements is TRUE?
(C) Only I, II and III (A) Ordered indexing will always
(D) Only I, III and IV outperform hashing for both queries
(B) Hashing will always outperform
CS - 2009 ordered indexing for both queries
9. Let R and S be relational schemes such (C) Hashing outperform ordered
that R={a, b, c} and S={c}. Now consider indexing on Q1, but not on Q2
the following queries on the database: (D) Hashing will outperform ordered
I. πR-S (r) πR-S πR-S(r) × indexing on Q2, but not on Q1
s πR-S,S (r))
II. {t|t ϵ πR-S (r) ∧ ∀uϵs ∃vϵr CS - 2012
(u = v[s] ∧ t = v [R S]))} 12. Suppose R (A,B) and R (C,D) are two
III. {t|t ϵ πR-S (r) ∧ ∀vϵr ∃uϵs relation schemas. Let r and r be the
(u = v[s] ∧ t = v [R S]))} corresponding relation instances. B is a

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 332
GATE QUESTION BANK DBMS

foreign key that refers to C in R . If data size(r(R))<size(s(S)), the join will have
in r and r satisfy referential integrity fewer number of disk block accesses if
constraints. Which of the following is (A) relation r(R) is in the outer loop.
ALWAYS TRUE? (B) relation s(S) is in the outer loop.
(A) r r = (C) join selection factor between r(R)
(B) r r = and s(S) is more than 0.5.
(C) r = r (D) join selection factor between r(R)
(D) r r ≠ and s(S) is less than 0.5.

CS - 2013 15. What is the optimized version of the


13. Consider the following relational schema. relation algebra expression
Students (roll no: integer, sname: string) π (π ( ( r ))) where A1, A2
Courses (course no: integer,
cname: string) are sets of attri utes in r with A1 ⊂ A2
Registration (rollno: integer, and F1, F2 are Boolean expressions
courseno: integer, percent: real) based on the attributes in r?
Which of the following queries are (A) π r
equivalent to this query in English? (B) π ∨ r
“Fin the istin t names of all stu ents (C) π r
who score more than 90% in the course (D) π ∨ r
num ere 107”
(I) SELECT DISTINCT S.sname FROM 16. Consider the relational schema given
Student as S, Registration as R below, where eId of the relation
WHERE R.rollno=S.rollno AND dependent is a foreign key referring to
R.courseno=107 AND empId of the relation employee. Assume
R. percent>90 that every employee has at least one
(II) ∧ associated dependent in the dependent
Registration Stu ent relation.
(III) {T|∃S stu ents ∃R Regitration employee (empId, empName, empAge)
S rollno = R rollno ∧ R.courseno dependent(depId, eId, depName, depAge)
=107∧R per ent>90∧T sname Consider the following relational algebra
=S.sname)} query:
(IV) {< S > |∃S ∃R < S S > ∏ employee
∏ employee epen ent
Stu ents ∧< S 107 R > ∧

Registration ∧ R > 90 } The above query evaluates to the set of


(A) I, II, III and IV empIds of employees whose age is
(B) I, II and III only greater than that of
(C) I, II and IV only (A) some dependent.
(D) II, III and IV only (B) all dependents.
(C) some of his/her dependents.
CS - 2014 (D) all of his/her dependents.
14. Consider a join (relation algebra)
between relations r(R) and s(S) using
the nested loop method. There are 3
buffers each of size equal to disk block
size, out of which one buffer is reserved
for intermediate results. Assuming
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 333
GATE QUESTION BANK DBMS

Answer Keys and Explanations

1. [Ans. C] 1 2 1
4 4 2
Relation =R(A, B, C, D) 3 stu info 3 enroll enroll
r = R
r = r
As e omposition of “R” into “r and r ” is
Selects only
LOSSY ⇒ Spurious tuples will e generate
girls students
s = r ∗ r Natural Join]
Will get “r” + spurious tuples Assumes that all girl students
⇒ “r” is a proper su set of “s” [r ⊂ s] joined in all courses
It selects the course ID in which only a proper subset
2. [Ans. A] of girl students are enrolled.
It consider only pairs of tuples that have the Stu i
1
same value on R. Step: 1 stu info =
2
3
3. [Ans. D] Step: 2
All given relational query language have the stu info enroll
same expressive power. = Stud ID Course ID
1 MCA ×
4. [Ans. B] 1 MBA ×
Every Course Must e taken y at least 2 MCA ×
one male and at least one female student. 2 MBA ×
Let us assume there are only 2 courses 3 MCA ×
3 MBA 
{MCA, MBA}
Step: 3 Step(2) enroll
MCA Course opte y all girls + 1-boy
= Stud ID Course ID
[3girls + 1-boy]
3 MBA
MBA Course opted by 2 girls + 1-boy Step: 4 (step.3)=MBA, course in
[2girls + 1-boy] whi h “proper su set of female stu ents are
Let total no of students = 5, enrolled”.
where 3 girls 2-boys.
{A, B, C} girls 5. [Ans. C]
{D, E} Boys employee (name, sex, supervisor name)
Student info Enroll Foreign key
Stud Name sex Stud Course
{e. name|Employee e ˄ ∀x
id id id
1 A F 1 MCA [ employee (x) ˅
2 B F 2 MCA x. supervisor name # e. name ˅
3 C F 3 MCA x. sex= “Male”]}
4 D M 4 MCA we are using 2 tuple variables
5 E M 1 MBA e free tuple varia le referring employee
2 MBA x Bounded tuple variable referring all the
5 MBA subordinates of the selected free tuple
varia le “e”
Finally the formulae ∀x F verifying
whether all the subordinates of the
particular employee are males (or) not.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 334
GATE QUESTION BANK DBMS

Formulae will be true if all subordinates of R S


an employee are males. P Q P Q 3 rows created
Employee 1 a 1 a Row:1 P&Q are same
Name Sex Supervisor 2 b 2 c Row:2 Only P same
Name 3 d 4 d Row:3 Only Q same
a M (1) R S =
P Q P
= 1
1 a
x M a
y M a P P P

z M a 2 R S = 1 1 = 1

b M 2 2 2

u F b
P Q P
v M b 3 ( R ∩ s )= 1 a = 1
1) If e name = a then x ={x y z} “a” will e
selected, since all his subordinates are 4 ( R ( R S ))
Males. P Q P
= = 1
2) If e name = then x={u v} “ ” will not be 1 a

selected, since all his subordinates are ⇒ Queries (1),(3) and (4) are equivalent,
NOT Males. because they all are operating on complete
⇒ Query returns the names of employees key (PQ). Where are Query (2) considering
with no immediate female subordinates. only part of key (P), hence it is different.

6. [Ans. D] 9. [Ans. C]
Given: II and IV are equivalent.
There are 100 tuples
These are uniformly distributed, in the 10. [Ans. A]
interval [0,500] R (A, B, C) and S (B, D, E)
So for values A≤100 There will e 200 F= Set of FD’s = {B A A C}
tuples returned by the given selected query. ⇒ “B” is the key for R A B C
R S
7. [Ans. B] A B C =200rows B D E =100rows
b - Schema = (b-name, b-city, assets)
a - Schema = (a-num, b-name, bal) Key = B
d - Schema = (c-name, a-number) Parent table = R Child table = S

Parent column =B Child column = B
( ran h a ount epsitor )
Max rows of R S
Most efficient version of this query.
= Max always from the child table only.
( ran h
= 100 rows
a ount epositor ) 100 rows 200 rows
Employee Dept
eno ename dno dno dname
8. [Ans. D]
1 D1 D1
R (P, Q, R1, R2, R3)
2 D1 D2
S (P, Q, S1, S2) : :
Key= P+Q for oth ta les omposite key 100 D20 D200
Let us consider the following instances:- Child table = Primary key =
Employee foreign dno
key = dno parent table =
Dept
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 335
GATE QUESTION BANK DBMS

⇒ Emp Dept ⇒ Maximum rows Let r(A,B,C) = 30,000 rows 25 rows fit in
= All Employee = 100 rows. 1-block Total Blocks required for
⇒ Maximum rows of natural join = Total no. “r” = 1200 lo ks
of rows from child table. S(C,D,E) = 60,000 rows 30 rows fit in 1-
block Total Blocks reqd for
11. [Ans. C] “s” =2000 lo ks
If records are accessed for a particular value If' “r” is use as the outer relation:-
from table, hashing will do better. If records “r” requires 30000/25 = 1200 lo ks of
are accessed in a range of values, ordered storage and s requires
indexing will perform better. (60000/30) = 2000 blocks of storage. The
formula for number of block accesses is
12. [Ans. A] (nr bs + br) i.e. 30000 2000+1200 =
R AB 60,001,200 disk accesses are required for a
R CD nested loop join.
B is a foreign key & referring to C & C is a If “s” is use as the outer relation:-
candidate key. The formula for number of block accesses is
So, r r = (ns br + bs) i.e. 60000 × 1200+2000 =
72,002,000.
13. [Ans. A] So the numbers of block accesses are less if
Find the distinct names of all students who “r” is use outsi e
score more than 90% in the course no. 107
1. SQL query 15. [Ans. A]
Condition would give all s.name having π (π ( ( r )))
score > 90 and attending course no. 107
and DISTINCT S.sname will give distinct =π ∧ r
student names π (π ( ( r )))
TRUE
2. Relational algebra =π ( ∧ r )
gives projection of all students
meeting the on ition an ‘ ’ gives 16. [Ans. D]
DISTINCT value Every employee has at least one
TRUE dependent.
3. Tuple calculus gives DISTINCT student EMPLOYEE
name having score > 90 and course no is empId empName empAge
107 1 A 50
2 B 60
TRUE
3 C 70
4. Domain calculus
Domain calculus is equivalent to
DEPENDENT
relational algebra and provide distinct
depId eId depName depAge
value for the query D1 1 X 30
TRUE D2 1 Y 40
D3 2 Z 50
14. [Ans. A] D4 2 U 80
As Size(r(R)) < Size (s(S)), let us consider D5 3 V 90
the following illustration D6 3 W 100
Consider these relations with the following Empi =1 An employee having 2 younger
properties: dependents [empAge > depAge]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 336
GATE QUESTION BANK DBMS

Empi = 2 An employee having 1


younger & 1 older dependent
[empAge < depAge]
Empi = 3 An employee having 2 ol er
dependents [empAge < depAge]
employee

employee ∧ epen ent


employee returns {1 2 3} employee i ’s

employee ∧ epen ent

returns {2 3}
Final Answer –{1, 2, 3} –{2 3} = {1}
Employee whose age is greater than all his
dependents.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 337
GATE QUESTION BANK DBMS

SQL

CS - 2005 (A) Do not supply any item


1. The relation book (title, price) contains (B) Supply exactly one item
the titles and prices of different books. (C) Supply one or more items
Assuming that no two books have the (D) Supply two or more items
same price, what does the following SQL
query list? 3. A table ‘student’ with schema (roll, name,
select title hostel, marks) and another table ‘hobby‘
from book as B with schema (roll, hobbyname) contains
where (select count (*) from book as T records as shown below.
where T.price>B. Price) < 5 Table student
(A) Titles of the four most expensive Roll Name Hostel Marks
books 1798 Manoj Rathod 7 95
(B) Title of the fifth most inexpensive 2154 Soumic Banerjee 5 68
book 2369 Gumma Reddy 7 86
(C) Title of the fifth most expensive book 2581 Pradeep Pendse 6 92
(D) Titles of the five most expensive 2643 Suhas Kulkarni 5 78
books 2711 Nitin Kadam 8 72
2872 Kiran Vora 5 92
2. In an inventory management system 2926 Manoj Kunkalikar 5 94
implemented at a trading corporation, 2959 Hemant Karkhanis 7 88
there are several tables designed to hold 3125 Rajesh Doshi 5 82
all the information. Amongst these, the
following two tables hold information on Table hobby
which items are supplied by which Roll Hobby name
suppliers, and which warehouse keeps 1798 chess
which items along with the stock-level of 1798 music
these items. 2154 music
Supply = (supplierid, itemcode) 2369 swimming
Inventory = (itemcode, warehouse, 2581 cricket
stocklevel) 2643 chess
For a specific information required by the 2643 hockey
management, following SQL query has 2711 volleyball
been written. 2872 football
Select distinct STMP supplierid 2926 cricket
From supply as STMP 2959 photography
Where not unique 3125 music
(Select ITMP. supplierid 3125 chess
From Inventory, Supply as ITMP The following SQL query is executed on
Where STMP.supplierid= ITMP. supplierid the above tables:
and ITMP.itemcode= Inventory. itemcode select hostel
and Inventory. warehouse = ‘Nagpur‘); from student natural join hobby
For the warehouse at Nagpur, this query where marks > = 75 and roll between
will find all suppliers who 2000 and 3000;

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 338
GATE QUESTION BANK DBMS

Relations S and H with the same schema in decreasing balance order and
as those of these two tables respectively assigning ranks using ODBC
contain the same information as tuples. A Which two of the above statements are
new relation S is obtained by the correct?
following relational algebra operation: (A) 2 and 5 (C) 1 and 4
S = ( . . (B) 1 and 3 (D) 3 and 5
( (S)) (H))
The difference between the number of 5. Consider the relation enrolled (student,
rows output by the SQL statement and the course) in which (student, course) is the
number of tuples in S is primary key, and the relation paid
(A) 6 (C) 2 (student, amount) where student is the
(B) 4 (D) 0 primary key. Assume no null values and
no foreign keys or integrity constraints.
CS - 2006 Given the following four queries:
4. Consider the relation account (customer, Query 1: Select student from enrolled
balance) where customer is a primary key where student in (Select student from
and there are no null values. We would paid)
like to rank customers according to Query 2: Select student from paid where
decreasing balance. The customer with student in (Select student from enrolled)
the largest balance gets rank 1. Ties are Query 3: Select E. student from enrolled E,
not broken but ranks are skipped: if paid P where E. student = P. student
exactly two customers have the largest Query 4: Select student from paid where
balance they each get rank 1 and rank 2 is exists (select * from enrolled where
not assigned. enrolled. student = paid. student)
Query 1: Select A. customer, Which one of the following statements is
count (B. customer) from account A, correct?
account B where (A) All queries return identical row sets
A. balance < = B. balance group by for any database
A. customer (B) Query 2 and Query 4 return identical
Query 2: Select A. customer, row sets for all databases but there
1+ count (B. customer) from account A, exist databases for which Query 1
account B where A. balance< B. balance and Query 2 return different row
group by A. customer sets
Consider these statements about Query 1 (C) There exist databases for which
and Query 2. Query 3 returns strictly fewer rows
1. Query 1 will produce the same row than Query 2
set as Query 2 for some but not all (D) There exist databases for which
databases. Query 4 will encounter an integrity
2. Both Query 1 and Query 2 are correct violation at runtime.
implementations of the specification
3. Query 1 is a correct implementation Statement for Linked Answer Questions 6
of the specification but Query 2 is not and 7
4. Neither Query 1 nor Query 2 is a Consider a database with three relation
correct implementation of the instances shown below. The primary keys
specification for the Drivers and Cars relations are did
5. Assigning rank with a pure relational and cid respectively and the records are
query takes less time than scanning stored in ascending order of these
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 339
GATE QUESTION BANK DBMS

primary keys as given in the tables. No C.color = ‘green’)


indexing is available in the database. (A) Karthikeyan, Boris
D: Drivers relation (B) Sachin, Salman
did dname rating age (C) Karthikeyan, Boris, Sachin
22 Karthikeyan 7 25 (D) Schumacher, Senna
29 Salman 1 33
31 Boris 8 55 7. Let n be the number of comparisons
32 Amoldt 8 25 performed when the above SQL query is
58 Schumacher 10 35 optimally executed. If linear search is
64 Sachin 7 35 used to locate a tuple in a relation using
71 Senna 10 16 primary key, then n lies in the range
74 Sachin 9 35 (A) 36 40 (C) 60 64
85 Rahul 3 25 (B) 44 48 (D) 100 – 104
95 Ralph 3 53
CS - 2007
R : Reserves relation 8. Consider the table employee (empId,
did cid day name, department, salary) and the two
22 101 10/10/06 queries Q1, Q2 below. Assuming that
22 102 10/10/06 department 5 has more than one
22 103 08/10/06 employee, and we want to find the
22 104 07/10/06 employees who get higher salary than
31 102 10/11/06 anyone in the department 5, which one of
31 103 06/11/06 the statements is TRUE for any arbitrary
31 104 12/11/06 employee table?
64 101 05/09/06 Q1: Select e.empId
64 102 08/09/06 From employee e
74 103 08/09/06 Where not exists
(Select * From employee s Where
C : Cars relation s.department = “5” and
cid cname colour s.salary>=e.salary)
101 Renault blue Q2: Select e. empId
102 Renault red From employee e
103 Ferrari green Where e. salary > Any
104 Jaguar red (Select distinct salary From employee s
Where s.department = “5”)
6. What is the output of the following SQL (A) Q1 is the correct query.
query? (B) Q2 is the correct query.
Select D.dname (C) Both Q1 and Q2 produce the same
from Drivers D answer
where D.did in (select R. did (D) Neither Q1 nor Q2 is the correct
from Cars C, Reserves R query
where R. cid = C.cid
and C. color = ‘red’ CS - 2008
intersect Common Data for Questions 9 &10
select R. did Consider the following relational schema:
from Cars C, Reserves R Student (school-id, sch-roll-no, sname,
where R. cid = C.cid and saddress)
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 340
GATE QUESTION BANK DBMS

School (school-id, sch-name, sch-address, If a student needs to score more than 35


sch-phone) marks to pass an exam, what does the
Enrolment (school-id, sch-roll-no, erollno, query return?
exam name) (A) The empty set
Exam Result (erollno, exam name, marks) (B) Schools with more than 35% of its
students enrolled in some exam or
9. What does the following SQL query the other
output? (C) Schools with a pass percentage
SELECT sch - name, COUNT (*) above 35% over all exams taken
FROM School C, Enrolment E, together
Exam Result R (D) Schools with a pass percentage
WHERE E. school – id = C.school-id above 35% over each exam
AND
E. exam name = R. exam name CS - 2009
AND Common data for Questions 11 and 12
E. Erollno = R.erollno Consider the following relational schema:
AND Suppliers (sid: integer, sname: string,
R.marks = 100 AND S.school-id IN city:string, street: string)
(SELECT school-id Parts (pid:integer, pname: string,
FROM student color:string)
GROUP BY school-id Catalog (sid:integer, pid:integer,
HAVING COUNT (*) > 200) cost: real)
GROUP BY school-id 11. Consider the following relational query
(A) For each school with more than 200 on the above database:
students appearing in exams, the SELECT S.sname
name of the school and the number FROM Suppliers S
of 100s scored by its students WHERE S.sid NOT IN (SELECT C. sid
(B) For each school with more than 200 FROM Catalog C
students in it, the name of the school WHERE C.pid NOT IN (SELECT P.pid
and the number of 100s scored by its FROM Parts P
students WHERE P.color<> ‘blue’))
(C) For each school with more than 200 Assume that relations corresponding to
students in it, the name of the school the above schema are not empty. Which
and the number of its students one of the following is the correct
scoring 100 in at least one exam interpretation of the above query?
(D) Nothing; the query has a syntax error (A) Find the names of all suppliers who
have supplied a non-blue part
10. Consider the following tuple relational (B) Find the names of all suppliers who
calculus query. have not supplied a non-blue part
{t | E Enrolment t= E. school – id (C) Find the names of all suppliers who
| {x x Enrolment x. school – id have supplied only blue parts
= t ( B ExamResult (D) Find the names of all suppliers who
. erollno = x. erollno have not supplied only blue part
B. exam name = x. exam name
. marks 35)+ 12. Assume that, in the suppliers relation
| {x | x Enrolment x. school-id = t+ above, each supplier and each street
100> 35} within a city has a unique name, and
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 341
GATE QUESTION BANK DBMS

(sname, city) forms a candidate key. No CS - 2011


other functional dependencies are 14. Database table by name Loan_Records is
implied other than those implied by given below.
primary and candidate keys. Which one of Borrower Bank_ Loan_
the following is TRUE about the above Manager Amount
schema? Ramesh Sunderajan 10000.00
(A) The schema is in BCNF Suresh Ramgopal 5000.00
(B) The schema is in 3NF but not in Mahesh Sunderajan 7000.00
BCNF What is the output of the following SQL
(C) The schema is in 2NF but not in 3 NF query?
(D) The schema is not in 2NF SELECT count(*)
FROM
CS - 2010 (SELECT Borrower, Bank_Manager FROM
13. A relational schema for a train Loan_Records) AS S
reservation database is given below. NATURAL JOIN
Passenger (pid, pname, age) (SELECT Bank_Manager, Loan_Amount
Reservation (pid, class, tid) FROM Loan_Records) AS T);
Table: Passenger (A) 3 (C) 5
pid pname Age (B) 9 (D) 6
0 ‘Sachin’ 65
1 ‘Rahul’ 66 15. Consider a database table T containing
2 ‘Sourav’ 67 two columns X and Y each of type integer.
3 ‘Anil’ 69 After the creation of the table, one record
(X = 1, Y = l) is inserted in the table.
Table: Reservation Let MX and MY denote the respective
pid class tid maximum values of X and Y among all
records in the table at any point in time.
0 ‘AC’ 8200
Using MX and MY, new records are
1 AC’ 8201
inserted in the table 128 times with X
2 ‘SC’ 8201
and Y values being MX +1, 2*MY + 1
5 ‘AC’ 8203
respectively. It may be noted that each
1 ‘SC’ 8204
time after the insertion, values of MX and
3 ‘AC’ 8202
MY change.
What pids are returned by the following
What will be the output of the following
SQL query for the above instance of the
SQL query after the steps mentioned above
tables?
are carried out?
SELECT pid
SELECT Y FROM T WHERE X=7;
FROM Reservation
(A) 127 (C) 129
WHERE class = ‘AC’ AND
(B) 255 (D) 257
EXISTS (SELECT *
FROM Passenger
CS - 2012
WHERE age > 65 AND
16. Which of the following statements are
Passenger.pid = Reservation.pid)
TRUE about an SQL query?
(A) 1, 0 (C) 1, 3
P: An SQL query can contain a HAVING
(B) 1, 2 (D) 1, 5
clause even if it does not a GROUP BY
clause

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 342
GATE QUESTION BANK DBMS

Q: An SQL query can contain a HAVING departments(dept-id, dept-name,


clause only if it has a GROUP BY clause manager-id, location-id)
R: All attributes used in the GROUP BY You want to display the last names and
clause must appear in the SELECT clause hire dates of all latest hires in their
S: Not all attributes used in the GROUP BY respective departments in the location ID
clause need to apper in the SELECT clause 1700. You issue the following query:
(A) P and R (C) Q and R SQL>SELECT last-name, hire-date
(B) P and S (D) Q and S FROM employees
WHERE (dept-id, hire-date) IN
Common Data for Questions 17 and 18 (SELECT dept-id, MAX(hire-date)
Consider the following relation A, B & C. FROM employees JOIN departments
A. Id Name Age USING(dept-id)
12 Arun 60 WHERE location-id = 1700
15 Shreya 24 GROUP BY dept-id);
99 Rohit 11 What is the outcome?
(A) It executes but does not give the
B. Id Name Age
correct result.
15 Shreya 24
(B) It executes and gives the correct
25 Hari 40
98 Rohit 20 result.
99 Rohit 11 (C) It generates an error because of
pairwise comparison.
C. Id Phone Area (D) It generates an error because the
10 2200 02 GROUP BY clause cannot be used
99 2100 01 with table joins in a sub- query.

17. How many tuples does the result of the 20. SQL allows duplicate tuples in relations,
following relational algebra expression and correspondingly defines the
contain? Assume that the schema of A∪ multiplicity of tuples in the result of joins.
is the same as that of A. Which one of the following queries
(A∪ ) . . C always gives the same answer as the
(A) 7 (C) 5 nested query shown below:
(B) 4 (D) 9 select * from R where a in (select S.a from
S)
18. How many tuples does the result of the (A) Select R.* from R, S where R.a=S.a
following SQL query contains? (B) Select distinct R.* from R,S where
SELECT A.Id R.a=S.a
FROM A (C) Select R.* from R,(select distinct a
WHERE A.Age>All (SELECT B.Age FROM from S) as S1 where R.a=S1.a
B WHERE . name = ‘Arun’) (D) Select R.* from R,S where R.a=S.a
(A) 4 (C) 0 and is unique R
(B) 3 (D) 1
21. Consider the following relational schema:
CS - 2014 employee(empId,empName,empDept)
19. Given the following schema: customer(custId,custName,salesRepId,
employees (emp-id, first-name, rating)
last-name, hire-date, dept-id, salary) salesRepId is a foreign key referring to
empId of the employee relation. Assume
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 343
GATE QUESTION BANK DBMS

that each employee makes a sale to at 22. Given an instance of the STUDENTS
least one customer. What does the relation as shown below:
following query return?
SELECT empName

CPI

9.4

9.5

9.4

9.3

8.7
FROM employee E
WHERE NOT EXISTS (SELECT custId

Student
FROM customer C

Age
WHERE C.salesRepId = E.empId

19

19

18

19
AND C.rating< ’GOOD’);

X
(A) Names of all the employees with at

shankar@math
least one of their customers having a

Student Email

shankar@cse

ganesh@civil
swati@mech
‘GOOD’ rating.

swati@ee
(B) Names of all the employees with at
most one of their customers having a
‘GOOD’ rating.
(C) Names of all the employees with
none of their customers having a

Student

Shankar

Shankar
Name

Ganesh
‘GOOD’ rating.

Swati

Swati
(D) Names of all the employees with all
their customers having a ‘GOOD’
rating.
Student
ID

2345

1287

7853

9876

8765
For (StudentName, StudentAge) to be a
key for this instance, the value X should
NOT be equal to ________

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 344
GATE QUESTION BANK DBMS

Answer Keys and Explanations

1. [Ans. D] Final Result → Rows from the Outer Query


No two books will have same price. where Condition is Satisfied.
Let us consider the table as follows:- TITLE
TITLE PRICE T1
T1 100 T2
T2 200 T3 Query returns the titles
T3 300 T4 Of 5 most expensive books
T4 400 T5
T5 500 T6
T6 600
As the given Query is a “Correlated Sub 2. [Ans. D]
Query, Outer Query executes first and SUPPLY
Inner Query executes second and executes Supplierid Item
once for each row written by the outer code
query. S1 I1
S1 I2
SELECT title From book as B
S1 I3
S2 I4
TITLE S2 I5
T1 S3 I6
T2
T3
INVENTORY
T4
Item Ware Stock
T5
Code house level
T6
I1 Nagpur
WHERE (SELECT count(*) FROM book as
I2 Nagpur
T WHERE T.price > B.price)<5 I3 Nagpur
I4 Nagpur
I5 Nagpur
INNER QUERY <5 Result I6 Nagpur
SELECT count (*) FROM <5 Not
book as T WHERE Qualified S1 → Supplier has 3-items [I1, I2, I3,] at
T.price > 100;=5 Nagpur Warehouse
SELECT count (*) FROM <5 Qualified
S2 → Supplier has 2-items [I4,I5] at
book as T WHERE
T.price > 200;=4 Nagpur Warehouse
SELECT count (*) FROM <5 Qualified S3 → Supplier has 1-item [I6] at Nagpur
book as T WHERE Warehouse
T.price > 300;=3 SELECT distinct STMP. supplierid
SELECT count (*) FROM <5 Qualified FROM supply as STMP
book as T WHERE
T.price > 400;=2
TITLE
SELECT count (*) FROM <5 Qualified
S1
book as T WHERE
S2
T.price > 500;=1
S3
SELECT count (*) FROM <5 Qualified
book as T WHERE
T.price > 600;=0

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 345
GATE QUESTION BANK DBMS

WHERE NOT UNIQUE Query: 2


(SELECT ITMP. supplierid FROM inventory, S = ( . .
supply as ITMP WHERE ITMP. supplierid = ( (S)) (H))
STMP. supplierid AND ITMP. itemcode = → returns only DISTINCT rows
Inventory. itemcode AND inventory. warehouse = 3 rows {7, 6, 5}
= ‘Nagpur’), Final Answer = Difference in no. of rows =
4 – rows

INNER QUERY OUT NOT 4. [Ans. C]


PUT UNIQUE Table A
SELECT ITMP.supplierid 3-rows Qualified Customer Balance
FROM Inventory,supply as ITMP {I1, I2,I3} 1 10
WHERE ITMP.supplierid = S1
AND ITMP.itemcode = 2 20
Inventory.itemcode 3 10
AND inventory.warehouse 4 15
=‘Nagpur’;
SELECT ITMP.supplierid 2-rows Qualified
Table B
FROM Inventory, supply as ITMP{I4, I5}
WHERE ITMP.supplierid = S2 Customer Balance
AND ITMP.itemcode = 1 10
Inventory.itemcode 2 20
AND Inventory.warehouse
=‘Nagpur’; 3 10
SELECT ITMP.supplierid 1-row Not 4 15
FROM Inventory,supply as ITMP {I6} Qualified
WHER ITMP.supplierid = S3
AND ITMP.itemcode = Output of Query 1
Inventory.itemcode Customer Count (B. Customer)
AND Inventory.warehouse 1 4
= ‘Nagpur’;
2 1
Final Result = *S1, S2+ suppliers are selected →
3 4
Suppliers supplying 2(or) more items
4 2
3. [Ans. B]
Student Natural Join Hobby WHERE Output of Query 2
Marks> =75 AND roll BETWEEN 2000 AND 3000 Customer Count (B. Customer)
Roll Name Hostel Marks Habby Name
1 3
2369 Gumma Reddy 7 86 Swimming
2581 Pradeep Pendse 6 92 Cricket 2 1
2643 Suhas Kulkarni 5 78 Chess 3 3
2643 Suhas Kulkarni 5 78 Hockey 4 2
2872 Kiran Vora 5 92 Football If there are no duplicates of balance then
2926 Manoj 5 94 Cricket they produce same row set else not (See
Kunkalikar
2959 Hemant 7 88 Photography table above). Both are not producing
Karkhanis desired output.
Query: 1
SELECT hostel
FROM student NATURAL JOIN hobby
WHERE marks > = 75
AND roll BETWEEN 2000 AND 3000;
→ returns 7 rows *7, 6, 5, 5, 5, 5, 7+
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 346
GATE QUESTION BANK DBMS

5. [Ans. B] When R.cid = c.cid and c.colour = ‘Red’


PAID ENROLLED Table - 2
Student Amount Student Course did cid day
1 2000 1 MCA 22 102 10/10/06
1 MBA 22 104 07/10/06
Primary Key = Primary Key =
31 102 10/11/06
Student Student + Course
31 104 12/11/06
Query 1:- SELECT student 64 102 08/09/06
FROM enrolled Table 1 Table 2 gives 2 values of did =
WHERE student in (SELECT 22 and 31
student FROM Paid) ∴ With these values in driver relation
→ returns 2 rows *1, 1+ gives KarthiKeyan and Boris.

Query 2:- SELECT Student 7. [Ans. C]


FROM Paid
Counting the number of comparisions
WHERE student in (SELECT
Student FROM leads to approximately 62.
enrolled)
→ returns 1 rows *1+ 8. [Ans. B]
EMPLOYEE
Query 3:- SELECT e.student Empid Name Dept Salary
FROM enrolled e, paid p 1 A 5 1000
WHERE e.student = p. student, 2 B 5 2000
→ returns 2 rows *1, 1+ 3 C 4 3000
4 D 4 1500
Query4:- SELECT student 5 E 4 500
FROM paid We want to find employees who get higher
WHERE EXISTS (SELECT * FROM salary than anyone in the department “5”
enrolled WHERE
Correct Output for the above query on the
enrolled. student
= paid. student), given data would be employees {2, 3, 4}
→ returns 1 rows *1+ Q1:- SELECT e. empId
Final Result = Query 2 and Query 4 FROM employee e
returns identical row sets for all WHERE not exists (SELECT *
databases, but there exist database for FROM employee s
which Query 1 and Query 2 return WHERE
different row sets on the relations. s.department=5 and
s.salary >=e.salary);
6. [Ans. A] → returns rows *2, 3+
When R.cid = c.cid and c.colour = ‘Green’
Table - 1
did cid day
22 103 08/10/06
31 103 06/11/06
74 103 08/09/06

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 347
GATE QUESTION BANK DBMS

e.emp INNER QUERY OUT NOT 11. [Ans. *](Answer is not matching with IIT
Id PUT EXISTS keys)
1 SELECT * FROM 1 row Not SUPPLIERS
employee s Qualified
Sid Sname City Street
WHERE s. department
=5 and s.salary>=1000; S1 A
2 SELECT * FROM No rows Qualified
S2 B
employee s S3 C
WHERE s. department =5
and s.salary>=2000; PARTS
3 SELECT * FROM No rows Qualified Pid Pname Color
employee s
WHERE s.department =5
P1 Blue
and s.salary >=3000; P2 Blue
4 SELECT * FROM 1 row Not P3 Blue
employee s Qualified P4 Green
WHERE s. department=5 P5 Green
and s.salary >=1500; P6 Green
5 SELECT * FROM 2 rows Not
employee s Qualified
WHERE s. department=5 CATALOG
and s.salary >=500; Sid Pid Cost
S1 P1
Q2:- SELECT e. empId S1 P2
FROM employee E S2 P3
WHERE e.salary > ANY
S2 P4
(SELECT distinct
salary FROM S3 P5
employee s WHERE S3 P6
s.department=5);
S1 → Supplier supplying only lue parts,
→ returns *2, 3, 4+ employees
Final Answer = Only Q2 is giving the correct [P1, P2]
result S2 → Supplier supplying both Blue &
Green parts. [P3, P4]
9. [Ans. D] S3 → Supplier supplying only Green parts,
If SELECT clause consists aggregate and [P5, P6]
non – aggregate. All non-aggregate
columns in the SELECT list must appear in Initial Query
Group by clause. But in this query Group SELECT S.sname
by consists school_id instead of sch_name FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
10. [Ans. C] WHERE C.pid NOT IN (SELECT
Here, we used division operator. P.pid FROM Parts P
Numerator produces all who scores more WHERE P.colour< ‘blue’));
than 35 marks, denominator checks all
exams. Hence it produces pass percentage After execution of second inner query:-
above 35% over all exams taken together. SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
WHERE C.pid NOT
IN (P4, P5, P6);
→Main Query returns output as {S3}

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 348
GATE QUESTION BANK DBMS

After execution of first inner query:- S Natural Join T


SELECT S.sname Borrower Bank Manager Loan Amount
FROM Suppliers S Ramesh Sunderajan 10000.00
WHERE S.sid NOT IN(S1, S1, S2); Ramesh Sunderajan 7000.00
Final Answer = Names of Suppliers who Suresh Ramgopal 5000.00
supplies Only non-blue parts Ramesh Sunderajan 10000.00
Ramesh Sunderajan 7000.00
12. [Ans. B] Query :-
pid is a primary key, sname and city are SELECT Count(*)
candidate keys. Hence all are prime FROM ((SELECT Borrower, Bank_Manager
attributes and there is a relationship FROM Loan_Records ) AS S
NATURAL JOIN
between prime attributes hence it is not in
(SELECT Bank_Manger Loan_Amount
BCNF but in 3 NF FROM Loan_Records) AS T);
→ Returns count =5
13. [Ans. C]
In the given SQL query, we have to select
15. [Ans. A]
the pid in which the value of class filed is
The entries inserted in order are
‘AC’. In the reservation table and age> 65
X 1 2 3 4 5 6 7
and the value of
Y 1 3 7 15 31 63 127
passenger.pid= reservation.pid
So according to SQL Query One can also solve the recursion and find
In this WHERE class = ‘AC’ out that Y = 2X— 1
So it select the pid = 0, 1, 5, 3 and for
SELECT *FROM passenger where age>65 16. [Ans. C]
and P: An SQL query can contain a HAVING
Passenger.pid = reservation.pid from clause even if it does not have a GROUT
passenger table we get the BY clause
Pid Pname Age SELECT avg(salary)
1 Rahul 66 FROM emp
2 Sourav 67 HAVING avg(salary) 1000; → Valid
3 Anil 69 SQL Statement, “P” is TRUE
Q: An SQL query can contain a HAVING
1 AC clause only if it has a GROUP BY clause
3 AC → FALSE
So the pid return from given query is(1, 3) R: All attributes used in the GROUP BY
clause must appear in the SELECT
14. [Ans. C] clause
S SELECT avg(salary), min(salary),
Borrower Bank_Manager max(salary)
Ramesh Sunderajan FROM emp
Suresh Ramgopal GROUP BY deptno,gender;
Mahesh Sunderajan → VALID SQL Statement, “R” is FALSE.
S: Not all attributes used in the GROUP BY
T clause need to appear in SELECT clause
Bank_Manager Loan_Amount
→ TRUE
Sunderajan 10000.00
Ramgopal 5000.00
Sunderajan 7000.00

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 349
GATE QUESTION BANK DBMS

17. [Ans. A] Option: (B) SELECT DISTINCT R.* FROM R,


A∪ ID Name Age S WHERE R.a = S.a
= 12 Arun 60 Option: (C) SELECT R.* FROM R,(SELECT
15 Shreya 24 DISTINCT a FROM S) AS S1 WHERE
99 Rohit 11 R.a = S1.a
25 Hari 40 Option: (D) SELECT R.* FROM R,S WHERE
98 Rohit 20 R.a = S.a AND UNIQUE R
(A∪ ) . . C Given Option Option Option
ID Name Age ID Phone Area Query (A) (B) (C)
12 Arun 60 10 2200 02 A a a a
15 Shreya 24 10 2200 02 1 1 1 1
99 Rohit 11 10 2200 02 1 1 2 1
25 Hari 40 10 2200 02 2 1 2
98 Rohit 20 10 2200 02 2 1 2
99 Rohit 11 99 2100 01 2
98 Rohit 20 99 2100 01 2
2
18. [Ans. B] 2
In this (Select B. Age Option (D)
from B Error: ORA – 00936: missing expression
where B. Name = ‘Arun’) Only option (C) is given the same output
⇓ as the given Query
Φ
So all A.Age will be selected, so Ans 3. 21. [Ans. D]
SalesRepId is a foreign key referring to
19. [Ans. B] empId of the employee relation. Assume
Inner query will have a join between that each employee makes a sale to at least
employee and departments and will one customer.
return dept – id and hire – date of EMPLOYEE
employees who are having location 1700 empId empName empDept
1 A
and latest line – date (in sorted order)
2 B
3 C
20. [Ans. C]
Will prove by taking the following CUSTOMER
illustration with relation “R” and “S” as custId custName salesRepId rating
follows: C1 1 GOOD
R S C2 1 GOOD
a a C3 2 GOOD
1 1 C4 2 BAD
C5 3 BAD
1 1
C6 3 BAD
2 2
empId = 1 → Employee with all their
2 2 customers [C1, C2] having GOOD rating
Given Query:-SELECT * FROM R WHERE a empId = 2 → Employee with one customer
IN (SELECT S.a FROM S) having GOOD [C3] and other having BAD
Option: (A) SELECT R.* FROM R,S WHERE [C4]
R.a = S.a

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 350
GATE QUESTION BANK DBMS

empId = 3 → Employee with all their


customer [C5, C6] having BAD rating
Query:-
SELET empName
FROM employee E
WHERE NOT EXISTS (SELECT custId
FROM customer C
WHERE C.salesRepId= E.empID
AND C.rating < ‘GOOD’);

e.emp INNER QUERY OUT NOT


Id PUT EXISTS
1 SELECT custId No Qualified
FROM customer C rows
WHERE C.salesRepId = 1
AND C.rating < ’GOOD’;
2 SELECT custId 1 Not
FROM customer C row Qualified
WHERE C.salesRepId =2
AND C.rating < ’GOOD”
3 SELECT custId 2 Not
FROM customer C rows Qualified
WHERE C.salesRepId =3
AND C.rating< ‘GOOD’;
Final Result =*1+ → employee with all
their customers having a “GOOD” rating.

22. [Ans. 19]


Key = (StudentName, StudentAge) →
Composite Key
Composite Key → Combination of 2
columns must be Unique
As 2 rows having same StudentName
“Shankar”. Obviously StudentAge should
not be fulfill the key. So X! = 19 [X can take
any value other than 19]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 351
GATE QUESTION BANK DBMS

Transactions and Concurrency Control


CS – 2005 (A) Except in case of an Operating
1. A company maintains records of sales System crash
made by its salespersons and pays them (B) Except in case of Disk crash
commission based on each individual’s (C) Except in case of a power failure
total sales made in a year. This data is (D) Always, even if there is a failure of
maintained in a table with following any kind
schema:
salesinfo = (salespersonid, totalsales, CS - 2006
commission) 3. Consider the following log sequence of
In a certain year, due to better business two transactions on a bank account,
results, the company decides to further with initial balance 12000, that transfer
reward its salespersons by enhancing the 2000 to a mortgage payment and, then
commission paid to them as per the apply a 5% interest.
following formula. 1. T1: start
If commission < = 50000, enhance it by 2. T1: B old= 12000, new=10000
2% 3. T1: M old = 0, new = 2000
If 50000 < commission < = 100000, 4. T1: commit
enhance it by 4% 5. T2: start
If commission > 100000, enhance it by 6. T2: B old=10000, new = 10500
6% 7. T2: commit
The IT staff has written three different
Suppose the database system crashed
SQL scripts to calculate enhancement for
just before log record 7 is written.
each slab, each of these scripts is to run as
When the system is restarted, which
a separate transaction as follows:
T1 Update salesinfo one statement is true of the recovery
Set commission = commission * 1.02 procedure?
Where commission < = 50000; (A) We must redo log record 6 to set B
T2 Update salesinfo to 10500
Set commission = commission * 1.04 (B) We must undo log record 6 to set B
Where commission > 50000 and to 10000 and then redo log records
commission is < =100000; 2 and 3
T3 Update salesinfo (C) We need not redo log records 2 and
Set commission = commission * 1.06 3 because transaction T1 has
Where commission > 100000; committed
Which of the following options of running (D) We can apply redo and undo
these transactions will update the operations in arbitrary order
commission of all salespersons correctly? because they are idempotent
(A) Execute T1, followed by T2 followed
by T3 CS - 2007
(B) Execute T2, followed by T3; T1 4. Consider the following schedules
running concurrently throughout involving two transactions. Which one of
(C) Execute T3, followed by T2; T1 the following statements is TRUE?
running concurrently throughout S1:r1(X); r1 (Y); r2(X); r2(Y); w2 (Y); w1(X)
(D) Execute T3, followed by T2 followed S2:r1(X); r2 (X); r2(Y); w2(Y); r1 (Y); w1(X)
by T1 (A) Both S1 and S2 are conflict
serializable
2. Amongst the ACID properties of a (B) S1 is conflict serializable and S2 is not
transaction, the ‘Durability‘ property conflict serializable
requires that the changes made to the (C) S1 is not conflict serializable and S2 is
database by a successful transaction conflict serializable
persist

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 352
GATE QUESTION BANK DBMS

(D) Both S1 and S2 are not conflict (C) S1: lock S(A); S2: lock S(B);
serializable read (A); read (B);
lock X(B); lock X(A);
5. Consider the following two transactions
read(B); read(A);
T1 and T2.
T1: read(A); if A = 0 if B≠ 0
read(B); then then
if A = 0 then B ⟵ B+1; B←B+1; A→A 1;
write(B); write (B); write (A);
T2: read (B); unlock (A); unlock (A);
read (A); commit; commit;
if B ≠ 0 then A⟵A 1;
unlock (B); unlock (B);
write(A);
Which of the following schemes, using
shared and exclusive locks, satisfy the (D) S1: lock S(A); S2: lock S(B);
requirements for strict two phase locking read (A); read (B);
for the above transactions? lock X(B); lock X(A);
(A) S1: lock S(A); S2: lock S(B); read(B); read(A);
read (A); read(B); if A = 0 if B≠ 0
lock S(B); lock S(A) then then
read(B); read(A); B←B+1; A→A 1;
if A = 0 if B≠0 write (B); write (A);
then then unlock (A); unlock (A);
B←B+1; A ← A – 1; unlock (B); unlock (B);
write (B); write(A); commit; commit;
commit; commit;
unlock (A); unlock (B); CS – 2009
unlock (B); unlock (A); 6. Consider two transactions T1 and T2, and
four schedules S1, S2, S3, S4 of T1 and T2 as
given below:
(B) S1: lock X(A); S2: lock X(B); T1: R1[x] W1 [x] W1 [y]
read (A); read (B); T2: R2 [x] R2 [y] W2 [y]
lock X(B); lock X(A); S1: R1[x] R2 [x] R2[y] W1 [x] W1 [y] W2 [y]
read(B); read(A); S2: R1[x] R2 [x] R2[y] W1 [x] W2 [y] W1 [y]
if A = 0 if B≠ 0 S3: R1[x] W1 [x] R2[x] W1 [y] R2 [y] W2 [y]
then B←B+1; then S4: R2[x] R2 [y] R1[x] W1 [x] W1 [y] W2 [y]
Which of the above schedules are conflict-
write (B); A→A 1;
serializable?
unlock (A); write (A); (A) S1 and S2 (C) S3 only
commit; unlock (A); (B) S2 and S3 (D) S4 only
unlock (B); commit;
unlock (B); CS - 2010
7. Which of the following concurrency
control protocols ensure both conflict
serializability and freedom from
deadlock?
I. 2-phase locking
II. Time-stamp ordering
(A) I only
(B) II only
(C) Both I and II
(D) Neither I nor II

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 353
GATE QUESTION BANK DBMS

8. Consider the following schedule for 11. Consider the following schedule S of
transactions T1, T2 and T3 transactions T1, T2, T3, T4:
T1 T2 T3 T1 T2 T3 T4
Read(X) Reads (X)
Read(Y) Writes(X)
Read(Y) Commit
Writes (X)
Write(Y)
Commit
Write(X) Writes (Y)
Write(X) Reads(Z)
Read(X) Commit
Write(X) Reads (X)
Which one of the schedules below is the Reads (Y)
correct serialization of the above? commit
(A) T1 → T3 → T2 Which one of the following statements is
(B) T2 → T1 → T3 CORRECT?
(C) T2 → T3 → T1 (A) S is conflict – serializable but not
(D) T3 → T1 → T2
recoverable
CS - 2012 (B) S is not conflict – serializable but is
9. Consider the following transactions with recoverable
data items P and Q initialized to zero: (C) S is both conflict – serializable and
T1: read (P); recoverable
read(Q); (D) S is neither conflict – serializable nor
if P = 0 then Q: = Q + 1 ; is it recoverable
write (Q).
T2: read(Q);
read (P); 12. Consider the transactions T1, T2, and T3
if Q = 0 then P: = P + 1 ; and the schedules S1 and S2 given below.
write (P). T1: r1(X); r1(Z); w1(X); w1(Z)
Any non-serial interleaving of T1 and T2 T2: r2(Y); r2(Z); w2(Z)
for concurrent execution leads to T3: r3(Y); r3(X); w3(Y)
(A) A serializable schedule S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z);
(B) A schedule that is not conflict w3(Y); w2(Z); r1(Z); w1(X); w1(Z)
serializable S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z);
(C) A conflict serializable schedule
r2(Z); w3(Y); w1(X); w2(Z); w1(Z)
(D) A schedule for which a precedence
graph cannot be drawn Which one of the following statements
about the schedules is TRUE?
CS - 2014 (A) Only S1 is conflict-serializable.
10. Consider the following four schedules due (B) Only S2 is conflict-serializable.
to three transactions (indicated by the (C) Both S1 and S2 are conflict-
subscript) using read and write on a data
serializable.
item x, denoted by r(x) and w(x)
respectively. Which one of them is conflict (D) Neither S1 nor S2 is conflict-
serializable? serializable.
(A) r (x); r (x); w (x); r (x); w (x)
(B) r (x); r (x); w (x); r (x); w (x)
(C) r (x); r (x); r (x); w (x); w (x)
(D) r (x); w (x); r (x); r (x); w (x)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 354
GATE QUESTION BANK DBMS

Answer Keys and Explanations


1. [Ans. D] Before relasing exclusive lock, commit
Transactions must execute in order operation is necessary.
T3 → T2 → T1.
Because if sales person “XYZ” Commission 6. [Ans. B]
= 49,999, then If “T1” executes first then Schedule S2
its new commission would be T T
49,999 × 1.02 = 50,998 [which is greater R x
than 50,000] R x
Now if “T2” executes second, then sales R y
person “XYZ” will get hike again, because x
his commission is greater than 50,000 y
This is absolutely wrong. y
So the perfect order of execution is Dependency graph T T S2 has no
T3 → T2 →T1. cycles.
Schedule S3
2. [Ans. D] T T
Always, even if there is a failure of any R x
kind. x
R x
3. [Ans. C] y
In data base transaction system if R y
transaction is commit then it becomes y
permanent there is no effect of any failure
so we need not redo log records 2 and 3 Dependency graph T T S Salso
because transaction T1 has committed. has no cycles. So, S and S are conflict –
serizlizable.
4. [Ans. C]
Schedule S1 → Not Conflict Serializable, 7. [Ans. B]
Since Cycle is formed. In 2 – phase locking concurrency control
Schedule S2 → Confilict Serializable, Since protocol it ensures the conflict serilizable
there is no cycle = Serial Schedule T2→ T1 schedule but it may not free from deadlock
Schedule : S1 Schedule : S2 Ex.
T1 T2 T1 T2 T T
r1(x) r1(x)
l(A) l(A)
r1(y) r2(x)
(A)
r2(x) r2(y)
r2(y) w2(y) (B)
u(A)
w2(y) r1(y)
Deny l(A)
w1(x) w1(x) l(B)
T in waiting (B) (A)
T1 T2 T1 T2 T for unlock
In time stamp ordering protocol it ensure
5. [Ans. C] conflict serializablity and free from dead
T1: A required shared lock because it lock
reads only.
B requires exclusive lock because it
perform read and write operation.
T2 : similarly it performs shared lock on B
and exclusive lock on A.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 355
GATE QUESTION BANK DBMS

8. [Ans. A] T1 T2 T3 T4
Given Schedule → Serializable, Since no Reads(X)
cycle is formed → Writes(X)
Serial Order =T1→ T3 →T2 Commit
T1 T2 T3 Writes(X)
Read(X) Commit
Read(Y) Writes(Y)
Read(Y) Reads (Z)
Write(Y) Commit
Write(X)
Reads (X)
Write(X)
Reads (Y)
Read(X)
Commit
Write(X)
T1 T2

T T

T4 T3
T
T
12. [Ans. A]
Test for Conflict Serializability→ Precedence
9. [Ans. B]
T T Graph
r (P) r (Q) Graph without Cycle → Schedule is Conflict
r (Q) r (P) Serializable
w (Q) w (P) Graph with Cycle → Schedule is NOT Conflict
Serializable
T Schedule S1→ No Cycle → Conflict Serializable
T
Whereas Schedule S2→ Cycle → Not Conflict
Cycle present so not conflict serializable Serializable
Schedule: S1
10. [Ans. D] S1
Schedule in option D
T1 T2 T3
T T T
r1(X)
r(x)
r3(Y)
w(x)
r3(X)
r(x)
r2(Y)
r(x)
r2(Z)
w(x)
w3(Y)
Dependency graph (T ) → (T ) → (T )
Conflict serializable. w2(Z)
r1(Z)
11. [Ans. C] w1(X)
Given Schedule is Recoverable → since all w1(Z)
transactions read the committed data only. No cycle → schedule is conflict serializable
Given Schedule is Serializable→Since there is Equivalent serializable order =
no cycle in the graph T2 → T3 → T1
Equivalent Serializable Schedule =
T2 → T3 → T1 → T4

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 356
GATE QUESTION BANK DBMS

r2(Z),w1(Z)

T1 T2

r3(X),w1(X) r2(Y),w3(Y)

T3

Schedule: S2
S2
T1 T2 T3
r1(X)
r3(Y)
r2(Y)
r3(X)
r1(Z)
r2(Z)
w3(Y)
w1(X)
w2(Z)
w1(Z)
Cycle is formed→Schedule is NOT conflict
serializable
Equivalent serializable order
= T2 → T3 → T1

r1(Z),w2(Z)

T1 T2
r2(Z),w1(Z)

r3(X),w1(X) r2(Y),w3(Y)

T3

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 357
GATE QUESTION BANK DBMS

File Structures
(Sequential files, Indexing, B and trees)

CS - 2005 enrolled paid enrolled paid

1. Which one of the following is a key factor


for preferring B+ -trees to binary search Probe Sequential Probe Sequential
index on scan, select index on scan
trees for indexing database relations? student amount > x student
(A) Database relations have a large
number of records
(B) Database relations are sorted on the Indexed nested Indexed nested
primary key loop join loop join
(C) B+ -trees require less memory than
binary search trees Select on
Project on
(D) Data transfer from disks is in blocks amount > x
course

2. A B-tree used as an index for a large Project on course


database table has four levels including
the root node. If a new key is inserted in
A disk seek takes 4ms, disk data transfer
this index, then the maximum number of
bandwidth is 300 MB/s and checking a
nodes that could be newly created in the
tuple if amount is greater than x takes
process are
10 µs. Which of the following statement is
(A) 5 (C) 3
correct?
(B) 4 (D) 2
(A) Plan 1 and Plan 2 will not output
identical row sets for all databases
CS - 2006
(B) A course may be listed more than
3. In a database file structure, the search key
once in the output of Plan 1 for some
field is 9 bytes long, the block size is 512
databases
bytes, a record pointer is 7 bytes and a
(C) For x = 5000, Plan 1 executes faster
block pointer is 6 bytes. The largest
than Plan 2 for all databases
possible order of a non-leaf node in a B+
(D) For x = 9000, Plan 1 executes slower
tree implementing this file structure is
than Plan 2 for all databases
(A) 23 (C) 34
(B) 24 (D) 44
CS - 2007
5. The order of a leaf node in a B+-tree is the
4. Consider the relation enrolled (student,
maximum number of (value, data record
course) in which (student, course) is the
pointer) pairs it can hold. Given that the
primary key, and the relation paid
block size is 1K bytes, data record pointer
(student, amount) where student is the
is 7 bytes long, the value field is 9 bytes
primary key. Assume no null values and
long and a block pointer is 6 bytes long,
no foreign keys or integrity constraints.
what is the order of the leaf node?
Assume that amounts 6000, 7000, 8000,
(A) 63 (C) 67
9000 and 10000 were each paid by 20%
(B) 64 (D) 68
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.”

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 358
GATE QUESTION BANK DBMS

Statement for Linked Answer Questions 6 non-key field, and the file organization is
and 7 unspanned. The file is stored in a file
Consider the tree in the adjoining system with block size 1024 bytes, and
figure, where each node has at most two the size of a block pointer is 10 bytes. If
keys and three links. the secondary index is built on the key
field of the file, and a multi-level index
scheme is used to store the secondary
index, the number of first-level and
second-level blocks in the multi-level
index are respectively
(A) 8 and 0 (C) 256 and 4
(B) 128 and 6 (D) 512 and 5
6. Keys K15 then K25 are inserted into this
tree in that order. Exactly how many of
the following nodes (disregarding the 9. A clustering index is defined on the fields
links) will be present in the tree after the which are of type
two insertions? (A) Non-key and ordering
(B) Non-key and non-ordering
(C) Key and ordering
(D) Key and non-ordering
(A) 1 (C) 3
(B) 2 (D) 4 CS - 2009
10. The following key values are inserted into
7. Now the key K50 is deleted from the B+ a B+-tree in which order of the internal
tree resulting after the two insertions nodes is 3, and that of the leaf nodes is 2,
made earlier. Consider the following in the sequence given below. The order of
statements about the tree resulting internal nodes is the maximum number of
after this deletion. tree pointers in each node, and the order
(i) The height of the tree remains the of leaf nodes is the maximum number of
same. data items that can be stored in it. The
(ii) The node B+-tree is initially empty.
K20
10, 3, 6, 8, 4, 2, 1. The maximum number
(disregarding the links) is present in the of times leaf nodes would get split up as a
tree. result of these insertions is
(A) 2 (C) 4
(ii) The root node remains unchanged (B) 3 (D) 5
(disregarding the links).
Which one of the following options is CS - 2013
true? 11. An index is clustered , if
(A) Statements (i) and (ii) are true (A) It is on a set of fields that form a
(B) Statements (ii) and (iii) are true candidate key.
(B) It is on a set of fields that include the
(C) Statements (iii) and (i) are true
primary key
(D) All the statements are false (C) The data records of the file are
organized in the same order as the
CS - 2008 data entries of the index
8. Consider a file of 16384 records. Each (D) The data records of the file are
record is 32 bytes long and its key field is organized not in the same order as
of size 6 bytes. The file is ordered on a the data entries of the index

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 359
GATE QUESTION BANK DBMS

Answer keys and Explanations

1. [Ans. D] Size of Key = K = 9 Bytes


The transfer of data from disk to primary Size of Block Pointer = BP = 6 Bytes
memory is in the form of data blocks if a (n × K) + (n × RP) + BP = B
data block is larger than indexing is easy (n × 9) + (n × 7) + 6 = 1024
due to this tree is better than binary n = CEIL (1018/16) = CEIL (63.62) = 63
search tree data structure if large amount
of data can be access. 6. [Ans. A]
Final tree is
2. [Ans. A] 20 40
root (first level)

15 50
second level 30

third level 40
10 20 25 50

15 30
fourth level

If insertion takes place then new node can


7. [Ans. A]
be inserted at each level shown by dashed
After deletion of K – 50, we get following
box and in this process the new root can
- tree
be created. Hence 5 is the answer 20

3. [Ans. C]
Size of Key = K=9 Bytes
15 30
Size of Block = B = 512 Bytes 40
Size of Record Pointer = RP = 7 Bytes
Size of Block Pointer = BP = 6 Bytes
Order (non-leaf node) of B + Tree = n =? 10 15 20 25 30 40
(n × BP) + (n ) K=B
So (i) is true
(n × 6) + (n ) 9 =512
(ii) is also true
n=CEIL (521/15) = CEIL (34.73) = 34
(iii) is false because root not remain
unchanged
4. [Ans. C]
The seek time of disk is 4ms and data
8. [Ans. C]
transfer node is 300 MB/s. So if x = 5000
DATA FILE
then plan 1 execute faster than plan 2 for
File → Ordered on Non – Key field
all database.
Total no. of Records = 16384 records
Size of the Record = 32 Bytes
5. [Ans. A]
INDEX FILE
Order (leaf node) = max (value, record
Type of Index = Secondary Index ( ey) →
pointers) = n =?
DENSE INDEX
Size of Block = B = 1K bytes
Size of Key = 6 Bytes
= 1024 Bytes
Size of block pointer =10 Bytes
Size of Record Pointer = RP = 7 Bytes

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 360
GATE QUESTION BANK DBMS

Size of the Block =1024 Bytes Insert: 4


Size of the Index Record 2
4 6
= 10 + 6 = 16 Bytes
No. of Index Records that can fit in a
single block = 1024/16 = 64 3* 4* 6* 8* 10*
Total No. of Index Records = DENSE = Insert: 2
16384 index records
4
Total No. of Blocks for First Level Index = 3
16384/64 = 256 blocks
Total No. of Blocks for Second Level Index
= 256/64=4 blocks 3 6

9. [Ans. A]
A clustering index is defined on the fields 2* 3* 4* 6* 8* 10*
which are of type non-key and ordering.
Insert: 1
10. [Ans. C] 4
4
Insert into B+ Tree in the order 10, 3, 6,
8, 4, 2, 1 & Calculate the No. of leaf Splits
2 3 6
Order of Non Leaf Node = 3

Max Pointers = 3 1* 2* 3* 4* 6* 8* 10*


K1 K1 Min Pointers = CEIL (3/2) =2
Min Pointers for ROOT = 2 Total no. of Leaf Splits in B+ Tree=4

Order of Leaf Node = 2 11. [Ans. C]


Clustered if the data is ordered in same
I1 I2 Max Keys = 2 order as the index order
Min Keys = 1

Insert : 10
10*

Insert: 3
3* 10*

Insert: 6
6 1

3* 6* 10*
Insert: 8
6

3* 6* 8* 10*

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 361
GATE QUESTION BANK Computer Networks

Introduction to Computer Networks


CS – 2005 The output capacity of multiplexer is
1. In a network of LANs connected by 5000 bits per time unit. Then the average
bridges, packets are sent from one LAN to number of backlogged of packets per time
another through intermediate bridges. unit during the given period is
Since more than one path may exist (A) 5 (B) 4.45 (C) 3.45 (D) 0
between two LANs, packets may have to
5. A group of 15 routers are interconnected
be routed through multiple bridges. Why
in a centralized complete binary tree with
is the spanning tree algorithm used for
a router at each tree node. Router i
bridge-routing?
communicates with router j by sending a
(A) For shortest path routing between
message to the root of the tree. The root
LANs
then sends the message back down to
(B) For avoiding loops in the routing
router j. The mean number of hops per
paths
message, assuming all possible router
(C) For fault tolerance
pairs are equally likely is
(D) For minimizing collisions
(A) 3 (B) 4.53 (C) 4.26 (D) 5.26
2. In a packet switching network, packets
are routed from source to destination CS – 2008
along a single path having two 6. How many bytes of data can be sent in 15
intermediate nodes. If the message size is seconds over a serial link with baud rate
24 bytes and each packet contains a of 9600 in asynchronous mode with odd
header of 3 bytes, then the optimum parity and two stop bits in the frame?
packet size is: (A) 10,000 bytes (C) 15,000 bytes
(B) 12,000 bytes (D) 27,000 bytes
(A) 4 (B) 6 (C) 7 (D) 9
CS – 2007 CS – 2014
3. Match the following : 7. In the following pairs of OSI protocol
P. SMTP 1. Application layer layer/sub-layer and its functionality. The
INCORRECT pair is
Q. BGP 2. Transport layer
(A) Network layer and Routing
R. TCP 3. Data link layer
(B) Data Link Layer and Bit
S. PPP 4. Network layer
synchronization
5. physical layer
(C) Transport layer and End-to-end
(A) P 2, Q 1, R 3, S 5
process communication
(B) P 1, Q 4, R 2, S 3
(D) Medium Access Control sub-layer
(C) P 1, Q 4, R 2, S 5
and Channel sharing
(D) P 2, Q 4, R 1, S 3
8. A bit-stuffing based framing protocol uses
4. Let us consider a statistical time division an 8-bit delimiter pattern of 01111110. If
multiplexing of packets. The number of the output bit-string after stuffing is
sources is 10. In a time unit, a source 01111100101, then the input bit-string is
transmits a packet of 1000 bits. The (A) 0111110100 (C) 0111111101
number of sources sending data for the (B) 0111110101 (D) 0111111111
first 20 time units is 6, 9, 3, 7, 2, 2, 2, 3, 4,
6, 1, 10, 7, 5, 8, 3, 6, 2, 9, 5 respectively.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 362
GATE QUESTION BANK Computer Networks

Answer keys & Explanations

1. [Ans. B] Mode = Asynchronous Mode


Spanning Tree Algorithm is used for To send ever 8-bits, we have to send
bridges for avoiding loops in the routing 1start bit, 2 stop bits, and 1 parity bit.
Total bits required to send 8-bit character
paths. Spanning Tree algorithm will make
= 8 + 1 + 2 + 1 = 12 bits
sure that there will be only one path [over head = 4 bits/byte]
between every 2 LAN’s Each signal can transmit 1-bit of data.
To send 8-bits we have to send
2. [Ans. D] 12 bits 12 signals to be used for 8-bit
Consider choices data.
(A) Packet size = 4 then message size = Thus total no of 8-bit characters sent per
second
4 3 = 1 byte (required 24 packets)
= 9600/12
(B) Packet size = 6 then message size = = 800 characters [Bytes/second]
6 3 = 3 bytes (required 8 packets) Total Bytes transmitted in 15 seconds
(C) Packet size = 7 then message size = = 800 × 15 = 12,000 Bytes.
7 3 = 4 bytes (required 6 packets)
(D) Packet size = 9 then message size = 7. [Ans. B]
9 3 = 6 bytes (required 4 packets) Since Bit Synchronization Physical
So 4 packets is optimum message size & 9 Layer Responsibility, It’s not Data Link
is optimum packet size. Layer’s Responsibility

3. [Ans. B] 8. [Ans. B]
SMTP ---------- Application layer 8-bit delimeter = 01111110 We will
BGP ------------ Network layer stuff with “0” after every 5 consecutive 1’s
TCP ------------ Transport layer Output String = 011111 00101 [Stuffed
PPP ------------- Data link layer bit has been highlighted]
Then, Input String = 0111110101 [After
4. [Ans. C] destuffing the stuffed “0”]
Total no. of source = 10
Packet size = 1000 bits
Output capacity of multiplexer= 5000 bits
∴ Average number of backlogged of
packet = 3.45

5. [Ans. D]
Mean Number of hop = 5.26

6. [Ans. B]
How many bytes of data can be sent in 15
seconds?
Baud Rate = 9600 [9600 signals can be
transmitted per second]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 363
GATE QUESTION BANK Computer Networks

Medium Access Sublayer


(LAN Technologies: Ethernet, Token Ring)
CS – 2005 5. Suppose the round trip propagation delay
1. Which of the following statements is for a 10 Mbps Ethernet having 48-bit
TRUE about CSMA/CD jamming signal is 46.4 µs. The minimum
(A) IEEE 802.11 wireless LAN runs frame size is:
CSMA/CD protocol (A) 94 (B) 416 (C) 464 (D) 512
(B) Ethernet is not based on CSMA/CD
protocol CS – 2006
(C) CSMA/CD is not suitable for a high 6. Station A needs to send a message
propagation delay network like consisting of 9 packets to Station B using
statellite network. a siding window (window size 3) and
(D) There is no contention in a CSMA/CD go-back-n error control strategy. All
network packets are ready and immediately
available for transmission. If every 5th
2. A network with CSMA/CD protocol in the packet that A transmits gets lost (but no
MAC layer is running at 1 Gbps over a acks from B ever get lost), then what is
1 km cable with no repeaters. The signal the number of packets that A will
speed in the cable is 2 ×108 m/sec. The transmit for sending the message to B?
minimum frame size for this network (A) 12 (C) 16
should be (B) 14 (D) 18
(A) 10000 bits (C) 5000 bits
(B) 10000 bytes (D) 5000 bytes CS – 2007
7. In Ethernet when Manchester encoding is
3. A channel has a bit rate of 4 kbps and one-
used the bit rate is
way propagation delay of 20 ms. The
(A) Half the baud rate
channel uses stop and wait protocol. The
(B) Twice the baud rate
transmission time of the
(C) Same as the baud rate
acknowledgement frame is negligible. To
(D) None of these
get a channel efficiency of at least 50%,
the minimum frame size should be
8. There are n stations in a slotted LAN.
(A) 80 bytes (C) 160 bytes
Each station attempts to transmit with a
(B) 80 bits (D) 160 bits
probability p in each time slot. What is the
4. In a TDM medium access control bus LAN, probability that ONLY one station
each station is assigned one time slot per transmits in a given time slot?
cycle for transmission. Assume that the (A) np(1 – p)n – 1 (C) p(1 – p)n – 1
length of each time slot is the time to (B) (1 – p) n – 1 (D) 1 (1 – p)n – 1
transmit 100 bits plus the end-to-end
9. In a token ring network the transmission
propagation delay. Assume a propagation
speed is 10 bps and the propagation
speed of 2 × 108 m/sec. The length of the
speed is 200 meters/ s. The 1-bit delay in
LAN is 1 km with a bandwidth of
this network is equivalent to :
10 Mbps. The maximum number of
(A) 500 meters of cable
stations that can be allowed in the LAN so
(B) 200 meters of cable
that the throughput of each station can be
(C) 20 meters of cable
2/3 Mbps is:
(D) 50 meters of cable
(A) 3 (B) 5 (C) 10 (D) 20
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 364
GATE QUESTION BANK Computer Networks

10. A broadcast channel has 10 nodes and 14. The minimum frame size required for
total capacity of 10 Mbps. It uses polling CSMA/CD based computer network
for medium access. Once a node finishes running at 1 Gbps on a 200m cable
transmission, there is a polling delay of with a link speed of 2 10 m/s is
80 s to poll the next node. Whenever a (A) 125 bytes
node is polled, it is allowed to transmit a (B) 250 bytes
maximum of 1000 bytes. The maximum (C) 500 bytes
throughput of the broadcast channel is (D) None of the above
(A) 1 Mbps (C) 10 Mbps
(B) 100/ 11 Mbps (D) 100 Mbps CS – 2013
15. Determine the maximum length of the
Common Data for Questions 11 & 12: cable (in km) for transmitting data at a
Consider a token ring topology with N rate of 500 Mbps in an Ethernet LAN with
stations (numbered 1 to N) running token frames of size 10,000 bits. Assume the
ring protocol where the stations are signal speed in the cable to be
equally spaced. When a station gets the 2,00,000 km/s.
token it is allowed to send one frame of (A) 1 (C) 2.5
fixed size. Ring latency is tp, while the (B) 2 (D) 5
transmission time of a frame is tt. All
other latencies can be neglected.
11. The maximum utilization of the token
ring when tt = 3 , tp = 5 ms, N =10 is
(A) 0.545 (C) 0.857
(B) 0.6 (D) 0.961

12. The maximum utilization of the token


ring when tt = 5ms , tp = 3 ms, N =15 is
(A) 0.545 (C) 0.9375
(B) 0.655 (D) 0.961

CS – 2008
13. 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 16
Megabits. What is the maximum duration
for which the computer can transmit at
the full 10Mbps?
(A) 1.6 seconds (C) 5 seconds
(B) 2 seconds (D) 8 seconds

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 365
GATE QUESTION BANK Computer Networks

Answer Keys & Explanations


1. [Ans. C] 6. [Ans. C]
CSMA/CD is not suitable for a high
propagation delay network like satellite
network.

2. [Ans. A]
Access Method = CSMA/CD
Bandwidth = B = 1Gbps = 109 bits/sec
Distance = d = 1km = 103 mts
Speed of Signal = s = 2 × 108 mts/sec
Minimum Frame Size = =?
= 2 × d/s × B bits
= 2× ×109=10,000 bits

3. [Ans. D]
Bandwidth = B = 4 Kbps
= 4 × 103 bits/sec
Number of packets = 16
Propagation Delay = Tp = 20 ms
= 20 × 10 sec
7. [Ans. A]
Protocol = Stop-and-Wait
Manchester ncoding 2 signals will be
Transmission Time for Ack = Negligible
used for sending 1-bit. For sending 10
= 0 sec
bits, we have to send 20 signals. Hence
Channel Efficiency = 50% = 1/2
baud rate is twice the bandwidth.
[Utilization]
Bandwidth = Baud rate/2 [Half the baud
Minimum Frame Size = F = ?
T rate]
fficiency
T 2T
8. [Ans. A]
1
p(1) = n p 1 p
2 2 20 10 4 10
n
160 bits = p 1 p
1 n 1
4. [Ans. C] = np 1 p
2 100
n 10 n 10 9. [Ans. C]
3 15 10
LAN = Token Ring
5. [Ans. C] Bandwidth = B = 10 bits/sec
Propagation Speed = 200 mts/micro
Round trip propagation delay
seconds [signal travels 200 meters in
(2 T ) 46.4 sec 46.4 10 10 seconds]
Frame size 2 T andwidth 1 bit delay in this network = ?
46.4 10 10 10 As B= 10 bits/sec, To place 1-bit in the
464 bits channel it takes 10 sec
As signal travels 200 meters in 10-6
seconds, then how much distance 1-bit
travels in 10 sec ?
10 seconds 200 meters
10 seconds ? meters
= 20 meters

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 366
GATE QUESTION BANK Computer Networks

10. [Ans. B] 15. [Ans. B]


Polling delay 80 s Distance of the Cable = d = ? [in kms]
Max t 8000 bits, 800 s at 10 Mbps Bandwidth = B = 500 Mbps
= 500 × 106 bits/sec
Max throughput = DR
LAN = Ethernet  Access Control
10 10 Mbps Protocol = 1 Persistent CSMA/CD
Size of Frame = F = 10,000 bits
Speed of Signal = S = 2,00,000 km/sec
11. [Ans. C] d
LAN = Token Ring 2 bits
s
Total no. of Stations = N = 10 10,000 = 2 × (d/ 2, 00,000) × 500 × 106
Ring Latency = t = 5 ms d = 2 kms
Transmission Time = t = 3 ms
Max Utilization
U = (N ×t ) / ((N × t +t )
= (10×3) / ((10×3) + 5)
= 30/35
= 0.857

12. [Ans. D]
LAN = Token Ring
Total no. of Stations = N = 15
Ring Latency = t = 3 ms
Transmission Time = t = 5 ms
Max Utilization
U= (N × t ) / ((N × t )+ t )
= (15×5) / ((15×5 )+ 3)
= 75/78
= 0.961

13. [Ans. B]
Bandwidth = B =10 Mbps
Token Bucket filled at the rate = r
= 2 Mbps
Capacity of Token Bucket = C
= 16 Mega bits
Max Duration at which computer can
transmit at fully 10 Mbps rate = S = ?
S = C/(B r)
= 16/(10 2)
= 2 seconds.

14. [Ans. B]
Min frame size 2 data rate
2 10
2 10 10
2 10
2000 bits = 250 bytes

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 367
GATE QUESTION BANK Computer Networks

The Data Link Layer


(Flow and Error Control Techniques)

CS – 2005 window size of N packets. Each packet


1. The maximum window size for data causes an ack or a nak to be generated by
transmission using the selective reject the receiver and ack/nak transmission
protocol with n bit frame sequence times are negligible. Further, the round
numbers is: trip time on the link is equal to N units.
(A) 2 (C) 2 – 1 Consider time i > N. if only acks have
(B) 2 –
(D) 2 – been received till time i(no naks), then
the goodput evaluated at the transmitter
2. Consider the following message at time i(in packets per unit time) is
M = 1010001101. The cyclic redundancy (A) 1 – N/ i (C) 1
check (CRC) for this message using the (B) i/ (N + i) (D) 1 – e
divisor polynomial x x x 1 is:
(A) 01110 (C) 10101 CS – 2007
(B) 01011 (D) 10110 6. The message 11001001 is to be
transmitted using the CRC Polynomial
CS – 2006 x 1 to protect it from errors. The
3. Station A uses 32 byte packets to transmit message that Should be transmitted is:
messages to station B using a sliding (A) 11001001000 (C) 11001010
window protocol. The round trip delay (B) 11001001011 (D) 110010010011
between A and B is 80 milliseconds and
the bottleneck bandwidth on the path 7. The distance between two stations M & N
between A and B is 128 kbps. What is the is L kilometers. All frames are K-bits long.
optimal window size that A should use? The propagation delay per kilometer is
(A) 20 (C) 160 t seconds. Let R bits/sec be the channel
(B) 40 (D) 320 capacity. Assuming that processing delay
is negligible, the minimum number of bits
4. Which of the following statements is for the sequence number field in a frame
TRUE? for maximum utilization, when the
(A) Both Ethernet frame and IP packet sliding window protocol is used, is:
include checksum fields (A) [log ] (C) [log ]
(B) Ethernet frame includes a checksum
field and IP packet includes a CRC (B) [log ] (D) [log ]
field
(C) Ethernet frame includes a CRC field
CS – 2008
and IP packet includes a checksum
8. Data transmitted on a link uses the
field
following 2D parity scheme for error
(D) Both Ethernet frame and IP packet
detection :
include CRC fields
Each sequence of 28 bits is arranged
in a 4 7 matrix ( rows r through r ,
5. Suppose that it takes 1 unit of time to
and columns d thorugh d ) and is
transmit a packet (of fixed size) on a
padded with a column d an row r of
communication link. The link layer uses a
parity bits computed using the Even
window flow control protocol with a
parity scheme . Each bit of column d

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 368
GATE QUESTION BANK Computer Networks

(respectively , row r ) gives the parity always piggy backed. After sending 2
of the corresponding row (respectively , frames, what is the minimum time the
column). These 40 bits are transmitted sender will have to wait before starting
over the data link . transmission of the next frame? (Identify
the closest choice ignoring the frame
0 1 0 1 0 0 1 1 processing time)
1 1 0 0 1 1 1 0 (A) 16 ms (C) 20 ms
0 0 0 1 0 1 0 0 (B) 18 ms (D) 22 ms
0 1 1 0 1 0 1 0
1 1 0 0 0 1 1 0 CS – 2012
The table shows data received by a 12. Consider a source computer (S)
receiver and has n corrupted bits. What transmitting a file size 106 bits to a
is the minimum possible value of n ? destination computer (D) over a network
(A) 1 (C) 3 of two routers (R1 and R2) and three (L1, L2,
(B) 2 (D) 4 and L3). L1 connects S to R1;L2 connects R1
to R2; and L3 connects R2 to D. Let each link
CS – 2009 be of length 100 km. Assume signals travel
9. Let G(x) be the generator polynomial over each link at a speed of 108 meters per
used for CRC checking. What is the second. Assume that the link bandwidth
condition that should be satisfied by G(x) on each link is 1Mbps. Let the file be
to detect odd number of bits in error? broken down into 1000 packets each of
(A) G(x) contains more than two terms size 1000bits. Find the total sum of
(B) G(x) does not divide 1 + x , for any transmission and propagation delays in
k not exceeding the frame length transmitting the file from S to D?
(C) 1 + x is a factor of G(x) (A) 1005 ms (C) 3000 ms
(D) G(x) has an odd number of terms (B) 1010 ms (D) 3003 ms

Statement for Linked Answer Questions 10 CS – 2014


and 11: 13. Consider a token ring network with a
Frames of 1000 bits are sent over a length of 2 km having 10 stations
10 bps duplex link between two hosts. including a monitoring station. The
The propagation time is 25 ms. Frames propagation speed of the signal is
are to be transmitted into this link to 2 10 m/s and the token transmission
maximally pack them in transit (with in time is ignored. If each station is allowed
the link) to hold the token for 2 sec, the minimum
10. What is the minimum number of bits ( ) time for which the monitoring station
that will be required to represent the should wait (in sec) before assuming
sequence numbers distinctly? Assume that the token is lost is _______.
that no time gap needs to be given
between transmission of two frames. 14. Consider a selective repeat sliding
(A) l 2 (C) l 4 window protocol that uses a frame size of
(B) l 3 (D) l 5 1 KB to send data on a 1.5 Mbps link with
a one-way latency of 50 msec. To achieve
11. Suppose that the sliding window protocol a link utilization of 60%, the minimum
is used with the sender window size of 2 , number of bits required to represent the
where is the number of bits identified in sequence number field is ________.
the earlier part and acknowledgments are

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 369
GATE QUESTION BANK Computer Networks

15. Consider the store and forward packet Consider only transmission time and
switched network given below. Assume ignore processing, queuing and
that the bandwidth of each link is propagation delays. Also assume that
10 bytes / sec. A user on host A sends a there are no errors during transmission.
file of size 10 bytes to host B through Let T1, T2 and T3 be the times taken to
routers R1 and R2 in three different ways. transmit the file in the first, second and
In the first case a single packet containing third case respectively. Which one of the
the complete file is transmitted from A to following is CORRECT?
B. In the second case, the file is split into A B
R1 R2
10 equal parts, and these packets are
(A) T1 T2 T3
transmitted from A to B. In the third case,
(B) T1 T2 T3
the file is split into 20 equal parts and
(C) T2 = T3 , T3 < T1
these packets are sent from A to B. Each
(D) T1 = T3, T3 > T2
packet contains 100 bytes of header
information along with the user data.

Answer Keys & Explanations


1. [Ans. B] 3. [Ans. B]
In the case of selective reject protocol; the Given round trip delay
maximum window size = 2 t = 80 ms = 80 10
R = 128 Kbps = 128 × 10 bps
L = Rt = 128 × 10 × 80 × 10
2. [Ans. A]
So, optimal window size
Message = data word=1010001101
Divisor x x x 1 n 40
110101 6 bits]
CRC = ? [Remainder] 4. [Ans. C]
Augmented data word Ethernet frame include a CRC field and IP
= data word + 5 bits[zeros] packet include a checksum field.
= 101000110100000
110101 101000 ① ① ⓪ ① ⓪ ⓪ ⓪ ⓪ ⓪ 1101010110 5. [Ans. C]
110101
111011 The link later uses a window from control
110101 protocol with a window size of N packets
011101
000000
and round trip time is equal to N units.
111010 Goodput = Packets/unit time
110101
011111 = N packets/N units = 1.
000000
111110
110101 6. [Ans. B]
010110 Message = data word =11001001
000000
101100
Divisor x 1
110101 1. x 0. x 0. x 1. x
110010
110101
1001 4 bits]
001110 Code word
000000
= data word +3 – redundant bits =?
01110
Augmented dataword = 11001001 000
R 01110

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 370
GATE QUESTION BANK Computer Networks

1001) 1100 ①⓪⓪ ① ⓪ ⓪ ⓪ 11010011 9. [Ans. C]


1001
1011 The polynomial generator used for CRC
1001 checking must satisfy at least two
0100
0000 conditions to detect odd numbers of
1000 errors:
1001
0011
1. It should be not divisible by x
0000 2. It should be divisible by 1 + x
0110 Therefore 1 x is a factor of G(x)
0000
1100
1001 10. [Ans. D]
1010
1001
The link is a duplex hence we need not to
011 wait for twice the propagation time for
Remainder 011 sending the frame belonging to next
Code word = Data word + Remainder window. If the sender window is of size N.
11001001 011 Transmitting 10 bits require = 1 sec
1
N 1000 bits require N 10
7. [Ans. C] 10
Frame Size = K bit N 10 sec Nm sec
Propagation delay = t sec/km Nm sec = 25 m sec, N = 25 2
Channel capacity = Rbits/sec ∴Minimum number of bits required is 5 to
Distance = L km represent sequence numbers distinctly
Round trip delay = 2Lt sec.
11. [Ans. B]
Window size w = 1 Time taken to send 10 bits 1 sec
∴ Time taken to send 2 frames = 32 m sec
1 (1 frame = 1000 bits)
Time taken for the first frame to be
acknowledged 25 2 50 m sec
# of bits = ⌈log ⌉ Then waiting time 50 32 18 m sec

8. [Ans. C] 12. [Ans. A]


The receiver will calculate all the row and Size of files = 10
column parities and found that there is an Total Routes = 2{ , }
error in 1-row and 2- columns. Total links = 3 { , , }
No. of errors detected in rows = 1 [r1] Length of each Link
No. of errors detected in columns = 3 [d5, = d= 100 km = 100 10
d2, d0]
Speed of signal of each link
Minimum possible errors
= max (errors in rows, errors in columns) = s= 10 mts Sec
L1 L2 L3
= max (1, 3) = 3 errors. S R R D

0 1 0 1 0 0 1 1 0 d= 100 kms d= 100 kms d= 100 kms


1 1 0 0 1 1 1 0 1 s = 10 mts sec s = 10 mts sec s = 10 mts sec

0 0 0 1 0 1 0 0 0 Band width = B = 1 MBPS = 10 bits sec


0 1 1 0 1 0 1 0 0 File is broken in to 1000 packets
1 1 0 0 0 1 1 0 0 n 1000 Packets
0 0 1 0 0 1 0 1 Size of Packet = F = 1000 bits
[10 bits 1000 packet 1000]

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 371
GATE QUESTION BANK Computer Networks

Find the sum of [T T ] in transmitting  Ring latency of token to be


a file from S to D? considered. [Time for token to
1000 bits traverse the entire ring]
T 10 sec 1ms
10 bits sec Ring Latency = Distance/Speed
d 100 10 10
T 10 sec 1 ms 2 10 seconds
s 10 2 10
T 1ms 10 10 seconds
T 1ms Minimum Time Monitor Station should
T T ] for I frame from S to D wait
3 T 3 T = (n 1) token holding time + ring
3 1ms 3 1ms 6 ms latency
T T ] for I frame 6 ms 10 1 2 10 seconds
T T ] for II frame 1ms 10 10 seconds
7 ms 7ms 6ms 1ms] 18 10 seconds
Receiver will reactive I frame after 10 10 seconds
6 ms and the successive frames in 1ms 28 10 seconds
only. 28 micro seconds.
Total T T ] for 1000 packet
= 6 ms for I packet 14. [Ans. 5]
999 ms for 999 packet Size of Frame = F = 1KB = 1024 Bytes
1005 ms = 1024 × 8 bits
P4 P3 P2 P1=6 ms Bandwidth 1.5 Mbps
S
L1
R
L2
R
L3
D 1.5 10 bits/sec
One Way Latency= Propagation
All packets are ready & reach to
Time = T = 50 msec 50 10 sec
destination in 1 ms gap
Utilization = 60% = 60/100
Minimum number of bits required to
13. [Ans. *] Range 28 to 30
represent the sequence number= ?
Total number of Stations in the Ring = n
Let window size = number of frames in
= 10 stations [including monitor station]
sender window = n
Length (or) distance of Ring
Utilization
= 2 km = 2 10 mts
= n × F bits / (F + 2 × × B) bits
Propagation Speed = 2 10 m/s
60 n
Token Holding time of each station 1024 8 bits 1024 8
100 2
= 2 micro seconds = 2 10 seconds
2 50 10
Ignore token transmission time
1.5 10 bits
Minimum time monitor station should n
wait before assuming that token is lost is 60 1024 8 2 50 10
2
= ? [in Micro Seconds] 1.5 10 1024
Minimum time monitor station should get 8 100
the token = (n 1) token holding time + n 949152
11.58 12 approx
ring latency 2 81920
 (n 1) Excluding Monitor station n = 24
 (n 1) stations token holding time to Total number of Frames in Sender
be considered Window = Sender Window Size
= 24 frames.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 372
GATE QUESTION BANK Computer Networks

Minimum number of bits required to


represent the sequence number in sender
window = log 24 4.58 5 bits

15. [Ans. D]
Given Bandwidth = 10 bytes/sec
L 10 bytes
Case: 1
L = 1000 bytes
Header size = 100 bytes
Total Frame size = 1000+100=1100
bytes
1100 8
∴T 1100 s
10 8
So, T 3300 s

Case: 2
L 100 bytes
Header size = 100 bytes
Total Frames size = 100 + 100 = 200 bytes
∴T 200 s for 1 packet
or 10 packets T 2000 s
So, T 2000 200 200 2400 s
Case: 3
L = 50 bytes
Header size = 100 bytes
Total frame size = 50 + 100 = 150 bytes
∴T 150 s for 1 packet
or 20 packets T 3000 s
So, T 3000 150 150 3300 s
∴T T
T T

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 373
GATE QUESTION BANK Computer Networks

Routing & Congestion Control

CS – 2005 (A) Table for (C) Table for


1. Count to infinity is a problem associated node A node B
with A - - A A 1
(A) link state routing protocol B B 1 B - -
(B) distance vector routing protocol C C 1 C C 1
(C) DNS while resolving host name D B 3 D D 1
(D) TCP for congestion control E C 3 E C 2
F C 4 F D 2
Statement for Linked Answer Questions 2
and 3: (B) Table for (D) Table for
Consider a simple graph with unit edge node C node D
costs. Each node in the graph represents a A A 1 A B 3
router. Each node maintains a routing
B B 1 B B 1
table indicating the next hop router to be
C - - C C 1
used to relay a packet to its destination
D D 1 D - -
and the cost of the path to the destination
E E 1 E E 1
through that router. Initially, the routing
F E 3 F F 1
table is empty. The routing table is
synchronously updated as follows. In each
3. Continuing from the earlier problem,
updated interval, three tasks are
suppose at some time t, when the costs
performed.
have stabilized, node A goes down. The
(i) A node determines whether its
cost from node F to node A at time
neighbours in the graph are
( t + 100) is:
accessible. If so, it sets the tentative
(A) > 100 but finite
cost to each accessible neighbour as
(B) ∞
1. Otherwise, the cost is set to ∞.
(C) 3
(ii) From each accessible neighbor, it
(D) 3 and ≤ 100
gets the costs to relay to other nodes
via that neighbor (as the next hop)
CS – 2008
(iii) Each node updates its routing table
4. Two popular routing algorithms are
based on the information received in
Distance vector (DV) and Link state (LS)
the previous two steps by choosing
routing . Which of the following are true?
the minimum cost.
S1: Count to infinity is a problem only
with DV and not LS routing
B S2: In LS, the shortest path algorithm is
run only at one node
A C D F S3: In DV, the shortest path algorithm is
run only at one mode
S4: DV requires lesser number of network
E messages than LS
2. For the graph given above, possible routing (A) S1, S2 and S4 ONLY
tables for various nodes after they have (B) S1, S3 and S4 ONLY
stabilized, are shown in the following (C) S2 and S3 ONLY
options. Identify the correct table? (D) S1 and S4 ONLY

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 374
GATE QUESTION BANK Computer Networks

CS – 2010 The network uses a Distance Vector


Statement for Linked Answer Questions 5 Routing protocol. Once the routes have
and 6: stabilized, the distance vectors at
Consider a network with 6 routers R1 to different nodes are as following:
R6 connected with links having weights N1: (0, 1, 7, 8, 4)
as shown in the following diagram. N2: (1, 0, 6, 7, 3)
R2
7
R4
N3: (7, 6, 0, 2, 6)
6 AS 8 N4: (8, 7, 2, 0, 4)
R1
B5: (4, 3, 6, 4, 0)
2 R6
1 Each distance vector is the distance of the
3 4 best known path at the instance to nodes,
R3 9 R5 N1 to N5, where the distance to itself is 0.
Also, all links are symmetric and the cost
5. All the routers use the distance vector
is identical in both directions. In each
based routing algorithm to update their
round, all nodes exchange their distance
routing tables. Each router starts with its
vectors with their respective neighbors.
routing table initialized to contain an
Then all nodes update their distance
entry for each neighbor with the weight of
vectors. In between two rounds, any
the respective connecting link. After all
change in cost of a link will cause the two
the routing tables stabilize, how many
incident nodes to change only that entry
links in the network will never be used
in their distance vectors.
for carrying any data?
7. The cost of link N2 N3 reduces to
(A) 4 (C) 2
2(in both directions). After the next
(B) 3 (D) 1
round of updates, what will be the new
distance vector at node, N3
6. Suppose the weights of all unused links in
(A) (3, 2, 0, 2, 5) (C) (7, 2, 0, 2, 5)
the previous question are changed to 2
(B) (3, 2, 0, 2, 6) (D) (7, 2, 0, 2, 6)
and the distance vector algorithm is used
again until all routing tables stabilize.
8. After the update in the previous question,
How many links will now remain unused?
the link N1-N2 goes down. N2 will reflect
(A) 0 (C) 2
this change immediately in its distance
(B) 1 (D) 3
vector as cost, ∞. After the NEXT ROUND
of update, what will be the cost to N1 in
CS – 2011
the distance vector of N3?
Statement for Linked Answer Questions 7
(A) 3 (C) 10
and 8:
(B) 9 (D) ∞
Consider a network with five nodes, N1 to
N5 as shown below
CS – 2012
N1
9. An Internet Service Provider (ISP) has the
1 following chunk of CIDR-based IP address
3
N2
available with it: 245.248.128.0/20. The
N5
ISP wants to give half of this chunk of
addresses of Organization A, and a
4 6 quarter of Organization B, while retaining
the remaining with itself. Which of the
following of a valid allocation of
N4 N3 addresses to A and B?
2

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 375
GATE QUESTION BANK Computer Networks

(A) 245.248.136.0/21 and 12. An IP router implementing Classless


245.248.128.0/22 Inter-domain Routing (CIDR) receives a
(B) 245.248.128.0/21 and packet with address 131.23.151.76. The
245.248.128.0/22 router’s routing table has the following
(C) 245.248.132.0/22 and entries:
245.248.132.0/21 Prefix Output Interface
(D) 245.248.136.0/24 and Identifier
245.248.132.0/21 131.16.0.0/12 3
131.28.0.0/14 5
CS – 2013 131.19.0.0/16 2
131.22.0.0/15 1
10. Assume that source S and destination D
The identifier of the output interface on
are connected through two intermediate which this packet will be forwarded is
routers labeled R. Determine how many ___________
times each packet has to visit the network
layer and the data link layer during a 13. Which one of the following is TRUE about
transmission from S to D. the interior gateway routing protocols –
Routing Information Protocol (RIP) and
S R R D
Open Shortest Path First (OSPF)?
(A) RIP uses distance vector routing and
(A) Network layer – 4 times and
OSPF uses link state routing
Data link layer – 4 times (B) OSPF uses vector routing and RIP
(B) Network layer – 4 times and uses link state routing
Data link layer – 3 times (C) Both RIP and OSPF use link state
(C) Network layer – 4 times and routing
Data link layer – 6 times (D) Both RIP and OSPF uses distance
(D) Network layer – 2 times and vector routing
Data link layer – 6 times

CS – 2014
11. Consider the following three statements
about link state and distance vector
routing protocols, for a large network
with 500 network nodes and 4000 links.
[S1] The computational overhead in link
state protocols is higher than in distance
vector protocols.
[S2] A distance vector protocol (with split
horizon) avoids persistent routing loops,
but not a link state protocol.
[S3] After a topology change, a link state
protocol will converge faster than a
distance vector protocol.
Which one of the following is correct
about S1, S2, and S3 ?
(A) S1, S2, and S3 are all true
(B) S1, S2, and S3 are all false
(C) S1 and S2 are true, but S3 is false
(D) S1 and S3 are true, but S2 is false.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 376
GATE QUESTION BANK Computer Networks

Answer Keys & Explanations


1. [Ans. B] Routing table
Associated with distance vector routing For R1
algorithm Next hop
R2 5 R3
2. [Ans. C] R3 3 R3
Table for node B R4 12 R3
A A 1 R5 12 R3
B - - R6 16 R3
C C 1
D D 1 For R2
E C 2 Next hop
F D 2 R1 5 R3
R2 2 R3
3. [Ans. A] R3 7 R4
Node “A” goes down at time “t”. At time R4 8 R4
t 100 the cost from Node “ ” to node
“A” will definitely be > 100 and finite, R5 12 R4
because Node “ ” will receive cost from
neighbor “D” where as “D” will have 3 For R3
neighbors {B, C, E} and at least one Next hop
neighbor will give finite cost. R2 3 R1
R3 2 R2
4. [Ans. D]
R4 9 R4
S1 True, Since ount To Infinity is only
a problem with DV but not LS R5 9 R5
S2 alse, since in LS, the shortest path R6 13 R5
algorithm is run at all nodes
S3 alse, since in DV, we don’t use any For R4
shortest path algorithm Next hop
S4 True, since in DV, each node shares R1 12 R2
its routing table only with its
neighbors, where as inLS each node R2 7 R2
broadcast its routing table to all R3 9 R2
nodes in the network. R5 1 R5
R6 5 R5
5. [Ans. C]
7 For R5
R2 R4
6 8
Next hop
R1
2 R6 R1 12 R3
1
R2 8 R4
3 4 R3 9 R3
R3 9 R5 R4 1 R4
R6 4 R6

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 377
GATE QUESTION BANK Computer Networks

For R6 9. [Ans. A]
Next hop Network ID = 245.248.128.0/20
R1 16 R5 alf of this IP addresses to “A”
ISP wants VLSM
R2 12 R5
to give Quarter to Organization “ ”
R3 13 R5
Retaining the remaining with
R4 5 R5 itself [Quarter]
R5 4 R5 Total subnets 2
2 level subnetting
So it is clear visualize from the all routing osts Subnet 2 2
table construction that we never use the
direct path between
6 8
R1 R2 and R4 R6

So two links never be used for carrying


data.

6. [Ans. B]
After changing the weights of unused link
R1 R2 & R4 R6 to 2. Then the no. of
unused links are only one [R5 R6]
7
2 R2 R4 2
6 8

R1 R6
2 1

3 4
R3 9 R5
Link R5-R6 will
be unused

7. [Ans. A]
In the next round, every node will send
and receive distance vectors to and from
neighbours, and update its distance
vector. N3 will receive (1, 0, 2, 7, 3) from
N2 and it will update distance to N1 and
Total soultions 2
N5 as 3 and 5 respectively
S. No Organization Network ID/
Subnet mast
8. [Ans. C] 1 A 50 245.248.128.0 21
In the next ground, N3 will receive 25 245.248.136.0 22,
distance from N2 to N1 as infinite. It will 245.248.140.0/22
receive distance from N4 to N1 as 8. So it 2 A 50 245.248.136.0 21
will update distance to N1 as 8+2 =10 25 245.248.128.0 22,
245.248.140.0/22

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 378
GATE QUESTION BANK Computer Networks

10. [Ans. C]
Network Layer = 4 times &
Data link layer = 6 times
S R R D
Network Network
Data link Data link

Physical Physical

11. [Ans. D]
S1 True, since in Link State Routing
every node has to execute the
shortest path algorithm.
S2 False, since looping problem is not
eliminated completely by Split
Horizon.
S3 True, since in Link State each node
broadcast the topology changes to
all other nodes in the network,
where as Distance Vector informs
only to its neighbors.

12. [Ans. 1]
IP Address = 131.23.151.76
Binary Value of given IP Address =
10000011. 00010111. 10010111.
0100110
We always compare the IP with the
Highest Mask.
131.19.0.0/16
10000011.00010011.00000000.
00000000 Match Failed
131.22.0.0/15
10000011.00010110.00000000.
00000000 Match Success
As the first 15 network bits of
131.22.0.0/15 and 131.23.151.76 are
same. So the outgoing interface will be
“1”.

13. [Ans. A]
RIP Routing Information Protocol uses
“Distance Vector Routing Algorithm”
OSPF Open Shortest Path First Protocol
uses “Link State Routing Algorithm”

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 379
GATE QUESTION BANK Computer Networks

TCP/IP, UDP and Sockets, IP(V4)


CS – 2005 5. On a TCP connection, current congestion
1. Packets of the same session may be window size is Congestion Window = 4 KB.
routed through different paths in: The window size advertised by the receiver
(A) TCP, but not UDP is Advertise Window = 6 KB. The last byte
(B) TCP and UDP sent by the sender is Last Byte Sent= 10240
(C) UDP, but not TCP and the last byte acknowledged by the
(D) Neither TCP nor UDP receiver is last byte acked = 8192.
The current window size at the sender is:
2. The address resolution protocol (ARP) is (A) 2048 bytes (C) 6144 bytes
used for: (B) 4096 bytes (D) 8192 bytes
(A) Finding the IP address from the DNS
(B) Finding the IP address of the default 6. In a communication network, a packet of
gateway length L bits takes link L1 with a
(C) Finding the IP address that probability of p1 or link L2 with a
corresponds to a MAC Address probability of p2 . Link L1 and L2 have bit
(D) Finding the MAC address that error probability of b1 and b2
corresponds to an IP Address respectively. The probability that the
3. An organization has a class B network and packet will be received without error via
wishes to for m subnets for 64 either L1 or L2 is:
departments. The subnet mask would be: (A) (1 b1)Lp1 + (1 b2)Lp2
(A) 255.255.0.0 (C) 255.255.128.0 (B) [1 (b1+b2)L]p1 p2
(B) 255.255.64.0 (D) 255.255.252.0 (C) (1 b1)L (1 b2)L p1 p2
(D) 1 (b1Lp1 + b2Lp2)
4. Trace-route reports a possible route that
is taken by packets moving from some 7. A company has a class C network address
host A to some other host B. Which of the of 204.204.204.0. It wishes to have three
following options represents the subnets, one with 100 hosts and two with
technique used by trace-route to identify 50 hosts each. Which one of the following
these hosts? options represents a feasible set of subnet
(A) By progressively querying routers address/subnet mask pairs?
about the next router on the path to (A) 204.204.204.128/255.255.255.192
B using ICMP packets, starting with 204.204.204.0/255.255.255.128
the first router. 204.204.204.64/255.255.255.128
(B) By requiring each router to append
the address to the ICMP packet as it (B) 204.204.204.0/255.255.255.192
is forwarded to B. The list of all 204.204.204.192/255.255.255.128
routers en-route to B is returned by 204.204.204.64/255.255.255.128
B in an ICMP reply packet.
(C) By ensuring that an ICMP reply (C) 204.204.204.128/255.255.255.128
packet is returned to A by each 204.204.204.192/255.255.255.192
router en-route to B, in the ascending 204.204.204.224/255.255.255.192
order of their hop distance from A
(D) By locally computing the shortest (D) 204.204.204.128/255.255.255.128
path from A to B 204.204.204.64/255.255.255.192
204.204.204.0/255.255.255.192

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 380
GATE QUESTION BANK Computer Networks

CS – 2006 11. A program on machine X attempts to


8. For which of the following reason does open a UDP connection to port 5376 on a
Internet Protocol (IP) use the machine Y and a TCP connection to port
time-to-live (TTL) field in the IP 8632 on machine Z. However, there are
datagram header? no applications listening at the ports y
(A) Ensure packets reach destination and Z. An ICMP port Unreachable error
within that time will be generated by
(B) Discard packet that reach later than (A) Y but not Z
that time (B) Z but not Y
(C) Prevent packets from looping (C) Neither Y nor Z
indefinitely (D) Both Y and Z
(D) Limit the time for which a packet
gets queued in intermediate routers 12. A subnetted Class B network has the
following broadcast address:
9. Two computers C1 and C2 are configured 144.16.95.255. Its subnet mask
as follows. C1 has IP address 203.197.2.53 (A) is necessarily 255.255.224.0
and netmask 255.255. 128.0. C2 has IP (B) is necessarily 255.255.240.0
address 203.197.75.201 and netmask (C) is necessarily 255.255.248.0
255.255.192.0. Which one of the (D) could be any one of 255.255.224.0,
following statements is true? 255.255.240.0, 255.255.248.0
(A) C1 and C2 both assume they are on
the same network Statement for Linked Answer Questions 13
(B) C2 assumes C1 is on same network, and 14:
but C1 assumes C2 is on a different Consider the diagram shown below
network where a number of LANs are connected
(C) C1 assumes C2 is on same network, by (transparent) bridges. In order to
but C2 assumes C1 is on a different avoid packets looping through circuit in
network the graph, the bridges organize
(D) C1 and C2 both assume they are on themselves in a spanning tree. First, the
different network root bridge is identified as the sends with
the least serial number. Next, the root
10. A router uses the following routing table: sends out (one or more) data unit to
Destination Mask Interface enable the setting up of the spanning tree
144.16.0.0 255.255.0.0 Eth0 of shortest paths from the root bridge to
144.16.64.0 255.255.224.0 Eth1 each bridge. Each bridge identifies a port
144.16.68.0 255.255.255.0 Eth2 (the root port) through which it will
144.16.68.64 255.255.255.224 Eth3 forward frames to the root bridge. Port
A packet bearing a destination address conflicts are always resolved in favour of
144.16.68.117 arrives at the router. On the port with the lower index value. When
which interface will it be forwarded? there is a possibility of a multiple bridge
(A) Eth0 (C) Eth2 forwarding to the same LAN(but not
(B) Eth1 (D) Eth3 through the root port), ties are broken as
follows: bridge closest to the root get
preference and between such bridges, the
one with lowest serial number is
preferred.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 381
GATE QUESTION BANK Computer Networks

B1 (C)
H1 H2 H3 H4 Hosts Port
1 2
H3, H4 3
2
H5, H6, H9, H10 1
4 3 H1, H2 4
B5 B3 H7, H8, H11, H12 2
3
1 4 1 2 (D)
Hosts Port
H1, H2, H3, H4 3
H5 H6 H7 H8
2 2 1 H5, H7, H9, H10 1
1 B4 B2
H7, H8, H11, H12 4

3 3

H9 H10 H11 H12


CS – 2007
15. The address of a class B host is to be split
into subnets with a 6 – bit subnet number.
13. For the given connection of LANs by What is the maximum no. of subnets and
bridges, which one of the following the maximum no. of hosts in each subnet?
choices represents the depth first (A) 62 subnets and 262142 hosts
traversal of the a spanning tree of (B) 64 subnets and 262142 hosts
bridges? (C) 62 subnets and 1022 hosts
(A) B1, B5, B3, B4, B2 (D) 64 subnets and 1024 hosts
(B) B1, B3, B5, B2, B4
16. Consider the following statements about
(C) B1, B5, B2, B3, B4
the timeout value used in TCP.
(D) B1, B3, B4, B5, B2
(i) The timeout value is set to the RTT
(Round Trip Time) measured during
14. Consider the correct spanning tree for the
TCP connection establishment for
previous question. Let host H1 send out a
the entire duration of the connection.
broadcast ping packet Which of the
(ii) Appropriate RTT estimation
following options represents the correct
algorithm is used to set the timeout
forwarding table on B3?
value of a TCP connection.
(A)
(iii) Timeout value is set to twice the
Hosts Port propagation delay from the sender to
H1, H2, H3, H4 3 the receiver
H5, H6, H9, H10 1 Which of the following choices hold?
H7, H8, H11, H12 2 (A) (i) is false, but (ii) and (iii) are true
(B) (B) (i) and (iii) are false, but (ii) is true
Hosts Port (C) (i) and (ii) are false, but (iii) is true
H1, H2 4 (D) (i), (ii) and (iii) are false
H3, H4 3
H5, H6 1 17. Consider a TCP connection in a state
H7, H8, H9, H10 2 where there are no outstanding ACKs. The
H11, H12 sender sends two segments back to back.
The sequence numbers of the first and
second segments are 230 and 290
respectively. The first segment was lost,

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 382
GATE QUESTION BANK Computer Networks

but the second segment was received (D) connect() system call returns in a
correctly by the receiver. Let X is the core dump
amount of data carried in the first
segment (in bytes) and Y is the ACK 22. In the slow start phase of the TCP
number sent by the receiver. congesting control algorithm the size of
The values of X and Y (in that order) are the congestion window
(A) 60 and 290 (C) 60 and 231 (A) Does not increase
(B) 230 and 291 (D) 60 and 230 (B) Increases linearly
(C) Increases quadratic ally
18. Which one of the following uses UDP as (D) Increases exponentially
the transport Protocol?
(A) HTTP (C) DNS 23. Which of the following system calls
(B) Telnet (D) SMTP results in the sending of SYN packets?
(A) socket (C) listen
CS – 2008 (B) blind (D) connect
19. What is the maximum size of data that the
application layer can pass on to the TCP CS – 2009
layer below? 24. While operating a TCP connection, the
(A) Any Size initial sequence no. is to be derived using
(B) 216 bytes – size of TCP header a time of day (TOD) clock that keeps
(C) 216 bytes running even when the host is down.
(D) 1500 bytes The low order 32 bit of the counter of the
TOD clock is to be used for the initial
20. If a class B network on the internet has a sequence numbers. The clock counter
subnet mask 255.255.248.0, what is the increments once per milli second. The
max no. of hosts per subnet? maximum packet lifetime is given to be
(A) 1022 (C) 2046 64s. Which one of the choices given
(B) 1023 (D) 2047 below is closest to the minimum
permissible rate at which sequence
21. A client process P needs to make a TCP numbers used for packets of a
connection to a server process S. connection can increase?
Consider the following situation: the (A) 0.015/s (C) 0.135/s
server process S executes a socket(), a (B) 0.064/s (D) 0.327/s
bind() & a listen() system call in that
order, following which it is preempted. CS – 2010
Subsequently, the client process P 25. One of the header fields in an IP datagram
executes a socket() system call followed is the Time-to-Live (TTL) field. Which of
by connect( ) system call to connect to the the following statements best explains the
server process S. The server process has need for this field?
not executed any accept() system call. (A) It can be used to prioritize packets.
Which one following events could take (B) It can be used to reduce delays.
place? (C) It can be used to optimize
(A) connect() system call returns throughput.
successfully (D) It can be used to prevent packet
(B) connect () system call blocks looping.
(C) connect() system call returns an
error

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 383
GATE QUESTION BANK Computer Networks

26. Suppose computers A and B have IP 31. In an IPv4 datagram, the M bit is 0, the
addresses 10.105.1.113 and 10.105.1.91 value of HLEN is 10, the value of total
respectively and they both use the same length is 400 and the fragment offset
netmask N. Which of the values of N given value is 300. The position of the
below should not be used if A and B datagram, the sequence numbers of the
should belong to the same network? first and the last bytes of the payload,
(A) 255.255.255.0 respectively are
(B) 255.255.255.128 (A) Last fragment, 2400 and 2789
(C) 255.255.255.192 (B) First fragment, 240 and 2759
(D) 255.255.255.224 (C) Last fragment, 2400 and 2759
(D) Middle fragment, 300 and 689
CS – 2012
27. In the IPV4 addressing format, the CS – 2014
number of networks allowed under Class 32. Let the size of congestion window of a
C address is TCP connection be 32 KB when a timeout
(A) 2 (C) 2 occurs. The round trip time of the
(B) 2 (D) 2 connection is 100 msec and the maximum
segment size used is 2 KB. The time taken
28. Which of the following transport layer
(in msec) by the TCP connection to get
protocol is used to support electronic
back to 32 KB congestion window is _____.
mail?
(A) SMTP (C) TCP
33. Which one of the following socket API
(B) IP (D) UDP
function converts an unconnected active
29. Consider an instance of TCP’s Additive TCP socket into a passive socket?
Increase Multiplicative Decrease (AIMD) (A) Connect (C) Listen
algorithm where the window size at the (B) Bind (D) Accept
start of the slow start phase is 2 MSS and
the threshold at the start of the first 34. In the diagram shown below, L1 is an
transmission is 8 MSS. Assume that a Ethernet LAN and L2 is a Token – Ring
timeout occurs during the fifth LAN. An IP packet originates from S and
transmission. Find the congestion traverses to R, as shown. The links within
window size at the end of the tenth each ISP and across the two ISPs, are all
transmission. point – to – point optical links. The initial
(A) 8 MSS (C) 7 MSS value of the TTL field is 32. The maximum
(B) 14 MSS (D) 12 MSS possible value of the TTL field when R
receives the datagram is ______.
ISP1 ISP2
CS – 2013
30. The transport layer protocols used for
LAN L2
real time multimedia, file transfer, DNS R
S LAN L1
and email, respectively are
(A) TCP, UDP, UDP and TCP
(B) UDP, TCP, TCP and UDP 35. Host A (on TCP/IPV4 network A) sends
(C) UDP, TCP, UDP and TCP an IP datagram D to host B (also on
(D) TCP, UDP, TCP and UDP TCP/IPV4 network B). Assume that no
error occurred during the transmission of
D. When D reaches B, which of the
following IP header field(s) may be
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 384
GATE QUESTION BANK Computer Networks

different from that of the original 37. An IP router with a Maximum


datagram D? Transmission Unit (MTU) of 1500 bytes
(i) TTL (ii) Checksum (iii) Fragment has received an IP packet of size
Offset 4404 bytes with an IP header of length
(A) (i) only 20 bytes. The values of the relevant fields
(B) (i) and (ii) only in the header of the third IP fragment
(C) (ii)and (iii) only generated by the router for this packet
(D) (i), (ii) and (iii) are
(A) MF bit: 0, Datagram Length: 1444;
36. Every host in an IPv4 network has a Offset: 370
1 second resolution real time clock (B) MF bit: 1, Datagram Length: 1424;
with battery backup. Each host needs to Offset: 185
generate up to 1000 unique identifiers (C) MF bit: 1, Datagram Length: 1500;
per second. Assume that each host has a Offset: 370
globally unique IPv4 address. Design a (D) MF bit: 0, Datagram Length: 1424;
50-bit globally unique ID for this purpose. Offset: 2960
After what period (in seconds) will the
identifiers generated by a host wrap
around?

Answer Keys & Explanations

1. [Ans. B] 4. [Ans. C]
In both TCP & UDP, packets of same ICMP reply packet is returned to A by
session will be routed in different paths, each router en-router to B.
because they are using IP protocol in the
Network Layer which is purely a
5. [Ans. B]
connection less protocol. Theoretically we
say that TCP is connection oriented Congestion window = cwnd = 4KB
protocol, it doesn’t mean that packets of Receiver window = rwnd = 6KB
same session will travel in the same path, Current Window Size = min(cwnd, rwnd)
we are simulating the connection by using = min(4KB, 6KB) = 4KB
buffers at both sender and receiver. Just to confuse us they provided the
Finally TCP is using a Virtual connection. additional information like Last Byte Sent
and Last Byte Acknowledged, which are
totally not required in finalizing the
2. [Ans. D]
window size.
ARP: Finding the MAC address that
corresponds to an IP address 6. [Ans. A]
Probability (p via L = 1 b p
3. [Ans. D] Probability (p via L = 1 b p
In a class B network initial two octets are ∴ Probability p) via L or L = p p
all 1’s but third octet specifies the
physical network for subnet of 64 7. [Ans. D]
department or 2 so initial 6 bits of third Class of network = class-C network
octets are 1’s [n=24, h=8] [25h hosts/Network]
11111111 . 11111111 .11111100 . 00000000
Network Address = 204.204.204.0
255 . 255 . 252 . 0
Requirement = 3 subnets

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 385
GATE QUESTION BANK Computer Networks

Subnet No of Hosts/Subnet 9. [Ans. C]


1 100 The two computers and are
2 50 configured as follows:
3 50
Types of subnetting = VLSM IP address 203.197.2.53 203.197.75.201
No of subnets = 2 and AND
No of hosts/subnet =2 2 Netmask 255.255.128.0 255.255.192.0
2 – levels subnetting required. 203.197.0.0 203.197.64.0
Initially Total Subnets = 2 2 2 Network address Network address
203.197.2.53 203.197.00000010.00111001
n 1 1 bit to be taken from host
255.255.192.0 255.255.11000000.00000000
n 25 203.197.0.0 203.197.0.0
h 8 203.197.75.201
255.255.128.0
203.192.0.0
∴ assumes is on same network but
assume is on different network

10. [Ans. C]
Boolean And (Destination Address, Mask)
Must give the Network ID
Given Destination Address =
144.16.68.117 = 144.16.68.01110101
Router always considers the Highest
Mask first, then second highest, and so
on…
First Highest Mask:-
Destination Network ID =144.16.68.64
and Mask = 255.255.255.224
Boolean And (144.16.68.117,
255.255.255.224)=144.16.68.96  Not
matching with NetworkID
Second Highest Mask:-
Destination Network ID =144.16.68.0 and
Mask = 255.255.255.0
Boolean And (144.16.68.117,
255.255.255.0)=144.16.68.0  Matched
with Network ID
Hence, the outgoing interface = Eth2
Total solution = 2
S. No Subnet Hosts/ Network ID/ Mask
subnet 11. [Ans. A]
1 100 204.204.204.0/255.255.255.128 Because UDP generate the error that
1 2 50 204.204.204.128/255.255.255.192
machine you are trying to reach is not
3 50 204.204.204.192/255.255.255.192
1 100 204.204.204.128/255.255.255.128 responding unlike TCP.
2 2 50 204.204.204.0/255.255.255.192
3 50 204.204.204.64/255.255.255.192
12. [Ans. D]
Broadcast Address with in a network 
8. [Ans. C]
All host bits will be 1’s. ontinuous 1’s]
TTL field in IP Datagram To prevent We cannot confidently say the exact no. of
packets from looping indefinitely. network bits in a subnetted network.
As all options are appropriate for the
given question.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.comPage 386
GATE QUESTION BANK Computer Networks

Broadcast Address = 144. 16.95.255 2 2 2 2 1024 2


=144. 16. 01011111.11111111 1022
Option A = 255. 255.224.0
=255.255.11100000.00000000 16. [Ans. B]
Option B = 255. 255.240.0 = TCP is using an appropriate RTT
255.255.11110000.00000000
estimation algorithm to set the timeout
Option C = 255. 255.248.0 =
255.255.11111000.00000000 value of a TCP connection. It is dynamic
and will change with every segment.
13. [Ans. A] Initial value of RTT is greater than that of
Spanning tree for the given diagram is as twice the propagation delay.
follows:-
1 2 17. [Ans. D]
B1
Difference between two consecutive
packets is amount of data carried in first
H1 H2 H3 H4 packet.
3
Here, 290 – 230 = 60
2 X = 60
1
B5 B3 Y = 230
2
18. [Ans. A]
H5 H6 H7 H8
Application layer can pass data of Any
1 1 Size to Transport Layer. The Transport
B4 B2 Layer can send data of any size in
3 3
multiple segments. Segmentation &
Reassembly is the responsibility of
H9 H10 H11 H12 Transport Layer to send data of any size
Three Possible Depth First Traversals are given by the application layer.
1. 1 5 3 4 2 19. [Ans. B]
2. 1 3 4 2 5
The maximum size of data that the
3. 1 3 2 4 5
Possibility: 1 is matching with Option A. application layer can pass on to the TCP
So obviously Answer = A layer is 2 bytes – size of TCP header.

14. [Ans. A] 20. [Ans. C]


By looking at the above diagram Bridge 11111111 . 11111111 . 11111000 .
“ 3” will broadcast to all the hosts as 00000000
follows:- ∴ No. of hosts per subnet
Hosts Port =2 2 2048 2= 2046
H1, H2, H3, H4 3
H5, H6, H9, H10 1 21. [Ans. C]
H7, H8, H11, H12 2 Connect ( ) system call returns an error.

15. [Ans. C] 22. [Ans. D]


The class B is defined as follows In the slow start phase, the size of the
congestion window increases exponentially.
0 16 31
1 0 net id host id 23. [Ans. D]
Connect system call is responsible for
Maximum number of subnet = 2 2 = 62 synchronize the packets
Maximum number of host in each subnet

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.comPage 387
GATE QUESTION BANK Computer Networks

24. [Ans. B] 27. [Ans. C]


0.064 is closest to the minimum Numbers of networks in class ‘ ’ are 2
permissible rate at which sequence as in class ‘ ’ there
number used for packet of a connection ⏟ ⏟
can increase.
Out of 24 bits 3-bits are used for representation
25. [Ans. D]
class ‘ ’ i.e. 110
Whenever Time to live field reaches ‘0’
∴ 21 bits.
we discard the packet. So, it can be used
With 21 bits we can make 2 networks
to prevent packet looping
28. [Ans. C]
26. [Ans. D]
UDP and TCP are transport layer protocol.
IP address of A = 10.105.1.113
TCP supports electronic mail.
10.105.1.01110001
∴Option ‘ ’ correct
IP address of B = 10.105.1.91
10.105.1.0101011011
29. [Ans. C]
For finding network address we take AND 1st 2 MSS
of IP address with the netmask N. So we } Slow Start
2nd 4 MSS
check one by one. 3rd 8 MSS
(A) (i) 255.255.255.0 = N 4th 9 MSS } additive increase
10.105.1.01110001 Taking AND 5 10
10.105.1.00000000 IP address of A Time out threshold 8 4
(ii) By taking and with B 6th 5MSS} multiplicative decrease
255.255.255.00000000 7th 4 MSS
10.105.1.01011011 8th 5 MSS
10.105.1.00000000 9th 6 MSS
So both belong to same network 10th 7MSS

(B) (i) 255.255.255.128 30. [Ans. C]


255.255.255.10000000 Real time multimedia – UDP
10.105.1.01110001 IP of A File transfer - TCP
10.105.1.00000000 DNS – UDP
(ii) 255.255.255.10000000 Email – TCP
10.105.1.01011011 IP of B
10.105.1.0000000 31. [Ans. C]
So both belong to same network M = 0: Means to more fragmentation so it
represent the last fragment.
(D) (i) 255.255.255.11100000 HLEN = 10:
10.105.1.01110001 IP of A Header length 10 4 40 bytes
10.105.1.01100000 Payload: 400 40 360 bytes [0 to 359]
(ii) 255.255.255.11100000 Fragment offset : 300 means
10.105.1.010111011 IP of B 300 8 2400 bytes
10.105.1.01100000 Sequence number of first fragment = 2400
Both are not same so it not belong to Sequence number of last fragment
same network = 2400 + 359
= 2759
Option (C) is correct

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.comPage 388
GATE QUESTION BANK Computer Networks

32. [Ans. *] Range 1100 to 1300 incoming connection requested to this


Size of Congestion Window = cw = 32KB socket.
Round Trip Time = 100 msec
Maximum Segment Size = 2KB 34. [Ans. 26]
Initial Congestion Window Size= initial Initial TTL Value = 32
cw = 1MSS = 2KB [Default Value] TTL value will be decremented by 1 at
Time Out occurs at cw = 32KB , then each Router on the way to the
Phase = Slow-Start Phase with the Destination.
following changes:- TTL value will be 26 when packet reaches
Threshold = cw/2 =16KB “R”
Current cw = 2KB [initial cw] ISP1 ISP2
27 26
Phase = Slow Start Phase 32 29 28
31
Round Current Threshold Phase Round 30
LAN L2
Congestion Trip Time R
Window S LAN L1
1 2KB 16KB Slow-Start 100msec
Phase
2 4KB 16KB Slow-Start 100msec 35. [Ans. D]
Phase
Host A sends a datagram D to Host B and
3 8KB 16KB Slow-Start 100msec
Phase it has been delivered successfully.
4 16KB 16KB Slow-Start 100msec All the 3 given options can change while
Phase datagram “D” reaches ost “ ”.
5 18KB 16KB Congestion 100msec 1) TTL It decrements at every router.
Avoidance
Phase
[Initial Value will be different from the
6 20KB 16KB Congestion 100msec
final value]
Avoidance 2) Checksum As IPV4 header will be
Phase reconstructed at every router;
7 22KB 16KB Congestion 100msec obviously checksum also will be
Avoidance
Phase calculated at every router. So the
initial value of checksum will be
S 24KB 16KB Congestion 100msec
Avoidance different from the final value.
Phase 3) Fragment Offset Any intermediate
9 26KB 16KB Congestion 100msec router can fragment the packet if
Avoidance
Phase packet size is greater than maximum
10 28KB 16KB Congestion 100msec transmission unit [MTU] of the next
Avoidance network. So obviously the initial value
Phase
of fragment offset will be different
11 30KB 16KB Congestion 100msec
Avoidance from the final value.
Phase
12 32KB 16KB Congestion 100msec 36. [Ans. 256]
Avoidance
Given that each host has a globally unique
Phase
1200 msec IPV4 address and we have to design
50 – bit unique Id. So, 50 – bit in the sense
33. [Ans. C] (32 + 18). So, it is showing that IP
The listen function converts an Address (32 bit) followed by 18 bits.
unconnected socket into a passive socket, 1000 unique Ids 1 sec
indicating that the kernel should accept 2 unique ids 2 1000 2 256

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.comPage 389
GATE QUESTION BANK Computer Networks

37. [Ans. A]
Size of received IP Datagram
= 4404 bytes = 20 byte IP Header + 4384
payload
Maximum Transmission unit [MTU]
= 1500 bytes
Obviously, Router will fragment the 4384
Payload as follows:
S.No 1 2 3
Size of 1500 1500 1444
Datagram
IP Header 200 20 20
Payload 1480 1480 1424
MF bit 1 1 0
Value
Starting 0 1480 2960
Payload
Byte No
Ending 1479 2959 4383
Payload
Byte No
Fragment 0/8 = 1480/8 2960/8
Offset 0 = 185 = 370
Thus for 3 IP fragment values are as
follows:
Size of Datagram = 1444 bytes
MF bit Value = 0 [Since this is the last
fragment]
Fragment Offset = 370

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.comPage 390
GATE QUESTION BANK Computer Networks

Application Layer

CS –2005 CS –2011
1. A HTML form is to be designed to enable 5. Consider different activities related to
purchase of office stationery. Required email
items are to be selected (checked). Credit m1: Send an email from a mail client to a
card details are to be entered and then mail server
the submit button is to be pressed. Which m2: Download an email form mailbox
one of the following options would be server to mail client
appropriate for sending the data to the m3: Checking email in a web browser
server? Assume that security is handled Which is the application level protocol
in a way that is transparent to the form used in each activity?
design. (A) m1: HTTP m2: SMTP m3: POP
(A) only GET (B) m1: SMTP m2: FTP m3: HTTP
(B) only POST (C) m1: SMTP m2: POP m3: HTTP
(C) either of GET or POST (D) m1: POP m2: SMTP m3: IMAP
(D) neither GET nor POST
CS –2012
CS – 2006 6. The protocol data unit (PDU) for the
2. HELO and PORT, respectively are application layer in the Internet stack is
commands from the protocols (A) Segment (C) Message
(A) FTP and HTTP (B) Datagram (D) Frame
(B) TELNET and POP3
(C) HTTP and TELNET CS –2014
(D) SMTP and FTP 7. Identify the correct order in which the
following actions take place in an
CS –2008 interaction between a web browser and a
3. Provide the best matching between the web server.
entries in the two columns given in the 1. The web browser requests a webpage
table below: using HTTP.
I Proxy Server a. Firewall 2. The web browser establishes a TCP
II aZaA, D b. Caching connection with the web server.
III SLIP c. P2P 3. The web server sends the requested
IV DNS d. PPP webpage using HTTP.
(A) I a, II d, III c, IV b 4. The web browser resolves the
(B) I b, II d, III c, IV a domain name using DNS.
(C) I a, II c, III d, IV b (A) 4,2,1,3 (C) 4,1,2,3
(D) I b, II c, III d, IV a (B) 1,2,3,4 (D) 2,4,1,3

CS –2010 8. A graphical HTML browser resident at a


4. Which one of the following is not a client- network client machine Q accesses a
server application? static HTML webpage from a HTTP server
(A) Internet chat (C) E-mail S. The static HTML page has exactly one
(B) Web browsing (D) Ping static embedded image which is also at S.
Assuming no caching, which one of the
following is correct about the HTML

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 391
GATE QUESTION BANK Computer Networks

webpage loading (including the 9. An IP machine Q has a path to another IP


embedded image)? machine H via three IP routers R1, R2,
(A) Q needs to send at least 2 HTTP and R3.
requests to S, each necessarily in a Q—R1—R2—R3—H
separate TCP connection to server S H acts as an HTTP server, and Q connects
(B) Q needs to send at least 2 HTTP to H via HTTP and downloads a file.
requests to S, but a single TCP Session layer encryption is used, with DES
connection to server S is sufficient as the shared key encryption protocol.
(C) A single HTTP request from Q to S is Consider the following four pieces of
sufficient, and a single TCP information:
connection between Q and S is [I1] The URL of the file downloaded by Q
necessary for this [I2] The TCP port numbers at Q and H
(D) A single HTTP request from Q to S is [I3] The IP addresses of Q and H
sufficient, and this is possible [I4] The link layer addresses of Q and H
without any TCP connection between Which of I1, I2, I3, and I4 can an intruder
Q and S learn through sniffing at R2 alone?
(A) Only I1 and I2 (C) Only I2 and I3
(B) Only I1 (D) Only I3 and I4

Answers Keys & Explanations

1. [Ans. C] m3 Checking email in a web browser


GET or POST can be used sending the HTTP
data to the server.
6. [Ans. C]
2. [Ans. D] PDU is called a message in application
HELO and PORT commands are from layer, segment in transport layer,
the protocol SMTP and FTP. datagram in network layer and frame in
data link layer
3. [Ans. D]
Proxy server aching 7. [Ans. A]
KaZaA, DC++ P2P Firstly DNS will translate the URL into IP
SLIP PPP address, then TCP connection will be
established. After that browser will
DNS irewall request for webpage and at the end
server will respond for request
4. [Ans. D]
Ping is utility to check connectivity either 8. [Ans. B]
between client-client or client-server Q: Client Accessing a Static HTML web
page from HTTP Server
S: Server Static HTML page has exactly
5. [Ans. C] one Static mbedded Image located in “S”
m1 Send an email from a mail client to only
a mail server SMTP No Caching
m2 Download an email from a mail How HTML Web Page Loads?
client to a mail server POP HTTP Uses TCP Protocol 1-TCP
Connection must be established first

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.comPage 392
GATE QUESTION BANK Computer Networks

[HTTP 1.1 uses Persistent Connection,


One TCP connection can serve multiple
requests]
Q must send 2 HTTP requests One for
Web Page and the other for the Image.

9. [Ans. C]
1) Station “Q” will be downloading a file
from TTP server “ ” and 3 routers
R1, R2, and R3 between Q and H.
2) Sniffing at R2 alone what
information will be disclosed?
Only IP addresses & Port Numbers
3) As IP addresses & Port Numbers
remains same for the entire journey
to the destination, so sniffing will get
both IP addresses and Port Numbers
of “Q and ”.
4) URL Station “Q” alone knows the
URL and requests the DNS server for
destination IP. As URL won’t be
included in the packet, so the routers
in the middle are totally unaware of
URL’s.
5) Link Layer Addresses of Q and H
Ethernet Address (or) MAC address
(or) Physical Address. As the
physical addresses changes from
Hop to Hop, Sniffing at R2 will know
only the physical addresses of R1 and
R2 but not Q and H.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 393
GATE QUESTION BANK Computer Networks

Network Security

CS -2005 CS -2008
1. Suppose that two parties A and B wish to 4. The total number of keys required for a
setup a common secret key (D-H key) set of n individuals to be able to
between themselves using the Diffie- communicate with each other using
Hellman key exchange technique. They secret key and public key cryptosystems,
agree on 7 as the modulus and 3 as the respectively are :
primitive root. Party A chooses 2 and (A) n (n 1) and 2n
party B chooses 5 as their respective (B) 2n and
secrets. Their D-H key is:
(A) 3 (C) 5 (C) and 2n
(B) 4 (D) 6 (D) and n

CS -2007 CS -2009
2. Exponentiation is a heavily used 5. In the RSA public key cryptosystem, the
operation in public key cryptography. private & public keys are (e, n) & (d, n)
Which of the following options is the respectively, where n=p * q and p and q
tightest upper bound on the no. of are large primes. Besides, n is public & p
multiplications required to compute & q are private . Let M be an integer such
b modulo m, 0≤b, n≤m? that 0<M<n & ϕ(n) = (p – 1) (q – 1).
(A) O (log n) (C) O (n/log n) Now consider the following equations.
(B) O (√n ) (D) O (n) (A) M = Me mod n
M = (M )d mod n
3. A firewall is to be configured to allow host (B) ed = 1 mod n
in a private network to freely open TCP (C) ed = 1 mod ϕ(n)
connections & send packets on open (D) M = Me mod ϕ(n)
connections. However, it will only allow M = (M )d mod ϕ(n)
external hosts to send packets on existing Which of the above equations correctly
open TCP connections or connections represent RSA cryptosystem?
that are being opened (by internal host ) (A) I and II (C) II and IV
but not allow them to open TCP (B) I and III (D) III and IV
connections to hosts in the private
CS -2011
network. To achieve this he minimum
6. A layer-4 firewall (a device that can look
capability of the firewall should be that of
at all protocol headers up to the transport
(A) A combinational circuit
layer ) CANNOT
(B) A finite automation
(A) Block entire HTTP traffic during
(C) A pushdown automation with one
9:00 PM and 5:00 AM
stack
(B) Block all ICMP traffic
(D) A pushdown automation with two
(C) Stop incoming traffic from a specific
stacks
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

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 394
GATE QUESTION BANK Computer Networks

CS -2013
7. 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?
(A) ncryption :X’s private key followed
by Y’s private key;
Decryption: X’s public key followed
by Y’s public key
(B) ncryption: X’s private key followed
by Y’s public key;
Decryption: X’s public key followed
by Y’s private key
(C) ncryption: X’s public key followed
by Y’s private key;
Decryption : Y’s public key followed
by X’s private key
(D) ncryption : X’s private key followed
by Y’s public key;
Decryption : Y’s private key followed
by X’s public key

CS- 2014
8. Which of the following are used to
generate a message digest by the network
security protocols?
(P) RSA (Q) SHA 1
(R) DES (S) MD5
(A) P and R only (C) Q and S only
(B) Q and R only (D) R and S only

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 395
GATE QUESTION BANK Computer Networks

Answers Keys & Explanations


1. [Ans. B] 8. [Ans. C]
p=7 RSA (Rivert, Shamir, Adleman) is a public
g = primitive root = 3 – key crypto system.
Party A chooses = a = 2 SHA – 1 (Secure Hash Algorithm) is a
Party B choose = b = 5
hash function to generate a message
D-H Key = k =?
digest
k= g (mod p) = 3 (mod 7) = 4
DES (Data Encryption standard) is a
2. [Ans. C] symmetric key algorithm for encryption
O(n/ log n) is the tightest upper bound. MD5 is a message – digest algorithm

3. [Ans. D]
A pushdown automata with two stacks

4. [Ans. C]
Secret key --------
Public key ------- 2n

5. [Ans. B]
I and III equation correctly represent RSA
cryptosystem

6. [Ans. D]
To block TCP traffic from specific user,
requires information of specific user
which is done by application layer. To
block HTTP data, layer-4, i.e., transport
layer can be used because it can block
port used by HTTP

7. [Ans. D]
Decrypting first with Y’s private key
ensures confidentiality and rest of the
things follows that way

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 396
GATE QUESTION BANK Compiler Design

Introduction to Compilers

CS-2005 CS-2011
1. Consider line number 3 of the following 3. In a complier, keywords of a language are
C –program. recognized during
int min( ){ /* Line 1 */; (A) Parsing of the program
int I, n; /* Line 2 */; (B) The code generation
fro(I=0, I<n,I++) /* Line 3 */; (C) The lexical analysis of the program
} (D) Dataflow analysis
Identify the compiler’s response about
this line while creating the object-module CS-2014
(A) No compilation error 4. Which one of the following is NOT
(B) Only a lexical error performed during compilation?
(C) Only syntactic errors (A) Dynamic memory allocation
(D) Both lexical and syntactic errors (B) Type checking
(C) Symbol table management
CS-2010 (D) Inline expansion
2. Which data structure in a compiler is used
for managing information about variables
and their attributes?
(A) Abstract syntax tree
(B) Symbol table
(C) Semantic stack
(D) Parse table

Answers Keys & Explanations

1. [Ans. C] symbol table are nothing but identifier


In 2nd line no mis-spelling is there. It is int and operators. It contains information
only. about variables and their attributes.
Error is underlined function fro ( )
which is a syntactical error rather than 3. [Ans. C]
lexical so correct option is C. Keywords are recognized during lexical
analysis
2. [Ans. B]
As we know symbol table is a Data 4. [Ans. A]
structure containing record for each Dynamic memory allocation is performed
identifier, with fields for the attribute of at run time not on compile time.
the identifier. The symbols entered into

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 397
GATE QUESTION BANK Compiler Design

Syntax Analysis
CS-2005 5. Consider the following grammar
1. The grammar A  AA |(A)|ε is not S → FR
suitable for predictive-parsing because R → *S | ε
the grammar is F → id
(A) ambiguous In the predictive parser table, M, of the
(B) left-recursive grammar the entries M[S, id] and M[R, $]
(C) right-recursive respectively
(D) an operator-grammar (A) {S → FR} and {R →ε}
(B) {S → FR} and { }
2. Consider the grammar E E + n|E n|n (C) {S → FR} and {R → *S}
For a sentence n + n n, the handles in (D) {F → id} and {R →ε}
the right-sentential form of the reduction
are Linked Answer Questions 6 and 7
(A) n, E + n and E + n n 6. Which one of the following grammars
(B) n, E + n and E + E n generates the language L = {aibj | i j }?
(C) n, n + n and n + n n (A) S→ A |
(D) n, E + n and E n → a b|a|b
A → aA|
3. Consider the grammar → b|
S  (S) | a (B) S → aS|Sb|a|b
Let the number of states in SLR(1), LR(1) (C) S → A |
and LALR(1) parsers for the grammar be → a b|
n1, n2 and n3 respectively. The following A → aA|
relationship holds good → b|
(A) n1< n2< n3 (C) n1 = n2 = n3 (D) S → A |
(B) n1 = n3< n2 (D) n1 n3 n2 → a b|
A → aA|a
CS-2006 → b|b
4. Consider the following grammar.
S  S*E 7. In the correct grammar above, what is the
SE length of the derivation (number of steps
E F + E starting from S) to generate the string
E F a bm with l m?
F id (A) max (l,m) + 2 (C) l + m + 3
Consider the following LR(0) items (B) l + m + 2 (D) max (l, m) + 3
corresponding to the grammar above.
(i) S  S*.E CS-2007
(ii) E  F.+E 8. Which one of the following is a top-down
(iii) E  F+.E parser?
Given the items above, which two of them (A) Recursive descent parser
will appear in the same set in the (B) Operator precedence parser
canonical sets-of-items for the grammar? (C) An LR(k) parser
(A) (i) and(ii) (C) (i) and (iii) (D) An LALR(k) parser
(B) (ii) and (iii) (D) None of these

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 398
GATE QUESTION BANK Compiler Design

9. Consider the grammar with CS-2008


non-terminals N = {S,C,S }, terminals 13. Which of the following describes a handle
T = {a,b,i,t,e}, with S as the start symbol, (as applicable to LR- parsing)
and the following set of rules appropriately?
S  iCtSS1| a (A) It is the position in a sentential form
S1eS| ε where the next shift or reduce
Cb operation will occur
The grammar is NOT LL(1) because: (B) It is a non-terminal whose
(A) It is left recursive production will be used for reduction
(B) It is right recursive in the next step
(C) It is ambiguous (C) It is a production that may be used
(D) It is not context-free for reduction in a future step along
with a position in the sentential form
10. Consider the following two statements: where the next shift or reduce
P : Every regular grammar is LL(1) operation will occur.
Q : Every regular set has LR(1) grammar (D) It is the production p that will be
Which of the following is TRUE? used for reduction in the next step
(A) Both P and Q are true along with a position in the
(B) P is true and Q is false sentential form where the right hand
(C) P is false and Q is true side of the production may be found.
(D) Both P and Q are false
14. An LALR(1) parser for a grammar G can
Linked Answer Questions Q.11 & Q.12 have shift reduce (S-R) conflicts if & only
Consider the CFG with {S,A,B} as the non- if
terminal alphabet, {a,b} as the terminal (A) The SLR(1) parser G has S-R conflicts
alphabet, S as the start symbol and the (B) The LR(1) parser for G has S-R
following set of production rules : conflicts
S aB S bA (C) The LR(0) parser for G has S-R
B b A a conflicts
B bS A aS (D) The LALR(1) parser for G has
B aBB A bAA reduce-reduce conflicts

11. Which of the following strings is CS-2010


generated by the grammar? 15. The grammar S → aSa | bS | c is
(A) aaaabb (C) aabbab (A) LL(1) but not LR(1)
(B) aabbbb (D) abbbba (B) LR (1) but not LL(1)
(C) Both LL(1) and LR(1)
12. For the correct answer string to above (D) Neither LL(1) nor LR(1)
Q. 11 how many derivation trees are
there? CS-2012
(A) 1 (C) 3 Statement for Linked Answer Question 16
(B) 2 (D) 4 and 17:
For the grammar below, a partial LL(1)
parsing table is also presented along with
the grammar. Entries that need to be
filled are indicated as E1, E2, and E3. ε is
the empty string, $ indicates end of input,

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 399
GATE QUESTION BANK Compiler Design

and, |separates alternate right hand side CS-2013


of productions. 18. What is the maximum number of reduce
S→ a A b B | b A a B | ε moves that can be taken by a bottom – up
A→S parser for a grammar with no epsilon and
B→S unit production
a B $ (i.e., of type A→ε and A → a )to parse a
s E1 E2 S→ε string with n tokens?
(A) n/2 (C) 2n – 1
A A→S A→S Error
(B) n – 1 (D)
B →S →S E3
19. Consider the following two sets of LR(1)
16. The FIRST and FOLLOW sets for the non- items of an LR(1) grammar.
terminals A and B are X→ c. X, c|d X →c.X,$
(A) FIRST(A) = {a,b,ε} = FIRST(B) X→ .c X, c|d X →.cX,$
FOLLOW (A) = {a,b} X→ .d, c|d X →.d,$
FOLLOW (B) = {a,b,$} Which of the following statement related
(B) FIRST(A) = {a,b,$} to merging of the two sets in the
FIRST (B) = {a,b,ε} corresponding LALR parser is / are
FOLLOW (A) = {a, b} FALSE?
FOLLOW (B) = {$} 1. Cannot be merged since look aheads
(C) FIRST(A) = {a,b,ε} = FIRST(B) are different
FOLLOW(A) = {a,b} 2. Can be merged but will result in S –R
FOLLOW(B) = conflict
(D) FIRST(A) = {a,b,ε} = FIRST(B) 3. Can be merged but will result in R –R
FOLLOW(A) = {a,b} conflict
FOLLOW(B) = {a,b} 4. Cannot be merged since goto on c
will lead to two different sets.
17. The appropriate entries for E1, E2, E3 are (A) 1 only (C) 1 and 4 only
(A) E1: S→aAbB, A→S (B) 2 only (D) 1, 2,3 and 4
E2: S→bAaB, B→S
E3: B→S CS-2014
(B) E1: S→aAbB, S→ε 20. A canonical set of items is given below
E2: S→bAaB, S→ε S→ . R
E3: S→ε → R.
(C) E1: S→aAbB, S→ε On input symbol < the set has
E2: S→bAaB, S→ε (A) a shift-reduce conflict and a
E3: B→S reduce-reduce conflict.
(D) E1: A→S, S→ε (B) a shift-reduce conflict but not a
E2: B→S, S→ε reduce-reduce conflict.
E3: B→S (C) a reduce-reduce conflict but not a
shift-reduce conflict.
(D) neither a shift-reduce nor a reduce-
reduce conflict.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 400
GATE QUESTION BANK Compiler Design

21. Consider the grammar defined by the


following production rules, with two
operators ∗ and
S T∗
T U|T ∗ U
|
id
U id
Which one of the following is TRUE?
(A) is left associative, while ∗ is right
associative
(B) is right associative, while ∗ is left
associative
(C) oth and ∗ are right associative
(D) oth and ∗ are left associative

Answers Keys & Explanations


1. [Ans. A] 4. [Ans. D]
Given grammar is Ambiguous,that is the Construct the canonical set-of-items and
reason that it is not suitable for Predictive observe the same.
paring.
5. [Ans. A]
2. [Ans. D] Construct Predictive parser table as
E E+n|E×n|n follows
Input String n + n × n Nonterminal Id * $
E + n × n reduction E n S S FR
E×n reduction E E+n R R *S R ε
E reduction E E×n F F id
So the reduction are n, E + n, E × n So M[S, id] = {S FR}
and M[R, $] = {R ε}
3. [Ans. B]
S (S) | a 6. [Ans. D]
Parsers No. of States S→A |
SLR (1) n → a b|
LR(1) n A → aA|a
LALR(1) n → b|b
The number of states of deterministic From the above grammar,
finite automata in SLR (1) and LALR (1) → a b| ( ) *a b +
parsers are equal, so n n . The number A → aA|a (A) a
of states of deterministic finite automata → b|b ( ) b
in LR (1) or canonical LR is greater than By substituting C, A and B in S.
the number of states of deterministic S → AC L(S) = {ambn| m > n}
finite automata of SLR(1) and LALR(1) S→ (S) *a b |m n+
So n n n . (S) *a b |m n or m n+ *a b |i j+

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 401
GATE QUESTION BANK Compiler Design

7. [Ans. A] lm
In the q no. 6 if grammar generates a b aabbab.
or a b then the length is max (l, m) if it lm
generates a b initially we include two So aabbab is generated by the grammar.
extra derivation so the total length is
max (l, m) + 2. 12. [Ans. B]
There are two parse trees for the string
8. [Ans. A] aabbab from left most derivation and one
Predictive parser and recursive descent from right most derivation.
parser are example of top-down parser. S
Where as LR(k) and LALR(k) parser are
bottom up parser a B

9. [Ans. A] a B
B
S i C t SS | a
S eS | ∈
b S b
C b
S i C t SS
b A
S i b t SS [apply C b] a
After second step of derivation i, b, t are S
terminals but the left nonterminal symbol
is S so grammar it left recursive after step B
a
2. It is noted that in some cases we can’t
observe the left recursion in initial step of
a B
derivation but after some step of B
derivation we can seen the left recursion.
b S
b
10. [Ans. A]
a B
Regular grammar is well recognized by
LL(1) parsers and LR (1) parser is stronger b
and more than powerful than LL (1) so
regular grammar is also accepted by LR (1)
13. [Ans. D]
parser. Every regular set has LR (1)
Definition of handle is given in (D) option.
grammar. So both statements are correct.
14. [Ans. B]
11. [Ans. C]
LALR (1) parser uses the LR (1) items. So
S aB
LALR (1) parser or for a grammar G can
lm
have S-R conflict if add only if the LR (1)
aaBB
parser for G has S-R conflicts.
lm
aabB
15. [Ans. C]
lm
S → aSa|bS|c
aabbS
The above grammar is LL (1) because,
lm
First ,aSa- ∩ first ,bS- (a) ∩ (b)
aabbaB
&&

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 402
GATE QUESTION BANK Compiler Design

First ,bS- ∩ first ,c- (b) ∩ (c) 19. [Ans. D]


&& X →c.X, c|d X →c.X, $
First ,c- first ,aSa- (c) ∩ (a) = X → .cX, c|d X → .c.X, $
X → .d, c|d X → .d, $
As the above grammar is LL(1), also
LR (1) because LL(1) grammar is always
LR (1) grammar.

16. [Ans. A]
S → aAbB | bAaB |ε
A→S
X →.cX, c|d
B→S X → .cX, c|d |$
First of S = {a, b, ε} X → .d, c|d | $
First of A = {a, b, ε}
First of B = {a, b, ε}
1. Merging of two state depends on
Follow of S = {$, a, b}
core part (production rule with
Follow of A = {b, a}
dotoperator), not on look ahead.
Follow of B = {$, a, b}
2. The two states are not containing
reduce item, so after merging the
17. [Ans. C]
merged state cannotcontain any S – R
S → aAb | bAa | ε
conflict
A→S
3. As there is no Reduce item in any of
B→S
the state, so can’t have R – R conflict
LL(1) Parsing table:
4. Merging of state does not depend on
a b $
S S → aAb S → bAa S→ further goto on any terminal. So all
S→ S→ statements are false
A A→S A→S error
B →S →S →S
20. [Ans. D]
No any conflict, because both items will
18. [Ans. B]
be in different states of canonical sets.
If n tokens are there in string, then one
reduction is required for each token. But
21. [Ans. B]
at the end two tokens will be reduced to
Consider the following derivation tree
two terminals because grammar does not S
have any unit production. So for last two
token =1 T * P

For remaining (n ) tokens = (n ) T U Q


P
* +
Total = 1 + n – 2 U id id Q P
=n 1 +
id id Q

id

String = (id ∗ id) ∗ (id (id id))


‘*’ is left associative ‘ ’ is right associative

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 403
GATE QUESTION BANK Compiler Design

Syntax Directed Translation

CS-2005 (D) Precedence of is higher than


Linked Answer Questions 1 & 2 that of , and both operators are
Consider the following expression left associative; expression is
grammar. The semantic rules for evaluated to 9
expression calculation are stated next to
each grammar production. CS-2006
E  number E.val=number.val 3. Consider the following translation
| E(1).val = E(2).val + E(3).val scheme.
| E(1).val = E(2).val E(3).val S→ R
R → * *print *‘*’); R | ε
1. The above grammar and the semantic E→ F *print (‘ ’); }| F
rules are fed to a yacc tool (Which is an F→ (S) | id {print (id.value);}
LALR(1) parser generator) for parsing Here id is a token that represents an
and evaluating arithmetic expressions. integer and id.value represents the
Which one of the following is true about corresponding integer value. For an input
the action of yacc for the given grammar? ‘ * 3 4’, this translation scheme prints
(A) It detects recursion and eliminates (A) 2 * 3 + 4 (C) 2 3 * 4 +
recursion (B) 2 * + 3 4 (D) 2 3 4 + *
(B) It detects reduce-reduce conflict,
and resolves CS-2008
(C) It detects shift-reduce conflict, and 4. Which of following are true?
resolves the conflict in favor of a shift I. A programming language which does
over a reduce action not permit global variables of any
(D) It detects shift-reduce conflict, and kind & has no nesting of
resolves the conflict in favor of a procedures/functions, but permits
reduce over a shift action recursion can be implemented with
static storage allocation
2. Assume the conflicts in Q.1 are resolved II. Multi-level access link(or display)
and an LALR (1) parser is generated for arrangement is needed to arrange
parsing arithmetic expressions as per the activation records only if the
given grammar. Consider an expression 3 programming language being
2 + 1. What precedence and implemented has nesting of
associativity properties does the producers/ functions
generated parser realize? III. Recursion in programming languages
(A) Equal precedence and left cannot be implemented with
associativity; expression is evaluated dynamic storage allocation.
to 7 IV. Nesting of producers/ functions &
(B) Equal precedence and right recursion require a dynamic heap
associativity; expression is evaluated allocation scheme and cannot be
to 9 implemented with a stack based
(C) Precedence of is higher than that allocation scheme for activation
of , and both operators are left records
associative; expression is evaluated V. Programming languages which
to 7 permits a function to return a

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 404
GATE QUESTION BANK Compiler Design

function as its result cannot be


implemented with a stack based
storage allocation scheme for
activation records
(A) (II) & (V) only
(B) (I),(III) & (IV) only
(C) (I),(II) & (V) only
(D) (II),(III) & (V) only

Answer Keys & Explanations

1. [Ans. C] So an input 2 * 3 + 4, it prints from the


E number | ‘ ’ | ‘ ’ Then A above parse tree as 234 +*.
compiler detects shift-reduce conflict, and
resolves the conflict in favor of a shift 4. [Ans. A]
over a reduce action. Consider the Consider each statement separately
following configuration where shift- I. If a programming language doesn’t
reduce conflict occurs permit global variables and no
Stack Input nesting procedures then we can’t
… × …$ use the recursion with static
storage because there is no stack
2. [Ans. C] support. For example Fortran
With look ahead we would prefer to shift doesn’t support the recursion. So
because the look ahead has higher statement is false
precedence than × over + and both II. Statement is true.
operation are left associative. So III. Recursion in programming
expression 3 6 7 will be languages will be implemented
evaluated. with dynamic storage. For example
C language implement recursion
3. [Ans. D] with the help of heap if size is also
S increases because heap stores the
R all activation records of a recursion.
E So statement is false.
* {print} R IV. Statement is false because we can
E
F implement recursion either with
ε
{print} the help of heap or a stack.
id F + E {print}
V. Statement is true.
2 id {print}
F

3
id {print}

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 405
GATE QUESTION BANK Compiler Design

Intermediate Code Generation

CS-2006 the performance (i.e. reduce CPU time) of


1. Consider the following C code segment. work2 compared to work1
for(i=0; i<n; i++){ (A) S1 is false and S2 is false
for(j=0; j<n; j++){ (B) S1 is false and S2 is true
if(i%2) (C) S1 is true and S2 is false
{x + = (4 * j + 5 * i); (D) S1 is true and S2 is true
y + = (7 + 4 *j);
} CS-2008
} 3. Some code optimizations are carried out
} on the intermediate code because
Which one of the following is false? (A) They enhance the portability of the
(A) The code contains loop-invariant compiler to other target processors
computation (B) Program analysis is more accurate
(B) There is scope of common sub- on intermediate code than on
expression elimination in this code machine code
(C) There is scope of strength reduction (C) The information from data flow
in this code analysis cannot otherwise be used
(D) There is scope of dead code for optimization
elimination in this code (D) The information from the front end
cannot otherwise be used for
2. Consider these two functions and two optimization
statements S1 and S2 about them.
int work1(int *a, int i, int j) CS-2009
{ 4. Which of the following statements are
int x = a [i + 2]; TRUE?
a[ j ] = x + 1 ; I. There exists parsing algorithm for some
return a [i+2] 3; programming languages whose
} complexities are less than θ(n3)
II. A programming language which allows
int work2 (int *a, int i, int j) recursion to be implemented with static
{ storage allocation
int t1 = i + 2; III. No L-attributed definition can be
int t2= a [t1]; evaluated in the framework of bottom-up
a [ j] = t2 1; parsing
return t2 3; IV. Code improving transformations can
} be performed at both source language &
S1: The transformation from work 1 to intermediate code level
work2 is valid, i.e., for any program state (A) I & II (C) III & IV
and input arguments, work2 will compute (B) I & IV (D) I, III & IV
the same output and have the same effect
on program state as work1
S2: All the transformations applied to
work1 to get work2 will always improve

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 406
GATE QUESTION BANK Compiler Design

CS-2010 c a b;
5. Which languages necessarily need heap d c ∗ a;
allocation in the runtime environment? e c a;
(A) Those that support recursion. x c ∗ c;
(B) Those that use dynamic scoping. if (x a) *
(C) Those that allow dynamic data y a ∗ a;
structures. +
(D) Those that use global variables. else {
d d ∗ d;
CS-2011 e e ∗ e;
6. Consider two binary operators ‘ ’ and ' ' }
with the precedence of operator being
lower than that of the operator . 7. Suppose the instruction set architecture
Operator is right associative while of the processor has only two registers.
operator is left associative. Which one of The only allowed compiler optimization is
the following represents the parse tree code motion, which moves statements
for expression (7 3 4 3 ) from one place to another while
preserving correctness. What is the
(A) (B)
minimum number of spills to memory in
7 the compiled code?
2 (A) 0 (C) 2
3 7 (B) 1 (D) 3

4 3 8. What is the minimum number of register


needed in the instruction set architecture
3 2 4 3 of the processor to compile this code
(C) (D) segment without any spill to memory? Do
not apply any optimization other than
7 2 optimizing register allocation
2
(A) 3 (C) 5
3 (B) 4 (D) 6
3
CS-2014
4
9. One of the purposes of using intermediate
3 4
3
code in compilers is to
7 (A) make parsing and semantic analysis
simpler.
CS-2013 (B) Improve error recovery and error
Common Data for Questions 7 & 8 reporting.
The following code segment is executed (C) Increase the chances of reusing the
on a processor which allows only register machine-independent code
operands in its instructions. Each optimizer in other compilers.
instruction can have almost two source (D) Improve the register allocation.
operands and one destination operand.
Assume that all variables are dead after
this code segment.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 407
GATE QUESTION BANK Compiler Design

10. Consider the basic block given below. 11. Which one of the following is FALSE?
a b c (A) A basic block is a sequence of
c a d instructions where control enters the
d b c sequence at the beginning and exits
e d b at the end.
a e b (B) Available expression analysis can be
The minimum number of nodes and edges used for common sub expression
present in the DAG representation of the elimination.
above basic block respectively are (C) Live variable analysis can be used for
(A) 6 and 6 (C) 9 and 12 dead code elimination.
(B) 8 and 10 (D) 4and4 (D) x 4 ∗ 5 x 0 is an example of
common sub expression elimination.

Answer Keys & Explanations

1. [Ans. D] 3. [Ans. B]
(A) i%2 is inner loop invariant, it can be Some code optimizations are carried out
moved before inner loop on the intermediate code because
(B) 4*j is common sub – expression program analysis is more accurate on
appeared in two statements intermediate code than on machine code.
(C) 4*j can be reduced to j<<2 by
strength reduction. 4. [Ans. B]
(D) There is no dead code in given code Recursion cannot be implemented with
segment. So there is not scope of static storage allocation.
dead code elimination in this code. L – attributed definition can be evaluated
Hence only option (D) is FALSE. if all rules are at the end and all attributes
are synthesized.
2. [Ans. D] So I and IV are correct.
Both work1 and work2 performs the
same task so S1 is true. But code in work2 5. [Ans. C]
will improve performance. Runtime environment mean we deal with
In work1: dynamic memory allocation and heap is a
int x = a[i+2]; dynamic data structure. So it is clear that
Here a[i+2] is computed twice. those languages that allow dynamic data
return a[i + 2] – 1 structure necessarily need heap
In work2; allocation in the runtime environment.
t i
t a,t -; 6. [Ans. B]
return t 3
Therefore option S2 is also correct.
2
7

4 3

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 408
GATE QUESTION BANK Compiler Design

7. [Ans. B] 10. [Ans. A]


c a b; e, d
x c ∗ c;
if (x a) *… … (i) c
y a ∗ a;
+ a, d d
else {
d c ∗ a;
b c
e c a; … … . (ii)
d d ∗ d;
e e ∗ e; 11. [Ans. D]
+ x=4*5
(i) Is to store c*c, it needs one memory x= 20 is the example of constant
spill. folding not of common sub expression
(ii) Is uses previous same(i) memory elimination
spill to store c*a.
Number of memory spills are used in
above program is one. With the use of
one memory cell and two registers the
above optimized code can be executed.

8. [Ans. B]
R R R c a b
R R ∗R d c∗a
R R R e c a
R R ∗R x c∗c
if(R R ) if(x 0)
{
R R ∗R y a∗b
}
else
{
R R ∗R d d∗d
R R ∗R e e∗a
}
4 registers are required
Option (B) is correct

9. [Ans. C]
Intermediate code is machine
independent code which makes it easy to
retarget the compiler to generate code for
newer and different processors.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 409
GATE QUESTION BANK SE & WT

Introduction to Software and Software Engineering


CS-2009 3. Which one of the following is TRUE?
1. The coupling between different modules (A) The requirements document also
as a software is categorized as follows describes how the requirements that
I. Content coupling are listed in the document are
II. Common coupling implemented efficiently.
III. Control coupling (B) Consistency and completeness of
IV. Stamp coupling functional requirements are always
V. Data coupling achieved in practice.
Coupling between modules can be ranked (C) Prototyping is a method of
in the order as strong (least desirable) to requirements validation.
weakest (most desirable) as follows (D) Requirements review is carried out
(A) I – II – III – IV - V to find the errors in system design.
(B) V – IV – III – II – I
(C) I – III – V – II – IV 4. In the context of modular software
(D) IV – II – V – III – I design, which one of the following
combinations is desirable?
CS-2014 (A) High cohesion and high coupling
2. Match the following: (B) High cohesion and low coupling
1) Waterfall a) Specifications (C) Low cohesion and high coupling
model can be (D) Low cohesion and low coupling
developed
incrementally
2) Evolutionary b) Requirements
model compromises
are inevitable
3) Component- c) Explicit
based recognition
software of risk
engineering
4) Spiral d) Inflexible
development partitioning of
the project
into stages
(A)
(B)
(C)
(D)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 410
GATE QUESTION BANK SE & WT

Answer Keys & Explanations


1. [Ans. A]
Functional dependences can be measure
between two metrics
a) Cohesion
b) Coupling
Coupling is the measure of interdependencies
among modules. As per Modularity coupling
should be low.
Low High
Coupling spectrum

Procedural
cell
Data coupling

Inclusion
coupling

Common
External

coupling

coupling

coupling

coupling
Content

coupling
Control

coupling
Stamp

Low
coupling

Import
coupling

2. [Ans. B]
Waterfall model is inflexible partitioning
because if once a phase is completed, it is
difficult to repeat that if any error
encounters in the later phases
Model is incremental
development
Spiral model is used where risk faction is
more important

3. [Ans. C]
Option (A) is false because implementation
details are not given in requirement
documents.
Option (B) is false because practically it
cannot be achieved perfectly
Option (D) is false because requirement
review is done on requirement document
after that design phase starts.
Option (C) is true.

4. [Ans. B]
Cohesion is a measure of internal strength
within a module, whereas coupling is a
measure of inter dependency among the
modules. So in the context of modular
software design there should be high
cohesion and low coupling.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 411
GATE QUESTION BANK SE & WT

Process Modeling
CS – 2009 CS – 2011
1. Consider the following statements about 3. Which one of the following is NOT
the Cyclomatic complexity of the control defined in a correct good Software
flow graph as a program module. Which of Requirement Specification (SRS)
these are true? document?
I. The Cyclomatic complexity of a (A) Functional Requirement
module is level to maximum (B) Non - Functional Requirements
number of linear independent (C) Goals of Implementation
circuits in a graph. (D) Algorithms for software
II. The Cyclomatic complexity of a Implementation
module is the number of decisions in
the module plus one where a decision CS – 2013
is effectively any conditional statement 4. The following figure represents access
in the module. graphs of two modules M1 and M2. The
III. The Cyclomatic complexity can also be filled circles represent methods and the
used as a number of linearly unfilled circles represent attributes. If
independent paths that should be method m is moved to module M2 keeping
tested during path coverage testing. the attributes where they are, what can we
(A) I &II (C) I & III say about the average cohesion and
(B) II & III (D) I, II & III coupling between modules in the system
of two modules?
CS – 2010 Module M1 Module M2
2. The Cyclomatic complexity of each of the
module A & B shown below is 10. What is
the Cyclomatic complexity of the sequential
integration shown on the right hand side.
m
(A) There is no change.
A (B) Average cohesion goes up but coupling
A B is reduced.
(C) Average cohesion goes down and
B coupling also reduces.
(D) Average cohesion and coupling
increased.
(A) 19 (C) 20
(B) 21 (D) 10

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 412
GATE QUESTION BANK SE & WT

Answer Keys & Explanations


1. [Ans. B] 4. [Ans. A]
Cyclomatic complexity V(c) can be evaluated If a method m is moved to module M2 by
by Keeping the attributes where they are
average cohesion and coupling between
modules will not change in the system.
V(c) = Number of internal persons +1 Cohesion M2 and M1 are interchanged but
External Regions average cohesion will be the same for the
given system after moving the method m to
2. [Ans. A] module M2
Cyclomatic complexity also known as
structural complexity because it gives
internal view of code. It is used to find the
number of independent paths.
So in the problem

Both have cyclomatic complexity = 10 is


given. So

Cyclomatic complexity of this is

3. [Ans. D]
A software requirements specification
(SRS), a requirements specification for a
software system, is a complete description
of the behavior of a system to be developed.
In addition it also contains non-functional
requirements. Algorithms are developed
during design phase.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 413
GATE QUESTION BANK SE & WT

Project Management
CS-2009 (A) 4000 (C) 4333
1. Which of the following statements are (B) 5000 (D) 4667
true?
I. The context diagram should depict the 3. A company needs to develop digital signal
system as a single bubble. processing software for one of its newest
II. External entities should be identified inventions. The software is expected to
clearly at all levels of DFDs have 40000 lines of code. The company
III. Control information should not be needs to determine the effort in person
represented in a DFD months needed to develop this software
IV. A data store can be connected either to using basic COCOMO model. The
another data store or to an external multiplicative factor for this model is given
entity. as 2.8 for the software development on
(A) II & III (C) I & III embedded systems, while the
(B) I, II & IV (D) I, II & III exponentiation factor is given as 1.20.
What is the estimated effort in person
CS-2011 months?
2. A company needs to develop a strategy for (A) 234.25 (C) 287.80
Software Product development for which it (B) 932.50 (D) 122.40
has a choice of two programming language
L1& L2. The number of lines of code (LOC)
developed using L2 is estimated to be twice
the LOC developed with L1.The product will
have to be maintained for five years. Various
parameters for the company are given in
the table below.
Parameter Language L1 Language L2
Man years LOC /10000 LOC/10000
needed for
development
Development $ 10,00, 00 $ 7,50,000
cost per man
year
Maintenance 5 years 5 years
time
Cost of $ 1,00, 000 $ 50, 000
maintenance
per year
Total cost of the project indicates cost of
yeayearyearm
development & maintenance. What is the
aintenancema
LOC for L1per
intenance for which the cost of the project
using
year L1 is equal to the cost of the project
using ?

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 414
GATE QUESTION BANK SE & WT

Answer Keys & Explanations


1. [Ans. C]
II. In DFD external entities are represented
only at level 0 DFD or context diagram
IV. Between every external agent & data
store process is compulsory, i.e

Invalid Notations

Valid Notations

2. [Ans. B]
L1 = x L2 = 2x
Given,
Cost of project using L1
= Cost of project using

3. [Ans. A]
Effort in person per month = ab
=2.8(40)1.20 = 234.22 Person – month

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 415
GATE QUESTION BANK SE & WT

Validation and Verification


CS - 2010 CS - 2011
1. What is the appropriate paring of 3. The following is comment written for a
items in the two columns listing C function.
various activities encountered in a /*This function computes the roots of
software use cycle. quadratic equation.
P. Requirements 1. Module ax2 + bx + c = 0 the function stores
Capture development two real roots in * root1 & * root2 &
& integration returns the status of validity of
Q. Design 2. Domain roots. In handles four different
Analysis kinds of cases
R. Implementation 3. Structures & i. When coefficient a is zero
Behavioral irrespective of discriminant
Modeling ii. When discriminant is positive.
S. Maintenance 4. Performance iii. When discriminant is zero
Tuning iv. When discriminant is negative
(A) Only in cases (ii) & (iii) the stored roots
(B) are valid otherwise 0 is stored in the
(C) roots. The function returns 0 when the
(D) roots are valid & 1 otherwise. The
function also ensures root1 >= root2
2. The following program is to be tested for int get_QuadRoots (float a, float b, float c,
statement coverage: float *root 1, float *root2)*/
Begin A software test engineer is assigned the
if (a==b),{S1;exit; } job of doing black box testing. He comes
else if(c==d){S2;} up with the following test cases, many
else {S3; exit;} of which are redundant
S4; Test Input set Expected output set
end case a b c Root Root 2 Return
The test cases T1, T2, T3& T4 given 1 value
below are expressed in terms of the T1 0.0 0.0 7.0 0.0 0.0 1
properties satisfied by the values of T2 0.0 1.0 3.0 0.0 0.0 1
variables a, b, c & d. The exact values are T3 1.0 2.0 1.0 1.0 1.0 0
not given. T4 4.0 12.0 9.0 1.5 1.5 0
T1: a, b, c & d are all equal T5 1.0 2.0 3.0 3.0 1.0 0
T2: a, b, c & d are all distinct T6 1.0 1.0 4.0 0.0 0.0 1
T3: a = b &c != d
Which one of the following options
T4 : a!=b & c = d
provide the set of non – redundant
Which of the test suites given below
tests using equivalence class
ensures coverage of statements S1, S2, S3&
partitioning approach from input
S4.
perspective for black testing?
(A) T1,T2,T3 (C) T3,T4
(A) T1, T2, T3, T6 (C) T2, T4, T5, T6
(B) T2,T4 (D) T1,T2,T4
(B) T1, T3, T4, T5 (D) T2, T3, T4, T5

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 416
GATE QUESTION BANK SE & WT

CS - 2013 1. “ ” w “ ”
Common Data for Question 4 and 5 2. “ ” w “ ”
The procedure given below is required 3. “ ” w “ ”
to find and replace certain characters 4. “ ” w “ ”
inside an input character string supplied 4. The tester now tests the program on all
in array A. The characters to be replaced input strings of length five consisting of
are supplied in array oldc, while their h ‘ ’ ‘ ’ ‘ ’ ‘ ’ ‘ ’ w h
respective replacement characters are duplicates allowed. If the tester carries
supplied in array newc. Array A has a out this testing with the four test cases
fixed length of five characters, while given above, how many test cases will
arrays oldc and newc contains three be able to capture the flaw?
characters each. (A) Only one (C) Only three
However, the procedure is flawed. (B) Only two (D) All four
void find_and_replace (char *A, char *oldc,
char *newc) { 5. If array A is made to hold the string
for (int i = 0 ; i < 5 ; i++) “ ” which of the above four test
for (int j = 0 ; j < 3 ; j++) cases will be successful in exposing the
if (A[i] == oldc [j]) flaw in this procedure?
A [i] = newc[j] ; (A) None (C) 3 and 4 only
(B) 2 only (D) 4 only
}
The procedure is tested with the
following four test cases.

Answer keys and Explanations


1. [Ans. B]
These are all the activities encountered in 4. [Ans. B]
a software life cycle. Requirement capture There is problem in the given code because
means requirement analysis we gather Break statement is missing.
the information about a particular Correct implementation is
domain. for (int j = 0; j < 3; j++)
if (A[i] == oldc[j])
2. [Ans. D] {
h A[i] = newc[j];
h break;
h }
h In both the questions whether array contain
repeated element or not, flaw is due to oldc
and newc string only.
Flaw is in test case 3 and 4.
3. [Ans. C]
“ ”
T1, & T2 checking same condition a = 0
i = 0, j = 0
hence, any one of T1 & T2 is redundant
A[0] = a
T3 and T4: in both cases
oldc [0] = b
discriminant (D) = b2 4ac = 0
a
Hence any one of it is redundant.
i = 0, j = 1
T5 : D > 0
A[0] = a
T6: D < 0
th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 417
GATE QUESTION BANK SE & WT

oldc [1] = c i= 0 j = 1
a c a [0] = b
i=0j=2 a [0] = oldc[1]
A[0] = a a [0] = newc[1]
oldc [2] = a array content abcde
A [0] == oldc[2] flow a two replacements
A [0] = newc[2]
Array content abcde
i = 1 j =0
a [1] = b
oldc [0] = b
a [1] == oldc[0]
a [1] = newc[0]
Array content = accde
i=1j=1
a [1] = c
oldc [1] = c
a[1] == oldc[1]
a[1] = newc[1]
adcde
flow
Two successive replacement but if should
break after one replacement.

5. [Ans. C]
There is problem in the given code because
Break statement is missing.
Correct implementation is
for (int j = 0; j < 3; j++)
if (A[i] == oldc[j])
{
A[i] = newc[j];
break;
}
In both the questions whether array contain
repeated element ot not, flaw is due to oldc
and newc string only.
Flaw is in test case 3 and 4.
Array abcde
i=0j=0
a [0] = a
oldc [0] = b
a [0] == oldc [0]
a [0] = newc [0]
array content bbcde

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 418
GATE QUESTION BANK SE & WT

HTML Structure
CS - 2005 CS - 2011
1. Consider the three commands: PROMPT, 3. HTML (Hyper Text Markup language) has
HEAD and RCPT. Which of the following language elements which permit certain
options indicate a correct association of actions other than describing the
these commands with protocols where structure of the web document. Which
these are used? one of the actions is NOT supported by
(A) HTTP, SMTP, FTP pure HTML (without any client or server
(B) FTP, HTTP, SMTP side scripting) pages?
(C) HTTP, FTP, SMTP (A) Embed web objects from different
(D) SMTP, HTTP, FTP sites into same page
(B) Refresh the page automatically after
CS - 2009 a specified interval
2. Consider the HTML table definition given (C) Automatically redirect to another
below: page upon download
<table border=1> (D) Display the client time as part of the
<tr><td rowspan=2>ab</td> page
<td colspan=2> cd </td>
</tr>
<tr><td>ef</td>
<td rowspan=2>gh</td>
</tr>
<tr><td colspan=2>ij</td>
</tr>
</table>
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)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 419
GATE QUESTION BANK SE & WT

Answer keys and Explanations


1. [Ans. B]
PROMPT: This command is used in FTP
(File Transfer Protocol)
HEAD: HEAD command is used in HTTP,
asks for the response identical to the one
that would correspond to a GET request,
But without the response body.
RCPT: This command is used in SMTP. It
is used to establish the return address or
return path.

2. [Ans. C]
Rowspan is used to specifying how many
rows a cell should span Colspan is used to
specifying how many columns a cell should
span
Table looks like.
cd

ab ef gh
ij

3. [Ans. D]
Date and Time can be displayed using
JavaScript
(A) For Embedding Object Tag is
available. <Object> Following
Objects can be Embedded,
ActiveX Controls, Flash,
Fireworks etc.
(B) <META http-equiv="refresh"
Content="5"> this will refresh a
page after 5 seconds
(C) <META http-equiv="refresh"
Content="5;
URL=http://www.othersite.com"> this
will Redirect a page after 5 seconds
(D) It needs JavaScript. Pure HTML does
not have any tag to show time on the
page.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 420
GATE QUESTION BANK SE & WT

XML and DTDs


CS - 2005 CS - 2006
1. Given below is an excerpt of xml 2. Consider the following XML DTD describing
specification. course information in a university:
<! DOCTYPE library SYSTEM <! ELEMENT Univ (Course+ , Prof+) >
" library .dtd "> <! ELEMENT Course (Title, Eval* ) >
<Book> <!ATTLIST Course number ID #REQUIRED
<title> GATE 2005 </title> Instructor IDREF # IMPLIED >
<type value= " BROCHURE”/> <! ELEMENT Title ( # PCDATA) >
<accno> 10237623786 </accno> <! ELEMENT Eval( # PCDATA ) >
</Book> <! ATTLIST Eval Score CDATA # REQUIRED >
<Book> <! ELEMENT Prof Empty >
<type value= " FICTION" /> <! ATTLIST Prof Name ID # REQUIRED
<accno> 0024154807 </accno> Teaches IDREF # IMPLIED >
</Book> What is returned by the following
Given below are several possible excerpts XQUERY?
from "library.dtd" . For which excerpt Let $ as := //@ Score
would the above specification be valid ? For $c in /Univ/Course [Eval]
(A) < ! ELEMENT Book (title+ , type, accno) > Let $cs :=$?c/Eval?@ Score
<! ELEMENT title (# PCDATA )> Where min ($cs) >avg ($ as)
<! ELEMENT type EMPTY > return $c
<! ATTLIST type value (BROCHURE (A) The professor with the lowest course
/FICTION/TECHNICAL) > evaluation
<! ELEMENT accno( # PCDATA ) > (B) Professors who have all their course
(B) < ! ELEMENT Book (title? , type, accno) > evaluation above the university average
<! ELEMENT title (# PCDATA )>
(C) The course with the lowest evaluation
<! ELEMENT type ATTLIST >
(D) Course with all evaluations above the
<!ATTLIST type value (BROCHURE
university average
/FICTION/TECHNICAL) >
< ! ATTLIST accno (# PCDATA) > CS - 2013
(C) <! ELEMENT Book (title* , type, accno) >
3. Match the problem domains in GROUP I with
<! ELEMENT title (# PCDATA )>
the solution technologies in GROUP II.
<! ELEMENT type ATTLIST >
GROUP I GROUP II
<!ATTLIST type value (BROCHURE
(P) Service oriented 1) Interoperability
/FICTION/TECHNICAL) >
<! ELEMENT accno( # PCDATA ) > computing
(D) < ! ELEMENT Book (title? , type, accno) > (Q) Heterogeneous 2) BPMN
<! ELEMENT title (# PCDATA )> communicating
<! ELEMENT type EMPTY > systems
<! ATTLIST type value (BROCHURE (R) Information 3) Publish-find-
/FICTION/TECHNICAL) > representation bind
<! ELEMENT accno (# PCDATA )> (S) Process description 4) XML
(A)
(B)
(C)
(D)

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 421
GATE QUESTION BANK SE & WT

Answer keys and Explanations


1. [Ans. D]
Book tag is repeated twice. <title> can be
either
1) Zero or more (*)
2) Zero or one (?)
<type>is EMPTY and have an attribute.

2. [Ans. D]
Return $c - Query return 'c' where 'c' is
set as Course with all Evaluations
Where min ($cs) >avg ($ as) - min(cs) is
minimum score of each evaluation in a
course
avg(as) is average of all the scores in all
courses from all professors.

3. [Ans. C]
Service oriented computer (
publish find bind
H p
Information representation XML
Process p BPMN.

th th th
THE GATE ACADEMY PVT.LTD. H.O.: #74, KeshavaKrupa (third Floor), 30 Cross, 10 Main, Jayanagar 4 Block, Bangalore-11
: 080-65700750,  [email protected] © Copyright reserved. Web: www.thegateacademy.com Page 422

You might also like