178 – 210 Introduction to Operating System Process Management Threads CPU Scheduling Deadlocks Memory Management & Virtual Memory File System I/O System
Data Structure and Algorithm Analysis Stacks and Queues Trees Height Balanced Trees (AVL Trees, B and Priority Queues (Heaps) Sorting Algorithms Graph Algorithms Hashing
236 – 263
Introduction to Computer Organization Memory Hierarchy Pipeline Instruction Types I/O Data Transfer
236 237 – 246 247 – 252 253 – 258 259 – 263
Digital Logic 30 31
264 – 289 Number Systems & Code Conversions Boolean Algebra & Karnaugh Maps th
Logic Gates Logic Gate Families Combinational and Sequential Digital Circuits
276 – 279 280 281 – 289
Discrete Mathematics & Graph Theory
290 – 322
35 36 37 38
290 – 297 298 - 300 301 – 313 314 – 322
Mathematical Logic Combinatorics Sets and Relations Graph Theory
Database Management System 39 40 41 42 43 44
#9.
Contents
323 – 361
ER Diagrams Functional Dependencies & Normalization Relational Algebra & Relational Calculus SQL Transactions and Concurrency Control File Structures (Sequential files, Indexing, B and trees)
Introduction to Computer Networks Medium Access Sublayer (LAN Technologies: Ethernet, Token Ring) The Data Link Layer (Flow and Error Control Techniques) Routing & Congestion Control TCP/IP, UDP and Sockets, IP(V4) Application Layer Network Security
Linear Algebra ME – 2005 1. Which one of the following is an Eigenvector of the matrix[
(A) [
]
(B) [ ]
2.
5.
]?
(C) [
]
(D) [
]
A is a 3 4 real matrix and Ax=B is an inconsistent system of equations. The highest possible rank of A is (A) 1 (C) 3 (B) 2 (D) 4
ME – 2006 3. Multiplication of matrices E and F is G. Matrices E and G are os sin E [ sin ] and os G
4.
[
sin os
sin (B) [ os
os sin
]
os (C) [ sin
sin os
]
sin (D) [ os
os sin
7.
Eigenvectors of 0
1 is
(A) 0 (B) 1
(C) 2 (D) Infinite
If a square matrix A is real and symmetric, then the Eigenvalues (A) are always real (B) are always real and positive (C) are always real and non-negative (D) occur in complex conjugate pairs
]
ME – 2008 8.
The Eigenvectors of the matrix 0
1 are
written in the form 0 1 and 0 1. What is a + b? (A) 0 (B) 1/2
]
Eigen values of a matrix 0
ME – 2007 6. The number of linearly independent
]. What is the matrix F?
os (A) [ sin
S
Match the items in columns I and II. Column I Column II P. Singular 1. Determinant is not matrix defined Q. Non-square 2. Determinant is matrix always one R. Real 3. Determinant is symmetric zero matrix S. Orthogonal 4. Eigen values are matrix always real 5. Eigen values are not defined (A) P - 3 Q - 1 R - 4 S - 2 (B) P - 2 Q - 3 R - 4 S - 1 (C) P - 3 Q - 2 R - 5 S - 4 (D) P - 3 Q - 4 R - 2 S - 1
9.
(C) 1 (D) 2
The matrix [
] has one Eigenvalue p equal to 3. The sum of the other two Eigenvalues is (A) p (C) p – 2 (B) p – 1 (D) p – 3
1are 5 and 1. What are the
Eigenvalues of the matrix = SS? (A) 1 and 25 (C) 5 and 1 (B) 6 and 4 (D) 2 and 10 th
For what value of a, if any, will the following system of equations in x, y and z have a solution x y x y z x y z (A) Any real number (B) 0 (C) 1 (D) There is no such value
11.
ME – 2012 15.
For a matrix,M-
*
x
√
(B) (√ )
1 is
(A) 2 (B) 2 3
3
(C) 2 3 (D) 2
3
ME – 2011 13. Consider the following system equations: x x x x x x x The system has (A) A unique solution (B) No solution (C) Infinite number of solutions (D) Five solutions 14.
of
Eigen values of a real symmetric matrix are always (A) Positive (C) Negative (B) Real (D) Complex
(D) ( ) √
√
of the matrix is equal to the inverse of the ,M- . The value of x is matrix ,Mgiven by ) (A) ( (C) ⁄ ( ⁄ ) (B) (D) ⁄
0
1 , one of the
(C) (√ )
(A) (√ )
+, the transpose
ME – 2010 12. One of the Eigenvectors of the matrix
For the matrix A=0
normalized Eigenvectors is given as
16.
ME – 2009
Mathematics
x + 2y + z =4 2x + y + 2z =5 x–y+z=1 The system of algebraic equations given above has (A) a unique algebraic equation of x = 1, y = 1 and z = 1 (B) only the two solutions of ( x = 1, y = 1, z = 1) and ( x = 2, y = 1, z = 0) (C) infinite number of solutions. (D) No feasible solution.
ME – 2013 17. The Eigenvalues of a symmetric matrix are all (A) Complex with non –zero positive imaginary part. (B) Complex with non – zero negative imaginary part. (C) Real (D) Pure imaginary. 18.
Choose correct set of functions, which are linearly dependent. (A) sin x sin x n os x (B) os x sin x n t n x (C) os x sin x n os x (D) os x sin x n os x
ME – 2014 19. Given that the determinant of the matrix [
Consider a non-homogeneous system of linear equations representing mathematically an over-determined system. Such a system will be (A) consistent having a unique solution (B) consistent having many solutions (C) inconsistent having a unique solution (D) inconsistent having no solution
3.
Consider the matrices , - . The order of , (
1 is
(A) {– }
(C) 2
(B) {– }
(D) 2 3
3
Consider a 3×3 real symmetric matrix S such that two of its Eigenvalues are with respective Eigenvectors x y [x ] [y ] If then x y + x y +x y x y equals (A) a (C) ab (B) b (D) 0 Which one of the following equations is a correct identity for arbitrary 3×3 real matrices P, Q and R? (A) ( ) ) (B) ( ( ) (C) et et et ) (D) (
CE – 2005 1. Consider the system of equations ( ) is s l r Let ( ) ( ) where ( ) e n Eigen -pair of an Eigenvalue and its corresponding Eigenvector for real matrix A. Let I be a (n × n) unit matrix. Which one of the following statement is NOT correct? (A) For a homogeneous n × n system of linear equations,(A ) X = 0 having a nontrivial solution the rank of (A ) is less than n. (B) For matrix , m being a positive integer, ( ) will be the Eigen pair for all i. (C) If = then | | = 1 for all i. (D) If = A then is real for all i.
Mathematics
,
-
,
-
and
- will be ) (C) (4 × 3) (D) (3 × 4
(A) (2 × 2) (B) (3 × 3
CE – 2006 4. Solution for the system defined by the set of equations 4y + 3z = 8; 2x – z = 2 and 3x + 2y = 5 is (A) x = 0; y =1; z = ⁄ (B) x = 0; y = ⁄ ; z = 2 (C) x = 1; y = ⁄ ; z = 2 (D) non – existent
5.
For the given matrix A = [
],
one of the Eigen values is 3. The other two Eigen values are (A) (C) (B) (D) CE – 2007 6. The minimum and the maximum Eigenvalue of the matrix [
]are 2
and 6, respectively. What is the other Eigenvalue? (A) (C) (B) (D) 7.
For what values of and the following simultaneous equations have an infinite 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
CE – 2008 9. The product of matrices ( ) (A) (C) (B) (D) PQ 10.
1 is
Mathematics
n n
The following simultaneous equation x+y+z=3 x + 2y + 3z = 4 x + 4y + kz = 6 will NOT have a unique solution for k equal to (A) 0 (C) 6 (B) 5 (D) 7
CE – 2009 12. A square matrix B is skew-symmetric if (C) (A) (D) (B) CE – 2011 13. [A] is square matrix which is neither symmetric nor skew-symmetric and , is its transpose. The sum and difference of these matrices are defined as [S] = [A] + , - and [D] = [A] , - , respectively. Which of the following statements is TRUE? (A) Both [S] and [D] are symmetric (B) Both [S] and [D] are skew-symmetric (C) [S] is skew-symmetric and [D] is symmetric (D) [S] is symmetric and [D] is skew symmetric
The Eigenvalues of matrix 0 (A) (B) (C) (D)
1 are
2.42 and 6.86 3.48 and 13.53 4.70 and 6.86 6.86 and 9.50
CE – 2013 16. There is no value of x that can simultaneously satisfy both the given equations. Therefore, find the ‘le st squares error’ solution to the two equations, i.e., find the value of x that minimizes the sum of squares of the errors in the two equations. 2x = 3 and 4x = 1 17.
What is the minimum number of multiplications involved in computing the matrix product PQR? Matrix P has 4 rows and 2 columns, matrix Q has 2 rows and 4 columns, and matrix R has 4 rows and 1 column. __________
CE – 2014 18.
Given the matrices J = [ K
19.
[
] n
], the product K JK is
The sum of Eigenvalues of the matrix, [M] is, where [M] = [
Let A be a 4x4 matrix with Eigenvalues –5, –2, 1, 4. Which of the following is an I Eigenvalue of 0 1, where I is the 4x4 I identity matrix? (A) (C) (B) (D)
]
is ____________ 21.
The
rank
[
of
the
matrix
] is ________________
CS – 2005 1. Consider the following system of equations in three real variables x x n x x x x x x x x x x This system of equation has (A) no solution (B) a unique solution (C) more than one but a finite number of solutions (D) an infinite number of solutions 2.
What are the Eigenvalues of the following 2 2 matrix? 0 (A) (B)
1 n n
(C) (D)
n n
CS – 2006 3. F is an n x n real matrix. b is an n real vector. Suppose there are two nx1 vectors, u and v such that u v , and Fu=b, Fv=b. Which one of the following statement is false? (A) Determinant of F is zero (B) There are infinite number of solutions to Fx=b (C) There is an x 0 such that Fx=0 (D) F must have two identical rows
Mathematics
CS – 2007 5. Consider the set of (column) vectors defined by X={xR3 x1+x2+x3=0, where XT =[x1, x2, x3]T }. Which of the following is TRUE? (A) {[1, 1, 0]T, [1, 0, 1]T} is a basis for the subspace X. (B) {[1, 1, 0]T, [1, 0, 1]T} is a linearly independent set, but it does not span X and therefore, is not a basis of X. (C) X is not the subspace for R3 (D) None of the above CS – 2008 6. The following system of x x x x x x x x x Has unique solution. The only possible value (s) for is/ are (A) 0 (B) either 0 or 1 (C) one of 0,1, 1 (D) any real number except 5 7.
How many of the following matrices have an Eigenvalue 1? 0
1 0
1 n 0
1 0
(A) One (B) two
1
(C) three (D) four
CS – 2010 8. Consider the following matrix 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
The value of the dot product of the Eigenvectors corresponding to any pair of different Eigenvalues of a 4-by-4 symmetric positive definite matrix is __________.
14.
If the matrix A is such that
]
Which one of the following options provides the CORRECT values of the Eigenvalues of the matrix? (A) 1, 4, 3 (C) 7, 3, 2 (B) 3, 7, 3 (D) 1, 2, 3
[
CS – 2013 11. Which one of x x equal [ y y z z x(x y(y (A) | z(z x (B) | y z x y (C) | y z z x y (D) | y z z
15.
-
The product of the non – zero Eigenvalues of the matrix
is __________. [ 16.
the following does NOT ] ) x ) y | ) z x | y z x y y z | z x y y z | z
],
Then the determinant of A is equal to __________.
CS – 2012 10. Let A be the 2
2 matrix with elements and . Then the Eigenvalues of the matrix are (A) 1024 and (B) 1024√ and √ (C) √ n √ (D) √ n √
Mathematics
]
Which one of the following statements is TRUE about every n n matrix with only real eigenvalues? (A) If the trace of the matrix is positive and the determinant of the matrix is negative, at least one of its eigenvalues is negative. (B) If the trace of the matrix is positive, all its eigenvalues are positive. (C) If the determinant of the matrix is positive, all its eigenvalues are positive. (D) If the product of the trace and determinant of the matrix is positive, all its eigenvalues are positive.
ECE – 2005 1. Given an orthogonal matrix
CS – 2014 12. Consider the following system of equations: x y x z x y z x y z The number of solutions for this system is __________.
ECE – 2007 7. It is given that X1 , X2 …… M are M nonzero, orthogonal vectors. The dimension of the vector space spanned by the 2M vector X1 , X2 … XM , X1 , X2 … XM is (A) 2M (B) M+1 (C) M (D) dependent on the choice of X1 , X2 … XM.
9.
All the four entries of the 2 x 2 matrix p p P = 0p p 1 are non-zero, and one of its Eigenvalues is zero. Which of the following statements is true? (A) p p p p (B) p p p p (C) p p p p (D) p p p p
Eigenvector
1 is
(A) 2 (B) 4 5.
1 , the Eigenvalue to
(C) 6 (D) 8
The Eigenvalues and the corresponding Eigenvectors of a 2 2 matrix are given by Eigenvalue Eigenvector =8
v =0 1
=4
(C) 2 (D) 3
ECE – 2008 8. The system of linear equations 4x + 2y = 7, 2x + y = 6 has (A) a unique solution (B) no solution (C) an infinite number of solutions (D) exactly two distinct solutions
1 the
(A) 0 1
]
v =0
1
ECE – 2009 10. The Eigen values of the following matrix are [
ECE – 2010 11. The Eigenvalues of a skew-symmetric matrix are (A) Always zero (B) Always pure imaginary (C) Either zero or pure imaginary (D) Always real ECE – 2011 12. The system of equations x y z x y z x y z has NO solution for values of given by (A) (C) (B) (D)
Mathematics
ECE – 2014 16. For matrices of same dimension M, N and scalar c, which one of these properties DOES NOT ALWAYS hold? (A) (M ) M (M) (B) ( M ) (C) (M N) M N (D) MN NM 17.
A real (4 × 4) matrix A satisfies the equation I where 𝐼 is the (4 × 4) identity matrix. The positive Eigenvalue of A is _____.
18.
Consider the matrix
n
J ECE\EE\IN – 2012 13.
Given that A = 0
1 and I = 0
the value of A3 is (A) 15 A + 12 I (B) 19A + 30
(C) 17 A + 15 I (D) 17A +21
ECE – 2013 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 ________.
20.
The system of linear equations
]
(A) 0 (B) 1 15.
[ ] Which is obtained by reversing the order of the columns of the identity matrix I . Let I J where is a nonnegative real number. The value of for which det(P) = 0 is _____.
1,
(C) 2 (D) 3
(
Let A be a m n matrix and B be a n m matrix. It is given that ) determinant Determinant(I (I ) where I is the k k identity matrix. Using the above property, the determinant of the matrix given below is
(A) 2 (B) 5
(
)h s
(A) a unique solution (B) infinitely many solutions (C) no solution (D) exactly two solutions 21.
[
)4 5
] (C) 8 (D) 16
th
Which one of the following statements is NOT true for a square matrix A? (A) If A is upper triangular, the Eigenvalues of A are the diagonal elements of it (B) If A is real symmetric, the Eigenvalues of A are always real and positive th
(C) If A is real, the Eigenvalues of A and are always the same (D) If all the principal minors of A are positive, all the Eigenvalues of A are also positive 22.
The maximum value of the determinant among all 2×2 real symmetric matrices with trace 14 is ___.
EE – 2005 1.
5.
If R = [
] , then top row of
(A) , (B) ,
2.
-
(C) , (D) ,
(B) [
] [
] [
]
(C) [
] [
] [
]
(D) [
] [
] [
]
-
(A) [ ] (B) [
]
(C) [
(B) [
]
(D) [ ]
]
In the matrix equation Px = q, which of the following is necessary condition for the existence of at least one solution for the unknown vector x (A) Augmented matrix [P/Q] must have the same rank as matrix P (B) Vector q must have only non-zero elements (C) Matrix P must be singular (D) Matrix P must be square
] ,R=[
(C) [ ] ]
(D) [
]
EE – 2007 6. X = [x , x . . . . x - is an n-tuple non-zero vector. The n n matrix V = X (A) Has rank zero (C) Is orthogonal (B) Has rank 1 (D) Has rank n 7.
The linear operation L(x) is defined by the cross product L(x) = b x, where b =[0 1 0- and x =[x x x - are three dimensional vectors. The matrix M of this operation satisfies x L(x) = M [ x ] x Then the Eigenvalues of M are (A) 0, +1, 1 (C) i, i, 1 (B) 1, 1, 1 (D) i, i, 0
8.
Let x and y be two vectors in a 3 dimensional space and denote their dot product. Then the determinant xx xy det 0 y x yy 1 (A) is zero when x and y are linearly independent (B) is positive when x and y are linearly independent (C) is non-zero for all non-zero x and y (D) is zero only when either x or y is zero
EE – 2006 Statement for Linked Answer Questions 4 and 5.
4.
]
is
] , one of
(A) [
] ,Q=[
] [
-
For the matrix p = [
P=[
(A) [
The following vector is linearly dependent upon the solution to the previous problem
the Eigenvalues is equal to 2 . Which of the following is an Eigenvector?
3.
Mathematics
] are
three vectors An orthogonal set of vectors having a span that contains P,Q, R is th
Statement for Linked Questions 9 and 10. Cayley-Hamilton Theorem states that a square matrix satisfies its own characteristic equation. Consider a matrix. A=0
A satisfies the relation (A) A + 3 + 2 =0 2 (B) A + 2A + 2 = 0 (C) (A+ ) (A 2) = 0 (D) exp (A) = 0
10.
equals (A) 511 A + 510 (B) 309 A + 104 (C) 154 A + 155 (D) exp (9A)
EE – 2008 11. If the rank of a ( ) matrix Q is 4, then which one of the following statements is correct? (A) Q will have four linearly independent rows and four linearly independent columns (B) Q will have four linearly independent rows and five linearly independent columns (C) Q will be invertible (D) Q will be invertible 12.
13.
(A) A A+ A = A (B) (AA+ ) = A A+ 14.
The characteristic equation of a ( ) matrix P is defined as () = | P| = =0 If I denotes identity matrix, then the inverse of matrix P will be (A) ( I) (B) ( I) (C) ( I) (D) ( I)
(C) A+ A = (D) A A+ A = A+
Let P be a real orthogonal matrix. x⃗ is a real vector [x x - with length ⃗x (x x ) . Then, which one of the following statements is correct? (A) x⃗ x⃗ where at least one vector satisfies x⃗ x⃗ (B) x⃗ x⃗ for all vectors x⃗ (C) x⃗ x⃗ where at least one vector satisfies x⃗ x⃗ (D) No relationship can be established between x⃗ and x⃗
1
9.
Mathematics
EE – 2009 15. The trace and determinant of a matrix are known to be –2 and –35 respe tively It’s Eigenv lues re (A) –30 and –5 (C) –7 and 5 (B) –37 and –1 (D) 17.5 and –2 EE – 2010 16. For the set of equations x x x x =2 x x x x =6 The following statement is true (A) Only the trivial solution x x x x = 0 exists (B) There are no solutions (C) A unique non-trivial solution exists (D) Multiple non-trivial solutions exist
17.
An Eigenvector of
[
(A) , (B) ,
(C) , (D) ,
-
] is -
EE – 2011 18.
The matrix[A] = 0
1 is decomposed
into a product of a lower triangular matrix [L] and an upper triangular matrix [U]. The properly decomposed [L] and [U] matrices respectively are
A is m n full rank matrix with m > n and is an identity matrix. Let matrix A+ = ( ) , then, which one of the following statements is FALSE?
(C) Non – zero unique solution (D) Multiple solution 20.
(A) [ 1 1]T (B) [3 1]T
A matrix has Eigenvalues – 1 and – 2. The corresponding Eigenvectors are 0 0
1 respectively. The matrix is
(A) 0
1
(C) 0
1
(B) 0
1
(D) 0
1
Which one of the following statements is true for all real symmetric matrices? (A) All the eigenvalues are real. (B) All the eigenvalues are positive. (C) All the eigenvalues are distinct. (D) Sum of all the eigenvalues is zero.
1?
(C) [1 1]T (D) [ 2 1]T
Let A be a 3 3 matrix with rank 2. Then AX = 0 has (A) only the trivial solution X = 0 (B) one independent solution (C) two independent solutions (D) three independent solutions
2.
1 and
EE – 2014 21. Given a system of equations: x y z x y z Which of the following is true regarding its solutions? (A) The system has a unique solution for any given and (B) The system will have infinitely many solutions for any given and (C) Whether or not a solution exists depends on the given and (D) The system would have no solution for any values of and 22.
Two matrices A and B are given below: p q pr qs p q [ ] 0 1 r s pr qs r s If the rank of matrix A is N, then the rank of matrix B is (A) N (C) N (B) N (D) N
IN – 2005 1. Identify which one of the following is an
(A) No solution x (B) Only one solution 0x 1
Mathematics
IN – 2006 Statement for Linked Answer Questions 3 and 4 A system of linear simultaneous equations is given as Ax=B where [
] n
[ ]
3.
The rank of matrix A is (A) 1 (C) 3 (B) 2 (D) 4
4.
Which of the following statements is true? (A) x is a null vector (B) x is unique (C) x does not exist (D) x has infinitely many values
(D) A 1 3 IN – 2007 6. Let A = [ ] i j n with n = i. j. Then the rank of A is (A) (C) n (B) (D) n 7.
n
Let A be an n×n real matrix such that = I and y be an n- dimensional vector. Then the linear system of equations Ax=Y has (A) no solution (B) a unique solution (C) more than one but finitely many independent solutions (D) Infinitely many independent solutions
The matrix P =[
12.
9.
The Eigenvalues of a (2 2) matrix X are 2 and 3. The Eigenvalues of matrix ( I) ( I) are (A) (C) (B) (D)
(
)(
)
(D) n IN – 2011 13.
The matrix M = [
] has
Eigenvalues . An Eigenvector corresponding to the Eigenvalue 5 is , - . One of the Eigenvectors of the matrix M is (A) , (C) , √ (B) , (D) ,
] rotates a vector
(C) (D)
A real n × n matrix A = [ ] is defined as i i j follows: { otherwise The summation of all n Eigenvalues of A is (A) n(n ) (B) n(n ) (C)
about the axis[ ] by an angle of (A) (B)
Let P 0 be a 3 3 real matrix. There exist linearly independent vectors x and y such that Px = 0 and Py = 0. The dimension of the range space of P is (A) 0 (C) 2 (B) 1 (D) 3
IN – 2010 11. X and Y are non-zero square matrices of size n n. If then (A) |X| = 0 and |Y| 0 (B) |X| 0 and |Y| = 0 (C) |X| = 0 and |Y| = 0 (D) |X| 0 and |Y| 0
IN – 2009 8.
Mathematics
IN – 2013 14. The dimension of the null space of the
15.
matrix [
] is
(A) 0 (B) 1
(C) 2 (D) 3
One of Eigenvectors corresponding to the two Eigenvalues of the matrix 0 (A) [
IN – 2014 16. For the matrix A satisfying the equation given below, the eigenvalues are , -[
]
[
(A) ( 𝑗,𝑗) (B) (1,1,0)
] (C) ( ) (D) (1,0,0)
Answer Keys and Explanations ME 1.
and G = [
[Ans. A] [
Now E × F = G
]
h r teristi equ tions is | I| ( )( )( ) ∴ Real eigenvalues are 5, 5 other two are complex Eigenvector corresponding to is ( I) (or) →( ) Verify the options which satisfies relation (1) Option (A) satisfies. [Ans. B] Given
n
in onsistent
4.
5.
[Ans. A]
6.
[Ans. B] 1 Eigenv lues re 2, 2 I)
(
I)
No. of L.I Eigenvectors ( (no of v ri les)
( ⁄ )
7.
matrix be A = 0 sin os
.
/ I)
[Ans. A] ( I) . olving for , Let the symmetric and real
[Ans. C] os Given , E = [ sin
]
matrix, if Eigenvalues are … … … … … then for matrix, the Eigenvalues will be , , ……… For S matrix, if Eigenvalues are 1 and 5 then for matrix, the Eigenvalues are 1 and 25.
No (
3.
sin os
[Ans. A] For S
0
( ) n ( ⁄ ) ( ( ) minimum of m n) For inconsistence ( ) ( ⁄ ) ∴ he highest possi le r nk of is
[Ans. C] Suppose the Eigenvalue of matrix A is ( i )(s y) and the Eigenvector is ‘x’ where s the onjug te p ir of Eigenvalue and Eigenvector is ̅ n x̅. So Ax = x … ① and x̅ ̅x̅……② king tr nspose of equ tion ② x̅ x̅ ̅ … ③ [( ) n ̅ is s l r ] ̅ x̅ x x̅ x x̅ x x̅ ̅x … , x̅ x x̅ ̅ x ̅ (x̅ x) ( ̅ re s l r ) (x̅ x) ̅
20.
[Ans. C] We know that os x os x sin x ( ) os x sin x ( ) os x Hence 1, 1 and 1 are coefficients. They are linearly dependent.
1 eigen v lues
Eigenve tor is
verify for oth n
21.
[Ans. D] We know that the Eigenvectors corresponding to distinct Eigenvalues of real symmetric matrix are orthogonal. x y x y [ ][ ] x y x y x y y x
22.
[Ans. D] ( ) In case of matrix PQ
CE 1.
QP (generally)
[Ans. C] If = i.e. A is orthogonal, we can only s y th t if is n Eigenv lue of then
also will be an Eigenvalue of A,
which does not necessarily imply that | | = 1 for all i. 2.
[Ans. A] In an over determined system having more equations than variables, it is necessary to have consistent unique solution, by definition
3.
[Ans. A] With the given order we can say that order of matrices are as follows: 3×4 Y 4×3 3×3
[Ans. A] |
[Ans. D] 0
nnot e zero )
Hence Eigenvalue of a symmetric matrix are real
19.
|
(Taking 2 common from each row) ( )
]
( x x̅ re Eigenve tors they i i i 0
18.
|
]
nk ( ) nk ( | ) So, Rank (A) = Rank (A|B) = 2 < n (no. of variables) So, we have infinite number of solutions 17.
[Ans. A] The augmented matrix for given system is [
]
[Ans. A] Inverse of 0
→
|
Now for infinite solution last row must be completely zero ie –2=0 n –7=0 n
Then by Gauss elimination procedure [
Mathematics
| ]
th
[Ans. D] The augmented matrix for given system is x [ | ] 6y7 [ ] z k Using Gauss elimination we reduce this to an upper triangular matrix to find its rank
[Ans. 16] , , M trix , The product of matrix PQR is , - , - , The minimum number of multiplications involves in computing the matrix product PQR is 16
18.
[Ans. 23]
k [
| ]
[
| ]
→
Now if k Rank (A) = rank (A|B) = 3 ∴ Unique solution If k = 7, rank (A) = rank (A|B) = 2 which is less than number of variables ∴ When K = 7, unique solution is not possible and only infinite solution is possible 12.
[Ans. A] A square matrix B is defined as skewsymmetric if and only if = B
13.
[Ans. D] By definition A + is always symmetric is symmetri is lw ys skew symmetri is skew symmetri
Mathematics
[
][
]
[
,
K JK
]
-[ ,
]
,
[
] -
-
19.
[Ans. A] Sum of Eigenvalues = Sum of trace/main diagonal elements = 215 + 150 + 550 = 915
20.
[Ans. 88] The determinant of matrix is [
]
→
14.
[Ans. B] 1 =(
0
i
∴ 0
15.
i
i
i
,( =
0
0
)
i)( i i
[
1
→
1 i -
i) i i
0
i i
i i
1
[
1
[
]
1 Interchanging Column 1& Column 2 and taking transpose
Sum of the Eigenvalues = 17 Product of the Eigenvalues = From options, 3.48 + 13.53 = 17 (3.48)(13.53) = 47 16.
[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 solution to Fx= b is true since |F| = 0 (C) here is n su h the is also true, since X has infinite number of solutions., including the X = 0 solution (D) F must have 2 identical rows is false, since a determinant may become zero, even if two identical columns 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| I | | I ( ) I I I Eigenvalue of P is ( 5 +1 ), ( 2+ 1), (1+ 1), (4+1 ), ( 5 1 ), ( 2 1 ),(1 1), (4 1) = 4, 1, 2, 5, 6, 3,0,3
5.
[Ans. B] |x X= {x x x = ,x x x - then,
→ [ ( )
(
)
( ) ]
( )
( )
[
] ( )
no. of non zero rows = 2
[Ans. B] The augmented matrix for the given system is [
| ]
Using elementary transformation on above matrix we get, [
| ]
→
⁄ | ] ⁄ ⁄
[
→
[
|
]
Rank ([A B]) = 3 Rank ([A]) = 3 Since Rank ([A B]) = Rank ([A]) = number of variables, the system has unique solution. 2.
[Ans. B] 0
1
The characteristic equation of this matrix is given by | I| |
{ [1, 1, 0]T , [1,0, 1 ]T } is a linearly independent set because one cannot be obtained from another by scalar multiplication. However (1, 1, 0) and (1,0, 1) do not span X, since all such combinations (x1, x2, x3) such that x1+ x2+ x3 =0 cannot be expressed as linear combination of (1, 1,0) and (1,0, 1) 6.
7.
Only one matrix has an Eigenvalue of 1 which is 0
| ] →
→
[
[
1
Correct choice is (A) 8.
[Ans. D] |
| x y ( )( y) When ( y) x y x When ( y) x y x x y Solving (1) & (2) x y
[Ans. D] The augmented matrix for above system is [
Mathematics
| ] | ]
x
( )
( )
Now as long as – 5 0, rank (A) =rank (A|B) =3 ∴ can be any real value except 5. Closest correct answer is (D).
9.
[Ans. A] The Eigenvalues of a upper triangular matrix are given by its diagonal entries. ∴ Eigenvalues are 1, 4, 3 only
[Ans. A]
10.
[Ans. D]
Eigenvalues of 0 |
1
0
| =0
Eigenvalues of 0 |
Eigenvalues of the matrix (A) are the roots of the characteristic polynomial given below.
=0,1 1
|
| =0 =0
1
|
(√ )
)( ) =0 = –1, 1
n
√
n ( √ ) n
1
n
| =0
( (
) )
√ Eigenvalues of A are √ respectively So Eigenvalues of
[Ans. A] → p q nd Since 2 & 3rd columns have been swapped which introduces a –ve sign Hence (A) is not equal to the problem
[
]
→
[
] →
→
[
] →
16.
[
]
( ) ( ) no of v ri ∴ nique solution exists
14.
[ ] x x Let X = x e eigen ve tor x [x ] By the definition of eigenvector, AX = 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 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
]
→ →
les
[Ans. 0] The Eigenvectors corresponding to distinct Eigenvalues of real symmetric matrix are orthogonal
ECE 1.
2.
[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), (D) are not correct
On comparing LHS and RHS 0= 5, which is irrelevant and so no solution. Approach 2: 4x + 2y =7
x x 1= 2 2 1 Hence, 0 4.
1 is Eigenvector.
[Ans. C]
Then Eigenvector is x Verify the options (C) 5.
or 2x y=
1 We know th t it is Eigenvalue
0
We know
0
1
|I A|=0
|
|
2 –I2 +32 =0 = 4, 8 (Eigenvalues) For
= 4, ( I
)=0
1
)=0
1
9.
[Ans. C] Matrix will be singular if any of the Eigenvalues are zero. | |= 0 For = 0, P = 0 p p |p p | =0 p p p p
10.
[Ans. D] Approach1: Eigenvalues exists as complex conjugate or real Approach 2: Eigenvalues are given by
v =0 1 For
= 8, ( I
v =0 6.
1
[Ans. C] [
] [
|
]
[Ans. C] There are M non-zero, orthogonal vectors, so there is required M dimension to represent them ’
| =0
(
( ) 7.
7 2
2x+y=6 Since both the linear equation represent parallel set of straight lines, therefore no solution exists. Approach 3: Rank (A)=1; rank (C)=2, As Rank (A) rank (C) therefore no solution exists.
x
[Ans. A] or m trix
Mathematics
11.
th
)(( ,
)=0
) j
j
[Ans. C] Eigenvalue of skew – symmetric matrix is either zero or pure imaginary. th
[Ans. B] Given equations are x y z x y z and x y z If and , then x y z have Infinite solution If and , then x y z ( ) no solution x y z If n x y z will have solution x y z and will also give solution
et of , -
et of [
]
16.
[Ans. D] Matrix multiplication is not commutative in general.
17.
[Ans. *] Range 0.99 to 1.01 Let ‘ ’ e Eigenv lue of ‘ ’ hen ‘ e Eigenv lue of ‘ ’ A. =I= Using Cauchey Hamilton Theorem,
[Ans. B] 0
Mathematics
’ will
1
Characteristic Equations is 18. By Cayley Hamilton theorem I ∴ ( I) I 14.
I | | [
[Ans. A] [
]
→
(
[
[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, then | | | | | | ∴| | | | | |
20.
[Ans. B]
) ]
]
19.
| |
| | Product of Eigenvalues = 0 ∴ Minimum Eigenv lue h s to e ‘ ’ 15.
whi h is re l symmetri m trix h r teristi equ tion is | I| ( ) ∴ (not positive) ( ) is not true (A), (C), (D) are true using properties of Eigenvalues 22.
EE 1.
2.
[Ans. B] ] j( ) | |
=[
]
∴ Top row of
=,
-
[Ans. D] Since matrix is triangular, the Eigenvalues are the diagonal elements themselves namely = 3, 2 & 1. Corresponding to Eigenvalue = 2, let us find the Eigenvector [A - ] x̂ = 0 x [ ][x ] [ ] x Putting in above equation we get, x [ ][x ] [ ] x Which gives the equations, 5x x x =0 . . . . . (i) x =0 . . . . . (ii) 3x = 0 . . . . . (iii) Since eqa (ii) and (iii) are same we have 5x x x =0 . . . . . (i) x =0 . . . . . (ii) Putting x = k, we get x = 0, x = k and 5x k =0
[Ans. *] Range 48.9 to 49.1 Real symmetric matrices are diagnosable Let the matrix be x 0 1 s tr e is x So determinant is product of diagonal entries So | | x x ∴ M ximum v lue of etermin nt x x ∴| |
R= [
Mathematics
, of tor( )| |
x = k | |=|
|
∴ Eigenvectorss are of the form x k x [ ] * k + x
= 1(2 + 3) – 0(4 + 2) – 1 (6 – 2) = 1 Since we need only the top row of , we need to find only first column of (R) which after transpose will become first row adj(A). cof. (1, 1) = + |
|=2+3=5
cof. (2, 1) =
|= 3
|
cof. (2, 1) = + |
i.e. x x x = k : k : 0 = :1:0 =2:5:0 x x ∴ [ ]=[ ] is an Eigenvector of matrix p. x
|= +1 3.
∴ cof. (A) = [
[Ans. A] Rank [P|Q] = Rank [P] is necessary for existence of at least one solution to x q.
[Ans. A] We need to find orthogonal vectors, verify the options. Option (A) is orthogonal vectors (
)(
[Ans. B] The vector ( ) is linearly dependent upon the solution obtained in - and , Q. No. 4 namely , We can easily verify the linearly dependence as |
6.
7.
i
[Ans. B] xy xx | yx
xy xx x n xy yx xy x xy y y | |y x y | (x y) x y = Positive when x and y are linearly independent.
Option (B), (C), (D) are not orthogonal 5.
) i
8.
)
Mathematics
9.
[Ans. A] A=0
1
|A – | = 0 |
|
[Ans. B] hen n n m trix xx x x x x x x x x x x x x * + x x x x x x Take x common from 1st row, x common from 2nd row …… x common from nth row. It h s r nk ‘ ’
| =0 A will satisfy this equation according to Cayley Hamilton theorem i.e. I=0 Multiplying by on oth si es we get I=0 I =0 10.
[Ans. A] If rank of (5 6 ) matrix is 4,then surely it must have exactly 4 linearly independent rows as well as 4 linearly independent columns.
= A is correct =A[( ) -A = A[( ) Put =P Then A [ ] = A. = A Choice (C) = is also correct since =( ) = I 14.
os
x in )
|| x⃗ || = √x
(x in
x
x
→
[Ans. C] Trace = Sum of Principle diagonal elements.
16.
[Ans. D] On writing the equation in the form of AX =B
+
, *
+
nk ( ) nk( ) Number of variables = 4 Since, Rank (A) = Rank(C) < Number of variables Hence, system of equations are consistent and there is multiple non-trivial solution exists. 17.
[Ans. B] Characteristic equation | |
I|
|
(1 ) ( )( ) Eigenve tors orrespon ing to ( I) x [ ] [x ] [ ] x 2x x x x At x x x x x x At x ,x
is
Eigenvectors = c[ ]{Here c is a constant}
os ) 18.
[Ans. D] , - ,L-, - ⟹ Options D is correct
19.
[Ans. D] x x … (i) } (i) n (ii) re s me x x … (ii) ∴x x So it has multiple solutions.
|| x⃗ || = || x̅|| for any vector x̅ 15.
* +
Argument matrix C =*
[Ans. B] Let orthogonal matrix be os in P=0 1 in os By Property of orthogonal matrix A I x os x in So, x⃗ = [ ] x in x os || x⃗ || = √(x
x x + *x + x
*
[Ans. D] If characteristic equation is =0 Then by Cayley – Hamilton theorem, I=0 = Multiplying by on both sides, = I = ( I) [Ans. D] Choice (A) Since
i.e., (1 ) (2 ) 2 Thus the Eigenvalue are 1, 2. If x, y, be the component of Eigenvectors corresponding to the Eigenv lues we have x [A- I- 0 1 0y1=0
1
0
Mathematics
For =1, we get the Eigenvector as 0 Hence, the answer will be ,
21.
22.
23.
IN 1.
1
0
[Ans. B] AX=0 and (A) = 2 n=3 No. of linearly independent solutions = n r = 3 =1
3.
[Ans. C] There are 3 non-zero rows and hence rank (A) = 3
4.
[Ans. C] Rank (A) = 3 (This is Co-efficient matrix) Rank (A:b) =4(This is Augmented matrix) s r nk( ) r nk ( ) olution oes not exist.
5.
[Ans. C] We know Hen e from the given problem, Eigenvalue & Eigenvector is known.
1
[Ans. B] Since there are 2 equations and 3 variables (unknowns), there will be infinitely many solutions. If if then x y z x y z x z y For any x and z, there will be a value of y. ∴ Infinitely many solutions [Ans. A] For all real symmetric matrices, the Eigenvalues are real (property), they may be either ve or ve and also may be same. The sum of Eigenvalues necessarily not be zero. [Ans. C] p q 0 1 r s ( pplying → p q →r s element ry tr nsform tions) p q pr qs [ ] pr qs r s ∴ hey h ve s me r nk N
Probability and Distribution ME - 2005 1. A single die is thrown twice. What is the probability that the sum is neither 8 nor 9? (A) ⁄ (C) ⁄ ⁄ (B) ⁄ (D)
ME - 2008 6. A coin is tossed 4 times. What is the probability of getting heads exactly 3 times? (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄
2.
ME - 2009 7. The standard deviation of a uniformly distributed random variable between 0 and 1 is (A) (C) ⁄√ √ (B) (D) √ √
A lot has 10% defective items. Ten items are chosen randomly from this lot. The probability that exactly 2 of the chosen items are defective is (A) 0.0036 (C) 0.2234 (B) 0.1937 (D) 0.3874
ME - 2006 3. Consider a continuous random variable with probability density function f(t) = 1 + t for 1 t 0 = 1 t for 0 t 1 The standard deviation of the random variable is: (C) ⁄ (A) ⁄√ (D) ⁄ (B) ⁄√ 4.
A box contains 20 defective items and 80 non-defective items. If two items are selected at random without replacement, what will be the probability that both items are defective? ⁄ (A) ⁄ (C) ⁄ ⁄ (B) (D)
ME - 2007 5. Let X and Y be two independent random variables. Which one of the relations between expectation (E), variance (Var) and covariance (Cov) given below is FALSE? (A) E (XY) = E (X) E (Y) (B) Cov (X, Y) = 0 (C) Var (X + Y) = Var (X) + Var (Y) (D)
(X Y )
( (X)) ( (Y))
8.
If three coins are tossed simultaneously, the probability of getting at least one head is (A) 1/8 (C) 1/2 (B) 3/8 (D) 7/8
ME - 2010 9. A box contains 2 washers, 3 nuts and 4 bolts. Items are drawn from the box at random one at a time without replacement. The probability of drawing 2 washers first followed by 3 nuts and subsequently the 4 bolts is (A) 2/315 (C) 1/1260 (B) 1/630 (D) 1/2520 ME - 2011 10. An unbiased coin is tossed five times. The outcome of each toss is either a head or a tail. The probability of getting at least one head is________ ⁄ (A) ⁄ (C) ⁄ ⁄ (B) (D) ME - 2012 11. A box contains 4 red balls and 6 black balls. Three balls are selected randomly from the box one after another, without 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
ME - 2013 12. Let X be a normal random variable with mean 1 and variance 4. The probability (X ) is (A) 0.5 (B) Greater than zero and less than 0.5 (C) Greater than 0.5 and less than 1.0 (D) 1.0 13.
The probability that a student knows the correct answer to a multiple choice
the probability of obtaining red colour on top face of the dice at least twice is _______ 17.
A group consists of equal number of men and women. Of this group 20% of the men and 50% of the women are unemployed. If a person is selected at random from this group, the probability of the selected person being employed is _______
18.
A machine produces 0, 1 or 2 defective pieces in a day with associated probability of 1/6, 2/3 and 1/6, respectively. The mean value and the variance of the number of defective pieces produced by the machine in a day, respectively, are (A) 1 and 1/3 (C) 1 and 4/3 (B) 1/3 and 1 (D) 1/3 and 4/3
19.
A nationalized bank has found that the daily balance available in its savings accounts follows a normal distribution with a mean of Rs. 500 and a standard deviation of Rs. 50. The percentage of savings account holders, who maintain an average daily balance more than Rs. 500 is _______
20.
The number of accidents occurring in a plant in a month follows Poisson distribution with mean as 5.2. The probability of occurrence of less than 2 accidents in the plant during a randomly selected month is (A) 0.029 (C) 0.039 (B) 0.034 (D) 0.044
question is . If the student dose not know the answer, then the student guesses the answer. The probability of the guessed answer being correct is . Given that the student has answered the questions correctly, the conditional probability that the student knows the correct answer is (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄ ME - 2014 14. In the following table x is a discrete random variable and P(x) is the probability density. The standard deviation of x is x 1 2 3 P(x) 0.3 0.6 0.1 (A) 0.18 (C) 0.54 (B) 0.3 (D) 0.6 15.
16.
Box contains 25 parts of which 10 are defective. Two parts are being drawn simultaneously in a random manner from the box. The probability of both the parts being good is ( )
( )
( )
( )
Consider an unbiased cubic dice with opposite faces coloured identically and each face coloured red, blue or green such that each colour appears only two times on the dice. If the dice is thrown thrice,
Mathematics
CE - 2005 1. Which one of the following statements is NOT true? (A) The measure of skewness is dependent upon the amount of dispersion
(B) In a symmetric distribution the value of mean, mode and median are the same (C) In a positively skewed distribution mean > median > mode (D) In a negatively skewed distribution mode > mean > median CE - 2006 2. A class of first years B. Tech students is composed of four batches A, B, C and D each consisting of 30 students. It is found that the sessional marks of students in Engineering Drawing in batch C have a mean of 6.6 and standard deviation of 2.3. The mean and standard deviation of the marks for the entire class are 5.5 and 4.2 respectively. It is decided by the course instruction to normalize the marks of the students of all batches to have the same mean and standard deviation as that of the entire class. Due to this, the marks of a student in batch C are changed from 8.5 to (A) 6.0 (C) 8.0 (B) 7.0 (D) 9.0 3.
There are 25 calculators in a box. Two of them are defective. Suppose 5 calculators are randomly picked for inspection (i.e. each has the same chance of being selected). What is the probability that only one of the defective calculators will be included in the inspection? (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄
CE - 2007 4. If the standard deviation of the spot speed of vehicles in a highway is 8.8 kmph and the mean speed of the vehicles is 33 kmph, the coefficient of variation in speed is (A) 0.1517 (C) 0.2666 (B) 0.1867 (D) 0.3646
Mathematics
CE - 2008 5. If probability density function of a random variable x is x for x nd f(x) { for ny other v lue of x Then, the percentage probability P.
x
/ is
(A) 0.247 (B) 2.47 6.
(C) 24.7 (D) 247
A person on a trip has a choice between private car and public transport. The probability of using a private car is 0.45. While using the public transport, further choices available are bus and metro out of which the probability of commuting by a bus is 0.55. In such a situation, the probability, (rounded upto two decimals) of using a car, bus and metro, respectively would be (A) 0.45, 0.30 and 0.25 (B) 0.45, 0.25 and 0.30 (C) 0.45, 0.55 and 0.00 (D) 0.45, 0.35 and 0.20
CE - 2009 7. The standard normal probability function can be approximated as (x )
|x | ) exp( Where x = standard normal deviate. If mean and standard deviation of annual precipitation are 102 cm and 27 cm respectively, the probability that the annual precipitation will be between 90 cm and 102 cm is (A) 66.7% (C) 33.3% (B) 50.0% (D) 16.7% CE - 2010 8. Two coins are simultaneously tossed. The probability of two heads simultaneously appearing is (A) 1/8 (C) 1/4 (B) 1/6 (D) 1/2
CE - 2011 9. There are two containers with one containing 4 red and 3 green balls and the other containing 3 blue and 4 green balls. One ball is drawn at random from each container. The probability that one of the balls is red and the other is blue will be (A) 1/7 (C) 12/49 (B) 9/49 (D) 3/7 CE - 2012 10. The annual precipitation data of a city is normally distributed with mean and standard deviation as 1000mm and 200 mm, respectively. The probability that the annual precipitation will be more than 1200 mm is (A) < 50 % (C) 75 % (B) 50 % (D) 100 % 11.
14.
A traffic office imposes on an average 5 number of penalties daily on traffic violators. Assume that the number of penalties on different days is independent and follows a poisson distribution. The probability that there will be less than 4 penalties in a day is ____.
15.
A fair (unbiased) coin was tossed four times in succession and resulted in the following outcomes: (i) Head (iii) Head (ii) Head (iv) Head The prob bility of obt ining ‘T il’ when the coin is tossed again is (A) 0 (C) ⁄ (B) ⁄ (D) ⁄
16.
An observer counts 240 veh/h at a specific highway location. Assume that the vehicle arrival at the location is Poisson distributed, the probability of having one vehicle arriving over a 30-second time interval is ____________
In an experiment, positive and negative values are equally likely to occur. The probability of obtaining at most one negative value in five trials is (A)
(C)
(B)
(D)
CE - 2013 12. Find the value of such that the function f(x) is a valid probability density function ____________________ (x )( f(x) x) for x otherwise CE - 2014 13. The probability density function of evaporation E on any day during a year in a watershed is given by f( )
{
mm d y
Mathematics
CS - 2005 1. Box P has 2 red balls and 3 blue balls and box Q has 3 red balls and 1 blue ball. A ball is selected as follows: (i) select a box (ii) choose a ball from the selected box such that each ball in the box is equally likely to be chosen. The probabilities of selecting boxes P and Q are 1/3 and 2/3 respectively. Given that a ball selected in the above process is red, the probability that it comes from box P is (A) 4/19 (C) 2/9 (B) 5/19 (D) 19/30 2.
Let f(x) be the continuous probability density function of a random variable X. The probability that a X b , is (A) f(b a) (C) ∫ f(x)dx
otherwise The probability that E lies in between 2 and 4 mm/day in a day in the watershed is (in decimal) ______
CS - 2006 3. For each element in a set of size 2n, an unbiased coin is tossed. The 2n coin tosses are independent. An element is chosen if the corresponding coin toss were head. The probability that exactly n elements are chosen is (A) ( n ⁄ ) (C) ( ⁄ n ) (D) ⁄ (B) ( n ⁄ ) CS - 2007 Linked Data for Q4 & Q5 are given below. Solve the problems and choose the correct answers. Suppose that robot is placed on the Cartesian plane. At each step it is easy to move either one unit up or one unit right, i.e if it is at (i,j) then it can move to either (i+1,j) or (i,j+1) 4. How many distinct paths are there for the robot to reach the point (10,10) starting from the initial position (0,0)? (C) 210 (A) 20 (D) None of these (B) 2 5.
Suppose that the robot is not allowed to traverse the line segment from (4,4) to (5,4). With this constraint, how many distinct paths are there for the robot to reach (10,10) starting from (0,0)? (A) 29 (B) 219 (C) . / . (D) .
6.
/
/ . / .
/
Suppose we uniformly and randomly select a permutation from the 20! ermut tions of ………… Wh t is the probability that 2 appears at an earlier position than any other even number in the selected permutation? (A) ⁄ (C) ⁄ (B) ⁄ (D) none of these
Mathematics
CS - 2008 7. Let X be a random variable following normal distribution with mean +1 and variance 4. Let Y be another normal variable with mean of 1 and variance unknown If (X ) (Y≥ ) the standard deviation of Y is (A) 3 (C) √ (B) 2 (D) 1 8.
Aishwarya studies either computer science or mathematics every day. If she studies computer science on a day, then the probability that she studies mathematics the next day is 0.6. If she studies mathematics on a day, then the probability that she studies computer science the next day is 0.4. Given that Aishwarya studies computer science on Monday, what is the probability that she studies computer science on Wednesday? (A) 0.24 (C) 0.4 (B) 0.36 (D) 0.6
CS - 2009 9. An unbalanced dice (with 6 faces, numbered from 1 to 6) is thrown. The probability that the face value is odd is 90% of the probability that the face value is even. The probability of getting any even numbered face is the same. If the probability that the face is even given that it is greater than 3 is 0.75, which one of the following options is closest to the probability that the face value exceeds 3? (A) 0.453 (C) 0.485 (B) 0.468 (D) 0.492 CS - 2010 10. Consider a company that assembles computers. The probability of a faulty assembly of any computer is p. The company therefore subjects each computer to a testing process. This 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
What is the probability that a divisor of is a multiple of ? (A) 1/625 (C) 12/625 (B) 4/625 (D) 16/625 If the difference between the expectation of the square if a random variable ( ,x -) and the square if the exopectation of the random variable ( ,x-) is denoted by R, then (A) R = 0 (C) R≥ (B) R< 0 (D) R > 0
CS - 2011 13. A deck of 5 cards (each carrying a distinct number from 1 to 5) is shuffled thoroughly. Two cards are then removed one at a time from the deck. What is the probability that the two cards are selected with the number on the first card being one higher than the number on the second card? (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄ 14.
Consider a finite sequence of random values X = [x1, x2 … xn].Let be the me n nd σx be the standard deviation of X. Let another finite sequence Y of equal length be derived from this as yi, a*xi+b, where a and b are positive constants. Let μy be the me n nd σy be the standard deviation of this sequence. Which one of the following statements is INCORRECT? (A) Index position of mode of X in X is the same as the index position of mode of Y in Y. (B) Index position of median of X in X is the same as the index position of median of Y in Y. (C) μy μx + b (D) σy σx + b
15.
Mathematics
If two fair coins flipped and at least one of the outcomes is known to be a head, what is the probability that both outcomes are heads? (A) 1/3 (C) 1/4 (B) 1/2 (D) 2/3
CS - 2012 16. Suppose a fair six – sided die is rolled once. If the value on the die is 1,2, or 3 the die is rolled a second time. What is the probability that the some total of value that turn up is at least 6? (A) 10/21 (C) 2/3 (B) 5/12 (D) 1/6 17.
Consider a random variable X that takes values +1 and 1 with probability 0.5 each. The values of the cumulative distribution function F(x) at x = and +1 are (A) 0 and 0.5 (C) 0.5 and 1 (B) 0 and 1 (D) 0.25 and 0.75
CS - 2013 18. Suppose p is the number of cars per minute passing through a certain road junction between 5 PM and 6 PM, and p has a Poisson distribution with mean 3. What is the probability of observing fewer than 3 cars during any given minute in this interval? ⁄ e (A) ⁄ e (C) ⁄ e (B) ⁄ e (D) CS - 2014 19. Suppose you break a stick of unit length at a point chosen uniformly at random. Then the expected length of the shorter stick is ________ . 20.
th
Four fair six – sided dice are rolled. The probability that the sum of the results being 22 is x/1296. The value of x is ____________
The security system at an IT office is composed of 10 computers of which exactly four are working. To check whether the system is functional, the officials inspect four of the computers picked at random (without replacement). The system is deemed functional if at least three of the four computers inspected are working. Let the probability that the system is deemed functional be denoted by p. Then 100p = _____________.
22.
Each of the nine words in the sentence “The quick brown fox jumps over the l zy dog” is written on sep r te piece of paper. These nine pieces of paper are kept in a box. One of the pieces is drawn at random from the box. The expected length of the word drawn is _____________. (The answer should be rounded to one decimal place.)
23.
The probability that a given positive integer lying between 1 and 100 (both inclusive) is NOT divisible by 2, 3 or 5 is __________.
24.
Let S be a sample space and two mutually exclusive events A and B be such that ∪ S If ( ) denotes the prob bility of the event, the maximum value of P(A) P(B) is _______
ECE - 2006 3. A probability density function is of the ). form (x) e || x ( The value of K is (A) 0.5 (C) 0.5a (B) 1 (D) A 4.
Three Companies X, Y and Z supply computers to a university. The percentage of computers supplied by them and the probability of those being defective are tabulated below Company % of Probability computers of being supplied defective X 60% 0.01 Y 30% 0.02 Z 10% 0.03 Given that a computer is defective, the probability that it was supplied by Y is (A) 0.1 (C) 0.3 (B) 0.2 (D) 0.4
ECE - 2007 5. If E denotes expectation, the variance of a random variable X is given by (A) E[X2] E2[X] (C) E[X2] (B) E[X2] + E2[X] (D) E2[X] 6.
An examination consists of two papers, Paper1 and Paper2. The probability of failing in Paper1 is 0.3 and that in Paper2 is 0.2.Given that a student has failed in Paper2, the probability of failing in paper1 is 0.6. The probability of a student failing in both the papers is (A) 0.5 (C) 0.12 (B) 0.18 (D) 0.06
ECE - 2005 1. A fair dice is rolled twice. The probability that an odd number will follow an even number is
ECE - 2008 7. The probability density function (PDF) of a random variable X is as shown below.
(x) exp( |x|) exp( |x|) is the probability density function for the real random variable X, over the entire x axis. M and N are both positive real numbers. The equation relating M and N is
8.
PDF PDF
1
Mathematics
(A) 1
0
(B) 2M
x 11
The -1 corresponding cumulative 0 distribution function (CDF) has the form
(A)
1
(C) M + N = 1 (D) M + N = 3 ECE - 2009 9. Consider two independent random variables X and Y with identical distributions. The variables X and Y take value 0, 1 and 2 with probabilities
CDF
1
N=1
x
and respectively. What is the 1
1
0
(B)
x
conditional probability (x y ) |x y| (A) 0 (C) ⁄ ⁄ (B) (D) 1
CD F C
1
D F
1
10. 0
1 -1
(C)
x
1
2
(B)
11. 1
0
x
1
1 1 1
0 0 1
1 2
(C) 2
0
(D)
10
1 2
(A)
CDF 1
0
1
A fair coin is tossed 10 times. What is the probability that ONLY the first two tosses will yield heads?
CDF
1 1
x
th
10
10
1 C2 2
(D)
10
1 C2 2
A discrete random variable X takes values from 1 to 5 with probabilities as shown in the table. A student calculates the mean of X as 3.5 and her teacher calculates the variance of X as 1.5. Which of the following statements is true? k P(X=k) 1 0.1 2 0.2 3 0.4 4 0.2 5 0.1
(A) Both the student and the teacher are right (B) Both the student and the teacher are wrong (C) The student is wrong but the teacher is right (D) The student is right but the teacher is wrong ECE - 2010 12. A fair coin is tossed independently four times. The prob bility of the event “the number of times heads show up is more th n the number of times t ils show up” is (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄ ECE - 2011 13. A fair dice is tossed two times. The probability that the second toss results in a value that is higher than the first toss is (A) 2/36 (C) 5/12 (B) 2/6 (D) 1/2 ECE\EE\IN - 2012 14. A fair coin is tossed till a head appears for the first time probability that the number of required tosses is odd , is (A) 1/3 (C) 2/3 (B) 1/2 (D) 3/4 ECE - 2013 15. Let U and V be two independent zero mean Gaussian random variables of variances ⁄ and ⁄ respectively. The probability ( V ≥ U) is (A) 4/9 (C) 2/3 (B) 1/2 (D) 5/9 16.
Consider two identically distributed zeromean random variables U and V . Let the cumulative distribution functions of U and 2V be F(x) and G(x) respectively. Then, for all values of x (x)) (A) ( (x) (B) ( (x)
(C) ( (x) (D) ( (x)
Mathematics
(x)) x (x)) x ≥
ECE - 2014 17. In a housing society, half of the families have a single child per family, while the remaining half have two children per family. The probability that a child picked at random, has a sibling is _____ 18.
Let X X nd X , be independent and identically distributed random variables with the uniform distribution on [0, 1]. The probability P{X is the largest} is _____
19.
Let X be a random variable which is uniformly chosen from the set of positive odd numbers less than 100. The expectation, E[X], is __________.
20.
An unbiased coin is tossed an infinite number of times. The probability that the fourth head appears at the tenth toss is (A) 0.067 (C) 0.082 (B) 0.073 (D) 0.091
21.
A fair coin is tossed repeatedly till both head and tail appear at least once. The average number of tosses required is _______.
22.
Let X X and X be independent and identically distributed random variables with the uniform distribution on [0, 1]. The probability P{X X X } is ______.
23.
Let X be a zero mean unit variance Gaussian random variable. ,|x|- is equal to __________
24.
Parcels from sender S to receiver R pass sequentially through two post-offices. Each post-office has a probability
of
losing an incoming parcel, independently of all other parcels. Given that a parcel is lost, the probability that it was lost by the second post-office is ____________.
EE - 2005 1. If P and Q are two random events, then the following is TRUE (A) Independence of P and Q implies that probability (P Q) = 0 (B) Probability (P ∪ Q)≥ Probability (P) +Probability (Q) (C) If P and Q are mutually exclusive, then they must be independent (D) Probability (P Q) Probability (P) 2.
A fair coin is tossed three times in succession. If the first toss produces a head, then the probability of getting exactly two heads in three tosses is (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄
EE - 2006 3. Two f ir dice re rolled nd the sum “ r ” of the numbers turned up is considered (A) Pr (r > 6) = (B) Pr (r/3 is an integer) = (C) Pr (r = 8|r/4 is an integer) = (D) Pr (r = 6|r/5 is an integer) = EE - 2007 4. A loaded dice has following probability distribution of occurrences Dice Value Probability ⁄ 1 2
⁄
3
⁄
4
⁄
5
⁄
⁄ 6 If three identical dice as the above are thrown, the probability of occurrence of values, 1, 5 and 6 on the three dice is (A) same as that of occurrence of 3, 4, 5 (B) same as that of occurrence of 1, 2, 5 (C) 1/128 (D) 5/8
Mathematics
EE - 2008 5. X is a uniformly distributed random variable that takes values between 0 and 1. The value of E{X } will be (A) 0 (C) 1/4 (B) 1/8 (D) 1/2 EE - 2009 6. Assume for simplicity that N people, all born in April (a month of 30 days), are collected in a room. Consider the event of atleast two people in the room being born on the same date of the month, even if in different years, e.g. 1980 and 1985. What is the smallest N so that the probability of this event exceeds 0.5? (A) 20 (C) 15 (B) 7 (D) 16 EE - 2010 7. A box contains 4 white balls and 3 red balls. In succession, two balls are randomly selected and removed from the box. Given that the first removed ball is white, the probability that the second removed ball is red is (A) 1/3 (C) 1/2 (B) 3/7 (D) 4/7 ECE\EE\IN - 2012 8. Two independent random variables X and Y are uniformly distributed in the interval , -. The probability that max , - is less than 1/2 is (A) 3/4 (C) 1/4 (B) 9/16 (D) 2/3 EE - 2013 9. A continuous random variable x has a probability density function + is f(x) e x . Then *x (A) 0.368 (C) 0.632 (B) 0.5 (D) 1.0
EE - 2014 10. A fair coin is tossed n times. The probability that the difference between the number of heads and tails is (n – 3) is (C) (A) (B) (D) 11.
12.
13.
14.
IN - 2005 1. The probability that there are 53 Sundays in a randomly chosen leap year is (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄ 2.
A mass of 10 kg is measured with an instrument and the readings are normally distributed with respect to the mean of 10 kg. Given that
Consider a dice with the property that the probability of a face with n dots showing up is proportional to n. The probability of the face with three dots showing up is _______________ Let x be a random variable with probability density function for |x| f(x) { |x| for otherwise The probability P(0.5 < x < 5) is_________ Lifetime of an electric bulb is a random variable with density f(x) kx , where x is measured in years. If the minimum and maximum lifetimes of bulb are 1 and 2 years respectively, then the value of k is__________ The mean thickness and variance of silicon steel laminations are 0.2 mm and 0.02 respectively. The varnish insulation is applied on both the sides of the laminations. The mean thickness of one side insulation and its variance are 0.1 mm and 0.01 respectively. If the transformer core is made using 100 such varnish coated laminations, the mean thickness and variance of the core respectively are (A) 30 mm and 0.22 (B) 30 mm and 2.44 (C) 40 mm and 2.44 (D) 40 mm and 0.24
Mathematics
exp .
∫
√
/ d =0.6
and that 60per cent of the readings are found to be within 0.05 kg from the mean, the standard deviation of the data is (A) 0.02 (C) 0.06 (B) 0.04 (D) 0.08 3.
The measurements of a source voltage are 5.9V, 5.7V and 6.1V. The sample standard deviation of the readings is (A) 0.013 (C) 0.115 (B) 0.04 (D) 0.2
IN - 2006 4. You have gone to a cyber-cafe with a friend. You found that the cyber-café has only three terminals. All terminals are unoccupied. You and your friend have to make a random choice of selecting a terminal. What is the probability that both of you will NOT select the same terminal? (A) ⁄ (C) ⁄ (B) ⁄ (D) 1 5.
Probability density function p(x) of a random variable x is as shown below. The value of is p(x) α
Two dices are rolled simultaneously. The probability that the sum of digits on the top surface of the two dices is even is (A) 0.5 (C) 0.167 (B) 0.25 (D) 0.125
measurements, it can be expected that the number of measurement more than 10.15 mm will be (A) 230 (C) 15 (B) 115 (D) 2
IN - 2007 7. Assume that the duration in minutes of a telephone conversation follows the
IN - 2011 12. The box 1 contains chips numbered 3, 6, 9, 12 and 15. The box 2 contains chips numbered 6, 11, 16, 21 and 26. Two chips, one from each box, are drawn at random. The numbers written on these chips are multiplied. The probability for the product to be an even number is (A) ⁄ (C) ⁄ ⁄ (B) ⁄ (D)
exponential distribution f(x) =
e ,x≥
The probability that the conversation will exceed five minutes is (A) e (C) (B) e (D) e IN - 2008 8. Consider a Gaussian distributed random variable with zero mean and standard deviation . The value of its cummulative distribution function at the origin will be (A) 0 (C) 1 (B) 0.5 (D) σ 9.
A random variable is uniformly distributed over the interval 2 to 10. Its variance will be ⁄ ⁄ (A) (C) (B) 6 (D) 36
IN - 2013 13. A continuous random variable X has probability density f(x) = . Then P(X > 1) is (A) 0.368 (C) 0.632 (B) 0.5 (D) 1.0 IN - 2014 14. Given that x is a random variable in the r nge , - with prob bility density function
the value of the constant k is
___________________ IN - 2009 10. A screening test is carried out to detect a certain disease. It is found that 12% of the positive reports and 15% of the negative reports are incorrect. Assuming that the probability of a person getting a positive report is 0.01, the probability that a person tested gets an incorrect report is (A) 0.0027 (C) 0.1497 (B) 0.0173 (D) 0.2100
15.
IN - 2010 11. The diameters of 10000 ball bearings were measured. The mean diameter and standard deviation were found to be 10 mm and 0.05mm respectively. Assuming Gaussian distribution of
The figure shows the schematic of production process with machines A,B and C. An input job needs to be preprocessed either by A or by B before it is fed to C, from which the final finished product comes out. The probabilities of failure of the machines are given as:
Assuming independence of failures of the machines, the probability that a given job is successfully processed (up to third decimal place)is ______________
4. [Ans. D] The number of ways coming 8 and 9 are (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
[Ans. D]
5.
[Ans. D] X and Y are independent ∴ ( ) ( ) ( ) re true Only (D) is odd one
6.
[Ans. A] Number of favourable cases are given by HHHT HHTH HTHH THHH Total number of cases = 2C1 2C1 2C1 2C1 =16
So probability of not coming these
2.
[Ans. B] Probability of defective item = Probability of not defective item = 1 0.1 = 0.9 So, Probability that exactly 2 of the chosen items are defective = ( ) ( )
3.
[Ans. B]
∴ Probability = 7.
[Ans. A] A uniform function
Mean (t)̅ = ∫ t f(t) dt ∫ t( t 6
t)dt t
t 6
7
[
]
∫ t(
[
t
t)dt
t)dt
=∫ (t =0
t )dt 1
0
7
density
Density function
1 f(x) b a 0
∫ t (
t)dt
a,x b a x,x b
Mean E(x)=
t)dt
b
x(F(x)) x a
ab 2
Variance = F(x)2 f(x)
2
1
2
b x F(x) xF(x) x a x a b
= Standard deviation = √v ri nce =
and
0,x a x a f(x) f x dx , axb 0 b a xb 0,
]
∫ t (
distribution
x
Variance = ∫ t f(t)dt =∫ t (
( oth defective) S mple sp ce
( oth defective)
2
Put the value of F(x), we get √
2
1 1 b dx x. dx Variance x ba x a x a b a b
No. of employed men = 80% of men = 80 No. of employed women = 50% of women = 50 Probability if the selected one person being employed = probability of one employed women +probability of one employed man
⏟
⏟
e does not know correct nswer so he guesses
( ) ( ⁄ ) ) ⁄ ( ) ⁄
[Ans. D] x 1 2 P(x) 0.3 0.6 (x) (x) x
18.
V(x) x (
σ
(x )
[Ans. A]
3 0.1 So from figure Mean value = 1 V ri nce : μ me n x defective pieces (x μ) σ ) n(n ( ) ( ) ( ) ( )
(x) x (x) σ
Mathematics
, (x)-
(x) ( x (x)) ) ( )
√ ( )
15.
[Ans. A] 19.
16.
[Ans. *](Range 49 to 51)
[Ans. *] Range 0.25 to 0.27 p orm l distribution
q
Given that μ σ x μ x z σ ere x μ , s x gre ter th n z ) ence prob bility (z
Using Binomial distribution (x ≥ )
17.
( ) ( )
( ) ( )
-
∫ e dz σ√ ∴ of s ving ccount holder
[Ans. *] Range 0.64 to 0.66 Let number of men = 100 Number of women = 100 th
[Ans D] A, B, C are true (D) is not true. Since in a negatively skewed distribution mode > median > mean [Ans. D] Let the mean and standard deviation of the students of batch C be μ and σ respectively and the mean and standard deviation of entire class of first year students be μ and σ respectively Now given, μ σ and μ σ In order to normalise batch C to entire class, the normalize score must be equated since Z = Z =
=
Now Z =
p( defective in c lcul tors)
4.
[Ans. C] σ μ
5.
[Ans. B] Given f(x) = x for x = 0 else where (
)
∫ f(x)dx
∫ x dx
=0 1 The probability expressed in percentage P= = 2.469% = 2.47% 6.
[Ans. A] Given P(private car) = 0.45 P(bus 1 public transport) = 0.55 Since a person has a choice between private car and public transport P(public transport) = 1 – P(private car) = 1 – 0.45 =0.55 P(bus) = P(bus public transport) (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
=
Equation these two and solving, we get = x = 8.969 ≃ 9.0 3.
x
[Ans. B] Since population is finite, hypergeometric distribution is applicable
m ke ex ctly ‘ ’ moves nd ‘U’ moves in any order. Similarly to reach (10, 10) from (0,0) the robot h s to m ke ‘ ’ moves nd ‘U’ moves in any order. The number of ways this can be done is same as number of permutations of a word consisting of 10 ‘ ’ s nd ’U’s Applying formula of permutation with limited repetitions we get the answer as
/
= 2.e = 0.2707 CS 1.
[Ans. A] P: Event of selecting Box P, Q: Event of selecting Box P P(P)=1/3, P(Q)=2/3 P(R/P)=2/5, P(R/Q)=3/4
[Ans. D] The robot can reach (4,4) from (0,0) in 8C ways as argued in previous problem. 4 Now after reaching (4,4) robot is not allowed to go to (5,4) Let us count how many paths are there from (0,0) to (10,10) if robot goes from (4,4) to (5,4) and then we can subtract this from total number of ways to get the answer. Now there are 8C4 ways for robot to reach (4,4) from (0,0) and then robot takes the ‘U’ move from ( ) to ( ) ow from (5,4) to (10,10) the robot has to make 5 ‘U’ moves nd ‘ ’ moves in ny order which can be done in 11! ways = 11C5 ways Therefore, the number of ways robot can move from (0,0) (10,10) via (4,4) – (5,4) move is
[Ans. C] If f (x) is the continuous probability density function of a random variable X then, ( x b) P( x b) b
= f x dx
a
3.
4.
[Ans. A] The probability that exactly n elements are chosen =The probability of getting n heads out of 2n tosses =
(
) . /
= =
(
) (
Mathematics
(Binomial formula) )
8C 4
[Ans. A] Consider the following diagram (3,3)
11C 5
8 11 4 5
=
No. of ways robot can move from (0,0) to (10,10) without using (4,4) to (5,4) move is
(0,0) 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
[Ans. D] umber of permut tions with ‘ ’ in the first position =19! Number of permutations with ‘ ’ in the second position = 10 18! (Fill the first space with any of the 10 odd numbers and the 18 spaces after the 2 with 18 of the remaining numbers in 18! ways) umber of permut tions with ‘ ’ in rd position =10 9 17! (Fill the first 2 place with 2 of the 10 odd numbers and then the remaining 17 places with remaining 17 numbers) nd so on until ‘ ’ is in th place. After that it is not possible to satisfy the given condition, since there are only 10 odd numbers v il ble to fill before the ‘ ’ So the desired number of permutations which satisfies the given condition is
8.
[Ans. C] Let C denote computes science study and M denotes maths study. P(C on Monday and C on Wednesday) = P(C on Monday, M on Tuesday and C on Wednesday) + P(C on Monday, C on Tuesday and C on Wednesday) =1 0.6 0.4+ 1 0.4 0.4 = 0.24 + 0.16 = 0.40
9.
[Ans. B] It is given that P (odd) = 0.9 P (even) Now since 𝜮P(x) = 1 ∴ P (odd) + P (even) = 1 0.9 P (even) + P (even) = 1 P(even) =
…
∴ P(2) = P(4) = P(6) = P(even) )
=
Which are clearly not choices (A), (B) or (C) 7.
/ = P (z ≥
.z
/ = P (z ≥
(z
) = P (z ≥
(
)
)
10. _____(i)
)
(
)
(
)
P(f ce )
) (
) (
(0.5263)
= 0.1754 It is given that P(even | face > 3) = 0.75
[Ans. A] Given μ = 1, σ = 4 σ =2 and μ = 1, σ is unknown Given, P(X ) = P (Y ≥ 2 ) Converting into standard normal variates, .z
= 0.5263
Now, it is given that P(any even face) is same i.e. P(2) = P(4) = P(6) Now since, P(even) = P(2) or P(4) or P(6) = P(2) + P(4) + P(6)
… Now the probability of this happening is given by = (
Mathematics
= 0.75
= 0.75 ( )
)
( )
=1
decl red f ulty
f ulty
p
q p
σ =3
not f ulty
decl red not f ulty decl red f ulty
q
q
decl red not f ulty
From above tree (decl red f ulty) th
=0.468
[Ans. A] The tree diagram of probabilities is shown below q
Now since we know that in standard normal distribution P (z ) = P (z ≥ 1) _____(ii) Comparing (i) and (ii) we can say that
[Ans. A] If b c … Then, no. of divisors of (x )(y )(z )… iven ∴ o of ivisors of ( )( ( )( )
(
(
which are multiples
13.
14.
15.
[Ans. C] (x ) , (x)V(x) Where V(x) is the variance of x, Since variance is σ and hence never negative, ≥
( t le st one he d)
TT )
So required prob bility
)
∴ equired rob bility 12.
)
( ∪ )
16. No. of divisors of of o of divisors of ( )( )
Mathematics
[Ans. B] Required Probability = P (getting 6 in the first time) + 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 3 or 4 or 5 or 6 in the second time) ( )
( )
( )
17.
[Ans. C] The p.d.f of the random variable is x +1 P(x) 0.5 0.5 The cumulative distribution function F(x) is the probability upto x as given below x +1 F(x) 0.5 1.0 So correct option is (C)
18.
[Ans. C] e (k)
[Ans. A] + The five cards are * Sample space ordered pairs st nd P (1 card = 2 card + 1) )( )( )( )+ *(
k P is no. of cars per minute travelling.
[Ans. D] 𝛔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 So P can be either 0,1,2. (i.e. k = 0,1,2) For k = 1, p(1)=e
[Ans. A] Let A be the event of head in one coin. B be the event of head in second coin. The required probability is * ) ( ∪ )+ ( )| ∪ ) ( ∪ ) ( ) ( ∪ ) ( ) (both coin he ds)
[Ans. *] Range 0.24 to 0.27 The smaller sticks, therefore, will range in length from almost 0 meters upto a maximum of 0.5 meters, with each length equally possible. Thus, the average length will be about 0.25 meters, or about a quarter of the stick.
24.
(
)
[Ans. 10] 22 occurs in following ways 6 6 6 4 w ys 6 6 5 5 w ys
[Ans. 0.25] ( ∪ ) P(S) = 1 ( ) ( ) ( ) utu lly exclusive ( ) ( ) ( ) et ( ) x; ( ) x P(A) P(B) = x( x) Maximum value of y = x ( x) dy ( x) x dx = 2x = 1 x
equired prob bility
(max)
x 21.
( )
) e
19.
( )
Mathematics
ximum v lue of y
[Ans. *] Range 11.85 to 11.95 For functioning 3 need to be working (function)
[Ans. *] Range 3.8 to 3.9 Expected length = Average length of all words
2.
[Ans. A] I
∫ e
(
√ omp ring with (
23.
σ√ ut μ
[Ans. *] Range 0.259 to 0.261 Let A = divisible by 2, B = divisible by 3 and C = divisible by 5, then n(A) = 50, n(B) = 33, n(C) = 20 n( ) n( ) n( ) n( ) P( ∪ ∪ )
Probability of failing in paper 2, P (B) = 0.2 Probability of failing in paper 1, when
equ tion
e
√
A 0.6 B A P A B We know that, P PB B
student has failed in paper 2, P
[Ans. C]
P x.dx 1
Ke
Mathematics
(
∴
.dx 1
ax
)
e dx
∫
e
dx
x x,for x 0 x for x 0 K K 1 a a
( )
= 0.6 0.2 = 0.12
or ∫
( )
7.
[Ans. A] CDF: F x
x
PDF
dx
For x<0, F x
x
x 1
dx
1
4.
[Ans. D] . / ( )
P (Y/D) =
. / ( )
. / ( )
= 5.
. / ( )
=0.4
0
1
F0
1 2
conc ve upw rds
For x>0, F x F0
x
x 1
dx
0
[Ans. A] var[x]=σ =E[(x x)2] Where, x=E[x] x= expected or mean value of X defining
1 x2 x concave downwards 2 2 Hence the CDF is, shown in the figure (A).
E[X] =
xf xdx x
8.
[Ans. A]
Given: Px x Me2|x| Ne3|x|
x P xi x xi dx i
P xdx 1 x
xiP xi
i
Variance σ is a measure of the spread of the values of X from its mean x. Using relation , E[X+Y]= E[X]+E[Y] And E[CX]=CE[X] On var[x]= σ =E[(x x)2] σ = ,Xx2 = E[X2] [ ,X-] 6.
Probability of getting head in first toss = Probability of getting head in second toss =
[Ans. C] P(no. of tosses is odd) (no of tosses is
…)
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 in second toss and head in third toss)
be tail always. So probability of getting head in first two tosses ( )( )( )…………… ( ) = (1/2)10
P(no. of toss is 5) = P(T,T,T,TH) . /
11.
Mathematics
[Ans. B] Both the teacher and student are wrong Mean = ∑ k = 0.1 + 0.4 + 1.2 + 0.8 + 0.5 = 3.0 E(x2) = ∑ k
… etc
So, P(no. of tosses in odd)
⁄ ⁄ ⁄ ⁄
Variance(x)= E(x2) – * (x)+ =10.2 9=1.2 12.
[Ans. D] P(H, H, H, T) +P (H, H, H, H ) =
13.
. /
. /
15.
[Ans. B] ( V ≥ V) ( V V≥ ) *z v v+ Linear combination of Gaussian random variable is Gaussian ∴ (z ≥ ) and not mean till zero because both random variables has mean zero hence ( ) Hence Option B is correct
[Ans. *] Range 0.65 to 0.68 et ‘ ’ be different types of f milies nd ‘S’ be there siblings. S S S (siblings) Probability that child chosen at random having sibling is 2/3
(x)
et S
,
∑x f(x)
[Ans. C]
21.
[Ans. *] Range 2.9 to 3.1 Let the first toss be head. 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) T 1 1/2 HT 2 1/2 1/2=1/4 HHT 3 1/8 nd so on…
II)gives
(
)S
……
(x) i.e. The expected number of tosses (after first head) to get first tail is 2 and same can be applicable if first toss results in tail. Hence the average number of tosses is
22.
-
20.
(I
(II)
S
∑x …
……
(I)
S
f(x) ∴ (x)
……
S
[Ans. *] Range 0.32 to 0.34 This is a tricky question, here, X X X independent and identically distributed random variables with the uniform distribution , -. So, they are equiprobable. So X X or X have chances being largest are equiprobable. So, [P {X is largest}] or [P {X is largest}] or [P {X is largest}] =1 and P {X is largest} = P {X is largest} = P {X is largest}
[Ans. *] Range 49.9 to 50.1 Set of positive odd number less than 100 is 50. As it is a uniform distribution
∑ x (x) …
∴ *X is l rgest + 19.
Mathematics
[Ans. *] Range 0.15 to 0.18 X X X X X X et z X X X (X ) X X (z ) Pdf of z we need to determine. It is the convolution of three pdf
∴pr(P ∪ Q) pr(P) + pr(Q) (D) is true since P Q P n(P Q) n(P) pr(P Q) pr(P)
5 dx 5 dx
5 dx 2.
x
∫ x exp 4
x
∫ x exp 4
√ [ exp (
√ , 24.
x
∫ |x| exp 4
-
[Ans. B] P(A|B) =
5 dx 5 dx
x ) dx]
( he d in tosses nd first toss in he d) = P(HHT) + P(HTH)
4/5
Parcel is sent to R
∴ Required probability = R
3.
1/5
S
Parcel is lost Parcel is lost
parcel
is
=
[Ans. C] If two fair dices are rolles the probability distribution of r where r is the sum of the numbers on each die is given by r P(r)
4/5
that
) ( )
Also, P(first toss is head) =
√
Parcel is sent to
Probability
(
∴ P(2 heads in 3 tosses | first toss is head) ( he ds in tosses nd first toss in he d) (first toss is he d)
[Ans. *] Range 0.43 to 0.45 Pre flow diagram is
1/5
Mathematics
lost
2 Probability that parcel is lost by 3 Probability that parcel is lost by provided that the parcel is lost
4 5
EE 1.
6 [Ans. D] (A) is false since of P & Q are independent pr(P Q) = pr(P) pr(Q) which need not be zero. (B) is false since pr(P ∪ Q) = pr(P) + pr(Q) – pr(P Q) (C) is false since independence and mutually exclusion are unrelated properties.
The above table has been obtained by taking all different all different ways of obtaining a particular sum. For example, a sum of 5 can be obtained by (1, 4), (2, 3), (3, 2) and (4, 1). ∴ P(x = 5) = 4/36 Now let us consider choice (A) Pr(r > 6) = Pr(r ≥ 7)
P(1, 5, 6) =
=
P(3, 4, 5) =
=
P(1, 2, 5) =
=
∴ Choice (C) P(1, 5 and 6) = 5.
is correct.
[Ans. C] x is uniformly distributes in [0, 1] ∴ Probability density function
= =
Mathematics
=
f(x) =
∴ Choice (A) i.e. pr(r > 6) = 1/6 is wrong. Consider choice (B) pr(r/3 is an integer) = pr(r = 3) + pr (r = 6) + pr (r = 9) + pr (r = 1)
=
=1
∴ f(x) = 1 0 < x < 1 Now E(x ) = ∫ x f(x)dx ∫x
dx
= =
6.
=
[Ans. B] Let N people in room. So no. of events that at least two people in room born at same date
∴ Choice (B) i.e. pr (r/3) is an integer = 5/6 is wrong. Consider choice (C) Now, pr(r/4 is an integer) = pr(r = 4) + pr (r = 8) + pr (r = 12) = =
≥
N
Solving, we get N = 7
+
7.
[Ans. C] (II is red|I is white) (II is red nd I is white) (I is white) (I is white nd II is red) (I is white)
8.
[Ans. B]
=
pr(r = 8) = ∴ pr(r = 8 | r/4 is an integer) =
…
=
= ∴ Choice (C) is correct. 4.
[Ans. C] Dice value 1 2
Probability
and
is the entrie
3
rectangle The region in which maximum of {x, y} is
[Ans. B] Let number of heads = x, ∴ Number of tails n x ∴ ifference x (n x)or (n x n or n x If x n n x n x
n
If n
x
n
IN 1.
x
x
|
[Ans. D]
=52 weeks and 2 days are extra. Out of x)
x
7, (SUN MON) (or) (SAT SUN) are favorable. So, Probability of this event= 2.
or x
[Ans. C] Since the reading taken by the instrument is normally distributed, hence P(x
x )
Where, [Ans. *] Range 0.13 to 0.15 Let proportionality constant = k ∴ ( dot) k ( dots) k ( dots) k ( dots) k ( dots) k ( dots) k ∴k k k k k k k ∴k ∴ rob bility of showing dots
∴k
[Ans. D] Since leap chosen will be random, so, we assume it being the case of uniform probability distribution function. Number of days in a leap year=366 days
As x and n are integers, this is not possible ∴ Probability 0 11.
k
Now
√
√
∫ e
(
)
.dx
μ e n of the distribution σ St nd rd devi tion of the distribution. ∫
exp(
)dx
where, n=x 10 (∴μ kg) and from the data given in question √
[Ans. B] By definition of Gaussian distribution, total area under the curve =1. Hence half of the area =0.5
9.
[Ans. A]
=5.9 V. (
√
S
̅)
(
̅)
(
̅)
V (closest answer is 0.2)
P(x)= 4.
[Ans. C] ( )
=
Mean = μ ( )
∫ x (x)dx = ∫
Var(x)= ∫ (x
1 2 3 3 5.
Mathematics
=∫
[Ans. A] ]
(x
(x)dx
μ)
) dx =
10.
[Ans. C] Probability of incorrect report
11.
[Ans. C] σ mm μ mm Then probability
P(x)dx 1
x dx = 6
Area under triangle =
c 1 2
α 6.
[Ans. A] Probability that the sum of digits of two dices is even is same either both dices shows even numbers or odd numbers on the top of the surface ( ) ∴ ( ) ( ) Where ( ) Probability of occurring even number of both the dices ( ) Probability of occurring odd number of both the dices (
(X where x
(
X
μ
σ mm
(
)
)
( )
e
√ e
√
So, number of measurement more than 10.15mm P Total number of measurement
)
nd (
)
) ≃
∴ ( ) 12. 7.
[Ans. A] ∫ f(x) dx=P or ∫
e
or e
|
.dx =P
[Ans. D] For the product to be even, the numbers from both the boxes should not turn out to be odd simultaneously. ∴ ( )
Numerical Methods ME – 2005 1. Starting from x = 1, one step of Newton – Raphson method in solving the equation x³ +3x 7=0 gives the next value (x₁) as (A) x₁=0.5 (C) x₁ = .5 (B) x₁= . 0 (D) x₁=2 2.
With a 1 unit change in b, what is the change in x in the solution of the system of equation = 2 .0 0. = (A) Zero (C) 50 units (B) 2 units (D) 100 units
ME – 2006 3. Match the items in columns I and II. Column I Column II (P) Gauss-Seidel (1) Interpolation method (Q) Forward (2) Non-linear Newton-Gauss differential method equations (R) Runge-Kutta (3) Numerical method integration (S) Trapezoidal (4) Linear algebraic Rule equation (A) 2 (B) 2 (C) 2 (D) 2 4.
Equation of the line normal to function ) f(x) = (x (A) y = x 5 (B) y = x 5
at (0 5) is (C) y = x (D) y = x
5 5
ME – 2007 5. A calculator has accuracy up to 8 digits 2
after decimal place. The value of
sinxdx 0
when evaluated using this calculator by trapezoidal method with 8 equal intervals, to 5 significant digits is (A) 0.00000 (C) 0.00500 (B) 1.0000 (D) 0.00025
ME – 2010 6. Torque exerted on a flywheel over a cycle is listed in the table. Flywheel energy (in J per unit cycle) using impson’s rule is Angle (degree) Torque (N-m) 0 0 60 1066 120 323 180 0 240 323 300 55 360 0 (A) 542 (C) 1444 (B) 992.7 (D) 1986 ME – 2011 7.
The integral ∫
dx, when evaluated by
using impson’s / rule on two equal subintervals each of length 1, equals (A) 1.000 (C) 1.111 (B) 1.098 (D) 1.120 ME – 2013 8. Match the correct pairs. Numerical Order of Fitting Integration Scheme Polynomial . impson’s / 1. First Rule Q. Trapezoidal Rule 2. Second . impson’s / 3. Third Rule (A) P – 2 , Q – 1, R – 3 (B) P – 3, Q – 2 , R – 1 (C) P – 1, Q – 2 , R – 3 (D) P – 3, Q – 1 , R – 2 ME – 2014 9. Using the trapezoidal rule, and dividing the interval of integration into three equal sub intervals, the definite integral ∫ |x|dx is ____________
the Trapezoidal rule with five sub intervals is _______ 11.
The definite integral ∫
12.
The real root of the equation 5x 2cosx = 0 (up to two decimal accuracy) is _______
13.
Consider
an
equation
= t
.If x =x at t = 0 , the
CE – 2005 Linked Answer Question 1 and 2 Give a>0, we wish to calculate its reciprocal value 1/a by using Newton Raphson Method for f(x) = 0.
2.
The Newton Raphson algorithm for the function will be (A) x
= (x
)
(B) x
= (x
x )
(C) x
= 2x
ax
(D) x
=x
x
in
the
(C) – (D)
CE – 2007 4. The following equation needs to be numerically solved using the NewtonRaphson method x3 + 4x – 9 = 0 the iterative equation for the purpose is (k indicates the iteration level)
differential
increment in x calculated using RungeKutta fourth order multi-step method with a step size of Δt = 0.2 is (A) 0.22 (C) 0.66 (B) 0.44 (D) 0.88
1.
(A) – (B) 0
value”)
is evaluated
using Trapezoidal rule with a step size of 1. The correct answer is _______
ordinary
Mathematics
For a = 7 and starting with x = 0.2 the first two iteration will be (A) 0.11, 0.1299 (C) 0.12, 0.1416 (B) 0.12, 0.1392 (D) 0.13, 0.1428
CE – 2006 3. A 2nd degree polynomial f(x) has values of 1, 4 and 15 at x = 0, 1 and 2 respectively.
5.
(A) x
=
(B) x
=
(C) x
=x
(D) x
=
x
Given that one root of the equation x 10x + 31x – 30 = 0 is 5, the other two roots are (A) 2 and (C) and (B) 2 and (D) 2 and
CE – 2008 6. Three values of x and y are to be fitted in a straight line in the form y = a + bx by the method of least squares. Given ∑x = 6, ∑y = 2 ∑x = and ∑xy = the values of a and b are respectively (A) 2 and 3 (C) 2 and 1 (B) 1 and 2 (D) 3 and 2 CE – 2009 7. In the solution of the following set of linear equation by Gauss elimination using partial pivoting 5x + y + 2z = 34; 4y – 3z = 12; and 10x – 2y + z = 4; the pivots for elimination of x and y are (A) 10 and 4 (C) 5 and 4 (B) 10 and 2 (D) 5 and 4
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
CE – 2010 8. The table below given values of a function F(x) obtained for values of x at intervals of 0.25. x 0 0.25 0.5 0.75 1.0 F(x) 1 0.9412 0.8 0.64 0.50 The value of the integral of the function between the limits 0 to using impson’s rule is (A) 0.7854 (C) 3.1416 (B) 2.3562 (D) 7.5000 CE 9.
2011 The square root of a number N is to be obtained by applying the Newton Raphson iterations to the equation x = 0. If i denotes the iteration index, the correct iteration scheme will be (A) x (B) x
= (x
)
= (x
CE – 2013 12. Find the magnitude of the error (correct to two decimal places) in the estimation of following integral using impson’s ⁄ Rule. Take the step length as 1.___________ ∫ (x
1.
Consider
)
(D) x
= (x
)
he error in
xe dx
=
)
(
)
is 2
1 R xn1 xn can be used to compute 2 xn
.
the (A) square of R (B) reciprocal of R (C) square root of R (D) logarithm of R
0 .
CE – 2012 The estimate of ∫ .
1 3
to an accuracy of at least 106
The Newton-Raphson iteration
for a continuous
The values of and ( ) are 19.78 and 500.01, respectively. The corresponding error in the central difference estimate for h = 0.02 is approximately (A) . 0 (C) .5 0 (B) .0 0 (D) .0 0
11.
x
1
function estimated with h=0.03 using the central difference formula f(x)|
=
using the trapezoidal rule is (A) 1000e (C) 100e (B) 1000 (D) 100
f(x)|
(
series
CS – 2008 2. The minimum number of equal length subintervals needed to approximate
3. 10.
the
= 0.5 obtained from the NewtonRaphson method. The series converges to (A) 1.5 (C) 1.6 (D) 1.4 (B) √2
)
= (x
0) dx
CS – 2007
2
(C) x
Mathematics
obtained using
impson’s rule with three – point function evaluation exceeds the exact value by (A) 0.235 (C) 0.024 (B) 0.068 (D) 0.012
CS – 2010 4. Newton-Raphson method is used to compute a root of the equation x 13 = 0 with 3.5 as the initial value. The approximation after one iteration is (A) 3.575 (C) 3.667 (B) 3.677 (D) 3.607
CS – 2012 5. The bisection method is applied to compute a zero of the function f(x) = x x x in the interval [1,9]. The method converges to a solution after ___________ iterations. (A) 1 (C) 5 (B) 3 (D) 7 CS – 2013 6. Function f is known at the following points: x f(x) 0 0 0.3 0.09 0.6 0.36 0.9 0.81 1.2 1.44 1.5 2.25 1.8 3.24 2.1 4.41 2.4 5.76 2.7 7.29 3.0 9.00 he value of ∫ f(x)dx computed using the trapezpidal rule is (A) 8.983 (C) 9.017 (B) 9.003 (D) 9.045 CS – 2014 7. The function f(x) = x sin x satisfied the following equation: ( ) + f(x) + t cos x = 0. The value of t is _________. 8.
In the Newton-Raphson method, an initial guess of = 2 made and the sequence x x x .. is obtained for the function 0.75x 2x 2x =0 Consider the statements (I) x = 0. (II) The method converges to a solution in a finite number of iterations. Which of the following is TRUE? (A) Only I
Mathematics
(B) Only II (C) Both I and II (D) Neither I nor II 9.
With respect to the numerical evaluation of the definite integral,
= ∫ x dx where a and b are given, which of the following statements is/are TRUE? (I) The value of K obtained using the trapezoidal rule is always greater then or equal to the exact value of the defined integral (II) The value of K obtained using the impson’s rule is always equal to the exact value of the definite integral (A) I only (B) II only (C) Both I and II (D) Neither I nor II ECE– 2005 1. Match the following and choose the correct combination Group I Group II (A) Newton1. Solving nonRaphson linear equations method (B) Runge-Kutta 2. Solving linear method simultaneous equations (C) impson’s 3. Solving ordinary Rule differential equations (D) Gauss 4. Numerical elimination integration method 5. Interpolation 6. Calculation of Eigen values (A) A-6, B-1, C-5, D-3 (B) A-1, B-6, C-4, D-3 (C) A-1, B-3, C-4, D-2 (D) A-5, B-3, C-4, D-1
ECE– 2007 2. The equation x3 x2+4x 4=0 is to be solved using the Newton-Raphson method. If x=2 is taken as the initial approximation of the solution, then the next approximation using this method will be (A) 2/3 (C) 1 (B) 4/3 (D) 3/2
Match the application to appropriate numerical method. Application Numerical Method P1:Numerical M1:Newtonintegration Raphson Method P2:Solution to a M2:Runge-Kutta transcendental Method equation P3:Solution to a M : impson’s system of linear 1/3-rule equations P4:Solution to a M4:Gauss differential equation Elimination Method (A) P1—M3, P2—M2, P3—M4, P4—M1 (B) P1—M3, P2—M1, P3—M4, P4—M2 (C) P1—M4, P2—M1, P3—M3, P4—M2 (D) P1—M2, P2—M1, P3—M3, P4—M4
(C) Xn1 1 Xn
ECE– 2013 5. A polynomial f(x) = a x a x a x a x a with all coefficients positive has (A) No real root (B) No negative real root (C) Odd number of real roots (D) At least one positive and one negative real root
(B) 2
7.
ECE– 2008 3. The recursion relation to solve x= using Newton-Raphson method is (A) =e (B) = e
ECE– 2011 4. A numerical solution of the equation f(x) = x √x = 0 can be obtained using Newton – Raphson method. If the starting value is x = 2 for the iteration, the value of x that is to be used in the next step is (A) 0.306 (C) 1.694 (B) 0.739 (D) 2.306
Mathematics
converges to
(A) 2 ln 2 (B) √2
(C) 2 (D) e
EE– 2007 1.
The differential equation
=
is
discretised using Euler’s numerical integration method with a time step T > 0. What is the maximum permissible value of T to ensure stability of the solution of the corresponding discrete time equation? (A) 1 (C) (B) /2 (D) 2 EE– 2008 2. Equation e = 0 is required to be solved using ewton’s method with an initial guess x = . Then, after one
step of ewton’s method estimate x of the solution will be given by (A) 0.71828 (C) 0.20587 (B) 0.36784 (D) 0.00000 3.
A differential equation dx/dt = e u(t) has to be solved using trapezoidal rule of integration with a step size h = 0.01 sec. Function u(t) indicates a unit step function. If x(0)= 0, then value of x at t = 0.01 s will be given by (A) 0.00099 (C) 0.0099 (B) 0.00495 (D) 0.0198
EE– 2009 4. Let x 7 = 0. The iterative steps for the solution using Newton – aphson’s method is given by (A) x
= (x
(B) x
=x
(C) x
=x
(D) x
=x
)
EE– 2013 7. When the Newton – Raphson method is applied to solve the equation f(x) = x 2x = 0 the solution at the end of the first iteration with the initial guess value as x = .2 is (A) 0.82 (C) 0.705 (B) 0.49 (D) 1.69 EE– 2014 8. The function ( ) = is to be solved using Newton-Raphson method. If the initial value of is taken as 1.0, then the absolute error observed at 2nd iteration is ___________ IN– 2006 1. For k = 0 2 . the steps of Newton-Raphson method for solving a non-linear equation is given as
2 5 xk 1 xk xK2 . 3 3 (x
Starting from a suitable initial choice as k tends to , the iterate tends to (A) 1.7099 (C) 3.1251 (B) 2.2361 (D) 5.0000
)
EE– 2011 5. Solution of the variables and for the following equations is to be obtained by employing the Newton-Raphson iterative method equation(i) 0x inx 0. = 0 equation(ii) 0x 0x cosx 0. = 0 Assuming the initial values = 0.0 and = .0 the jacobian matrix is 0 0. 0 0. (A) * (C) * + + 0 0. 0 0. 0 0 0 0 (B) * (D) * + + 0 0 0 0 6.
Mathematics
IN– 2007 2. Identify the Newton-Raphson iteration scheme for finding the square root of 2.
3.
(A) x
=
(x
)
(B) x
= (x
)
(C) x
=
(D) x
= √2
x
The polynomial p(x) = x + x + 2 has (A) all real roots (B) 3 real and 2 complex roots (C) 1 real and 4 complex roots (D) all complex roots
Roots of the algebraic equation x x x = 0 are ) (A) ( (C) (0 0 0) (B) ( j j) (D) ( j j)
IN– 2008 4. It is known that two roots of the nonlinear equation x3 – 6x2 +11x 6 = 0 are 1 and 3. The third root will be (A) j (C) 2 (B) j (D) 4
IN– 2013 8. While numerically solving the differential equation
The differential equation
=
with
x(0) = 0 and the constant 0 is to be numerically integrated using the forward Euler method with a constant integration time step T. The maximum value of T such that the numerical solution of x converges is (C) (A) (B)
2xy = 0 y(0) =
using
Euler’s predictor – corrector (improved Euler – Cauchy )method with a step size of 0.2, the value of y after the first step is (A) 1.00 (C) 0.97 (B) 1.03 (D) 0.96
IN – 2009 5.
Mathematics
IN– 2014 9. The iteration step in order to solve for the cube roots of a given number N using the Newton- aphson’s method is
(D) 2
(A) x
=x
(B) x
= (2x
(C) x
=x
(D) x
= (2x
(
x ) )
(
x ) )
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
[Ans. C] Given x y = 2 (i) .0 x 0.0 y = b (ii) Multiply 0.99 is equation (i) and subtract from equation (ii); we get ( .0 0. )x = b (2 0. ) 0.02x = b . 0.02Δx = Δb Δx =
0.02
[Ans. D]
4.
[Ans. B] Given f(x) = (x 2 ) f (x) = (x
f(x)dx = [(y
∫ y ∫
0.70 0
6.
y )
[(0
0)
0.70 0
0.70 0
[(0
y )]
7.
[Ans. C] x y= ∫
( 0
0)
2( 2.7 /unit cycle.
=
Slope of normal = 3 (∵ roduct of slopes = 1) Slope of normal at point (0, 5) y 5 = (x 0) y= x 5 [Ans. A] b a 2 0 h= = = n y = sin(0) = 0
0=0
[Ans. B] ower = ω = Area under the curve. h (y = [(y y ) y y )
By intermediate value theorem roots lie be between 0 and 1. et x = rad = 57. 2 By Newton Raphson method f(x ) x =x f (x ) 2x sin x 2 cos x x = 5 2 sin x x = 0.5 2 x = 0.5 25 x = 0.5 2
∫ |x|dx is h ∫ ydx = [y 2
2(y
y
y
x
1
y
1
0.33
2
y ]
y
0.33
2
∫ |x|dx =
.)
y
[
y
0.33
1
0.333
1
2(0.
0.
)]
13.
= . 0 10.
[Ans. *] Range 1.74 to 1.76 2.5 h= = 0. 5 y 2y 2y ∫ . ln (x)dx = [ 2y y =
.
[ln(2.5)
2ln( . ) = .75 11.
2(ln2. )
.
2y
]
2 ln( . )
CE 1.
[Ans. *]Range 1.1 to 1.2
t|
Δx = 0.0
0. = 0.
= 2t
t|
Set up the equation as x = i.e. = a
∫ f(x)dx = [y
y
2(y
iven in question 0 1 1 2 1 0.5
∫ dx = [y x 2
.
.
t Δx = 2
To calculate using N-R method
rapezoidal rule
x y
)dt
[Ans. C]
∫ dx by trapezoidal rule x
h=
[Ans. D] The variation in options are much, so it can be solved by integrating directly dx = t dt ∫ dx = ∫ ( t
ln( )]
2ln( .7)
Mathematics
y
y
..y
)]
a=0 i.e. f(x) =
2 3 0.33
a=0
Now f (x) = f(x ) =
a
f (x ) =
2(y )]
For N-R method = [ 2 = .
0.
2
0.5]
x
=x x
12.
[Ans. *] Range 0.53 to 0.56 Let f(x) = 5x 2 cos x f (x) = 5 2 sin x f(0) = f( ) = 2.
[Ans. A ] Given f(x) = x x =0 f (x) = x Newton – Raphson formula is
γα =
βγ = (i) Also
Error = exact – Approximate value =
βγ
α βγ = 5
Now exact value ∫ f(x)dx
= *x
2x x
αβγ=
Approximate value by rapezoidal ule = 12 Since f(x) is second degree polynomial, let f(x) = a0 + a x + a x f(0) = 1 a 0 0= a = f(1) = 4 a a a = 1+ a a = a a = f(2) = 15 a 2a a = 5 2a a = 5 2a a = Solving (i) and (ii) a = and a = f(x) = 1 – x + 4 x x
=
[Ans. A] Given x – 10 x + 31x 30 = 0 One root = 5 Let the roots be α β and γ of equation ax + bx + cx + d = 0
Normal equations are ∑y = na b∑x ∑xy = a∑x b∑x Substitute the values and simply a= b=2 7.
9.
5 [0 0
2
(
)
| 2] → 2
0 [0 5
2
=
f(x ) f(x )
=x
=x
(
x
)
2x
x
=
2x
2
[x
x
]
10.
[Ans. D] Error in central difference formula is (h) This means, error If error for h = 0.03 is 2 0 then Error for h = 0.02 is approximately (0.02) 2 0 0 (0.0 )
11.
[Ans. D] Exact value of ∫ .
| 2] 2
So the pivot for eliminating x is a = 10 Now we eliminate x using this pivot as follows : 0 2 [0 | 2] 5 2 5 0 2 0 2] → [0 0 2 /2 Now to eliminate y, we need to compare the elements in second column at and below the diagonal element Since a = 4 is already larger in absolute value compares to a = 2 The pivot element for eliminating y is a = 4 itself. The pivots for eliminating x and y are respectively 10 and 4 8.
[Ans. A] x
[Ans. A] The equation is 5x + y + 2z = 34 0x + 4y – 3z = 12 and 10x – 2y + z = The augmented matrix for gauss elimination is 5 2 [0 | 2] 0 2 Since in the first column maximum element in absolute value is 10 we need to exchange row 1 with row 3
Mathematics
.
dx = .0
Using impson’s rule in three – point form, b a .5 0.5 h= = = 0.5 n 2 So, x 0.5 1 1.5 y 2 1 0.67 ∫
= =
[
0.5
] [2
0. 7
]
= . So, the estimate exceeds the exact value by Approximate value – Exact value = 1.1116 1.0986 =0.012(approximately)
12.
[Ans. *](Range 0.52 to 0.55) Using impson’s ule X 0 1 2 3 Y 10 11 26 91
2α = α + R α =R α=√ So this iteration will compute the square root of R
α= + α= 8α = 4α +9 α = 4.
α = = 1.5 [Ans. A] Here, the function being integrated is f(x) = xe f (x) = xe + e = e (x + 1) f’ (x) = xe + e + e = e (x + 2) Since, both are increasing functions of x, maximum value of f ( ) in interval 1 2, occurs at = 2 so ( )| (2 max |f =e 2) = e Truncation Error for trapezoidal rule = TE (bound)
[Ans. D] y=x dy = 2x dx f(x)= x x
= .5
5.
=
(b – a) max |f ( )| 1
=
(2 – 1) [e (2 + 2)]
=
e
Now putting
(
)
=
= 57 7
)=5 f(x ) 2 oot lies between and
x =(
0
0
)=2 f(x ) 0 2 After ' ' interations we get the root
[Ans. – ] Given (x) + f(x) + t cos x = 0 and f(x) = x sin x f (x) = x cos x + sin x f (x) = x ( sin x) + cos x + cos x = 2 cos x – x sin x = 2 cos x – f (x) 2 cos x – f (x) + f(x) +t cos x = 0 2 cos x = tcos x t = 2 [Ans. A] f(x) = 0.75x 2x 2x f (x) = 2.25x x 2 x =2 f = 2 f = f x =x =0 f f = f = 2 f x =x =2 f f = 2 f = f x =x =0 f Also, root does not lies between 0 and 1 So, the method diverges if x = 2 nly ( )is true.
x1 2 3.
1 x n 4.
x1 x0
e e
e xn 1 exn
[Ans. C] x
f(x ) f (x )
=x
f(2) = (2
x
) = √2
√2
f (2) =
√
=2
and
√
=
√ )
(√ √
= .
√
5.
[Ans. D] f(x) = a x a x a x a x a If the above equation have complex roots, then they must be in complex conjugate pair, because it’s given all co-efficients are positive ( they are real ) So if complex roots are even no. (in pair) then real roots will also be even. ption ( )is wrong From the equation ( 0) roduct of roots = As no. of roots = 4, Product of roots < 1 either one root 0 (or) Product of three roots < 0 ption ( )is rong. Now, take option (A), Let us take it is correct . Roots are in complex conjugate pairs = Product of roots 0 | | | | 0 which is not possible ption (A) is wrong orrect answer is option ( )
[Ans. C] By definition (& the application) of various methods
4=0
Next approximation x1 x0
8 4 12 3
[Ans. C] Given : f(x)= x e By Newton Raphson method, f(x ) x x =x =x f (x )
[Ans. C] For value of K if trapezoidal rule is used then the value is either greater than actual value of definite integral and if impson’s rule is used then value is exact Hence both statements are TRUE
[Ans. *] Range 0.05 to 0.07 Clearly, x = 0 is root of the equation f(x) = e =0 f (x) = e and x = .0 Using ewton raphson method (e . ) f(x ) x =x = = f (x ) e. e and x = x
f(x ) = f (x ) e =
(e
Approach- 2 For ax3 +bx2 + cx +d = 0 If the three roots are p,q,r then Sum of the roots= p+q+r= b/a Product of the roots= pqr= d/a pq+qr+rp=c/a
) e
5.
[Ans. D] dx x = dt f(x, y) =
e
e = 0. 7 0. = 0.0 Absolute error at 2nd itteration is |0 0.0 | = 0.0 IN 1.
x
=x h
=( [Ans. A] As k ∞ xk+1 ≈xk xk = x
h (x y ) = x )x
2.
3.
h
h(
x
)
)
h
|
h
x
/
(
or stability |
Δ
x = x x =5 x =5
Mathematics
Δ
= 1.70
[Ans. A] Assume x = √ f(x) = x =0 f(x ) x =x = [x f (x ) 2
6.
[Ans. A] dv =v t dt t v dv =v t dt 0 0 0 0+0 0. = 0 0.1 0 0+0.1 0. = 0.0
7.
[Ans. C] f(x) = x x f (x) = x = g(x) x = initial guess g (x) = x g (x ) x =x g (x )
2 ] x
[Ans. C] Given p(x) = x + x + 2 There is no sign change, hence at most 0 positive root ( rom escarte’s rule of signs) p( x) = x x+2 There is one sign change, hence at most 1 negative root ( rom escarte’s rule of signs)
[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
The line integral ∫ ⃗ ⃗⃗⃗⃗ of the vector function ⃗ ( ) 2xyz ̂+ x²z + ̂ k²y ̂ from the origin to the point P (1,1,1) (A) is 1 (B) is Zero (C) is 1 (D) cannot be determined without specifying the path
2.
be (A) (B) 8.
(A)
(C)
(B)
(D)
Changing the order of the integration in the double integral I = ∫ ∫
(
∫ (
What is q?
(A)
(C) X (D) 8 )
(A)
√
(C)
√
(B)
√
(D)
.
(
10.
/
)
(A) 0 (B) ⁄
is equal to 11.
∫
(C) (D) 1
The area of a triangle formed by the tips of vectors a , b and c is (A)
(
)(
(D) Zero
(B)
|(
)
Stoke’ theorem connects (A) A line integral and a surface integral (B) Surface integral and a volume integral (C) A line integral and a volume integral (D) Gradient of function and its surface integral
(C)
|
(D)
(
(C) 2∫ (
√
ME – 2007
(B) 2∫
6.
1 and t is a real number,
Let x denote a real number. Find out the INCORRECT statement + represents the set if all (A) S * real numbers greater then 3 + represents the empty (B) S * set + represents the (C) S * union of set A and set B + represents the set (D) S * of all real umbers between a and b, where and b are real number
)
leads to (A) 4y (B) 16y²
(C) 0 (D) ⁄
dt is:
∫
9.
4.
)
⁄ ⁄
√
By a change of variables x(u,v) = uv, y(u,v) = v/u is double integral, the integral f(x,y) changes to f(uv, u/v) ( ). Then, ( ) (A) 2 v/u (C) v² (B) 2 u v (D) 1
I =∫ ∫ (
2x2 7x 3 , then limf(x) will x 3 5x2 12x 9
Assuming i =
The right circular cone of largest volume that can be enclosed by a sphere of 1 m radius has a height of
ME – 2010 26. Velocity vector of a flow field is given as ⃗ ̂ .̂ The vorticity vector at (1, 1, 1) is (A) 4 ̂ ̂ (B) 4 ̂ ̂ 27.
The function (A) o o
(C) ̂ (D) ̂
∀ ∀ (B) o o ∀ ∀ except at x = 3/2 (C) o o ∀ ∀ except at x = 2/3 (D) o o ∀
28.
29.
ME – 2012 33. Consider the function ( ) in the interval . At the point x = 0, f(x) is (A) Continuous and differentiable. (B) Non – continuous and differentiable. (C) Continuous and non – differentiable. (D) Neither continuous nor differentiable.
̂ ̂
R R R R
34.
R R
ME – 2011 30. If f(x) is an even function and is a positive real number, then ∫ ( )dx equals
31.
What is (A) (B)
32.
36.
For the spherical surface the unit outward normal vector at the point
is
(C) π (D) π
(C)
(B) (C)
is
√
(A) (B)
has
/
√
̂
√
̂
√
̂
√
̂
√
(C) ̂ (D) 37.
equal to?
A series expansion for the function (A)
.
∫ ( )
(C) 0 (D) 1
(C) 1 (D) 2
At x = 0, the function f(x) = (A) A maximum value (B) A minimum value (C) A singularity (D) A point of inflection
R except at x = 3 ∀ R
(D)
/ is
35.
The parabolic arc is √ revolved around the x-axis. The volume of the solid of revolution is (A) π (C) π (B) π (D) π
(A) 0 (B)
. (A) 1/4 (B) 1/2
The value of the integral ∫ (A) –π (B) –π
Mathematics
√
̂
√
̂
√
̂
The area enclosed between the straight line y = x and the parabola y = in the x – y plane is (A) 1/6 (C) 1/3 (B) 1/4 (D) 1/2
ME – 2013 38. The following surface integral is to be evaluated over a sphere for the given steady velocity vector field defined with respect to a cartesian coordinate system having i, j and k as unit base vectors. ∫∫ (
Where S is the sphere, and n is the outward unit normal vector to the sphere. The value of the surface integral is (A) π (C) π⁄ (B) π (D) π 39.
45.
If a function is continuous at a point, (A) the limit of the function may not exist at the point (B) the function must be derivable at the point (C) the limit of the function at the point tends to infinity (D) the limit must exist at the point and the value of limit should be same as the value of the function at that point
The value of the definite integral ( )
∫ √
is
(A)
√
(C)
√
(B)
√
(D)
√
46.
Divergence of the vector field ̂ ( ̂ ̂ ) is (A) 0 (C) 5 (B) 3 (D) 6
(C) 3 (D)Not defined
47.
The value of the integral
ME – 2014 40.
is (A) 0 (B) 1
∫ 41.
Which one of the following describes the relationship among the three vectors ̂ ̂ ̂ ̂ + ̂ + ̂ ̂ ̂ ̂ (A) The vectors are mutually perpendicular (B) The vectors are linearly dependent (C) The vectors are linearly independent (D) The vectors are unit vectors
42.
.
(
)
/ is equal to
(A) 0 (B) 0.5 43.
̂
̂
)̂ )̂ ̂ ̂
̂ ̂ ̂ ̂
)
(
)
) (
)
(A) 3 (B) 0 48.
(C) 1 (D) 2
The value of the integral ∫ ∫ is (
)
(C) (
(B) (
)
(D) .
(A)
) /
).
Where, c is the square cut from the first quadrant by the lines x = 1 and y = 1 will ( G ’ h o o h h line integral into double integral) (A) ⁄ (C) ⁄ (B) 1 (D) ⁄
̂ ̂
( (
CE – 2005 1. Value of the integral ∮ (
(C) 1 (D) 2
Curl of vector ⃗ ̂ (A) ( (B) ( (C) (D)
44.
Mathematics
̂ ̂ 2.
A rail engine accelerates from its stationary position for 8 seconds and travels a distance of 280 m. According to the Mean Value theorem, the speedometer at a certain time during acceleration must read exactly. (A) 0 kmph (C) 75 kmph (B) 8 kmph (D) 126 kmph
The best approximation of the minimum value attained by (100x) for ≥ is _______
CE – 2006 3. What is the area common to the circles o 2 (A) 0.524 a (C) 1.014 a2 (B) 0.614 a2 (D) 1.228 a2 4.
The directional derivative of f(x, y, z) = 2 + 3 + at the point P (2, 1, 3) in the direction of the vector a= k is (A) (C) (B) (D)
CE – 2007 5. Potential function is given as = . When will be the stream function () with the condition = 0 at x = y = 0? (A) 2xy (C) (B) + (D) 2 6.
Evaluate ∫ (C) π⁄ (D) π⁄
(A) π (B) π⁄ 7.
10.
12.
transformed to (A) (B)
9.
(C) √ (D) 18
parabola is y = 4h
(A) ∫ √ √
√
(D)
√
√
(C) ∫
= 0 by substituting (C)
where x is the
horizontal coordinate and y is the vertical coordinate with the origin at the centre of the cable. The expression for the total length of the cable is
= 0 can be
(D)
14.
√
∫
.
The
/
is
(A) 2/3 (B) 1
The inner (dot) product of two vectors ⃗ and ⃗ is zero. The angle (degrees) between in two vectors is (A) 0 (C) 90 (B) 30 (D) 120
(C) 40.5 (D) 54.0
√
(B) 2∫
+
is
CE – 2010 13. A parabolic cable is held between two supports at the same level. The horizontal span between the supports is L. The sag at the mid-span is h. The equation of the
CE – 2008 +
)
For a scalar function f(x, y, z) = the directional derivative at the point P(1, 2, 1) in the ⃗ is direction of a vector (A) (B)
A velocity is given as ̅ = 5xy + 2 y2 + 3yz2⃗ . The divergence
The equation
The value of ∫ ∫ ( (A) 13.5 (B) 27.0
CE – 2009 11. For a scalar function f(x, y, z) = + 3 + 2 the gradient at the point P (1, 2, 1) is (A) 2 + 6 + 4⃗ (C) 2 + 12 + 4⃗ (D) √ (B) 2 + 12 – 4⃗
of this velocity vector at (1 1 1) is (A) 9 (C) 14 (B) 10 (D) 15
8.
Mathematics
15.
th
(C) 3/2 (D)
Given a function ( ) The optimal value of f(x, y) th
(A) Is a minimum equal to 10/3 (B) Is a maximum equal to 10/3 (C) Is a minimum equal to 8/3 (D) Is a maximum equal to 8/3
CE – 2013 21.
CE – 2011 16.
∫
√ √
√
?
22.
(C) a (D) 2a
/
o
magnitudes a and b respectively. |⃗ ⃗ | will be equal to (A) – (⃗ ⃗ ) (C) + (⃗ ⃗ ) (B) ab ⃗ ⃗ (D) ab + ⃗ ⃗ CE – 2012 19. For the parallelogram OPQR shown in the sketch, ̅̅̅̅ ̂ ̂ and ̅̅̅̅ R ̂ .̂ The area of the parallelogram is Q
(C) 1 (D)
24.
A particle moves along a curve whose parametric equation are : and z = 2 sin (5t), where x, y and z show variations of the distance covered by the particle (in cm) with time t (in s). The magnitude of the acceleration of the particle (in cm ) at t = 0 is ___________
25.
If {x} is a continuous, real valued random variable defined over the interval ( ) and its occurrence is defined by the density function given as:
(C) 1 (D) π
If ⃗ and ⃗ are two arbitrary vectors with
R P
.
( )
/
√
wh
‘ ’
‘ ’
the statistical attributes of the random variable {x}. The value of the integral
O
(A) ad –bc (B) ac+bd
.
With reference to the conventional Cartesian (x, y) coordinate system, the vertices of a triangle have the following coordinates: ( ) ( ) ( ) ( ) ( ) ( ). The area of the triangle is equal to (A) ⁄ (C) ⁄ (B) ⁄ (D) ⁄
π
(A) 0 (B) π
(C) ad + bc (D) ab – cd
∫
o
o
. √
/
dx is
(A) 1 (B) 0.5
The infinity series
(A) sec (B)
(C) 1 (D) 8/3
23.
π
20.
o
(A) (B)
Wh ho h o λ such that the function defined below is continuous π ? f(x)={
CS – 2007 2. Consider the following two statements about the function f(x) =|x|: P: f(x) is continuous for all real values of x Q: f(x) is differentiable for all real values of x Which of the following is true? (A) P is true Q is false (B) P is false Q is true (C) Both P and Q are true (D) Both P and Q are false CS – 2008 3.
4.
x sinx equals Lim x x cosx (A) 1 (B) 1
(C) (D)
Let P=∑
∑
7.
What is the value of (A) 0 (B)
∫ (A) 0 (B) 1
(C) (D) 1
(A) 0 (B) 2
(C) –i (D) i
CS – 2012 9. Consider the function f(x)= sin(x) in the interval x ,π⁄ π⁄ -. The number and location(s) of the local minima of this function are (A) One , at π⁄ (B) One , at π⁄ (C) Two , at π⁄ and π (D) Two , at π⁄ and π CS – 2013 10. Which one the following function is continuous at x =3? (A) ( )
{
(B) ( )
2
(C) ( )
2
(D) ( ) CS – 2014 11. Let the function ( )
CS – 2009 6.
/ ?
∫
A point on a curve is said to be extreme if it is a local minimum or a local maximum. The number of distinct extrema for the 4 3 2 curve 3x 16x 24x 37 is (A) 0 (C) 2 (B) 1 (D) 3
.
CS – 2011 8. Given i = √ , what will be the evaluation of the definite integral
where k is a positive integer. Then (A) (C) (B) (D) 5.
Mathematics
(π (π
|
Where evaluates to
o o (π o (π
) )
) )
(π (π
)| )
1 and ( ) denote the
0
derivation of f with respect to . Which of the following statements is/are TRUE? (I) There exists
A function f (x) is continuous in the interval [0, 2]. It is known that 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) (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) such that f(y) ( )
(C)
(D)
ECE – 2006 2. As x is increased from function f x
If and are 4 – dimensional subspace of a 6 – dimensional vector space V, then the smallest possible dimension of is ____________. If ∫
dx = π, then the value of k
e 1 ex
3 The integral sin d is given by
3.
0
1 2 2 (B ) 3
o
(A) π (B) π
, the
The value of the integral given below is ∫
to
x
(A) monotonically increases (B) monotonically decreases (C) increases to a maximum value and then decreases (D) decreases to a minimum value and then increases
is equal to_______. 15.
Mathematics
4 3 8 (D) 3
(A) (C) – π (D) π
ECE – 2005 1. The derivative of the symmetric function drawn in given figure will look like
ECE – 2007 6. For the function , the linear approximation around = 2 is (A) (3 x) (B) 1 x
ECE – 2008 12. Consider points P and Q in the x –y plane, with P=(1,0) and Q=(0,1). The line Q
integral 2 xdx ydy along the
P
(C) 3 2 2 1 2 x e
2
semicircle with the line segment PQ as its diameter (A) is 1 (B) is 0 (C) is 1 (D) depends on the direction (clockwise or anticlockwise) of the semicircle
(D) 7.
8.
9.
10.
For x <<1, coth(x) can be approximated as (A) x (C) (B) x2 (D)
In the Taylor series expansion of exp(x)+sin(x) about the point x=π the coefficient of (x π)2 is (π) (A) (π) (C) (π) (π) (B) (D)
14.
Which of the following functions would have only odd powers of x in its Taylor series expansion about the point x=0? (A) sin(x3) (C) cos(x3) 2 (B) sin(x ) (D) cos(x2)
15.
The value of the integral of the function g(x, y)=4x3+10y4 along the straight line segment from the point (0,0) to the point (1,2) in the x y plane is (A) 33 (C) 40 (B) 35 (D) 56
16.
For real values of x, the minimum value of the function f(x)=exp(x)+ exp( x) is (A) 2 (C) 0.5 (B) 1 (D) 00
17.
Consider points P and Q in the x-y plane, with P=(1, 0) and Q= (0, 1).
Which one of the following function is strictly bounded? 2 (A) (C) x x (B) e (D)
(A) 0.5 (B) 1 11.
13. Consider the function f(x) = x – 2. The maximum value of f(x) in the closed interval [ 4,4] is (A) 18 (C) 2.25 (B) 10 (D) Indeterminate
sin /2 lim is 0 (C) 2 (D) not defined
The following Plot shows a function y which varies linearly with x. The value of 2
the integral I ydx is 1
Y 3 2
) along ∫ ( the semicircle with the line segment PQ as its diameter (A) Is (B) Is 0 (C) Is 1 h
(D) Depends on the direction (clockwise or anti-clockwise) of the semicircle
21.
ECE – 2009 18. The Taylor series expansion of
sinx at x is given by x (A) 1
x 2 ..... 3!
(B)
2 x 1 .....
(C)
2 x 1 .....
the value of the integral ∯ (A) 3V (B) 5V
3!
x
2
19.
3!
.....
If a vector field ⃗ is related to another ⃗ , which vector field ⃗ through ⃗ = of the following is true? Note: C and refer to any closed contour and any surface whose boundary is C. (A) ∮ ⃗ ⃗ = ∬ ⃗ ⃗ (B) ∮ ⃗ ⃗ =
∬⃗ ⃗
(C) ∮
⃗ ⃗ =
∬⃗ ⃗
(D) ∮
⃗ ⃗ =
∬⃗ ⃗
ECE – 2010 20. If ⃗
̂ ̂ , then ∮ ⃗ ⃗⃗⃗ over the path shown in the figure is
(A) 0 (B) ⁄√
̂⃗
is
(C) 10V (D) 15V
ECE\IN – 2012 23. The direction of vector A is radially outward from the origin, with where and K is constant. The value of n for which . A = 0 is (A) 2 (C) 1 (B) 2 (D) 0 ECE\EE – 2012 24. The maximum value of ( ) in the interval [1,6] is (A) 21 (C) 41 (B) 25 (D) 46 ECE – 2013 25. The maximum value of unit which the approximation holds to within 10% error is (A) (C) (B) (D) 26.
√
, then has a maximum at minimum at maximum at minimum at
ECE – 2011 22. Consider a closed surface S surrounding a volume V. If is the position vector of a point inside S, with ̂ the unit normal of S,
3!
(D) 1
If (A) (B) (C) (D)
Mathematics
The divergence of the vector field ⃗ ̂ ̂ ̂ is (A) 0 (B) 1/3
Consider a vector field ⃗ ( ) The closed loop line integral ∮ ⃗ can be expressed as ⃗ ) over the closed (A) ∯( surface boundary by the loop (B) ∰( ⃗ )dv over the closed volume bounded by the loop (C) ∭( ⃗ )dv over the open volume bounded by the loop ⃗ ) over the closed surface (D) ∬( bounded by the loop
Mathematics
34.
The magnitude of the gradient for the function ( ) at the point (1,1,1) is_______.
35.
The directional derivative of ( ) ( ) ( )in the direction √
of the unit vector at an angle of with y axis, is given by ________________. EE – 2005 1.
For the scalar field u =
, magnitude
of the gradient at the point (1, 3) is ECE – 2014 28. The volume under the surface z(x, y) = x+y and above the triangle in the x-y plane defined by {0 y x and 0 x 12} is______ 29.
30.
For function ( ) (A) o (B) o The value of
the maximum value of the occurs at (C) (D) o .
(A) (B)
(B) √ ⁄ 2.
For the function f(x) = , the maximum occurs when x is equal to (A) 2 (C) 0 (B) 1 (D) 1
3.
If S = ∫
/ is
31.
The maximum value of the function ( ) ( ) (wh ) occurs at x =____.
32.
The maximum value of ( ) 0 x 3 is ______.
in the interval
EE – 2006 4. A surface S(x, y) = 2x + 5y – 3 is integrated once over a path consisting of the points that satisfy (x+1)2+ (y 1)2 =√ . The integral evaluates to (A) 17√ (C) √ /17 (D) 0 (B) 17/√ 5.
33.
, then S has the value (C) ⁄ (D) 1
⁄ ⁄
(A) (B)
(C) (D)
(C) √ (D) ⁄
⁄
(A) √
The expression V = ∫ πR (
h
)
h
for the volume of a cone is equal to
For a right angled triangle, if the sum of the lengths of the hypotenuse and a side is kept constant, in order to have maximum area of the triangle, the angle between the hypotenuse and the side is (A) 12 (C) 60 (B) 36 (D) 45
EE – 2009 8. f(x, y) is a continuous function defined over (x, y) [0, 1] [0, 1]. Given the two constraints, x > and y > , the volume under f(x, y) is (A) ∫
∫
(B) ∫
∫
(C) ∫
∫
9.
10.
√
11.
∫
√
(
)
(
)
( √
a minimum a discontinuity a point of inflection a maximum
Divergence of the three-dimensional radial vector field is (A) 3 (C) ̂ ̂ ̂ (B) 1/r (D) ̂ ( ̂ ̂)
13.
The value of the quantity P, where ∫ (A) 0 (B) 1
, is equal to (C) e (D) 1/e
EE – 2011 14. The two vectors [1, 1, 1] and [1, a, where a = . (A) (B) (C) (D)
)
A cubic polynomial with real coefficients (A) can possibly have no extrema and no zero crossings (B) may have up to three extrema and upto 2 zero crossings (C) cannot have more than two extrema and more than three zero crossings (D) will always have an equal number of extrema and zero crossings
has
12.
) (
At t = 0, the function ( ) (A) (B) (C) (D)
(C) (1/2) o (D) (1/2)
EE – 2008 7. Consider function f(x)= ( ) where x is a real number. Then the function has (A) only one minimum (B) only two minima (C) three minima (D) three maxima
(D) ∫
Mathematics
15.
√
],
/, are
orthonormal orthogonal parallel collinear
The function f(x) = 2x – has (A) a maxima at x = 1 and a minima at x=5 (B) a maxima at x = 1 and a minima at x= 5 (C) only a maxima at x = 1 (D) only a minima at x = 1
EE – 2013 16. Given a vector field , the line integral
F(x, y) = ( )̂ ( )̂ ’ line integral over the straight line from ( ) = (0, 2) to ( ) = (2, 0) evaluates to (A) –8 (C) 8 (B) 4 (D) 0
evaluated along a segment on the x∫ axis from x = 1 to x = 2 is (A) 2.33 (C) 2.33 (B) 0 (D) 7 17.
th
The curl of the gradient of the scalar field defined by (A) th
( ) Where f and v are scalar and vector fields respectively. If h is (A) (B) (C) (D)
24.
The minimum value of the function ( ) 0 in the interval , - is (A) 20 (C) 16 (B) 28 (D) 32
)
)
EE – 2014 18. Let ( ) . The maximum value of the function in the interval ( ) is (A) (C) (B) (D) The line integral of function , in the counterclockwise direction, along the circle is (A) π (C) π (B) π (D) π Minimum of the real valued function ( ) occurs at x equal to ( ) (A) (C) 1 (B) (D)
IN – 2005 1. A scalar field is given by f = x2/3 + y2/3, where x and y are the Cartesian coordinates. The derivative of f along the line y = x directed away from the origin, at the point (8, 8) is
To evaluate the double integral ∫ .∫
( ⁄ )
.
/
substitution u = (
/ dy, we make the ) and
2.
)
( ) ∫ (∫
)
( ) ∫ (∫
)
( ) ∫ (∫
)
(A)
√
(B)
√
(A) (B) 0 3.
√
∫ ( )
is
(C) f(1) (D) f(0)
The value of the integral ∫ (A) 2 (B) does not exist
(C) (D)
is 2
̅(t) has a constant magnitude, If a vector R then
4.
A particle, starting from origin at t = 0 s, is traveling along x-axis with velocity π π o . /
(D)
√
f(t) defined over [0,1],
̅ (A) R 22.
(C)
Given a real-valued continuous function
. The
integral will reduce to ( ) ∫ (∫
Mathematics
̅ (B) R 5.
̅
̅
̅ R ̅ (C) R ̅
̅ (D) R
̅ R
̅
If f = + …… + where ai (i = 0 to n) are constants,
At t = 3 s, the difference between the distance covered by the particle and the magnitude of displacement from the origin is _________
The plot of a function f(x) is shown in the following figure. A possible expression for the function f(x) is f(x)
(B) once differentiable but not twice (C) twice differentiable but not thrice (D) thrice differentiable 11.
x
0 (A)
(
)
(C)
(
(B)
. /
(D)
. /
)
IN – 2006 7. The function ( ) is approximated as where is in radian. The maximum value of for which the error due to the approximation is within (A) 0.1 rad (C) 0.3 rad (B) 0.2 rad (D) 0.4 rad
()
( )∫
(A) (
()
(
))
(B) (
()
(
))
(
()
(
))
(
()
(
))
()
(
(D) (
(
)
(
) ( )
( )) ( ))
13.
The expression (A) – (B) x
14.
Given y =
(A) √π⁄ (B) √π 10.
(C) Π (D) π⁄
Consider the function f(x) = , where x is real. Then the function f(x) at x = 0 is (A) continuous but not differentiable
+ 2x + 10, the value of
|
(C) 12 (D) 13
15. (A) Indeterminate (B) 0
(C) 1 (D)
IN – 2009 16. A sphere of unit radius is centered at the origin. The unit normal at a point (x, y, z) on the surface of the sphere is (A) (x, y, z) (C) . /
IN – 2007 9. The value of the integral dx dy is.
√
for x > 0 is equal to (C) (D)
is equal to (A) 0 (B) 4
(B) .
∫ ∫
(C) (D)
is.
IN – 2008 12. Consider the function y = x2 6x + 9. The maximum value of y obtained when x varies over the interval 2 to 5 is (A) 1 (C) 4 (B) 3 (D) 9
The solution of the integral equation ()
(C)
For real x, the maximum value of (A) 1 (B) e 1
1
8.
Mathematics
√
√
√
/
(D) .
√
√
√
√
√
√
/
IN – 2010 17. The electric charge density in the region R: is given as σ( ) , where x and y are in meters. The total charge (in coulomb) contained in the region R is (A) π (C) π⁄ (B) π (D) 0 th
A scalar valued function is defined as ( ) , where A is a symmetric positive definite matrix with dimension n× n ; b and x are vectors of dimension n×1. The minimum value of ( ) will occur when x equals ) (A) ( (C) . / ) (B) – ( (D)
24.
Given ()
(
()
o .
(C) 1.5 (D) 0
The infinite series ( )
…………
converges to (A) cos (x) (B) sin(x)
(C) sinh(x) (D)
IN – 2011 20.
The series ∑ for (A) (B)
(
)
Mathematics
π) π
π /
The o w (A) A circle (B) A multi-loop closed curve (C) Hyperbola (D) An ellipse
converges
(C) (D)
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 ̂ ̂ ̂ ̂ are unit vectors in Where ̂ ̂ 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________
Since, potential function of ⃗ is x²yz ( ) ( ) ( ) 2.
0 o
1
[Ans. A]
[Ans. D] o
h
π h
π o
(
√
0
9.
[Ans. B]
10.
[Ans. B] (
)
For V to be max
)
This is of the form . /
Hence, h
Applying L hospital rule (
3.
√
1
)
[Ans. A]
. /
= (
)
|
|
|
|
= = 11.
4.
[Ans. A] (
After changing order ∫ ∫ 5.
[Ans. A] I= ∫ (
)
=2∫
[ ∫
[Ans. B] Let the vectors be
) ( )(⃗ )(⃗ )
]
= 2∫ 6.
[Ans. A] A Line integral and a surface integral is connected by stokes theorem
7.
[Ans. B]
Now Area vector will be perpendicular to plane of i.e. will be the required unit vector. And option (A), (D) cannot give a vector product )| |(⃗ ⃗ ) (⃗ 12.
[Ans. B] Since interval given is bounded, so minimum value of functions is 1.
= 0
(
)
)
)
Now by partial fractions, (a3 8) = (a 2)(a2+2a+4)
) |
⇒L=
[Ans. D] To see whether the integrals are bounded or unbounded, we need to see that the o ’ h h interval of integration. Let us write down the range of the integrands in the 4 options, Thus, (D) , i.e., ∫ [Ans. B] h
19.
o
o
o Φ (
Φ)
̂
̂ ). (
̂
( ̂
( )
(
( )
)
( )
( )
Coefficient of (x- )⁴ Now f(x)= ex ⇒ (x)= ex ⇒ (a)= ea ( )
Hence for a=2, 20.
⃗⃗
[Ans. D] div {( (
Hence directional derivative is (grad (x2+2y2+z)).
=
[Ans. C] Taylor series expansion of f(x) about a is given by ( )
[Ans. A] Short method: Take a point on the curve z = 1, x = 0, y=0 Length between origin and this point ) ( ) ( ) =1 √( This is minimum length because all options have length greater than 1.
[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
34.
[Ans. B]
[Ans. C]
1
1
2
y is continuous for all x differentiable for all x since at
o
o
R, and R, except at
o
,
Using this standard limit, here a = 1 then = ( ) /2 =1/2
’ h
value towards the left and right side of
35.
[Ans. D] ( ) ( ) ( ) ( ) f(x) has a point of inflection at x =0.
√ √ The unit outward normal vector at point P is (
Mathematics
)
∭(
(Surface Integral is transformed to volume Integral)
)
( )
( )
( )
)̂
√ ̂
)
∭(
∭
[Ans. A] The area enclosed is shown below as shaded
π π
(
∬( ̅ ̂)
)
)
∭(
( π) (
)
The coordinates of point P and Q is obtained by solving y = x and y = simultaneously, i.e. x = ) ⇒ ( ⇒ Now, x = 0 ⇒ which is point Q(0,0) and x = 1 ⇒ which is point P(1,1) So required area is
[Ans. D] Since the position of rail engine S(t) is continuous and differentiable function according to Lagrange’s mean value theorem more )
(
o ) o
∫(
w
∫
(t) = v(t) =
(
π * (
( )
π
π π
√
| π
√
√
)
√
)
)+
+
)
m/sec kmph
4.
[Ans. C] f = 2 +3
= 126 kmph Where v(t) is the velocity of the rail engine. 3.
∫
∫
(
-
= 2y
=∫
=
∫
)
’ h o I= ∫
)
, ∫
= xy
)
(
)
)
⇒
R
Here I = ∮ (
2.
Mathematics
[Ans. D] h ’ o h r=2acos (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 y Q π 3
[Ans. A] Define g(x) = f(x) – f(x + 1) in [0, 1]. g(0) is negative and g(1) is positive. By intermediate value theorem there is €( ) h h g(y) = 0 That is f(y) = f(y + 1) 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 o ∫
∫
*
+ [
]
,
-(
o π
, f(x) =
For x = , f(x) = 3 – 1 = 2 For x = 3, f(x) = 2 ( ) ( ) = f(3)
d2f x = 2 ve dx2 So it shows only minima for interval [ 4, 4], it contains a maximum value that will be at x= 4 or x=4 f( 4)=18 and f(+4)=10
[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 A.M. >= GM => exp(x) + exp( x) ≥ 2 Hence minimum value = 2
17.
[Ans. B]
∫
[ |
13.
16.
| ]
[Ans. B] Let f(x) ex sinx o ’ 2 x a f x f a x a f'a f''a 2!
Q
where, a= 2 x f x f x f' f'' 2!
Now at x = 2 (2) = ( ) = ( ) = 2 <0 At x = 2 we have a maxima.
[Ans. *] Range 6.8 to 7.2 ⃗ ̂ ̂ ̂ ̂
̂
=
̂
̂
̂
3.
=∫
[Ans. *] Range 2.99 to 3.01 √
⃗
√
)
√
(
(
)
)̂
At (1, 1), ⃗
√
(̂
Given unit vector, ̂
(
√
√
)̂
(̂
√
√
.
-
,
-
/
[Ans. D]
5.
[Ans. D] We consider options (A) and (D) only because which contains variable r. By integrating (D), we get π , which is volume of cone.
6.
[Ans. D] By property of definite integral
̂ ) ̂ )
=3
) ∫ ( ) ∫ ( π On simplification we get option (D)
[Ans. C] Grad u = ̂
⁄
At (1, 3) Grad u = √
,( ⁄ )
7.
[Ans. B] f(x) = ( ) (x) = 2( ) =4x( ) =0 x = 0, x = 2 and x = 2 are the stationary points. (x) = 4[x(2x) +( ) ] = 4[2 = 4 [3 = 12 (0) = < 0, maxima at x = 0 (2) =(12) = 32 > 0, minima at x = ( 2) =12( ) = 32 > 0; minima at x = There is only one maxima and only two minima for this function.
-
=√ 2.
,
4.
̂ )
So, directional derivative ⇒ ⃗ ̂ (̂ ̂ ) (̂
EE 1.
1
[Ans. C]
=
(
0
̂
At (1, 1, 1) ⃗ |⃗ | √
35.
Mathematics
[Ans. A] f(x) = (x) = ( ) = ( ) Putting ( (x) = 0 ( )=0 ( )=0 x = 0 or x = 2 are the stationary points. Now, ( ) ( (x) = )( ) = ( ( )) = ( ) ( )=2 At x = 0, (0) = Since (x) = 2 is > 0 at x = 0 we have a minima. th
[Ans. A] ̅ (t) =x (t) ̂+y (t) + Let R ̂ z (t) ̂ ̅( ) =K (constant) |R i.e., (t) + (t) + (t) = constant. On analyzing the given (A) option, we find ̅(t) that R
̅( )
⇒ ⇒
[Ans. C] Given : f= + where,
(
)
⇒
√
will give constant magnitude, √
1
G …… + (i=0 to n) are constant.
=
+(n 1)
o
…… ⇒
+ and
)
o
so first differentiation of the integration will be zero. 5.
Data Structure and Algorithm Analysis CS- 2005 1. Suppose T (n) = 2T (n/2) + n, T(0) = T(1)=1. Which one of the following is FALSE? (A) T(n) = O(n2) (B) T(n) = (n log n) (C) T(n) = Ω(n2) (D) T(n) = O(n log n) Linked Data Questions 2 and 3. Consider the following C- function: double foo(int n) { int i; double sum; if (n = = 0) return 1.0; else { sum = 0.0; for( i=0; i < n; i++) sum += foo(i); return sum; }} 2.
3.
4.
The space complexity of the above function is (A) O(1) (C) O(n!) (B) O(n) (D) Suppose we modify the above function foo( ) and store the values of foo(i), 0 < = I < n, as and when they are computed. With this modification, the time complexity for function foo( ) is significantly reduced. The space complexity of the modified function would be: (A) O(1) (C) O(n2) (B) O(n) (D) O(n!)
5.
What does the following C-statement declare? int(*f) (int *); (A) A function that takes an integer pointer as argument and returns an integer (B) A function that takes an integer pointer as argument and returns an integer pointer (C) A pointer to a function that takes an integer pointer as argument and returns an integer (D) A function that takes an integer pointer as argument returns a function pointer
6.
An Abstract Data Type (ADT) is (A) Same as an abstract class (B) A data type that cannot be instantiated (C) A data type for which only the operations defined on it can be used, but none else (D) All of the above
7.
A common property of logic programming languages and functional languages is (A) both are procedural language (B) both are based on - l ulus (C) both are declarative (D) both use Horn-clauses
8.
Which of the following are essential features of an object-oriented programming language? 1. Abstraction and encapsulation 2. Strictly-typedness 3. Types-safe property coupled with sub-type rule 4. Polymorphism in the presence of inheritance (A) 1 and 2 only (C) 1, 2 and 4 only (B) 1 and 4 only (D) 1, 3 and 4 only
The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be (A) O(n) (C) O(n3/2) (B) O(n log n) (D) O(n3)
Consider the following C-program double foo (double);/* Line 1 */ int main () { double da, db; // input da db = foo(da);} double foo(double a){ return a; } The above code complied without any error or warning. If Line 1 is deleted, the above code will show (A) no compile warning or error (B) some complier-warnings not leading to unintended results (C) Some complier-warnings due to type-mismatch eventually leading to unintended results (D) Complier errors Consider the following C-program void foo (int n,int sum 0) { int k = 0, j = 0; if (n = = 0) return; k = n % 10; j = n / 10; sum = sum + k; foo (j, sum); print “% d”, k ; } int main () { int a = 2048, sum = 0; foo(a, sum); printf “%d\n” sum ; } What does the above program print? (A) 8, 4, 0, 2, 14 (B) 8, 4, 0, 2, 0 (C) 2, 0, 4, 8, 14 (D) 2, 0, 4, 8, 0 A program P reads in 500 integers in the range [0, 100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be
DSA
the best way for P to score the frequencies? (A) An array of 50 numbers (B) An array of 100 numbers (C) An array of 500 numbers (D) A dynamically allocated array of 550 numbers Linked data Questions Q 12 & Q 13 We are given 9 tasks are , , , . The execution of each task requires one unit of time. We can execute one task at a time. has a profit and a deadline profit is earned if the task is completed before the end of the unit of time. Task Profit Deadline 15 7 20 2 30 5 18 3 18 4 10 5 23 2 16 7 25 3 12.
Are all tasks completed in the schedule that gives maximum profit? (A) All tasks are completed (B) nd are left out (C) nd are left out (D) nd are left out
13.
What is maximum profit earned? (A) 147 (C) 167 (B) 165 (D) 175
CS- 2006 14. Consider the polynomial p(x) = a0 + a1x + a2x2 + a3x3,where ai 0, i. The minimum number of multiplications needed to evaluate p on an input x is (A) 3 (C) 6 (B) 4 (D) 9 th
An element in an array X is called a leader if it is greater than all elements to the right of it in X. The best algorithm to find all leaders in an array. (A) Solves it in linear time using a left to right pass of the array (B) Solves in linear time using a right to left pass of the array (C) Solves it is using divide and conquer in time n log n (D) Solves it in time n2)
16.
Consider the following C program fragment in which i, j and n are integer variables. for (i = n, j = 0; i > 0; i / = 2, j +=i); Let Val (j) denotes the value stored in the variable j after termination of the for loop. Which one of the following is true? (A) Val (j) = (log n) (B) Val (j) = (√n) (C) Val (j) = (n) (D) Val (j) = (n log n)
17.
A set X can be represented by an array x[n] as follows ; if i X x [i] = { ; , otherwise Consider the following algorithm in which x, y and z are boolean arrays of size n: algorithm zzz (x[], y[], z[]) { int i; for ( i =0; i < n; ++i) z[i] =( x[i] ~ y[i]) (~x[i] y[i])
(A) n = (B) n = (C) n = (D) T (n) =
(log log n) (log n) (√n) (n)
19.
Consider the following code written in a pass-by-reference language like FORTAN and these statements about the code. Subroutine swap (ix,iy) it = ix L1 : ix = iy L2 : iy = it end ia = 3 ib = 8 call swap (ia, ib + 5) print *, ia, ib end S1: The compiler will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the cell to swap S2: On execution the code will generate a runtime error on line L1 S3: On execution the code will generate a runtime error on line L2 S4: The program will print 13 and 8 S5: The program will print 13 and 2 Exactly the following set of statement (s) is correct: (A) S1 and S2 (C) S3 (B) S1 and S4 (D) S1 and S5
20.
Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c [n + m] be another integer array. void xyz (int a[ ], int b[ ], int c[ ]) { int i, j, k; i = j = k = 0; while ((i
} The set Z computed by the algorithm is (A) ( X Y ) (B) ( X Y ) (C) ( X – Y ) ( Y – X ) (D) ( X – Y ) ( Y – X ) 18.
DSA
Consider the following T (n) = 2T ([√n])+ 1, T(1) = 1 Which one of the following is true?
hold (s) after the termination of the while loop? (i) j < m, k = n + j – 1, and a [n – 1] < b [j] if i = n (ii) i < n, k = m+i– 1, and b [m – 1] if j = m (A) Only (i) (B) Only (ii) (C) Either (i) or (ii) but not both (D) Neither (i) nor (ii) 21.
22.
Consider this C code to swap integers and these five statements : the code void swap (int *px, int *py) { *px = *px *py; *py = *px + *py; *px = *py *px; } S1: will generate a compilation error S2: may generate a segmentation fault at runtime depending on the arguments passed S3: Correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the process S4: implements the swap procedure correctly for some but not all valid input pointers S5: may add or subtract integers and pointers (A) S1 (C) S2 and S4 (B) S2 and S3 (D) S2 and S5
DSA
CS- 2007 23. In the following C function , let n m, int gcd(n, m) { if (n % m == 0) return m; n = n % m; return gcd(m, n); } How many recursive calls are made by this function? (A) log n (C) (log log n) (B) Ω(n) (D) (√n ) 24.
What is the time complexity of the following recursive function? int DoSomething ( int n ) { if ( n < = 2 ) return 1; else return (DoSomething (floor(sqrt(n))) + n); } (A) (n2) (B) (n log2 n) (C) (log2 n) (D) (log2 log2 n)
25.
Consider the following C code segment : int IsPrime(n) { int i, n; for (i =2; i < = sqrt(n); i++) { if (n % i == 0) { printf “Not Prime \n” ; return ; } } return 1; } Let T(n) denote the number of times the for loop is executed by the program on input n.Which of the following is TRUE? (A) T (n) = O √n nd n = √n (B) T (n) = O √n nd n = (C) n = O n nd n = √n (D) None of the above
Given two arrays of numbers , , and , , where each number is 0 or 1, the fastest algorithm to find the largest span (i, j) such that = , or report that there is no such span, (A) Takes O( and time if hashing is permitted (B) Takes O(n and n time in the key comparison model (C) Takes n time and space (D) Takes O √n time only if the sum of the 2n elements is an even number th
Consider the following C function: int f(int n) { static int r=0; if(n<=0) return 1; if(n>3) { r = n; return f(n 2)+2; } return f(n 1)+r; } What is the value of f(5)? (A) 5 (C) 9 (B) 7 (D) 18
27.
An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is true about the number of comparisons needed? (A) At least n comparisons, for some constant c, are needed (B) At most n comparisons are needed. (C) At least n log n comparisons are needed (D) None of the above
28.
Consider the following segment of C-code int j, n; j=1; while (j<=n) j=j*2; The number of comparisons made in the execution of the loop for any n>0 is (A) log n (C) log n (B) n (D) log n
DSA
order. What will be the contents of the list after the function completes execution? struct node { int value; struct node * next;}; void rearrange (struct node *list) { struct node *p, *q; int temp; if (!list || !list next) return; p = list; q = list next; while (q) { temp = p value; p value = q value; q value = temp; p = q next; q = p ? p next: 0; } } (A) 1, 2, 3, 4, 5, 6, 7 (B) 2, 1, 4, 3, 6, 5, 7 (C) 1, 3, 2, 5, 4, 7, 6 (D) 2, 3, 4, 5, 6, 7, 1 30.
The minimum number of comparisons required to determine, if an integer appears more than n/2 times in a sorted array of n integers is (A) n) (C) (1) (B) (log n) (D) (log n)
31.
Consider the following functions: f(n) = g(n) = n! h(n) = Which of the following statements about the asymptotic behavior of f(n), g(n) and h(n) is true? (A) f(n) = O(g(n)); g(n) = O(h(n)) (B) f n = g n ; g n = O h n (C) g(n) = O(f(n)); h(n) = O(f(n)) (D) h(n) = O(f(n)); g(n) = f n
CS- 2008 29. The following C function takes a singlylinked 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
Common data for Questions 32 & 33 Consider the following C functions: int f1(int n) { if (n == 0 || n == 1) return n; else return (2*f1( n – 1 ) + 3 * f1(n – 2)); } int f2(int n) { int i; int X[n], Y[n], Z[n]; X[0] = Y[0] = Z[0] =0; X[1] = 1; Y[1] = 2; Z[1] =3; for ( i = 2; i < = n; i++ ) { X[i] = Y[i – 1] + Z[ i – 2 ]; Y[i] = 2 * X[i]; Z[i] = 3 * X[i]; } return X[n]; } 32.
33.
5. k = ( i + j)/2; 6. if (Y[k] < x) i = k; else j = k; 7. } while ((Y[k] != x) && (i < j)); 8. if Y k == x printf “x is in the rr y” ; 9 else printf “x is not in the rr y” ; 10. } 34.
On which of the following contents of Y and x does the program fail? (A) Y is [ 1 2 3 4 5 6 7 8 9 10] and x < 10. (B) Y is [ 1 3 5 7 9 11 13 15 17 19] and x < 1. (C) Y is [ 2 2 2 2 2 2 2 2 2 2 ] and x > 2. (D) Y is [ 2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even.
35.
The correction needed in the program to make it work properly is (A) change line 6 to : if (Y[k])
36.
When n = for some k 0, the recurrence relation T(n) = √ T(n / 2) + √n , T (1) = 1 evaluates to (A) √n (log n +1) (C) √n log √n (B) √n log n (D) n log √n
37.
Arrange the following function increasing asymptotic order:
The running time of f1(n) and f2(n) are (A) (n) and (n) (B) (C) (n) and ( ) (D) ( ) and ( ) f1(8) and f2(8) return the values (A) 1661 and 1640 (B) 59 and 59 (C) 1640 and 1640 (D) 1640 and 1661 Statement for the Linked Answer Questions 34 & 35 Consider the following C program that attempts to locate an element x in an array Y [ ] using binary search. The program is erroneous. 1. f(int Y[10], int x) { 2. int i, j, k; 3. i = 0; j = 9; 4. do {
Which combination of the integer variables x, y and z makes the variable a get the value 4 in the following expression? a = (x > y) ? ((x > z) ? x : z) : ((y>z) ? y : z) (A) x = , y = , z = (B) x = , y = , z = (C) x = , y = , z = (D) x = , y = , z = What is printed by the following C program ? int f(int x, int *py, int ** ppz) { int y, z; **ppz + = 1; z = *ppz; *py + = 2; y = *py; x + = 3; return x + y + z; } void main( ) { int c, *b, **a; c = 4; b = &c; a = & b; printf “%d”, f , , ; } (A) 18 (C) 21 (B) 19 (D) 22
DSA
(B) ? is = get h r ? 2 is getchar (c) (C) ? is ! =’\n’ ? 2 is putchar (c); (D) ? is = get h r ? 2 is putchar (c); CS- 2009 41. The running time represented by the relation: n T(n)={ ( ) n
! = ‘\n’
! = ‘\n’
of an algorithm is following recurrence n otherwise
Which one of the following represents the time complexity of the algorithm? (A) (n) (C) n (B) (n log n) (D) n logn 42.
Choose the correct option to fill ?1 and ?2 so that program below prints an input string in the reverse order .Assume that the input string is terminated by a new line character. void reverse(void){ int c; if(?1)reverse ( ); ?2 } main( ){ printf “enter text” ; printf “\n” ; reverse ;printf “\n” ; } (A) ? is get h r != ‘\n’ ? 2 is getchar (c); th
Consider the program below: #include int fun (int n, int *f_p) { int t, f; if ( n<= 1) { *fp = 1 ; return 1 ; } t = fun n ,f p ; f = t+ * f_p ; *fp = t; return f ; } int main( ) { int x = 15 ; printf “%d\n”, fun , &x ; return 0; } The value printed is (A) 6 (C) 14 (B) 8 (D) 15
CS- 2010 43. What does the following program print? # include void f ( int *p, int *q) { p = q; *p = 2; } int i = 0, j = 1 ; int main ( ) { f( &i, &j); printf “%d %d\n”, i, j ; return 0; } (A) 2 2 (C) 0 1 (B) 2 1 (D) 0 2 44.
45.
What is the value printed by the following C program? # include int f(int *a, int n) { if (n < = 0 ) return 0; else if (*a % 2 = = 0 ) return *a + f (a + 1, n – 1) ; else return *a – f (a + 1, n – 1); } int main ( ) { int a [ ] = {12, 7, 13, 4, 11, 6} ; printf “%d”, f , ; return 0; } (A) 9 (C) 15 (B) 5 (D) 19
DSA
Node *move_to_front (Node *head) { Node *p, *q; if((head = = NULL)|| (head next = = NULL)) return head; q = NULL; p = head; while (p next ! = NULL) { q = p; p=p next; } _______________ return head; } Chose the correct alternative to replace the blank line. (A) q = NULL; p next = head; head = p; (B) q next = NULL; head = p; p next = head; (C) head = p ; p next = q; q next = NULL; (D) q next = NULL; p next = head; head = p; 46.
The following C function takes a singlylinked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank. typedef struct node { int value; struct node *next; } Node;
th
The following program is to be tested for statement coverage: begin if(a = = b) {S1; exit;} else if(c = = d) {S2;} else {S3; exit;} S4; end. The test cases T1, T2, T3 and T4 given below are expressed in terms of the properties satisfied by the values of variables a, b, c and d. The exact values are not given. T1: a, b, c and d are all equal T2: a, b, c and d are all distinct T3: a = b and c != d T4: a! = b and c = d Which of the test given below ensures coverage of statements S1, S2, S3 and S4? (A) T1, T2, T3 (C) T3, T4 (B) T2, T4 (D) T1, T2, T4
CS- 2011 Common Data for Question 47 and 48: Consider the following recursive C function that takes two arguments. unsigned int foo (unsigned int n, unsigned int r) { if (n>0)return ((n%r)+foo (n/r, r)); else return 0; } 47.
What is the return value of the function foo when it is called as foo (345, 10)? (A) 345 (C) 5 (B) 12 (D) 3
48.
What is the return value of the function foo when it is called as foo (513,2)? (A) 9 (C) 5 (B) 8 (D) 2
49.
Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3 and f4? f1 (n)=2n f2 (n)=n3/2 f3 (n)=n log2n f4 (n)=n (A) f3,f2,f4,f1 (C) f2,f3,f1,f4 (B) f3,f2,f1,f4 (D) f2,f3,f4,f1
50.
Which does the following program print? h rt = “GATE ”; char *p = c; printf % s, p p p (A) GATE2011 (C) (B) E2011 (D)
51.
fragment of C
pqr + rst + prt. When multiplied as ( ) , the total number of scalar multiplications is pqr+ prs + pst. If p = 10, q = 100, r = 20, s = 5 and t = 80, then the minimum number of scalar multiplications needed is (A) 248000 (C) 19000 (B) 44000 (D) 25000 CS- 2012 52. What will be the output of the following C program segment? ch r inCh r = ‘A’ ; switch (inChar) { case ‘A’ :printf “Choice A\ n” ; c se ‘B’ : c se ‘C’ : printf “Choi e B” ; c se ‘D’ : c se ‘E’ : def ult : print f “No Choi e” ; } (A) No choice (B) Choice A (C) Choice A Choice B No choice (D) Program gives no output as it is erroneous 53.
Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE? (A) A n = W n (B) A n = W n (C) A (n) = O (W(n)) (D) A (n) = o (W(n))
54.
The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is (A) T(n) = 2T(n 2) + 2 (B) T(n) = 2T(n 1) + n (C) T(n) = 2T(n/2) + 1 (D) T(n) = 2T(n 1) + 1
; 2011 011
Four matrices , , nd of dimensions p q, q r, r s nd s t respectively can be multiplied with several ways with different number of total scalar multiplications. For example when multiplied as ( ), the total number of scalar multiplications is
Common Data for Question 55 and 56: Consider the following C code segment. int a, b, c = 0; void prtFun (void) ; main ( ) {static int a =1; /* line 1 */ prtFun ( ); a + = 1; prtFun ( ); printf “ \n %d %d “ , , ; } void prtFun (void) {static int a = 2; /* line 2 */ int b = 1; a + = ++b; printf “ \n %d %d “ , , ; } 55.
DSA
End A1 Procedure A2; V r Procedure A21; V r Call A1; End A21 Call A21; End A2 Call A1; End main; Consider the calling chain: m in A A A A The correct set of activation records along with their access links is given by (A) (A)
Main
What output will be generated by the given code segment? (A)
A1 A2
(C)
A21
(B)
FRAME POINTER
(D)
A1
ACCESS LINKS
(B)
56.
What output will be generated by the given code segment if: Line 1 is replaced by auto int a = 1; Line 2 is replaced by register int a = 2; (A)
Main A1 A2
(C)
A21
(B)
FRAME POINTER
(D)
A1
ACCESS LINKS
(C)
57.
Main
Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted Program main; V r Procedure A1; V r Call A2;
323 gm. Then the product of the labels of the bags having 11 gm coins is _________.
Main A1 A2
61.
The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is ____________
62.
Which one of the following correctly determines the solution of the recurrence relation with T(1) = 1?
A21 FRAME POINTER
A1
ACCESS LINKS
n = CS- 2013 58. Consider the following function; int unknown (int n){ int i, j, k=0 for (i =n/2; i<=n; i++) for (j=2; j<=n; j=j*2) k=k+n/2; return (k ) ; } The return value of the function is (A) n ) (C) n (B) n log n (D) n log n 59.
(A) (B)
log n
n n log n
(C) (D)
n ) log n
63.
Consider two strings A = “qpqrr” nd B = “pqprqrp” Let x e the length of the longest common subsequence (not necessarily contiguous) between A and B and let y be the number of such longest common subsequences between A and B. Then x + 10y = _________.
64.
Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the value at the leaves, the maximum possible value of the expression represented by the tree is _________.
What is the return value of f(p,p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second 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 (B) 6561 (D) 161051
CS- 2014 60. There are 5 bags labeled 1 to 5. All the coins in a given bag have the same weight. Some bags have coins of weight 10 gm, others have coins of weight 11 gm. I pick 1, 2, 4, 8, 16 coins respectively from bags 1 to 5. Their total weight comes out to
( )
+ +
+
+
0/1
65.
th
0/1 0/1
0/1 0/1
0/1 0/1
0/1
Which of the following statements are CORRECT? 1) Static allocation of all data areas by a compiler makes it impossible to implement recursion. 2) Automatic garbage collection is essential to implement recursion. th
Dynamic allocation of activation records is essential to implement recursion. 4) Both heap and stack are essential to implement recursion (A) 1 and 2 only (C) 3 and 4 only (B) 2 and 3 only (D) 1 and 3 only 66.
Suppose you want to move from 0 to 100 on the number line. In each step, you either move right by a unit distance or you take a shortcut. A shortcut is simply a pre-specified pair of integers i, j with i< j. Given a shortcut i, j if you are at position i on the number line, you may directly move to j. Suppose T(k) denotes the smallest number of steps needed to move from k to 100. Suppose further that there is at most 1 shortcut involving any number, and in particular from 9 there is a shortcut to 15. Let y and z be such that T(9) = 1 + min(T(y), T(z)). Then the value of the product yz is _____.
67.
Consider the following program in C language: #include main() { int i; int *pi = &i; s nf “%d”,pi ; printf “%d\n”, i ; } Which one of the following statements is TRUE? (A) Compilation fails. (B) Execution results in a run-time error. (C) On execution, the value printed is 5 more than the address of variable i. (D) On execution, the value printed is 5 more than the integer value entered.
DSA
68.
Consider the following C function in which size is the number of elements in the array E: int MyX (int *E, unsigned int size) { int Y = 0; int Z; int i, j, k; for(i = 0; i < size; i++) Y = Y + E[i]; for(i = 0; i < size; i++) for(j = i; j < size; j++) { Z = 0; for(k = i; k <= j; k++) Z = Z + E[k]; if (Z > Y) Y = Z; } return Y; } The value returned by the function MyX is the (A) maximum possible sum of elements in any sub-array of array E. (B) maximum element in any sub-array of array E. (C) sum of the maximum elements in all possible sub-arrays of array E. (D) the sum of all the elements in the array E.
69.
Consider the following pseudo code. What is the total number of multiplications to be performed? D=2 for i = 1 to n do for j = i to n do for k = j + 1 to n do D=D*3 (A) Half of the product of the 3 consecutive integers. (B) One-third of the product of the 3 consecutive integers. (C) One-sixth of the product of the 3 consecutive integers. (D) None of the above.
Consider the function func shown below: int func(int num) { int count = 0; while (num) { count++; num>>= 1; } return (count); } The value returned by func(435)is __________.
71.
Suppose n and p are unsigned int variables in a C program. We wish to set p to C . If n is large, which one of the following statements is most likely to set p correctly? (A) p = n n n ; (B) p = n n n ; (C) p = n n n ; (D) p = n n n ;
72.
For a C program accessing X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits. t = i t = j t = k t = t t t = t t t = Xt Which one of the following statements about the source code for the C program is CORRECT? (A) X is de l red s “int X 8” (B) X is de l red s “int X ” (C) X is de l red s “ h r X 8” (D) X is de l red s “ h r X ”
73.
DSA
Give a value q (to 2 decimals) such that f (q) will return q: ___________. 74.
Consider the C function given below. int f(int j) { static int i = 50; int k; if (i == j) { printf “something” ; k = f(i); return 0; } else return 0; } Which one of the following is TRUE? (A) The function returns 0 for all values of j. (B) The function prints the string something for all values of j. (C) The function returns 0 when j = 50. (D) The function will exhaust the runtime stack or run into an infinite loop when j = 50.
75.
Let A be a square matrix of size n × n. Consider the following pseudocode. What is the expected output? c = 100; for i = 1 to n do for j = 1 to n do { Temp = A[i] [j] + c; A [i] [j] = A[j] [i]; A [j] [i] = Temp – c; } for i = 1 to n do for j = 1 to n do output (A [i] [j]); (A) The matrix A itself (B) Transpose of the matrix A (C) Adding 100 to the upper diagonal elements and subtracting 100 from lower diagonal elements of A (D) None of the above
Consider the following function double f (double x) { if (abs (x*x – 3) < 0.01) return x; else return f (x/2 + 1.5/x); } th
Consider the C function given below. Assume that the array listA contains n(>0) elements, sorted in ascending order. int ProcessArray(int *listA, int x, int n) { int i, j, k; i = 0; j = n 1; do { k = (i+j)/2; if (x <= listA[k]) j = k 1; if (listA[k] <= x) i = k+1; }while (i <= j);
DSA
if (listA[k] == x) return(k); else return ; } Which one of the following statements about the function ProcessArray is CORRECT? (A) It will run into an infinite loop when x is not in list A. (B) It is an implementation of binary search. (C) It will always find the maximum element in list A. (D) It will return even when x is present in list A.
Answer Keys and Explanations 1.
[Ans. C] n = n n By M ster’s method, = , = n
=n
f n = (n
[Ans. B] It would require n rr y of size ‘n’ to store temporary results. 0< = I
4.
[Ans. D] The time complexity of computing the transitive closure of a binary relation on a set of n elements is O(n3). Apply the w rsh ll’s algorithm to compute the transitive closure. The algorithm contains three nested for loops each having frequency n so time complexity is O(n3)
5.
[Ans. C] int (*f) (int *); returns type int, (*f) is a pointer to a function and the argument is (int *), an integer pointer. So, int (*f) (int *) means a pointer to a function that takes an integer pointer as an argument and returns an integer.
=n )
n = (n logn) = nlogn So, it is also O nlogn & O n but not n 2.
3.
[Ans. C] double foo (int n) { int i ; double sum ; if (n ==0)return; else {sum = 0; for (i = 0 ; i
th
[Ans. C] The abstract data type (ADT) refers to a programmer defined data type together with a set of operations that can be performed on that data So, the choice (C) is correct.
7.
[Ans. C] A common property of logic programming languages and functional languages is both are declarative because we declare any statement before we will use it.
8.
[Ans. B] Properties of object – oriented Programming language - Abstraction - Inheritance - Polymorphism - Encapsulation
9.
[Ans. C] When we don’t de l re fun tion spe ify the prototype), the default rule is that the function (foo in our case) would have been assumed to be int, even though it really returns a double. This will generate compiler warning and our program will have undefined behavior. [Ans. D] The function foo is recursive function When we call foo(a, sum) = foo (2048, 0) k j sum k = 2048%10 j = 204 sum = 0+8 = 8 = foo(204, 8) k = 204%10 = 4 j = 20 sum = 8+4 = 12 foo(20, 12) k = 20%10 = 0 j=2 sum = 12+0 = 12 foo(2,12) k = 2%10 = 2 j=0 sum = 12+2 = 14 foo(0,14) function will be terminated and value of k will print in stack way i.e. 2, 0, 4, 8. Value of sum as computed within the fun tion foo is From s it is ‘ ll y value’ parameter passing, the change
DSA
made inside the called function foo will not be reflected back in the calling function main. So, from main, value 0 will be printed as sum 11.
[Ans. A] There are 500 students and the score range is 0 to 100. We need to print the frequency of those students whose score is above 50. So frequency range contains scores from 50 to 100, so an array of 50 numbers is suitable for representing the frequency.
12.
[Ans. D] The given problem is job scheduling problem 9 tasks are , , , . J is initially empty then according to deadlines it includes { , , , , , , }. So nd n’t e in lude in J
13.
[Ans. A] Total profit earned by an algorithm = 8 =
14.
[Ans. A] Use the Hornor algorithm. 1st iter a3*x ----------------- 1 multiplication 2nd iter (a2 + a3*x)*x ----------------- 1 multiplication 3rd iter (a1 + (a2 + a3*x)*x)*x ------ 1 multiplication 4th iter a0 + (a1 + (a2 + a3*x)*x)*x
15.
[Ans. B] Scan each element from right to left. Make First element as largest element. If any other larger elements found, then mark it as leader element & make this element as largest element. Repeat above steps for rest of the elements
[Ans. C] Given i < n, j < m and a [i] < b[j] for this a[n – 1] < b[j] So if i
21.
[Ans. B] S2 and S3 are correct statements.
22.
[Ans. C] If each and is either 0 or 1 and the numbers are stored in an array then the algorithm can find the largest span (i, j) on average in n time because this is only need of search.
23.
[Ans. A] Just draw the recursion tree for some value of n and m. You will observe that the height of this tree never going to be more than logn.
24.
[Ans. D] Get the recurrence relation initially and solving it will give you the order. T(n) = T(√n) + n O(log log n)
25.
[Ans. B] T(n) = O √n quite clear as loop will run for √n in worst case if number is prime number. However if number is divisible by , , et ) then loop will run only for one iteration. That means number of iterations is varied from 1, √n . Thus B is the answer.
If n is not a power of 2 , then there will be minor differences of 1 at wherever is odd. Hence the Val (j) computed on the basis of n = will give a fair answer j=n GP n (( )
)
=
17.
18.
19.
=
n
[Ans. D] The statement inside the similar to X – OR operation set o t ined is X Y X It is equivalent to (X – Y
for loop is such that the Y Y – X ).
[Ans. B] n = ([√n]) ; = m = logn = en me S m = S m = S m S m = m ording to master's theorem So, S m = logn s m = logn
DSA
[Ans. B] Sw p ix i iy i
8
S1: The compiler will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the cell to swap S4: The program will print ia = 13 and ib = 8 Option (B) is correct.
[Ans. D] To compute f(5), initially r=5. f = 8 n :f n f
=
f n
r
f
=
f n
r
f
=
f n
r
1 27.
30.
[Ans. C] To find an integer appears more than n/2 times minimum comparisons are of order just check first,last and middle element and 1/4 ,3/4 index element
31.
[Ans. D] So we need to identify the correct order of relative growth rates of the given functions Either we use L hospital rule to compute the above or we may simplify the functions so that growth rate can be proved with obvious reasons. h(n) can be written in form of as follows: h(n) = The following is the growth rates in increasing order, h(n) < f(n) < g(n). Thus D is the answer.
32.
[Ans. B] Function f1 contain recursive function so its running time must be O(2n) but f2 have not. Alternately f1 has complexity of O(2n), while f2 has a loop from 2 to N , so the complexity of it is O(n)
33.
[Ans. C] When solved . f = f = f f = f f = f . . . f 8 = Now for f , x = y x = y In loop x = y x = y
n
[Ans. B] When we apply the divide and conquer method such that dived n into two parts of n/2 then recurrence equations is T(n) = 1 for n = 2 T(n) = 2T(n/2)+2 for n > 2 The solution of T(n) is n = n =
28.
29.
n
omp risons
[Ans. D] Let the increment of j is , , , , for some value of i so according to the question for while loop: n or i log n One extra comparison required for the termination of while loop. So total number of comparisons =i = log n
DSA
[Ans. B] If there are even number of nodes in the linked list , given program interchanges 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 unchanged, all other nodes values are interchanged as given in program. Current values are 1,2,3,4,5,6,7 After interchange 2,1,4,3,6,5,7 th
[Ans. C] In C option when we give x =4 (say )the working is as follows. I iteration k = (0+9)/2=4 (y[4]
= log √ = f n n √n = = √n
. . x8 = 34.
DSA
h n =
n =
, Where i =0
n = log n n =f n n = √n log n 37.
[Ans. C] Here, n< n log9 n< en So
n
n
n log n
e
e n log n
n
Fig. Plot of function values
38.
[Ans. A] a= (x > y) ? ((x > z) ? x : z) : ((y>z) ? y : z) In C “? : “ is tern ry oper tor the synt x is (exp 1 ? exp2 : exp3). It means if exp 1 is true print exp2 else exp3. Let x = 3, y = 4, z = 2. = ?( ? ): ((4 > 2) ? 4 : 2) a = (3 > 4) ? 3 : 4 a=4
39.
[Ans. B] f(c, b, a ) is called by the main () function the graphical execution of the program is given below.
in f
[Ans. A] T(n)= √ n⁄ √n T(1)=1 Comparing it with T(n) = aT (n/b) +f(n) We get , a= √ ; = ; f n = √n
int y, z; ppz = ppz ; z = ppz = ; py = py ; y = py = x= = return x y z = 9 40.
41.
[Ans. D] Here we re using the ‘=’ oper tor whi h h s less priority th n ‘! =’ oper tor So (C = getchar( ) ) has to be in brackets and reversing the string we use function putchar(c) for printing the character.
43.
[Ans. D] i, j variables are global to main function p and q will also be pointing to same memory location where i and j respectively, when f (& i , & j) is called up. Now p = q statement will move p to the memory location being pointed by q Thus, * p = 2 will replace 1 by 2. There is no change in the value of variable i (which is still 0);
44.
[Ans. C] a [ ]= 12
[Ans. A] Complexity is decided for large values of n only. So, T(n) = T( )+ cn for n>3.
[Ans. B] x = 15 fun , &x fun
7
13
4
11
6
So , first this call Thus the number stored in the array & we can access these by using f ,
Using ster’s theorem, Here, a=1, b=3, log = log = f n = n= n Sin e log = n is elow f n = n his elongs to se III of m ster s theorem, Where the solution is n = (f n ) = n 42.
DSA
so
f f
,n f
,n
f
let &x =
,n f
{odd} {odd} {even}
,n f
{even}
,n
,
{odd} {even}
, t = 5, return 8
f = 5+3, *f_p = 5
t = 3, return 5
f = 3+2, *f_p = 3
t = 2, return 3
f = 2+1, *f_p = 2
t = 1, return 2
f =1+ 1, *f_p = 1
=
fun ,
=
fun ,
=
*
*
[
*
[
[
]+] ]+ ]+
= =
fun ,
fun ,
[
45.
[Ans. D]
*f_p = 1
q
p
return 1 So fun (5, &x) will return 8 and it will be printed.
When ‘while’ loop is over, the st tes of p and q variables are as given in the diagram. Now node q will become last node, hus, q next = NULL will e required Since, p is inserting in the front of the list p next = he d is required nd p e ome first node of the modified list hence head = p is required for the successful operation. 46.
[Ans. D] In given program we take the test cases and apply From If all values are equal means a = b = c = d, a = b condition satisfied. S1 and S4 executed From When all a, b, c, d distinct: S , S not execute, S and executes. From When a = b, S execute but c = d. S will not execute but S and S executes. Here no need of because we get these result from above two. From If a! = b and c = d, S will not execute and S and S execute. All of S , S , S , S will execute and covered by , nd .
[Ans. C] p = E p = A p –p = p p –p = p It prints the su string of “GA E starting at index 4.
”
51.
[Ans. C] We get minimum number of multiplications ((M1 (M2 M3)) M4). Total number of multiplications = 8 = 9
52.
[Ans. C] Switch statement case A matches initially and all other cases are executed from there on as there is no ‘Bre k’ in ses Output C Choi e A Choice B No Choice There is no break in between the case statements.
53.
[Ans. C] Avg case running time always less than (or) equal to worst case Time. A n =O w n By definition of asymptotic notation. Average lies always between the best and the worst case inclusive.
to k. Return Value = no of outer loops n n = ( ) logn
OH , , L,
n
[Ans. C] If any variable is static, then it retains its v lue ross fun tion lls V ri le ‘ ’ in ptrFun is static and local, so the update of this variable is available across different invocations of function ptrFun, but as it is a local variable its update will not affect the value of variable a present in main. Uninitialized global variables have 0 as their default value.
56.
[Ans. D] If the variables are auto, these variables will be reinitialized in every function calls. Now the variables are all auto storage class. Their lifetime is local.
57.
[Ans. D]
[Ans. B] f(5, 5) { c = 4; x = 6; return f(6, 4) * x; } f(6 , 4){ c = 3; x = 7; return f(7, 3) * x; } f(7, 3) { c = 2; x = 8; f( 8, 2) * x } f(8, 2) { c=1; x=9; f(9, 1) * x; } f (9,1){ c = 0; return 1; }when c=1, x=9 So, 9* 9 * 9 * 9 = 6561
60.
[Ans. 12] No. of coins picked having 10 gm weight = 18 No. of coins picked having 11 gm weight = 13 1 + 4 + 8 = 13 (Bag no. 1, 3, 4 are having 11 gm coins) So =
A1 A2 A21 ACCESS LINKS
Given calling sequence from the program is: main A A A A A1 & A2 are defined in main, so A1 & A2 access links are pointed to main A21 definition is available in A2, hence A21 access link points to A2 58.
[Ans. *] Range 147.1 to 148.1 If we use comparison in pair method then no. of comparisons will be
3.
(
4.
)
If n = 100 then = = 62.
8
n ( )
[Ans. 150] From 9 you can go to either 10 or 15 (shortcut) So T(9) = 1 + min (T(10), T(15)) So y = 10, z = 15 or y = 15, z = 10 So yz = 150
67.
[Ans. D] Statement s nf “% d”, & i ; and s nf “% d”, pi ; are equivalent, because, of the statement int *pi = & i; So execution of the program will print 5 more than the integer value entered
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.
69.
[Ans. C] Let n=4 When i=1; j=1: number of multiplications: 3 When i=1; j=2; number of multiplications: 2 When i=1; j=3; number of multiplications: 1 When i=1; j=4; number of multiplications: 0
logn
By ster’s method, = , = So, log =1 So, = n log So, se of m ster’s theorem pplies T(n)= (n) 63.
[Ans. 34] x=4 A = qpqrr B = pqpr qrp B = pqprqrp B = pqp rqrp y=3 So x + 10y = 4 + (10 × 3) = 34
64.
[Ans. 6] + + +
+
1
1 2
0
1
1
0 1
1
1 2
= =3+3=6 65.
Dynamic allocation of activation records is mandatory of recursion implementation (TRUE). Heap & stack are not mandatory for recursion implementation 1 and 3 are correct.
66.
[Ans. A] n =
DSA
[Ans. D] 1. Recursion cannot be implemented with only static allocation (TRUE) 2. Garbage collection is not essential for recursion implementation th
When i=2; j=2: number of multiplications: 2 When i=2; j=3: number of multiplications: 1 When i=2; j=4: number of multiplications: 0 When i=3; j=3: number of multiplications: 1 When i=3; j=4: number of multiplications: 0 When i=4; j=4: number of multiplications: 0 Total number of multiplications: 10 The 3 consecutive numbers are: 3,4,5 One-sixth of product of 3 consecutive numbers is: )/6 = 60/6 = 10 70.
71.
[Ans. 9] num = num me ns divide num er y . while : count = 1; num = 217 while : count = 2; num = 108 while 8 : count = 3; num = 56 while : count = 4; num = 27 while : count = 5; num = 13 while : count = 6; num = 6 while : count = 7; num = 3 while : count = 8; num = 1 while : count = 9; num = 0 while meout of loop Count = 9
This expression works only when n is small (ii) C is also wrong because in left to right evaluate on n n may not give exact integer. It may be fractional value. But C – language ignores fractional part and multiples it with (n – 2) then divided by 2. So it will not give correct result. (iii) B is correct. n(n – 1) will be divided by 2 exactly because n or (n – 1) is even; then multiply with (n – 2) then divide by 3. 72.
[Ans. A] Three address code to access arr [n] t = size of word t =t n t = rr t In given ode in question t =i It is equivalent to t = t =i t So the rr y is de l red s ‘int’ nd first index is of 32 size So Option (A) is correct
73.
[Ans. *] Range 1.72 to 1.74 f(q) must give q So f(x) must give x if condition must be tree ie abs (x * x – 3) < 0.01 So x must be almost equal to 3 x=
74.
[Ans. D] When j = 50 i = j printf statement executes; k = f (50) So j = 50 again and the recursion continues for ever. untime stack exhaust & it will run into infinite loop.
[Ans. B] p=n
= =
n n
n n
n n
n ! !
DSA
!
n
But all the 4 options give the same expression as above (i) A & D are wrong because, it is given that n is large so the multiplication of n n– n result is must also be unsigned int and its result will be very large & cannot fit in unsigned int variable.
[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)
Stacks and Queues CS-2005 1. A function f defined on stacks of integers satisfies the following properties. f(ф) = 0 and f(push(S, i)) = max (f(S), 0) + i for all stacks S and integers i. If a stack S contains the integers 2, 3, 2, 1, 2 in order from bottom to top, what is f(S)? (A) 6 (C) 3 (B) 4 (D) 2
CS-2007 3. The following postfix expression with single digit operand is evaluated using a stack 8 2 3 ^ / 2 3 * + 5 1 * Note that ^ is the exponentiation operator. The top elements of the stack after the first * is evaluated are (A) 6, 1 (C) 3, 2 (B) 5, 7 (D) 1, 5
CS-2006 2. An implementation of a queue Q, using two stacks S1 and S2, is given below void insert(Q, x) { push (S1,x); } void delete (Q) { if (stack-empty(S2)) then if (stack-empty(S1)) then { printf(“Q is empty”); return; } else while(!stack-empty (S1)) { x = pop (S1); push (S2, x); } x = pop (S2); } Let n insert and m ( n) delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n? (A) n + m x < 2n and 2m y n+m (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
4.
Suppose you are given an implementation of a queue of integers. The Operations that can be performed on the queue are: i. isEmpty(Q) – returns true if the queue is empty, false otherwise. ii. delete (Q) – deletes the element at the front of the queue & returns its value . iii. insert (Q , i ) – insert the integer i at the rear of the queue. Consider the following function: void f (queue Q) { int i; if (! isEmpty (Q)) { i = delete (Q); f(Q); insert (Q, i) ; } } What operation is performed by the above function f? (A) Leaves the queue Q unchanged (B) Reverses the order of the elements in the queue Q (C) Deletes the elements at the front of the queue Q & inserts it at the rear keeping the other elements in the same order. (D) Empties the queue Q
CS-2012 5. Suppose a circular queue of capacity (n 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are (A) full: (REAR+1) mod n = = FRONT empty: REAR = = FRONT (B) full: (REAR+1) mod N = = FRONT empty: (FRONT+1) mod n = = REAR (C) full: REAR = = FRONT empty: (REAR+1) mod n = = FRONT (D) full: (FRONT+1) mod n = = REAR empty: REAR = = FRONT CS-2013 6. Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter. MultiDequeue (Q){ m = k; while (Q is not empty) and (m >0) { Dequeue (Q) m=m–1 } } What is the worst case time complexity of a sequence of n queue operations on an initially empty queue? (A) (n) (C) (n ) (n ) (B) (D) (n )
DSA
CS-2014 7. Suppose a stack implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack? (A) A queue cannot be implemented using this stack. (B) A queue can be implemented where ENQUEUE takes a single instruction and DEQUEUE takes a sequence of two instructions. (C) A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction. (D) A queue can be implemented where both ENQUEUE and DEQUEUE take a single instruction each. 8.
The minimum number of arithmetic operations required to evaluate the polynomial P(X) = for a given value of X, using only one temporary variable is _________.
stack operation, the queue will be reversed at the end).
f(s) ma ma ma ma ma
(f(s) (f(s) (f(s) (f(s) (f(s)
0) 0) 0) 0) 0)
= (
)=
5.
= (
)= =
[Ans. A] So given condition can be specified as full: (REAR + 1) mod n = FRONT empty : REAR = FRONT FRONT
2.
3.
[Ans. A] The order in which insert and delete operations are performed matters here. The best case: insert and delete operations are performed alternatively. In every delete operation , 2 pop and 1 push operations are performed. So, total m+n push (n push for insert () and m push for delete ()) operations and 2m pop operations are performed. The worst case: First n elements are inserted and then m elements are deleted. In first delete operation, n+1 pop operations and n push operation are performed. Other than first, in all delete operations, 1 pop operation is performed. So, total m+n pop operations and 2n push operations are performed (n push for insert () and m push for delete ())
a
8 8
2
8
8
8
8
2
3
^ 2 ^3 =8
2
2
6
1
1
1
1
/ 8 8 =1
2
3
* 2 3 =6
e
f
g
queue full
6.
[Ans. A] Since the queue is empty initially, the condition of while loop never becomes true. So, for n operations, the time complexity is (n)
7.
[Ans. C] Queue can be implemented as below ENQUEUE: REVERSE; PUSH; REVERSE (3 instructions) DEQUEUE: pop (single instruction)
8.
[Ans. 7] ( )= an e e itten as fo o s ) P(x) = ( Now using only one temporary variable t and any number of data transfers as well as memory related operations, the polynomial can be evaluated as follows a. t = x * x [Evaluate and store in memory] b. t = t [Evaluate ( ) and store in memory] c. t = [Retrieve from memory] d. t = t * x [Evaluate and store in memory]
⟹ The top two elements are 6, 1 4.
d
FRONT/REAR
3
2
c
queue empty
[Ans. A] 3
b
REAR
[Ans. B] As the elements are deleted from front and inserted from the rear in the reverse order in which element are deleted (because of
t=t*( ) [Evaluate ( ) and store in memory] t=6*x [Evaluate 6x and store in memory] 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]
Trees CS-2005 1. How many distinct binary search trees can be created out of 4 distinct keys? (A) 5 (C) 24 (B) 14 (D) 42
If the height of the tree is h > 0, then the minimum number of nodes in the tree is: (A) (C) (D) 2h (B) 6.
2.
In a complete k-ary tree, every internal node has exactly k children. The number of leaves in such a tree with n internal nodes is (A) n k (C) n(k – 1) + 1 (B) (n – 1) k + 1 (D) n(k – 1)
3.
Postorder traversal of a given binary search tree, T produces the following sequence of keys 10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29 Which one of the following sequences of keys can be the result of an inorder traversal of the tree T? (A) 9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95 (B) 9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29 (C) 29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95 (D) 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29
4.
5.
A binary search tree contains the numbers 1, 2, 3, 4, 5, 6, 7, 8. When the tree is traversed in pre-order and the values in each node printed out, the sequence of values obtained is 5, 3, 1, 2, 4, 6, 8, 7. If the tree is traversed in post-order, the sequence obtained would be (A) 8, 7, 6, 5, 4, 3, 2, 1 (B) 1, 2, 3, 4, 8, 7, 6, 5 (C) 2, 1, 4, 3, 6, 7, 8, 5 (D) 2, 1, 4, 3, 7, 8, 6, 5
The numbers 1, … n are inserted in a binary search tree in some order. In the resulting tree, the right subtree of the root contains p nodes. The first number to be inserted in the tree must be (A) p (C) n p (B) p + 1 (D) n p + 1
CS-2006 7. A scheme for storing binary trees in an array X is as follows. Indexing of X starts at 1 instead of 0. The root is stored at X [1]. For a node stored at X[i], the left child, if any is stored in X [2i] and the right child, if any in X [2i + 1]. To be able to store any binary tree on n vertices, the minimum size of X should be (A) log2 n (C) 2n + 1 (B) n (D) 8.
Suppose that we have numbers between 1 and 100 in a binary search tree and want to search for the number 55. Which of the following sequences CANNOT be the sequence of nodes examined? (A) {10, 75, 64, 43, 60, 57, 55} (B) {90, 12, 68, 34, 62, 45, 55} (C) {9, 85, 47, 68, 43, 57, 55} (D) {79, 14, 72, 56, 16, 53, 55}
9.
In a binary tree, the number of internal nodes of degree 1 is 5 and the number of internal nodes of degree 2 is 10. The number of leaf nodes in the binary tree is (A) 10 (C) 12 (B) 11 (D) 15
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
CS-2007 10. Consider the following C program segment where Cell Node represents a node in a binary tree struct CellNode { struct CellNode * leftchild; int element; struct CellNode *rightchild; }; int GetValue (struct CellNode * ptr) { int value = 0; if(ptr != NULL) { if((ptr leftchild == NULL) && (ptr rightchild == NULL)) value =1; else value = value + GetValue(ptr leftchild) +GetValue(ptr rightchild); } return(value); } The value returned by GetValue when a pointer to the root of a binary tree is passed as its arguments is (A) The number of nodes in the tree (B) The number of internal nodes in the tree (C) The number of leaf nodes in the tree (D) The height of the tree 11.
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is (A) 2h (C) 2h+1 – 1 (D) (B)
12.
The maximum number of binary trees that can be formed with three unlabeled nodes is (A) 1 (C) 4 (B) 5 (D) 3
13.
The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e c f g respectively
DSA
The postorder traversal of the binary tree is (A) d e b f g c a (B) e d b g f c a (C) e d b f g c a (D) d e f g b c a 14.
A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41 and I = 10, what is the value of n? (A) 3 (C) 5 (B) 4 (D) 6
CS-2008 15. You are given the post-order traversal, P of a binary search tree on the n elements , , ……., n. You have to determine the unique binary search tree that has P as its post-order traversal. What is the time complexity of the most efficient algorithm for doing this? (A) (log n) (B) (n) (C) (n log n) (D) none of the above, as the tree cannot be uniquely determined 16.
th
The following three are known to be the preorder, in-order and post-order sequence of a binary tree. But it is not known which one is which binary tree. I. MBCAFHPYK II. KAMCBYPFH III. MABCKYFPH Pick the true statement from the following (A) I and II are preorder and inorder sequences, respectively (B) I and III are preorder and postorder sequences, respectively (C) II is the inorder sequence, but nothing more can be said about the other two sequences (D) II and III are the preorder and inorder sequences, respectively th
Common Data questions 17, 18 and 19: A Binary search Tree (BST) store value in the range 37 to 573. Consider the following sequences of keys. I. 81, 537,102,439,285,376,305 II. 52,97,121,195,242,381,472 III. 142,248,520,386,345,270,307 IV. 550,149,507,395,463,402,270
CS - 2011 21. We are given a set of n distinct elements and an unlabeled binary tree with n nodes. In how many ways we can populate the tree with the given set so that it becomes a binary search tree? (A) 0 (C) n! (B) 1 (D) .
Suppose the BST has been unsuccessfully searched for key 273. Which all of the above sequences list nodes in the order in which we could have encountered them in the search? (A) II and III only (B) I and III only (C) III and IV only (D) III only
CS-2012 22. The worst case running time to search for an element in a balanced binary search tree with n2n elements is (A) Θ(n log n) (C) Θ (n) (B) Θ (n n) (D) Θ (log n)
18.
Which of the following statements is TRUE? (A) I, II and IV are inorder sequences of three different BSTs (B) I is preorder sequence of some BST with 439 as the root (C) II is an inorder sequence of some BST where 121 is the root and 52 is a leaf (D) IV is a postorder sequence of some BST with 149 as the root
19.
How many distinct BSTs can be constructed with 3 distinct keys? (A) 4 (C) 6 (B) 5 (D) 9
23.
CS-2010 20. In a binary tree with n nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child? (A) 0 (C) (n 1)/2 (B) 1 (D) n 1
th
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudocode below is invoked as height (root) to compute the height of a binary tree rooted at the tree pointer root. int height (treeptr n) { if (n = = NULL) return 1; if(n left = = NULL) if (n right = = NULL) return 0; else return // Box 1 else { h1 = height (n left); if (n right = = NULL) return (1 + h1); else * h = height (n right); return ; //Box 2 } } } The appropriate expression for the two boxes Bl and B2 are (A) :( height(n right)) B2:(1 +max(hl,h2)) (B) : (height(n right)) B2 :(1+max(hl,h2)) (C) : height(n right) B2 : max(h1,h2) (D) :( height(n right)) B2: max (h1,h2)
CS-2013 24. The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 23, 25, 39, 35, 42. Which one the following is the postorder traversal sequence of the same tree? (A) 10, 20, 15, 23, 25, 35, 42, 39, 30 (B) 15, 10, 25, 23, 20, 42, 35, 39, 30 (C) 15, 20, 10, 23, 25, 42, 35, 39, 30 (D) 15, 10, 23, 25, 20, 35, 42, 39, 30 25.
Struct treeNode { treeptr leftMostChild, rightSibling; }; int DoSomething (treeptr tree) { int value=0; if (tree != NULL) { if (tree leftMostChild == NULL) value = 1; else value = DoSomething(tree leftMostChild); value = value + DoSomething(tree rightSibling); } return(value); } When the pointer to the root of a tree is passed as the argument to DoSomething, the value returned by the function corresponds to the (A) number of internal nodes in the tree. (B) height of the tree. (C) number of nodes without a right sibling in the tree. (D) number of leaf nodes in the tree.
Which one of the following is the tightest upper bound that represents the time complexity of the inserting an object into a binary search tree of n nodes? (A) O(1) (C) O(n) (B) O(log n) (D) O(n log n)
CS-2014 26. Consider the following rooted tree with the vertex labeled P as the root: P
Q
S
R
T
U
DSA
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;
be p numbers after x, because right subtree of root contains p nodes. x is n – p
=
[Ans. C] The number of internal nodes of a complete k- ary tree of height h is …… =
7.
[Ans. B] The root of the tree is stored at X [1] Left X[i] stored at X[2i] Right X[i] stored at X [2i+1] If tree is complete Binary tree minimum it require n consecutive memory locations of x, x[1],…..x[n 1], x[n].
8.
[Ans. C]
=n
) = n( Here is the number of leaves at height h 3.
4.
[Ans. A] 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
0
[Ans. D]
5 8
1
( ) Possible
4 7
2
[Ans. B] Draw the tree as per the definition and count the nodes. dif =2
dif =2 dif =0
dif =1
dif =2 dif =0
dif =1 dif =0
( ) not Possible
dif =2 dif =2 dif =2 dif =1
dif =0
( ) Possible
Because 43 is less than 47, but placed in right subtree of 47
dif =2 dif =0 dif =1 dif =0
6.
( ) possi le possible( ) Possible
6
3
5.
0
9.
[Ans. B] If a tree of height 4 will be down. In which at third level 3 nodes can have 2- children 5- nodes can have one children to fulfill the given requirement. No. of leaf nodes will be 11
[Ans. C] If we insert the number x, first it becomes the root of resulting B.S.T. There should
Second node in preorder is b, so again dividing, a
10 11
[Ans. C] The given routine will return the number of leaf nodes in the tree Since the function is recursive, the left child invoked function of a node will return number of leaves in left subtree, right child invoked function will return number of leaves in right subtree. Both will e added and returned ⇒ total number of leaves. [Ans. C] Maximum nodes in binary tree of height 0= 1= ( ) Maximum nodes in binary tree of height 1= 3= ( ) Maximum nodes in inary tree of height h=( )
b
13.
(
)
=
=
g
Postorder will be : d e b f g c a 14.
[Ans. C] For a complete n – ary tree where each node has n children or no children, following relation holds L = (n 1) *I +1, where L is the number of leaf nodes and I is the number of internal nodes. Let us find out the value of n for the given data : L = 41, I = 10 implies 41 = 10* (n ) n=
15.
[Ans. B] We have post order traversal and the tree is Binary Search tree. So, in order traversal of Binary Search Tree is sequence order , , ,………..,n. By using inorder, postorder can construct unique Binary Tree with in O (n) time.
16.
[Ans. D] 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.
Formula = =
e f
d
[Ans. B]
3 unlabeled nodes Possible Binary tress total = 5
c
=
[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,
273 is smaller than 395. So it should be searched in left subtree instead of going for 463.
I.
0
18.
0 ncorrect
Incorrect, 273 is smaller than 285. So, from 285, search should proceed in the left subtree
[Ans. C] (A) It is incorrect because in order sequence of BST gives sorted list in increasing order. (B) In preorder sequence of BST, root will be processed first. So 439 should be the first no in sequence. So it is not true (C) Corrrect. 121
II. 97
195
52
242 381 1
472
(D) Incorrect 149 root, then it should come at the end of sequence. But option C can be possible, where 97 is left child of root and 52 is left child of it. 52 will be leaf node
0
orrect .
19. 0
[Ans. B] Consider keys 3, 4, 5 3,4,5
3,4,5
3
3 4
3,4,5 5
4 5
0
3,4,5
5
3
3,4,5 5
3
4 4
4
3
5 0
orrect
V
Number of distinct BSTs: 5
0
20. 0
0 0
[Ans. A] 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 not possible in this tree structure. Hence, zero is right.
[Ans. C] Time = O (log2n 2n) = O (log n log ) = O (log ) = O (n)
23.
[Ans. A] E.g. h = max(0, 0) h = 0 , return max(h , h )
h = 0, h = 0
3
15
[Ans. C] Upper bound is O(n), because if the BST is skewed tree then time is equal to number of elements
26.
[Ans. A] Inorder traversal of m – ary tree: f T , T , ……, Tm are su trees then inorder traversal is visit (T1) visit (root) visit (T ,……,Tm) Follow inorder for T ,…..,Tm. According to this logic, inorder traversal of given tree is SQPTRWUV
27.
[Ans. D] At every node, if left sibiling = null, value =1 & it is added to Dosomething (right sibiling). If right sibiling = null then value = 0 is returned & it is added to value. Value = 1 + 0 = 1 It is counting number of leaf nodes.
0 Return ‘0’ Return ‘0’ another e.g.
(
right)
height(n right)) return ‘ ’
return 0,
Option ‘ ’ is correct y going through options. 24.
Height Balanced Trees (AVL Trees, B and CS-2008 1. A B-tree of order 4 is built from scratch by 10 successive insertions. What is the maximum number of node splitting operations that may take place? (A) 3 (C) 5 (B) 4 (D) 6 2.
6.
DSA
)
Suppose we have a balanced binary search tree T holding n numbers. We are given two numbers L and H and wish to sum up all the numbers in T that lie between L and H. Suppose there are m such numbers in T. If the tightest upper bound on the time to compute the sum is the value of a + 10b + 100c + 1000d is _______________.
Which of the following is TRUE? (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 _________.
[Ans. 1] To find subtrees from a tree of n nodes, it takes O(n) [Dynamic Programming] So ( ) a = 1 and b = 0 So a + 10 b = 1 + (10
A B – tree of order m contains n records and if each node contains b records on the ⌉ average then the tree has about ⌈ leaves. If we split k nodes along the path from leave then ⌈ ⁄ ⌉
6.
[Ans. 110] Out of n number of balanced binary search trees, to search for a number L in tree, the time required is = O(log n). 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
In given problem n = 10 , b =3, m=4 So ⌈ ⌉
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]
+ 0 1
+ + 1 1
1 + 1
0 0
4.
0) = 1
1 1 0 OR x hei ht → 3
1 0
0
[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
Priority Queues CS – 2005 1. A priority-Queue is implemented as a Max-Heap. Initially it is 5 elements. The level- order traversal of the heap is given below: 10, 8, 5, 3, 2. Two new elements ‘1’ and ‘7’ are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the element is (A) 10, 8, 7, 5, 3, 2, 1 (B) 10, 8, 7, 2, 3, 1, 5 (C) 10, 8, 7, 1, 2, 3, 5 (D) 10, 8, 7, 3, 2, 1, 5 2.
Suppose the elements 7, 2, 10 and 4 are inserted in that order into the valid 3-ary max heap found in the above question, Q.3. Which one of the following is the sequence of items in the array representing the resultant heap? (A) 10, 7, 9, 8, 3, 1, 5, 2, 6, 4 (B) 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 (C) 10, 9, 4, 5, 7, 6, 8, 2, 1, 3 (D) 10, 8, 6, 9, 7, 2, 3, 4, 1, 5 Common Data for Questions 5, 6, 7 An array X of n distinct integers is interpreted as a complete binary tree. The index of the first element of the array is 0.
Suppose there are ⌈lo n⌉ sorted lists of ⌊
⌋ elements each. The time complexity
of producing a sorted list of all these elements is: (Hint: Use a heap data structure) (A) O(n log log n) (C) (n log n) (B) (n log n) (D) (n3/2) CS – 2006 Statement for Linked answer-questions 3&4 A 3-ary max heap is like a binary max heap, but instead of two children, nodes have 3 children. A 3-ary heap can be represented by an array as follows: The root is stored in the first location, a[0], nodes in the next level, from left to right, is stored from a[1] to a[3]. The nodes from the second level of the tree from left to right are stored from a[4] location onward. An item x can be inserted into a 3-ary heap containing n items by placing x in the location a[n] and pushing it up the tree to satisfy the heap property. 3.
4.
Which one of the following is a valid sequence of elements in an array representing 3-ary max heap? (A) 1, 3, 5, 6, 8, 9 (C) 9, 3, 6, 8, 5, 1 (B) 9, 6, 3, 1, 8, 5 (D) 9, 5, 6, 8, 3, 1
5.
The index of the parent of element X [i] , i ≠0, is (A) ⌊i 2⌋ (C) ⌈i 2⌉ (B) ⌈ i 2 2⌉ (D) ⌈ ⌉ 1
6.
If only the root node does not satisfy the heap property, the algorithm to convert the complete binary tree into a heap has the best asymptotic time complexity of (A) O(n) (C) O(n log n) (B) O(log n) (D) O(n log log n)
7.
If the root is at level 0, the level of element X[i], i ≠0, is (A) ⌊lo i⌋ (C) ⌊lo i ⌈lo ⌉ (B) i 1 (D) ⌈lo i⌉
1 ⌋
8.
Which of the following sequences of array elements forms a heap? (A) {23, 17, 14, 6, 13, 10, 1, 12, 7, 5} (B) {23, 17, 14, 6, 13, 10, 1, 5, 7, 12} (C) {23, 17, 14, 7, 13, 10, 1, 5, 6, 12} (D) {23, 17, 14, 7, 13, 10, 1, 12, 5, 7}
9.
In a binary max heap counting n numbers the smallest element can be found in time (A) n (C) lo (B) lo lo n (D) 1 th
CS – 2007 10. Consider the process of inserting an element into a Max Heap, where the Max Heap is represented by an array. Suppose, we perform binary search on the path from the new leaf to the root to find the position for the newly inserted element, the number of comparisons performed is (A) (log2 n) (C) (n) (B) (log2 log2 n) (D) (n log2 n)
(A)
10
8
(B)
10
8
4
1
5
2
10
6
5
4
8
(D)
2
1
5
2
1
CS – 2011 14. A max-heap is a heap where the value of each parent is greater than or equal to value of its children. Which of the following is a max-heap?
6
(C)
Which one of the following array represents a binary max- heap? (A) {25, 12, 16, 13, 10, 8, 14} (B) {25, 14, 13, 16, 10, 8, 12} (C) {25, 14, 16, 13, 10, 8, 12} (D) {25, 14, 12, 13, 10, 8, 16} What is the content of the array after two delete operations on the correct answer to the previous question? (A) {14, 13, 12, 10, 8} (B) {14, 12, 13, 8, 10} (C) {14, 13, 8, 12, 10} (D) {14, 13, 12, 8, 10}
2
5 1
CS – 2009 Statement for linked answer Questions 12 & 13 Consider a binary max-heap implemented using an array
13.
6
4
CS – 2008 11. We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is (A) (log n) (C) (n log n) (B) (n) (D) (n2)
12.
DSA
8
4
10
6
CS - 2014 15. A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is: (A) 10, 8, 7, 3, 2, 1, 5 (B) 10, 8, 7, 2, 3, 1, 5 (C) 10, 8, 7, 1, 2, 3, 5 (D) 10, 8, 7, 5, 3, 2, 1 th
[Ans. A] After inserting 7, 2, 10, 4 the resultant heap become 10, 7,9, 8, 3, 1, 5, 2, 6, 4
8 2
3
1
10
root Heap after inserting 7 and heapify
10
7
9
8
7 8
3
2
1
3
5
5. 2.
1
2
5
6
4
[Ans. D] Complete binary tree ⇒ array representation
[Ans. A] The algorithm as follows: Prepare a heap of lists that means each node will have a list. And treat the first element as the key of each respective node. Perform deleteMin, which will return list whose first element is smallest among all. Then delete the current list first element and insert the same list now based on next list element. Perform these steps repeatedly until heap is empty completely. Preparing heap step will take O(logn) as there are logn list. Each deleteMin and insert will take O(loglogn) as the height of heap is O(loglogn). There will be n such operation. Thus, A is correct choice.
The index of parent element of x[1] =0 x[2] =0 x[3] =1 x[4] =1 x[5] =2 x[6] =2 i.e. for Index of the parent of x[i] ⇒ ⌈ 2⌉ 1 6.
[Ans. B] It is the complexity to adjust the tree to satisfy heap property that will be equal to the height of the tree. That is O(logn)
7.
[Ans. C] 0
2
3
7
4
8
Index min = (20 + 21+22+ 23 + ------------+ 21-1) since index starts with “0” Indexmin = 2
5
6
9 10 11 12 13 14 3 0 1
Level 1 = 2 = 21
2
1
The level ‘1’ will have at most 2 elements so indexmax will be Indexmax = 2 1 2 1 2 2 1 2 1 index 2 2 1 1 i=2 –1 When index is max ⇒i 1 21 log (21+1 – 2+1) ⇒ lo 2(i +1)= 1 = log 2(21+1 – 1)< 1 + 1 when index is min =1 So, to get value as an integer and equal to 1, we need to apply floor operator. ⇒ So, the expression level is ⌊lo 1 ⌋
evel 0 = 20
1
DSA
8.
[Ans. C] {23, 17, 14, 7, 13, 10, 1, 5, 6, 12}
Level 2 = 4 = 22
23 17
Level 3 = 8 = 23
14
15 16 17 18
Level 4 = 16 Maximum no. of nodes at level 1 is 21 = 24
Since elements are stored in an array To place an element at level ‘1’ we need to put (completely all possible) max possible elements at level “1-1” i.e. 21-1. i.e. if we have to put an elements at level 4 all the above 3 levels have max possible capacities. i.e.
7
5
6
10
1
12 Max heap
9.
[Ans. A] MAX heap used to identity max element in O (1) time. So, to identify min element require O (n), to apply the linear search.
10.
[Ans. A] Inserting an element into a max heap takes O(1) times. When we perform a binary search on the path from the new leaf to the root to find the position for the newly inserted element takes (log n) as expected.
level’0’ → 1 level’1’ → 2 level’2’ → 4
13
level’3’ → 8
So, the least index of an element at the level ‘1’ will be
[Ans. B] If we have a binary heap on n elements and we wish to insert n more elements then we call a recursive function to build heap which is responsible for constructing the heap The time spend by build heap is of the order of the sum of heights of all the vertices. But at most ⌈ 2 ⌉ vertices are of height i. so the total time spent by build heap is ∑
12.
n i 2
Delete 16: Replace it by 8
8
13
10
After heafying: 14
12
13 8
8
10
15.
[Ans. A] Level order traversal is: 10, 8, 5, 3, 2 So the tree will be
12
[Ans. D] Delete 25 : Replace it by 12
10
[Ans. B] The structure of a heap is near-complete binary tree. All levels except the last level must be completely full. Option A does not have this property, whereas options C and D violate max-heap property that every node must have higher value than it children.
16
14
12
10 5
8
16
14
3
13
= {14, 13, 12, 8, 10}
14.
25
13.
12
14
n
[Ans. C] In a max-heap, parent node should have value greater than or equal to both its children
Sorting Algorithms CS – 2006 1. Which one the following inplace sorting algorithms needs the minimum number of swaps? (A) Quick-sort (C) Selection sort (B) Insertion sort (D) Heap sort 2.
The median of n elements can be found in O(n) time. Which one of the following is correct about the complexity of quick sort, in which median is selected as pivot? (A) (n) (C) (n2) (B) (n log n) (D) (n3)
CS-2007 3. Which of the following sorting algorithms has the lowest worst case complexity? (A) Merge sort (C) Quick sort (B) Bubble sort (D) Selection sort CS-2008 4. Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required to sort n elements. Then (A) T(n) 2T (n/5) + n (B) T(n) T(n/5) + T(4n/5) + n (C) T(n) 2T (4n/5) + n (D) T(n) 2T (n/2) + n CS-2009 5. What is the number of swaps required to sort n elements using selection sort, in the worst case? (A) (n) (C) ( ) (B) (n log n) (D) ( g ) 6.
is the worst case time complexity of the quick sort? (A) (n) (C) ( ) (B) (n log n) (D) ( g ) CS-2011 7. An algorithm to find the length of the longest monotonically increasing sequence of number in an array A[0 :n 1] is given below. Let denote the length of the longest monotonically increasing sequence starting at index i in the array. Initialize F r a i such that 0 i 2 [i] [i ] if { ther ise Finally the length of the longest monotonically increasing sequence is Max( ) Which of the following statements is TRUE ? (A) The algorithm uses dynamic programming paradigm (B) The algorithm has a linear complexity and uses branch and bound paradigm (C) The algorithm has a non-linear polynomial complexity and uses branch and bound paradigm (D) The algorithm uses divide and conquer paradigm. CS-2012 8. A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is (A) O(n log n) (C) O (n2 + log n) (B) O(n2 log n) (D) O(n2)
CS-2013 9. Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort? (A) ( g ) (C) ( g ) (B) ( ) (D) ( ) 10.
The number of elements that can be s rted i Θ( g ) time usi g heap s rt is (A) Θ( ) (C) Θ ( ) (B) Θ(√ g )
DSA
12.
Suppose P, Q, R, S, T are sorted sequences having lengths 20,24,30,35,50 respectively. They are to be merged into a single sequence by merging together two sequences at a time. The number of comparisons that will be needed in the worst case by the optimal algorithm for doing this is ____.
13.
You have an array of n elements. Suppose you implement quicksort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is (C) Θ( g ) (A) O( ) (B) O(n log n) (D) O( )
(D) Θ( g )
CS-2014 11. Let P be a quick sort program to sort 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.
2.
[Ans. C] In selection sort, minimum number of swaps taken compared to other sorting techniques. No. of swaps = O(n) No. of comparisons = O( ) In every pass, it constructs sorted subarrays and places the next element in proper position in the sorted sub array. So, we need only 1 swap in every pass
records with key less than v appear in [ ] … [j 1] and all those with keys v r greater appear i [j ] … [ ] we then apply quicksort recursively to [ ] … A[j 1] a d [j ] … [ ] The recursion equation becomes for some value of i ( )
∑( (i
)
(
))
he s uti f the ( ) ( g ) But to calculate median every time [pass] it require at least (n2) time. Total time requireme t ( 2).
[Ans. C] If the median of n elements can be found 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
[Ans. B] Selection sort Selects the next big element and swaps with initial elements Comparisons – O ( ) Swaps – O(n)
10.
[Ans. C] If we have an array of x elements then time complexity to sort x elements using heap sort is (x g x). We need to find value of x so that time complexity to sort x elements gets ( g ) We can direct discard option (A) & (D). Now check option (C) g g [ g( )] g g g g
[Ans. B] If we want to sort n elements with the help of Quicksort algorithm. If pivot elements which split the list into two sublists each in which one list contains one fifth element or n/5 and other list contains 4n/5 and balancing takes n. So ( ) ( / ) (4 / ) [Note : n
5.
9. Worst case complexity (with n input) O(nlogn)
Bubble sort
g(
]
[Ans. A] In each pass there can be at most 1 swap. There are n such passes in selection sort i.e. maximum n swaps will happen in worst case. [Ans. B] The relation T(n) = T(n/4)+T(3n/4)+n The pivot element is selected in a such way that it will divide the array into 1/4th and 3/4th always solving this relation given (n log n).
7.
[Ans. A] The algorithm uses dynamic program paradigm.
8.
[Ans. B] In merge – sort algorithm no. of splits are proportional to height and in each level work done is . ∴ ta ime C mp exity ( log n)
DSA
g
[ ⏟
)
g g
( ( g ) ∴ pti (C) is c rrect
] )
11.
[Ans. C] First input [1 2 3 4 5 ] is the worst case of quicksort and it will require more no.of comparisons than input 2 [4 1 5 3 2]
12.
[Ans. 358] When we are merging two sorted lists of lengths m and n, the maximum number of comparisons will be m+n 1. Also the worst case merging is done by merging the two smallest length sequences. The given lengths of sequences are: L1:20, L2:24, L3:30, L4:35, L5:50. Step1: The number comparisons in merging sequences L1, L2 is ( 0 4 ) 4 (Sequence L6) Step2: The number comparisons in merging sequences L3, L4 is (30+35 1)=64 (sequence L7)
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
Graph Algorithms CS – 2005 1. An undirected graph G has n nodes. Its adjacency matrix is given by an n × n square matrix whose (i) diagonal elements are 0’s and (ii) non-diagonal elements are 1’s. Which one of the following is TRUE? (A) Graph G has no minimum spanning tree (MST). (B) Graph G has a unique MST of cost n – 1. (C) Graph G has multiple distinct MST’s, each of cost n – 1. (D) Graph G has multiple spanning trees of different costs.
5.
To implement Dijkstra’s shortest path algorithm on unweighted graphs so that it runs in linear time, then data structure to be used is (A) Queue (C) Heap (B) Stack (D) B-tree
6.
Consider the following graph: 2 b
d
4
1 1 a
2
3
3
f 5
6
2.
3.
Let G (V, E)be an undirected graph with positive edge weights. Dijkstra’s single source shortest path algorithm can be implemented using the binary heap data structure with time complexity? (A) O( |V|2 ) (B) O( |E| + |V| log|V|) (C) O(|V|log|V|) (D) O((|E| + |V|) log |V|) In a depth first traversal of a graph G with n vertices, k edges are marked as tree edges. The number of connected components in G is (A) k (C) n k – 1 (B) k + 1 (D) n – k
4
c
e
7
Which one of the following can’t be the sequence of edges added, in that order to a minimum spanning tree using Kruskal’s algorithm? (A) ( a – b), (d – f), (b – f), (d – c), (d – e) (B) ( a – b), (d – f), (d – c), (b – f), (d – e) (C) ( d – f), (a – b), (d – c), (b – f), (d – e) (D) ( d – f), (a – b), (b – f), (d – e), (d – c) 7.
Let T be a depth first search tree in an undirected graph G. Vertices u and v are leaves of this tree T. The degrees of both u and v in G are at least 2. Which one of the following statements is true? (A) There must exist a vertex w adjacent to both u and v in G (B) There must exist a vertex w whose removal disconnect u and v in G (C) There must exist a cycle in G containing u and v (D) There must exist a cycle in G containing u and all its neighbor in G
CS – 2006 4. Consider a weighted complete graph G on the vertex set {v1, v2, …. , vn} such that the weight of the edge (vi, vj) is 2| i – j|. The weight of a minimum spanning tree of G is (A) n – 1 (C) . / (B) 2n – 2 (D) n2
Consider the depth-first-search of an undirected graph with 3 vertices P, Q and R. Let discovery time d(u) represent the time instant when the vertex u is first visited and finish time f(u) represents the time instant when the vertex u is last visited. Given that d(P) = 5 units f(P) = 12 units d(Q) = 6 units f(Q) = 10 units d(R) = 14 units f(R) = 18 units Which one of the following statements is TRUE about the graph? (A) There is only one connected component (B) There are two connected components and P and R are connected (C) There are two connected components and Q and R are connected (D) There are two connected components and P and Q are connected
CS - 2007 9. In an unweighted, undirected connected graph, the shortest path from a node S to every other node is computed most efficiently, in terms of time complexity by (A) Dijkstra’s algorithm starting from S (B) Warshall’s algorithm (C) Performing a DFS starting from S (D) Performing a BFS starting from S 10.
What is the largest integer m such that every simple connected graph with n vertices & n edges contains at least m different spanning trees? (A) 1 (C) 3 (B) 2 (D) n
12.
DSA
Let be the minimum weight among all edge weights in an undirected connected graph. Let e be a specific edge of weight w. Which of the following is FALSE? (A) There is a minimum spanning tree containing e. (B) If e is not in minimum spanning tree T, then in the cycle formed by adding e to T, all edges have the same weight. (C) Every minimum spanning tree has an edge of weight . (D) e is present in every minimum spanning tree
Linked data for Q.13 & Q.14 Suppose the letters a, b, c, d, e, f have probabilities , , , 13.
14.
15.
,
,
respectively. Which of the following is the Huffman code for the letters a, b, c, d, e, f? (A) 0, 10, 110, 1110, 11110, 11111 (B) 11, 10, 011, 010, 001, 000 (C) 11, 10, 01, 001, 0001, 0000 (D) 110, 100, 010, 000, 001, 111 What is the average length of the correct answer to above question? (A) 3 (C) 2.25 (B) 2.1875 (D) 1.9375 Consider the DAG with V = {1, 2, 3, 4, 5, 6}, shown below 2
5
3
6
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 first time & f[u] the time at which the dfs call to the vertex u terminates. Which of the following statements is always true for all edges (u,v) in the graph? (A) d[u] < d[v] (C) f[u] < f[v] (B) d[u] < f[v] (D) f[u] > f[v]
Which of the following is NOT a topological Ordering? (A) 1 2 3 4 5 6 (B) 1 3 2 4 5 6 (C) 1 3 2 4 6 5 (D) 3 2 4 1 6 5 th
CS – 2008 16. The most efficient algorithm for finding the number of connected components in an undirected graph on n vertices and m edges has time complexity: (A) (n) (C) (m + n) (B) (m) (D) (mn) 17.
a
R
Q
(A) MNOPQR (B) NQMPOR
c
c
a
5
3
2 d
h
2
3 g
Dijkstra’s single source shortest path algorithm when run from vertex a in the above graph, computes the correct shortest path distance to (A) Only vertex a (B) Only vertices a, e, f, g, h (C) Only vertices a, b, c, d (D) All the vertices 19.
12
h
The subset-sum problem is defined as follows: Given a set S of n positive integers and a positive integer W, determine whether there is a subset of S whose elements sum to W. An algorithm Q solves this problem in O(nW) time. Which of the following statement is false? (A) Q solves the subset-sum problem in polynomial time when the input is encoded in unary. (B) Q solves the subset-sum problem in 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
f
1
e
8
21.
2
2
8
i
G is a graph on n vertices and 2n 2 edges. The edges of G can be partitioned into two edge-disjoint spanning trees. Which of the following is NOT true for G? (A) For every subset of k vertices, the induced sub graph has a most 2k 2 edges. (B) The minimum cut in G has a least two edges (C) There are two edges-disjoint paths between every pair of vertices (D) There are two vertex-disjoint paths between every pair of vertices
The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is M
DSA
For the undirected, weighted graph given below, which of the following sequences of edges represents a correct execution of Prim’s algorithm to construct a Minimum Spanning Tree?
Linked Answers Questions Q.22 and Q.23 The subset-sum problem is defined as follows. Given a set of n positive integers, S *a , a , a , . . . . . , a + and a positive integer W is there a subset S whose elements sum of W? A dynamic program for solving this problem uses a 2-dimensional Boolean array, X with n rows and W 1 columns X[i, j], 1 i n, 0 j W, is TRUE if and only if there is a subset of *a , a . . . . . , a + whose elements sum to j. Which of the following is valid for 2 i n and a j W ,i 1, j(A) ,i, j,i, j a ,i 1, j(B) ,i, j,i 1, j a ,i 1, j(C) ,i, j,i, j a ,i 1, j(D) ,i, j,i 1, j a -
Q. Finds whether any negative weighted cycle is reachable from the source. (A) P only (C) Both P and Q (B) Q only (D) Neither P nor Q
26.
Which entry of the array X, if TRUE, implies that there is a subset whose elements sum to W? (A) X[1, W] (C) X[n, W] (B) X[n, 0] (D) X[n 1, n]
CS – 2009 24. Consider the following graph:
a
2
b
5 4
6
d 5
6 6
e
5 3
g
27.
4 f c 6 c Which of the following is NOT the sequence of edges added to the minimum spanning tree using Kruskal’s algorithm (A) (b,e) (e,f) (a,c) (b,c) (f,g) (c,d) (B) (b,e) (e,f) (a,c) (f,g) (b,c) (c,d) (C) (b,e) (a,c) (e,f) (b,c) (f,g) (c,d) (D) (b,e) (e,f) (b,c) (a,c) (f,g) (c,d) 3
25.
DSA
Which of the following statement (s) is/are correct regarding Bellman-Ford shortest path algorithm? P. Always find a negative weighted cycle, if one exists.
th
Common Data for Question Q.26 and Q.27 A subsequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n, respectively , with indexes of X and Y starting from 0. We wish to find the length of the longest common subsequence (LCS) of X[m] and Y[n] as (m, n), where an incomplete recursive definition for the function (I, j) to compute the length of the LCS of X[m] and Y[n] is given below: (i, j) = 0, if either i = 0 or j = 0 = expr1, if i, j>0 and x[i 1] = ,j 1= expr2, if i, j>0 and x[i 1] ,j 1Which one of the following option is correct? (i 1, j) 1 (A) expr1 (i, j 1) (B) expr1 (C) expr2 max( (i 1, j), (i, j 1)) (D) expr2 max( (i 1, j 1), (i, j)) The values of (i, j) could be obtained by dynamic programming based on the correct recursive definition of (i, j) of the form given above, using an array L[M, N], where M = m + 1 and N = n + 1, such that L[I, j] = (i, j). Which of the following statements would be TRUE regarding the dynamic programming solution for the recursive definition of (i, j) ? (A) All elements of L should be initialized to 0 for the values of (i, j) to be properly computed (B) The values of (i, j) may be computed in a row major order or column major order of L[M, N]
(C) The values of (i, j) cannot be computed in either row major order or column major order of L[M, N] (D) L[p, q] needs to be computed before L [r, s] if either p < r or q < s 28.
the same. Let X denote the maximum possible weight of a subsequence of a , a , … , a and Y is the maximum possible weight of a subsequence of a , a … a . Then X is equal to (A) max( , a ) (B) max( , a 2) (C) max( , a 2 ) (D) a 2
Let be a problem that belongs to the class NP. Then which one of the following is TRUE? (A) There is no polynomial time algorithm for (B) If can be solved deterministically in polynomial time, then P = NP (C) If is NP-hard, then it is NP complete (D) may be undecidable
CS - 2011 Linked Answer Question Q.32 and Q.33 An undirected graph G(V, E) contains n(n>2) nodes named v , v , … , v . Two nodes v , v are connected if and only if 0<| i j | 2. Each edge (v , v ) is assigned a weight i + j. A sample graph with n = 4 is shown below. 7
CS – 2010 Common Data for Questions 29 and 30: 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}. 0 1 8 14 1 0 12 4 9 W = 8 12 0 7 3 1 4 7 02 [4 9 3 2 0] 29.
31.
32.
What is the minimum possible weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T? (A) 7 (C) 9 (B) 8 (D) 10 What is the minimum possible weight of a path P from vertex 1 to vertex 2 in this graph such that P contains at most 3 edges? (A) 7 (C) 9 (B) 8 (D) 10 The weight of a sequence a , a , … , a real numbers is defined as
5
4
33. 30.
DSA
of .A
subsequence of a sequence is obtained by deleting some elements from the sequence, keeping the order of the remaining elements
6
3 What will be the cost of the Minimum Spanning Tree (MST) of such a graph with n nodes? (C) 6n 11 (A) (11n 5n) (D) 2n 1 (B) n n 1 The length of the path from v to v in the MST of previous question with n = 10 is (A) 11 (C) 31 (B) 25 (D) 41
CS – 2012 34. Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijkstra’s shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is
updated only when a strictly shorter path to v is discovered.
3. If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A (A) 1, 2 and 3 (C) 2 and 3 only (B) 1 and 2 only (D) 1 and 3 only
2 2
1
G
1 4 S
1
4
7 D 4
3
3
3
5 5 T
(A) SDT (B) SBDT 35.
(C) SACDT (D) SACET
Let G be a weighted graph with edge weights greater than one and G be the graph constructed by squaring the weights of the edge in G. Let T and T be the minimum spanning trees of G and G respectively, with total weights t and t . Which of the following statements are TRUE? (A) T = T with total weight t = t (B) T = T with total weight t t (C) T T but total weight t t (D) None of the above
DSA
CS – 2014 38. Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time of Depth First Search on G, when G is represented as an adjacency matrix? (A) (n) (C) ( ) (B) (n m) (D) ( ) 39.
Suppose a polynomial time algorithm is discovered that correctly computes the largest clique in a given graph. In this scenario, which one of the following represents the correct venn diagram of the complexity classes P, NP and NP Complete (NPC)? (A)
NP P NPC
(B)
CS – 2013 36. What is the time complexity of Bellman – Ford single – source shortest path algorithm on a complete graph of n vertices? (A) ( ) (C) ( ) (B) ( log ) (D) ( log )
P
NP NPC
(C)
37.
Which of the following statements are TRUE? 1. The problem of determining whether there exists a cycle in an undirected graph is in P. 2. The problem of determining whether there exists a cycle in an undirected graph is in NP.
Consider the tree arcs of a BFS traversal from a source node W in an unweighted, connected, undirected graph. The tree T 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.
DSA
(C) Solvable in constant time since any input instance is satisfiable. (D) NP-hard, but not NP-complete.
[Ans. C] Use induction on the number of vertices. Consider 4 4 matrix and the corresponding graph G. 011 0 100 1 100 1 01 10 1 3 4 2
According to the question the weight of edge in G is | v1 – v2 |, | v2 –v3|, …….|v , v | is 1. In the case of minimum spanning tree of a graph G we will add upto (n – 1) vertices, so, the weight of a minimum spanning tree of G
This graph has more than one minimum spanning trees that are structurally different and each of them will have cost 3. 2.
[Ans. D] In Dijkstra’s algorithm for single – source shortest path when we implement the algorithm using the binary heap data structure then total updates of E edges require O(logv) time and total spent time becomes O(|E|log|V|) but of |E| is much less than |V|2 then time O(E+ V) log V
3.
[Ans. D] If k edges are marked as tree edges then k + 1 vertices are connected to each other. That means n – k 1 vertices are not connected with any of k + 1 vertices. Now we can maximize number of components only if all n – k – 1 vertices are isolated. Therefore, n – k – 1 + 1 = n – k This 1 is for the component having k+1 vertices
4.
∑ 2|
|
2∑|
|
2 ∑|1| 2|n 2(n
1| 1)
2n
2
5.
[Ans. C] Heap or priority queue are very neat data structures allowing : Add an element to heap with an associated priority. Remove the element from the heap or priority queue that has the highest priority, and return it. Peak at the element with highest priority without removing it. A simple way to implement a heap or priority queue data type is to keep a list of elements, and search through the list for the highest priority which taken O(n) time to implement Dijkstra’s shortest path algorithm on unweighted graph.
6.
[Ans. D] In the Kruskal’s algorithm we will start with the edge with minimum weight and add the edges in non-decreasng order if it does not form a cycle. (A) (a b), (d f), (b f), (d c), (d, e) 1 + 1 + 2 + 2 + 3 =9 (B) (a b), (d f), (d c), (b f), (d, e) 1 + 1 + 2 + 2 + 3 =9
[Ans. B] Given vertex set of G = {v1 , v2 , ……, vn} Weight of an edge = 2 |i j| : (vi , vj) ϵ G
(C) (d f), (a b), (d c), (b f), (d, e) 1 + 1 + 2 + 2 + 3 =9 (D) (d f), (a b), (b f), (d e), (d c) 1 + 1 + 2 + 3 + 2 =9 In choice (D), we add (d e) before (d c) which violets the algorithm. 7.
[Ans. D] Let the node u has some ‘n’ adjacent nodes, numbered 1 to n. In that case, to make u as a leaf node of the tree. ⇒ We must discover all the adjacent nodes of (u) first and next come to (u) ⇒ In that process let us say we have first discovered the node (1) [Each of the nodes 1, 2, 3 ……….. n must be of at least 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] ⇒ fter discovering the first adjacent node , we have to go on discovering nodes except u till al the adjacent nodes of u are discovered.
1
2
9.
[Ans. D] In an unweighted graph performing a BFS starting from S takes O(n) time if graph contains n vertices. Dijkstra’s algorithm only finds the single source shortest path and takes O(n ) time but it is good for weighted graph. Warshall’s algorithm for all pair shortest path takes O( ) time but it is also applicable for weighted graph.
10.
[Ans. D] Consider the following graph. Only one edge is needed to be removed for converting it into spanning tree. We have n choices for removing the edges. f a c d b
11.
[Ans. D] Termination time of vertex which is coming earlier is more than that of the vertex which is coming later
12.
[Ans. D] w be the minimum weight among all edge weights in an undirected connected graph. e is the specific edge of weight w. It may be possible that another edge in the graph having weight w which had been added to minimum spanning tree and when we add e to minimum spanning tree it from a simple circuit. So we can’t include e in every minimum spanning tree.
13.
[Ans. A]
6 5
u 5 3 4
⇒ So there must be a path in G having all the adjacent nodes of u connected. ⇒ As shown in the figure, then there will be a cycle consisting u and all the neighbors of node u 8.
DSA
The probabilities are
, , ,
,
,
.
So, the Huffman code according to tree is unique. 0, 10, 110, 1110, 111110,11111 represents a, b, c, d, e and f respectively.
[Ans. D] As per the time slices, the discovery time for Q is before the exit of P. And discovery of R happens only when Q and P finishes, which clearly indicates that the P and Q are connected but not R th
[Ans. C] Prim’s algorithm Prim’s algorithm starts at an random vertex. Then edges added to this tree one by one. The next edge (i, j) to be added is such that i is a vertex already included the tree, j is a vertex not yet included and the cost of (i, j) is minimum among all edges. Here, when we start with the minimum cost edge (a,b) so after (a,b) , (b,c) must be added to the tree in (A) option (d,f) is added which is according to Krushkal’s algorithm and not Prim’s. So, we take next minimum edge, i.e. (d,f). Now starting with this, we select minimum cost edge from which is (f,c). Thus, in this way , we move we move on selecting next minimum cost edge at each node such that circuit is formed. Hence answer is (d,f), (f,c), (d,a), (a,b), (c,e), (f, h), (g,h), (g,i)
20.
[Ans. A] A vertex-induced subgraph (sometimes simply called an "induced subgraph") is a subset of the vertices of a graph G together with any edges whose endpoints are both in this subset. Now take any graph with 4 or 5 vertices that follows given properties and you can observe that the option (A) is not true.
21.
[Ans. B] When the input is encoded in binary, subset sum problem is NP complete.
22.
[Ans. B] X[i, j] (2< = i < = n and a < =j<=w), is true , if any of the following is true
d
1 f
0
source shortest path algorithm when run from vertex a in the graph it includes all the vertices. Dijkstra’s don’t work properly in the edge that has negative weight (b,e), (c, h). So algorithm results correct result only for b,c,d.
0
0
e
[Ans. D] The average length of the tree is 1
2
3
4
5
5 1.9375 15.
[Ans. D] In topological sorting the partial ordering of the DAG, must be preserved i.e, if a b in the DAG, then in the topological order, b must come after a, not before. Consider the ordering 3 2 4 1 6 5 . 1 4 in the given DAG but 4 comes before 1 in 3 2 4 1 6 5 order which means that 3 2 4 1 6 5 is not a topological order of the given DAG.
16.
[Ans. C] The most efficient algorithm for finding the number of connected components (articulation point) in an undirected graph on n vertices and m edges using depth – first search take O(m + n) time. ssume n m.
17.
[Ans. C] The BFS using Queue data structure is QMNPRO
18.
DSA
[Ans. C] In given graph, the graph is directed and from vertex a to all the vertices there exist a weighted path. So Dijkstra’s single
1. Sum of weights excluding a is equal to j, i.e., if x,i 1, j- is true. 2. Sum of weights including a is equal to j, i.e., if x,i 1, j a - is true so that we get (j a ) a as j
23.
24.
25.
26.
27.
28.
29.
0 8
1 1
1
[Ans. D] After adding (b,e) one can add either (e,f) or (a,c) Kruskals algorithm works based on greedy strategy (picks minimum weight edge). Weight of edge (a,c) is less than (b,c). So it cannot come after (b,c)
2
12 9
4
3
4 7
3
2
4
We have to make minimum possible spanning tree having vertex 0 as a leaf node. 0
[Ans. B] Bellman-Ford shortest path algorithm always finds whether any negative weighted cycle which is reachable from the source.
1 3
4
2
So minimum possible weight = 4+1+2+3 = 10 30.
[Ans. B] From vertex 1 to vertex 2 we choose the path 1
3
4
[Ans. B] (i, j) values can be computed in a row major order or column major order of L[M, N]. [Ans. C] It is given that NP If is NP-hard, and since it is given that NP this means that is NP-complete Choice C is correct.
[Ans. C] The entry X[n, W] is true, because we find the weight W of subset of S which contains n elements.
[Ans. C] l(i, j) 0 if either i 0 or j 0 l(i 1, j 1); if i, j>0 and x,i 1,j 1max(l(i 1, j), l(i, j 1)); if i, j>0 and x,i 1,j 1expr2 max(l(i 1, j), l(i, j 1))
DSA
So weight = 1+4+3 = 8 31.
th
[Ans. B] If X and Y be two different maximum possible weights then we can say like either X and Y both will be equal or the difference between them will be because of a . Because all other numbers are th
having some positive values in denominator in weight. So those denominators will be decreasing weight. Therefore max( , a ) 32.
[Ans. B] Minimum spanning tree for 2 nodes would be (v1) (v2) Total weight 3 Minimum spanning tree for 3 nodes would be (v1) (v2) | (v3) Total weight= 3 + 4 = 7 Minimum spanning tree for 4 nodes would be (v1) (v2) (v4) | (v3) Total weight= 3 + 4 + 6 = 13 Minimum spanning tree for 5 nodes would be (v1) (v2) (v4) | (v3) | (v5) Total weight= 3 + 4 + 6 + 8 = 21 Minimum spanning tree for 6 nodes would be (v1) (v2) (v4) (v6) | (v3) | (v5) Total weight= 3 + 4 + 6 + 8 + 10 = 31 We can observe from above examples that when we add kth node, the weight of spanning tree increases by 2k 2. Let T(n) be the weight of minimum spanning tree. 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
DSA
The recurrence can be written as sum of series (2n – 2) + (2n 4) + (2n 6) + (2n 8) …. 3 and solution of this recurrence is n – n + 1.
4
6 here cost 13
3
n
n
1
16
4
1
13
33.
[Ans. C] Any MST which has more than 5 nodes will have the same distance between v5 and v6 as the basic structure of all MSTs (with more than 5 nodes) would be following. (v1) (v2) (v4) (v6) …. (more even numbered nodes) | (v3) | (v5) | . . (more odd numbered nodes) Distance between v5 and v6 = 3 + 4 + 6 + 8 + 10 = 31
For a complete graph time complexity n(n 1) O (n ) O(n ) 2
b
2
37.
[Ans. A] 1. We can use “Depth irst Search” Algorithm to check it there is a cycle in an undirected graph. If we encounter any “back edge” in “Depth first search” then given undirected graph has a cycle. DFS can be done in O(| | | |) time for graph G ( , ). So, it is in P. 2. P NP,So, it is also in NP 3. NP-Complete problem NP by definition every problem in NP can be solved in polynomial time using nondeterministic alogrithms. So, Answer is (A) i.e., 1, 2 and 3 are true.
38.
[Ans. C] DFS visits each vertex once and as it visits each vertex, we need to find all of its neighbors to figure out where to search next. Finding all its neighbors in an adjacency matrix requires O(V) times, so overall the running time will be O( )
39.
[Ans. D] Then all NP & NPC problems can be reduced to P problems. Because to compute the largest clique is NPC problem.
40.
[Ans. B] BFS is used in shortest path problems. So it finds the shortest path from source vertex to each and every vertex of a graph
41.
[Ans. 19]
3
d
c 3
4
a
4
b
4
d
9
c
9
MST 2
a 2
b
2
T
c
c
a
4
4 T
4
c
b
c
E.g. 2 2
G
4 2 4
4
2
4
MST 2 2
T 2
4
T
4
4
We can make different as well as same MST also. Option (D) is correct 36.
DSA
[Ans. C] In a complete graph total no of edges is n(n 1) 2 Time complexity of Bellman-ford algorithm for a graph having n vertices and m edges = O (nm)
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.
Hashing CS – 2007 1. Consider a hash table of size seven, with starting index zero, and a hash function (3x+4) mod 7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing? Note that – denotes an empty location in the table (A) (B) (C) (D) CS – 2009 2. The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table? (A) 0 (B) 0 1 1 2 2 2 12 3 23 3 13 4 4 5 15 5 5 6 6 7 7 8 18 8 18 9 9 (C)
0 1 2 3 4 5 6 7 8 9
(D) 12 13 2 3 23 5 18 15
0 1 2 3 4 5 6 7 8 9
CS – 2010 Statement for Linked Answer Questions 3 and 4: A hash table of length 10 uses open addressing with hash function h(k) = k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below. 0 1 2 42 3 23 4 34 5 52 6 46 7 33 8 9 3.
Which one of the following choices gives a possible order in which the key values could have been inserted in the table? (A) 46, 42, 34, 52, 23, 33 (B) 34, 42, 23, 52, 33, 46 (C) 46, 34, 42, 23, 52, 33 (D) 42, 46, 33, 23, 34, 52
4.
How many different insertion sequences of the key values using the same hash function and linear probing will result in the hash table shown above? (A) 10 (C) 30 (B) 20 (D) 40
12,2 13,3,23 5,15
18
CS – 2014 5. Consider a hash table with 9 slots. The hash function is ℎ(k) = k mod 9. The 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
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.
2.
[Ans.B] Size of hash table = 7 h(x) = (3x+4) mod 7 h(1) = (3.1+4) mod 7 = 7 mod 7 = 0; insert at 0th location. h(3) = (3.3+4) mod 7 =13 mod 7 = 6; insert at 6th location. h(8) = (3.8+4) mod 7 =28 mod 7 = 0; 0th position is already filled by element 3 so insert 8 at next free location which is 1st position h(10) = (3.10+4) mod 7 =34 mod 7 = 6 but 6th position is already filled with element 3. So insert 10 at next free location which is 2nd position 1 8 10 3 0 1 2 3 4 5 6 [Ans. C] 12 mod 10 = 2 18 mod 10 = 8 13 mod 10 = 3 2 mod 10 = 2 collision (2+1)mod 10 = 3 again collision (using linear probing) (3+1)mod 10 = 4 3 mod 10 = 3 collision (3+1) mod 10 = 4 collision (using linear probing) (4+1) mod 10 = 5 23 mod 10 = 3 collision (3+1) mod 10 = 4 collision (4+1) mod 10 = 5 again collision (5+1) mod 10 = 6 5 mod 10 = 5 collision (5+1) mod 10 = 6 again collision (6+1) mod 10 = 7 15 mod 10 = 5 collision (5+1) mod 10 = 6 collision (6+1) mod 10 = 7 collision
[Ans. C] h (46) = 6, location 6 is free hence get placed h (34) = 4, location 4 is free hence get placed h (42) = 2, location 2 is free hence get placed h (23) = 3, location 3 is free hence get placed h (52) = 2, location 2 is not free as 42 is already there. Linear probing will return index 5. Hence, 52 will be placed at 52. h (33) = 3, linear probe will return index 7
4.
[Ans. C] Please notice 52 cannot be appear in any of first three position of any input sequence otherwise we will not get the needed hash table. Also, 33 can only appear in the last position. th
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 8
0 17 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 (
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.
Process Management CS – 2005 1. Consider the following code fragment: if (fork( ) == 0) * a = a + 5; printf (“%d, %d\n”, a, &a); + else { a= a – 5; printf (“%d, %d\n”, a, &a); + Let u and v be the values printed by the parent process and x and y be the values printed by the child process. Which one of the following is TRUE? (A) u = x + 10 and v = y (B) u = x +10 and v y (C) u + 10 = x and v = y (D) u + 10 = x and v y 2.
Given below is a program which when executed spawns two concurrent processes: Semaphore X:=0; /* Process now forks into concurrent processes P1 & P2 */ P1 : repeat forever P2:repeat forever V(X); P(X); Compute; Compute; P(X); V(X); Consider the following statements about processes P1 and P2: I: It is possible for process P1 to starve. II. It is possible for process P2 to starve. Which of the following holds? (A) Both I and II are true (B) I is true but II is false (C) II is true but I is false (D) Both I and II are false
3.
Two concurrent processes P1 and P2 use four shared resources R1, R2, R3 and R4, as shown below. P1: P2: Compute: Compute: Use R1; Use R1; Use R2; Use R2; Use R3; Use R3; Use R4; Use R4; Both processes are started at the same time, and each resource can be accessed by only one process at a time. The following scheduling constraints exist between the access of resources by the processes: P2 must complete use of R1 before P1 gets access to R1.
P1 must complete use of R2 before P2 gets access to R2. P2 must complete use of R3 before P1 gets access to R3. P1 must complete use of R4 before P2 gets access to R4. There are no other scheduling constraints between the processes. If only binary semaphores are used to enforce the above scheduling constraints, what is the minimum number of binary semaphores needed? (A) 1 (C) 3 (B) 2 (D) 4 CS – 2006 4. The atomic fetch–and set x, y instruction unconditionally sets the memory location x to 1 and fetches the old value of x in y without allowing any intervening access to the memory location x. Consider the following implementation of P and V functions on a binary semaphore S. void P(binary_semaphore *S) { unsigned y; unsigned *x = & (S value); } do { fetch – and – set x, y; } while (y); } void V(binary_semaphore *S) { S value = 0; } Which one the following is true? (A) The implementation may not work if context switching is disabled in P (B) Instead of using fetch- and- set, a pair of normal load/ store can be used (C) The implementation of V is wrong (D) The code does not implement a binary semaphore 5.
The process state transition diagram of an operating system is as given below. Which of the following must be FALSE about the above operating system?
GATE QUESTION BANK Create a new process Schedule Running Ready Start I/O Complete or Resource released
Exit
(C) Lines 6 to 10 need not be inside a critical section (D) The barrier implementation is correct if there are only two processes instead of three
Terminated
Wait for I/O completion or resource Blocked
7.
Which one of the following rectifies the problem in the implementation? (A) Lines 6 to 10 are simply replaced by process_arrived (B) At the beginning of the barrier the first process to enter the barrier waits until process_arrived becomes zero before proceeding to execute P(S) (C) Context switch is disabled at the beginning of the barrier and reenabled at the end (D) The variable process_left is made private instead of shared
(A) It is a multi-programmed operating system (B) It uses preemptive scheduling (C) It uses non- preemptive scheduling (D) It is a multi-user operating system Common Data for Q. 6 & 7 Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and then all processes leave the barrier. Let the number of processes in the set be three and S be a binary semaphore with the usual P and V functions. Consider the following C implementation of a barrier with line numbers shown on the left. void barrier (void) { 1 : P (S); 2 : process_arrived + +; 3 : V (S) ; 4 : while (process_arrived ! = 3); 5 : P (S) ; 6 : process_left + + ; 7 : if (process_left = = 3){ 8 : process_arrived = 0; 9 : process_left = 0; 10: } 11 : V (S); } The variable process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. 6.
Operating System
CS - 2007 8. Two processes P1 and P2 need to access a critical section of code. Consider the following synchronization construct used by the processes: /* P1 */ while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1 = false; } /* Remainder section */
/* P2 */ while (true) { wants2 = true; while (wants1 == true); /* Critical Section */ wants2 = false; } /* Remainder section */ Here, wants1 and wants2 are shared variables,which are initialized to false. Which one of the following statements is TRUE about the above construct? (A) It does not ensure mutual exclusion (B) It does not ensure bounded waiting (C) It requires that processes enter the critical section in strict alternation (D) It does not prevent deadlocks but ensures mutual exclusion
The above implementation of barrier is incorrect. Which one of the following is true? (A) The barrier implementation is wrong due to the use of binary semaphore S (B) The barrier implementation may lead to a deadlock if two barrier invocations are used in immediate succession th
Processes P1 and P2 use critical_flag in the following routine to achieve mutual exclusion. Assume that critical_flag is initialized to FALSE in the main program. get_exclusive_access ( ) { if ( critical_flag == FALSE) { critical_flag = TRUE; critical_region ( ); critical_flag = FALSE; } } Consider the following statements. (i) It is possible for both P1 and P2 to access critical_region concurrently. (ii) This may lead to a deadlock. Which of the following holds? (A) (i) is false and (ii) is true (B) Both (i) and (ii) are false (C) (i) is true and (ii) is false (D) Both (i) and (ii) are true
10.
Synchronization in the classical readers and writers problem can be achieved through use of semaphores. In the following incomplete code for readerswriters problem, two binary semaphores mutex and wrt are used to obtain synchronization wait ( wrt ) writing is performed signal (wrt) wait (mutex) readcount = readcount + 1 if readcount = 1 then S1 S2 reading is performed S3 readcount = readcount – 1 if readcount = 0 then S4 signal (mutex) The values of S1, S2, S3 and S4 (in that order) are (A) signal (mutex), wait (wrt), signal (wrt), wait (mutex) (B) signal (wrt), signal (mutex), wait (mutex), wait (wrt) (C) wait (wrt), signal (mutex), wait ( mutex), signal (wrt) (D) signal (mutex), wait (mutex), signal (mutex) , wait (mutex)
11.
Operating System
The contents of the text file t1.txt containing four lines are as follows: a1 b1 a2 b2 a3 b2 a4 b1 The contents of the text file t2. txt containing five lines are as follows: a1 c1 a2 c2 a3 c3 a4 c3 a5 c4 Consider the following Bourne shell script: awk – (Print $1, $2) ‘ t1.txt while read a b ; do awk – v aV = $ a – v by = $b – ‘a V = = $1 (print aV, bV, $2) ‘ t2.txt done Which one of the following strings will NOT be present in the output generated when the above script in run? (Note that the given strings may be substrings of a printed line.) (A) “b1 c1” (C) “b1 c2” (B) “b2 c3” (D) “b1 c3”
CS - 2008 12. A process executes the following code for (i = 0; i < n; i ++) fork ( ); The total number of child processes created is (A) n (C) 2 (B) 2 1 (D) 2 1 13.
th
The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows: P (s): s = s – 1; if s < 0 then wait; V (s): s = s + 1; if s < = 0 then wakeup a process waiting on s; Assume that Pb and Vb, the wait and signal operations on binary semaphore are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P (s) and V (s) as follows: P(s): Pb (Xb); s = s – 1;
if (s < 0) { Vb (Xb); Pb(Yb); } else Vb(Xb); V(s): Pb(Xb); s = s + 1; if (s <= 0) Vb (Yb); Vb (Xb); The initial values of Xb and Yb are respectively (A) 0 and 0 (C) 1 and 0 (B) 0 and 1 (D) 1 and 1 CS – 2009 14. In the following process state transition diagram for a uniprocessor system, assume that there are always some processes in the ready state: B Start
A
Running
Ready E
C
D
Terminated
F
Blocked
Now consider the following statements: I. If a process makes a transition D, it would result in another process making transition A immediately II. A process P2 in blocked state can take transition E while another process P1 is in running state III. The OS uses preemptive scheduling IV. The OS uses non-preemptive scheduling Which of the above statements are TRUE? (A) I and II (C) II and III (B) I and III (D) II and IV
Which one of the following statements describes the properties achieved? (A) Mutual exclusion but not progress (B) Progress but not mutual exclusion (C) Neither mutual exclusion nor progress (D) Both mutual exclusion and progress 16.
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0= 1, S1 = 0, S2 = 0
Process P0 while (true) { wait (S0); print ‘0’ release (S1); release (S2); }
Process P1 wait (S1); release (S0);
Process P2 wait (S2) release (S0);
How many times will process P0 print ‘0’? (A) At least twice (C) Exactly thrice (B) Exactly twice (D) Exactly once CS - 2012 17. A process executes the code fork (); fork (); fork (); The total number of child processes created is (A) 3 (C) 7 (B) 4 (D) 8 18.
CS – 2010 15. Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned. Method used by P1 Method used by P2 while (S1 = = S2); critical Section S1= S2;
Operating System
while (S1 ! = S2); critical Section S2 = not (S1); th
Fetch_And_Add (X, i) is an atomic ReadModify-Write instruction that reads the value of memory location X, increments it by value i, and returns the old value of X it is used in the pseudocode shown below to implement a busy-wait lock. L is unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available. AcquireLock (L) { while ( Fetch_And_Add ( L, 1 ) ) L = 1; } ReleaseLock (L) { L = 0; } This implementation (A) fails as L can overflow (B) fails as L take on a non-zero value when the lock is actually available th
(C) works correctly but may starve some processes (D) works correctly without starvation CS – 2013 19. A certain computation generates two arrays a and b such that a[i]=f(i) for 0≤i
Operating System
A shared variable x, initialized to zero, is operated on by four concurrent processes W,X,Y,Z as follows. Each of the process W and X reads x from memory , increments by one, stores it to memory and then terminates. Each of the processes Y and Z reads x from memory , decrements by two, stores it to memory and then terminates. Each processes before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution? (A) 2 (C) 1 (B) 1 (D) 2
Which one of the following is TRUE? (A) The producer will be able to add an item to the buffer, but the consumer can never consume it. (B) The consumer will remove no more than one item from the buffer. (C) Deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty. (D) The starting value for the semaphore n must be 1 and not 0 for deadlockfree operation.
CS - 2014 21. Consider the procedure below for the Producer-Consumer problem which uses semaphores: semaphore n = 0; semaphore s = 1; void producer() void consumer() { { while (true) while(true) { { Produce(); semWait(s); SemWaits(s); semWait(n); addToBuffer(); removeFromBuffer(); semSignal(s); semsignal(s); semSignal(n); consume(); } } } }
Answer Keys and Explanations 1.
[Ans. C] fork ( ) will returns 0 for child . So, parent is printing 5 less than ‘a’ & child is printing 5 more. So, regarding the values u +10 =x Regarding the addresses v = y, though the physical addresses of child Process & Parent Process are different, yet “&a” refers to the logical addresses of the process which will be same for both Child & Parent Processes. Physical Address will be generated at runtime and it will be known to Memory Management Unit Only and CPU is totally unaware of Physical address.
2.
[Ans. C] As semaphore X = 0, the process calling P(X) must wait until another process calls V(X). P1 calling V(X) first, So P1 need not starve and it is independent and can run multiple times. P2 calling P(X) first, So P2 must wait until P1 comes. So P2 will starve.
3.
[Ans. B] Consider the possible solution X 𝑎𝑛𝑑 Y=0 P1 P2 wait(X) use R1 use R1 signal (X) use R2 wait (Y)
Signal(Y) useR2 wait(X) use R3 use R3 signal(X) use R4 wait(Y) Signal (Y) use R4 ∴ Total no. of binary semaphore = 2 4.
[Ans. A] void P (binary- semaphore * S){ unsigned y; unsigned * x = & (S value); do { fetch – and – set x, y; } while(y); } void V(binary- semaphore * S) * S value = 0;+ } fetch – and – set instruction always sets the memory location x = 1 and fetches the old value of x and y. The binarysemaphore * S takes only two value either 0 and 1. When we initialize S = 0 then in statement 3 this value will be started at location x and fetch – and-set instruction change the value of x= 0 to x = 1 and y becomes 0. If there are more than two processes and context switching between processes is disabled in P then this implementation doesn’t work properly and can’t synchronize the processes
[Ans. C] As Switching from Running to Ready is not allowed It is not a non-Preemptive Scheduling.
6.
[Ans. B] The barrier implementation may lead to a deadlock if two barrier invocations are used in immediate succession which is due to line 3 and 7.
7.
[Ans. B] At the beginning of the barrier the first process to enter in the line 8 the barrier waits until process_arrived becomes zero before proceeding to execute P(S)
8.
[Ans. D] It ensures Mutual Exclusion, but it doesn’t prevent deadlock. Wants1 Wants2 RESULT True True Deadlock True False P1 False True P2 False False No Process will enter into Critical Section
9.
[Ans. C] After execution of if (critical_flag== False). If P1 preempts and P2 starts . Then for P2 also line if (critical_ flag == False) Condition will be true. And P1, P2 both will access critical_ region concurrently. But here there is no any deadlock chance
10.
[Ans. C] S1 = Wait (wrt) To block writers accessing the buffer. S2 = Signal (mutex) To allow other readers to access the readcount shared variable. S3 wait (mutex) To block other readers in accessing the readcoun shared variable S4 = Signal (wrt) To allow writer to proceed as all readers are done with reading.
11.
Operating System
12.
[Ans. B] Fork ( ) system call creates the child process initially number of processes is 0. After first fork ( ), it creates a single process. After second fork ( ), it creates one parent and two child processes. After n fork ( ), the total number of processes is 2 but we subtract the main process then the total number of child processes is 2 1.
13.
[Ans. C] In given code, P(s) decrements the value of semaphore and V(s) increment the value of semaphore. P &V are wait and signal operations on binary semaphore. X &Y are binary semaphores. To avoid the mutual exclusion condition if the value of X is 1 and the value of Y = 0 then P(s) and V(s) work properly.
14.
[Ans. C] Transition C indicates that OS uses preemptive scheduling. II is also true.
15.
[Ans. A] It ensures Mutual Exclusion. S1 S2 RESULT 1 1 P2 1 0 P1 0 1 P1 0 0 P2 It doesn’t ensure progress, consider the following cases:If “P1” is the only process if (S1=S2), then it must wait indefinitely for “P2” If “P1” is the only process if (S1! = S2), then it will execute only once and makes (S1 = S2), if “P1” wants to execute for the second time, then it must wait indefinitely for “P2” We can conclude the Progress condition is not achieved .
16.
[Ans. A] When S =1, S = 0 So firstly the value of S and S = 0, P and P not execute. The value of S = 1, So it can execute, process P . Now value of S = 0 and it prints zero one time when it calls release (S1) call then the value of S1 increases by 1. So P executes. It makes
[Ans. C] So, its output is : a1 b1 c1 a2 b2 c2 a3 b2 c3 a4 b1 c3 th
2. Start with Y P(s) s=0 ead x = 0 ,old valuex=x 2 x= 2 Store it to memory V(s) s = 1 3. Again start with X, So it will write x = 1 in memory. V(s) s = 2 4. Same procedure for W and Z. Start with W. Preempt after read and then execute Z and again execute W. So final value in x will be 2.
value of S again zero and S = 1, then it release (S ) make value of S = 0 by applying wait and (S ) means it decrease by one so it prints zero and this process continue. So P prints zero at least twice. 17.
[Ans. C] fork (); 1 fork (); 2 = 7 fork (); 4 Total no of child processes after n fork ( ) calls = (2 1)
18.
[Ans. B] Assume P1 executes until while condition and preempts before executing L = 1. Now P2 executes all statements, hence L = 0. Then P1 without checking L it makes L = 1 by executing the statement where it was preempted. ∴It takes a non-zero value (L = 1) when the lock is actually available (L = 0).
19.
[Ans. C] Here take any sequence of operations of process X and process Y, first process X will wait for S which is incremented by process Y and then process Y waits for R which is incremented by process X. There is no sequence of operations in which the value of R or S overlaps. Hence both process executes one after another. So option (C) is correct. [X & Y] should run in strict alteration manner
20.
[Ans. D] 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
Operating System
21.
th
[Ans. C] semaphore n = 0; semaphore s = 1; The given solution will lead to deadlock in the following case: if consumer starts first. Consumer calls semWait(s) s = s – 1 = 0 Consumer is allowed Consumer calls semWait(n) n = n – 1 =0 1 = 1 Consumer is Blocked on semWait (n) Now producer started and called semWait(s) s = s 1 = 0 1= 1 Blocked on semWait(s) Now Both producer & Consumer are blocked Deadlock.
Threads CS – 2007 1. Consider the following statements about user level threads and kernel level threads. Which one of the following statements is FALSE? (A) Context switch time is longer for kernel level threads than for user level threads (B) User level threads do not need any hardware support (C) Related kernel level threads can be scheduled on different processors in a multiprocessor system (D) Blocking one kernel level thread blocks all related threads CS - 2011 2. Let the time taken to switch between user and kernel modes of execution be t1 while the time taken to switch between two processes be t2. Which of the following is TRUE? (A) t1 > t2 (B) t1 = t2 (C) t1 < t2 (D) nothing can be said about the relation between t1 and t2
3.
A thread is usually defined as a “light weight process” because an operating system (OS) maintains smaller data structures for a thread than for a process. In relation to this, which of the following is TRUE? (A) On per-thread basis, OS maintains only CPU register state (B) The OS does not maintain a separate stack for each thread (C) On per-thread basis, the OS does not maintain virtual memory state (D) On per-thread basis, the OS maintains only scheduling and accounting information
CS – 2014 4. Which one of the following is FALSE? (A) User level threads are not scheduled by the kernel. (B) When a user level thread is blocked, all other threads of its process are blocked. (C) Context switching between user level threads is faster than context switching between kernel level threads. (D) Kernel level threads cannot share the code segment
Answer Keys and Explanations 1.
2.
[Ans. D] In kernel level threads, if the blocking system call comes, the kernel can schedule another thread in the application for execution. So, statement (D) is false about kernel level threads. It is true for user level threads
3.
[Ans. A] Threads are called light weight processes because they only need storage for stack and registers. They don’t need separate space for other things.
4.
[Ans. D] All types of threads share code segment. So operation (D) is false All other statements are true.
[Ans. C] Process switching includes mode switching. Context switching can occur only in kernel mode. So t2 will include t1 in itself
CPU Scheduling CS – 2005 1. We wish to schedule three processes P1, P2 and P3 on a uni-processor system. The priorities, CPU time requirements and arrival times of the processes are as shown below. Process
Priority
P1
10 (highest) 9
P2 P3
8 (lowest)
CPU time required 20 sec
Arrival time (hh:mm:ss) 00:00:05
10sec
00:00:03
15 sec
00:00:00
We have a choice of preemptive or nonpreemptive scheduling. In preemptive scheduling, a late-arriving higher priority process can preempt a currently running process with lower priority. In nonpreemptive scheduling, a late arriving higher priority process must wait for the currently executing process to complete before it can be scheduled on the processor. What are the turnaround times (time from arrival till completion) of P2 using preemptive and non-preemptive scheduling respectively? (A) 30 sec, 30 sec (C) 42 sec, 42 sec (B) 30 sec, 10 sec (D) 30 sec, 42 sec
giving priority to the process with the lowest process id. The average turnaround time is (A) 13 units (C) 15 units (B) 14 units (D) 16 units 4.
Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation and the last 10% of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm and schedules a new process either when the running process get blocked on I/O or when the running process finishes its compute burst. Assume that all I/O operations can be overlapped as much as possible. For what percentage of time does the CPU remain idle? (A) 0% (C) 30.0% (B) 10.6% (D) 89.4%
5.
The arrival time, priority and durations of the CPU and I/O bursts for each of three processes P1, P2, and P3 are given in the table below. Each process has a CPU burst followed by an I/O burst followed by another CPU burst. Assume that each process has its own I/O resource.
CS – 2006 2. Consider three CPU intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6 respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end (A) 1 (C) 3 (B) 2 (D) 4 3.
The multi- programmed operating system uses preemptive priority scheduling. What are the finish times of the processes P1, P2 and P3? (A) 11, 15, 9 (C) 11, 16, 10 (B) 10, 15, 9 (D) 12, 17, 11
Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by
CS – 2007 6. Group-1 contains some CPU scheduling algorithms and Group-2 contains some applications. Match entries in Group-1 entries in Group-2 Group-1 Group-2 P. Gang 1. Guaranteed scheduling Scheduling Q. Rate 2. Real time Monotonic Scheduling Scheduling R. Fair Share 3. Thread Scheduling Scheduling (A) P – 3; Q – 2; R – 1 (B) P – 1; Q – 2; R – 3 (C) P – 2; Q – 3; R – 1 (D) P – 1; Q – 3; R – 2 7.
An operating system uses Shortest Remaining Time First (SRTF) process scheduling algorithm. Consider the arrival times and execution times for the following processes Process P1 P2 P3 P4
Execution time 20 25 10 15
Arrival time 0 15 30 45
Which is the total waiting time for process P2? (A) 5 (C) 40 (B) 15 (D) 55 CS – 2008 8. If the time – slice used in the round – robin scheduling policy is more than the maximum time required to execute any process ,then the policy will (A) degenerate to shortest job first (B) degenerate to priority scheduling (C) degenerate to first come first serve (D) none of the above CS – 2010 9. Which of the following statements are true? I. Shortest remaining time first scheduling may cause starvation II. Preemptive scheduling may cause starvation III. Round robin is better than FCFS in terms of response time
(A) (B) (C) (D)
Operating System
I only I and III only II and III only I, II and III
CS - 2011 10. Consider the following table of arrival time and burst time for three processes P0, P1 and P2. Process Arrival time Burst time P0 0 ms 9 ms P1 1 ms 4 ms P2 2 ms 9 ms The pre-emptive shortest job first scheduling algorithm is used. Scheduling is carried out only at arrival or completion of processes. What is the average waiting time for the three processes? (A) 5.0 ms (C) 6.33 ms (B) 4.33 ms (D) 7.33 ms
CS – 2012 11. Consider the 3 processes, P1, P2 and P3 shown in the table Process Arrival Time unit time required P1 0 5 P2 1 7 P3 3 4 The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are (A) FCFS: P1, P2, P3 RR2: P1, P2, P3 (B) FCFS: P1, P3, P2 RR2: P1, P3, P2 (C) FCFS: P1, P2, P3 RR2: P1, P3, P2 (D) FCFS: P1, P3, P2 RR2: P1, P2, P3 CS – 2013 12. A scheduling algorithm assigns priority proportional to the waiting time of a process. Every process starts with priority zero (the lowest priority ). The scheduler reevaluates the process priorities every T time units and decides the next process to schedule. Which one of the following is TRUE if the processes have no I/O operations and all arrive at time zero? (A) This algorithm is equivalent to the first – come first – serve algorithm. th
(B) This algorithm is equivalent to the round – robin algorithm (C) This algorithm is equivalent to the shortest – job – first algorithm (D) This algorithm is equivalent to the shortest – remaining – time – first algorithm
15.
CS – 2014 13. Consider the following set of processes that need to be scheduled on a single CPU. All the times are given in milliseconds. Process Arrival Execution Name Time Time A 0 6 B 3 2 C 5 4 D 7 6 E 10 3 Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is ___________ 14.
Operating System
An operating system uses shortest remaining time first scheduling algorithm for pre – emptive scheduling of processes. Consider the following set of processes with their arrival times and CPU bust times (in milliseconds) Process Arrival Time Burst Time P1 0 12 P2 2 4 P3 3 6 P4 8 5 The average waiting time (in milliseconds) of the processes is __________.
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 ___________.
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 k k d [Ans. A] k Group 1 P. dGang scheduling Q.k Rate Monotonic Scheduling
Total time = 33 3 = 30 2.
[Ans. B] Let three processes are Process Arrival time
6.
Burst time 0 10 2 20 6 30 The Gannt chart for SRTF scheduling algorithm is
R. Fair show scheduling. Group 2 3. Thread scheduling 2. Real time scheduling 1. Guaranteed scheduling 7.
[Ans. B] The Gantt chart for SRTF scheduling algorithm is
So there is only two context switches at time unit 10 context switch from o and at time unit 30 context switch from o
3.
P1 0
[Ans. A] The Gantt chart for LRTF CPU cheduling algorithm is
[Ans. B] Process P1 P2 P3
Burst Time 10 20 30
I/O Time 2 4 6
CPU Time 7 14 21
P2
20
P3 30
P4
P2 40
55
70
So, the waiting time for P2 = (20 – 15) + (40 – 30) = 15 8.
[Ans. C] If the time used in RR scheduling is more than the maximum time required to execute any process. Then the policy will degenerate to first come first serve
9.
[Ans. D] All three options are correct
Turn around time for P0 = 12 0=12 Turn around time for P1 =13 0 = 13 Turn around time for P2 = 14 0 = 14 ∴ Average urnaround ime = = 4.
P1,P2,P3 Therefore option (C) is correct. FCFS:P1,P2,P3 RR2:P1,P3,P2 12.
13.
[Ans. B] Every process arrives at time zero and priority is proportional to waiting time quantum T time units. Every process is given equal chance, all are arrived at same time. This is equal to round – robin algorithm. Because after each T time waiting time of all process will increase (except running process)
Operating System
[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 Computation[ m ] Operation m I/O of processes can proceed in parallel since there are sufficient no. of I/O devices. Process Id Arrival _Time A 0 100 500 B 5 350 500 C 10 200 500 CPU Scheduling Algorithm = Round Robin with quantum = 50 milliseconds When ro e “ ” will omple e i fir I/O operation? A eA ro e “ ” fini hed i exe u ion for first Iteration at 500 ms Af er fini hing exe u ion ro e “ ” will go for I/O I/O time = 500 ms ro e “ ” will fini h i ir operation in first Iteration = =
15.
[Ans. 5.5] P2 done
[Ans. 7.2] Gantt chart A B A C E D 0 3 5 8 12 15 21 Turn around line of (A) = (8 – 0) = 8 Turn around line of (B) = (5 – 3) = 2 Turn around line of (C) = (12 – 5) = 7 Turn around line of (D) = (21 – 7) = 14 Turn around line of (E) = (15 – 10) = 5 Average urn around ime
Deadlocks CS – 2005 1. Suppose n processes, P1, ……, Pn share m identical resource units, which can be reserved and released one at time. The maximum resource requirement of process Pi is si, where si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur? (A) i, si < m (B) i, si < n (C) ∑ (D) ∑ 2.
Two shared resource R1 and R2 are used by processes P1 and P2. Each process has a certain priority for accessing each resource. Let Tij denote the priority of for accessing Rj. A process Pi can snatch a resource Rh from process if Tik is greater than Tjk. Given the following: I. T11 > T21 II. T12 > T22 III. T11 < T21 IV. T12 < T22 Which of the following conditions ensures that P1 and P2 can never deadlock? (A) I and IV (B) II and III (C) I and II (D) None of the above
CS – 2006 3. Consider the following snapshot of a system running n processes. Process i is holding xi instances of a resource R, for 1 i n. Currently all instances of R are occupied. Further, for all i, process i has placed a request for an additional yi instances while holding the instances it already has. There are exactly two processes p and q such that yp = yq = 0. Which one of the following can serve as a necessary condition to guarantee that the system is not approaching a deadlock?
(A) (B) (C) (D)
min (xp, xq) < maxkp,q yk xp + xq minkp, qyk max ( xp, xq) < 1 min ( xp, xq) > 1
CS - 2007 4. A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of the processes will finish LAST? alloc request X Y Z X Y Z P0 1 2 1 1 0 3 P1 2 0 1 0 1 2 P2 2 2 1 1 2 0 (A) P0 (B) P1 (C) P2 (D) None of the above, since the system is in a deadlock CS - 2008 5. The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores equipped with the standard P and V Operations. Semaphore S = 1, Q = 0 ; integer x ; producer: consumer: while (true) do while (true) do P(S) ; P(Q) ; x = produce ( ) ; consume (x) ; V(Q) ; V(S) ; done done Which of the following is true about the program above? (A) The process can deadlock (B) One of the threads can starve th
initialized to 0. Now consider the following statements I. The above solution to CS problem is deadlock-free II. The solution is starvation free III. The processes enter CS in FIFO order IV. More than one process can enter CS at the same time Which of the above statements are TRUE? (A) I only (C) II and III (B) I and II (D) IV only
(C) Some of the items produced by the producer may be lost (D) Values generated and stored in ‘ ’ by the producer will always be consumed before the producer can generate a new value
t = 3 : requests 2 units of R1 t = 5 : releases 1 unit of R2 and 1 unit of R1 t = 7 : releases 1 unit of R3 t = 8 : requests 2 units of R4
Process P1 :
CS - 2009 8. The enter_CS( ) and leave_CS( ) functions to implement critical section of a process are realized using test-and-set instruction as follows: void enter_CS ( X) { while (test-and-set (X)) } void leave_CS (X) { X = 0; } In the above solution, X is a memory location associated with the CS and is
t = 0 : requests 2 units of R3 t = 2 : requests 1 unit of R4 t = 4 : requests 1 unit of R1 t = 6 : releases 1 unit of R3 t = 8 : Finishes
An operating system implements a policy that requires a process to release all resources before making a 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. (C) Starvation cannot occur but deadlock can occur. (D) Neither starvation nor deadlock can occur
t = 0 : requests 1 unit of R4 t = 2 : requests 2 units of R1 t = 5:releases 2 units of R1 t = 7 : requests 1 unit of R2 t = 8 :requests 1 unit of R3 t = 9 : Finishes
Consider a system with 4 types of resources R1 (3 units), R2 (2 units), R3 (3 units), R4 (2 units). A non-preemptive resource allocation policy is used. At any given instance, a request is not entertained if it cannot be completely satisfied. Three processes P1,P2,P3 request the resources as follows if executed independently.
t = 0 : requests 2 units of R2 t = 1 : requests 1 unit of R3 t = 10: Finishes
9.
Process P3 :
7.
Which of the following is NOT true of deadlock prevention and deadlock avoidance schemes? (A) In deadlock prevention, the request for resources is always granted if the resulting state is safe. (B) In deadlock avoidance, the request for resources is always granted if the resulting state is safe. (C) Deadlock avoidance is less restrictive than deadlock prevention (D) Deadlock avoidance requires knowledge of resource requirements a priori
Process P2 :
6.
Operating System
Which one of the following statements is TRUE if all three processes run concurrently starting at time t = 0? (A) All processes will finish without any deadlock (B) Only P1 and P2 will be in a deadlock (C) Only P1 and P3 will be in deadlock (D) All three processes will be in deadlock
CS - 2010 10. A system has n resources , .. and k processes , .. . The implementation of the resource request logic of each process , is as follows: if ( i % 2 = = 0) { if ( i
Operating System
CS – 2014 12. An operating system uses the Banker’s algorithm for deadlock avoidance when managing the allocation of three resource types X, Y and Z to three processes P0, P1, and P2. The table given below presents the current system state. Here, the Allocation matrix shows the current number of resources of each type allocated to each process and the Max matrix shows the maximum number of resources of each type required by each process during its execution. Allocation Max X Y Z X Y Z P0 0 0 1 8 4 3 P1 3 2 0 6 2 0 P2 2 1 1 3 3 3 There are 3 units of type X, 2 units of type Y and 2 units of type Z still available. The system is currently in a safe state. Consider the following independent requests for additional resources in the current state: REQ1: P0 requests 0 units of X, 0 units of Y and 2 units of Z REQ2: P1 requests 2 units of X, 0 units of Y and 0 units of Z Which one of the following is TRUE? (A) Only REQ1 can be permitted. (B) Only REQ2 can be permitted. (C) Both REQ1 and REQ2 can be permitted. (D) Neither REQ1 nor REQ2 can be permitted. 13.
th
A system contains three programs and each requires three tape units for its operation. The minimum number of tape units which the system must have such that deadlocks never arise is ____.
[Ans. C] No. of processes = n 1, 2……. n No. of identical resources = m. The maximum resource requirement for a process Pi is SP, where Si > 0 If all process is in safe state then system can allocate resources to each process Pi in some order and still avoid a deadlock. We can avoid the deadlock if each Pi request can be satisfied by the current available resource plus the resources held by process Pj such that j
2.
[Ans. C] Here I and II says T11>T21 T12>T22 P1 P2 Required R1 required R1 Required R2 required R2 Assume that P1 is running and after a context switch P2 goes to running state that it cannot snatch resource from P1, because has high priority for both resources. Hence no deadlock.
3.
4.
[Ans. C] Consider the matrix alloc Request X Y Z X Y Z 1 2 1 1 0 3 P1 2 0 1 0 1 2 2 2 1 1 2 0 The available matrix is (0 1 2) and requirement of process P1 is (0 1 2). So P1 can uses the available resources after release the resources, the matrix becomes Alloc Request X Y Z X Y Z P0 1 2 1 1 0 3 P1 0 0 0 0 0 0 P2 2 2 1 1 2 0 In this time available matrix is (2 1 3) and required matrix of P0 is (1 0 3) so P0 uses the resources of the releasing resources. The available matrix is (3 3 4). So, P2 will use the resource. So, P2 will finish last.
5.
[Ans. D] Since, after every produce function; it calls consume function. Producer and consumer will run in strict alteration. So (D) is true
6.
[Ans. A] In deadlock prevention, OS tries to prevent system from deadlock by not allowing any one of the four necessary conditions to hold So, option A is not true
7.
[Ans. B] If a process release all resources before making a request for another resource, starvation may or may not occur but deadlock cannot occur; because hold and wait condition will not hold
8.
[Ans. A] The given solution is deadlock free
[Ans. B] There is no any additional requirement for both processes. So both p & q should be executed with all allocated resources so should be sufficient for p & q and should be at least (min
[Ans. B] According to the given program, in all the cases for even sequences of processes only corresponding sequence number of resource will be allotted except case (B), where n = 21, k = 12, For can only be allotted and for can be allotted. allotted and for odd sequence of process i.e. that never conflict in any case except (B), when a same resource is requested by more than one process at the same time may lead to the deadlock.
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 P0 0 0 1 8 4 3 8 4 P1 3 2 0 6 2 0 3 0 P2 2 1 1 3 3 3 1 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]
13.
Operating System
[Ans. 7] Total no of programs = 3 = {P1, P2, P3} Each program requires = 3 tape drives Now just allocate one less than the required resources Program No. of tap drives P1 3 1=2 P2 3 1=2 P3 3 1=2 6 tape drives To avoid Deadlock, we need minimum = 6 + 1 = 7 tape drives
Memory Management & Virtual Memory CS - 2006 1. A CPU generates 32-bit virtual addresses. The page size is 4 KB. The processor has a translation look-aside buffer (TLB) which can hold a total of 128 page table entries and is 4-way set associative. The minimum size of the TLB tag is (A) 11 bits (C) 15 bits (B) 13 bits (D) 20 bits 2.
3.
A computer system supports 32-bit virtual addresses as well as 32-bit physical addresses. Since the virtual address space is of the same size as the physical address space, the operating system designers decide to get rid of the virtual memory entirely. Which one of the following is true? (A) Efficient implementation of multiuser-support is no longer possible (B) The processor cache organization can be made more efficient now (C) Hardware support for memory management is no longer needed (D) CPU scheduling can be made more efficient now
CS - 2007 4. A virtual memory system uses First In First Out (FIFO) page replacement policy and allocates a fixed number of frames to a process. Consider the following statements: P: Increasing the number of page frames allocated to a process sometimes increases the page fault rate Q: Some program do not exhibit locality of reference. Which one of the following is TRUE? (A) Both P and Q are true and Q is the reason for P (B) Both P and Q are true, but Q is not the reason for P (C) P is false, but Q is true (D) Both P and Q are false 5.
Let a memory have four free blocks of sizes 4k, 8k, 20k, 2k. These blocks are allocated following the best-fit strategy. The allocation requests are stored in a queue as shown below. Request Request Usage No sizes time J1 2k 4 J2 14k 10 J3 3k 2 J4 6k 8 J5 6k 4 J6 10k 1 J7 7k 8 J8 20k 6 The time at which the request for J7 will be completed will be (A) 16 (C) 20 (B) 19 (D) 37
6.
The address sequence generated by tracing a particular program executing in a pure demand paging system with 100 bytes per page is 0100, 0200, 0430, 0499, 0510, 0530, 0560, 0120, 0220, 0240, 0260, 0320, 0410. Suppose that the memory can store only one page and if x is the address which causes a page fault then the bytes from
For each of the four processes P1, P2, P3 and P4. The total size in kilobytes (KB) and the number of segments are given below. Process Total size (in Number of KB) segments P1 195 4 P2 254 5 P3 45 3 P4 364 8 The page size is 1 KB. The size of an entry in the page table is 4bytes. The size of an entry in the segment table is 8 bytes. The maximum size of the segment is 256KB. The paging method for memory management uses two-level paging and its storage overhead is P. The storage overhead for the segmentation method is S. The storage overhead for the segmentation and paging method is T. What is the relation among the overheads the different methods of memory management in the concurrent execution of the above four processes? (A) P < S < T (C) S < T < P (B) S < P < T (D) T < S < P
addresses x to x + 99 are loaded on to the memory. How many page faults will occur? (A) 0 (C) 7 (B) 4 (D) 8
7.
8.
Common Data for Q. 7 & 8 A process has been allocated 3 page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequence of page references (reference string) : 1, 2, 1, 3, 7, 4, 5, 6, 3, 1. If optimal page replacement policy is used, how many page faults occur for the above reference string? (A) 7 (C) 9 (B) 8 (D) 10 Least Recently Used (LRU) page replacement policy is a practical approximation to optimal page replacement. For the above reference string, how many more page faults occur with LRU than with the optimal page replacement policy? (A) 0 (C) 2 (B) 1 (D) 3
CS - 2008 9. A processor uses 36-bit physical addresses and 32-bit virtual addresses, with a page frame size of 4 Kbytes. Each page table entry is of size 4 bytes. A three level page table is used for virtual-tophysical address translation, where the virtual address is used as follows bits 30-31 are used to index into the first level page table bits 21-29 are used to index into the second level page table bits 12-20 are used to index into the third level page table bits 0-11 are used as offset within the page The number of bits required for addressing the next level page table (or page frame) in the page table entry of the first, second and third level page table are respectively (A) 20, 20 & 20 (C) 24, 24 & 20 (B) 24, 24 & 24 (D) 25, 25 & 24
10.
Operating System
Match the following flag bits used in the context of virtual memory management on the left side with the different purpose on the right side of the table below. Name of the bit Purpose i. Dirty a. Page initialization ii. R / W b. Write–back policy iii. Reference c. Page protection iv. Valid d. Page replacement policy (A) i – d , ii – a , iii – b , iv – c (B) i – b , ii - c , iii – a , iv – d (C) i – c , ii – d , iii – a , iv – b (D) i – b , ii – c , iii - d , iv – a
CS - 2009 11. In which one of replacement policies, occur? (A) FIFO (B) Optimal
the following page Belady’s anomaly may (C) LRU (D) MRU
12.
The essential content(s) in each entry of a page table is/are (A) Virtual page number (B) Page frame number (C) Both virtual page number and page frame number (D) access right information
13.
A multilevel page table is preferred in comparison to a single level page table for translating virtual address to physical address because (A) It reduces the memory access time to read or write a memory location (B) It helps to reduce the size of page table needed to implement the virtual address space of a process (C) It is required by the translation look a side buffer (D) It helps to reduce the number of page faults in page replacement algorithms.
CS - 2010 14. A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded to begin with. The system first accesses 100 distinct pages in some order and then accesses the same 100 pages but now in the reverse order. How many page faults will occur? (A) 196 (B) 192 (C) 197 (D) 195 th
CS - 2011 15. Let the page fault service time be 10 ms in a computer with average memory access time being 20 ns. If one page fault is generated for every memory accesses, what is the effective access time for the memory? (A) 21 ns (B) 30 ns (C) 23 ns (D) 35 ns CS - 2012 16. Consider the virtual page reference string 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 On a demand paged virtual memory system running on a computer system that has main memory size of 3 page frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number of page faults under the corresponding page replacement policy. Then (A) OPTIMAL < LRU < FIFO (B) OPTIMAL < FIFO < LRU (C) OPTIMAL = LRU (D) OPTIMAL = FIFO CS - 2013 Statement for linked Answer Questions 17 and 18: A computer uses 46- bit virtual address, 32 – bit physical address, and a three – level paged page table organization. The page table base register stores the base address of the first – level table (T1), which occupies exactly one page. Each entry of T1 stores the base address of the second – level table (T2). Each entry of T2 stores the base address of a page of the third – level table (T3). Each entry of T3 stores a page table entry (PTE). The PTE is 32 bits in size. The processor used in the computer has a 1 MB 16- way set associative virtually indexed physically tagged cache. The cache block size is 64 bytes. 17. What is the size of a page in KB in this computer? (A) 2 (C) 8 (B) 4 (D) 16
18.
Operating System
What is the minimum number of page colors needed to guarantee that no two synonyms map to different sets in the processer cache of this computer? (A) 2 (C) 8 (B) 4 (D) 16
CS - 2014 19. Assume that there are 3 page frames which are initially empty. If the page reference string is 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6, the number of page faults using the optimal replacement policy is__________. 20.
A system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are initially empty. What is the total number of page faults that will occur while processing the page reference string given below? 4, 7, 6, 1, 7, 6, 1, 2, 7, 2
21.
Consider a paging hardware with a TLB. Assume that the entire page table and all the pages are in the physical memory. It takes 10 milliseconds to search the TLB and 80 milliseconds to access the physical memory. If the TLB hit ratio is 0.6, the effective memory access time (in milliseconds) is _________.
22.
A computer has twenty physical page frames which contain pages numbered 101 through 120. Now a program accesses the pages numbered , 2, …, in that order, and repeats the access sequence THRICE. Which one of the following page replacement policies experiences the same number of page faults as the optimal page replacement policy for this program? (A) Least-recently-used (B) First-in-first-out (C) Last-in-first-out (D) Most-recently-used
[Ans. A] No. of pages = 128 = 2 ∴ Bits needed for page table entry = 7 page size = 4 KB = 4.2 byte. = 12 bits. For 4 way associative memory cell needs 2- bit (2 ∴ Total engaged bits = 7+12+2=21 bits ∴Minimum size of TLB = 32 21= 11 bits [Ans. C] Since both memory are equal. Therefore address translation from virtual to physical is not needed. And it is done by MMU. So, hardware support for memory management is no longer needed [Ans. C] T = storage overhead for segmentation and paging method S= storage overhead for segmentation method P = storage overhead for paging method = 4×8+5×8+3×8+8×8 = 160 𝑏𝑦𝑡𝑒𝑠 T = Stores the software programs needed hus , and 𝑃 = 95×4+254×4+45×4+364×4=3432 ∴𝑆<𝑇<𝑃. [Ans. B] P and Q both are true but Q is not the reason for P because increasing the number of page frames allocated to a process sometime increases the page fault rate or it is not concern with replacement policy. [Ans. B] There are four block of size 4k, 8k, 20k, 2k Request Allocated Remaining Usage No block block time 4k, 8k, J1 2k 20k 4 J2 20k 4k, 8k, 6k 10 J3 4k k, 8k, 6k 2 J4 6k k, 8k 8 It will wait to free block used by J2. So it will wait for 10 units, then J6 will
complete in 1 unit time. So total time 11 units is taken to process request of J7 and J7 takes 8 unit time to complete the request ∴Total time taken by J7 = 10+1+8 = 19 unit times. 6.
[Ans. D] Page reference string is 1, 2, 4, 5, 1, 2, 3, 4 So, 2 No. of page faults = 8
7.
[Ans. A] Number of page frames = 3 Consider the optimal page replacement algorithm as follows: 1, 2, 1, 3, 7, 4, 5, 6, 3, 1. Page Frame
So total number of page fault = 9 Number of page fault in LRU Number of page fault in optional = 9 7 = 2 more page faults. 9.
[Ans. B] Number of bits required for first level page table = 24 Number of bits required for 2nd level page table = 24 Number of bits required for 3rd level page table = 24
[Ans. A] Belady’s anomaly can occur only in FIFO. Which means with increment in page frames, sometimes no. of pages faults also increases
(
(
)] )
2 ns 2 ns
( (
) )
3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4
5 MISS
6 MISS
LRU 1 M
2 1 M
3 2 1 M
3 2 1 H
3 2 4 M
1 2 4 M
1 3 4 M
1 3 2 M
4 3 2 M
4 1 2 M
So optimal < FIFO < LRU 17.
[Ans. C] Let page size = 2 bytes Page offset = X bits 46 X X 2 2 i e of 2 2 Size of
B
2 B
2
Size of 2 & 2 2 occupies e actly one page
age si e
18.
2
B B
[Ans. C] Page size = 2 Bytes Divide cache size by page size & group 16 pages in one set. No. of pages in caches No. of sets in cache =
2 pages sets
So all pages which will be mapped to one set, will be colored with same color So 8 sets = 8 colors required.
[Ans. B] Effective access time = [(1 – p) access time when no page fault +p access time during page fault] [
FIFO
3 3 3 3 3 2 2 2 2 2 2 4 4 4 4 4 4
[Ans. B] Multilevel page table is preferred to reduce the size of page table needed to implement the virtual address space of a process. [Ans. A] FIFO policy for page replacement used. Access 100 distinct pages by taking some example 2 3 4 5 6 7 8 9. So by loading it get 5 = 4 page faults 4 3 2
[Ans. B] OPTIMAL
[Ans. B] Page frame numbers are most important, virtual page number may not be stored entirely.
9 8 = 4 page faults 7 6 and now access these pages in reverse so ⏟ ⏟ 2 o, no page fault for these page fault for these 9 5 8 4 4 page faults 7 3 6 2 So total = 4+4+4=12 page faults For 8 pages = 2 8 4=12 So for n pages = 2n 4 For 100 pages = 2 ( =196 15.
16.
MISS MISS MISS HIT MISS HIT H M H H M M M H M M H M H H M M M
[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
6 3 6 4
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”
File System CS – 2005 1. In a computer system, four files of size 11050 bytes, 4990 bytes, 5170 bytes and 12640 bytes need to be stored. For storing these files on disk, we can use either 100 byte disk blocks or 200 byte disk blocks (but can‘t mix block sizes). For each block used to store a file, 4 bytes of bookkeeping information also needs to 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 – 2014 4. A FAT (file allocation table) based file system is being used and the total overhead of each entry in the FAT is 4 bytes in size. Given a bytes disk on which the file system is stored and data block size is bytes, the maximum size of a file that can be stored on this disk in units of bytes is ____________.
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
Size of Block = bytes Total no. of Blocks in Disk = Total Size of Disk / Size of Block = 100 / = Blocks Size of FAT table = Total No of Blocks Size of each entry in FAT = ×4 = 0.4× bytes Max Size of File = Total Size of Disk - Size of FAT = (100 × ) (0.4 × ) = 99.6 × bytes Answer = 99.6 bytes 99.6 in units of bytes
locks fo file Blocks for book keeping = For 100 bytes blocks:File Book keeping F1 111 5 F2 50 2 F3 52 3 F4 127 6 Total 340 16 ) ) For 200 block size Blocks for file F1 55 F2 25 F3 26 F4 64 Total 170 )
Blocks for Book keeping 2 1 1 3 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
4.
( k
)
]
k
[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
I/O System CS - 2009 1. Consider a disk system with 100 cylinders. The requests to access the cylinders occur in the following sequence: 4, 34, 10, 7, 19, 73, 2, 15, 6, 20 Assuming that the head is currently at cylinder 50, what is the time taken to satisfy all requests if it takes 1 ms to move from one cylinder to adjacent one and shortest seek time first policy is used? (A) 95 ms (C) 233 ms (B) 119 ms (D) 276 ms CS - 2011 2. An application loads 100 libraries at startup. Loading each library requires exactly one disk access. The seek time of 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
CS - 2013 3. Consider a hard disk with 16 recording surfaces (0-15) having 16384 cylinders (0-16383) and each cylinder contains 64 sectors (0-63). Data storage capacity in each sector is 512 bytes. Data are organized cylinder – wise and the addressing format is . A file of size 42797 KB is stored in the disk and the 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] 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.
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.
Finite Automata CS – 2005 1. Consider the machine M
Consider the strings u = abbaba, v = bab and w = aabb. Which of the following statements is true? (A) The automaton accepts u and v but not w (B) The automaton accepts each of u, v and w (C) The automaton rejects each of u, v and w (D) The automaton accepts u but rejects v and w
b
b
a b
b
a a
a a, b
The language recognized by M is (A) {w { }*|every a in w is followed y x tly two s} (B) {w {a, b}*|every a in w is followed y t l st two ’s} (C) {w {a, b}*|w does not contains the su string ‘ ’} (D) {w {a,b}*|w ont ins ‘ ’ s substring} 2.
The following diagram represents a finite state machine which takes as input a binary number from the least significant bit 0/0
CS – 2007 4. A minimum state deterministic finite automation accepting the language L = {w w ϵ {0,1}*, number of 0s & 1s in w are divisible by 3 and 5, respectively} has (A) 15 states (C) 10 states (B) 11 states (D) 9 states 5.
Consider the following DFA in which s is the start state and s , s are the final states.
0/1 1/0
1/1
s
x
Which one of the following is TRUE? (A) It omput s 1’s ompl m nt of th input number (B) It omput s 2’s ompl m nt of th input number (C) It increments the input number (D) It decrements the input number
y
x s
s y
x x
y
s
What language does this DFA recognize? (A) All strings of x and y (B) All strings of x and y which have either even number of x and even number of y or odd number of x and odd number of y (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 number of x and odd number of y or odd number of x and even number of y.
CS – 2006 3. In the automaton below, s is the start state & t is the only final state.
CS – 2009 6. Given the following state table of an FSM with two states A and B, one input and one output: Present State A
0 0 1 1 0 0 1 1
7.
Present State B
Input
Next State A
Next State B
Out put
0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 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? (A) 3 (C) 5 (B) 4 (D) 6
CS – 2011 9. Definition of a language L with alphabet {a} is given as following L={ k n n is positiv int g r constant} What is the minimum number of states needed in a DFA to recognize L? (A) k + 1 (C) 2n+1 (B) n + 1 (D) 2k+1 10.
(A) (B) (C) (D)
A deterministic finite automaton (DFA) D with alphabet ∑ {a,b} is given below: p
q
r
t
Which of the following finite state machines is a valid minimal DFA which accepts the same language as D?
The following DFA accepts the set of all strings over {0,1} that 1 0 1 0 1
TOC
p
q
r
0
Begin either with 0 or 1 end with 0 end with 00 contain the substring 00
s
s
CS – 2010 8. Let w be any string of length n in {0, 1}*. 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
than 3 are also in the language. A partially completed DFA that accepts this language is shown below.
q
1
1 1
s 1
11.
1
q
1
1
11
The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense? (A) Finite state automata (B) Deterministic pushdown automata (C) Non-deterministic pushdown automata (D) Turing machine
1
The missing arcs in the DFA are (A) 00 01 10 11 00 1 0 01 1 10 0 11 0
q
(B) 12.
Let P be a regular language and Q be a context-free language such that Q ⊆ P. (For example, let P be the language represented by the regular expression } Then which p*q* and Q be {p q n of the following always regular? (A) P ∩ Q (C) Σ* P (B) P – Q (D) Σ* Q
00 00 01 10 11
01 0 1
10
11
q l
0 0
(C) 00 00 01 10 11
CS – 2012 13. What is the complement of the language accepted by the NFA shown below? ssum ∑ { } n is the empty string
01 1 1
10
11
q 0
11
q 0
0 0
(D) a
(A) 14.
(B) { }
00
(C)
(D) {
00 01 10 11
}
01 1
10
1 0 0
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
CS – 2014 16. Consider the finite automaton in the following figure 1
1 q
1 1
q
1
q
1
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
Which of the following are FALSE? 1. Complement of L(A) is context – free. 2. L(A)= L((11*0+0)(0+1)*0*1*) 3. For the language accepted by A,A is the minimal DFA. 4. Accepts all strings over {0, 1} of length at least 2. (A) 1 and 3 (C) 2 and 3 (B) 2 and 4 (D) 3 and 4
17.
L tΣ finit non-empty alphabet and let 2 th pow r s t of Σ* Whi h on of the following is TRUE? (A) Both 2 n Σ* are countable (B) 2 is ount l n Σ* is un ount l (C) 2 is un ount l n Σ* is ount l (D) Both 2 n Σ* r un ount l
Answer Keys and Explanations 1.
2.
[Ans. B] (A) is f ls sin M is pting “ bbb” (B) is true. (C) is false since the string abb is accepted by M. (D) is false, since abb does not contain “ ” s su string ut abb is being rejected by M. [Ans. B] To onv rt in ry num r to 2’s complement fom, all the digits from LSB are directly copied upto the 1st occurance of 1. After that all digits are complemented 0/0
0/1 1/1
Transition table for the diagram is Next state PS 0 1 1 1 1 Output function z is Start state PS 0 1 q0 0 1 q1 1 0 The output z computes th complement of the input number. 3.
2’s
[Ans. D] At the end of string u, automaton will be at the final state t, but the automaton will be at the state s after the end of both the strings v and w.
[Ans. A] L={w w { 1} number of ’s n 1’s in w are divisible by 3 and 5 respectively} The minimum number of states for the state deterministic finite automation accepting the language L has 3 × 5 = 15 states.
5.
[Ans. D] As s and s are both final states, the strings accepted are x, y, xyx, yxx etc.
6.
[Ans. A] String 1 0 1 will bring m/c to specified state. The transition diagram is given below: 0/1 1/0
Thus the corresponding NFA looks like as follows: 0/1
1/1
11
9.
[Ans. B] The following DFA that accepts a s qu n of ’s whos l ngth is positiv multiple of a constant n. It has n + 1 states q0 through qn.
10.
[Ans. A] The language accepted by given DFA is L Choice (A)is accepting same language and is minimal “ ” is r j t y hoi and it belongs to L. So choice (B) is incorrect. Choice (C) is an NFA and hence not the right answer “ ” is pt y hoi n is rejected by L. So choice (D) is incorrect.
11.
[Ans. A] Lexical analysis uses express regular expressions. So, finite state automata is necessary and sufficient to perform lexical analysis.
12.
[Ans. C] Complement of a regular language is always regular.
13.
[Ans. B]
1 0/0
7.
8.
[Ans. C] (A) says that all strings that start with either 0 or 1, which is not true because 1001 is one of this string which is not the member of given DFA. (B) imil rly string “ ” is n ing string and not acceptable by given DFA. (D) lso n’t orr t s 1 is not accepted by given DFA. Any string of {0, 1} that ends with 00 certainly acceptable by this DFA.
0/1
Dead state
0/0 1/1, 0/0
00 –----------1(0) --------> 01 –-----0(0) -----> 10 –---1(1) -----> 01 (Highlighted text is input followed by output).
0/1
0/1
1
1/1
TOC
[Ans. C] Since L is set of all substrings of w, that mean L has strings of Length 0, 1, 2, 3 ---------- n.
[Ans. D] Notice that the state names are given 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 allowed in any substring). Based on this fact, option (A) and (B) are incorrect. Between option (C) and (D), if you look at r l l “1” from st t 1 this r should go to state 11 since the string at this point is ending with 11. So option (C) is wrong and option (D) is correct. The DFA corresponding to correct option (D) is shown below missing arrow shown in dotted lines.
1
4.
1
A accepts all strings over {0,1} of length at least 2-False. The given DFA accepts the string ‘ ’ which is of length less than 2.
16.
[Ans. A] (Current state, input) = next state q q q q q 1 q or q q 1 q So set of reachable states {q q q }
q
1
17.
[Ans. C] 2 is the power set of Σ Σ is countability infinite. The power set of countable infinite set is uncountable. So 2 is uncountable, and Σ is countable
1 1
15.
1
1
1
1
Minimal DFA is
1
1 1
TOC
1
1
11
[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
Regular Expression CS – 2005 1. Which of the following statements is TRUE about the regular expression 01*0? (A) It represents a finite set of finite strings. (B) It represents an infinite set of finite strings. (C) It represents a finite set of infinite strings. (D) It represents an infinite set of infinite strings. 2.
Which regular expression best describes the language accepted by the nondeterministic automaton below?
q (A) (B) (C) (D) 5.
Common Data for Q.7 & Q.8 Consider the following Finite Automation
q
q
state
q3
The language * n + is (A) Regular (B) context free but not regular (C) context free but its complement is not context free (D) not context free
CS – 2006 3. Consider the regular language L= (111+11111)*. The minimum number of states in any DFA accepting this languages is: (A) 3 (B) 5 (C) 8 (D) 9 4.
CS – 2007 6. Which of the following languages is regular? * + + (A) *ww w * + + (B) *ww x x w * + + (C) *wxw x w * + + (D) *xww x w
b
b
b
a a
q0
a
q1
q2
b
a
7.
The language accepted by this automaton is given by the regular expression (A) b* ab* ab* ab* (C) b*a(a + b)* (B) (a + b)* (D) b * ab* ab*
8.
The minimum state automaton equivalent to the above FSA has the following number of states (A) 1 (B) 2 (C) 3 (D) 4
9.
Which of the following is TRUE? (A) Every subset of a regular set is regular (B) Every finite subset of a non-regular set is regular (C) The union of two non-regular sets is not regular (D) Infinite union of finite sets is regular
q
(a + b) * a(a + b)b (abb)* (a + b) * a(a + b) * b(a + b)* (a + b)*
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
CS – 2008 10. Given below are two finite state automata ( indicates the start state and F indicates a final state) Y: Z: a b a b 1 2 2 2 2(F) 2 1 2(F) 1 1 Which of the following represents the product automaton Z Y? (A) a b P S R Q R S R(F) Q P S Q P (B) a b P S Q Q R S R(F) Q P S P Q (C) a b P Q S Q R S R(F) Q P S Q P (D) a b P S Q Q S R R(F) Q P S Q P 11.
Match the following NFAs with the regular expressions they correspond to. P. 1 0
TOC
Which of the following are regular sets? 1. { n 0, m 0 } 2. { n=2m} 3. { n m} 4. * x y x y є * +*+ (A) 1 and 4 only (C) 1 only (B) 1 and 3 only (D) 4 only
Consider the following two finite automata. M1 accepts L1 and M2 accepts L2. 0,1
0
1
1
TOC
CS – 2010 16. Let L = {w (0 + 1)* | w has even num er of ’s+ i.e. is the set of ll it strings with even num er of ’s. Which one of the regular expressions below represents L? (A) (0*10*1) * (C) 0*(10*1)*0* (B) 0*(10*10*)* (D) 0*1(10*1)*10*
0 0,1
0,1
1
1
Which one of the following is TRUE? (A) (C) L1 (B) (D) L1 14.
Which of the following regular expressions describes the language over {0, 1} consisting of strings that contain ex tly two ’s? (A) (0 +1)* 11(0 +1)* (B) 0 * 110* (C) 0*10*10* (D) (0 +1)* 1(0 +1)* 1 (0 +1)*
CS – 2009 15. Which one of the following languages over the alphabet {0, 1} is described by the regular expression: ( + ) ( + ) ( + )? (A) The set of all strings containing the substring 00 (B) The set of all strings containing at most two ’s (C) The set of all string containing at le st two ’s (D) The set of all strings that begin and end with either 0 or 1
CS -2012 17. Given the language L = {ab, aa, baa}, which of the following strings are in L*? 1. abaabaaabaa 2. aaaabaaaa 3. baaaaabaaaab 4. baaaaabaa (A) 1, 2 and 3 (C) 1, 2 and 4 (B) 2, 3 and 4 (D) 1, 3 and 4 CS – 2013 18. Consider the languages n * +. Which one of the following represents ? (A) *ε+ (B) (C) (D) *ε + CS – 2014 19. Which one of the following is TRUE? (A) The language L ={ n + is regular (B) The language L = * n is prime+ is regul r (C) The language L=*w w h s 3 + s for some with * + + is regul r (D) The language * ++ L = *ww w with is regul r. 20.
Let L be a language and be its complement. Which one of the following 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.
Which of the regular expressions given below represent the following DFA? 0 0 1
1
I) II) III) (A) (B)
0*1(1 + 00* 1)* 0*1* 1+ 11* 0* 1 (0 + 1)* 1 I and II only (C) II and III only 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
TOC
Let A B denotes that language A is mapping reducible (also known as manyto-one reducible) to language B. Which one of the following is FALSE? (A) If A B and B is recursive then A is recursive. (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. (D) If A B and B is not recursively enumerable then A is not recursively enumerable.
[Ans. A] Every finite language is regular. Given language is finite hence it is regular [Finite language or those which have finite string of finite length is always regular]
middle of wwR. Hence only C seems to be correct answer. The r.e for (C) is 1(0 + 1)*1 + 0(0 + 1)*0. That is language of strings starts and ends with same symbol. Here acts as a marker to denote the end of w. 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 length >= 8(since all words more than 8 length can be formed using any combination of 111 and 11111) are in L. The corresponding DFA is given below: 1
1
1
1
1
q
1
1 1
[Ans. A] We will use Arden theorem to solve this. So the derivation is as follows: = q0 (a + b) + - - - -(1) Then using Arden, we q0 = ( + ) = (a + b)* - - - - (2) q1 = q0 a = (a + b)*a - - - - - (3) 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 correct choice.
5.
[Ans. C]
6.
[Ans. C] A B D n’t etermine the en of w n start of w . If language is regular then an FA definitely exists for it. Let us try to design FA for each option. No FA can remember
q
Here, in all strings accepted by this automation, at least one a is necessary to take from initial state to first final state q1 but another a is not mandatory because string a is perfectly acceptable by this automaton. q is the initial state. From q to q the regular expression is b* a. After that, every combination of a and b is accepted by q or q ( + ). r
1
4.
q
8.
[Ans. B] The minimum state FSA contains 2 states as given below for the regular expression b*a(a+b)* a, b
b
a
q
9.
q
[Ans. B] (A) is false. Consider L = {w | where w is in {a, b} *} and L1 = {anbn| where n > = 0}; Clearly is a subset of L and L1 is not a regular. (B) is true; since all finite sets are regular. (C) is false; consider non-regular set th
L1 = {anbn| where n > = 0} and its complement . The union over these two is {a, b}* which is regular. Every finite set must be regular, so (B) must be true. 10.
[Ans. A] Draw the two automata and use product construction.
11.
[Ans.C] Either you n use Ar en’s theorem or y careful observation we can solve this. [Q] accepts string ending with 0. [R] accepts strings ending with 1. Thus only [C] is the suitable choice
12.
[Ans. A] Set [1] is regular as FA exists and we can write r.e also. The r.e is a*(bb)* (b symbol should occur in multiple of 2). Set [2] and [3] are not regular as there is no finite automaton exists that can remember the count of a as to compare with count of b. Set [4] again is regular. The r.e for it is (a + b)* c (a +b)*.
13.
[Ans. A] Both automata epts ll strings of n ’s th t h ve two onse utive ’s.
’s
14.
[Ans. C] (A) and (D) cannot be the answer because in each case minimum 2 number of ’s is gu r ntee not ex tly one . (B) also cannot be the answer because it imposes one restri tion th t oth the ’s should be consecutive.
15.
[Ans. C] The string generates all the strings which ont ins tle st zero’s
TOC
16.
[Ans. B] Choice (A) (0*10*1)* will always generate strings ending with 1. But we want an expression for bit strings with even num er of ’s whi h in lu es strings li e “ ” whi h en s with . So choice (A) is not correct. Choice (C) 0* (1 0 *1)* 0* “ ” *( * )* * ut “ ” h s even num er of ’s So choice (C) is incorrect Choice (D) *1(10*1)*10* but is a it string with even num er of ’s (zero ’s). So hoi e (D) is in orre t. Choice (B) can generate all bit strings with even num er of ’s. So choice (B) is correct.
17.
[Ans. C] L = {ab, aa, baa} The breakdown of the strings 1, 2, 4, in terms of ab, aa and baa is shown below: 1. ab aa baa ab aa 2. aa aab aa aa 3. baa aa ab aa String no. 3 has no breakdown in terms of strings in L and hence string 3 does not belong to L*. Only 1, 2 and 4 belongs to L*.
18.
[Ans. A] * + As is empty language so multiplication of with any language will give . So . Also ,εfor all language Also [ -* ε So gives ε So *ε+ Option (A) is correct.
19.
th
[Ans. C] * n +is not regular because n FS nnot e written th t will ‘ ount’ i enti l sequen es of ‘ ’ n symbols
* n is prime+is not regular because an FSM cannot be written that will determine n is prime number or not * + is not *ww w with 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.
Context Free Grammar CS – 2005 1. Consider the languages ={ nm } and ={ nm } Which one of the following statement is false? (A) is a context-free language (B) is a context-free language (C) and are context-free languages (D) is a context sensitive language 2.
3.
4.
Let L be a regular language and M be a context free language, both over the lph et Σ. et and denote the complements of L and M respectively. Which of the following statements about the language is TRUE? (A) It is necessarily regular but not necessarily context free (B) It is necessarily context free (C) It is necessarily non-regular (D) None of the above Let and denote the classes of languages accepted by non-deterministic finite automata and non-deterministic push-down automata, respectively. Let D and D denote the classes of languages accepted by deterministic finite automata and deterministic push-down automata, respectively. Which one of the following is TRUE? (A) D and D (B) D and D = (C) D = and D = (D) D = and D Let be a recursive language, and let be a recursively enumerable but not a recursive language. Which one of the following is TRUE? (A) ̅ is recursive and ̅ is recursively enumerable
(B) ̅ is recursive and ̅ is not recursively enumerable (C) ̅ and ̅ are recursively enumerable (D) ̅ is recursively enumerable and ̅ is recursive. 5.
Consider the languages = *ww w * ++ = {w # w w * + + (Where # is a special symbol) = *ww w * + + Which one of the following is true? (A) is a deterministic CFL (B) is a deterministic CFL (C) is a CFL, but not a deterministic CFL (D) is a deterministic CFL
CS – 2006 6. Let L1 = { nm +, * nm + and L3 * nm + which of these languages are NOT context free? (A) L1 only (C) L1 and L2 (B) L3 only (D) L2 and L3 7.
If s is a string over (0 +1)*, then let n (s) denote the num er of ’s in s nd n1(s) the num er of ’s in s. Which one of the following languages is not regular? (A) L = {s ϵ (0 + 1)* | n0(s) is a 3-digit prime} (B) L = {s ϵ ( + )* for every prefix’s of s, | n0 (s ) – n1(s ) | 2} (C) L = {s ϵ (0 +1)* | n0(s) – n1(s) 4} (D) L = {s ϵ (0 + 1)* | n0(s) mod 7 = n1(s) mod 5 = 0}
8.
Consider the following statements about the context-free grammar, G *S →SS S → S→ S→ } 1. G is ambiguous 2. G produces all strings with equal num er of ’s nd ’s th
G can be accepted by a deterministic PDA. Which combination below expresses all the true statements about G? (A) 1 only (B) 1 and 3 only (C) 2 and 3 only (D) 1, 2 and 3 9.
10.
For s ( + )* let d(s) denote the decimal value of s (e.g.d(101) = 5). Let *s ( + )* d(s) mod 5 2 nd d(s) mod 7 4}? Which one of the following statements is true? (A) L is recursively enumerable, but not recursive (B) L is recursive, but not context-free (C) L is context-free, but not regular (D) L is regular Let L1 be regular language, L2 be a deterministic context-free language and L3 a recursively enumerable, but not recursive, language. Which one of the following statements is false? (A) L1 is a deterministic CFL (B) L3 is recursive (C) L1 L2 is context free (D) L1 is recursively enumerable
CS – 2007 11. The language L={0i 21i | i 0} over the alphabet {0, 1, 2) is (A) not recursive (B) is recursive and is a deterministic CFL (C) is a regular language (D) is not a deterministic CFL but a CFL
TOC
CS – 2009 13. S → S | bSb| a| b The language generated by the above grammar over the alphabet {a, b} is the set of (A) All palindromes (B) All odd length palindromes (C) Strings that begin and end with the same symbol (D) All even length palindromes 14.
Which one of the following is FALSE? (A) There is a unique minimal DFA for every regular language (B) Every NFA can be converted to an equivalent PDA (C) Complement of every context-free language is recursive (D) Every nondeterministic PDA can be converted to an equivalent deterministic PDA
15.
Let L = L1 where L1 and are languages as defined below: * mn + 2 * ijk + Then L is (A) Not recursive (B) regular (C) context – free but not regular (D) recursively enumerable but not contextfree
CS – 2010 16. Consider the language L1 = { L2 = { i j+ ( |i
i j+ 2j + +
L4 = { i 2j+. Which one of the following statements is true? (A) Only L2 is context free (B) Only L2 and L3 are context free (C) Only L1 and L2 are context free (D) All are context free
CS – 2008 12. If L and ̅ and recursively enumerable then L is (A) Regular (B) Context –free (C) Context –sensitive (D) Recursive th
Let L1 be a recursive language. Let L2 and L3 language that are recursively enumerable but not recursive. Which of the following statements is not necessarily true? (A) L2 L1 is recursively enumerable (B) L1 L3 is recursively enumerable (C) 2 is recursively enumerable (D) 2 is re ursively enumer le
CS – 2013 18. Consider the following languages. * + pqr * pqr p r+ 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
TOC
CS - 2014 19. Consider the following languages over the + alphabet ∑ * * n + *w w wϵ* + + *ww wϵ* + + Here, w is the reverse of the string w. Which of these languages are deterministic Context-free languages? (A) None of the languages (B) Only (C) Only and (D) All the three languages
Answer keys and Explanations 1.
[Ans. A] and are both context free languages. Context free languages are not closed under intersection.
2.
[Ans. D] The complement of CFL need not be a CFL. [A] is false; Let us consider Mc as a CFL, now remember not every CFL is regular. Therefore it is not necessary that union is regular. [B] is false; as we know complement may not CFL. Thus union over non-CFL with regular will result into non-CFL. [C] is false; it is not necessarily as argued in previously. Thus [D] is most appropriate choice
3.
[Ans. D] : Non-Deterministic finite automata. : Non-Deterministic push-down automata. D : Deterministic finite automata. D : Deterministic push down automata. A ording to “Su set Constru tion” theorem every language accepted by Nondeterministic-finite automata. ( ) is also accepted by some Deterministic-Finite automata (D ) so D = . Deterministic push-down automata (D ) recognizes a proper subset of the language of context-free languages and the non-deterministic push down automata recognizes the context-free languages. So D
[Ans. B] Given that is REC and is RE but not REC Consider choice (A) ̅ is REC and ̅ is RE. Since is REC, clearly ̅ is also REC. Since is RE but not REC, its complement has to be not RE. ∴ But (A) l ims th t ̅ is RE. Therefore (A) is false Consider (B) ̅ is REC and ̅ is not RE. If is REC, then ̅ is REC. Also, if is RE but not REC, then ̅ is not RE ∴(B) is true. Clearly (C) and (D) false since ̅ is not RE.
* same as context sensitive 7.
x
+ which is
[Ans. C] Choice (A) is regular since it is finite. Choice (B) is regular since although omp rison is m de etween ’s nd ’s it is for all prefixes and this can be done by DFA. Note: |n (s ) n (s ) 2 is s me s n (s ) n (s ) 2 or n (s ) n (s ) 2. Chose (C) involves comparison of number of ’s nd ’s ut for the string as a whole, and this cannot be done by a DFA, since it has finite memory and has no stack for counting upto infinity. Therefore, choice (C) is not regular Choice (D) is regular since n (s) mod 7 = n (s) mod 5 = 0 means num er of ’s is divisi le by 7 and num er of ’s is divisi le y 5 nd this can be accepted by a DFA with 7 × 5 = 35 states. A DFA that will accept the language of choice (B) is shown below:
[Ans. B] is CFL but not a DCFL, since accepting ww necessarily involves finding the middle of the string, which involves nondeterminism. ∴ (A) is false. is DCF is true sin e “#” is spe i l symbol and middle of string can now be surely found y using “#” there y eliminating the need for nondeterministic guessing. So (B) is true. is a CSL and not a CFL. So (C) is false. is not a DCFL either. So (D) is false. [Ans. D] * + is context free nm (first n+m ’s re pushed into the st k 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 empty then the word is accepted). * + is not nm context free, since two comparisons have to be made here to determine if w . . s nd s are equal 2. Since m
TOC
1
1
0
0
1
0
1
0
0, 1 0
0, 1
8.
[Ans. B] G *S → SS S → S→ S→ } 1. “G is m iguous” is true sin e “ ” has infinite number of derivations some of which are shown below:
on regular union, we can say that is surely CFL. is RE” is true sin e ll three are surely RE and RE languages are closed under intersection.
S
ε 2.
TOC
11.
[Ans. B] * 2 i } is a DCFL since, a DPDA can ept this l ngu ge. ’s re pushed into the stack and then when 2 appears in input, state is changed and immediately after that for every 1, a zero is popped out of the stack. In the end, if stack has start stack symbol only, then the string is accepted, else it is rejected. Since every DCFL is recursive, we can say that the language is recursive, and is a DCFL.
12.
[Ans. D] There is a theorem which states that
ε
“G produ es ll strings with equ l num er of ’s nd ’s” is f lse sin e L(G) = (ab + ba)* and this language cannot produce all strings with equal num er of ’s nd ’s. For ex mple aabb h s equ l num er of ’s nd ’s ut ∉ (G). “G n e epted y DPDA” is true, since L(G) = (ab + ba)* and this is a regular language, since we have written a regular expression for it. Since every regular language is also a DCFL, a DPDA exists, which accepts this language.
9.
[Ans. D] There is a DFA corresponding to d(s) mod 5 = 2 as well as d(s) mod 7 = 4. Therefore, both of them are regular languages. Let they be and . The given language is . Since regular languages are closed under intersection and complementation, the given language is also regular.
10.
[Ans. B] Given be regular, is DCFL and is RE but not REC. A. “ is DCF ” is true sin e DCF ’s are closed under regular intersection. B. “ is re ursive” is f lse sin e is RE but not REC and therefore is surely RE according to closure of RE under regular intersection, but we cannot be sure that is REC. C. “ is CF ” is true sin e is DCFL and hence a CFL and is regul r. Therefore y losure of CF ’s
whenever L and will be REC.
are both RE, then both
13.
[Ans. B] S→ S S is the grammar corresponding to all odd length palindromes. Notice that choice (C)is not correct since "abaa" is a string that begins and ends with the same symbol but cannot be generated by above grammar. Since all strings generates by this grammar have odd length, choices (A) and (D) are also incorrect.
14.
[Ans. D] The set of DCF ’s re proper su l ss of the set of CF ’s of PDA’s. So, choice (D) is false.
15.
[Ans. C] * m n 0} { |i j k + L= is context free language and regular language, as intesection of
is context free language, L is a context free. 16.
[Ans. D] L1 = { i j+ L2= { i j+ L3 * i 2j + + L4 = { i 2j+ All of nd are context free, 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.
19.
th
TOC
[Ans. C] For = *ww wϵ( ) + It can not be predicted that where w is ending and where w is starting But in * + n Both inputs are different and in L2 = *w w wϵ( ) + w and w are separated by an alphabet c.
Turing Machines CS – 2005 1. Consider three decision problems n . It is known that is decidable and is undecidable. Which one of the following is TRUE? (A) is decidable if is reducible to (B) is undecidable if is reducible to
2.
(C)
is undecidable if
(D)
is decidable if ’s complement
is reducible to is reducible to
Consider the following two problems on undirected graphs : Given G (V, E), does G have an in epen ent set of size ∣V∣ 4? : Given G (V, E), does G have an independent set of size 5? Which one of the following is TRUE? (A) is in the P and is NP-complete (B) is NP-complete and is in P (C) Both and are NP-complete (D) Both and are in P
CS – 2006 3. Let S be an NP –complete problem and Q and R be two other problems not known to be in NP. Q is polynomial-time reducible to S and S is polynomial-time reducible to R. Which one of the following statements is true? (A) R is NP-complete (B) R is NP-hard (C) Q is NP-complete (D) Q is NP-hard
4.
(C) DHAM3 is NP-hard, but SHAM3 is not (D) Neither DHAM3 nor SHAM3 is NP-hard CS – 2007 5. Which of the following problems is undecidable? (A) Membership problem for CFGs (B) Ambiguity problem for CFGs (C) Finiteness problems for FSAs (D) Equivalence problem for FSAs CS – 2008 6. Which of the following is true for the language {ap| p is a prime} ? (A) It is not accepted by a Turning Machine (B) It is regular but not context-free (C) It is context-free but not regular (D) It is neither regular nor context-free, but accepted by a Turning Machine
7.
Which of the following are decidable? 1. Whether the intersection of two regular languages is infinite 2. Whether a given context – free language is regular 3. Whether two push –down automata accept the same language 4. Whether a given grammar is context – free (A) 1 and 2 (C) 2 and 3 (B) 1 and 4 (D) 2 and 4
8.
Which of the following statement is false? (A) Every NFA can be converted to an equivalent DFA (B) Every non –deterministic Turing machine can be converted to an equivalent deterministic Turing machine (C) Every regular language is also a context –free language (D) Every subset of a recursively enumerable set is recursive
Let SHAM3 be the problem of finding a Hamiltonian cycle in a graph G = (V,E) with |V| divisible by 3 and DHAM3 be the problem of determining if a Hamiltonian cycle exists in such graphs. Which one of the following is true? (A) Both DHAM3 and SHAM3 are NP-hard (B) SHAM3 is NP-hard, but DHAM3 is not th
Which of the following statements are true? 1. Every left –recursive grammar can be converted to a right – recursive grammar and vice –versa 2. All ε- productions can be removed from any context – free grammar by suitable transformations 3. The language generated by a context – free grammar all of whose productions are of the from X w or X wY (where, w is a string of terminals and Y is a non–terminal), is always regular. 4. The derivation trees of strings generated by a context –free grammar in Chomsky Normal from are always binary trees (A) 1 ,2,3, and 4 (B) 2, 3 and 4 only (C) 1, 3 and 4 only (D) 1, 2 and 4 only Match List-I with List–II and select the correct answer using the codes given below the list: List -I a. Checking that identifiers are declared before their use b. Number of formal parameters in the declaration of a function agrees with the number of actual parameters in a use of that function c. Arithmetic expression with matched pairs of parentheses d. Palindromes List –II 1. L = * c |n m + 2. X X b X| Xc XC d X f| g 3. L = {wcw| w ∈ (a | b) *} 4. X b X b| c X c| ε Codes: (A) (B) (C) (D)
a 1 3 3 1
b 3 1 1 3
c 2 4 2 4
d 4 2 4 2
TOC
CS – 2011 11. Consider the languages L1, and as given below. |p q ∈ + L1 = * * |p q ∈ = n p q+ n |p q r ∈ =* n p q r+ Which of the following statements is NOT TRUE? (A) Push Down Automata (PDA) can be used to recognize L1 and (B) L1 is a regular language (C) All the three languages are context free (D) Turing machines can be used to recognize all the languages
12.
Which of the following pairs have DIFFERENT expressive power? (A) Deterministic finite automata (DFA) and Non-deterministic finite automata (NFA) (B) Deterministic push down automata (DPDA) and Non-deterministic push down automata (NPDA) (C) Deterministic single-tape Turing machine and Non-deterministic single-tape Turing machine (D) Single-tape Turing machine and multi-tape Turing machine
CS – 2012 13. Which of the following problems are decidable? 1. Does a given program ever produce an output? 2. If L is a context-free language, then ̅ also context-free? 3. If L is a regular language, then is ̅ also regular? 4. If L is a recursive language, then, is ̅ also recursive? (A) 1, 2, 3, 4 (C) 2, 3, 4 (B) 1, 2 (D) 3, 4
Assuming ≠ N which of the following is TRUE? (A) NP-complete = NP (B) NP-complete ∩ ∅ (C) NP-hard = NP (D) P = NP-complete
18.
CS – 2013 15. Which of the following statement is/are FALSE? 1. For every non – deterministic Turing machine, there exists an equivalent deterministic Turning machine. 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.
TOC
Which one of the following problems is undecidable? (A) Deciding if a given context-free grammar is ambiguous. (B) Deciding if a given string is generated by a given context-free grammar. (C) Deciding if the language generated by a given context-free grammar is empty. (D) Deciding if the language generated by a given context-free grammar is finite.
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 be the encoding of a Turing machine as a string over ∑ = {0,1}. Let L = {| 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
[Ans. C] Note that in general if , decidable ⟹ decidable and undecidable ⟹ is undecidable. Given that is decidable and is undecidable. Consider (A) is decidable if is reducible to i.e and if is undecidable, then would be undecidable. But it is given that and decidable, therefore we cannot use this theorem. (A) is false. Consider (B) is undecible if is reducible to i.e. Now if is undecidable then is undecidable but nothing is given regarding . Also if is decidable, then would be decidable, but it is given that is un eci le so we c n’t use this (B) is false. Consider (C) is undecidable if is reducible to i.e Now if is undecidable, this would mean is undecidable. Since it is given that is undecidable, therefore, surely is undecidable is correct. Choice (C) is correct [Ans. C] Consider the statement. : Given G(V E) oes G h ve n independent set of size |V| : Let G contains n nodes and assume |n| = K for some constant K so there is a polynomial time reduction from 3SAT then is lso N -complete. : Given G(V E) oes G h ve n independent set of size 5 is also NP-complete, reduction from 3SAT.
and Since S is NP-complete ⟹ R is NP-complete. ∴ (A) is true 4.
[Ans. A] HA be the problem of finding Hamiltonian cycle in a graph G = (V, E) with |V| is divisible by 3 contains three remainders either 0, 1 and 2 can be reduced to this problem 3SAT and hence HA is NP-complete problem. DHA be the problem of determining if a Hamiltonian cycle exists is also a reduction from 3SAT and hence it is also NP-complete problem. So both DHA and HA are NP complete and hence NP Hard also.
5.
[Ans. B] (A) em ership pro lem of CFG’s is decidable (CYK algorithm exists). (B) Ambiguity problem of CFG’s is undecidable. (C) Finiteness pro lem of F A’s is decidable, since there exists an algorithm to check if a given regular language L is finite or infinite. (D) Equiv lence pro lem for F A’s is decidable, since there exists an algorithm to check where L( ) ( ) or not.
6.
[Ans. D] Let L = { | p is a prime} the statement (D) is true. There is no DFA which recognizes the L or apply the pumping lemma then we can say that is not a regular language. It is not context free either, but L is surely accepted by a (linearly bounded) Turning machine.
[Ans. A] Note: then is NP-complete ⟹ is NP-complete. Given S, is NP-complete. th
[Ans. B] 1. “Intersection of two regul r l ngu ges is infinite” is eci le since we can construct a product DFA of the 2 given DFA’s and then, using the algorithm to check finiteness or infiniteness on this 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 l ngu ge” is un eci le since equiv lence of CF ’s is un ecidable. 4. “Whether given gr mmar is context – free” is eci le since we c n easily check using a TM, whether the LHS of every production has a single variable and, then it is a CFG, else it is not a CFG. ∴ n re eci le [Ans. D] (A) True (B) True (C) True (D) Every subset of a recursively enumerable set is recursive, is false, since a set is a subset of itself and there are RE languages, which are not recursive. [Ans. C] 1. True 2. All ε - productions can be removed from only context free grammars th t pro uce λ – free CF ’s If λ ε L(G), then all ε - productions cannot be successfully removed. So 2 is false 3. True 4. True, since is Chomsky normal form, every production is of the form of A BC or A An example of a binary tree generated by CNF derivation is shown below:
TOC
S
A
B
a
C
D
c
d
10.
[Ans. C] In *w c w | w ∈ ( | )*+ leftmost w is the identifier checking and rightmost w is the use of w. In c the actual parameters are and and the formal parameters and c and such that the number of arguments of a and b are equal to c and d respectively. The gr mm r *X X X|XcX| Xf|g+ generates the arithmetic expressions with matched pair of parentheses. The gr mm r *X X |cXc|ε} generates the palindromic string.
11.
[Ans. C] is not context free. (It fails to satisfy pumping lemma for context free languages.) One can also infer the answer by observing that options A, B and D which are true.
12.
[Ans. B] DFA ≡ NFA D DA ≠ N DA DT ≡ NT ingle t pe T ≡
13.
th
ulti-tape TM
[Ans. D] If L is regular, ̅ is surely regular. So statement number (3) is trivially decidable. Also if L is recursive, ̅ is also surely recursive. So statement number (4) is also trivially decidable.
Complement of a context free language, may or may not be context free. So statement number (2) is not only a non trivial problem but is also undecidable. Statement (1) is undecidable. Correct option is (D) i.e. only 3 and 4 are decidable. 14.
15.
[Ans. B] L is NP complete iff ( ) ∈N H (2) ∈ N (A) ∴ ption c n t e s N -complete ‘N ’ ut not ‘ ’ ption C: NPH can be NP or not be NP ∴ ption C lso not correct ∴ ption B : N complete ∩ P= correct answer.
16.
[Ans. D] 1. G is CFG, Is L(G) = ? Decidable, because in CFG there exits a algorithm to check whether L(G) = . 2. G is CFG, Is L(G) = ∑* un eci le no algorithm exits. 3. M is turning machine, Is L(M) regular, undecidable. 4. A is a DFA and N is NFA, Is L(A) =L(N), Trivially true so decidable.
17.
[Ans. B] Undecidable because L = {< M >|M is a turing machine} And halting of a turing machine is undecidable problem. Recursively enumerable because given that turing machine accepts a string of length 2014.
18.
[Ans. A] There were algorithm to find the membership of CFG (using CYK algorithm) and finiteness of CFG (using CNF graph) and emptiness. But there is no algorithm for ambiguity of CFG, so it is undecidable.
is
is
[Ans. C] 1. Non-deterministic turning machine can be simulated into an equivalent deterministic turing machine. So for every non deterministic turing machine there exits an equivalent deterministic turing machine. So true. 2. Turing recognizable language are closed under complementation so 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.
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 1000) 0 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
Memory Hierarchy CS – 2005 1. What is the swap space in the disk used for? (A) Saving temporary html pages (B) Saving process data (C) Storing the super-block (D) Storing device drivers 2.
Increasing the RAM of a computer typically improves performance because (A) Virtual memory increases (B) Larger RAMs are faster (C) Fewer page faults occur (D) Fewer segmentation faults occur
3.
Consider a direct mapped cache of size 32KB with block size 32 bytes. The CPU generates 32 bit addresses. The number of bits needed for cache indexing and the number of tag bits are respectively (A) 10, 17 (C) 15, 17 (B) 10, 22 (D) 5, 17
4.
Consider a 2-way set associative cache memory with 4 sets and total 8 cache blocks (0-7) and a main memory with 128 blocks (0-127). What memory blocks will be present in the cache after the following sequence of memory block references if LRU policy is used for cache block replacement. Assuming that initially the cache did not have any memory block from the current job? 0 5 3 9 7 0 16 55 (A) 0 3 5 7 16 55 (B) 0 3 5 7 9 16 55 (C) 0 5 7 9 16 55 (D) 3 5 7 9 16 55
6.
A computer system has a level 1 instruction cache (I cache), a level 1 data cache (D-cache) and a level 2 cache (L2 – cache) with the following specifications: Capacity Mapping Block method size I4K Direct 4 cache words mapping words D4K 2-way set- 4 cache words associative words mapping L264K 4-way set- 16 cache words associative words mapping The length of the physical address of a word in the main memory is 30 bits. The capacity of the tag memory in the I-cache, D-cache and L2-cache is, respectively, (A) 1 K×18-bit, 1K ×19-bit, 4K×16-bit (B) 1K ×16-bit, 1K × 19-bit, 4K×18-bit (C) 1K ×16-bit, 512×18-bit, 1K×16-bit (D) 1K ×18-bit, 512 ×18-bit, 1K ×18-bit
7.
A CPU has a cache with block size 64 bytes. The main memory has k banks, each bank being c bytes wide. Consecutive c-byte chunks are mapped on consecutive banks with warp-around. All the k banks can be accessed in parallel, but two accesses to the same bank must be serialized. A cache block access may involve multiple iterations of parallel bank accesses depending on the amount of data obtained by accessing all the k banks in parallel. Each iteration requires decoding the bank numbers to be accessed in parallel and this takes k/2 ns. The latency of one bank access is 80 ns. If c = 2 and k = 24, then latency of retrieving a cache block starting at address zero from main memory is (A) 92 ns (C) 172 ns (B) 104 ns (D) 184 ns
CS – 2006 5. A cache line is 64 bytes. The main memory has latency 32ns and bandwidth 1GBytes/s. The time required to fetch the entire cache line from the main memory is (A) 32 ns (C) 96 ns (B) 64 ns (D) 128 ns th
Common Data for Q.8& Q.9 Consider two cache organizations: The first one is 32 KB 2-way set associative with 32-byte block size. The second one is of the same size but direct mapped. The size of an address is 32 bits in both cases. A 2-to- 1 multiplexer has latency of 0.6 ns while a k-bit comparator has a latency of k/10 ns. The hit latency of the set associative organization is h while that of the direct mapped one is h . The value of h is (A) 2.4 ns (C) 1.8 ns (B) 2.3 ns (D) 1.7 ns The value of h is (A) 2.4 ns (B) 2.3 ns
(C) 1.8 ns (D) 1.7 ns
Linked Answer Questions Q.10 & Q.11 A CPU has a 32 KB direct mapped cache with 128-byte block size. Suppose A is a two dimensional array of size 512 512 with elements that occupy 8-bytes each. Consider the following two C code segments, P1 and P2 ) P1 : for (i i i { ) for(j j j { [i][j] x } } P2 : for (i { for(j
i j
(C) 16384 (D) 262144
12.
A CPU has 24-bit instructions. A program starts at address 300(in decimal). Which one of the following is a legal program counter (all values in decimal)? (A) 400 (C) 600 (B) 500 (D) 700
CS – 2007 13. Consider a Direct Mapped Cache with 8 cache blocks (numbered 0 7). If the memory block requests are in the following order 3, 5, 2, 8, 0, 63, 9, 16, 20, 17, 25, 18, 30, 24, 2, 63, 5, 82, 17, 24. Which of the following memory blocks will not be in the cache at the end of the sequence? (A) 3 (C) 20 (B) 18 (D) 30 Statement for Linked Answer Questions 14 and 15: Consider a machine with a byte addressable main memory of bytes. 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 in the main memory starting from memory location 1100 H. Assume that the data cache is initially empty. The complete array is accessed twice. Assume that the contents of the data cache do not change in between the two accesses.
)
[j][i]
} } P1 and P2 are executed independently with the same initial state, namely, the array A is not in the cache and i, j, x are in registers. Let the number of cache misses experienced by P1 be and that for P2 be
is
The value of the ratio is (A) 0 (C) 1/8 (B) 1/16 (D) 16
{ {x
The value of (A) 0 (B) 2048
11.
)
i j
10.
Computer Organization
14.
th
How many data cache misses will occur in total? (A) 48 (C) 56 (B) 50 (D) 59
Which of the following lines of the data cache will be replaced by new blocks in accessing the array for the second time? (A) line 4 to line 11 (B) line 4 to line 12 (C) line 0 to line 7 (D) line 0 to line 8
3. 4. (A) (B) (C) (D)
Consider a 4-way set associative cache consisting of 128 lines with a line size of 64 words. The CPU generates a 20-bit address of a word in main memory. The number of bits in the TAG, LINE and WORD fields are respectively (A) 9, 6, 5 (C) 7, 5, 8 (B) 7, 7, 6 (D) 9, 5, 6
CS – 2008 17. For a magnetic disk with concentric circular tracks, the seek latency is not linearly proportional to the seek distance due to (A) Non - uniform distribution of requests (B) Arm starting and stopping inertia (C) Higher capacity of tracks on the periphery of the platter (D) Use of unfair arm scheduling policies 18.
19.
In an instruction execution pipeline , the earliest that the data TLB (Translation Look aside Buffer) can be accessed is (A) Before effective address calculation has started (B) During effective address calculation (C) After effective address calculation has completed (D) After data cache lookup has completed For inclusion to hold between two cache level L1 and L2 in a multilevel cache hierarchy, which of the following are necessary? 1. L1 must be a write –through cache 2. L2 must be write –through cache
20.
Computer Organization
The associativity of L2 must be greater than that of L1 The L2 cache must be at least as large as the L1 cache 4 only 1 and 4 only 1, 3 and 4 only 1, 2, 3 and 4
Common Data For Q.20, Q.21& Q.22 Consider a machine with a 2-way set associative data cache of size 64K bytes and block size 16 bytes.The cache is managed using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins as follows: ][ ]; double ARR [ int i, j; /* initialize array ARR to 0.0 */ for (i=0; i 1024;i++) for (j=0, j 1024; j ++) ARR [i] [j] = 0.0; The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0 x FF000 and stored in row major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by the program are those to array ARR. The total size of the tags in the cache directory is (A) 32 Kbits (C) 64 Kbits (B) 34 K bits (D) 68 K bits
21.
Which of the following array elements has the same cache index as ARR [0] [0]? (A) ARR [0] [4] (C) ARR [0][5] (B) ARR [4][0] (D) ARR [5][0]
22.
The cache hit ratio for initialization loop is (A) 0% (C) 50% (B) 25% (D) 75%
CS – 2009 Common Data for Question 23 and 24 A hard disk has 63 sectors per track, 10 platters each with 2 recording surfaces and 1000 cylinders. The address of a sector is given as a triple〈 h 〉, where c is the cylinder number, h is the surface number and s is the sector number. Thus, the sector is addressed as 〈 〉 , the 1st sector as 〈 〉 and so on. 〉 corresponds to 23. The address 〈 sector number: (A) 505035 (C) 505037 (B) 505036 (D) 505038 24.
The address of 103 〉 (A) 〈 〉 (B) 〈
sector is (C) 〈 (D) 〈
for L1 cache, L2 cache and main memory unit respectively. L1 Cache
How many 32K × 1 RAM chips are needed to provide a memory capacity of 256 K-bytes = (A) 8 (C) 64 (B) 32 (D) 128
26.
Consider a 4-way set associative cache (initially empty) with total 16 cache blocks. The main memory consists of 256 blocks and the request for memory blocks is in the following order: 0,255,1,4,3,8,133,159,216,129,63,8,48, 32, 73, 92,155 Which one of the following memory block will not be in cache if LRU replacement policy is used? (A) 3 (C) 129 (B) 8 (D) 216
CS - 2010 Common Data for Questions 27 and 28: A computer system has an L1 and an L2 cache, and a main memory unit connected as shown below. The block size in L1 cache is 4 words. The block size in L2 cache is 16 words. The memory access times are 2 nanoseconds, 20 nanoseconds and 200 nanoseconds
Data Bus
L2 Cache
4 words
Data Bus
Main memory
4 words
27.
When there is a miss in L1 cache and a hit in L2 cache, a block is transferred from L2 cache to L1 cache. What is the time taken for this transfer? (A) 2 nanoseconds (B) 20 nanoseconds (C) 22 nanoseconds (D) 88 nanoseconds
28.
When there is miss in both L1 cache and L2 cache, first a block is transferred from main memory to L2 cache, and then a block is transferred from L2 cache L1 cache. What is the total time taken for these transfers? (A) 222 nanoseconds (B) 888 nanoseconds (C) 902 nanoseconds (D) 968 nanoseconds
29.
A main memory unit with a capacity of 4 megabytes is built using 1M 1-bit DRAM chips. Each DRAM chip has 1K rows of cells with 1K cells in each row. The time taken for a single refresh operation is 100 nanoseconds. The time required to perform one refresh operation on all the cells in the memory unit is (A) 100 nanoseconds (B) 100 nanoseconds (C) 100 nanoseconds (D) 3200 nanoseconds
〉 〉
25.
Computer Organization
CS - 2011 30. An 8KB direct-mapped write-bank cache is organized as multiple blocks, each of size 32-bytes. The processor generates 32-bit addresses. The cache controller maintains the tag
information for each cache block comprising of the following. 1 Valid bit 1 Modified bit As many bits as the minimum needed to identify the memory block mapped in the cache. What is the total size of memory needed at the cache controller to store meta-data (tags) for the cache? (A) 4864 bits (C) 6656 bits (B) 6144 bits (D) 5376 bits CS - 2012 Statement for linked Answer Question 31 and 32: A computer has a 256Kbyte, 4-way set associative, write back data cache with block size of 32 Bytes. The processor sends 32 bit addresses to the cache controller. Each cache tag directory entry contains, in addition to address tag, 2 valid bits, 1 modified bit and 1 replacement bits 31. The number of bits in the tag field of an address is (A) 11 (C) 16 (B) 14 (D) 27
32.
The size of the cache tag directory is (A) 160 Kbits (C) 40 Kbits (B) 136 Kbits (D) 32 Kbits
The lines in set s are sequenced before the lines in set (s+1). The main memory blocks are numbered 0 onwards. The main memory block numbered j must be mapped to any one of the cache lines from (A) (j mod v ) k to (j mod v) k+(k 1) (B) (j mod v ) to (j mod v) +(k 1) (C) (j mod k) to (j mod k) +(v 1) (D) (j mod k ) v to (j modk) v+(v 1) CS - 2014 35. An access sequence of cache block addresses is of length N and contains n unique block addresses. The number of unique block addresses between two consecutive accesses to the same block addresses is bounded above by k. What is the miss ratio if the access sequence is passed through a cache of associatively A k exercising least – recently – used replacement policy? (A) n/N (C) 1/A (B) 1/N (D) k/n 36.
A 4-way set-associative cache memory unit with a capacity of 16 kB is built using a block size of 8 words. The word length is 32 bits. The size of the physical address space is 4 GB. The number of bits for the TAG field is ________________.
37.
In de igning a omputer’ a he y tem the cache block (or cache line) size is an important parameter. Which one of the following statements is correct in this context? (A) A smaller block size implies better spatial locality (B) A smaller block size implies a smaller cache tag and hence lower cache tag overhead (C) A smaller block size implies a larger cache tag and hence lower cache hit time (D) A smaller block size incurs a lower cache miss penalty
CS - 2013 33. A RAM chip has a capacity of 1024 words of 8 bits each (1K 8). The number of 2 decoders with enable line needed to construct a 16K 16 RAM from 1K RAM is (A) 4 (C) 6 (B) 5 (D) 7 34.
Computer Organization
In a k – way set associative cache, the cache is divided into v sets, each of which consists of k lines. The lines of a set are placed in sequence one after another. th
If the associativity of a processor cache is doubled while keeping the capacity and block size unchanged, which one of the following is guaranteed to be NOT affected? (A) Width of tag comparator (B) Width of set index decoder (C) Width of way selection multiplexor (D) Width of processor to main memory data bus
Computer Organization
modules may overlap in time, but only one request can be on the bus at any time. The maximum number of stores (of one word each) that can be initiated in 1 millisecond is ____________ 40.
Consider a main memory system that consists of 8 memory modules attached to the system bus, which is one word wide. When a write request is made, the bus is occupied for 100 nanoseconds (ns) by the data, address, and control signals. During the same 100 ns, and for 500 ns thereafter, the addressed memory module executes one cycle accepting and storing the data. The (internal) operation of different memory
The memory access time is 1 nanosecond for a read operation with a hit in cache, 5 nanoseconds for a read operation with a miss in cache, 2 nanoseconds for a write operation with a hit in cache and 10 nanoseconds for a write operation with a miss in cache. Execution of a sequence of instructions involves 100 instruction fetch operations, 60 memory operand read operations and 40 memory operand write operations. The cache hit-ratio is 0.9. The average memory access time (in nanoseconds) in executing the sequence of instructions is __________.
Answer keys and Explanations 1.
[Ans. B] Saving process data.
2.
[Ans. C] Increasing the RAM means increase the primary memory which reduces the swapping so fewer page faults occur
3.
[Ans. A] Size of cache = 32 KB = 32 bytes = yte yte it Size of tag = 32 – 15 = 17 bits Cache indexing size = 10 bits
4.
5.
[Ans. C] Latency time = 32 ns. Bandwidth = 1GB / sec 1 sec = bytes Or bytes = 1sec 64 bytes = 64 n sec Total time = 64 + 32 = 96 ns
6.
[Ans. A] For I cache: Number of block = 1 k 10 bits can be used to distinguish between blocks 1 block = 4 Words 2 bits to recognize between words
30
[Ans. C] Notice here conflict occurs in placement of block 55 3 is come first and never refuse so in this set 3 is only victim for replacement
For the next 15 address, there will be hit as A [0] [0] to A [0] [15] are there in the cache.Then again there will be a miss at A [0] [16] and hit at next 15 accesses.
D – cache: Number of blocks = = 1k block 10 bits are enough to recognize b/w blocks. 2 bits are required to recognize among & words within a block and it uses 2 way set mapping 19 9 2 Since the # of tags are always same = k The size of tag memory is 19 × k Capacity of cache = 18 512 7.
[Ans. D] The main memory consists of 24 banks, each of c bytes. Since parallel accesses to all banks are possible. Only two parallel accesses of all banks are needed to traverse the whole data. For one parallel access, Total time = Decoding time + latency time =
+ 80 = 92 ns
[Ans. A] Tag Set 18 9
h
13.
[Ans. B] 0 8,0,16,24 1 9,17,25,17, 2 2,18,2,82 3 3 4 20 5 5 6 30 7 63 So, 18 is not present in final map shown of cache memory
14.
[Ans. C] 56 data cache misses will occur. There are 32 lines in the 50 × 50 array, therefore initial 32 misses + 8 misses (this will replace initial 8 lines data). In second round initial lines needs to be reloaded again so 8 more misses i.e. 48
15.
[Ans. A] Line 4 to line 11. At the last, while accessioning last 8 lines (33 40) aging initial 8-lines 4-11 of the
= 1.7 ns
Because multiplexer is not required in case of direct-mapping 10.
[Ans. C] Cache is 32 KB with 128 bytes block size. M1: When the first element A[0] [0] is accessed , 128 byte block consisting of
, there will be one
[Ans. C] Size of instruction 24 bits Starting address of the program is 300. The size of instruction is 3 bytes long. So the address is always the multiple of 3 byte next address is 600 it is also the next instruction of the program
Block 5
Block 5
transfer during miss and 15 hits
12.
= 2.4 ns [Ans. D] Tag Set 17 10
= 16384 blocks
[Ans. B] = 262144 (Because every access to array element is a miss)
h =
9.
There for every
11.
Hence, for 2 such accesses, time = 2 92 = 184 ns 8.
cache has to be reloaded has 8 more misses i.e. 48+8 = 56. 16.
17.
[Ans. D] No. of blocks in cache No. of blocks in main memory ⁄ ⁄ No. of sets in cache ) ⁄ TAG bits log( = 9bits LINE offset log(no of et ) log( ) it WORD offset log( ) it
Tag memory size = No. of sets No. of lines in a set No. of tag bits it it it 21.
[Ans. B] After every two elements the index increases once, therefore after 4048 elements the index will increment 2096 ( ) which is index size. Hence, ARR[0] [0] and ARR [4] [0] has the same.
22.
[Ans. C] Row major access a[0] [0] = Miss a[0] [1] = hit a[0] [2] = Miss a[0] [3] = hit ⋮ Every miss is followed by a hit
[Ans. C] Due to higher capacity of tracks on the periphery of the platter
18.
[Ans. C] Data TLB can be accessed only after effective address calculation has completed
[Ans. D] There are total 4 sets in the cache and each set contains 4 blocks. 0 48 4 32 Set 0 8 216 92 1 133 Set 1 73 129
of L1 is 4 words. So only 4 words will be transferred.Then it takes time 20 + 2 = 22 nano seconds 28.
[Ans. C] From main memory, now again time of access is 200ns. So access means for L2 came from main memory time ( ) ( )n ano e ond Similarly for cache to access from cache. L1 time ano e ond Totoal time required = 880 +22 = 902Nano seconds
255 155 3 Set 3 159 63 0 mod 4 = 0 set 0 255 mod 4 = 3 set 3 1 mod 4 = 1 set 1 4 mod 4 = 0 set 0 3 mod 4 = 3 set 3 8 mod 4 = 0 set 0 133 mod 4 = 1 set 1 159 mod 4 = 3 set 3 216 mod 4 = 0 set 0 129 mod 4 = 1 set 1 63 mod 4 = 3 set 3 8 mod 4 = 0 set 0 (already in cache) 48 mod 4 = 0 set 0 48 will replace block 0 using LRU 32 mod 4 = 0 set 0 32 will replace block 73 mod 4 = 1 set 1 92 mod 4 = 0 set 0 92 will replace block 216 155 mod 4 = 3 set 3 155 will replace 255
29.
[Ans. D] Main memory unit has capacity = 4MB um er of hip it it it hip ha ( ) rows and 1 K( ) cells In ea h row
[Ans. C] When a miss in in L1, then it goes to L2 and access the word but in 1 time only 4 words can be transferred because data bus can take 4 words at a time.Block size
31.
Set 2
27.
Computer Organization
Time taken in one refresh operation = 100ns Time required to perform one refresh operation on all the ell in unit ‘ n
30.
[Ans. D] No of blocks = Address format 19 8 5 Tag Block offset No. of tag bits per cache entry = 19 + 1 + 1 = 21 So total = [Ans. C] o of a he line o of et
[Ans. A] Tag directory size = Number of sets no of tags in each set (no. of tag bits in each tag + valid bits + modified bit + replacement bit) ( ) it ption i orre t
33.
[Ans. B] At 1st level we need 4 decoders to select 16 RAMS. At second level we need 1 decoder to select the 4 decoders of 1st level.
34.
[Ans. A] ain memory lo k ‘j’ mapped to any of cache line. Cache line range is: (j mod v)*k to (j mod v)*k + (k 1)
35.
[Ans. A] As given n N And the miss ratio will not be dependent on associativity and k and LRU policy will lead to n/N
36.
[Ans. 20] No. of sets = No. of Blocks =
[Ans. D] Width of processor to main memory data bus is independent of cache associativity
39.
[Ans. 10000] For 1 store time required = 100ns(because of overlape) So in 1ns no. of stores = In 1 ms no. of stores = = 10000
40.
[Ans. 1.68] Total instructions = 100 instruction fetch operations +60 memory operand read operations +40 memory operand write operations = 200 instructions (operations) Time taken for fetching 100 instructions (equivalent to read) = 90 × 1 ns + 10 × 5 ns = 140 ns Memory operand Read operation time = 90%(60) × 1ns +10%(60)×5 ns = 54 ns + 30 ns = 84 ms Memory operand write operation time = 90% (40)×2 ns+10%(40)×10 ns =72 ns + 40 ns = 112 ns Total time taken for execution 200 instructions = 140 + 84 + 112 = 336 ns n verage memory a e time
= 1.68 ns k lo k
Address length of memory = Address format:TAG Block Word Byte 20 7 3 2 TAG bits = 20 37.
38. 5
Word offset No. of Tag bits are 16 bits
Computer Organization
(
)
[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.
Pipeline CS - 2005 1. A 5 stage pipelined CPU has the following sequence of stages: IF – Instruction fetch from instruction memory, RD – Instruction decode and register read, EX – Execute: ALU operation for data and address computation, MA – Data memory access – for write access, the register read at RD stage it used, WB – Register write back. Consider the following sequence of instructions: : L R0, Loc 1; R0 ← M [Loc 1] : A R0, R0; R0 ← R0 + R0 :S R2, R0; R2 ← R2 – R0 Let each stage take one clock cycle.What is the number of clock cycles taken to complete the above sequence of instructions starting from the fetch of ? (A) 8 (C) 12 (B) 10 (D) 15 2.
We have two designs D1 and D2 for a synchronous pipeline processor. D1 has 5 pipeline stages with execution times of 3 nsec, 2 nsec, 4 nsec, 2 nsec and 3 nsec while the design D2 has 8 pipeline stages each with 2 nsec execution time. How much time can be saved using design D2 over design D1 for executing 100 instructions? (A) 214 nsec (C) 86 nsec (B) 202 nsec (D) 200 nsec
CS – 2006 3. A CPU has five-stage pipeline and runs at 1 GHz frequency. Instruction fetch happens in the first stage of the pipeline. A conditional branch instruction computes the target address and evaluates the condition in the third stage of the pipeline. The processor stops
fetching new instructions following a conditional branch until the branch outcome is known. A program executes 10 instructions out of which 20% are conditional branches. If each instruction takes one cycle to complete on average, then total execution time of the program is (A) 1.0 sec (C) 1.4 sec (B) 1.2 sec (D) 1.6 sec CS - 2007 4. Consider a pipelined processor with the following four stages IF : Instruction Fetch ID: Instruction Decode and Operand Fetch EX : Execute WB : Write Back The IF, ID and WB stages take one clock cycle each to complete the operation. The number of clock cycles for the EX stage depends on the instruction. The ADD and SUB instructions need 1 clock cycle and the MUL instruction need 3 clock cycles in the EX stage. Operand forwarding is used in the pipelined processor. What is the number of clock cycles taken to complete the following sequence of instructions? ADD R2,R1,R0 R2←R1+R0 MUL R4,R3,R2 R4←R3*R2 SUB R6,R5,R4 R6←R5 R4 (A) 7 (C) 10 (B) 8 (D) 14 CS - 2008 5. Which of the following are NOT true in a pipelined processor? 1. Bypassing can handle all RAW hazards. 2. Register renaming can eliminate all register carried WAR hazards. 3. Control hazard penalties can be eliminated by dynamic branch prediction th
What is the number of cycles needed to execute the following loop? for (i=1 to 2) {I1; I2; I3; I4 ;} (A) 16 (C) 28 (B) 23 (D) 30
Linked Answer Questions Q.6& Q. 7 Delayed branching can help in the handling of control hazards For all delayed conditional branch instructions, irrespective of whether the condition evaluates to true or false, (A) The instruction following the conditional branch instruction in memory is executed (B) The first instruction in the fall through path is executed (C) The first instruction in the taken path is executed (D) The branch takes longer to execute than any other instruction The following code is to run on a pipelined processor with one branch delays slot I1: ADD R2 ←R7 +R8 I2: SUB R4 ←R5 R6 I3: ADD R1 ←R2 + R3 I4: STORE Memory [R4] ←R 1 BRANCH to Label if R1 = = 0 Which of the instruction I1, I2, I3 or I4 can legitimately occupy the delay slot without any other program modification? (A) I1 (C) I3 (B) I2 (D) I4
CS - 2009 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
CS - 2010 9. A 5-stage pipelined processor has Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Perform Operation (PO) and Write Operand (WO) stages. The IF, ID, OF and WO stages take 1 clock cycle each for any instruction. The PO stage takes 1 clock cycle for ADD and SUB instructions, 3 clock cycles for MUL instruction, and 6 clock cycles for DIV instruction respectively. Operand forwarding is used in the pipeline. What is the number of clock cycles needed to execute the following sequence of instructions? Instruction Meaning of instruction : MUL R , R , R R ← R *R : DIV R , R , R R ←R R : ADD R , R , R R ← R +R : SUB R , R , R R ←R R (A) 13 (C) 17 (B) 15 (D) 19 CS - 2011 10. Consider an instruction pipeline with four stages (S1, S2, S3 and S4) each with combinational circuit only. The pipeline registers are required between each stage and at the end of the last stage. Delays for the stages and for the pipeline registers are as given in the figure
stage and the delay of each buffer is 1 ns. A program consisting of 12 instructions I1,I2, I3,…., 12 is executed in this pipelined processor. Instruction I4 is the only branch instruction and its branch target is I9. If the branch is taken during the execution of this program , the time (in ns) needed to complete the program is (A) 132 (C) 176 (B) 165 (D) 328
Stage S1 Delay 5ns
Pipeline Register (Delay 1ns)
Stage S2 Delay 6ns
Pipeline Register (Delay 1ns)
Stage S3 Delay 11ns
Pipeline Register (Delay 1ns)
Stage S4 Delay 8ns
Pipeline Register (Delay 1ns)
What is the approximate speed up of the pipeline in steady state under ideal conditions when compared to the corresponding non-pipeline implementation? (A) 4.0 (C) 1.1 (B) 2.5 (D) 3.0
CS – 2014 13. Consider a 6-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is executing on this 6-stage pipeline, the speedup achieved with respect to non-pipelined execution if 25% of the instructions incur 2 pipeline stall cycles is ______________________. 14.
Consider the following processors (ns stands for nanoseconds). Assume that the pipeline registers have zero latency. P1: Four-stage pipeline with stage latencies 1 ns, 2 ns, 2 ns, 1 ns. P2: Four-stage pipeline with stage latencies 1 ns, 1.5 ns, 1.5 ns, 1.5 ns. P3: Five-stage pipeline with stage latencies 0.5 ns, 1 ns, 1 ns, 0.6 ns, 1 ns. P4: Five-stage pipeline with stage latencies 0.5 ns, 0.5 ns, 1 ns, 1 ns, 1.1 ns. Which processor has the highest peak clock frequency? (A) P1 (C) P3 (B) P2 (D) P4
15.
An instruction pipeline has five stages, namely, instruction fetch (IF), instruction decode and register fetch (ID/RF), instruction execution (EX), memory access (MEM), and register write back (WB) with stage latencies 1 ns, 2.2 ns, 2 ns, 1 ns, and 0.75 ns, respectively (ns stands for nanoseconds). To gain in terms of
CS - 2012 11. Register renaming is done in pipelined processors (A) as an alternative to register allocation at compile time (B) for efficient access to function parameters and local variables (C) to handle certain kinds of hazards (D) as part of address translation CS – 2013 12. Consider an instruction pipeline with five stages without any branch prediction: Fetch Instruction (FI), Decode Instruction (DI), Fetch Operand (FO), Execute Instruction (EI) and Write Operand (WO). The stage delays for FI, DI, FO, EI and WO are 5ns, 7ns, 10ns, 8ns and 6ns, respectively. There are intermediate storage buffers after each
frequency, the designers have decided to split the ID/RF stage into three stages (ID, RF1, RF2) each of latency 2.2/3 ns. Also, the EX stage is split into two stages (EX1, EX2) each of latency 1 ns. The new design has a total of eight pipeline stages. A program has 20% branch instructions which execute in the EX stage and produce the next instruction pointer at the end of the EX stage in the old design and at the end of the EX2 stage in the new design. The IF stage stalls after fetching a branch instruction until the next instruction pointer is computed. All instructions other than the branch instruction have an average CPI
Computer Organization
of one in both the designs. The execution times of this program on the old and the new design are P and Q nanoseconds, respectively. The value of P/Q is __________. 16.
Consider two processors P and P executing the same instruction set. Assume that under identical conditions, for the same input, a program running on P takes 25% less time but incurs 20% more CPI (clock cycles per instruction) as compared to the program running on P . If the clockfrequency of P is 1GHz, then the clock frequency of P (in GHz) is _________.
Answers Keys and Explanations 1.
[Ans. B] Clock cycles 1 2 3 4 5 6 7 8 I R E M W F D X A B I R M W F D A B IF R E
9
Total time 80 20 10 ( 10 1+ 100 100 = + = 1.4 second
10
4. M D
X
W A
B
So, it requires 10 clock cycles 2.
3.
[Ans. B] Time required by design D1 (100 + 5 1) × 4 = 416nsec Time required by design D2 (100 + 8 1) × 2 = 214nsec So time saved using design D2 = 416 – 214 = 202nsec [Ans. C] For 80% of 10 instructions a single cycle is sufficient as there is no conditional branch. For the rest 20%, one extra cycle will be needed making the number of cycles required to 3. Total time will be computed as below One cycle takes = 10
10
3)
[Ans. B] Pipelined processor has four stages IF, ID, EX, WB Clock cycles Instruction 1 ADD 1 SUB 3 MVL Consider the following diagram Clock cycles
R ←R +R R ←R R ←R
R
1
2
3
4
IF
ID
EX
WB
IF
ID
EX
IF
ID
R
5
6
7
EX
EX
WB EX
8
WB
So total required clock cycle is 8. 5.
[Ans. D] All statements 1, 2 and 3 are false for a pipelined processor.
6.
[Ans. B] For all delayed conditional branch instruction the first instruction in the fall through path is executed and evaluates to true of false.
[Ans. B] Instruction 2 occupy the delay slot because data dependency of instruction 4
8.
[Ans. B] By showing cycle vs stage data for each instruction, it can be seen that the loop takes 23 cycles.
9.
[Ans. B] IF 1 1 1 1
11.
[Ans. C] Register renaming is used to handle data hazards.
12.
[Ans. B] Given: Five stage instruction pipeline delays for FI, DI, FO, EI and WO are 5,7,10,8,6ns resp. To find: since the maximum time taken by any stage is 10ns and additional 1 ns is required for delay of buffer Therefore total time for an instruction to pass from one stage to another is 11ns Now instructions are executed as follows
PO O PO PO
PO
PO
PO
PO
PO PO PO
,
,
,
,
,
,
,
c o Now when I4 is in its execution stage we detect the branch and when I4 is in WO stage we fetch I9 so time for execution of instructions from I1 to I4 is = 11 5 + (4 1) 11 =88 ns And time for execution of instructions from I9 to I12 is = 11 5 + (4 1) 11 = 88 ns But we have 11ns when fetching of 55 ns because time for fetching I9 can be overlap with WO of I4 Hence total times is = 88 +88 11 = 165 ns
O PO PO
PO PO PO O
PO PO PO O
WO
PO
PO
PO PO
PO
WO PO PO
PO
OW
15 14 13 12 11 10 9 8 4
7
WO 1 1 1 1
→
3
6
PO 3 6 1 1
No c o T P c o T Non pipeline Execution time S1 + S2 + S3 + S4 5 + 6 + 11 + 8 30 P c o ( )+ M (5 , 6 , 11 , 8 ) + 1 M 11 + 1 12 c 30 12 2.5
o 5 + )] T c oc P (0.8 + 0.12) 1 2 P 3.08 So o 1.54 Q 2
4
[Ans. C] Support n = 100 tasks. So time required for processing 100 tasks in processors: ( + (100 + 4 1)2 T 1) 206 ( + (100 + 4 1)1.5 T 1) 154.6 ( + (100 + 5 1)1 T 1) 104 ( + (100 + 5 1)1.1 T 1) 114.4 Best time = 104 [Here k = no.of stages, c oc c c ]
[80 (1c oc ) + 20
)
) 6 3 2
Computer Organization
16.
co
[Ans. 1.6] 1 cycle time P
1
Assume P takes 5 cycles for a program then P taken 20% more, means 6 cycles. P Takes 25% less time, means, if P takes 5 n.s, then P takes 3.75 ns. Assume P clock frequency is x GHz. P T 6c c , 6 10 o 3.75, 1.6
[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
Instruction Types CS – 2005 1. Consider a three word machine instruction “ADD A[ ], @B” The first operand (destin tion) A [ ] uses indexed addressing mode with R0 as the index register. The second operand (source) “@B” uses indirect ddressing mode. A and B are memory addresses residing at the second and the third words, respectively. The first word of the instruction specifies the opcode, the index register designation and the source and destination addressing modes. During execution of ADD instruction, the two operands are added and stored in the destination (first oper nd). The number of memory cycles needed during the execution cycle of the instruction is (A) 3 (C) 5 (B) 4 (D) 6
2.
Match List I(high level language statements) and List II(addressing modes) and pick the correct options . List I List II ( high level language (addressing modes) statements) 1. A [I] = B[J]; a. Indirect addressing 2. while (* A ++); b. Indexed addressing 3. int temp = *x; c. Auto increment (A) (1,c), (2,b), (3,a) (B) (1,a), (2,c), (3,b) (C) (1,b), (2,c), (3, a) (D) (1,a), (2,b), (3,c)
Common Data Questions Q.3 & Q.4 Consider the following data path of a CPU. MD R
MAR
S IR
T
PC GPRS
ALU
The, ALU, the bus and all the registers in the data path are of identical size. All operations including incrementation of the PC and the GPRs are to be carried out in the ALU. Two clock cycles are needed for memory read operation – the first one for loading address in the MAR and the next one for loading data from the memory bus into the MDR.
3.
The instruction “ dd , ” has the register transfer interpretation R0 ⇐ R0 + R1. The minimum number of clock cycles needed for execution cycle of this instruction is (A) 2 (C) 4 (B) 3 (D) 5
4.
The instruction “c ll n, sub” is two word instruction. Assuming that PC is incremented during the fetch cycle of the first word of the instruction, its register transfer interpretation is Rn< = PC + 1; PC < = M [PC]; The minimum number of CPU clock cycles needed during the execution cycle of this instruction is (A) 2 (C) 4 (B) 3 (D) 5
CS - 2006 5. Consider a new instruction named branch-on-bit-set (mnemonic bbs). The instruction “bbsreg, pos, l bel” jumps to label if bit in position pos of register operand reg is one. A register is 32 bits wide and the bits are numbered 0 to 31, bit in position 0 being the least significant. Consider the following emulation of this instruction on a processor that does not have bbs implemented. temp reg and mask Branch to label if temp is non-zero The variable temp is a temporary register. For correct emulation,the variable mask must be generated by (A) mask 0 pos (B) mask 0 ffffffff>> pos (C) mask pos (D) mask 0 f
6.
7.
The memory locations 1000, 1001 and 1020 have data values 18, 1 and 16 respectively before the following program is executed. MOVI Rs, 1;Move immediate LOAD Rd, 1000(Rs); Load from memory ADDI Rd, 1000;Add immediate STOREI 0(Rd), 20;Store immediate Which of the statements below is TRUE after the program is executed? (A) Memory location 1000 has value 20 (B) Memory location 1020 has value 20 (C) Memory location 1021 has value 20 (D) Memory location 1001 has value 20 Which of the following statements about relative addressing mode is FALSE? (A) It enables reduced instruction size (B) It allows indexing of array elements with same instruction (C) It enables easy relocation of data (D) It enables faster address calculations than absolute addressing
Computer Organization
CS - 2007 Common Data for Q.8 , Q.9 & Q10. Consider the following program segment. Here R1, R2 and R3 are the general purpose registers. Instruction Operation Instruction size (no. of words) ) R1 MOV R1,( 2 [ ] LOOP: [ ] MOV R2, M[R3] R2 1 ADD R2, R1 R2 1 MOV ( ), INC R3 DEC R1 BNZ LOOP
M [R3] 1 R3 R3 + 1 1 R1 R1 – 1 1 Branch on 2 not zero HALT `Stop 1 Assume that the content of memory location 3000 is 10 and the content of the register R3 is 2000. The content of each of the memory locations from2000 to 2010 is 100. The program is loaded from the memory location 1000. All the numbers are in decimal. Assume that the memory is word addressable. The number of memory references for accessing the data in executing the program completely is (A) 10 (C) 20 (B) 11 (D) 21
8.
9.
Assume that the memory is word addressable. After the execution of this program, the content of memory location 2010 is (A) 100 (C) 102 (B) 101 (D) 110
10.
Assume that the memory is byte addressable and the word size is 32 bits. If an interrupt occurs during the e ecution of the instruction “INC ”, what return address will be pushed on to the stack? (A) 1005 (C) 1024 (B) 1020 (D) 1040
Following table indicates the latencies of operations between the instruction producing the result and instruction using the result. Instruction Instruction Latency producing using the the result result ALU ALU 2 operation operation ALU Store 2 operation Load ALU 1 operation Load Store 0 Consider the following code segment. Load R1, Loc1; Load R1 from memory location Loc1 Load R2, Loc2; Load R2 from memory location Loc2 Add R1, R2, R1; Add R1 and R2 and save result in R1 Dec R2; Decrement R2 Dec R1; Decrement R1 Mpy R1, R2, R3; Multiply R1 and R2 and save result in R3 Store R3, Loc3; Store R3 in memory location Loc 3 What is the number of cycles needed to execute the above code segment assuming each instruction takes one cycle to execute? (A) 7 (C) 13 (B) 10 (D) 14
CS - 2008 12. Which of the following is/are true of the auto increment addressing mode? 1. It is useful in creating self relocating code 2. If it is included in an Instruction Set Architecture, then an additional ALU is required for effective address calculation 3. The amount of increment depends on the size of the data item accessed
(A) (B) (C) (D)
Computer Organization
1 only 2 only 3 only 2 and 3 only
13.
Which of the following must be true for the RFE (Return From Exception) instruction on a general purpose processor I. It must be a trap instruction II. It must be a privileged instruction III. An exception cannot be allowed to occur during execution of an RFE instruction (A) I only (B) II only (C) I and II only (D) I , II and III only
14.
The use of multiple register windows with overlap causes a reduction in the number of memory accesses for 1. function locals and parameters 2. register saves and restores 3. instruction fetches (A) 1 only (B) 2only (C) 3 only (D) 1,2 and 3
CS - 2010 15. The program below uses six temporary variables a, b, c, d, e, f. a=1 b = 10 c = 20 d= a+b e=c+d f=c+e b=c+e e=b+f d=5+e return d + f Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling? (A) 2 (C) 4 (B) 3 (D) 6 th
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 ____________.
[Ans. D] ADD A [ ], @B A [ ] uses index addressing mode as follow such that as the index register Regs [ ] Regs [ ] +Mem [Regs [B] +Regs [ ]…….. ( ) And @B uses indirect as follow ADD A [ ], @B Regs [ ] Regs [ ] + Mem [Mem[(B)]]………….. ( ) So the first instruction needed 3 memory cycles and the second needed 2 and one memory cycles in needed for writing the result into the memory. So, total 6 memory cycles are needed to execute ADD A [ ], @B
[Ans. A] bbsreg,pos, label temp reg and mark Branch to label if temp is nonzero. If we shift one position left by pos of 0x1 then it evaluate the bbs instruction and mask 1<
6.
[Ans. D] Content of register as program will be execute are = content of 1000 (1) = 1000 + 1 = 10001 memory address =1 = content of 1000 (1) = 1000 + 1 = 1001 memory address Add I. , 1000
[Ans. C] A [I] = B[J] indexed, While(*A++) Auto increment. int temp = Indired Addressing mode
), store ( means store 20 in the address value 1001
[Ans. B] The sequence of microinstruction take place in following cycles : I. Cycle : , II. Cycle : ,T III. Cycle : ,T ,A , 3 cycles will be required to execute.
4.
5.
[Ans. B] n C T C ( C) The sequence of microinstruction take place in following cycles. I cycle: C , , A ( A c n be lo ded with C ) II cycle: ,A , in III cycle: D , C ( D can be performed once A has been performed) c cles will be required to e ecute.
7.
[Ans. B] It does not allow indexing of array element with same instruction.
8.
[Ans. D] Given M[3000]=10 Instruction [ [ [
] ]or [
Required Memory Reference 1 10 10 Tot l
]
]
9.
[Ans. A] The register contain the memory location 2010 whose value is 100 at the end of loop BNZ loop
[ ] 1016 1020 So if an interrupt occurs during the execution of the instruction “INC 3” the return address 1024 will be pushed onto the stack. (Address of next instruction)
11.
R2 R3
R3+R1 ………… (f c e) R3+R1 ………… (b c e) R2+R3 ………… (e b f) R3 5+R1 ………… (d 5 e) return (R2+R3) ……… return (d + f) Hence 3 registers needed only. 16.
[Ans. D] LW R1, 20(R2) Instruction shows the source address can be formed by adding the constant with the R2 content. It is the MIPS instruction. R2 points the base address of an array and 20 points the index address of an array. Hence the addressing mode used for the above is based indexed Addressing mode. This addressing mode is used to implement the arrays
17.
[Ans. D] PC holds the value of next instruction to be executed we store the value of PC to MBR and then to memory. We are saving the value of PC in memory and new address value is loaded into PC. This can be done only in interrupt service option (D) is correct.
18.
[Ans. 16383] Instruction format of 32 – bit Opcode Reg Reg Immediate 1 2 operand 6 – bit 6– 6– 14 – bit bit bit Opcode = 6 – bit ( 5 intructions to support) Reg 1, Reg 2 = 6 – bit ( no. of registers) So, Immediate operand bits = 32 – (6 + 6 + 6) = 14 Max value to be represented by 14 bits is =
[Ans. B] All seven installations take 1 clock cycles. But 1 clock cycle latency needed b/w load R2, Loc 2, and Add R1, R2,1 lso, 2 clock cycles latency needed b/w Mpy R1, R2, R1 and store R3 ,Loc 3 S𝑜, 7 + 1 + 2 = 10
12.
[Ans. C] The amount of increment depends on the size of data item accessed
13.
[Ans. D] A RFE (Return From Exception) instruction contains a trap instruction, privileged instruction and an exception c n’t be llowed to occur during the execution of an REF instruction.
14.
[Ans. C] The use of multiple register windows with overlap causes a reduction in the number of memory accesses for the instruction fetches only.
15.
[Ans. B] Register operations ………… ( b ………… (b c ………… (c R1+R2 ………… (d R3+R1 ………… (e
I/O Data Transfer CS - 2005 1. Which one of the following is true for a CPU having a single interrupt request line and a single interrupt grant line? (A) Neither vectored interrupt nor multiple interrupting devices are possible (B) Vectored interrupts are not possible but multiple interrupting devices are possible (C) Vectored interrupts and multiple interrupting devices are both possible (D) Vectored interrupt is possible but multiple interrupting devices are not possible 2.
Normally user programs are prevented from handling I/O directly by I/O instructions in them. For CPUs having explicit I/O instructions, such I/O protection is ensured by having the I/O instructions privileged. In a CPU with memory mapped I/O, there is no explicit I/O instruction. Which one of the following is true for a CPU with memory mapped I/O? (A) I/O protection is ensured by operating system routine( ) (B) I/O protection is ensured by a hardware trap (C) I/O protection is ensured during system configuration (D) I/O protection is not possible
3.
A device with data transfer rate 10 KB/sec is connected to a CPU. Data is transferred byte-wise. Let the interrupt overhead be 4 μsec. The byte transfer time between the device interface register and CPU or memory is negligible. What is the minimum performance gain of operating the device under interrupt
mode over operating it under program controlled mode? (A) 15 (C) 35 (B) 25 (D) 45 4.
A hardwired CPU uses 10 control signals S1 to S10 in various time steps T1 to T5 to implement 4 instructions I1 to I4 as shown below.
T2
I1 S1, S3, S5 S2, S4, S6
T3
S1, S7
I2 S1, S3, S5 S8, S9, S10 S5, S6, S7
T4
S10
S6
T1
I3 S1, S3, S5 S7, S8, S10 S2, S6, S9
I4 S1, S3, S5 S2, S6, S7 S5, S10
S10
S6, S9
T5 S3, S8 S10 S1, S3 S10 Which of the following pairs of expressions represent the circuit for generating control signals S5 and S10 respectively. [Ij + Ik] Tn indicates that the control signal should be generated in time step Tn if the instruction being executed is Ij or Ik ? (A) S5 = T1 + I2. T3 & S10 = (I1 + I3). T4 + (I2 + I4). T5 (B) S5 = T1 + (I2 + I4). T3 & S10 = (I1 + I3). T4 + (I2 + I4). T5 (C) S5 = T1 + (I2 + I4). T3 & S10 = (I2 + I3 + I4). T2 + (I1 + I3).T4 + (I2+ I4). T5 (D) S5 = T1 + (I2 + I4). T3 & S10 = (I2 + I3). T2 + I4. T3 + (I1 + I3).T4 + (I2 + I4). T5 5.
An instruction set of a processor has 125 signals which can be divided into 5 groups of mutually exclusive signals as follows: Group 1: 20 signals, Group 2: 70 signals, Group 3: 2 signals, Group 4: 10 signals, Group 5: 23 signals.
How many bits of the control words can be saved by using vertical microprogramming over horizontal microprogramming? (A) 0 (C) 22 (B) 103 (D) 55 6.
7.
8.
Consider a disk drive with the following specifications: 16 surfaces, 512 tracks/surface, 512 sectors/track, 1 KB/sector, rotation speed 3000 rpm. The disk is operated in cycle stealing mode whereby whenever one 4 byte word is ready it is sent to memory; smilarly, for writing, the disk interface reads 4-byte word from the memory in each DMA cycle. Memory cycle time is 40 nsec. The maximum percentage of time that the CPU gets blocked during DMA operation is (A) 10 (C) 40 (B) 25 (D) 50 Statement for Linked Answer Questions 7 and 8 A disk has 8 equidistant tracks. The diameters of the innermost and outermost tracks are 1cm and 8 cm respectively. The innermost track has a storage capacity of 10MB. What is the total amount of data that can be stored on the disk if it is used with a drive that rotates it with (i) Constant Linear Velocity (ii) Constant Angular Velocity? (A) (i) 80 MB (ii) 2040 MB (B) (i) 2040 MB (ii) 80 MB (C) (i) 80 MB (ii) 360 MB (D) (i) 360 MB (ii) 80 MB If the disk has 20 sectors per track and is currently at the end of the 5th sector of the inner-most track and the head can move at a speed of 10 meters/sec and it is rotating at constant angular velocity of 6000 RPM, how much time will it take to
Computer Organization
read 1 MB contiguous data starting from the sector 4 of the outer-most track? (A) 13.5 ms (C) 9.5 ms (B) 10 ms (D) 20 ms CS - 2007 9. Consider a disk pack with 16 surfaces, 128 tracks per surface and 256 sectors per track. 512 bytes of data are stored in a bit serial manner in a sector. The capacity of the disk pack and the number of bits required to specify a particular sector in the disk are respectively (A) 256 Mbyte, 19 bits (B) 256 Mbyte, 28 bits (C) 512 Mbyte, 20 bits (D) 64 Gbyte, 28 bits CS - 2008 10. Which of the following statements about synchronous and asynchronous I/O is NOT true? (A) An ISR is invoked on completion of I/O in synchronous I/O but not in asynchronous I/O (B) In both synchronous and asynchronous I/O an ISR ( Interrupt Service Routine) is invoked after completion of the I/O (C) A process making a synchronous I/O call waits until I/O is complete, but a process making an asynchronous I/O call does not wait for completion of the I/O (D) In the case of synchronous I/O, the process waiting for the completion of I/O is woken up by the ISR that is invoked after the completion of I/O CS - 2009 11. A CPU generally handles an interrupt by executing an interrupt service routine (A) as soon as an interrupt is raised (B) by checking the interrupt register at the end of fetch cycle
(C) by checking the interrupt register after finishing the execution of the current instruction (D) by checking the interrupt register at fixed time intervals CS – 2011 12. A computer handles several interrupt sources of which of the following are relevant for this question. • Interrupt from CPU temperature sensor (raises interrupt if CPU temperature is too high) • Interrupt from Mouse (raises interrupt if the mouse is moved or a button is pressed) • Interrupt from Keyboard (raises interrupt when a key is pressed or released) • Interrupt from Hard Disk (raises interrupt when a disk read is completed) Which one of these will be handled at the HIGHEST priority? (A) Interrupt from Hard Disk (B) Interrupt from Mouse (C) Interrupt from Keyboard (D) Interrupt from CPU temperature sensor 13.
On a non-pipelined sequential processor, a program segment, which is a part of the interrupt service routine, is given to transfer 500 bytes from an I/O device to memory. Initialize the address register Initialize the count to 500 LOOP: Load a byte from device Store in memory at address given by address register Increment the address register Decrement the count If count! = 0 go to LOOP Assume that each statement in this program is equivalent to a machine instruction which takes one clock cycle to execute if it is a non-load/store
Computer Organization
instruction. The load-store instructions take two clock cycles to execute. The designer of the system also has an alternate approach of using the DMA controller to implement the same transfer. The DMA controller requires 20 clock cycles for initialization and other overheads. Each DMA transfer cycle takes two clock cycles to transfer one byte of data from the device to the memory. What is the approximate speedup when the DMA controller based design is used in place of the interrupt driven program based input-output? (A) 3.4 (C) 5.1 (B) 4.4 (D) 6.7 14.
An application loads 100 libraries at startup. Loading each library requires exactly one disk access. The seek time of the disk to a random location is given as 10 ms. Rotational speed of disk is 6000 rpm. 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
CS - 2012 15. The amount of ROM needed to implement a 4 bit multiplier is (A) 64 bits (C) 1 kbits (B) 128 bits (D) 2 kbits CS - 2013 16. Consider a hard disk with 16 recording surfaces (0 15) having 16384 cylinders (0 – 16383) and each cylinder contains 64 sectors (0-63). Data storage capacity in each sector is 512 bytes. Data is organized cylinder-wise and the addressing format is . A file of size 42797 KB is stored in the disk and the th
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] Vectored interrupts are not possible but multiple interrupting devices are possible.
2.
[Ans. A] Memory mapped I/O requires that memory locations and I/O ports share the same set of addresses, so address bit pattern that is assign to memory cannot also be assigned to an I/O port and viceversa. I/O protection in this approach in ensured by operating system macros and routines.
3.
4.
5.
[Ans. B] Data transfer rate = 10KB/sec Total transfer = 25 Data transfer rate = So perform gain = 25 % [Ans. D] Notice here that S5 have to be activated on T1 for all instructions and for I2 and I3 on T3. S10 have to be activated for I2 and I4 on T5 for I1 and I3 on T4 for I4 on T3 for I2 and I3 on T2
So, total no of bits required for vertical microprogramming = 22 bits With horizontal approach = 125 bits So, no. of bits saved = 125 – 22 =103 bits 6.
[Ans. B] Time takes for 1 rotation = 60 sec = 3000 rotations 60/3000 sec= 1 rotation In 1 rotation it reads – 1/50 sec ? = 4 bytes Time it takes to read 4 bytes = 153 ns % of time CPU gets blocked
7.
[Ans. D] For Constant Linear Velocity, density of bits per track will increase as the head moves towards outside of the disk. So the disk capacity = 10 + 20 + 30 + 40 + 50 + 60 + 70 +80 =360MB For Constant Angular Velocity, density of bits per track is uniform. So the disk capacity = 10 × 8 = 80MB
8.
[Ans. A] To move from 1st sector to 8th sector, the distance covered by head =(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
5th sector, the head needs to take entire one rotation. As head can rotate at 6000RPM, one rotation will take 10ms Total time = 3.5 + 10 = 13.5ms 9.
[Ans. A] No. of surfaces = 16 No. of track/sectors = 128 No. of sector/tracks = 256 Total size of disk = 16 bytes = 256 MB Total no. of sectors in the disk = 16 bytes = 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 assigned to requests which, if delayed or interrupted, could have serious consequences. Interrupt from CPU temperature sensor would have serious consequences if ignored. So it has the highest priority.
13.
Computer Organization
14.
[Ans. B] Time for one library Rotational latency ½ resolution time 6000 rpm = 10 ms, ½ revolution = 5ms 100(10ms+5ms)= 100 15ms = 1500 ms = 1.5 sec.
15.
[Ans. D]
=2 k bits 16.
[Ans. D]
When head is moving then it is reading data from all 16 surfaces simultaneously. Currently head is on 9th surface, sector no. 40. Data it read from 9th surface Data it read from surface 10th to 15th
[Ans. A] Non pipelined system require = (2+2+1+1+1)
Data it read from cylinder 1201 to 1283 Total data read from 1200th to 1283th cylinder 12288 + 163840 + 42991616 =13167744 bytes = 42156 KB But we need to read 42797 KB. So we need to go 1284th cylinder.
DMA clock need = 20 + 2 500 = 1020 cycles Speed up = 3500/1020= 3.43
Number Systems & Code Conversions CS – 2005 1. The range of integers that can be represented by an n bit 2’s complement number system is (A) 2 to ( 2 –1) (B) 2 1 ) to (2 – 1) (C) 2 to 2 (D) 2 + 1 ) to (2 ) 2.
The hexadecimal representation of 657 is (A) 1AF (C) D71 (B) D78 (D) 32F
Linked Answer Questions for Q 3 & Q 4 Consider the following floating point format 15 14
8
Sign bit
Excess – 64 Exponent
0
7
CS -2006 6. Consider numbers represented in 4-bit gray code. Let h h h h be the gray code representation of a number n and let g g g g be the gray code of (n + 1) (modulo 16) value of the number. Which one of the following functions is correct? (A) g h h h h ) = Σ , 2, 3, 6, 0, 3, 4, 5) (B) g h h h h ) = Σ(4, 9, 10, 11, 12, 13, 14,15) (C) g h h h h ) = Σ 2, 4, 5, 6, 7, 2, 3, 5) (D) g h h h h ) = Σ 0, , 6, 7, 0, , 2, 3) 7.
The addition of 4-bit, two’s complement, binary numbers 1101 and 0100 results in (A) 0001 and an overflow (B) 1001 and no overflow (C) 0001 and no overflow (D) 1001 and an overflow
Mantissa
Mantissa is a pure fraction is sign – magnitude form. 3.
4.
5.
The decimal number 0.239 2 has the following hexadecimal representation (without normalization and rounding off): (A) 0D 24 (C) 4D 0D (B) 0D 4D (D) 4D 3D The normalized representation for the above format is specified as follows. The mantissa has an implicit 1 preceding the binary radix) point. Assume that only 0’s are padded in while shifting a field. The normalized representation of the above number (0.239 2 ) is: (A) 0A 20 (C) 4D D0 (B) 11 34 (D) 4A E8
CS - 2008 9. In the IEEE floating point representation the hexadecimal value 0x00000000 corresponds to (A) The normalized value 2 (B) The normalized value 2 (C) The normalized value + 0 (D) The special value + 0 10.
(34.4)8 (23.4)8 evaluates to (A) (1053.6)8 (C) (1024.2)8 (B) (1053.2)8 (D) None of these
th
Let ‘r’ denote number system radix. The only value s) of ‘r’ that satisfy the equation √ 2 = is/are (A) decimal 10 (B) decimal 11 (C) decimal 10 and 11 (D) any value > 2 th
The following bit pattern represents a floating point number in IEEE 754 single precision format 1 10000011 10100000000000000000000 The value of the number in decimal form is (A) 10 (B) 13 (C) 26 (D) None of the above
Digital Logic
biased exponent and 23 bits for mantissa. A float type variable X is assigned the decimal value of 4.25. The representation of X in hexadecimal notation is (A) C1640000H (C) 41640000H (B) 416C0000H (D) C16C0000H
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
[Ans. A] 2’s complement of a number represents the negative number. If a number is n-bit long the most significant digit is a sign bit so starting from 2 because only n – 1 place and addition of 1 and LSB we represent the magnitude. So the range is 2 to (2 ) including 0.
Representation biased exponent 74 in binary 74) = 00 0 0) Floating point representation of number is as follows: Sign Exponent Mantissa 0 1001010 1101000
[Ans. A] 657) =
A 4 = 4A 8)
) 0 0 000 0 0 = A ) 657) = A
3.
0100 1101 0011 1101
4.
3
E
8
)
[Ans. D] The decimal number is 0.239 2 We have to find hexadecimal representation without normalization. Biased exponent = 13 + 64 = 77 Representing 77 in binary 77) = 00 0 ) Representing mantissa in binary 0.239) = 0.00 0 000 0 Floating point representation is an follows: Sign Exponent Mantissa 0 1001101 00111101
4 D = 4 3 )
0100 1010 1110 1000
D
[Ans. D] The decimal number is 0.239 2 We have to find hexadecimal representation with normalization. Binary representation of 0.239 is 0.00111101000101 is 0.00 0 000 0 ) 2 After normalization we have 1.11101000101 × 2 Then, biased exponent = 10 + 64 = 74
5.
6.
[Ans. A] 34.4)
23.4) =
053.6)
[Ans. C] Let b , b , b , b are binary and h , h , h , h , g , g , g , g as discussed in Question then b b b b h h h h g g g g 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 0 1 1 0 0 1 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 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 1 1 0 1 1 0 1 1 1 0 0 1 1 1 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 Now clearly g is high at position 0, so option (A) is wrong, also g is high at position 1, so option (B) is also wrong, for g h , h , h , h )g is high at g h , h , h , h ) = Σm 2,6,7,5,4, 2, 3, 5) g h , h , h , h ) = Σm 2,4,5,6,7, 2, 3, 5) Hence option (C) is correct answer.
[Ans. C] Overflow condition is check with the expression x yz yxz where x is MSB of first number, y is MSB of second and z is MSB of output (all in same size, 4 bit here) Here x =1 y=0& z=0 So x yz xyz = 0 So no overflow will be there.
0 0 0 0 0 0 0 0 0 0 0 0 Checking options. (a) 10 Sign = 1 0) = 0 0 = .0 0 2 The exponent is biased by 2 , where ‘e’ is the number of bits used for the exponent field which is 8. 2 = 27 For the 32 bit IEEE 754 format, the bias is + 127 and so 3 + 127 = 130. In binary (130) is encoded as 1 0 0 00010. Thus, it is not equal to exponent field. (b) 13 Sign = 1 3) = 1101 = 1.101 × 2 3 27 = 30 Hence 30) = 00000 0 exponent (c) 26 26) = 0 0 = . 0 0 2 27 4 = 3 and 3 ) = 00000 But fraction part does not match
[Ans. D] √ r ) 2r )= r ) √ 2 = ) ) r 2r = r r 2r =r 2r Given equation will satisfy for every vale of r, however with radix r = 2 we cannot have sign 2 in it. So answer is r > 2.
11.
[Ans. D] sign Exponent 1 1 0 0 0 0 0 1 1
12. Fraction 1 0 1 0 0 0 0 0 0 0 0 0
Digital Logic
[Ans. B] 2 7) = 028 ) (1
001 2
13.
th
2
1 7)8
001
010 8
111 F
[Ans. A] 2’s complement of P is given as 2’s complement of 8 P = 2 th
[Ans. B] Range of 2’s complement number is for n bit is from 2 ) to 2 ) so smallest number is 2 = 2 = 28
15.
[Ans. 5] Given 3 2) = 3. ) 20) 3r r 2 =r 2r 3 r =r 2 2 r r 5 = 2 2 r=5
16.
3 3
So binary representation is 1100 C 0001 1 0110 6 0100 4 0000 0 0000 0 0000 0 0000 0
0 0
Digital Logic
r r
[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.
Boolean Algebra & Karnaugh Maps CS – 2005 1. The switching expression corresponding to f(A,B,C,D) = (1,4,5,9,11,12) is (A) B + D+ A D (B) AB +ACD+ D (C) AC + B + A (D) BD+ AC +BC
2.
A line L in a circuit is said to have a stuck at 0 fault if the line permanently has a logic value 0. Similarly a line L in a circuit is said to have a stuck – at - 1 fault if the line permanently has a logic value 1. A circuit is said to have a multiple stuck-at fault if one or more lines have stuck at faults. The total number of distinct multiple stuck - at faults possible in a circuit with N lines is (A) 3N (C) 2N 1 (B) 3N 1 (D) 2N
CS - 2006 3. Consider a Boolean function f(w, x, y, z). Suppose that exactly one of its inputs is allowed to change at a time. If the function happens to be true for two input vectors i w x y z n i w x y z w would like the function to remain true as the input changes from i to i i n i differ in exactly one bit position), without becoming false momentarily. Let f(w, x, y, z,) = (5, 7, 11, 12, 13, 15). Which of the following cube covers of f will ensure that the required property is satisfied? (A) w ̅ x z w x y̅ x y̅z x y z w y z (B) w x y , w ̅ xz wyz (C) w x ̅̅̅̅, y z x z, w x̅ y z (D) w z y, w y z, w ̅ x z x y̅ z x y z
4.
(A) f (x1, x2 …. xn) = x f (x1, x2 …. xn) + x1f (x1, x2 ….. xn) (B) f (x1, x2 …. xn) = x2f (x1, x2 …. xn) + x f (x1, x2 ….. xn) (C) f (x1, x2 …. xn) = x f (x1, x2 …. 0) + xn f (x1, x2 ….. 1) (D) f (x1, x2 …. xn) = f (0, x2 …. xn) + f (1,x2 ….. xn)
5.
The Boolean function for a combinational circuit with four inputs is represented by the following Karnaugh map. PQ 00
01
11
10
00
1
0
0
1
01
0
0
1
1
11
1
1
1
0
10
1
0
0
1
RS
Which of the product terms given below is an essential prime implicant of the function? (A) QRS (C) (B) PQS (D) CS - 2007 6. What is the maximum number of different Boolean functions involving n Boolean variables? (A) n (C) 2 (B) 2 (D) 2
7.
Consider the following Boolean function of four variables f w x y z) 1 3 4 6 9 11 12 14) The function is (A) Independent of one variable (B) Independent of two variables (C) Independent of three variables (D) Dependent on all the variables
Given a Boolean function f (x1, x2 ….. xn), which of the following equation is NOT true
Let f(w, x y z) 0 4 5 7 8 9 13 15). Which of the following expressions are NOT equivalent to f? (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
̅̅
̅
c̅
̅̅ ̅
̅
9.
Define the connective * for the Boolean variable X and Y as: X* Y = X Y + Let Z = X * Y. 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̅
̅̅ ̅
̅
c̅
̅̅ ̅
̅
̅
̅
11. ̅
̅̅
c̅
̅
+ + Which of the following Karnaugh Maps correctly represents the expression? ) ̅̅
̅
̅̅
Statement for Linked Answer Questions 10 and 11. Consider the expression 10.
̅̅
Which of the following expressions does 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
Given f f and f in canonical sum of products form (in decimal) for the circuit f1 f f2
f3 f m 45678) f m 1 6 15) f m 1 6 8 15) Then f is (A) m 4 6) (C) (B) m 4 8) (D)
14.
15.
m 6 8) m 4 6 8)
P, Q, R are Boolean variables, then (P + ̅ ) (P. ̅ + P.R) (̅. ̅ + ̅ ) simplifies to (A) P. ̅ (C) P. ̅ + R (B) P. ̅ (D) P. ̅ + Q Consider the following Boolean function of four variables f(A, B, C, D) = (2, 3, 6, 7, 8, 9, 10, 11, 12, 13) The function is (A) Independent of one variable (B) Independent of two variables (C) Independent of three variables (D) Dependent on all the variables
Digital Logic
CS – 2010 16. The minterm expansion of f (P, Q, R) = PQ + Q̅ + P̅ is (A) m + m + m + m (B) m + m + m + m (C) m + m + m + m (D) m + m + m + m
CS - 2011 17. The simplified SOP (Sum Of Product) form of the Boolean expression (P+ ̅ + ̅).(P+ ̅ +R). (P+Q+̅) (A) (̅. + ̅) (C) (̅. + ) (D) (P.Q+R) (B) (P+ ̅ . ̅) CS - 2012 18. The truth table X Y f(X, Y) 0 0 0 0 1 0 1 0 1 1 1 1 represents the Boolean function (A) X (C) (B) X + Y (D) Y CS - 2013 19. Which one the following expressions does NOT represent exclusive NOR of x and y ? (A) xy + x y (C) x y (B) x y (D) x y CS - 2014 20. Consider the expression for F:
following
Boolean
F(P, Q, R, S) = PQ + + The minimal sum-of-products form of F is (A) PQ + QR + QS (C) + + + (B) P + Q + R + S (D) + +
21.
th
The dual of a Boolean function x x … . x + . ) written as is 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
Consider the following minterm expression for F: ) 0 2 5 7 8 10 13 15 Th mint rms 2 7 8 n 13 r ‘ o not r ’ t rms. Th minim l sum – of – products for F is
L t not th Ex lusiv O O ) op r tion. L t ‘1’ n ‘0’ not th binary constants. Consider the following Boolean expression for F over two variables P and Q: ) )) ( 1 ) ) 0)) The equivalent expression for F is (A) P + Q (C) P Q
(A)
+
(B)
(B)
+
(C) 2 (D) 2
(C)
+
+
+
(D)
+
+
+
+
(D)
Answer Keys and Explanations 1.
[Ans. A] f(A, B, C, D) = (1, 4, 5, 9, 11, 12) The K – map for f is
[Ans. D] A is true statement f x x … x ) x f x x … x )+x f x x … x ) f x x … x ) x +x ) f x x … x ) Similarly B is also true To prove (C) and (D) Let f x x x ) x + x + x Then (C) f x x x ) x + x + x x x + x + 0) + x x + x + 1) x x +x )+x x x +x x +x x +x +x f x x x ) So (C) can be true, let check for D f x x x ) f 0 x x )+ 1 x x ) 0+x +x )+ 1+x +x ) =1 f x x x ) It is not true, and we know that if a statement is not true even for one om in tion it n’t g n r l statement
1
1 1
11 10
B
11
1
+
1
+
2.
[Ans. C] Total no. of distinct multiple stuck at faults in a circuit with N lines is 2 1.
3.
[Ans. A] f (w, x, y, z) = (5, 7, 11, 12, 13, 15) Draw the K – map yz 10
[Ans. A] Consider a simple method let w = 1, x = 1, y = 1, z = 1 then the value of f is 1. Consider each statement (P) x y z + w xy + wy z + xz =000+010+101+11=1 (Q) w y z + wx y + xz 000+100+11=1 (R) w y z + wx y + xyz + xy z =000+100+111+101=1 (S) x y z + wx y + w y =000+100+01=0 So statement (S) is false because w = 1, x = 1, y = 1, z = 1 the value of f is 0. (S) is not contain the essential minterms. So option not containing S is answer which is option (A)
9.
[Ans. D]
PQ 00
is essential prime implicants.
[Ans. C] Let the binary constant be the value of the function f(x x … … x ) for the combination of variables whose decimal code is i. Then every switching function can be expressed in form. f (x x … . x ) = x́ x́ … x́ + x́ x́ … x́ + … + x x … x . A factor is either 0 or 1 if the corresponding minterm is contained in canonical form of the function. Then there are r = 2 coefficients each of which can have values either 0 or 1 hence there are 2 possible assignments.
+ Z = X*Y y + from eq. (i) P:X= = YZ + by eq.(i) =Y(XZ + X Z ) + Y Z = XYZ + X YZ + Y Z Q:Y= Y = XZ + X Z by eq.(i) Y =XZ + X Z R: = 1 if we will take the truth table for P, Q, R, then all are valid formulas
[Ans. B] Given f(w, x, y, z) = (1, 3, 4, 6, 9, 11, 12, 14) Corresponding K – map for f is yz 00
wx 00
01
11
1
1
10
10.
[Ans. A] a 00
+ 01
00
1
1
01
1
1
11
1
1
10
1
cd
01 11 10
ab
1
1
1
1 1
Digital Logic
1
+ 11
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.
It depends on 3 variables A, B and C. So it is independent of one variable.
[Ans. A] Option (A) does not correspond to Kmap option in question 10. +
+
16.
+
Digital Logic
[Ans. A] +
12.
[Ans. A] The K-Map is
( + )+( + ) +
ab 00
01
00
1
1
01
x
cd
11
11
17.
+ ) + )
x
15.
+ + 100)
+
+ ) )
+
+
+
+ )
+ )
+ ) +
+
+
+
14.
+
(( + ) + 1
+ )
[Ans. B] +
1
+
+ + + 111) 110) 010) m +m +m +m
1
+
13.
+
+
+
10
x
10
+
[Ans. C] f and f are connected with AND gate so when f = m(6, 8) then f is true for m (1, 6, 8, 15) [Ans. A] + ) + ) + ) ) + + + + ) + + + ) ( + 1 + )) + ) + ) + ) + 1+ )
[Ans. A] f (A, B, C, D =
18.
X 0 0 1 1
01
11
19.
1
01
1
1
1
1
1
1
+
+
1
+
y)
xy + x y) x + y) x + y )) x y + xy … … … … . i) Option (A): is same as (i) Option (B): x y x y + xy same as (i) Option (C): x y xy + x y same as (i) Option (D): x y x y + xy not same as (i) Option (D) is not correct.
[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 x 00 1 01
1 x x 1
11
QS
10 x
1
All four corner = Minimal sum of products for F is QS +
Logic Gates CS – 2005 1. A two-way switch has three terminals a, b and c. In ON position (logic value 1), a is connected to b, and in OFF position, a is connected to c. Two of these two way switches S1 and S2 are connected to a bulb as shown below. b
b
a
a c Switch c S1
c Switch S2 c
CS - 2007 4. The following expression was to be realized using 2 input AND and OR gates. However, during the fabrication all 2 input AND gates were mistakenly substituted by 2 input NAND gates. (a. b).c + (̅.c).d + (b.c).d + a.d What is the function finally realized? (A) 1 (B) ̅ + ̅ + ̅ + ̅ (C) ̅ + b + ̅ + ̅ (D) ̅ + ̅ + c + ̅
Bulb
Which of the following expressions, if true, will always result in the lighting of the bulb? (A) S1. ̅̅̅ (C) ̅̅̅̅̅̅̅̅̅̅ (B) S1+ S2 (D) S1 S2 2.
5. The line T in the following figure is permanently connected to the ground. X1 X2 X3 X2 X4 X3
X4
Which of the following expressions is equivalent to (A B) C (A) (A + B + C) ( ̅ ̅ ̅ ) ) (B) (A + B + C) ( ̅ ̅ ̅ ̅ (C) ABC + (B C) + (A C)
Which of the following inputs (X1 X2 X3 X4) X4 will detect the fault? X4 (A) 0000 (B) 0111 (C) 1111 (D) None of these
(D) None of these CS - 2006 3. The majority function is a Boolean function f (x, y, z) that takes the values 1 whenever a majority of the variables x, y and z. In the circuit diagram for the majority function shown below, the logic gates for the boxes labeled P and Q are, respectively z y P
T
X3
CS - 2009 6. What is the minimum number of gates required to implement the Boolean function (AB + C) if we have to use only 2-input NOR gates? (A) 2 (C) 4 (B) 3 (D) 5
CS – 2010 7. What is the Boolean expression for the output f of the combinational logic circuit of NOR gates given below? P Q Q R R RP R R Q R R R R (A)
f
̅̅̅̅̅̅̅̅ (B) ̅̅̅̅̅̅̅
(C) ̅̅̅̅̅̅̅ (D) ̅̅̅̅̅̅̅̅̅̅̅̅̅̅
CS – 2011 8. Which one of the following circuits is NOT equivalent to a 2-input XNOR (exclusive NOR) gate? (A)
Digital Logic
CS – 2014 10. Consider the following combinational function block involving four Boolean variables x, y, a, b where x, a, b are inputs and y is the output. f (x, y, a, b) { if (x is 1) y = a; else y = b; } Which one of the following digital logic blocks is the most suitable for implementing this function? (A) Full adder (B) Priority encoder (C) Multiplexer (D) Flip-flop
(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
[Ans. C] ( ) ( ) ( ) Replace AND gate with NAND gate,
)
(
( ) ( ) ( ) So A is false (not correct option) )( (B) ( )
)
(
)
(
(
)( (
( ) So option C is correct
( ) )
(
(
( ) So B is false (not correct option) ( ) (C) ( )
3.
(
) 4.
Now (A), ( )(
)
5.
)
)
) )
[Ans. D] X1 X2 X3 X2 X3
[Ans. D] f= where
() ( ) ( ) Now we know a 3 variable majority circuit is given as ( ) Now on comparing, we get that there is no on actual expression, so we have to eliminate from equation (i) we know that
X4
y
X3 X4
X3
T
X3 X4 X4 X4 X3 X4
X4
( ) So the eliminate , Q must also be present in P and in addition P must contain some other terms so by observation option A, B & C are eliminated Now option (D) ( )
Combinational and Sequential Digital Circuits CS – 2005 1. Consider the following circuit involving a positive edge triggered D FF.
3.
How many pulses are needed to change the contents of a 8-bit upcounter from 10101100 to 00100111 (rightmost bit is the LSB)? (A) 134 (C) 124 (B) 133 (D) 123
4.
Which of the following input sequences will always generate a 1 at the output z at the end of the third cycle?
A X Q
D
Y
CLK
A B
Consider the following timing diagram. Let represent the logic level on the line A in the i-th clock period. CL 0 K X
1
2
3
4
Clock
̅
C
5
Clock
̅
A 1 0 0
B 0 0 1
C 1 1 0
(B)
1 1 1
0 1 1
1 0 1
(C)
0 1 1
1 0 1
1 1 1
(D)
0 1 1
0 1 1
1 0 1
(A)
Let represent the complement of A. The correct output sequence on Y over the clock periods 1 through 5 is (A) (C) (B) (D) 2.
Z
Consider the following circuit
CLK
The flip-flops are positive edge triggered D FFs. Each state is designated as a two bit string . Let the initial state be 00. The state transition sequence is (A) 00→11→01
5.
The circuit shown below implements a 2-input NOR gate using two 2 1 MUX (control signal 1 selects the upper input). What are the values of signals x, y and z?
CS - 2006 6. You are given a free running clock with a duty cycle of 50% and a digital waveform f which changes only at the negative edge of the clock. Which one of the following circuits (using clocked D-flip-flops) will delay the phase of f by 180 ? (A) D
D
f
8.
Given
Digital Logic
two
three bit numbers and c, the carry in, the function that represents the carry generate function when these two numbers are added is (A) + + + + + + (B)
D Q
+
+
+
+
+
+
̅
(C)
+( ( ) ( (D) + ̅̅̅ ̅̅̅ ̅̅̅ + ̅ ̅
clk
(B) D Q
D Q
f g clk
9.
D Q
D Q
D
D Q
(D)
̅
(C) c (D)
clk
7.
Consider the circuit below . Which one of the following options correctly represents f(x,y,z)? x 0
MUX
1 y̅ z
0 1
MUX f
+ +
+ ̅
̅̅̅
+
c c
CS - 2007 10. How many 3-to-8 line decoders with an enable input are needed to construct a 6-to-64 line decoder without using any other logic gates? (A) 7 (C) 9 (B) 8 (D) 10 11.
x y
(A) xz̅ + xy + y̅z (B) xz̅ + xy +yz ̅̅̅
+
binary adder for adding unsigned 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 correctly identifies the overflow condition? (A) c (̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅) (B) c̅̅̅̅̅̅ + ̅̅̅̅̅̅̅̅̅̅̅̅c
clk
f
+ + ̅̅̅
)[ )]
We co si er the itio of two 2’s complement numbers
(C) f
+
(C) xz + xy + yz ̅̅̅ (D) xz + xy̅ + y̅z th
Suppose only one multiplexer and one inverter are allowed to be used to implement any Boolean function of n variables. What is the minimum size of the multiplexer needed?
In a look-ahead carry generator, the carry generate function the carry propagate function for inputs, re give y
where is the input carry. Consider a two-level logic implementation of the look-ahead carry generator. Assume that all are available for the carry generator circuit and that the AND and OR gates can have any number of inputs. The number of AND gates and OR gates needed to implement the look-ahead carry generator for a 4-bit adder with as its outputs are respectively (A) 6, 3 (C) 6, 4 (B) 10, 4 (D) 10, 5
X
X
X
0
X
0
0
0
↑
1
X
0
↑
0
1
Clear to 0 No change Load input Count next
Count = 1 Load = 0 Clock
Clear 0
0
1
Inputs 1
Assume that the counter and gate delays are negligible. If the counter starts at 0, then it cycles through the following sequence (A) 0, 3, 4 (C) 0, 1, 2, 3, 4 (B) 0, 3, 4, 5 (D) 0, 1, 2, 3, 4, 5 14.
The following circuit implements a two – input AND gate using two 2-1 multiplexers. a
1
1
b
0
0
ab
What are the values of X1, X2, and X3? (A) 0 (B) 1 (C) 1 (D) 0
The control signal functions of a 4-bit binary counter are given below ( where X is “ o ’t c re”) Clear Clock Load Count Function 1
4-bit counter
Clear
The expressions for the sum bit and the carry bit of the look-ahead carry adder are given by
13.
Digital Logic
15.
th
Which of the following input sequences for a cross – coupled R – S flip – flop realized with two NAND gates may lead to an oscillation? (A) 11, 00 (C) 10, 01 (B) 01, 10 (D) 00, 11
What is the final value stored in the linear feedback shift register if the input is 101101?
101101 +
0
1 1
20.
The Boolean expression for the output f of the multiplexer shown below is R
0
̅
1
̅ ̅
2
0
XOR
(A) 0110 (B) 1011
Digital Logic
(C) 1101 (D) 1111
R R
CS - 2008 17. What Boolean function does the circuit below realize?
f
3
R ̅
P
(A) ̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ (B)
Q
(C) P + Q + R (D) ̅̅̅̅̅̅̅̅̅̅̅̅̅̅
z 3 to 8 y
f (x, y, z)
Decoder
x
(A) xz + x z (B) xz xz 18.
CS - 2011 Common data for questions 21 and 22: Consider the following circuit involving three D-type flip-flops used in a certain type of counter configuration.
(C) x y + yz (D) xy + y z
D Q ̅ clock
The two numbers given below are mu tip ie usi g the ooth’s gorithm Multiplicand: 0101 1010 1110 1110 Multiplier: 0111 0111 1011 1101 How many additions/Subtractions are required for the multiplication of the above two numbers? (A) 6 (C) 10 (B) 8 (D) 12
CS - 2010 19. In the sequential circuit shown below, if the initial value of the output is 00, what are the next four values of ? 1
T
Q
T
D Q
D
21.
Q
Clock
(A) 11,10,01,00 (B) 10,11,01,00
̅
clock
clock
Q
Q
R
̅
If some instance prior to the occurrence 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? (A) 000 (C) 010 (B) 001 (D) 011
If all the flip-flops were reset to 0 at power on, what is the total number of distinct output (states) represented by PQR generated by the counter? (A) 3 (C) 5 (B) 4 (D) 6
(A) (B) (C) (D) PQ 26.
The minimum number of D flip-flops needed to design a mod-258 counter is (A) 9 (C) 512 (B) 8 (D) 258
CS - 2013 24. In the following truth table, V = 1 if and only if the input is valid. Inputs Outputs V 0 0 0 0 x x 0 1 0 0 0 0 0 1 x 1 0 0 0 1 1 x x 1 0 1 0 1 x x x 1 1 1 1 What function does the truth table represent? (A) Priority encoder (B) Decoder (C) Multiplexer (D) Demultiplexer
Digital Logic
C
C
C
The above synchronous sequential circuit built using JK flip – flops in initialized with 000 The state sequence for this circuit for the next 3 clock cycles is (A) 001, 010, 011 (C) 100, 110, 111 (B) 111, 110, 101 (D) 100, 011, 001 27.
Let 2 . A circuit is built by giving the output of an n bit binary counter as input to an to 2 bit decoder. This circuit is equivalent to a (A) k bit binary up counter. (B) k bit binary down counter. (C) k bit ring counter. (D) k bit Johnson counter
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
x x Given x = 1 1 0 1 1 0 Clock = 0 1 2 3 4 5 and A= Then Clock A D
0
A
1
B
0
P=A +B
2
C = xP + y
5
x(
)
y
x(
)
y
) ) y
y
from emorg theorem) Now from option (A) Put x = 1, y = 0, = B we get 0 0 0 0 From option (B) Put x = 1, y = 0 & = A
NS 11 01 10 00 11 01 ⋮⋮ ⋮⋮
0
0
0
From option (C) Put x = 0, y = 1 & = B
[Ans. D] 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 then from 1 1 1 1 1 1 1 1 →00000000→ 0 0 1 0 0 1 1 1 40 So total = 83 + 40 = 123 [Ans. A] A B C
P(let)
x x y Also given (required)
[Ans. D]
00 11 01 10 00 11 ⋮⋮ ⋮⋮
4.
y
Z
4
3.
1
1 3
2.
x
0
0
rom optio ) Put x = 0, y = 1 & = A 0
0
0
Which is required So correct option is (D) Z
1 0 1 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 1 We got answer with first option no need to check for other options.
6.
[Ans. B] Hint: Invertor provides 1 0 phase FF with Q output 360 or 0 FF with ̅ output gives 1 0 phase
[Ans. C] B= A= S=c c c The over flow condition V V= c c c is c so V=c c So the over flow condition is c c
10.
[Ans. C] For the construction of a 6 × 64 decoder by using 3 × 8 line decoder
x 0
f
1 y̅ 0 1
z
f
x y Let the output of first uppermost Mux is f f xz yz The output of second Mux is f = (xz y z)y xy = xy z y y z xy = xy z + y z xy [ = y z xy z xy z z ) [a + = 1] = y z xy z xyz xyz = y z xy z + xyz xyz xyz [a + a = a] = y z + xz y y) xy z z) = y z xz xy [a + = a] = xz xy y z 8.
[Ans. D] Consider
1
3×8
11.
[Ans. C] To implement n variable function, we require a data selector with n 1 select inputs and 2 data inputs. So minimum size of multiplexer needed is 2 line to 1 line
12.
[Ans. B] A 4-bit adder with and as its output require 2 – 1 bit adder and a single one bit adder require 5 AND gates and 2 OR gates in two level logic. So the required gate are 10 AND gate and 4 OR gates.
13.
[Ans. D] If load = 0 and count = 1 then counter count the sequence 0000, 0001, 0010, 0011, 0100, 0101, 0000 in decimal if count 0, 1, 2, 3, 4, 5 and then 0 and repeat the sequence. After 0101 clear = 1 So again 0000 as count output.
14.
[Ans. A]
1 1 or 1 or 1 1 or 1 So the statement (D) generate a carry c always
extra decoder for combining
the result 6 × 64 →
and
000 000 001 001 010 010 011 011 100 100 101 101 110 110 111 111 So the carry c will be generated if
So, a.b = (a + b ) + If = b, = 0, = a then RHS = (a . b + b . ) a + 0 . =a.b.a =a.b 15.
Digital Logic xyz xyz x yz
z 3 × 8 decodes
y
xy z xy z xy z
[Ans. B]
x
xyz xyz
S
= xz
= (x z ) xz) = (x + z) (x z) = xx xz x z zz = xz xz
R
S R 1 1 1 0 0 0 1 1 0 0 Invalid Now since 00 leads to invalid state it cannot lead to an oscillation So (A) & (D) are wrong options In both option B & C oscillation will occur but in option (C) oscillation will start after one clock cycle however in option (B) oscillation will state with first clock cycle so B is more correct answer 16.
[Ans. A] Clock 0 1 2 3 4 5 6
18.
Output 0110 1011 1101 0110 1011 1101 0110
101101 + So option A 17.
xz)
[Ans. B] f xyz x yz xy z xyz =x z y y) xz y y ) = x z 1) xz 1) =x z xz
[Ans. B] ooth’s gorithm requires ex mi tio of the multiplier bits and shifting of the partial product. Prior to the shifting, the multiplicand may be added to the partial product, subtracted from the partial product or left unchanged according to the following rules. 1. The multiplicand is subtracted from the partial product upon encountering the first least significant 1 in a string of 1’s i the multiplier. 2. The multiplicand is added to the partial product upon encountering the first 0 i stri g of 0’s i the multiplier. 3. The partial product does not change when the multiplier bit is identical to the previous multiplier bit. As in multiplier we see that a change occurs in bit as 0 changes to 1 and 1 changes to 1. Multiplier: 0111
[Ans. A] Clock to next flipflop is by Q and +ve edge trigger so it will be a down counter
After After After After 20.
Initial 1st Clock 2nd Clock 3rd Clock 4th Clock
26.
[Ans. C] Values of J and K in each flip – flop from left to right will be J = 1, 0, 0 K = 0, 1, 1 According to these inputs will be 100 Now based on new outputs J – K will be J = 1, 1, 0 K = 0, 0, 1 And will be 110 Now new J – K J = 1, 1, 1 L = 0, 0, 0 And will be 110
27.
[Ans. C]
0 1 0 1 0
[Ans. B] (
)
(
)
21.
0 1 1 0 0
) )
[Ans. D] ) f
) )
Digital Logic
n - bit binary counter
0 1 0) the ext st te 0 1 1)
2 bit decode r
1 )
22.
[Ans. B] There are four distinct states. 000 →010→011→100 →000)
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 (
So output of n-bit binary counter move from 1, 2, 3, and so on according to that and so on output will be high.
Mathematical Logic CS - 2005 1. What is the first order predicate calculus statement equivalent to the following? Every teacher is liked by some student ( ) (A) ( ), ( ), ( ) ( )-] ( ), ( ) (B) ( ), ( ) ( )-( ) (C) ( ) ( ), ( ) ( )-, ( ) ( ) (D) ( ), ( ) ( )-, 2.
3.
5.
Which one of the first order predicate calculus statements given below correctly expresses the following English statement? Tigers and lions attack if they are hungry of threatened. ( ) ( )) (A) [(
(D) . (
( ( ))/ ( ( )
(
(B)
[(
( )
( ))
( )
{(
( ))
( )}] (C)
[(
(D)
[( *(
6.
( ) ( )
{
( ))
( ( ))}]
( ) ( ) ( )+]
( ) ( )) ( ))
A logical binary relation ⨀, is defined as follows : A B A⨀B True True True True False True False True False False False True Let ~ be the unary negation (NOT) operator, with higher precedence, than ⨀. Which one of following is equivalent A B? (A) (~A ⨀ B) (C) ~(~A⨀~B) (B) ~(A⨀~B) (D) ~(~A⨀B)
( )))
( )))
CS - 2006 4. Consider the following propositional statements: P1: ((A B) C) ((A C) (B C)) P2: ((A B) C) ((A C) (B C)) Which one of the following is true? (A) P1 is a tautology, but not P2. (B) P2 is a tautology, but not P1. (C) P1 and P2 are both tautologies (D) Both P1 and P2 are not tautologies
( ))
( )}]
Let P, Q and R be three atomic propositional assertions. Let X denote ( ) and Y denote ( ) ( ). Which one of the following is a tautology? (A) X Y (C) Y X (B) X Y (D) Y X Let P(x) and Q(x) be arbitrary predicates. Which of the following statements is always TRUE? ( ) ( ))) (A) (( (( ( )) ( ( ))) ( ))) (B) ( ( ( ) ( ))) (( ( ( )) ( ( ( ))) (C) ( ( ( )) ( ) ( ))) (( (
( )
{(
CS - 2007 7. Which of the following is TRUE about formulae in Conjunctive Normal Form? (A) For any formula, there is a truth assignment for which at least half the clauses evaluate to true. (B) For any formula, there is a truth assignment for which all the clauses evaluate to true.
(C) There is a formula such that for each truth assignment, at most one-fourth of the clauses evaluate to true. (D) None of the above. 8.
9.
Let Graph (x) be a predicate which denotes that x is a graph. Let Connected (x) be a predicate which denotes that x is connected. Which of the following first order logic sentences DOES NOT represent the statement. “N every graph is connec ”? (A) ¬ (Graph(x) ⇒ Connected (x)) (B) x(Graph (x) Connected (x)) (C) (¬Graph(x) Connected (x)) (D) (Graph (x) ¬ Connected (x)) Which one of these first-order logic formulae is valid? (A) ( ( ) Q(x)) (( ( ( )) ( ))) ( (B) ( ( ) Q(x)) (( ( ( )) ( ))) ( (C) ( ( ) Q(x)) ( ))) (( ( ( )) ( ( ) ( ) (D)
Which of the following is the negation of ( ))[ ( ( ))(A) [ ( ( ))(B) [ ( ( ))(C) [ ( ( ))(D) [ (
13.
Which of the following first order m ?H ( ) first order formula with x as free variable, and is a first order formula with no free variable (A) [ ( x, (x))] [ x, (x)] (B) [ x, (x)] [ ( x, (x))] (C) [( ( )) , x, ( ) (D) [( ( )) - , ( ) -
CS - 2008 10. P and Q are two propositions. Which of the following logical expressions are equivalent? 1) 2) ( ) 3) ( ) ( ) ( ) 4) (P Q) (P ~Q) (~P Q) (A) Only 1 and 2 (B) Only 1, 2 and 3 (C) Only 1, 2 and 4 (D) All of 1, 2, 3 and 4
CS - 2009 14. Consider the following formulae: i. x P x
11.
15.
Let fsa and pda be two predicates such that fsa(x) means x is a finite state automaton, and pda(y) means that y is a pushdown automaton. Let equivalent be another predicate such that equivalent (a, b) means a and b are equivalent. Which of the following first order logic statement represents the following:
ii.
xP x
iii.
x P x
iv.
xP x
well-formed
Which of the above are equivalent? (A) i and iii (C) ii and iii (B) i and iv (D) ii and iv
th
Which one of the following is the most appropriate logical formula to represent the statement: “G m ”. The following notations are used: G(x): x is a gold ornament S(x): x is a silver ornament P(x): x is precious th
The binary operation is defined as follows ; P Q P Q T T T T F T F T F F F T Which one of the following is equivalent to P Q? (A) (C) (B) (D)
CS – 2010 17. Suppose the predicate F(x, y, t) is used to represent the statement that person x can fool person y at time t. Which one of the statements below expresses best the meaning of the formula (F(x, y, t))? (A) Everyone can fool some person at some time. (B) No one can fool everyone all the time. (C) Everyone cannot fool some person all the time. (D) No one can fool some person at some time. CS - 2011 18. Which of the following option is correct given three positive integers x, y and z, and a predicate P(x) = (x = 1) y ( z(x = y * z) (y = x) (y = 1)) (A) P(x) being true means that x is a prime number (B) P(x) being true means that x is number other than 1 (C) P(x) is always true irrespective of the value of x (D) P(x) being true means that x has exactly two factors other than 1 and x
DMGT
CS - 2012 19. Consider the following logical inferences. I1: If it rains then the cricket match will not be played The cricket match was played Inference: There was no rain I2: If it rains then the cricket match will not be played It did not rain Inference: The cricket match was played Which of the following is True? (A) Both I1 and I2 are correct inferences (B) I1 is correct but I2 is not correct inference (C) I1 is not correct I2 is a correct inference (D) Both I1 and I2 are not correct inference 20.
What is the correct translation of the following statement into mathematical logic? “ m mb ” (A) ( ( ) rational(x)) (B) ( ( ) ( )) (C) ( ( ) rational(x)) (D) ( ( ) real(x))
CS - 2013 21. Which one of the following is NOT logically ( ))? equivalent to ( ( ) (A) ( ( ) ( )) (B) ( ( ) ( )) (C) ( ( ) ( )) ( )) (D) ( ( ) 22.
What is the logical translation of the following statement? “N m .” (A) (F( ) ( )) (F( ) (F( )
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 ) ( ) (b ) (D)
)
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
[Ans. B] “E b m ”: then the logical expression is (x)[teacher (x) (y) [student ( ) ( )-Where likes (y, x) means y likes x, such that y represent the student and x represents the teacher.
2.
[Ans .B] X: ( )R Y: (P ) ( R) X: P + QR (P+Q) + R P Q + R Y: (P +R) + (Q + R) P + Q + R Clearly XY Consider XY (P Q + R)(P + Q + R) (P Q + R) + P + Q + R (P Q ) .R + P + Q + R (P + Q).R + P + Q + R PR + QR + P + Q + R (PR + R) + (QR + Q ) + P (P + R) (R + R) + (Q + Q ) × (R + Q ) + P (P + R) + (R + Q ) + P P + P + R + R + Q 1+1+ Q 1 ∴ XY is a tautology
3.
[Ans. A]
4.
[Ans. D] : ((A B) C) ((A LHS: (A B) C AB C (A B) C A B C RHS: (A C) (B C) (A + C) (B + C) AB+C C LHS ≠ HS
C)
is not a tautology : ((A B) C) ((A C) (B C)) LHS ((A+ B) C) (A B) C AB C HS (A C) (B C) (A C) (B C) A B C C LHS ≠ HS is also not a tautology Therefore both and are not tautologies. Correct choice is (D). 5.
[Ans. D] T m b “I an animal is a tiger or lion, then (if the animal is hungry or threatened, then it will attacks). Therefore the correct translation is ( ) ( )) [( ( ) {( Which is choice (D)
( ))
( )}]
6.
[Ans. D] By using min terms we can define A B AB AB AB A AB (A A ). (A B ) A B (A) A B A B A B (B) (A B) (A B ) (A (B ) ) (A B) AB (C) ( A B) (A B) (A (B ) ) (A B) AB (D) ( A B) (A B) (A B ) A. B A B (D) A B ∴
7.
[Ans. D] In conjunctive normal form, for any particular assignment of truth values, all except one clause, will always evaluate to true, So (D) is correct answer
[Ans. A] When ( ( )) FALSE, then the formula ( ( ( )) F: ( ( ) ( )) ( )))becomes ( ( TRUE. If ( ( )) TRUE and ( ( ) ( )) TRUE, then ( ( )) TRUE, and ∴ F TRUE. Hence formula F is valid. [Ans .B] ( ) ( ) ( ( ( ( ) (
(
) ( ( ( )
. ) ( ) ( ) ( )
) ) (
) ( (
( ) ( representation.
m ” which is
w the same as * ( ) ( )+ Which is choice (B) Alternate solution We can translate the given statement “N T ( )” ( ( ) ( )) ( ( ) ( )) ( ( ) ( )) ( ( ) ( )) Which is choice (B) 9.
( ))
( m ”
DMGT
12.
[Ans. D] [ , x,
(
(
(
[
(
(
)) is the logical
))] ))]
(
( u, v, ))]
(
13.
[Ans .C] ( )) - , Consider ,( ( ) ( )) is FALSE, then If ( ( ) is TRUE, and hence the entire statement is ( )) is TRUE and TRUE. If ( ,( - is TRUE, then is TRUE, ( )) and hence the entire statement is TRUE.
14.
[Ans .B] ( ) ( ) & iv ( ( )) Clearly, choices i and iv are equivalent. ii ( ) ( ) and iii , ( )( ) Clearly ii & iii are not equivalent to each other or to i & iv.
15.
[Ans. D] T m ((G( ) w
) )
“G ” ( ))
S( )) “
(D)
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 .”
[Ans. A] The given statement reads, P(x) is true whenever x is not 1 and for every y, if there is a z such that x = y*z, then either x = y or y = 1 In other words, P(x) is true whenever x is prime.
19.
[Ans. B] Let p : It rains q : cricket match will not be played I : ⇒
-⇒
which is not a tautology. So I is incorrect inference
[Ans. B] (F( )) ( F( )), which means there does not exist a person who can fool every one at all times.
⇒
∴ Which corresponds , ⇒ ) -⇒ ,( , -⇒ ⇒ ( )
P
T
T
F
T F T
F
F
T
I :
T
Q
P Q
~Q ~P (̅̅̅̅̅̅̅)
~P Q ̅̅̅̅̅̅̅̅̅̅̅̅ ( )
~P ~Q
16.
DMGT
)“C” )- Option “B” )))-
22.
[Ans. D] None of my friends are perfect i.e., All of my friends are not perfect ((F( ) ( )) (F( ) ( )) ( )) (F( ) Alternatively ( )) gives there exist some of (F( ) my friends who are perfect. ( )) there does not exists (F( ) any friend who is perfect i.e., none of my friends are perfect. So (D) is correct.
23.
[Ans. D] (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 not glitter (D) There are few x, which glitters and not gold.
∴ Clearly I is correct since it is in the form of Modus Tollens (rule of contrapositive)
[Ans. D] Now let us assume m b b m b P statement implies that b ( b) Q statement implies that b ( b ) ∴ P and Q are equivalent and the imply each other thus option (D) is the correct option
27.
[Ans. D] Given statement is not all rainy days are cold This means all rainy days need not be cold So there is atleast one day which is (rainy) and (not cold) So the representation is ( ) ( C ( )) Option (D) is correct
T
T
T
T
T
T
T
T
T
T
F
T
T
F
T F T T T
T
F F F T T
F
T T T F T
T
F T F F T
F
F F F T F
T
F F T T F
F
F T F T F F
F F F
c
T
T
F
(
F
)
(
( (
F
)
))
[Ans. B]
b
25.
[Ans. B] 1. If p is false, q and r are true ( (F T) T) (F T T) (T T) F T 2. If q is false, p and r are true ( (T F) T) (T F T) (T T) F T 3. If r is false, p and q are true ( (T T) F) (T T F) (F F) T F T T In all case it is giving true.
Combinatorics CS - 2005 1. What is the minimum number of ordered pairs of non-negative numbers that should be chosen to ensure that there are two pairs (a, b) and (c, d) in the chosen set such that a ≡ c mod 3 and b ≡ d mod 5 (A) 4 (C) 16 (B) 6 (D) 24
5.
Suppose that the robot is not allowed to traverse the line segment from (4,4) to (5,4). With this constraint , how many distance paths are there for the robot to reach (10,10)starting from (0,0) (A) (B) (C) ( ) (D) (
2.
Let G(x)=1/(1 x)2=∑ g(i) | | . What is g(i)? (A) i (C) i (B) i + 1 (D)
(B)
( (
) )
(C)
(
)
(D)
CS - 2007 Statement for Linked Answer Questions 4 and 5 Suppose that a robot is placed on the Cartesian plane. At each step is allowed to move either one unit up or one unit right, i.e., if it is at (i, j) then it can move to either (i j)o (i j ) 4. How many distinct paths are there for the robot to reach the point (10,10) starting from the initial position(0,0)? (A) (
)
(B) (C) (D) None of these
)
5
)
( )
(
where
CS - 2006 3. For each element in a set of size 2n, an unbiased coin is tossed. The 2n coins tosses are independent. An element is chosen if the corresponding coin toss were head. The probability that exactly n elements are chosen is (A)
(
5
)
CS - 2008 Statement for Linked Answer Questions 6 &7 Let Xn denote the number of binary strings of length n that contain no consecutive 0s. 6. Which of the following recurrences does Xn satisfy? (A) Xn 2Xn1 (C) Xn X n/2 n
7.
8.
(B) Xn Xn/2 1
(D) Xn Xn1 Xn2
The value of X5 is (A) 5 (B) 7
(C) 8 (D) 13
In how many ways can b blue balls and r red balls be distributed in n distinct boxes? (A) (B)
(
)(
(
) (
( (
)
(
) )
)
)(
)(
)
(C) (D)
(
( (
)
) )
CS – 2014 9. The number of distinct positive integral factor of 2014 is __________.
[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 of them must have (a mod 3, b mod 5) the same (basic pigeon hole principle). Let such two pairs be (a, b) and (c, d) then a mod 3 c mod 3 ac mod 3 and b mod 5 d mod 5 bd mod 5
( ) ( ) ( 4.
[Ans. A] Each path from (0,0) to (10,10) consists of 20 steps which contains 10 horizontal moves and 10 vertical moves. The 10 horizontal moves, we can choose in ways.
5.
[Ans. C] 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)
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 . ∴ = 3.
7.
[Ans. D] ,
[Ans. B] (
)
∑
(
)
∑
(
)
∑
(
)
∑
(
)
Put n = 2 (
)
∑(
)
∑(i
)
(Since r is a dummy variable, r can be replaced by i) ∑ g(i) ∴ g(i) 3.
i
8.
3, ,
5, 3.
[Ans. A] The number of ways to distribute b blue balls in n distinct boxes is equal to the number of solutions of the equation b, which is distribution of the r red balls is . Since the distribution of red balls and blue balls are independent, the
[Ans. A] The probability that exactly n elements are chosen = the probability of getting n heads out 2n tosses ( ) ( )
[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 )( )( ) =(
Sets and Relations CS – 2005 1. Consider the set H of all 3×3 matrices of the type [
a
]
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 (B) a monoid but not a group (C) a semigroup but not a monoid (D) neither a group nor a semigroup 2.
3.
4.
5.
The set {1, 2, 4, 7, 8, 11, 13, 14} is a group under multiplication modulo 15. The inverses of 4 and 7 are respectively (A) 3 and 13 (C) 4 and 13 (B) 2 and 11 (D) 8 and 14 Let R and S be any two equivalence relations on a non-empty set A. Which one of the following statements is TRUE? (A) , are both equivalence relations (B) is an equivalence relation (C) is an equivalence relation (D) Neither nor is an equivalence relation Let f:B C and g:A B be two functions and let h=f o g . Given that h is an onto function. Which one of the following is TRUE? (A) f and g should both be onto functions (B) f should be onto but g need not be onto (C) g should be onto but f need not be onto (D) both f and g need not be onto The following is the Hasse diagram of the poset [{a, b, c, d, e}, ≺].
c
b
e The poset is (A) not a lattice (B) a lattice but not a distributive lattice (C) a distributive lattice but not a Boolean algebra (D) a Boolean algebra 6.
Let A, B and C be non-empty sets and let X=(A B) C and Y=(A C) (B C). Which one of the following is TRUE? (A) X=Y (B) (C) (D) none of these
7.
Let A be a set with n elements. Let C be a collection of distinct subsets of A such that for any two subsets S1 and S2 in C, either S1 S2 or S2 S1 . What is the maximum cardinality of C? (A) n (C) (B) n+1 (D) n!
8.
Let f be a function from a set A to a set B, g is a function from B to C, and h is a function from A to C, such that h(a)= g(f(a)) for all a ϵ A. Which of the following statements is always true for all such functions f and g? (A) g is onto h is onto (B) h is onto f is onto (C) h is onto g is onto (D) h is onto f and g are onto
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
What is the cardinality of the set of integers X defined below? X = {n | 1 n 123, n is not divisible by either 2, 3 or 5} (A) 28 (C) 37 (B) 33 (D) 44
16.
Let P, Q and R be sets. Let denote the symmetric difference operator defined as P Q = (P Q) – (P Q). Using Venn diagrams, determine which of the following is/are TRUE? )=( ) ( (I) P ( ) ( ) ( ) ( (II) P = ) (A) I only (B) II only (C) Neither I nor II (D) Both I and II
17.
For the set N of natural numbers and a binary operation f: N×N N, an element z ϵ N is called an identity for f, if f(a, z) = a = f(z, a), for all a ϵ N. Which of the following binary operations have an identity? (I) f(x, y) = x + y – 3 (II) f(x, y) = max(x, y) (III) f(x, y) = xy (A) I and III only (B) II and III only (C) I and II (D) None of these
/
Let = * , , 3, ……………, m+,m>3. Let X1 ,............Xn be subsets of S each of size 3. Define a function f from S to the set of natural numbers as, f(i) is the number of sets that contains the element i. That is f(i) = |{ j|i |}.Then m
f (i) is
i 1
(A) 3m (B) 3n
(C) 2m + 1 (D) 2n + 1
11.
Let X, Y, Z be sets of sizes x, y and z respectively. Let W=X Y and E be the set of all subsets of W. The number of functions from Z to E is (C) (A) (B) Z (D)
12.
A relation R is defined on ordered pairs of integers as follows (x, y) R (u, v) if xv. Then R is (A) Neither a partial order nor an Equivalence Relation (B) A Partial order but not a Total order (C) A Total Order (D) An Equivalence Relation
13.
14.
The set {1, 2, 3, 5, 7, 8, 9} under multiplication modulo 10 is not a group. Given below are four possible reasons. Which one of them is false? (A) It is not closed (B) 2 does not have an inverse (C) 3 does not have an inverse (D) 8 does not have an inverse
DMGT
CS - 2007 18. How many different non-isomorphic Abelian groups of order 4 are there? (A) 2 (C) 4 (B) 3 (D) 5
19.
Let E, F and G be finite sets. Let = (E F) (F G) and Y = (E – (E G)) (E – F ). Which one of the following is true ? (A) (B) ⊃ (C) X = Y (D) X – ≠ ∅ and – ≠ ∅
th
Consider the set S={a, b, c, d}. Consider the following 4 partitions , , , on ̅̅̅̅̅̅}, π = {ab ̅̅̅, cd ̅̅̅}, π = {abc ̅̅̅̅̅, d̅}, : π1={abcd ̅ ̅ π = *a̅, b, c̅, d+ Let be the partial order on the set of partitions ’= (π , 2 3 , 4 ), defined as follows: πi πj if and only if πi refines πj . The poset diagram for ( , ) is
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) (ii) and (iv) (D) (iii) and (iv)
π π π π
(B)
π 22.
π
π
π (C)
π
π
π
π (D)
π
π
π
21.
Let S be a set of n elements. The number of ordered pairs in the largest and the smallest equivalence relations on S are (A) n and n (C) n2 and 0 2 (B) n and n (D) n and 1
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 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? (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 (C) (D) U
25.
Consider the following Hasse diagrams.
π 20.
DMGT
A partial order P is defined on the set of natural numbers as follows. Here x/y denotes integer division. i. (0, 0)ϵ P. ii. (a, b)ϵ if and only a % b% and (a/10, b/10)ϵ P.
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
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 (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.
Which all of the above represents a lattice (A) (i) and (iv) only (B) (ii) and (iii) only (C) (iii) only (D) (i), (ii) and (iv) only CS – 2009 26. For the composition table of a cyclic group shown below * a b c d a a b c d b b a d c c c d b a d d c a b Which one of the following choices is correct? (A) a, b are generators (B) b, c are generators (C) c, d are generators (D) d, a are generators 27.
Which one of the following is NOT necessarily a property of a Group? (A) Commutativity (B) Associativity (C) Existence of inverse for every element (D) Existence of identity
CS - 2012 31. How many onto (or surjective) functions are there from n- element (n≥2) set to a 2-element set? (A) (C) ) (B) (D) (
CS - 2013 32. A binary operation ⨁ on a set of integers is defined as ⨁y = x . Which one of the following statement is TURE about ⨁? (A) Commutative but not associative (B) Both commutative and associative (C) Associative but not commutative (D) Neither commutative nor associative CS - 2014 33. A pennant is a sequence of numbers, each number being 1 or 2. An n-pennant is a sequence of numbers with sum equal to n. For example, (1,1,2) is a 4-pennant. The set of all possible 1-pennants is {(1)}, the set of all possible 2-pennants is {(2), (1,1)} and the set of all 3-pennants is {(2,1), (1,1,1), (1,2)}. Note that the pennant (1,2) is not the same as the pennant (2,1). The number of 10pennants is ______________.
Let S denote the set of all functions * , + * , +. Denote by N the number of functions from S to the set {0,1}. The value of log log is ______.
35.
A non-zero polynomial f(x) of degree 3 has roots at x = 1, x = 2 and x =3. Which one of the following must be TRUE? (A) f( )f( ) (B) f( )f( ) (C) f( ) f( ) (D) f( ) f( )
36.
Consider the following relation on subsets of the set of integers between 1 and 2014. For two distinct subsets U and V of S we say U
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.
DMGT
Which one of the following is CORRECT? (A) P, Q and R are true (B) Only Q and R are true (C) Only P and Q are true (D) Only R is true 39.
th
There are two elements x, y in a group (G,∗) such that every element in the group can be written as a product of some number of x's and y's in some order. It is known that ∗ = ∗ = ∗ ∗ ∗ = ∗ ∗ ∗ = Where e is the identity element. The maximum number of elements in such a group is ____.
[Ans. A] The set H is closed, since multiplication of upper triangular matrices will result only in upper triangular matrix. Matrix multiplication is associative, i.e. A (B C) = (A B) C. (iii)The identity element is I should be = [
S is reflexive. Now, (x, y) R S (x, y) R and (x, y) S (y, x) R and (y, x) S (Since R and S are symmetric) (y, x) R S (x, y) R S (y, x) R S Therefore R S is symmetric. Now consider (x, y) and (y, z) R S (x, y) and (y, z) R and (x, y) and (y, z) S (x, z) R and (x, z)S (Since R and S are transitive) (x, z) R S R S is transitive also Since is reflexive, symmetric and transitive. R S is equivalence relation. Note: A similar argument cannot be made for R S.
]
and this belongs to H as I is an upper triangular as well as lower triangular matrix. If AH, then |A = abc. Since it is given that abc 0, this means that |A 0 i.e., every matrix belonging to H is non-singular and has a unique inverse. The set H along with matrix multiplication is a group. 2.
3.
[Ans .C] The set S = {1, 2, 4, 7, 8, 11, 13, 14} is a group under multiplication modulo 15. The identity element for this group is e = 1 since, x , ∙x mod 5 = x Now let the inverse of 4 be . Therefore ( ∙ ) mod 15 = e = 1 (by the definition of inverse) ince ( ∙ ) mod 5 = = 4 (This inverse is unique) Similarly let the inverse of 7 be 7 . (7∙7 ) mod 15 = 1 (7.7 ) mod 15 =1 inverse clearly 1,2 cannot be 7 7. 5 7. 5 Putting each element of the set as 7 by trial and error we get (7.1) mod 15= 7, (7.2) mod 15 =14; (7.4) mod 15 = 13; (7.7) mod 15 = 4; (7.8) mod 15 = 11; (7.11) mod 15 = 2; (7.14) mod 15 = 8, (7∙ 3) mod 5 = 9 mod 5 = 7 =13 So and 7 are respectively 4 and 13. Correct choice is (C).
4.
[Ans. B] Consider the arrow diagram shown below B C A g f a 1 b 2 3 h h (a) = f∙(g (a)) = h (b) = f∙(g (b)) = Here f is onto but g is not onto, yet h is onto. As can be seen from the diagram for h to be onto f should be onto, but g need not be onto. Answer is (B).
5.
[Ans. B] a
[Ans. C] R S is an equivalence relation as can be seen from proof given below. Let xA (x, x)R and (x, x)S(since R and S are reflexive) (x, x)R S also.
The poset [{a, b, c, d, e},≺] is a lattice (since every pair of elements has LUB and GLB) but it is not a distributive lattice. Because distributive lattice satisfies the following conditions. For any x, y, z, x (y z) = (x y) (x z) x (y z) = (x y) (x z) Where and are meet and join operations respectively. For given poset [{a, b, c, d, e}≺] b (c d) = b a = b (b c) (b d) = e e = e So it is not distributive. (Also, the element b has 2 complements c and d, which is not possible in a distributive lattice, since, in a distributive lattice, complement if exists, is always unique). Hence it is not a Boolean algebra. 6.
[Ans. A] Let A denote the complement of set A. = (A B) C = (A B ) C = A (B C) = (A C) (B C) = (A C ) (B C ) = (A C ) (B C) = (A C B ) (A C C) = A (B C) ( A C C = ∅) =
7.
[Ans. B] The set C with the subset relation ⊆ is a total order. Hence the elements of C can be ordered as ⊆ ⊆ ⊆ . We have | | | |if i j. The longest possible chain is ⊆ ⊆ ⊆ ⊆ = A. Hence the maximum cardinality of C is n .
8.
[Ans. C] If g is not ONTO, then no way h can be ONTO. h is ONTO g is ONTO. Let A = {1}, B = {1, 2}, C = {1}, ( ) = , g(1) = 1, g(2) = 2, shows that h = g of need not be ONTO even when g is ONTO. Option ‘A’ is wrong
9.
[Ans. C] If A = B, then for any π, min ,π (A)- = min,π (B)-. Hence the number of permutation π which satisfy the criterion in this special case is n !.
Only the choice n!
DMGT |
|
|
|
equal to n !. Hence
the correct answer must be n! 10.
|
|
|
|
[Ans. B] ∑ f(i)just represents | | | | ∙∙∙ | |, because f(i) equals the total number of occurrences of element i in the set . ∑ f(i) = 3n ( | | = 3).
11.
[Ans. D] | | = x, | | = y and | | = z Given = So| | = xy |E| = | | = So the number of distinct functions from Z to E = |E|| | =( ) =
12.
[Ans. A] (x, y) R(u, v) iff x < u and y > v (x, x̅) (x, x) since x x and x x So R is not reflexive, R is neither a partial order, nor an equivalence relation.
13.
[Ans. C] Let A= {1, 2, 3, 5, 7, 8, 9} Construct the Cayley table for any x, y A such that x * y = (x.y) mod 10 1 2 3 5 7 8 9 1 1 2 3 5 7 8 9 2 2 4 6 0 4 6 8 3 3 6 9 5 1 4 7 5 5 0 5 5 5 0 5 7 7 4 1 5 9 6 3 8 8 6 4 0 6 4 2 9 9 8 7 5 3 2 1 We know that 0 A. So it is not closed. ( .5)mod A Therefore, (A) is true. The identity element = 1 ( ) mod 10 = 1 From the table we see that does not exist. Since, (3 7)mod = 7 is the inverse of 3 and 7ϵ A. (C)is false (D) is true since 8 does not have inverse.
[Ans. C] Consider the following Venn diagram for = (E F) (F G) E
Again the number of elements divisible by 5 will be in multiples of 5 i.e., = elements Total number of elements divisible by 2 and 3 or 5 is 20 + 24 = 44
F
16. E
DMGT
F
[Ans. B] ( ) U
F
G
G
= (E
(E = (E
G))
(E
(E G)) E
F) (E F) 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) = EF (F G) = 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) = EE G EFG = EFG X=Y 15.
(
)
Now (
)is
And
[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
[Ans. C] 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 f(y, a ) = y + a 3 Clearly f(a, y) = a = f(a, y)for y = 3 and a
(
And
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
)=
=
3
18.
th
[Ans. A] 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
b ∙ c = a and c ∙ a = b. Hence only two non-isomorphic Abelian groups of order 4 exist. 19.
22.
[Ans. A] = *x |x x x = , (x ) where x = ,x ,x } Let = ( , , ) ( , , ) ( , , )=( , , ) Clearly ( , , ) ( )=( , , ) , . , . = = } = = = contains L. I vectors also For any x ( , , ) x= ( , , ) (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
24.
[Ans. D] Let A=( = .(
[Ans. C] 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 π π and π are not comparable since neither is a refinement of the other. So the poet diagram for ( , ≺) is π
π
π
π
Which is choice (C). 20.
[Ans. B] Let S be a set of n elements say * , , 3,……., n+. Now the smallest equivalence relation on S must contain all the reflexive pairs *( , ), ( , ), (3, 3) …., (n, n)} and its cardinality is therefore n. The largest equivalence relation on S is S × S, which has cardinality n × n = n . The largest and the smallest equivalence relations on S have cardinalities n and n respectively. The correct choice is (B).
DMGT
)
(
) )/
(
= = U.
25.
) (
) ,
(
) = U]
[Ans. A] a
b
21.
c
[Ans. D] It can be seen that ( , ) if and only if the decimal digit of b at the 10th place is greater than or equal to that corresponding to , ≥ . This follows from the fact that % returns the decimal digit at unit’s place and truncates the digit at the unit’s place. 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 must be greater than or equal to that of a. The rule ( , ) respectively specifies this rule for all the other digit positions. Hence, only (145, 265) and (0, 153) P.
d
It is a lattice because for each pair supremum and infimum exists a
b
c
d
e
is not a lattice because lub (e, d) does not exist (b and c are not comparable).
[Ans. A] Group properties are closure, associativity existence of identity and existence of inverse for every element. Commutativity is not required for a mathematical structure to a group.
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. is not symmetric. Also (x, z) R and (z, x) R. is not antisymmetric. R is neither symmetric nor anti-symmetric.
29.
[Ans. A] {S, *} is a group. To be a ring, an integral domain, or a field, there must be two binary operations.
30.
[Ans. C] Let S be a set of n elements. A relation R S×S is reflexive if (r, r) R r S. Each of the remaining elements of S×S may or may not be present in R. Hence the number of reflexive relations on S is . When n = 5, the answer is .
31.
[Ans. C] Let n = 2. There are only 2 onto functions as shown below:
f is not a lattice since lub (e, d) does not exist. a c
b d
e
is a lattice since every pair has lub as well as glb. 26.
[Ans. C] If an element is a generator, all the elements must be obtained as powers of that element. Try a, b, c, d one by one to see which are the generators. a=a a = a. a = a a = a. a = a. a = a and so on. a is not the generator. b=b b = b. b = a b = b. b = b. a = b b = b. b = b. b = a and so on b is not the generator c=c c = c. c = b c = c. c = c. b = d c = c. c = c. d = a Since all of a, b, c, d have been generated as powers of c, c is a generator of this group. Similarly d=d d = d. d = b d = d. d = d. b = c d = d. d = d. c = a d is the other generator.
DMGT
A
B
a
b
A
B
a
b
For n = 2 Option (A) = = Option (B) = =3 Option (C) = = )= ( )= Option (D) ( So only the option (C) gives the correct answer.
[Ans. A] x y=x y x y=y x As ‘ ’ sign in commutative so x y is equal to y x so x y is commutative. Now check associativity x (y z) = x (y z ) (y =x z ) =x y z y z (x y) z = (x y ) z = (x y ) z =x y x y z x (y z) ≠ (x y) z So not associative Option (A) is Correct. [Ans. *] Range 88.9 to 89.1 For 10 – pennants we need to consider minimum 5 coordinates, maximum 10 coordinates in n – tuple For 5 – tuple all entries are 2 [i.e (2, 2, 2, 2,2)] So no. of 5 – tuples = 1 For 6 – tuple 4 entries are 2 (remaining are 1) So no.of 6 – tuples 6 = 5 For 7 – tuple 3 entries are 2 (remaining are 1) so no.of 7 – tuples 7 = 35 For 8 – tuple 2 entries are 2 (remaining are 1) so no.of 8 – tuples 8 = 8 For 9 – tuple 2 entries are 2 (remaining are 1) so no.of 9 – tuples 9 = 9 For 10 – tuple all entries are [ie. (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) so no.of 10 – tuples = 1] No.of 10 pennants = 5 35 8 9 = 89 [Ans. 16] If |A| = m, |B| = n then the no. of functions from A to B is …..( ) | | And = ….( ) Given S is set of all function of f: * , + * , + (A) (B) By (2) domain (A) contains elements So S contains function (by (1)) Given N is the no.of function from S to {0, 1} So N = (by( )) So log log N
35.
[Ans. A] Since, the roots of f(x) = 0 i.e., x =1 2, 3 lies between 0 and 4 and f(x) is of degree 3 f( ) and f(4) are of opposite signs f( ). f( ) .
36.
[Ans. A] For statements , (empty set) is example is larger than all the elements For statement , (itself * , , ……. + is example) S is smaller than all the elements So option (A) is correct
37.
[Ans. D] f: defined by f(a) = , f(b) = , f(c) = where X = *a, b, c+ = * , + Let A = {a, c}, B = {b, c} be subsets of X Then |f(A B)| = 2; |f(A)| = 2 ; |f(B)| = 2 f(A B) = * + f(A) = * , + f(B) = * , + f(A) f(B) = * , + |f(A B)| = 1 ptions (A), (B)and (C) are not true Hence, option (D) is correct
38.
[Ans. B] a. Since f(f(i)) = i Every element in codomain has some pre image. So f is onto. So R is true b. To have this type function we can have either ption f(i) = i i In this case P, Q are both true Option 2 Take any pair x, y in * , , ……. + and map f(x) = y, f(y) = x Do like this for all pairs ince * , , , ……. + contains odd of elements, one element ‘z’ will be left finally For that element we must have f(z) = z So in this case only Q is true P is false nly , are true o option (B) is correct
39.
[Ans. 4] Given x ∗ x = e y ∗ y = e, x ∗ y ∗ x ∗ y = e, y ∗ x ∗ y ∗ x = e ………( ) From (1) we can observe for any number of x, y’s (in any order) the result of binary operation ∗ is e except for one x, y [for example x ∗ y ∗ y ∗ x = x ∗ e ∗ x = x ∗ x = e]
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
Graph Theory CS – 2005 1. Let G be a directed graph whose vertex set is the set of numbers from 1 to 100. There is an edge from a vertex i to a vertex j iff either j = i + 1 or j = 3i. The minimum number of edges in a path in G from vertex 1 to vertex 100 is: (A) 4 (C) 23 (B) 7 (D) 99 2.
3.
Let G be a simple connected planar graph with 13 vertices and 19 edges. Then, the number of faces in the planar embedding of the graph is (A) 6 (C) 9 (B) 8 (D) 13 Which one of the following graphs is NOT planar?
CS - 2006 Common Data for Questions 4, 5, 6: The vertices of a graph G correspond to all subsets of a set of size n, for n 6. Two vertices of G are adjacent if and only if the corresponding sets intersect in exactly two elements. 4. The number of vertices of degree zero in G is (A) 1 (C) n +1 (B) n (D) 5.
The maximum degree of a vertex in G is ) (C) (A) ( (D) (B)
6.
The number of connected components in G is (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 (C) 2 / n (A) (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
CS- 2008 10. What is the chromatic number of the following graph?
(A) (B) (C) (D) 15.
DMGT
I and II III and IV IV only II and IV
Let G = (V, E) be a graph. Define (G) = id d where is the number of d
(A) 2 (B) 3 11.
(C) 4 (D) 5
G is a simple undirected graph. Some vertices of G are of odd degree. Add a node v to G and make it adjacent to each odd degree vertex of G. The resultant graph is sure to be (A) Regular (B) Complete (C) Hamiltonian (D) Euler
CS - 2009 12. Which one of the following is TRUE for any simple connected undirected graph with more than 2 vertices? (A) No two vertices have the same degree (B) At least two vertices have the same degree (C) At least three vertices have the same degree (D) All vertices have the same degree 13.
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 | (D) | S | = | T | + 1
What is the chromatic number of an n-vertex simple connected graph which does not contain any odd length cycle? Assume n (A) 2 (C) n – 1 (B) 3 (D) n
CS - 2011 16. K4 and Q3 are graph with the following structures. K4
Q3
Which one of the following statements is TRUE in relation to these graphs? (A) K4 is planar while Q3 is not (B) Both K4 and Q3 are planar (C) Q3 is planar while K3 is not (D) Neither K4 nor Q3 is planar CS – 2012 17. Let G be a simple undirected planar graph on 10 vertices with 15 edges. If G is a connected graph, then the number of bounded faces in any embedding of G on the plane is equal to (A) 3 (C) 5 (B) 4 (D) 6 18.
Which of the isomorphic to
following
graphs
is
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
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 (A) 15 (C) 90 (B) 30 (D) 360
CS - 2013 20. Which of the following statement is/are 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 (C) Both P and Q (D) Neither P nor Q 21.
Consider an undirected random graph of eight vertices. The probability that there is an edge between a pair of vertices is 1/2. What is the expected number of unordered cycles of length three? (A) 1/8 (C) 7 (B) 1 (D) 8
22.
The line graph L(G) of a simple graph G is defined as follows: There is exactly one vertex v(e) in L(G) for each edge e in G. For any two edges e and e' in G, L(G) has an edge between v(e) and v(e'), if and only if e and e' are incident with the same vertex in G. Which of the following statements is/are TRUE? P. The line graph of a cycle is a cycle. Q. The line graph of a clique is a clique. R. The line graph of a planar graph is planar. S. The line graph of a tree is a tree. (A) P only (B) P and R only (C) R only (D) P, Q and S only
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) *( ) } ( ) (D) is the set of vertices in 24.
Consider the direct graph given below P
Q
R
S
Which one of the following is true? (A) The graph does not have any topological ordering (B) Both PQRS and SRQP are topological ordering (C) Both PSRQ and SPRQ are topological ordering (D) PSRQ is the topological ordering 25.
Consider an undirected graph G where self-loops are not allowed. The vertex set of G is *( ) +. There is an edge between (a, b) and (c, d) b .T b of edges in this graph is __________.
26.
An ordered n tuple ( ) with is called graphic if there exists a simple undirected graph with n vertices having degrees respectively. Which of the following 6-tuples is NOT graphic? (A) (1, 1, 1, 1, 1, 1) (B) (2, 2, 2, 2, 2, 2) (C) (3, 3, 3, 1, 0, 0) (D) (3, 2, 1, 1, 1, 0)
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
1
2
2
DMGT
2 1
2
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, number of faces is less than
the
(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
[Ans. B] Since along any path, at each step the vertex labels can atmost be triple and ⌉ since ⌈ , we must have the shortest path length from vertex 1 to 100 greater than or equal to 5. The path
Since we want exactly 2 elements in common, we can choose these in ways and then we can add or not add remaining n 3 elements. This can be done in ways. ∴ Total number of subsets with at least 2 elements in common with {1, 2, 3} is given by and for 4 elements subsets is for 5 elements subsets is and so on. Out of these is less than
shows that the shortest path length is less than or equal to 7. It can be shown that the shortest path length cannot be 5 or 6, hence it is 7. 2.
3.
[Ans. B] Given V = 13, E = 19 Let R be the number of regions. R = E – V +2
Then and than
[Ans. A] is same as which is known to be non-planar. G2, G3 and G4 can be redrawn as follows so they are planar.
4.
[Ans. C] The vertices of degree zero are vertex corresponding to the empty set, and those corresponding to the singleton sub-sets of the given set of n elements. Hence the number of vertices of degree 0 is n + 1.
5.
[Ans. C] L b S * 4 . + Consider a subset containing 2 elements of the form {1, 2}. Now {1, 2} will be adjacent to any subset with which it has exactly 2 elements in common. These sets can be formed by adding zero or more elements from remaining n 2 elements to the set {1, 2}. Since each of these elements may be either added or not added, number of ways of making such sets containing 1 and 2 is . ∴ The vertices with 2 elements will have degrees. Now consider the subsets of 3 elements say {1, 2, 3}
is same as is greater
∴ The maximum degrees in this graph is occurring for 3 element and 4 element 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 they can form connected components. The remaining vertices of the graph G are all connected as a single component. So the total number of connected component is .
7.
[Ans. C] The shortest distance between two vertices u and v whose corresponding bit strings are at hamming distance d is of length d. Hence, the diameter of G is n. Also, since all the paths between any two given vertices are all of odd length and are all of even length, we get that the chromatic number of G is 2. Hence the required ratio is .
8.
[Ans. A] Any k regular graph for k (even no) Eulerian circuit because we have a result y “ th
every vertex has even degree, then it has ” And since k – regular graph where k-even number is connected and every vertex is of even degree ∴ Option (A) is correct 9.
[Ans. B] K5 and are the smallest non planar graphs. K5 has 5 vertices and = 10 edges and has 6 vertices and edges. So, the non planar graph with the minimum number of edges is with 9 edges and 6 vertices. Note: K5 is the non planar graph with the minimum number of vertices.
10.
[Ans. B] a
b
b
(B) Complete graph on 90 vertices does not contains Euler circuit, because every vertex has odd degree odd(89) (C) The complement of a cycle on 25 vertices must contain Euler circuit, where of each vertex is even (22) 13.
[Ans. A] If a n-vertex simple connected graph contains no cycles of odd length, then its chromatic number is two. Since the vertices can be alternately colored with the first color, the second color, then the first color and the second color and so on. Alternatively, since a simple connected graph with no cycles of odd length must be bipartite, and since the chromatic number of bipartite graph is always 2 (in a bipartite graph each partition requires one color there are no edges within a partition of a bipartite graph and there are only two partitions).
14.
[Ans. D] The length of a degree sequence gives the number of vertices in the corresponding graph. All the given sequences have length equal to 8, since graphs are simple, no vertex can have degree more than 7. ∴ The sequence 8, 7, 7, 6, 4, 2, 1, 1 is not possible. A vertex can have degree 6 when it is connected to every other, except one. When there are four vertices of degree six each, then there are at most two vertices of degree two each (if no vertex is of degree 1), in which case other vertices are of degree at least 4. Hence the sequence 6, 6, 6, 6, 3, 3, 2, 2 cannot be possible. The other two sequences are possible.
15.
[Ans. C] Given, ( ) =
c d e
Let us try to color the graph with two colors. From the path (a, b, c, d, e), we see that a and e must be colored with the same color. But this is not possible since there is an edge between a and e. It is easy to see that 3 colors sufficient. A pattern of coloring is given and we can observe that the chromatic number of the given graph is 3. 11.
12.
[Ans. D] A connected graph has an Euler circuit if and only if every vertex is of even degree. A K-regular graph has all vertices of degree K each. Hence if K is even, a connected K-regular graph has an Euler circuit.
DMGT
i d = Sum of degrees d
[Ans. C] Whenever in a graph of vertices have even degrees, it will surely have an Euler circuit. (A) Since in a k-regular graph, every vertex has exactly k degrees and if k is even, every vertex in the graph has even degrees. k-regular graph need not be connected, hence k-regular graph may not contain Euler circuit
d
By handshaking lemma, ( ) where, is the number of edges in G. (T). If S and T are two trees with (S)
In a tree, S and T Where |S| is the number of vertices of tree S and |T| is the number of vertices of tree T. ∴ S T S T th
[Ans. B] Both the graphs are planar as can be seen from their planar representation.
17.
[Ans. D] n = 10 e = 15 In a simple connected planar graph, ’ b regions as e Out of this, one region is unbounded and the other 6 are bounded. So correct answer is 6, which is Option (D).
18.
[Ans. B] Check invariants are one by one. Step 1: All 4 choices have same number of vertices and edges as given graph. Step 2: So we find degree sequence of given graph which is (1, 1, 2, 2, 2, 2, 2, 4). Degree sequence of graph in option (A) is (1, 1, 1, 2, 2, 2, 3, 4). Degree sequence of graph in option (B) is (1, 1, 2, 2, 2, 2, 2, 4). Degree sequence of graph in option (C) is (1, 1, 2, 2, 2, 2, 3, 3). Degree sequence of graph in option (D) is (1, 1, 2, 2, 2, 2, 2, 4). So only options (A) and (C) are not isomorphic to given graph, since degree sequence of these graphs is not same as given graph. Step 3: Now to decide between option (B) and (D), which one is isomorphic to given graph, we check the number of cycles. In given Graph there is one cycle of length 5. But in Graph (B) has one cycle of length 5. So only Graph (B) can be isomorphic to given Graph.
19.
[Ans. C] The graph given is K6 In K6, every cycle of length 4 corresponds to selecting 4 vertices out of 6 vertices, which can be done in ways and then ordering the 4 vertices in circular permutation in 3! ways (since vertices are labeled). So final answer is .
DMGT
20.
[Ans. C] P : Number of odd degree vertices is even 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 degrees. H ‘ ’ all vertices is 2e (is even) Note: It is valid even in case of self loops P is also true: Reason: We have established that sum of degree of all vertices is even Let us assume, that the number of odd degree vertices is odd, so, the contribution of odd degree vertices in total sum is odd Now the contribution of even degree vertices is also even (whether the number is even or odd). So, total sum becomes odd, which is not possible. Hence P is true Note: Include vertex of degree zero in even degree vertices.
21.
[Ans. C] We need to find unordered cycles of length 3 so we choose any 3 vertices from 8 vertices. This can be done in ways. To make a cycle we need to choose edge between the selected vertices. The probability of choosing any edge is 1/2. So for three edges = Expected no. of cycle = ∑
22.
th
( )
[Ans. A] L ‘ ’b y .I L( ) 1. There will be an edge between two vertices corresponding to the adjacent edges in the cycle 2. Degree of each vertex in L(C) will be z. 3. L(C) will be connected. Hence L(C) will also be a cycle So, (P) is True
(Q) L ‘ n’ b q Consider line graph L(Kn). L(Kn) has vertices
‘ ’
.
matrix (1). Out of 144 vertices, 100 vertices are like this no.of edges for these = 800 Out of the remaining 44 vertices, the corner vertices [ie. (1, 1), (1, 12), (12, 1), (12, 12)] has 3 edges as shown in matrix (2) so 4 The remaining 40 vertices has 5 edges as shown in matrix (3) so 4 5=200 So total no of edges = Since the graph is undirected no.of edges
For n>3, there will be two edges say e1, e2 “ n” “ n” So V(e1), V(e2) will not be adjacent in L(Kn). Hence L(Kn) is not always a clique (Q) is False 23.
[Ans. B] Take an example for Graph G . . A B Then option A and D will be eliminated. Let G is below graph A B Then is a graph with below structure
= 26.
25.
( 1, 1, 1, 1, 1, 1)
( ( ( [
) ) )
( ( (
) ) ) ( ) ( ) ( ) ( ) ( )
( ( (
) ) )
( ( (
) ) )
( ( (
( 1, 1) ( 0, 0)
(1, 1)
Got all zeros so graphic Option (B) ( 2, 2, 2, 2, 2, 2)
( 1, 1, 2, 2, 2) ( 1, 1, 1, 1)
( 2, 2, 2, 1, 1) ( 1, 1, 1, 1)
( 1, 1,) ( 0, 0)
(1, 1)
[Ans. 506] Given vertex set is V = {(i, j)|1 } Imagine vertex set as a matrix as follows ) ) )
( 1, 1, 1, 1)
( 1, 1, 1, 1)
[Ans. C] PQRS is not a topological ordering because no edge is there from Q to R PSRQ and SPRQ are topological ordering because S Q and Q exits b y y
( ( (
[Ans. C] Apply Havel – Hakimi algorithm to the four options Option (A)
A B In G the number of strongly connected components are 2 ,where as in it is only one.
24.
DMGT
Got all zeros so graphic Option (C) 2 2 0 (3, 3, 3, 1, 0, 0)
) ) )
( ( (
) ) )
) ) )
( ( (
) ) )
1 (2, 2, 0, 0, 0)
(2, 2, 0, 0, 0) (1,
0, 0)
( ) ( ( (
) ) )
( ( (
) ) )
( ( ( (4)
Got negative number. So it is not graphic Option (C) is correct
]
All the vertices (except in 1st row, 1st column, last row, last column) has 8 edges to the neighboring vertices as shown in th
group is not equal to given group. Thus the order cannot be 3 or 5. Hence it is 5.
vertices is given by ⌊ ⌋ . 28.
⌊
31.
[Ans. C] If G is a tree with n vertices then no.of edges = n – 1 If G is forest (collection of trees) with k connected components then the edges = n – k. ∴Option (C) is correct
32.
[Ans. A] By Euler formula
⌋
4
[Ans. 5] Result 1: In a cycle graph no.of vertices = n, edges = n Result 2: If a graph G is isomorphic to its complement then E(G) = (
S
(
)
)
.( ) By Hand shaking theorem.
4=n–1 n=5 29.
DMGT
( )
∑
[Ans. 6] In graph portion
δ δ δ
1
2
. ,
2
Two
2
2
2
1
2
And in subgraph 2 1
-
From (1) we have f=2+e–v =2+e–n
ST are possible 2
δ
∴ So no. of faces is atleast Option (A)is answer
1
2 2
Three ST 2 1
possible 1
1
2
1
1
2
1
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
ER Diagrams CS – 2005 1. Let and be two entities in an ER diagram with simple single-valued attributes. R1 and R2 are two relationships between and , where R1 is one-to-many and R2 is many-to-many. R1 and R2 do not have any attributes of their own. What is the minimum number of tables required to represent this situation in the relational model? (A) 2 (C) 4 (B) 3 (D) 5 2.
3.
The following table has two attributes A and C where A is the primary key and C is the foreign key referencing A with on-delete cascade. A C 2 4 3 4 4 3 5 2 7 2 9 5 6 4 The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (2, 4) is deleted is: (A) (3,4) and (6,4) (B) (5,2) and (7,2) (C) (5, 2) (7, 2) and (9, 5) (D) (3, 4) (4, 3) and (6, 4) Consider the entities ‘hotel room’, and ‘person’ with a many to many relationship ‘lodging’ as shown below: HotelRoom
Lodging
Person
(A) (B) (C) (D)
Person Hotel Room Lodging None of these
CS - 2008 Linked Answer Questions 4 & 5 Consider the following ER diagram
4.
The minimum number of tables needed to represent M, N, P, R1, R2 is (A) 2 (C) 4 (B) 3 (D) 5
5.
Which of the following is a correct attribute set for one of the tables for the correct answer to the above question? (A) {M1, M2, M3, P1} (B) {M1, P1, N1, N2} (C) {M1, P1, N1} (D) {M1, P1}
CS - 2012 6. Given the basic ER and relational models, which of the following is INCORRECT? (A) An attributes of an entity can have more than one value (B) An attribute of an entity can be composite (C) In a row of a relational table, an attribute can have more than one value (D) In a row of a relational table, an attribute can have exactly one value or a NULL value
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
[Ans. B] M, P ⟶ Entity sets, will become tables N ⟶ Weak Entity set, will become a table R1 ⟶ Relationship set with cardinality N:1, will not be a table R2 ⟶ Identifying Relationship set, will not be a table Total No of tables = 3 1) M=(M1, M2, M3, P1) 2) P =(P1, P2) 3) N =(N1, P1, N2)
5.
[Ans. A] The correct attribute set is {M1, M2, M3, P1}
6.
[Ans. C] ⟶ An attribute of an Entity can be atomic, Multi-valued, and composite. ⟶ An attribute (or) column of a table must take exactly one value (or) a NULL value. Option A ⟶Correct, Multivalued Attribute Option B ⟶Correct, Composite Attribute Option C ⟶Incorrect, since column cannot take multiple values Option D ⟶ Correct, column in a table takes single value (or) NULL.
1: N
E1
E2
N: N
E1, E2 are entities will become tables Relationship with cardinality 1:N will not be a table [Primary key of 1- side [E1] will be included as foreign key of N – side [E2]] Relationship with cardinality N:N will become a table. Total No of tables = 3 = {E1, E2, } 2.
[Ans. C] A rimary key Parent column C Foreign key Child column “C” refers to “A” O -DELETE CASCADE, when parent gets deleted, all corresponding child rows will be deleted automatically. (2, 4) is deleted [Parent =2] (5, 2) and (7, 2) will get deleted (5, 2) is deleted [Parent = 5] (9, 5) will get deleted (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.
Functional Dependencies & Normalization CS – 2005 1. Which-one of the following statements about normal forms is FALSE? (A) BCNF is stricter than 3NF (B) Lossless, dependency-preserving decomposition into 3NF is always possible (C) Lossless, dependency-preserving decomposition into BCNF is always possible (D) Any relation with two attributes is in BCNF
CS - 2006 5. The following functional dependencies are given: AB→ CD, AF →D, DE→ F, C →G, F→ E, G→ A Which one of the following options is false? (A) {CF}+ = {ACDEFG} (B) {BG}+ = {ABCDG} (C) {AF}+ = {ACDEFG} (D) {AB}+ = {ABCDG} 6.
2.
Consider a relation scheme R= (A, B, C, D, E, H) on which the following functional dependencies hold: *A→ B, BC →D, E →C, D →A+. What are the candidate keys of R? (A) AE, BE (B) AE, BE, DE (C) AEH, BEH, BCH (D) AEH, BEH, DEH
3.
A table has fields F1, F2, F3, F4, F5 with the following functional dependencies F1 → F3; F2 → F4; (F1. F2) → F5 In terms of Normalization, this table is in (A) 1 NF (C) 3 NF (B) 2 NF (D) None of these
4.
In a schema with attributes A, B, C, D and E following set of functional dependencies are given A B A C CD E B D E A Which of the following functional dependencies is NOT implied by the above set? (A) CD AC (C) BC CD (B) BD CD (D) AC BC
Consider a relation R with five attributes V, W, X, Y and Z. The following functional dependencies hold: VY → W, WX → Z, and ZY → V. which of the following is a candidate key for R? (A) VXZ (C) VWXY (B) VXY (D) VWXYZ
CS - 2007 7. Which one of the following statements is FALSE? (A) Any relation with two attributes is in BCNF. (B) A relation in which every key has only one attribute is in 2NF. (C) A prime attribute can be transitively dependent on a key in a 3NF relation. (D) A prime attribute can be transitively dependent on a key in a BCNF relation. 8.
Consider the following implications relating to functional and multivalued dependencies given below, which may or may not be correct. i) If A B and A C then A → BC ii) If A→B and A→C then A BC iii) If A BC and A →B and A → C iv) If A →BC and A B and A C Exactly how many of the above implications are valid? (A) 0 (C) 2 (B) 1 (D) 3 th
CS - 2008 9. Consider the following relational schemes for a library database: Book (Title, Author, Catalog_no, Publisher, Year, Price) Collection (Title, Author, Catalog_no) With the following functional dependencies: i) Title Author→ Catalog_no ii) Catalog_no →Title, Author, Publisher, Year iii) Publisher, Title, Year → Price Assume {Author, Title} is the key for both schemes. Which of the following statements is true? (A) Both Book and Collection are in BCNF (B) Both Book and Collection are in 3NF only (C) Book is in 2NF and Collection is in 3NF (D) Both Book and Collection are in 2NF only CS - 2011 10. Consider a relational table with a single record from each registered student with the following attributes. 1. Registration_Num: Unique registration number of each registered student 2. UID: Unique identity number, unique at the national level for each citizen 3. BankAccount_Num: Unique account number at the bank. A student can have multiple accounts or joint accounts. This attribute stores the primary account number 4. Name: Name of student 5. Hostel_Room: Room number of the hostel Which of the following options is INCORRECT? (A) BankAccount_Num is a candidate key (B) Registration_Num can be a primary key
DBMS
(C) UID is a candidate key if all students are from the same country (D) If S is a superkey such that S∩UID is NULL then S UID is also a superkey CS - 2012 11. Which of the following is TRUE? (A) Every relation in 3NF is also in BCNF (B) A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every key of R (C) Every relation in BCNF is also in 3NF (D) No relation can be in both BCNF and 3NF CS - 2013 Statement for Linked Answer Questions 12 and 13 Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values. F={CH →G, A →BC, B → CFH, E →A, F→EG+ is a set of functional dependencies (FDs) so that F is exactly the set of FDs that hold for R. 12. How many candidate keys does the relation R have? (A) 3 (C) 5 (B) 4 (D) 6 13.
The relation R is (A) In 1NF, but not in 2NF (B) In 2 NF, but not in 3 NF (C) In 3NF, but not in BCNF (D) In BCNF
CS - 2014 14. Consider the relation scheme R = (E, F, G, H, I, J, K, L, M, N) and the set of functional dependencies {*E, F+ → *G+, *F+ → *I, J+, *E, H+ → *K, L+, *K+ → *M+, *L+ → *N+} on R. What is the key for R? (A) {E, F} (C) {E, F, H, K, L} (B) {E, F, H} (D) {E}
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.
[Ans. C] 2NF, 3NF decomposition ⟶ guarantees both dependency preservation and loss less join. BCNF decomposition ⟶ Only guarantees loss less join. BCNF decomposition, at times satisfies dependency preservation and at times not. BCNF wont guarantee the dependency preservation property.
Highest normal form of Relation = Least normal form among all FD’s NF 4.
[Ans. B] Relation = R(A, B, C, D) F Set of FD’s *( ) A → B ( )A→C ( ) CD → E ( )B→D ( ) E → A+ Option (A):- CD → AC→ Correct ( )CD → E ] By transitivity ( )E → A CD → A CD → C ] ] CD → AC ( )A → C CD → A (By union rule) Option (B):- BD →CD Cannot be derived from given set of FD’s Option (C):- BC→CD can be derived (4)B→D, By Augmentation rule BC→CD Option (D):- AC→BC Can be derived ( )A→B+→By augmentation rule AC → BC
5.
[Ans. C] Relation=R(ABCDEFG) Set of FD’s F are
[Ans. D] Relation = R(A, B, C, D, E, H) Set of FD’s are 1) 2) 3) 4)
A⟶B BC⟶D E⟶C D⟶A A B C D E H AEH BEH DEH Candidate key = {AEH, BEH, DEH}
3.
[Ans. A] Table has fields Simple attributes = F1, F2, F3, F4, F5 F=set of FD’s ( )F → F ( )F → F ] ( )F , F → F
1) 2) 3) 4) 5) 6)
AB → CD AF → D DE → F C→G F→E G→A A B C D E F G →ACDEFG CF →ABCDG BG AF →ADEF →ABCDG AB As closure of AF = AF = {ADEF} Option (C) is incorrect.
Candidate key =(F1, F2)[F1+F2] Prime Attribute = {F1, F2}
Now we will assign the highest normal form to each FD 1) FD : F → F is in 1NF, since it violated NF. “F is part of key. 2) FD : F → F also violated NF, since “F ” is part of key. 3) FD : F , F , → F is in BCNF, since (F1, F2) is key
[Ans. B] Relation = R(V, W, X, Y, Z) F Set of FD’s *VY → W, WX → Z, ZY→ V+ V W X Y Z VXZ VXY Candidate key VXY [Ans. D] Statement (D) is false because in BCNF relation a prime attribute can’t be transitively dependent on a key.
10.
[Ans. A] Since students can have joint accounts, two students can have same bank account number. So, BankAccount_Num can not be candidate key.
11.
[Ans. C] A table is said to be in BCNF if it is already in 3 NF and all determinants are keys
12.
[Ans. B] Relation = R(ABCDEFGH) F Set of FD’s are
[Ans. C] In DBMS, we can see that If A ⟶⟶ B and A ⟶⟶ C then A ⟶ BC and A ⟶⟶ BC then A ⟶ B and A ⟶ C Hence answer is (C). [Ans. C] 1) Book (Title, Author, Catalog-NO, Publisher, Year, Price) FD’s on book are I. Title, Author → Catalog-NO II. Catalog-NO → Title, Author, Publisher, Year III. Publisher, Title, Year → Price Key = {Author, Title} Prime Attributes = {Author, Title} FD1: Title, Author → Catalog-NO is in BCNF. FD2: Catalog-NO → Title, Author, Publisher, Year has to be decomposed → FD . : Catalog-NO→ Title is in NF → FD . : Catalog-NO → Author is in 2NF → FD . : Catalog-NO → Publisher is in NF → FD . : Catalog-NO → Year is in 2NF FD3: Publisher, title, year→ Price is in 2NF Book is in 2NF 2) Collection (Title, Author, Catalog-NO) FD’s on collection are ( ) Title, Author → Catalog-NO Key = {Author, Title} Prime Attributes = {Author, Title} FD : Title, Author → Catalog-NO is in BCNF Collection is in BCNF [In 3NF, 2NF, 1NF also]
DBMS
1) 2) 3) 4) 5)
CH→G A→BC B→CFH E→A F→EG A B
C D E F G CH A B E F Candidate keys are *AD, BD, ED, FD+ 13.
th
H
[Ans. A] Candidate keys = {AD, BD, ED, FD} Prime attributes = {A, B, D, E, F} Let’s assign highest Normal form to each FD 1) CH → G is in NF 2) A → BC can be treated as A → B is in NF A → C is in NF,A is part of key3) B → CFH can be written as B → C is in NF B → F is in NF B → H is in NF 4) E → A is in NF, Since “A” is prime 5) F → EG can be written as F → E is in NF F → G is in NF Relation is in 1NF only.
[Ans. B] Relation = R (EFGHIJKLMN) F Set of FD’s are 1) 2) 3) 4) 5)
E EF EFH Key 15.
EF → G F → IJ EH → KL K→M L→N
DBMS
which is a single valued attribute and it is referencing the primary key (ab) of relation R (a, b, c), which is a composite key. A single value attribute cannot refer a composite key. S is false 16.
[Ans. A] S1 is true because if R(a, b) is relation and a → b is dependency then this relation is in 1NF, 2NF, 3NF and BCNF S2 is false because AB → E cannot be removed from minimal cover.
17.
[Ans. 8] Given Relation = R (E, F, G, H) Key = E Maximum no. of Super Keys = ? SNo SUPER KEYS 1 {E} 2 {E, F} 3 {E, G} 4 {E, H} 5 {E, F, G} 6 {E, G, H} 7 {E, F, H} 8 {E, F, G, H}
18.
[Ans. B] Prime Attribute = Part of some candidate key. Relation = R (ABCDEF) Candidate keys are {AB, CD} Total No of prime Attributer = 4 = {A, B, C, D}
E F G H I J K L M N EFH
[Ans. D] S1: Manager (Name, DeptID) Department (Dept Name, Deptid) In a given relation Manager DeptID is a foreign key referencing Deptid (P.K) of relation Department. Let’s declare the foreign key by an equivalent check assertion as follows:CREATE TABLE Manager (Name Varchar (10), DeptID INT (6), check (DeptID IN (select Deptid from Department)), PRIMARY KEY (Name)); The above use of check assertion is good to declare the foreign key as far as insertion is considered for relation manager (will not insert any tuple in Manager containing such DeptID value which is not present in any tuple of Department). 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
Relational Algebra & Relational Calculus CS - 2005 1. Let r be a relation instance with schema R= (A, B, C, D). We define r1=∏A,B,C(R) and r2= ∏ r Let S =r1 * r2 where * denotes natural join. Given that the decomposition of r into r1 and r2 is lossy, which one of the following is TRUE? (A) s ⊂ r (C) r ⊂ s (D) r*s=s (B) r ∪ s=r
(B) Courses in which a proper subset of female students are enrolled (C) Courses in which only male students are enrolled (D) None of the above. 5.
Consider the relation employee (name, sex, supervisorName) with name as the key. supervisorName-gives the name of the supervisor of the employee under consideration. What does the following Tuple Relational Calculus query produce? {e name|employee e ∧ ∀x [¬ employee x ∨ x. supervisorName≠e name ∨ x sex=”male”]} (A) Names of employees with a male supervisor (B) Names of employees with no immediate male subordinates (C) Names of employees with no immediate female subordinates (D) Names of employees with a female supervisor
6.
Consider a selection of the form A≤100(r), where r is a relation with 1000 tuples. Assume that the attribute values for A among the tuples are uniformly distributed in the interval [0,500]. Which one of the following options is the best estimate of the number of tuples returned by the given selection query? (A) 50 (C) 150 (B) 100 (D) 200
7.
Consider the following relation schemas: -Schema = ( -name, -city, assets) a-Schema = (a-num, -name, bal) -Schema = ( -name, a-number) Let branch, account and depositor be respective instances of the above schemas. Assume that account and
CS - 2006 2. Consider the relations r1 (P, Q, R) and r2 (R, S, T) with primary keys P and R respectively. The relation n contains 2000 tuples and r2 contains 2500 tuples. The maximum size of the join r1 r2 is (A) 2000 (C) 4500 (B) 2500 (D) 5000 3.
Which of the following relational query languages have the same expressive power? (I) Relational algebra (II) Tuple relational calculus restricted to safe expressions (III) Domain relational calculus restricted to safe expressions (A) II and III only (C) I and III only (B) I and II only (D) I, II and III
CS - 2007 4. Information about a collection of students is given by the relation studInfo (studId, name, sex). The relation enroll (studId, CourseId) gives which student has enrolled for (or taken) what course (s). Assume that every course is taken by at least one male and at least one female student. What does the following relational algebra expression represent? courseld(( studld( sex=“female”(studInfo)) courseld(enroll)) enroll) (A) Courses in which all the female students are enrolled
depositor relations are much bigger than the branch relation. Consider the following query: ∏c-name b-city= “Agra” ∧ al<0 (branch (account depositer))) Which one of the following queries is the most efficient version of the above query? (A) c-name bal< 0 b-city = “Agra” branch account) depositer) (B) c-name b- ity = “Agra” branch depositer)) bal< 0 account (C) c-name b- ity = “Agra” branch b- ity = “Agra” ∧ al< 0 account depositer) (D) c-name b- ity = “Agra branch b- ity = “Agra” ∧ al< 0 account depositer)) CS - 2008 8. Let R and S be two relations with the following schema R(P,Q,R1, R2, R3) S(P,Q ,S1, S2) Where {P,Q} is the key for both schemas. Which of the following queries are equivalent? I. R S II. R (S) III. R ∩ (S)) P( IV. (R) ( P,Q (R) (S))) P( (A) Only I and II (B) Only I and III (C) Only I, II and III (D) Only I, III and IV CS - 2009 9. Let R and S be relational schemes such that R={a, b, c} and S={c}. Now consider the following queries on the database: I. πR-S (r) πR-S πR-S(r) × s πR-S,S (r)) II. {t|t ϵ πR-S (r) ∧ ∀uϵs ∃vϵr (u = v[s] ∧ t = v [R S]))} III. {t|t ϵ πR-S (r) ∧ ∀vϵr ∃uϵs (u = v[s] ∧ t = v [R S]))}
DBMS
IV.
Select R.a, R.b from R, S Where R.c = S.c Which of the above queries equivalent? (A) I and II (C) II and IV (B) I and III (D) III and IV
are
CS - 2010 10. The following functional dependencies hold for relations R(A, B, C) and S(B, D, E): B A, A C The relation R contains 200 tuples and the relation S contains 100 tuples. What is the maximum number of tuples possible in the natural join R S? (A) 100 (C) 300 (B) 200 (D) 2000 CS - 2011 11. Consider a relational table r with sufficient number of records, having attributes A1, A2…… An an let 1 ≤ p ≤ n Two queries Q1 and Q2 are given below. Q1: π …… ( where c is a ) constant Q2: π ……
(
)
where
and
are constants. The database can be configured to do ordered indexing on A or hashing on A . Which of the following statements is TRUE? (A) Ordered indexing will always outperform hashing for both queries (B) Hashing will always outperform ordered indexing for both queries (C) Hashing outperform ordered indexing on Q1, but not on Q2 (D) Hashing will outperform ordered indexing on Q2, but not on Q1 CS - 2012 12. Suppose R (A,B) and R (C,D) are two relation schemas. Let r and r be the corresponding relation instances. B is a th
foreign key that refers to C in R . If data in r and r satisfy referential integrity constraints. Which of the following is ALWAYS TRUE? (A) r r = (B) r r = (C) r = r (D) r r ≠ CS - 2013 13. Consider the following relational schema. Students (roll no: integer, sname: string) Courses (course no: integer, cname: string) Registration (rollno: integer, courseno: integer, percent: real) Which of the following queries are equivalent to this query in English? “Fin the istin t names of all stu ents who score more than 90% in the course num ere 107” (I) SELECT DISTINCT S.sname FROM Student as S, Registration as R WHERE R.rollno=S.rollno AND R.courseno=107 AND R. percent>90 (II) ∧ Registration Stu ent (III) {T|∃S stu ents ∃R Regitration S rollno = R rollno ∧ R.courseno =107∧R per ent>90∧T sname =S.sname)} (IV) {< S > |∃S ∃R < S S > Stu ents ∧< S 107 R > Registration ∧ R > 90 } (A) I, II, III and IV (B) I, II and III only (C) I, II and IV only (D) II, III and IV only
DBMS
size(r(R))
What is the optimized version of the relation algebra expression π
(π
(
(
r ))) where A1, A2
are sets of attri utes in r with A1 ⊂ A2 and F1, F2 are Boolean expressions based on the attributes in r? (A) π r (B) π r ∨ (C) π r (D) π r ∨ 16.
Consider the relational schema given below, where eId of the relation dependent is a foreign key referring to empId of the relation employee. Assume that every employee has at least one associated dependent in the dependent relation. employee (empId, empName, empAge) dependent(depId, eId, depName, depAge) Consider the following relational algebra query: ∏ ∏
employee employee
∧
epen ent
The above query evaluates to the set of empIds of employees whose age is greater than that of (A) some dependent. (B) all dependents. (C) some of his/her dependents. (D) all of his/her dependents.
CS - 2014 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
[Ans. C] Relation =R(A, B, C, D) r = R r = r As e omposition of “R” into “r and r ” is LOSSY ⇒ Spurious tuples will e generate s = r ∗ r Natural Join] Will get “r” + spurious tuples ⇒ “r” is a proper su set of “s” [r ⊂ s]
1 2
4 stu info 3
enroll
1
2
enroll
Selects only girls students Assumes that all girl students joined in all courses It selects the course ID in which only a proper subset of girl students are enrolled.
[Ans. A] It consider only pairs of tuples that have the same value on R.
Stu i 1 stu info = 2 3
Step: 1
[Ans. D] All given relational query language have the same expressive power. [Ans. B] Every Course Must e taken y at least one male and at least one female student. Let us assume there are only 2 courses {MCA, MBA} MCA Course opte y all girls + 1-boy [3girls + 1-boy] MBA Course opted by 2 girls + 1-boy [2girls + 1-boy] Let total no of students = 5, where 3 girls 2-boys. {A, B, C} girls {D, E} Boys Student info Enroll Stud Name sex Stud Course id id id 1 A F 1 MCA 2 B F 2 MCA 3 C F 3 MCA 4 D M 4 MCA 5 E M 1 MBA 2 MBA 5 MBA
3
4
Step: 2 stu info enroll = Stud ID Course ID 1 MCA × 1 MBA × 2 MCA × 2 MBA × 3 MCA × 3 MBA Step: 3 Step(2) enroll = Stud ID Course ID 3 MBA Step: 4 (step.3)=MBA, course in whi h “proper su set of female stu ents are enrolled”. 5.
th
[Ans. C] employee (name, sex, supervisor name) Foreign key {e. name|Employee e ˄ ∀x [ employee (x) ˅ x. supervisor name # e. name ˅ x. sex= “Male”]} we are using 2 tuple variables e free tuple varia le referring employee x Bounded tuple variable referring all the 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
Formulae will be true if all subordinates of an employee are males. Employee Name Sex Supervisor Name a M x M a y M a z M a b M u F b v M b 1) If e name = a then x ={x y z} “a” will e selected, since all his subordinates are Males. 2) If e name = then x={u v} “ ” will not be selected, since all his subordinates are NOT Males. ⇒ Query returns the names of employees with no immediate female subordinates. 6.
7.
[Ans. D] Given: There are 100 tuples These are uniformly distributed, in the interval [0,500] So for values A≤100 There will e 200 tuples returned by the given selected query.
R P 1 2 4
(1)
R
S =
R
Q a c d
3 rows created Row:1 P&Q are same Row:2 Only P same Row:3 Only Q same P Q 1 a
P = 1
P
P
P
1
1
= 1
2
2
2
S =
3
(
R ∩
s )=
4
(
R
(
P Q 1 a
P = 1
R
P Q 1 a
P = 1
S ))
⇒ Queries (1),(3) and (4) are equivalent, because they all are operating on complete key (PQ). Where are Query (2) considering only part of key (P), hence it is different. 9.
[Ans. C] II and IV are equivalent.
10.
[Ans. A] R (A, B, C) and S (B, D, E) F= Set of FD’s = {B A A ⇒ “B” is the key for R A B R A B C =200rows B Key = B Parent table = R Parent column =B
∧
8.
Q a b d
=
( ran h a ount epsitor ) Most efficient version of this query.
a ount
S
P 1 2 3
2
[Ans. B] b - Schema = (b-name, b-city, assets) a - Schema = (a-num, b-name, bal) d - Schema = (c-name, a-number)
(
DBMS
C} C S D E
=100rows
Child table = S Child column = B
Max rows of R S = Max always from the child table only. = 100 rows 100 rows 200 rows Employee Dept eno ename dno dno dname 1 D1 D1 2 D1 D2 : : 100 D20 D200 Child table = Primary key = Employee foreign dno key = dno parent table = Dept
ran h epositor )
[Ans. D] R (P, Q, R1, R2, R3) S (P, Q, S1, S2) Key= P+Q for oth ta les omposite key Let us consider the following instances:-
⇒ Emp Dept ⇒ Maximum rows = All Employee = 100 rows. ⇒ Maximum rows of natural join = Total no. of rows from child table. 11.
[Ans. C] If records are accessed for a particular value from table, hashing will do better. If records are accessed in a range of values, ordered indexing will perform better.
12.
[Ans. A] R AB R CD B is a foreign key & referring to C & C is a candidate key. So, r r =
13.
[Ans. A] Find the distinct names of all students who score more than 90% in the course no. 107 1. SQL query Condition would give all s.name having score > 90 and attending course no. 107 and DISTINCT S.sname will give distinct student names TRUE 2. Relational algebra gives projection of all students meeting the on ition an ‘ ’ gives DISTINCT value TRUE 3. Tuple calculus gives DISTINCT student name having score > 90 and course no is 107 TRUE 4. Domain calculus Domain calculus is equivalent to relational algebra and provide distinct value for the query TRUE
14.
DBMS
Let r(A,B,C) = 30,000 rows 25 rows fit in 1-block Total Blocks required for “r” = 1200 lo ks S(C,D,E) = 60,000 rows 30 rows fit in 1block Total Blocks reqd for “s” =2000 lo ks If' “r” is use as the outer relation:“r” requires 30000/25 = 1200 lo ks of storage and s requires (60000/30) = 2000 blocks of storage. The formula for number of block accesses is (nr bs + br) i.e. 30000 2000+1200 = 60,001,200 disk accesses are required for a nested loop join. If “s” is use as the outer relation:The formula for number of block accesses is (ns br + bs) i.e. 60000 × 1200+2000 = 72,002,000. So the numbers of block accesses are less if “r” is use outsi e 15.
[Ans. A] π
(π
(
=π π
∧
(π
=π 16.
(
(
r )))
r (
( ∧
r )))
r )
[Ans. D] Every employee has at least one dependent. EMPLOYEE empId empName empAge 1 A 50 2 B 60 3 C 70 DEPENDENT depId eId depName depAge D1 1 X 30 D2 1 Y 40 D3 2 Z 50 D4 2 U 80 D5 3 V 90 D6 3 W 100 Empi =1 An employee having 2 younger dependents [empAge > depAge]
[Ans. A] As Size(r(R)) < Size (s(S)), let us consider the following illustration Consider these relations with the following properties: th
SQL CS - 2005 1. The relation book (title, price) contains the titles and prices of different books. Assuming that no two books have the same price, what does the following SQL query list? select title from book as B where (select count (*) from book as T where T.price>B. Price) < 5 (A) Titles of the four most expensive books (B) Title of the fifth most inexpensive book (C) Title of the fifth most expensive book (D) Titles of the five most expensive books 2.
(A) (B) (C) (D) 3.
Do not supply any item Supply exactly one item Supply one or more items Supply two or more items
A table ‘student’ with schema (roll, name, hostel, marks) and another table ‘hobby‘ with schema (roll, hobbyname) contains records as shown below. Table student Roll Name Hostel Marks 1798 Manoj Rathod 7 95 2154 Soumic Banerjee 5 68 2369 Gumma Reddy 7 86 2581 Pradeep Pendse 6 92 2643 Suhas Kulkarni 5 78 2711 Nitin Kadam 8 72 2872 Kiran Vora 5 92 2926 Manoj Kunkalikar 5 94 2959 Hemant Karkhanis 7 88 3125 Rajesh Doshi 5 82
In an inventory management system implemented at a trading corporation, there are several tables designed to hold all the information. Amongst these, the following two tables hold information on which items are supplied by which suppliers, and which warehouse keeps which items along with the stock-level of these items. Supply = (supplierid, itemcode) Inventory = (itemcode, warehouse, stocklevel) For a specific information required by the management, following SQL query has been written. Select distinct STMP supplierid From supply as STMP Where not unique (Select ITMP. supplierid From Inventory, Supply as ITMP Where STMP.supplierid= ITMP. supplierid and ITMP.itemcode= Inventory. itemcode and Inventory. warehouse = ‘Nagpur‘); For the warehouse at Nagpur, this query will find all suppliers who
Table hobby Roll Hobby name 1798 chess 1798 music 2154 music 2369 swimming 2581 cricket 2643 chess 2643 hockey 2711 volleyball 2872 football 2926 cricket 2959 photography 3125 music 3125 chess The following SQL query is executed on the above tables: select hostel from student natural join hobby where marks > = 75 and roll between 2000 and 3000;
Relations S and H with the same schema as those of these two tables respectively contain the same information as tuples. A new relation S is obtained by the following relational algebra operation: S = ( . . (S)) (H)) ( The difference between the number of rows output by the SQL statement and the number of tuples in S is (A) 6 (C) 2 (B) 4 (D) 0
DBMS
in decreasing balance order and assigning ranks using ODBC Which two of the above statements are correct? (A) 2 and 5 (C) 1 and 4 (B) 1 and 3 (D) 3 and 5 5.
Consider the relation enrolled (student, course) in which (student, course) is the primary key, and the relation paid (student, amount) where student is the primary key. Assume no null values and no foreign keys or integrity constraints. Given the following four queries: Query 1: Select student from enrolled where student in (Select student from paid) Query 2: Select student from paid where student in (Select student from enrolled) Query 3: Select E. student from enrolled E, paid P where E. student = P. student Query 4: Select student from paid where exists (select * from enrolled where enrolled. student = paid. student) Which one of the following statements is correct? (A) All queries return identical row sets for any database (B) Query 2 and Query 4 return identical row sets for all databases but there exist databases for which Query 1 and Query 2 return different row sets (C) There exist databases for which Query 3 returns strictly fewer rows than Query 2 (D) There exist databases for which Query 4 will encounter an integrity violation at runtime.
CS - 2006 4. Consider the relation account (customer, balance) where customer is a primary key and there are no null values. We would like to rank customers according to decreasing balance. The customer with the largest balance gets rank 1. Ties are not broken but ranks are skipped: if exactly two customers have the largest balance they each get rank 1 and rank 2 is not assigned. Query 1: Select A. customer, count (B. customer) from account A, account B where A. balance < = B. balance group by A. customer Query 2: Select A. customer, 1+ count (B. customer) from account A, account B where A. balance< B. balance group by A. customer Consider these statements about Query 1 and Query 2. 1. Query 1 will produce the same row set as Query 2 for some but not all databases. 2. Both Query 1 and Query 2 are correct implementations of the specification 3. Query 1 is a correct implementation of the specification but Query 2 is not 4. Neither Query 1 nor Query 2 is a correct implementation of the specification 5. Assigning rank with a pure relational query takes less time than scanning
Statement for Linked Answer Questions 6 and 7 Consider a database with three relation instances shown below. The primary keys for the Drivers and Cars relations are did and cid respectively and the records are stored in ascending order of these th
primary keys as given in the tables. No indexing is available in the database. D: Drivers relation did dname rating age 22 Karthikeyan 7 25 29 Salman 1 33 31 Boris 8 55 32 Amoldt 8 25 58 Schumacher 10 35 64 Sachin 7 35 71 Senna 10 16 74 Sachin 9 35 85 Rahul 3 25 95 Ralph 3 53 R : Reserves relation did cid day 22 101 10/10/06 22 102 10/10/06 22 103 08/10/06 22 104 07/10/06 31 102 10/11/06 31 103 06/11/06 31 104 12/11/06 64 101 05/09/06 64 102 08/09/06 74 103 08/09/06 C : Cars relation cid cname colour 101 Renault blue 102 Renault red 103 Ferrari green 104 Jaguar red 6.
What is the output of the following SQL query? Select D.dname from Drivers D where D.did in (select R. did from Cars C, Reserves R where R. cid = C.cid and C. color = ‘red’ intersect select R. did from Cars C, Reserves R where R. cid = C.cid and
Let n be the number of comparisons performed when the above SQL query is optimally executed. If linear search is used to locate a tuple in a relation using primary key, then n lies in the range (A) 36 40 (C) 60 64 (B) 44 48 (D) 100 – 104
CS - 2007 8. Consider the table employee (empId, name, department, salary) and the two queries Q1, Q2 below. Assuming that department 5 has more than one employee, and we want to find the employees who get higher salary than anyone in the department 5, which one of the statements is TRUE for any arbitrary employee table? Q1: Select e.empId From employee e Where not exists (Select * From employee s Where s.department = “5” and s.salary>=e.salary) Q2: Select e. empId From employee e Where e. salary > Any (Select distinct salary From employee s Where s.department = “5”) (A) Q1 is the correct query. (B) Q2 is the correct query. (C) Both Q1 and Q2 produce the same answer (D) Neither Q1 nor Q2 is the correct query CS - 2008 Common Data for Questions 9 &10 Consider the following relational schema: Student (school-id, sch-roll-no, sname, saddress) th
School (school-id, sch-name, sch-address, sch-phone) Enrolment (school-id, sch-roll-no, erollno, exam name) Exam Result (erollno, exam name, marks) 9.
10.
What does the following SQL query output? SELECT sch - name, COUNT (*) FROM School C, Enrolment E, Exam Result R WHERE E. school – id = C.school-id AND E. exam name = R. exam name AND E. Erollno = R.erollno AND R.marks = 100 AND S.school-id IN (SELECT school-id FROM student GROUP BY school-id HAVING COUNT (*) > 200) GROUP BY school-id (A) For each school with more than 200 students appearing in exams, the name of the school and the number of 100s scored by its students (B) For each school with more than 200 students in it, the name of the school and the number of 100s scored by its students (C) For each school with more than 200 students in it, the name of the school and the number of its students scoring 100 in at least one exam (D) Nothing; the query has a syntax error Consider the following tuple relational calculus query. {t | E Enrolment t= E. school – id | {x x Enrolment x. school – id = t ( B ExamResult . erollno = x. erollno B. exam name = x. exam name . marks 35)+ | {x | x Enrolment x. school-id = t+ 100> 35}
DBMS
If a student needs to score more than 35 marks to pass an exam, what does the query return? (A) The empty set (B) Schools with more than 35% of its students enrolled in some exam or the other (C) Schools with a pass percentage above 35% over all exams taken together (D) Schools with a pass percentage above 35% over each exam CS - 2009 Common data for Questions 11 and 12 Consider the following relational schema: Suppliers (sid: integer, sname: string, city:string, street: string) Parts (pid:integer, pname: string, color:string) Catalog (sid:integer, pid:integer, cost: real) 11. Consider the following relational query on the above database: SELECT S.sname FROM Suppliers S WHERE S.sid NOT IN (SELECT C. sid FROM Catalog C WHERE C.pid NOT IN (SELECT P.pid FROM Parts P WHERE P.color<> ‘blue’)) Assume that relations corresponding to the above schema are not empty. Which one of the following is the correct interpretation of the above query? (A) Find the names of all suppliers who have supplied a non-blue part (B) Find the names of all suppliers who have not supplied a non-blue part (C) Find the names of all suppliers who have supplied only blue parts (D) Find the names of all suppliers who have not supplied only blue part 12.
th
Assume that, in the suppliers relation above, each supplier and each street within a city has a unique name, and th
(sname, city) forms a candidate key. No other functional dependencies are implied other than those implied by primary and candidate keys. Which one of the following is TRUE about the above schema? (A) The schema is in BCNF (B) The schema is in 3NF but not in BCNF (C) The schema is in 2NF but not in 3 NF (D) The schema is not in 2NF CS - 2010 13. A relational schema for a train reservation database is given below. Passenger (pid, pname, age) Reservation (pid, class, tid) Table: Passenger pid pname Age 0 ‘Sachin’ 65 1 ‘Rahul’ 66 2 ‘Sourav’ 67 3 ‘Anil’ 69 Table: Reservation pid class tid 0 ‘AC’ 8200 1 AC’ 8201 2 ‘SC’ 8201 5 ‘AC’ 8203 1 ‘SC’ 8204 3 ‘AC’ 8202 What pids are returned by the following SQL query for the above instance of the tables? SELECT pid FROM Reservation WHERE class = ‘AC’ AND EXISTS (SELECT * FROM Passenger WHERE age > 65 AND Passenger.pid = Reservation.pid) (A) 1, 0 (C) 1, 3 (B) 1, 2 (D) 1, 5
DBMS
CS - 2011 14. Database table by name Loan_Records is given below. Borrower Bank_ Loan_ Manager Amount Ramesh Sunderajan 10000.00 Suresh Ramgopal 5000.00 Mahesh Sunderajan 7000.00 What is the output of the following SQL query? SELECT count(*) FROM (SELECT Borrower, Bank_Manager FROM Loan_Records) AS S NATURAL JOIN (SELECT Bank_Manager, Loan_Amount FROM Loan_Records) AS T); (A) 3 (C) 5 (B) 9 (D) 6 15.
Consider a database table T containing two columns X and Y each of type integer. After the creation of the table, one record (X = 1, Y = l) is inserted in the table. Let MX and MY denote the respective maximum values of X and Y among all records in the table at any point in time. Using MX and MY, new records are inserted in the table 128 times with X and Y values being MX +1, 2*MY + 1 respectively. It may be noted that each time after the insertion, values of MX and MY change. What will be the output of the following SQL query after the steps mentioned above are carried out? SELECT Y FROM T WHERE X=7; (A) 127 (C) 129 (B) 255 (D) 257
CS - 2012 16. Which of the following statements are TRUE about an SQL query? P: An SQL query can contain a HAVING clause even if it does not a GROUP BY clause
Q: An SQL query can contain a HAVING clause only if it has a GROUP BY clause R: All attributes used in the GROUP BY clause must appear in the SELECT clause S: Not all attributes used in the GROUP BY clause need to apper in the SELECT clause (A) P and R (C) Q and R (B) P and S (D) Q and S
departments(dept-id, dept-name, manager-id, location-id) You want to display the last names and hire dates of all latest hires in their respective departments in the location ID 1700. You issue the following query: SQL>SELECT last-name, hire-date FROM employees WHERE (dept-id, hire-date) IN (SELECT dept-id, MAX(hire-date) FROM employees JOIN departments USING(dept-id) WHERE location-id = 1700 GROUP BY dept-id); What is the outcome? (A) It executes but does not give the correct result. (B) It executes and gives the correct result. (C) It generates an error because of pairwise comparison. (D) It generates an error because the GROUP BY clause cannot be used with table joins in a sub- query.
Common Data for Questions 17 and 18 Consider the following relation A, B & C. A. Id Name Age 12 Arun 60 15 Shreya 24 99 Rohit 11 B.
Id 15 25 98 99
Name Shreya Hari Rohit Rohit
Age 24 40 20 11
C.
Id 10 99
Phone 2200 2100
Area 02 01
17.
How many tuples does the result of the following relational algebra expression contain? Assume that the schema of A∪ is the same as that of A. (A∪ ) . C . (A) 7 (C) 5 (B) 4 (D) 9
18.
How many tuples does the result of the following SQL query contains? SELECT A.Id FROM A WHERE A.Age>All (SELECT B.Age FROM B WHERE . name = ‘Arun’) (A) 4 (C) 0 (B) 3 (D) 1
DBMS
20.
SQL allows duplicate tuples in relations, and correspondingly defines the multiplicity of tuples in the result of joins. Which one of the following queries always gives the same answer as the nested query shown below: select * from R where a in (select S.a from S) (A) Select R.* from R, S where R.a=S.a (B) Select distinct R.* from R,S where R.a=S.a (C) Select R.* from R,(select distinct a from S) as S1 where R.a=S1.a (D) Select R.* from R,S where R.a=S.a and is unique R
21.
Consider the following relational schema: employee(empId,empName,empDept) customer(custId,custName,salesRepId, rating) salesRepId is a foreign key referring to empId of the employee relation. Assume
CS - 2014 19. Given the following schema: employees (emp-id, first-name, last-name, hire-date, dept-id, salary)
Given an instance of the STUDENTS relation as shown below: CPI
22.
Student ID
that each employee makes a sale to at least one customer. What does the following query return? SELECT empName FROM employee E WHERE NOT EXISTS (SELECT custId FROM customer C WHERE C.salesRepId = E.empId AND C.rating< ’GOOD’); (A) Names of all the employees with at least one of their customers having a ‘GOOD’ rating. (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 ‘GOOD’ rating. (D) Names of all the employees with all their customers having a ‘GOOD’ rating.
DBMS
For (StudentName, StudentAge) to be a key for this instance, the value X should NOT be equal to ________
[Ans. D] No two books will have same price. Let us consider the table as follows:TITLE PRICE T1 100 T2 200 T3 300 T4 400 T5 500 T6 600 As the given Query is a “Correlated Sub Query, Outer Query executes first and Inner Query executes second and executes once for each row written by the outer query. SELECT title From book as B
Final Result → Rows from the Outer Query where Condition is Satisfied. TITLE T1 T2 T3 Query returns the titles T4 Of 5 most expensive books T5 T6 2.
TITLE T1 T2 T3 T4 T5 T6 WHERE (SELECT count(*) FROM book as T WHERE T.price > B.price)<5
INNER QUERY SELECT count (*) FROM book as T WHERE T.price > 100;=5 SELECT count (*) FROM book as T WHERE T.price > 200;=4 SELECT count (*) FROM book as T WHERE T.price > 300;=3 SELECT count (*) FROM book as T WHERE T.price > 400;=2 SELECT count (*) FROM book as T WHERE T.price > 500;=1 SELECT count (*) FROM book as T WHERE T.price > 600;=0
<5 <5
Item Code I1 I2 I3 I4 I5 I6
Result Not Qualified
<5
Qualified
<5
Qualified
<5
Qualified
<5
Qualified
<5
Qualified
INVENTORY Ware house Nagpur Nagpur Nagpur Nagpur Nagpur Nagpur
Stock level
S1 → Supplier has 3-items [I1, I2, I3,] at Nagpur Warehouse S2 → Supplier has 2-items [I4,I5] at Nagpur Warehouse S3 → Supplier has 1-item [I6] at Nagpur Warehouse SELECT distinct STMP. supplierid FROM supply as STMP TITLE S1 S2 S3
WHERE NOT UNIQUE (SELECT ITMP. supplierid FROM inventory, supply as ITMP WHERE ITMP. supplierid = STMP. supplierid AND ITMP. itemcode = Inventory. itemcode AND inventory. warehouse = ‘Nagpur’),
INNER QUERY
OUT PUT
NOT UNIQUE
Query: 2 S = ( . . (S)) (H)) ( → returns only DISTINCT rows = 3 rows {7, 6, 5} Final Answer = Difference in no. of rows = 4 – rows 4.
SELECT ITMP.supplierid 3-rows Qualified FROM Inventory,supply as ITMP {I1, I2,I3} WHERE ITMP.supplierid = S1 AND ITMP.itemcode = Inventory.itemcode AND inventory.warehouse =‘Nagpur’; SELECT ITMP.supplierid 2-rows FROM Inventory, supply as ITMP{I4, I5} WHERE ITMP.supplierid = S2 AND ITMP.itemcode = Inventory.itemcode AND Inventory.warehouse =‘Nagpur’; SELECT ITMP.supplierid 1-row FROM Inventory,supply as ITMP {I6} WHER ITMP.supplierid = S3 AND ITMP.itemcode = Inventory.itemcode AND Inventory.warehouse = ‘Nagpur’;
Final Result = *S1, S2+ suppliers are selected → Suppliers supplying 2(or) more items 3.
[Ans. B] Student Natural Join Hobby WHERE Marks> =75 AND roll BETWEEN 2000 AND 3000 Roll Name Hostel Marks Habby Name 2369 Gumma Reddy 7 86 Swimming 2581 Pradeep Pendse 6 92 Cricket 2643 Suhas Kulkarni 5 78 Chess 2643 Suhas Kulkarni 5 78 Hockey 2872 Kiran Vora 5 92 Football 2926 Manoj 5 94 Cricket Kunkalikar 2959 Hemant 7 88 Photography Karkhanis 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+
Output of Query 2 Customer Count (B. Customer) 1 3 2 1 3 3 4 2 If there are no duplicates of balance then they produce same row set else not (See table above). Both are not producing desired output.
When R.cid = c.cid and c.colour = ‘Red’ Table - 2 did cid day 22 102 10/10/06 22 104 07/10/06 31 102 10/11/06 31 104 12/11/06 64 102 08/09/06 Table 1 Table 2 gives 2 values of did = 22 and 31 ∴ With these values in driver relation gives KarthiKeyan and Boris.
Query 1:- SELECT student FROM enrolled WHERE student in (SELECT student FROM Paid) → returns 2 rows *1, 1+ Query 2:- SELECT Student FROM Paid WHERE student in (SELECT Student FROM enrolled) → returns 1 rows *1+
7.
[Ans. C] Counting the number of comparisions leads to approximately 62.
8.
[Ans. B] EMPLOYEE Empid Name Dept Salary 1 A 5 1000 2 B 5 2000 3 C 4 3000 4 D 4 1500 5 E 4 500 We want to find employees who get higher salary than anyone in the department “5” Correct Output for the above query on the given data would be employees {2, 3, 4} Q1:- SELECT e. empId FROM employee e WHERE not exists (SELECT * FROM employee s WHERE s.department=5 and s.salary >=e.salary); → returns rows *2, 3+
Query 3:- SELECT e.student FROM enrolled e, paid p WHERE e.student = p. student, → returns 2 rows *1, 1+ Query4:- SELECT FROM WHERE
student paid EXISTS (SELECT * FROM enrolled WHERE enrolled. student = paid. student), → returns 1 rows *1+ Final Result = Query 2 and Query 4 returns identical row sets for all databases, but there exist database for which Query 1 and Query 2 return different row sets on the relations. 6.
DBMS
[Ans. A] 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
[Ans. *](Answer is not matching with IIT keys) SUPPLIERS Sid Sname City Street S1 A S2 B S3 C
SELECT * FROM 1 row Not employee s Qualified WHERE s. department =5 and s.salary>=1000; SELECT * FROM No rows Qualified employee s WHERE s. department =5 and s.salary>=2000; SELECT * FROM No rows Qualified employee s WHERE s.department =5 and s.salary >=3000; SELECT * FROM 1 row Not employee s Qualified WHERE s. department=5 and s.salary >=1500; SELECT * FROM 2 rows Not employee s Qualified WHERE s. department=5 and s.salary >=500;
2
3
4
5
Q2:-
Sid S1 S1 S2 S2 S3 S3
10.
SELECT FROM WHERE
[Ans. D] If SELECT clause consists aggregate and non – aggregate. All non-aggregate columns in the SELECT list must appear in Group by clause. But in this query Group by consists school_id instead of sch_name [Ans. C] Here, we used division operator. Numerator produces all who scores more than 35 marks, denominator checks all exams. Hence it produces pass percentage above 35% over all exams taken together.
PARTS Pname Color Blue Blue Blue Green Green Green
Pid P1 P2 P3 P4 P5 P6
e. empId employee E e.salary > ANY (SELECT distinct salary FROM employee s WHERE s.department=5); → returns *2, 3, 4+ employees Final Answer = Only Q2 is giving the correct result
9.
DBMS
CATALOG Pid Cost P1 P2 P3 P4 P5 P6
S1 → Supplier supplying only lue parts, [P1, P2] S2 → Supplier supplying both Blue & Green parts. [P3, P4] S3 → Supplier supplying only Green parts, [P5, P6] Initial Query SELECT S.sname FROM Suppliers S WHERE S.sid NOT IN (SELECT C.sid FROM Catalog C WHERE C.pid NOT IN (SELECT P.pid FROM Parts P WHERE P.colour< ‘blue’)); After execution of second inner query: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}
After execution of first inner query:SELECT S.sname FROM Suppliers S WHERE S.sid NOT IN(S1, S1, S2); Final Answer = Names of Suppliers who supplies Only non-blue parts 12.
[Ans. B] pid is a primary key, sname and city are candidate keys. Hence all are prime attributes and there is a relationship between prime attributes hence it is not in BCNF but in 3 NF
13.
[Ans. C] In the given SQL query, we have to select the pid in which the value of class filed is ‘AC’. In the reservation table and age> 65 and the value of passenger.pid= reservation.pid So according to SQL Query In this WHERE class = ‘AC’ So it select the pid = 0, 1, 5, 3 and for SELECT *FROM passenger where age>65 and Passenger.pid = reservation.pid from passenger table we get the Pid Pname Age 1 Rahul 66 2 Sourav 67 3 Anil 69
S Natural Join T Borrower Bank Manager Loan Amount Ramesh Sunderajan 10000.00 Ramesh Sunderajan 7000.00 Suresh Ramgopal 5000.00 Ramesh Sunderajan 10000.00 Ramesh Sunderajan 7000.00 Query :SELECT Count(*) FROM ((SELECT Borrower, Bank_Manager FROM Loan_Records ) AS S NATURAL JOIN (SELECT Bank_Manger Loan_Amount FROM Loan_Records) AS T); → Returns count =5 15.
16.
[Ans. C] Borrower Ramesh Suresh Mahesh
S Bank_Manager Sunderajan Ramgopal Sunderajan T
Bank_Manager Sunderajan Ramgopal Sunderajan
[Ans. A] The entries inserted in order are X 1 2 3 4 5 6 7 Y 1 3 7 15 31 63 127 One can also solve the recursion and find out that Y = 2X— 1
1 AC 3 AC So the pid return from given query is(1, 3) 14.
DBMS
Loan_Amount 10000.00 5000.00 7000.00 th
[Ans. C] P: An SQL query can contain a HAVING clause even if it does not have a GROUT BY clause SELECT avg(salary) FROM emp HAVING avg(salary) 1000; → Valid SQL Statement, “P” is TRUE Q: An SQL query can contain a HAVING clause only if it has a GROUP BY clause → FALSE R: All attributes used in the GROUP BY clause must appear in the SELECT clause SELECT avg(salary), min(salary), max(salary) FROM emp GROUP BY deptno,gender; → VALID SQL Statement, “R” is FALSE. S: Not all attributes used in the GROUP BY clause need to appear in SELECT clause → TRUE
Name Arun Shreya Rohit Hari Rohit C ID 10 10 10 10 10 99 99
Option: (B) SELECT DISTINCT R.* FROM R, S WHERE R.a = S.a Option: (C) SELECT R.* FROM R,(SELECT DISTINCT a FROM S) AS S1 WHERE R.a = S1.a Option: (D) SELECT R.* FROM R,S WHERE R.a = S.a AND UNIQUE R Given Option Option Option Query (A) (B) (C) A a a a 1 1 1 1 1 1 2 1 2 1 2 2 1 2 2 2 2 2 Option (D) Error: ORA – 00936: missing expression Only option (C) is given the same output as the given Query
Age 60 24 11 40 20
Phone 2200 2200 2200 2200 2200 2100 2100
Area 02 02 02 02 02 01 01
[Ans. B] In this (Select B. Age from B where B. Name = ‘Arun’) ⇓ Φ So all A.Age will be selected, so Ans 3.
19.
[Ans. B] Inner query will have a join between employee and departments and will return dept – id and hire – date of employees who are having location 1700 and latest line – date (in sorted order)
20.
[Ans. C] Will prove by taking the following illustration with relation “R” and “S” as follows: R S a a 1 1 1 1 2 2 2 2 Given Query:-SELECT * FROM R WHERE a IN (SELECT S.a FROM S) Option: (A) SELECT R.* FROM R,S WHERE R.a = S.a
DBMS
21.
[Ans. D] SalesRepId is a foreign key referring to empId of the employee relation. Assume that each employee makes a sale to at least one customer. EMPLOYEE empId empName empDept 1 A 2 B 3 C CUSTOMER custId custName salesRepId rating C1 1 GOOD C2 1 GOOD C3 2 GOOD C4 2 BAD C5 3 BAD C6 3 BAD empId = 1 → Employee with all their customers [C1, C2] having GOOD rating empId = 2 → Employee with one customer having GOOD [C3] and other having BAD [C4]
empId = 3 → Employee with all their customer [C5, C6] having BAD rating Query:SELET empName FROM employee E WHERE NOT EXISTS (SELECT FROM WHERE AND e.emp Id 1
2
3
custId customer C C.salesRepId= E.empID C.rating < ‘GOOD’);
INNER QUERY SELECT custId FROM customer C WHERE C.salesRepId = 1 AND C.rating < ’GOOD’; SELECT custId FROM customer C WHERE C.salesRepId =2 AND C.rating < ’GOOD” SELECT custId FROM customer C WHERE C.salesRepId =3 AND C.rating< ‘GOOD’;
OUT NOT PUT EXISTS No Qualified rows
1 Not row Qualified
2 Not rows Qualified
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]
Transactions and Concurrency Control CS – 2005 1. A company maintains records of sales made by its salespersons and pays them commission based on each individual’s total sales made in a year. This data is maintained in a table with following schema: salesinfo = (salespersonid, totalsales, commission) In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission paid to them as per the following formula. If commission < = 50000, enhance it by 2% If 50000 < commission < = 100000, enhance it by 4% If commission > 100000, enhance it by 6% The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a separate transaction as follows: T1 Update salesinfo Set commission = commission * 1.02 Where commission < = 50000; T2 Update salesinfo Set commission = commission * 1.04 Where commission > 50000 and commission is < =100000; T3 Update salesinfo Set commission = commission * 1.06 Where commission > 100000; Which of the following options of running these transactions will update the commission of all salespersons correctly? (A) Execute T1, followed by T2 followed by T3 (B) Execute T2, followed by T3; T1 running concurrently throughout (C) Execute T3, followed by T2; T1 running concurrently throughout (D) Execute T3, followed by T2 followed by T1 2.
Amongst the ACID properties of a transaction, the ‘Durability‘ property requires that the changes made to the database by a successful transaction persist
(A) Except in case of an Operating System crash (B) Except in case of Disk crash (C) Except in case of a power failure (D) Always, even if there is a failure of any kind CS - 2006 3. Consider the following log sequence of two transactions on a bank account, with initial balance 12000, that transfer 2000 to a mortgage payment and, then apply a 5% interest. 1. T1: start 2. T1: B old= 12000, new=10000 3. T1: M old = 0, new = 2000 4. T1: commit 5. T2: start 6. T2: B old=10000, new = 10500 7. T2: commit Suppose the database system crashed just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure? (A) We must redo log record 6 to set B to 10500 (B) We must undo log record 6 to set B to 10000 and then redo log records 2 and 3 (C) We need not redo log records 2 and 3 because transaction T1 has committed (D) We can apply redo and undo operations in arbitrary order because they are idempotent CS - 2007 4. Consider the following schedules involving two transactions. Which one of the following statements is TRUE? S1:r1(X); r1 (Y); r2(X); r2(Y); w2 (Y); w1(X) S2:r1(X); r2 (X); r2(Y); w2(Y); r1 (Y); w1(X) (A) Both S1 and S2 are conflict serializable (B) S1 is conflict serializable and S2 is not conflict serializable (C) S1 is not conflict serializable and S2 is conflict serializable
(D) Both S1 and S2 are not conflict serializable 5.
Consider the following two transactions T1 and T2. T1: read(A); read(B); if A = 0 then B ⟵ B+1; write(B); T2: read (B); read (A); if B ≠ 0 then A⟵A 1; write(A); Which of the following schemes, using shared and exclusive locks, satisfy the requirements for strict two phase locking for the above transactions? S2: lock S(B); (A) S1: lock S(A); read (A); read(B); lock S(B); lock S(A) read(B); read(A); if A = 0 if B≠0 then then B←B+1; A ← A – 1; write (B); write(A); commit; commit; unlock (A); unlock (B); unlock (B); unlock (A); (B)
S1: lock X(A); S2: lock X(B); read (A); read (B); lock X(B); lock X(A); read(B); read(A); if A = 0 if B≠ 0 then B←B+1; then write (B); A→A 1; unlock (A); write (A); commit; unlock (A); unlock (B); commit; unlock (B);
(C)
(D)
DBMS
S1: lock S(A); read (A); lock X(B); read(B); if A = 0 then B←B+1; write (B); unlock (A); commit; unlock (B); S1: lock S(A); read (A); lock X(B); read(B); if A = 0 then B←B+1; write (B); unlock (A); unlock (B); commit;
CS – 2009 6. Consider two transactions T1 and T2, and four schedules S1, S2, S3, S4 of T1 and T2 as given below: T1: R1[x] W1 [x] W1 [y] T2: R2 [x] R2 [y] W2 [y] S1: R1[x] R2 [x] R2[y] W1 [x] W1 [y] W2 [y] S2: R1[x] R2 [x] R2[y] W1 [x] W2 [y] W1 [y] S3: R1[x] W1 [x] R2[x] W1 [y] R2 [y] W2 [y] S4: R2[x] R2 [y] R1[x] W1 [x] W1 [y] W2 [y] Which of the above schedules are conflictserializable? (A) S1 and S2 (C) S3 only (B) S2 and S3 (D) S4 only 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
Consider the following schedule for transactions T1, T2 and T3 T1 T2 T3 Read(X) Read(Y) Read(Y) Write(Y) Write(X) Write(X) Read(X) Write(X) Which one of the schedules below is the correct serialization of the above? (A) T1 → T3 → T2 (B) T2 → T1 → T3 (C) T2 → T3 → T1 (D) T3 → T1 → T2
CS - 2012 9. Consider the following transactions with data items P and Q initialized to zero: T1: read (P); read(Q); if P = 0 then Q: = Q + 1 ; write (Q). T2: read(Q); read (P); if Q = 0 then P: = P + 1 ; write (P). Any non-serial interleaving of T1 and T2 for concurrent execution leads to (A) A serializable schedule (B) A schedule that is not conflict serializable (C) A conflict serializable schedule (D) A schedule for which a precedence graph cannot be drawn
11.
DBMS
Consider the following schedule S of transactions T1, T2, T3, T4: T1
Which one of the following statements is CORRECT? (A) S is conflict – serializable but not recoverable (B) S is not conflict – serializable but is recoverable (C) S is both conflict – serializable and recoverable (D) S is neither conflict – serializable nor is it recoverable 12.
CS - 2014 10. Consider the following four schedules due to three transactions (indicated by the subscript) using read and write on a data item x, denoted by r(x) and w(x) respectively. Which one of them is conflict 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
Consider the transactions T1, T2, and T3 and the schedules S1 and S2 given below. T1: r1(X); r1(Z); w1(X); w1(Z) T2: r2(Y); r2(Z); w2(Z) T3: r3(Y); r3(X); w3(Y) S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z); w3(Y); w2(Z); r1(Z); w1(X); w1(Z) S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z); r2(Z); w3(Y); w1(X); w2(Z); w1(Z) Which one of the following statements about the schedules is TRUE? (A) Only S1 is conflict-serializable. (B) Only S2 is conflict-serializable. (C) Both S1 and S2 are conflictserializable. (D) Neither S1 nor S2 is conflictserializable.
[Ans. D] Transactions must execute in order T3 → T2 → T1. Because if sales person “XYZ” Commission = 49,999, then If “T1” executes first then its new commission would be 49,999 × 1.02 = 50,998 [which is greater than 50,000] Now if “T2” executes second, then sales person “XYZ” will get hike again, because his commission is greater than 50,000 This is absolutely wrong. So the perfect order of execution is T3 → T2 →T1.
2.
[Ans. D] Always, even if there is a failure of any kind.
3.
[Ans. C] In data base transaction system if transaction is commit then it becomes permanent there is no effect of any failure so we need not redo log records 2 and 3 because transaction T1 has committed.
4.
[Ans. C] Schedule S1 → Not Conflict Serializable, Since Cycle is formed. Schedule S2 → Confilict Serializable, Since there is no cycle = Serial Schedule T2→ T1 Schedule : S1 Schedule : S2 T1 T2 T1 T2 r1(x) r1(x) r1(y) r2(x) r2(x) r2(y) r2(y) w2(y) w2(y) r1(y) w1(x) w1(x)
Before relasing exclusive lock, commit operation is necessary. 6.
[Ans. B] Schedule S2 T R x R R
5.
T2
T1
x y
x y y Dependency graph T cycles. Schedule S3 T R x x
T S2 has no T
R
x
R
y y
y
T S Salso Dependency graph T has no cycles. So, S and S are conflict – serizlizable. 7.
[Ans. B] In 2 – phase locking concurrency control protocol it ensures the conflict serilizable schedule but it may not free from deadlock Ex. T
T
l(A)
l(A) (A) (B)
u(A) Deny T in waiting
T1
T
T2
l(A) l(B) (B)
(A)
T for unlock
In time stamp ordering protocol it ensure conflict serializablity and free from dead lock
[Ans. C] T1: A required shared lock because it 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.
[Ans. A] Given Schedule → Serializable, Since no cycle is formed → Serial Order =T1→ T3 →T2 T1 T2 T3 Read(X) Read(Y) Read(Y) Write(Y) Write(X) Write(X) Read(X) Write(X) T
[Ans. D] Schedule in option D T T T r(x) w(x) r(x) r(x) w(x) Dependency graph (T ) → (T ) → (T ) Conflict serializable.
11.
[Ans. C] Given Schedule is Recoverable → since all transactions read the committed data only. Given Schedule is Serializable→Since there is no cycle in the graph Equivalent Serializable Schedule = T2 → T3 → T1 → T4 th
[Ans. A] Test for Conflict Serializability→ Precedence Graph Graph without Cycle → Schedule is Conflict Serializable Graph with Cycle → Schedule is NOT Conflict Serializable Schedule S1→ No Cycle → Conflict Serializable Whereas Schedule S2→ Cycle → Not Conflict Serializable Schedule: S1 S1 T1 T2 T3 r1(X) r3(Y) r3(X) r2(Y) r2(Z) w3(Y) w2(Z) r1(Z) w1(X) w1(Z) No cycle → schedule is conflict serializable Equivalent serializable order = T2 → T3 → T1
File Structures (Sequential files, Indexing, B and CS - 2005 1. Which one of the following is a key factor for preferring B+ -trees to binary search trees for indexing database relations? (A) Database relations have a large number of records (B) Database relations are sorted on the primary key (C) B+ -trees require less memory than binary search trees (D) Data transfer from disks is in blocks 2.
4.
Consider the relation enrolled (student, course) in which (student, course) is the primary key, and the relation paid (student, amount) where student is the primary key. Assume no null values and no foreign keys or integrity constraints. Assume that amounts 6000, 7000, 8000, 9000 and 10000 were each paid by 20% of the students. Consider these query plans (Plan 1 on left, Plan 2 on right) to “list all courses taken by students who have paid more than x.”
enrolled
paid
enrolled
Probe index on student
Sequential scan, select amount > x
Probe index on student
Indexed nested loop join
paid Sequential scan
Indexed nested loop join
Select on amount > x
Project on course
A B-tree used as an index for a large database table has four levels including the root node. If a new key is inserted in this index, then the maximum number of nodes that could be newly created in the process are (A) 5 (C) 3 (B) 4 (D) 2
CS - 2006 3. In a database file structure, the search key field is 9 bytes long, the block size is 512 bytes, a record pointer is 7 bytes and a block pointer is 6 bytes. The largest possible order of a non-leaf node in a B+ tree implementing this file structure is (A) 23 (C) 34 (B) 24 (D) 44
trees)
Project on course
A disk seek takes 4ms, disk data transfer bandwidth is 300 MB/s and checking a tuple if amount is greater than x takes 10 µs. Which of the following statement is correct? (A) Plan 1 and Plan 2 will not output identical row sets for all databases (B) A course may be listed more than once in the output of Plan 1 for some databases (C) For x = 5000, Plan 1 executes faster than Plan 2 for all databases (D) For x = 9000, Plan 1 executes slower than Plan 2 for all databases CS - 2007 5. The order of a leaf node in a B+-tree is the maximum number of (value, data record pointer) pairs it can hold. Given that the block size is 1K bytes, data record pointer is 7 bytes long, the value field is 9 bytes long and a block pointer is 6 bytes long, what is the order of the leaf node? (A) 63 (C) 67 (B) 64 (D) 68
Statement for Linked Answer Questions 6 and 7 Consider the tree in the adjoining figure, where each node has at most two keys and three links.
6.
Keys K15 then K25 are inserted into this tree in that order. Exactly how many of the following nodes (disregarding the links) will be present in the tree after the two insertions?
(A) 1 (B) 2 7.
(C) 3 (D) 4
Now the key K50 is deleted from the B+ tree resulting after the two insertions made earlier. Consider the following statements about the tree resulting after this deletion. (i) The height of the tree remains the same. (ii) The node K20 (disregarding the links) is present in the tree. (ii) The root node remains unchanged (disregarding the links). Which one of the following options is true? (A) Statements (i) and (ii) are true (B) Statements (ii) and (iii) are true (C) Statements (iii) and (i) are true (D) All the statements are false
CS - 2008 8. Consider a file of 16384 records. Each record is 32 bytes long and its key field is of size 6 bytes. The file is ordered on a
DBMS
non-key field, and the file organization is unspanned. The file is stored in a file system with block size 1024 bytes, and the size of a block pointer is 10 bytes. If 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 (C) 256 and 4 (A) 8 and 0 (B) 128 and 6 (D) 512 and 5 9.
A clustering index is defined on the fields which are of type (A) Non-key and ordering (B) Non-key and non-ordering (C) Key and ordering (D) Key and non-ordering
CS - 2009 10. The following key values are inserted into a B+-tree in which order of the internal nodes is 3, and that of the leaf nodes is 2, in the sequence given below. The order of internal nodes is the maximum number of tree pointers in each node, and the order of leaf nodes is the maximum number of data items that can be stored in it. The B+-tree is initially empty. 10, 3, 6, 8, 4, 2, 1. The maximum number of times leaf nodes would get split up as a result of these insertions is (A) 2 (C) 4 (B) 3 (D) 5 CS - 2013 11. An index is clustered , if (A) It is on a set of fields that form a candidate key. (B) It is on a set of fields that include the primary key (C) The data records of the file are organized in the same order as the data entries of the index (D) The data records of the file are organized not in the same order as the data entries of the index th
[Ans. D] The transfer of data from disk to primary memory is in the form of data blocks if a data block is larger than indexing is easy due to this tree is better than binary search tree data structure if large amount of data can be access.
Size of Key = K = 9 Bytes Size of Block Pointer = BP = 6 Bytes (n × K) + (n × RP) + BP = B (n × 9) + (n × 7) + 6 = 1024 n = CEIL (1018/16) = CEIL (63.62) = 63 6.
[Ans. A] Final tree is
[Ans. A]
20
40
root (first level)
15
second level
third level
3.
4.
5.
7.
50
30
15
[Ans. A] After deletion of K – 50, we get following - tree 20
[Ans. C] Size of Key = K=9 Bytes Size of Block = B = 512 Bytes Size of Record Pointer = RP = 7 Bytes Size of Block Pointer = BP = 6 Bytes Order (non-leaf node) of B + Tree = n =? (n × BP) + (n ) K=B (n × 6) + (n ) 9 =512 n=CEIL (521/15) = CEIL (34.73) = 34 [Ans. C] The seek time of disk is 4ms and data transfer node is 300 MB/s. So if x = 5000 then plan 1 execute faster than plan 2 for all database.
40
20 25
10
fourth level
If insertion takes place then new node can be inserted at each level shown by dashed box and in this process the new root can be created. Hence 5 is the answer
50
30
30
15
10
15
20
25
40
30
40
So (i) is true (ii) is also true (iii) is false because root not remain unchanged 8.
[Ans. C] DATA FILE File → Ordered on Non – Key field Total no. of Records = 16384 records Size of the Record = 32 Bytes INDEX FILE Type of Index = Secondary Index ( ey) → DENSE INDEX Size of Key = 6 Bytes Size of block pointer =10 Bytes
[Ans. A] Order (leaf node) = max (value, record pointers) = n =? Size of Block = B = 1K bytes = 1024 Bytes Size of Record Pointer = RP = 7 Bytes th
Size of the Block =1024 Bytes Size of the Index Record = 10 + 6 = 16 Bytes No. of Index Records that can fit in a single block = 1024/16 = 64 Total No. of Index Records = DENSE = 16384 index records Total No. of Blocks for First Level Index = 16384/64 = 256 blocks Total No. of Blocks for Second Level Index = 256/64=4 blocks 9.
10.
DBMS
Insert: 4 4 3*
4*
2
6
8* 10*
6*
Insert: 2 4
3
3
[Ans. A] A clustering index is defined on the fields which are of type non-key and ordering.
2* 3*
6
4*
6*
8* 10*
Insert: 1 4
[Ans. C] Insert into B+ Tree in the order 10, 3, 6, 8, 4, 2, 1 & Calculate the No. of leaf Splits 2
4
3
6
Order of Non Leaf Node = 3 K1
Max Pointers = 3 Min Pointers = CEIL (3/2) =2 Min Pointers for ROOT = 2
K1
Order of Leaf Node = 2 I1
I2
1* 2*
3*
4*
6*
8* 10*
Total no. of Leaf Splits in B+ Tree=4 11.
Max Keys = 2 Min Keys = 1
[Ans. C] Clustered if the data is ordered in same order as the index order
Introduction to Computer Networks CS – 2005 1. In a network of LANs connected by bridges, packets are sent from one LAN to another through intermediate bridges. Since more than one path may exist between two LANs, packets may have to be routed through multiple bridges. Why is the spanning tree algorithm used for bridge-routing? (A) For shortest path routing between LANs (B) For avoiding loops in the routing paths (C) For fault tolerance (D) For minimizing collisions 2.
In a packet switching network, packets are routed from source to destination along a single path having two intermediate nodes. If the message size is 24 bytes and each packet contains a header of 3 bytes, then the optimum packet size is: (A) 4 (B) 6 (C) 7 (D) 9
CS – 2007 3. Match the following : P. SMTP 1. Application layer Q. BGP 2. Transport layer R. TCP 3. Data link layer S. PPP 4. Network layer 5. physical layer (A) P 2, Q 1, R 3, S 5 (B) P 1, Q 4, R 2, S 3 (C) P 1, Q 4, R 2, S 5 (D) P 2, Q 4, R 1, S 3 4.
Let us consider a statistical time division multiplexing of packets. The number of sources is 10. In a time unit, a source transmits a packet of 1000 bits. The number of sources sending data for the 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.
The output capacity of multiplexer is 5000 bits per time unit. Then the average number of backlogged of packets per time unit during the given period is (A) 5 (B) 4.45 (C) 3.45 (D) 0 5.
A group of 15 routers are interconnected in a centralized complete binary tree with a router at each tree node. Router i communicates with router j by sending a message to the root of the tree. The root then sends the message back down to router j. The mean number of hops per message, assuming all possible router pairs are equally likely is (A) 3 (B) 4.53 (C) 4.26 (D) 5.26
CS – 2008 6. How many bytes of data can be sent in 15 seconds over a serial link with baud rate of 9600 in asynchronous mode with odd parity and two stop bits in the frame? (A) 10,000 bytes (C) 15,000 bytes (B) 12,000 bytes (D) 27,000 bytes CS – 2014 7. In the following pairs of OSI protocol layer/sub-layer and its functionality. The INCORRECT pair is (A) Network layer and Routing (B) Data Link Layer and Bit synchronization (C) Transport layer and End-to-end process communication (D) Medium Access Control sub-layer and Channel sharing 8.
A bit-stuffing based framing protocol uses an 8-bit delimiter pattern of 01111110. If the output bit-string after stuffing is 01111100101, then the input bit-string is (A) 0111110100 (C) 0111111101 (B) 0111110101 (D) 0111111111
[Ans. B] Spanning Tree Algorithm is used for bridges for avoiding loops in the routing paths. Spanning Tree algorithm will make sure that there will be only one path between every 2 LAN’s
[Ans. B] SMTP ---------- Application layer BGP ------------ Network layer TCP ------------ Transport layer PPP ------------- Data link layer
4.
[Ans. C] 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]
Mode = Asynchronous Mode To send ever 8-bits, we have to send 1start bit, 2 stop bits, and 1 parity bit. Total bits required to send 8-bit character = 8 + 1 + 2 + 1 = 12 bits [over head = 4 bits/byte] Each signal can transmit 1-bit of data. To send 8-bits we have to send 12 bits 12 signals to be used for 8-bit data. Thus total no of 8-bit characters sent per second = 9600/12 = 800 characters [Bytes/second] Total Bytes transmitted in 15 seconds = 800 × 15 = 12,000 Bytes. 7.
[Ans. B] Since Bit Synchronization Physical Layer Responsibility, It’s not Data Link Layer’s Responsibility
8.
[Ans. B] 8-bit delimeter = 01111110 We will stuff with “0” after every 5 consecutive 1’s Output String = 011111 00101 [Stuffed bit has been highlighted] Then, Input String = 0111110101 [After destuffing the stuffed “0”]
Medium Access Sublayer (LAN Technologies: Ethernet, Token Ring) CS – 2005 1. Which of the following statements is TRUE about CSMA/CD (A) IEEE 802.11 wireless LAN runs CSMA/CD protocol (B) Ethernet is not based on CSMA/CD protocol (C) CSMA/CD is not suitable for a high propagation delay network like statellite network. (D) There is no contention in a CSMA/CD network 2.
3.
4.
A network with CSMA/CD protocol in the MAC layer is running at 1 Gbps over a 1 km cable with no repeaters. The signal speed in the cable is 2 ×108 m/sec. The minimum frame size for this network should be (A) 10000 bits (C) 5000 bits (B) 10000 bytes (D) 5000 bytes A channel has a bit rate of 4 kbps and oneway propagation delay of 20 ms. The channel uses stop and wait protocol. The transmission time of the acknowledgement frame is negligible. To get a channel efficiency of at least 50%, the minimum frame size should be (A) 80 bytes (C) 160 bytes (B) 80 bits (D) 160 bits In a TDM medium access control bus LAN, each station is assigned one time slot per cycle for transmission. Assume that the length of each time slot is the time to transmit 100 bits plus the end-to-end propagation delay. Assume a propagation speed of 2 × 108 m/sec. The length of the LAN is 1 km with a bandwidth of 10 Mbps. The maximum number of stations that can be allowed in the LAN so that the throughput of each station can be 2/3 Mbps is: (A) 3 (B) 5 (C) 10 (D) 20
5.
Suppose the round trip propagation delay for a 10 Mbps Ethernet having 48-bit jamming signal is 46.4 µs. The minimum frame size is: (A) 94 (B) 416 (C) 464 (D) 512
CS – 2006 6. Station A needs to send a message consisting of 9 packets to Station B using a siding window (window size 3) and go-back-n error control strategy. All packets are ready and immediately available for transmission. If every 5th packet that A transmits gets lost (but no acks from B ever get lost), then what is the number of packets that A will transmit for sending the message to B? (A) 12 (C) 16 (B) 14 (D) 18 CS – 2007 7. In Ethernet when Manchester encoding is used the bit rate is (A) Half the baud rate (B) Twice the baud rate (C) Same as the baud rate (D) None of these 8.
There are n stations in a slotted LAN. Each station attempts to transmit with a probability p in each time slot. What is the probability that ONLY one station transmits in a given time slot? (A) np(1 – p)n – 1 (C) p(1 – p)n – 1 n – 1 (B) (1 – p) (D) 1 (1 – p)n – 1
9.
In a token ring network the transmission speed is 10 bps and the propagation speed is 200 meters/ s. The 1-bit delay in this network is equivalent to : (A) 500 meters of cable (B) 200 meters of cable (C) 20 meters of cable (D) 50 meters of cable th
A broadcast channel has 10 nodes and total capacity of 10 Mbps. It uses polling for medium access. Once a node finishes transmission, there is a polling delay of 80 s to poll the next node. Whenever a node is polled, it is allowed to transmit a maximum of 1000 bytes. The maximum throughput of the broadcast channel is (A) 1 Mbps (C) 10 Mbps (B) 100/ 11 Mbps (D) 100 Mbps Common Data for Questions 11 & 12: Consider a token ring topology with N stations (numbered 1 to N) running token ring protocol where the stations are equally spaced. When a station gets the token it is allowed to send one frame of fixed size. Ring latency is tp, while the transmission time of a frame is tt. All other latencies can be neglected. 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
14.
Computer Networks
The minimum frame size required for CSMA/CD based computer network running at 1 Gbps on a 200m cable with a link speed of 2 10 m/s is (A) 125 bytes (B) 250 bytes (C) 500 bytes (D) None of the above
CS – 2013 15. Determine the maximum length of the cable (in km) for transmitting data at a rate of 500 Mbps in an Ethernet LAN with frames of size 10,000 bits. Assume the signal speed in the cable to be 2,00,000 km/s. (A) 1 (C) 2.5 (B) 2 (D) 5
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
[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×
3.
4.
5.
[Ans. C]
×109=10,000 bits
[Ans. D] Bandwidth = B = 4 Kbps = 4 × 103 bits/sec Propagation Delay = Tp = 20 ms = 20 × 10 sec Protocol = Stop-and-Wait Transmission Time for Ack = Negligible = 0 sec Channel Efficiency = 50% = 1/2 [Utilization] Minimum Frame Size = F = ? T fficiency T 2T 1 2 2 20 10 4 10 160 bits [Ans. C] 2 n 10 3
6.
Number of packets = 16 7.
[Ans. A] Manchester ncoding 2 signals will be used for sending 1-bit. For sending 10 bits, we have to send 20 signals. Hence baud rate is twice the bandwidth. Bandwidth = Baud rate/2 [Half the baud rate]
8.
[Ans. A] p(1) = n p 1 =
n 1 n 1
= np 1 100 15 10
n
10
9.
p
p 1
p
p
[Ans. C] LAN = Token Ring Bandwidth = B = 10 bits/sec Propagation Speed = 200 mts/micro seconds [signal travels 200 meters in 10 seconds] 1 bit delay in this network = ? As B= 10 bits/sec, To place 1-bit in the 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
[Ans. B] Polling delay 80 s Max t 8000 bits, 800 s at 10 Mbps Max throughput = 10
DR 10 Mbps
11.
[Ans. C] LAN = Token Ring Total no. of Stations = N = 10 Ring Latency = t = 5 ms 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
15.
2 2
Computer Networks
[Ans. B] Distance of the Cable = d = ? [in kms] Bandwidth = B = 500 Mbps = 500 × 106 bits/sec LAN = Ethernet Access Control Protocol = 1 Persistent CSMA/CD Size of Frame = F = 10,000 bits Speed of Signal = S = 2,00,000 km/sec d 2 bits s 10,000 = 2 × (d/ 2, 00,000) × 500 × 106 d = 2 kms
The Data Link Layer (Flow and Error Control Techniques) CS – 2005 1. The maximum window size for data transmission using the selective reject protocol with n bit frame sequence numbers is: (A) 2 (C) 2 – 1 – (B) 2 (D) 2 – 2.
Consider the following message M = 1010001101. The cyclic redundancy check (CRC) for this message using the divisor polynomial x x x 1 is: (A) 01110 (C) 10101 (B) 01011 (D) 10110
CS – 2006 3. Station A uses 32 byte packets to transmit messages to station B using a sliding window protocol. The round trip delay between A and B is 80 milliseconds and the bottleneck bandwidth on the path between A and B is 128 kbps. What is the optimal window size that A should use? (A) 20 (C) 160 (B) 40 (D) 320 4.
5.
Which of the following statements is TRUE? (A) Both Ethernet frame and IP packet include checksum fields (B) Ethernet frame includes a checksum field and IP packet includes a CRC field (C) Ethernet frame includes a CRC field and IP packet includes a checksum field (D) Both Ethernet frame and IP packet include CRC fields Suppose that it takes 1 unit of time to transmit a packet (of fixed size) on a communication link. The link layer uses a window flow control protocol with a
window size of N packets. Each packet causes an ack or a nak to be generated by the receiver and ack/nak transmission times are negligible. Further, the round trip time on the link is equal to N units. Consider time i > N. if only acks have been received till time i(no naks), then the goodput evaluated at the transmitter at time i(in packets per unit time) is (A) 1 – N/ i (C) 1 (B) i/ (N + i) (D) 1 – e CS – 2007 6. The message 11001001 is to be transmitted using the CRC Polynomial x 1 to protect it from errors. The message that Should be transmitted is: (A) 11001001000 (C) 11001010 (B) 11001001011 (D) 110010010011 7.
The distance between two stations M & N is L kilometers. All frames are K-bits long. The propagation delay per kilometer is t seconds. Let R bits/sec be the channel capacity. Assuming that processing delay is negligible, the minimum number of bits for the sequence number field in a frame for maximum utilization, when the sliding window protocol is used, is: (A) [log (B) [log
] ]
(C) [log
]
(D) [log
]
CS – 2008 8. Data transmitted on a link uses the following 2D parity scheme for error detection : Each sequence of 28 bits is arranged in a 4 7 matrix ( rows r through r , and columns d thorugh d ) and is padded with a column d an row r of parity bits computed using the Even parity scheme . Each bit of column d th
(respectively , row r ) gives the parity of the corresponding row (respectively , column). These 40 bits are transmitted over the data link . 0
1
0
1
0
0
1
1
1
1
0
0
1
1
1
0
0
0
0
1
0
1
0
0
0
1
1
0
1
0
1
0
1
1
0
0
0
1
1
0
The table shows data received by a receiver and has n corrupted bits. What is the minimum possible value of n ? (A) 1 (C) 3 (B) 2 (D) 4 CS – 2009 9. Let G(x) be the generator polynomial used for CRC checking. What is the condition that should be satisfied by G(x) to detect odd number of bits in error? (A) G(x) contains more than two terms (B) G(x) does not divide 1 + x , for any k not exceeding the frame length (C) 1 + x is a factor of G(x) (D) G(x) has an odd number of terms
10.
11.
Statement for Linked Answer Questions 10 and 11: Frames of 1000 bits are sent over a 10 bps duplex link between two hosts. The propagation time is 25 ms. Frames are to be transmitted into this link to maximally pack them in transit (with in the link) What is the minimum number of bits ( ) that will be required to represent the sequence numbers distinctly? Assume that no time gap needs to be given between transmission of two frames. (A) l 2 (C) l 4 (B) l 3 (D) l 5
Computer Networks
always piggy backed. After sending 2 frames, what is the minimum time the sender will have to wait before starting transmission of the next frame? (Identify the closest choice ignoring the frame processing time) (A) 16 ms (C) 20 ms (B) 18 ms (D) 22 ms CS – 2012 12. Consider a source computer (S) transmitting a file size 106 bits to a destination computer (D) over a network of two routers (R1 and R2) and three (L1, L2, and L3). L1 connects S to R1;L2 connects R1 to R2; and L3 connects R2 to D. Let each link be of length 100 km. Assume signals travel over each link at a speed of 108 meters per second. Assume that the link bandwidth on each link is 1Mbps. Let the file be broken down into 1000 packets each of size 1000bits. Find the total sum of transmission and propagation delays in transmitting the file from S to D? (A) 1005 ms (C) 3000 ms (B) 1010 ms (D) 3003 ms CS – 2014 13. Consider a token ring network with a length of 2 km having 10 stations including a monitoring station. The propagation speed of the signal is 2 10 m/s and the token transmission time is ignored. If each station is allowed to hold the token for 2 sec, the minimum time for which the monitoring station should wait (in sec) before assuming that the token is lost is _______. 14.
Suppose that the sliding window protocol is used with the sender window size of 2 , where is the number of bits identified in the earlier part and acknowledgments are th
Consider a selective repeat sliding window protocol that uses a frame size of 1 KB to send data on a 1.5 Mbps link with a one-way latency of 50 msec. To achieve a link utilization of 60%, the minimum number of bits required to represent the sequence number field is ________.
Consider the store and forward packet switched network given below. Assume that the bandwidth of each link is 10 bytes / sec. A user on host A sends a file of size 10 bytes to host B through routers R1 and R2 in three different ways. In the first case a single packet containing the complete file is transmitted from A to B. In the second case, the file is split into 10 equal parts, and these packets are transmitted from A to B. In the third case, the file is split into 20 equal parts and these packets are sent from A to B. Each packet contains 100 bytes of header information along with the user data.
Computer Networks
Consider only transmission time and ignore processing, queuing and propagation delays. Also assume that there are no errors during transmission. Let T1, T2 and T3 be the times taken to transmit the file in the first, second and third case respectively. Which one of the following is CORRECT? A
(A) (B) (C) (D)
R2
R1
B
T1 T2 T3 T1 T2 T3 T2 = T3 , T3 < T1 T1 = T3, T3 > T2
Answer Keys & Explanations 1.
[Ans. B] In the case of selective reject protocol; the maximum window size =
2.
3.
[Ans. B] Given round trip delay t = 80 ms = 80 10 R = 128 Kbps = 128 × 10 bps L = Rt = 128 × 10 × 80 × 10 So, optimal window size
2
[Ans. A] Message = data word=1010001101 Divisor x x x 1 110101 6 bits] CRC = ? [Remainder] Augmented data word = data word + 5 bits[zeros] = 101000110100000 110101 101000 ① ① ⓪ ① ⓪ ⓪ ⓪ ⓪ ⓪ 1101010110 110101 111011 110101 011101 000000 111010 110101 011111 000000 111110 110101
n 4.
[Ans. C] Ethernet frame include a CRC field and IP packet include a checksum field.
5.
[Ans. C] The link later uses a window from control protocol with a window size of N packets and round trip time is equal to N units. Goodput = Packets/unit time = N packets/N units = 1.
6.
[Ans. B] Message = data word =11001001 Divisor x 1 1. x 0. x 0. x 1. x 1001 4 bits] Code word = data word +3 – redundant bits =? Augmented dataword = 11001001 000
[Ans. C] The polynomial generator used for CRC checking must satisfy at least two conditions to detect odd numbers of errors: 1. It should be not divisible by x 2. It should be divisible by 1 + x Therefore 1 x is a factor of G(x)
10.
[Ans. D] The link is a duplex hence we need not to wait for twice the propagation time for sending the frame belonging to next window. If the sender window is of size N. Transmitting 10 bits require = 1 sec 1 N 1000 bits require N 10 10 N 10 sec Nm sec Nm sec = 25 m sec, N = 25 2 ∴Minimum number of bits required is 5 to represent sequence numbers distinctly
11.
[Ans. B] Time taken to send 10 bits 1 sec ∴ Time taken to send 2 frames = 32 m sec (1 frame = 1000 bits) Time taken for the first frame to be acknowledged 25 2 50 m sec Then waiting time 50 32 18 m sec
12.
[Ans. A] Size of files = 10 Total Routes = 2{ , } Total links = 3 { , , } Length of each Link = d= 100 km = 100 10 Speed of signal of each link = s= 10 mts Sec
Remainder 011 Code word = Data word + Remainder 11001001 011 7.
[Ans. C] Frame Size = K bit Propagation delay = t sec/km Channel capacity = Rbits/sec Distance = L km Round trip delay = 2Lt sec. Window size w =
1 1
# of bits = ⌈log 8.
⌉
[Ans. C] The receiver will calculate all the row and column parities and found that there is an error in 1-row and 2- columns. No. of errors detected in rows = 1 [r1] No. of errors detected in columns = 3 [d5, d2, d0] Minimum possible errors = max (errors in rows, errors in columns) = max (1, 3) = 3 errors. 0
1
0
1
0
0
1
Computer Networks
L1 S
1
0
1
1
0
0
1
1
1
0
1
0
0
0
1
0
1
0
0
0
0
1
1
0
1
0
1
0
0
1 0
1 0
0 1
0 0
0 0
1 1
1 0
0 1
0
L2 R
d= 100 kms s = 10 mts sec
L3 R
d= 100 kms s = 10 mts sec
D d= 100 kms s = 10 mts sec
Band width = B = 1 MBPS = 10 bits sec File is broken in to 1000 packets n 1000 Packets Size of Packet = F = 1000 bits [10 bits 1000 packet 1000]
Find the sum of [T T ] in transmitting a file from S to D? 1000 bits T 10 sec 1ms 10 bits sec d 100 10 T 10 sec 1 ms s 10 T 1ms T 1ms T ] for I frame from S to D 3 T 3 T 3 1ms 3 1ms 6 ms T T ] for I frame 6 ms T T ] for II frame 1ms 7 ms 7ms 6ms 1ms] Receiver will reactive I frame after 6 ms and the successive frames in 1ms only. Total T T ] for 1000 packet = 6 ms for I packet 999 ms for 999 packet 1005 ms
Ring latency of token to be considered. [Time for token to traverse the entire ring] Ring Latency = Distance/Speed 10 2 10 seconds 2 10 10 10 seconds Minimum Time Monitor Station should wait = (n 1) token holding time + ring latency 10 1 2 10 seconds 10 10 seconds 18 10 seconds 10 10 seconds 28 10 seconds 28 micro seconds.
T
P4 S
L1
P3
P2
R
R
L2
14.
P1=6 ms L3
D
All packets are ready & reach to destination in 1 ms gap 13.
Computer Networks
[Ans. *] Range 28 to 30 Total number of Stations in the Ring = n = 10 stations [including monitor station] Length (or) distance of Ring = 2 km = 2 10 mts Propagation Speed = 2 10 m/s Token Holding time of each station = 2 micro seconds = 2 10 seconds Ignore token transmission time Minimum time monitor station should wait before assuming that token is lost is = ? [in Micro Seconds] Minimum time monitor station should get the token = (n 1) token holding time + ring latency (n 1) Excluding Monitor station (n 1) stations token holding time to be considered
th
[Ans. 5] Size of Frame = F = 1KB = 1024 Bytes = 1024 × 8 bits Bandwidth 1.5 Mbps 1.5 10 bits/sec One Way Latency= Propagation Time = T = 50 msec 50 10 sec Utilization = 60% = 60/100 Minimum number of bits required to represent the sequence number= ? Let window size = number of frames in sender window = n Utilization = n × F bits / (F + 2 × × B) bits 60 n 1024 8 bits 1024 8 100 2 2 50 10 1.5 10 bits n 60 1024 8 2 50 10 2 1.5 10 1024 8 100 n 949152 11.58 12 approx 2 81920 n = 24 Total number of Frames in Sender Window = Sender Window Size = 24 frames.
Routing & Congestion Control CS – 2005 1. Count to infinity is a problem associated with (A) link state routing protocol (B) distance vector routing protocol (C) DNS while resolving host name (D) TCP for congestion control Statement for Linked Answer Questions 2 and 3: Consider a simple graph with unit edge costs. Each node in the graph represents a router. Each node maintains a routing table indicating the next hop router to be used to relay a packet to its destination and the cost of the path to the destination through that router. Initially, the routing table is empty. The routing table is synchronously updated as follows. In each updated interval, three tasks are performed. (i) A node determines whether its neighbours in the graph are accessible. If so, it sets the tentative cost to each accessible neighbour as 1. Otherwise, the cost is set to ∞. (ii) From each accessible neighbor, it gets the costs to relay to other nodes via that neighbor (as the next hop) (iii) Each node updates its routing table based on the information received in the previous two steps by choosing the minimum cost. B
A
C
D
F
E
2.
For the graph given above, possible routing tables for various nodes after they have stabilized, are shown in the following options. Identify the correct table?
3.
(A)
Table for node A A B B 1 C C 1 D B 3 E C 3 F C 4
(C)
Table for node B A A 1 B C C 1 D D 1 E C 2 F D 2
(B)
Table for node C A A 1 B B 1 C D D 1 E E 1 F E 3
(D)
Table for node D A B B B C C D E E F F
3 1 1 1 1
Continuing from the earlier problem, suppose at some time t, when the costs have stabilized, node A goes down. The cost from node F to node A at time ( t + 100) is: (A) > 100 but finite (B) ∞ (C) 3 (D) 3 and ≤ 100
CS – 2008 4. Two popular routing algorithms are Distance vector (DV) and Link state (LS) routing . Which of the following are true? S1: Count to infinity is a problem only with DV and not LS routing S2: In LS, the shortest path algorithm is run only at one node S3: In DV, the shortest path algorithm is run only at one mode S4: DV requires lesser number of network messages than LS (A) S1, S2 and S4 ONLY (B) S1, S3 and S4 ONLY (C) S2 and S3 ONLY (D) S1 and S4 ONLY th
CS – 2010 Statement for Linked Answer Questions 5 and 6: Consider a network with 6 routers R1 to R6 connected with links having weights as shown in the following diagram. 7
R2 AS
6 R1
8
4 R3
6.
R6
1
3
5.
R5
9
All the routers use the distance vector based routing algorithm to update their routing tables. Each router starts with its routing table initialized to contain an entry for each neighbor with the weight of the respective connecting link. After all the routing tables stabilize, how many links in the network will never be used for carrying any data? (A) 4 (C) 2 (B) 3 (D) 1 Suppose the weights of all unused links in the previous question are changed to 2 and the distance vector algorithm is used again until all routing tables stabilize. How many links will now remain unused? (A) 0 (C) 2 (B) 1 (D) 3
CS – 2011 Statement for Linked Answer Questions 7 and 8: Consider a network with five nodes, N1 to N5 as shown below N1 1 N5
3
4
N2
6
N4
The network uses a Distance Vector Routing protocol. Once the routes have stabilized, the distance vectors at different nodes are as following: N1: (0, 1, 7, 8, 4) N2: (1, 0, 6, 7, 3) N3: (7, 6, 0, 2, 6) N4: (8, 7, 2, 0, 4) B5: (4, 3, 6, 4, 0) Each distance vector is the distance of the best known path at the instance to nodes, N1 to N5, where the distance to itself is 0. Also, all links are symmetric and the cost is identical in both directions. In each round, all nodes exchange their distance vectors with their respective neighbors. Then all nodes update their distance vectors. In between two rounds, any change in cost of a link will cause the two incident nodes to change only that entry in their distance vectors. The cost of link N2 N3 reduces to 2(in both directions). After the next round of updates, what will be the new distance vector at node, N3 (A) (3, 2, 0, 2, 5) (C) (7, 2, 0, 2, 5) (B) (3, 2, 0, 2, 6) (D) (7, 2, 0, 2, 6)
R4
2
2
N3
Computer Networks
7.
8.
After the update in the previous question, the link N1-N2 goes down. N2 will reflect this change immediately in its distance vector as cost, ∞. After the NEXT ROUND of update, what will be the cost to N1 in the distance vector of N3? (A) 3 (C) 10 (B) 9 (D) ∞
CS – 2012 9. An Internet Service Provider (ISP) has the following chunk of CIDR-based IP address available with it: 245.248.128.0/20. The ISP wants to give half of this chunk of addresses of Organization A, and a quarter of Organization B, while retaining the remaining with itself. Which of the following of a valid allocation of addresses to A and B? th
(A) 245.248.136.0/21 and 245.248.128.0/22 (B) 245.248.128.0/21 and 245.248.128.0/22 (C) 245.248.132.0/22 and 245.248.132.0/21 (D) 245.248.136.0/24 and 245.248.132.0/21 CS – 2013 10. Assume that source S and destination D are connected through two intermediate routers labeled R. Determine how many times each packet has to visit the network layer and the data link layer during a transmission from S to D.
S
R
R
Computer Networks
12.
An IP router implementing Classless Inter-domain Routing (CIDR) receives a packet with address 131.23.151.76. The router’s routing table has the following entries: Prefix Output Interface Identifier 131.16.0.0/12 3 131.28.0.0/14 5 131.19.0.0/16 2 131.22.0.0/15 1 The identifier of the output interface on which this packet will be forwarded is ___________
13.
Which one of the following is TRUE about the interior gateway routing protocols – Routing Information Protocol (RIP) and Open Shortest Path First (OSPF)? (A) RIP uses distance vector routing and OSPF uses link state routing (B) OSPF uses vector routing and RIP uses link state routing (C) Both RIP and OSPF use link state routing (D) Both RIP and OSPF uses distance vector routing
D
(A) Network layer – 4 times and Data link layer – 4 times (B) Network layer – 4 times and Data link layer – 3 times (C) Network layer – 4 times and Data link layer – 6 times (D) Network layer – 2 times and Data link layer – 6 times 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.
[Ans. B] Associated with distance vector routing algorithm [Ans. C] Table for node B A A B C C D D E C F D
Routing table For R1 R2 R3 R4 R5 R6
1 1 1 2 2
R1 R2 R3 R4 R5
R2 R3 R4 R5 R6
12 7 9 1 5
Next hop R2 R2 R2 R5 R5
12 8 9 1 4
Next hop R3 R4 R3 R4 R6
For R4 R1 R2 R3 R5 R6
[Ans. C]
For R5
R4 8
6 R1
3 2 9 9 13
Next hop R1 R2 R4 R5 R5
For R3
[Ans. D] S1 True, Since ount To Infinity is only a problem with DV but not LS S2 alse, since in LS, the shortest path algorithm is run at all nodes S3 alse, since in DV, we don’t use any shortest path algorithm S4 True, since in DV, each node shares its routing table only with its neighbors, where as inLS each node broadcast its routing table to all nodes in the network.
7
5 2 7 8 12
Next hop R3 R3 R4 R4 R4
For R2
[Ans. A] Node “A” goes down at time “t”. At time t 100 the cost from Node “ ” to node “A” will definitely be > 100 and finite, because Node “ ” will receive cost from neighbor “D” where as “D” will have 3 neighbors {B, C, E} and at least one neighbor will give finite cost.
[Ans. A] Network ID = 245.248.128.0/20 alf of this IP addresses to “A” ISP wants VLSM Quarter to Organization “ ” to give Retaining the remaining with itself [Quarter] Total subnets 2 2 level subnetting osts Subnet 2 2
Next hop R1 16 R5 R2 12 R5 R3 13 R5 R4 5 R5 R5 4 R5 So it is clear visualize from the all routing table construction that we never use the direct path between 6
R1
R2
and
R4
8
Computer Networks
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] R2
2
7
R4
6 R1
8 2
R6
1
3
2
4 R3
9
R5 Link R5-R6 will be unused
7.
8.
[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 N5 as 3 and 5 respectively
Total soultions 2 S. No Organization Network ID/ Subnet mast A 50 245.248.128.0 21 1 25 245.248.136.0 22, 245.248.140.0/22 A 50 245.248.136.0 21 2 25 245.248.128.0 22, 245.248.140.0/22
[Ans. C] In the next ground, N3 will receive distance from N2 to N1 as infinite. It will receive distance from N4 to N1 as 8. So it will update distance to N1 as 8+2 =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”
TCP/IP, UDP and Sockets, IP(V4) CS – 2005 1. Packets of the same session may be routed through different paths in: (A) TCP, but not UDP (B) TCP and UDP (C) UDP, but not TCP (D) Neither TCP nor UDP 2.
The address resolution protocol (ARP) is used for: (A) Finding the IP address from the DNS (B) Finding the IP address of the default gateway (C) Finding the IP address that corresponds to a MAC Address (D) Finding the MAC address that corresponds to an IP Address
3.
An organization has a class B network and wishes to for m subnets for 64 departments. The subnet mask would be: (A) 255.255.0.0 (C) 255.255.128.0 (B) 255.255.64.0 (D) 255.255.252.0
4.
Trace-route reports a possible route that is taken by packets moving from some host A to some other host B. Which of the following options represents the technique used by trace-route to identify these hosts? (A) By progressively querying routers about the next router on the path to B using ICMP packets, starting with the first router. (B) By requiring each router to append the address to the ICMP packet as it is forwarded to B. The list of all routers en-route to B is returned by B in an ICMP reply packet. (C) By ensuring that an ICMP reply packet is returned to A by each router en-route to B, in the ascending order of their hop distance from A (D) By locally computing the shortest path from A to B
5.
On a TCP connection, current congestion window size is Congestion Window = 4 KB. The window size advertised by the receiver is Advertise Window = 6 KB. The last byte sent by the sender is Last Byte Sent= 10240 and the last byte acknowledged by the receiver is last byte acked = 8192. The current window size at the sender is: (A) 2048 bytes (C) 6144 bytes (B) 4096 bytes (D) 8192 bytes
6.
In a communication network, a packet of length L bits takes link L1 with a probability of p1 or link L2 with a probability of p2 . Link L1 and L2 have bit error probability of b1 and b2 respectively. The probability that the packet will be received without error via either L1 or L2 is: (A) (1 b1)Lp1 + (1 b2)Lp2 (B) [1 (b1+b2)L]p1 p2 (C) (1 b1)L (1 b2)L p1 p2 (D) 1 (b1Lp1 + b2Lp2)
7.
A company has a class C network address of 204.204.204.0. It wishes to have three subnets, one with 100 hosts and two with 50 hosts each. Which one of the following options represents a feasible set of subnet address/subnet mask pairs? (A) 204.204.204.128/255.255.255.192 204.204.204.0/255.255.255.128 204.204.204.64/255.255.255.128 (B) 204.204.204.0/255.255.255.192 204.204.204.192/255.255.255.128 204.204.204.64/255.255.255.128 (C) 204.204.204.128/255.255.255.128 204.204.204.192/255.255.255.192 204.204.204.224/255.255.255.192 (D) 204.204.204.128/255.255.255.128 204.204.204.64/255.255.255.192 204.204.204.0/255.255.255.192 th
CS – 2006 8. For which of the following reason does Internet Protocol (IP) use the time-to-live (TTL) field in the IP datagram header? (A) Ensure packets reach destination within that time (B) Discard packet that reach later than that time (C) Prevent packets from looping indefinitely (D) Limit the time for which a packet gets queued in intermediate routers 9.
10.
Computer Networks
11.
A program on machine X attempts to open a UDP connection to port 5376 on a machine Y and a TCP connection to port 8632 on machine Z. However, there are no applications listening at the ports y and Z. An ICMP port Unreachable error will be generated by (A) Y but not Z (B) Z but not Y (C) Neither Y nor Z (D) Both Y and Z
12.
A subnetted Class B network has the following broadcast address: 144.16.95.255. Its subnet mask (A) is necessarily 255.255.224.0 (B) is necessarily 255.255.240.0 (C) is necessarily 255.255.248.0 (D) could be any one of 255.255.224.0, 255.255.240.0, 255.255.248.0
Two computers C1 and C2 are configured as follows. C1 has IP address 203.197.2.53 and netmask 255.255. 128.0. C2 has IP address 203.197.75.201 and netmask 255.255.192.0. Which one of the following statements is true? (A) C1 and C2 both assume they are on the same network (B) C2 assumes C1 is on same network, but C1 assumes C2 is on a different network (C) C1 assumes C2 is on same network, but C2 assumes C1 is on a different network (D) C1 and C2 both assume they are on different network
Statement for Linked Answer Questions 13 and 14: Consider the diagram shown below where a number of LANs are connected by (transparent) bridges. In order to avoid packets looping through circuit in the graph, the bridges organize themselves in a spanning tree. First, the root bridge is identified as the sends with the least serial number. Next, the root sends out (one or more) data unit to enable the setting up of the spanning tree of shortest paths from the root bridge to each bridge. Each bridge identifies a port (the root port) through which it will forward frames to the root bridge. Port conflicts are always resolved in favour of the port with the lower index value. When there is a possibility of a multiple bridge forwarding to the same LAN(but not 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.
A router uses the following routing table: Destination Mask Interface 144.16.0.0 255.255.0.0 Eth0 144.16.64.0 255.255.224.0 Eth1 144.16.68.0 255.255.255.0 Eth2 144.16.68.64 255.255.255.224 Eth3 A packet bearing a destination address 144.16.68.117 arrives at the router. On which interface will it be forwarded? (A) Eth0 (C) Eth2 (B) Eth1 (D) Eth3
CS – 2007 15. The address of a class B host is to be split into subnets with a 6 – bit subnet number. What is the maximum no. of subnets and the maximum no. of hosts in each subnet? (A) 62 subnets and 262142 hosts (B) 64 subnets and 262142 hosts (C) 62 subnets and 1022 hosts (D) 64 subnets and 1024 hosts 16.
Consider the following statements about the timeout value used in TCP. (i) The timeout value is set to the RTT (Round Trip Time) measured during TCP connection establishment for the entire duration of the connection. (ii) Appropriate RTT estimation algorithm is used to set the timeout value of a TCP connection. (iii) Timeout value is set to twice the propagation delay from the sender to the receiver Which of the following choices hold? (A) (i) is false, but (ii) and (iii) are true (B) (i) and (iii) are false, but (ii) is true (C) (i) and (ii) are false, but (iii) is true (D) (i), (ii) and (iii) are false
17.
Consider a TCP connection in a state where there are no outstanding ACKs. The 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,
Consider the correct spanning tree for the previous question. Let host H1 send out a broadcast ping packet Which of the following options represents the correct forwarding table on B3? (A) Port 3 1 2
For the given connection of LANs by bridges, which one of the following choices represents the depth first traversal of the a spanning tree of bridges? (A) B1, B5, B3, B4, B2 (B) B1, B3, B5, B2, B4 (C) B1, B5, B2, B3, B4 (D) B1, B3, B4, B5, B2
but the second segment was received correctly by the receiver. Let X is the amount of data carried in the first segment (in bytes) and Y is the ACK number sent by the receiver. The values of X and Y (in that order) are (A) 60 and 290 (C) 60 and 231 (B) 230 and 291 (D) 60 and 230 18.
Which one of the following uses UDP as the transport Protocol? (A) HTTP (C) DNS (B) Telnet (D) SMTP
CS – 2008 19. What is the maximum size of data that the application layer can pass on to the TCP layer below? (A) Any Size (B) 216 bytes – size of TCP header (C) 216 bytes (D) 1500 bytes 20.
If a class B network on the internet has a subnet mask 255.255.248.0, what is the max no. of hosts per subnet? (C) 2046 (A) 1022 (B) 1023 (D) 2047
21.
A client process P needs to make a TCP connection to a server process S. Consider the following situation: the server process S executes a socket(), a bind() & a listen() system call in that order, following which it is preempted. Subsequently, the client process P executes a socket() system call followed by connect( ) system call to connect to the server process S. The server process has not executed any accept() system call. Which one following events could take place? (A) connect() system call returns successfully (B) connect () system call blocks (C) connect() system call returns an error
Computer Networks
(D) connect() system call returns in a core dump 22.
In the slow start phase of the TCP congesting control algorithm the size of the congestion window (A) Does not increase (B) Increases linearly (C) Increases quadratic ally (D) Increases exponentially
23.
Which of the following system calls results in the sending of SYN packets? (A) socket (C) listen (B) blind (D) connect
CS – 2009 24. While operating a TCP connection, the initial sequence no. is to be derived using a time of day (TOD) clock that keeps running even when the host is down. The low order 32 bit of the counter of the TOD clock is to be used for the initial sequence numbers. The clock counter increments once per milli second. The maximum packet lifetime is given to be 64s. Which one of the choices given below is closest to the minimum permissible rate at which sequence numbers used for packets of a connection can increase? (A) 0.015/s (C) 0.135/s (B) 0.064/s (D) 0.327/s CS – 2010 25. One of the header fields in an IP datagram is the Time-to-Live (TTL) field. Which of the following statements best explains the need for this field? (A) It can be used to prioritize packets. (B) It can be used to reduce delays. (C) It can be used to optimize throughput. (D) It can be used to prevent packet looping.
Suppose computers A and B have IP addresses 10.105.1.113 and 10.105.1.91 respectively and they both use the same netmask N. Which of the values of N given below should not be used if A and B should belong to the same network? (A) 255.255.255.0 (B) 255.255.255.128 (C) 255.255.255.192 (D) 255.255.255.224
CS – 2012 27. In the IPV4 addressing format, the number of networks allowed under Class C address is (A) 2 (C) 2 (B) 2 (D) 2 28.
29.
Which of the following transport layer protocol is used to support electronic mail? (A) SMTP (C) TCP (B) IP (D) UDP Consider an instance of TCP’s Additive Increase Multiplicative Decrease (AIMD) algorithm where the window size at the start of the slow start phase is 2 MSS and the threshold at the start of the first transmission is 8 MSS. Assume that a timeout occurs during the fifth transmission. Find the congestion window size at the end of the tenth transmission. (A) 8 MSS (C) 7 MSS (B) 14 MSS (D) 12 MSS
CS – 2013 30. The transport layer protocols used for real time multimedia, file transfer, DNS and email, respectively are (A) TCP, UDP, UDP and TCP (B) UDP, TCP, TCP and UDP (C) UDP, TCP, UDP and TCP (D) TCP, UDP, TCP and UDP
31.
Computer Networks
In an IPv4 datagram, the M bit is 0, the value of HLEN is 10, the value of total length is 400 and the fragment offset value is 300. The position of the datagram, the sequence numbers of the first and the last bytes of the payload, respectively are (A) Last fragment, 2400 and 2789 (B) First fragment, 240 and 2759 (C) Last fragment, 2400 and 2759 (D) Middle fragment, 300 and 689
CS – 2014 32. Let the size of congestion window of a TCP connection be 32 KB when a timeout occurs. The round trip time of the connection is 100 msec and the maximum segment size used is 2 KB. The time taken (in msec) by the TCP connection to get back to 32 KB congestion window is _____. 33.
Which one of the following socket API function converts an unconnected active TCP socket into a passive socket? (A) Connect (C) Listen (B) Bind (D) Accept
34.
In the diagram shown below, L1 is an Ethernet LAN and L2 is a Token – Ring LAN. An IP packet originates from S and traverses to R, as shown. The links within each ISP and across the two ISPs, are all point – to – point optical links. The initial value of the TTL field is 32. The maximum possible value of the TTL field when R receives the datagram is ______. ISP1
ISP2 LAN L2
R
S LAN L1
35.
th
Host A (on TCP/IPV4 network A) sends an IP datagram D to host B (also on 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
different from that of the original datagram D? (i) TTL (ii) Checksum (iii) Fragment Offset (A) (i) only (B) (i) and (ii) only (C) (ii)and (iii) only (D) (i), (ii) and (iii) 36.
37.
Every host in an IPv4 network has a 1 second resolution real time clock with battery backup. Each host needs to generate up to 1000 unique identifiers per second. Assume that each host has a globally unique IPv4 address. Design a 50-bit globally unique ID for this purpose. After what period (in seconds) will the identifiers generated by a host wrap around?
Computer Networks
An IP router with a Maximum Transmission Unit (MTU) of 1500 bytes has received an IP packet of size 4404 bytes with an IP header of length 20 bytes. The values of the relevant fields in the header of the third IP fragment generated by the router for this packet are (A) MF bit: 0, Datagram Length: 1444; Offset: 370 (B) MF bit: 1, Datagram Length: 1424; Offset: 185 (C) MF bit: 1, Datagram Length: 1500; Offset: 370 (D) MF bit: 0, Datagram Length: 1424; Offset: 2960
Answer Keys & Explanations 1.
2.
3.
[Ans. B] In both TCP & UDP, packets of same session will be routed in different paths, because they are using IP protocol in the Network Layer which is purely a connection less protocol. Theoretically we say that TCP is connection oriented protocol, it doesn’t mean that packets of same session will travel in the same path, we are simulating the connection by using buffers at both sender and receiver. Finally TCP is using a Virtual connection. [Ans. D] ARP: Finding the MAC address that corresponds to an IP address [Ans. D] In a class B network initial two octets are all 1’s but third octet specifies the physical network for subnet of 64 department or 2 so initial 6 bits of third octets are 1’s 11111111 . 11111111 .11111100 . 00000000 255 . 255 . 252 . 0
4.
[Ans. C] ICMP reply packet is returned to A by each router en-router to B.
5.
[Ans. B] Congestion window = cwnd = 4KB Receiver window = rwnd = 6KB Current Window Size = min(cwnd, rwnd) = min(4KB, 6KB) = 4KB Just to confuse us they provided the additional information like Last Byte Sent and Last Byte Acknowledged, which are totally not required in finalizing the window size.
6.
[Ans. A] Probability (p via L = 1 b Probability (p via L = 1 b ∴ Probability p) via L or L = p
7.
p p p
[Ans. D] Class of network = class-C network [n=24, h=8] [25h hosts/Network] Network Address = 204.204.204.0 Requirement = 3 subnets
Subnet No of Hosts/Subnet 1 100 2 50 3 50 Types of subnetting = VLSM No of subnets = 2 No of hosts/subnet =2 2 2 – levels subnetting required. Initially Total Subnets = 2 2 2 n 1 1 bit to be taken from host n 25 h 8
9.
[Ans. C] The two computers configured as follows: IP address and
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
11.
[Ans. A] Because UDP generate the error that machine you are trying to reach is not responding unlike TCP.
12.
[Ans. D] Broadcast Address with in a network All host bits will be 1’s. ontinuous 1’s] We cannot confidently say the exact no. of network bits in a subnetted network. As all options are appropriate for the given question.
Broadcast Address = 144. 16.95.255 =144. 16. 01011111.11111111 Option A = 255. 255.224.0 =255.255.11100000.00000000 Option B = 255. 255.240.0 = 255.255.11110000.00000000 Option C = 255. 255.248.0 = 255.255.11111000.00000000 13.
2
2
1024
2
[Ans. B] TCP is using an appropriate RTT estimation algorithm to set the timeout value of a TCP connection. It is dynamic and will change with every segment. Initial value of RTT is greater than that of twice the propagation delay.
17.
[Ans. D] Difference between two consecutive packets is amount of data carried in first packet. Here, 290 – 230 = 60 X = 60 Y = 230
18.
[Ans. A] Application layer can pass data of Any Size to Transport Layer. The Transport Layer can send data of any size in multiple segments. Segmentation & Reassembly is the responsibility of Transport Layer to send data of any size given by the application layer.
19.
[Ans. B] The maximum size of data that the application layer can pass on to the TCP layer is 2 bytes – size of TCP header.
[Ans. A] By looking at the above diagram Bridge “ 3” will broadcast to all the hosts as follows:Hosts Port H1, H2, H3, H4 3 H5, H6, H9, H10 1 H7, H8, H11, H12 2
20.
[Ans. C] 11111111 . 11111111 . 11111000 . 00000000 ∴ No. of hosts per subnet =2 2 2048 2= 2046
21.
[Ans. C] Connect ( ) system call returns an error.
[Ans. C] The class B is defined as follows
22.
[Ans. D] In the slow start phase, the size of the congestion window increases exponentially.
23.
[Ans. D] Connect system call is responsible for synchronize the packets
[Ans. A] Spanning tree for the given diagram is as follows:B1
2
H1 H2
H3 H4 3
2 1
B5
B3 2
H5 H6
H7 H8
1
1
B4
B2
3
3
H9 H10
H11 H12
Three Possible Depth First Traversals are 1. 1 5 3 4 2 2. 1 3 4 2 5 3. 1 3 2 4 5 Possibility: 1 is matching with Option A. So obviously Answer = A
15.
2
16.
1
14.
2 1022
Computer Networks
0 1
16 0
net id
31
host id
Maximum number of subnet = 2 2 = 62 Maximum number of host in each subnet th
[Ans. B] 0.064 is closest to the minimum permissible rate at which sequence number used for packet of a connection can increase.
25.
[Ans. D] Whenever Time to live field reaches ‘0’ we discard the packet. So, it can be used to prevent packet looping
26.
27.
[Ans. C] Numbers of networks in class ‘ ’ are 2 as in class ‘ ’ there ⏟ ⏟ Out of 24 bits 3-bits are used for representation class ‘ ’ i.e. 110 ∴ 21 bits. With 21 bits we can make 2 networks
28. [Ans. D] IP address of A = 10.105.1.113 10.105.1.01110001 IP address of B = 10.105.1.91 10.105.1.0101011011 29. For finding network address we take AND of IP address with the netmask N. So we check one by one. (A) (i) 255.255.255.0 = N 10.105.1.01110001 Taking AND 10.105.1.00000000 IP address of A
[Ans. C] UDP and TCP are transport layer protocol. TCP supports electronic mail. ∴Option ‘ ’ correct [Ans. C] 1st 2 MSS } Slow Start 2nd 4 MSS 3rd 8 MSS 4th 9 MSS } additive increase 5 10 Time out threshold 8 4 6th 7th 8th 9th 10th
(ii) By taking and with B 255.255.255.00000000 10.105.1.01011011 10.105.1.00000000 So both belong to same network (B) (i) 255.255.255.128 255.255.255.10000000 10.105.1.01110001 IP of A 10.105.1.00000000 (ii) 255.255.255.10000000 10.105.1.01011011 IP of B 10.105.1.0000000 So both belong to same network
[Ans. C] Real time multimedia – UDP File transfer - TCP DNS – UDP Email – TCP
31.
[Ans. C] M = 0: Means to more fragmentation so it represent the last fragment. HLEN = 10: Header length 10 4 40 bytes Payload: 400 40 360 bytes [0 to 359] Fragment offset : 300 means 300 8 2400 bytes Sequence number of first fragment = 2400 Sequence number of last fragment = 2400 + 359 = 2759 Option (C) is correct
(D) (i) 255.255.255.11100000 10.105.1.01110001 IP of A 10.105.1.01100000 (ii) 255.255.255.11100000 10.105.1.010111011 IP of B 10.105.1.01100000 Both are not same so it not belong to same network
[Ans. D] Host A sends a datagram D to Host B and it has been delivered successfully. All the 3 given options can change while datagram “D” reaches ost “ ”. 1) TTL It decrements at every router. [Initial Value will be different from the final value] 2) Checksum As IPV4 header will be reconstructed at every router; obviously checksum also will be calculated at every router. So the initial value of checksum will be different from the final value. 3) Fragment Offset Any intermediate router can fragment the packet if packet size is greater than maximum transmission unit [MTU] of the next network. So obviously the initial value of fragment offset will be different from the final value.
36.
[Ans. 256] Given that each host has a globally unique IPV4 address and we have to design 50 – bit unique Id. So, 50 – bit in the sense (32 + 18). So, it is showing that IP Address (32 bit) followed by 18 bits. 1000 unique Ids 1 sec 2 unique ids 2 1000 2 256
100msec
100msec
100msec
100msec
1200 msec
33.
31
29 28
S LAN L1
100msec
100msec
[Ans. 26] Initial TTL Value = 32 TTL value will be decremented by 1 at each Router on the way to the Destination. TTL value will be 26 when packet reaches “R” 32
Round Trip Time
Slow-Start Phase Slow-Start Phase
Computer Networks
[Ans. C] The listen function converts an unconnected socket into a passive socket, indicating that the kernel should accept
[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
Application Layer CS –2005 1. A HTML form is to be designed to enable purchase of office stationery. Required items are to be selected (checked). Credit card details are to be entered and then the submit button is to be pressed. Which one of the following options would be appropriate for sending the data to the server? Assume that security is handled in a way that is transparent to the form design. (A) only GET (B) only POST (C) either of GET or POST (D) neither GET nor POST CS – 2006 2. HELO and PORT, respectively commands from the protocols (A) FTP and HTTP (B) TELNET and POP3 (C) HTTP and TELNET (D) SMTP and FTP
are
CS –2008 3. Provide the best matching between the entries in the two columns given in the table below: I Proxy Server a. Firewall II aZaA, D b. Caching III SLIP c. P2P IV DNS d. PPP (A) I a, II d, III c, IV b (B) I b, II d, III c, IV a (C) I a, II c, III d, IV b (D) I b, II c, III d, IV a CS –2010 4. Which one of the following is not a clientserver application? (A) Internet chat (C) E-mail (B) Web browsing (D) Ping
CS –2011 5. Consider different activities related to email m1: Send an email from a mail client to a mail server m2: Download an email form mailbox server to mail client m3: Checking email in a web browser Which is the application level protocol used in each activity? (A) m1: HTTP m2: SMTP m3: POP (B) m1: SMTP m2: FTP m3: HTTP (C) m1: SMTP m2: POP m3: HTTP (D) m1: POP m2: SMTP m3: IMAP CS –2012 6. The protocol data unit (PDU) for the application layer in the Internet stack is (A) Segment (C) Message (B) Datagram (D) Frame CS –2014 7. Identify the correct order in which the following actions take place in an interaction between a web browser and a web server. 1. The web browser requests a webpage using HTTP. 2. The web browser establishes a TCP connection with the web server. 3. The web server sends the requested webpage using HTTP. 4. The web browser resolves the domain name using DNS. (A) 4,2,1,3 (C) 4,1,2,3 (B) 1,2,3,4 (D) 2,4,1,3 8.
A graphical HTML browser resident at a network client machine Q accesses a static HTML webpage from a HTTP server S. The static HTML page has exactly one static embedded image which is also at S. Assuming no caching, which one of the following is correct about the HTML
webpage loading (including the embedded image)? (A) Q needs to send at least 2 HTTP requests to S, each necessarily in a separate TCP connection to server S (B) Q needs to send at least 2 HTTP requests to S, but a single TCP connection to server S is sufficient (C) A single HTTP request from Q to S is sufficient, and a single TCP connection between Q and S is necessary for this (D) A single HTTP request from Q to S is sufficient, and this is possible without any TCP connection between Q and S
9.
Computer Networks
An IP machine Q has a path to another IP machine H via three IP routers R1, R2, and R3. Q—R1—R2—R3—H H acts as an HTTP server, and Q connects to H via HTTP and downloads a file. Session layer encryption is used, with DES as the shared key encryption protocol. Consider the following four pieces of information: [I1] The URL of the file downloaded by Q [I2] The TCP port numbers at Q and H [I3] The IP addresses of Q and H [I4] The link layer addresses of Q and H Which of I1, I2, I3, and I4 can an intruder 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.
2.
[Ans. D] HELO and PORT commands are from the protocol SMTP and FTP.
3.
[Ans. D] Proxy server KaZaA, DC++ SLIP DNS
4.
5.
m3 Checking email in a web browser HTTP
[Ans. C] GET or POST can be used sending the data to the server.
aching P2P PPP irewall
[Ans. D] Ping is utility to check connectivity either between client-client or client-server
6.
[Ans. C] PDU is called a message in application layer, segment in transport layer, datagram in network layer and frame in data link layer
7.
[Ans. A] Firstly DNS will translate the URL into IP address, then TCP connection will be established. After that browser will request for webpage and at the end server will respond for request
8.
[Ans. B] Q: Client Accessing a Static HTML web page from HTTP Server S: Server Static HTML page has exactly one Static mbedded Image located in “S” only No Caching How HTML Web Page Loads? HTTP Uses TCP Protocol 1-TCP Connection must be established first
[Ans. C] m1 Send an email from a mail client to a mail server SMTP m2 Download an email from a mail client to a mail server POP
[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.
Network Security CS -2005 1. Suppose that two parties A and B wish to setup a common secret key (D-H key) between themselves using the DiffieHellman key exchange technique. They agree on 7 as the modulus and 3 as the primitive root. Party A chooses 2 and party B chooses 5 as their respective secrets. Their D-H key is: (A) 3 (C) 5 (B) 4 (D) 6
CS -2008 4. The total number of keys required for a set of n individuals to be able to communicate with each other using secret key and public key cryptosystems, respectively are : (A) n (n 1) and 2n
CS -2007 2. Exponentiation is a heavily used operation in public key cryptography. Which of the following options is the tightest upper bound on the no. of multiplications required to compute b modulo m, 0≤b, n≤m? (A) O (log n) (C) O (n/log n) (D) O (n) (B) O (√n )
CS -2009 5. In the RSA public key cryptosystem, the private & public keys are (e, n) & (d, n) respectively, where n=p * q and p and q are large primes. Besides, n is public & p & q are private . Let M be an integer such that 0
3.
A firewall is to be configured to allow host in a private network to freely open TCP connections & send packets on open connections. However, it will only allow external hosts to send packets on existing open TCP connections or connections that are being opened (by internal host ) but not allow them to open TCP connections to hosts in the private network. To achieve this he minimum capability of the firewall should be that of (A) A combinational circuit (B) A finite automation (C) A pushdown automation with one stack (D) A pushdown automation with two stacks
(B) 2n and (C)
and 2n
(D)
and n
CS -2011 6. A layer-4 firewall (a device that can look at all protocol headers up to the transport layer ) CANNOT (A) Block entire HTTP traffic during 9:00 PM and 5:00 AM (B) Block all ICMP traffic (C) Stop incoming traffic from a specific IP address but allow outgoing traffic to the same IP address (D) Block TCP traffic from a specific user on a multi-user system during 9:00PM and 5:00AM
CS -2013 7. Using public key cryptography, X adds a digital signature to message M, encrypts 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 (D) R and S only (B) Q and R only
[Ans. B] p=7 g = primitive root = 3 Party A chooses = a = 2 Party B choose = b = 5 D-H Key = k =? k= g (mod p) = 3 (mod 7) = 4
2.
[Ans. C] O(n/ log n) is the tightest upper bound.
3.
[Ans. D] A pushdown automata with two stacks
4.
[Ans. C]
8.
[Ans. C] RSA (Rivert, Shamir, Adleman) is a public – key crypto system. SHA – 1 (Secure Hash Algorithm) is a hash function to generate a message digest DES (Data Encryption standard) is a symmetric key algorithm for encryption MD5 is a message – digest algorithm
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
Introduction to Compilers CS-2005 1. Consider line number 3 of the following C –program. int min( ){ /* Line 1 */; int I, n; /* Line 2 */; fro(I=0, I
CS-2011 3. In a complier, keywords of a language are recognized during (A) Parsing of the program (B) The code generation (C) The lexical analysis of the program (D) Dataflow analysis CS-2014 4. Which one of the following is NOT performed during compilation? (A) Dynamic memory allocation (B) Type checking (C) Symbol table management (D) Inline expansion
Answers Keys & Explanations 1.
2.
[Ans. C] In 2nd line no mis-spelling is there. It is int only. Error is underlined function fro ( ) which is a syntactical error rather than lexical so correct option is C. [Ans. B] As we know symbol table is a Data structure containing record for each identifier, with fields for the attribute of the identifier. The symbols entered into
symbol table are nothing but identifier and operators. It contains information about variables and their attributes. 3.
[Ans. C] Keywords are recognized during lexical analysis
4.
[Ans. A] Dynamic memory allocation is performed at run time not on compile time.
Syntax Analysis CS-2005 1. The grammar A AA |(A)|ε is not suitable for predictive-parsing because the grammar is (A) ambiguous (B) left-recursive (C) right-recursive (D) an operator-grammar 2.
3.
Consider the grammar E E + n|E n|n For a sentence n + n n, the handles in the right-sentential form of the reduction are (A) n, E + n and E + n n (B) n, E + n and E + E n (C) n, n + n and n + n n (D) n, E + n and E n
5.
Consider the following grammar S → FR R → *S | ε F → id In the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $] respectively (A) {S → FR} and {R →ε} (B) {S → FR} and { } (C) {S → FR} and {R → *S} (D) {F → id} and {R →ε} Linked Answer Questions 6 and 7 Which one of the following grammars generates the language L = {aibj | i j }? (A) S→ A | → a b|a|b A → aA| → b| (B) S → aS|Sb|a|b (C) S → A | → a b| A → aA| → b| (D) S → A | → a b| A → aA|a → b|b
6.
Consider the grammar S (S) | a Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good (A) n1< n2< n3 (C) n1 = n2 = n3 (B) n1 = n3< n2 (D) n1 n3 n2
CS-2006 4. Consider the following grammar. S S*E SE E F + E E F F id Consider the following LR(0) items corresponding to the grammar above. (i) S S*.E (ii) E F.+E (iii) E F+.E Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar? (A) (i) and(ii) (C) (i) and (iii) (B) (ii) and (iii) (D) None of these
7.
In the correct grammar above, what is the length of the derivation (number of steps starting from S) to generate the string a bm with l m? (A) max (l,m) + 2 (C) l + m + 3 (B) l + m + 2 (D) max (l, m) + 3
CS-2007 8. Which one of the following is a top-down parser? (A) Recursive descent parser (B) Operator precedence parser (C) An LR(k) parser (D) An LALR(k) parser
Consider the grammar with non-terminals N = {S,C,S }, terminals T = {a,b,i,t,e}, with S as the start symbol, and the following set of rules S iCtSS1| a S1eS| ε Cb The grammar is NOT LL(1) because: (A) It is left recursive (B) It is right recursive (C) It is ambiguous (D) It is not context-free
10.
Consider the following two statements: P : Every regular grammar is LL(1) Q : Every regular set has LR(1) grammar Which of the following is TRUE? (A) Both P and Q are true (B) P is true and Q is false (C) P is false and Q is true (D) Both P and Q are false
CS-2008 13. Which of the following describes a handle (as applicable to LRparsing) appropriately? (A) It is the position in a sentential form where the next shift or reduce operation will occur (B) It is a non-terminal whose production will be used for reduction in the next step (C) It is a production that may be used for reduction in a future step along with a position in the sentential form where the next shift or reduce operation will occur. (D) It is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found. 14.
Linked Answer Questions Q.11 & Q.12 Consider the CFG with {S,A,B} as the nonterminal alphabet, {a,b} as the terminal alphabet, S as the start symbol and the following set of production rules : S aB S bA B b A a B bS A aS B aBB A bAA 11.
Which of the following strings is generated by the grammar? (A) aaaabb (C) aabbab (B) aabbbb (D) abbbba
12.
For the correct answer string to above Q. 11 how many derivation trees are there? (A) 1 (C) 3 (B) 2 (D) 4
Compiler Design
An LALR(1) parser for a grammar G can have shift reduce (S-R) conflicts if & only if (A) The SLR(1) parser G has S-R conflicts (B) The LR(1) parser for G has S-R conflicts (C) The LR(0) parser for G has S-R conflicts (D) The LALR(1) parser for G has reduce-reduce conflicts
CS-2010 15. The grammar S → aSa | bS | c is (A) LL(1) but not LR(1) (B) LR (1) but not LL(1) (C) Both LL(1) and LR(1) (D) Neither LL(1) nor LR(1) CS-2012 Statement for Linked Answer Question 16 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
and, |separates alternate right hand side of productions. S→ a A b B | b A a B | ε A→S B→S a B $ s
E1
E2
S→ε
A
A→S
A→S
Error
B
→S
→S
E3
CS-2013 18. What is the maximum number of reduce moves that can be taken by a bottom – up parser for a grammar with no epsilon and unit production (i.e., of type A→ε and A → a )to parse a string with n tokens? (A) n/2 (C) 2n – 1 (B) n – 1 (D) 19.
16.
The FIRST and FOLLOW sets for the nonterminals A and B are (A) FIRST(A) = {a,b,ε} = FIRST(B) FOLLOW (A) = {a,b} FOLLOW (B) = {a,b,$} (B) FIRST(A) = {a,b,$} FIRST (B) = {a,b,ε} FOLLOW (A) = {a, b} FOLLOW (B) = {$} (C) FIRST(A) = {a,b,ε} = FIRST(B) FOLLOW(A) = {a,b} FOLLOW(B) = (D) FIRST(A) = {a,b,ε} = FIRST(B) FOLLOW(A) = {a,b} FOLLOW(B) = {a,b}
Consider the following two sets of LR(1) items of an LR(1) grammar. X→ c. X, c|d X →c.X,$ X→ .c X, c|d X →.cX,$ X→ .d, c|d X →.d,$ Which of the following statement related to merging of the two sets in the corresponding LALR parser is / are FALSE? 1. Cannot be merged since look aheads are different 2. Can be merged but will result in S –R conflict 3. Can be merged but will result in R –R conflict 4. Cannot be merged since goto on c will lead to two different sets. (A) 1 only (C) 1 and 4 only (B) 2 only (D) 1, 2,3 and 4
CS-2014 20. A canonical set of items is given below S→ . R → R. On input symbol < the set has (A) a shift-reduce conflict and a reduce-reduce conflict. (B) a shift-reduce conflict but not a reduce-reduce conflict. (C) a reduce-reduce conflict but not a shift-reduce conflict. (D) neither a shift-reduce nor a reducereduce conflict.
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] Given grammar is Ambiguous,that is the reason that it is not suitable for Predictive paring.
2.
[Ans. D] E E+n|E×n|n Input String n + n × n E + n × n reduction E n E×n reduction E E+n E reduction E E×n So the reduction are n, E + n, E × n
3.
[Ans. B] S (S) | a Parsers No. of States SLR (1) n LR(1) n LALR(1) n The number of states of deterministic finite automata in SLR (1) and LALR (1) parsers are equal, so n n . The number of states of deterministic finite automata in LR (1) or canonical LR is greater than the number of states of deterministic finite automata of SLR(1) and LALR(1) So n n n .
4.
[Ans. D] Construct the canonical set-of-items and observe the same.
5.
[Ans. A] Construct Predictive parser table as follows Nonterminal Id * $ S S FR R R *S R ε F F id So M[S, id] = {S FR} and M[R, $] = {R ε}
6.
[Ans. D] S→A | → a b| A → aA|a → b|b From the above grammar, ( ) *a b + → a b| (A) a A → aA|a ( ) b → b|b By substituting C, A and B in S. S → AC L(S) = {ambn| m > n} (S) *a b |m n+ S→ (S) *a b |m n or m n+ *a b |i
[Ans. A] In the q no. 6 if grammar generates a b or a b then the length is max (l, m) if it generates a b initially we include two extra derivation so the total length is max (l, m) + 2.
lm aabbab. lm So aabbab is generated by the grammar. 12.
[Ans. A] Predictive parser and recursive descent parser are example of top-down parser. Where as LR(k) and LALR(k) parser are bottom up parser
[Ans. B] There are two parse trees for the string aabbab from left most derivation and one from right most derivation. S
B
a
[Ans. A] S i C t SS | a S eS | ∈ C b S
i C t SS
S
i b t SS [apply C
Compiler Design
a
B
B
b
S
b
A
b
b]
a
After second step of derivation i, b, t are terminals but the left nonterminal symbol is S so grammar it left recursive after step 2. It is noted that in some cases we can’t observe the left recursion in initial step of derivation but after some step of derivation we can seen the left recursion.
S B a a
b
10.
11.
[Ans. A] Regular grammar is well recognized by LL(1) parsers and LR (1) parser is stronger and more than powerful than LL (1) so regular grammar is also accepted by LR (1) parser. Every regular set has LR (1) grammar. So both statements are correct. [Ans. C] S aB lm aaBB lm aabB lm aabbS lm aabbaB
B
B
S
b a
B b
13.
[Ans. D] Definition of handle is given in (D) option.
14.
[Ans. B] LALR (1) parser uses the LR (1) items. So LALR (1) parser or for a grammar G can have S-R conflict if add only if the LR (1) parser for G has S-R conflicts.
15.
[Ans. C] S → aSa|bS|c The above grammar is LL (1) because, First ,aSa- ∩ first ,bS- (a) ∩ (b) &&
First ,bS- ∩ first ,c- (b) ∩ (c) && First ,c- first ,aSa- (c) ∩ (a) = As the above grammar is LL(1), also LR (1) because LL(1) grammar is always LR (1) grammar. 16.
17.
A B
b S → bAa S→ A→S →S
X →c.X, $ X → .c.X, $ X → .d, $
X →.cX, c|d X → .cX, c|d |$ X → .d, c|d | $
1.
2.
[Ans. C] S → aAb | bAa | ε A→S B→S LL(1) Parsing table: a S → aAb S→ A→S →S
[Ans. D] X →c.X, c|d X → .cX, c|d X → .d, c|d
[Ans. A] S → aAbB | bAaB |ε A→S B→S First of S = {a, b, ε} First of A = {a, b, ε} First of B = {a, b, ε} Follow of S = {$, a, b} Follow of A = {b, a} Follow of B = {$, a, b}
S
18.
19.
Compiler Design
3. 4.
$ S→ error →S
[Ans. B] If n tokens are there in string, then one reduction is required for each token. But at the end two tokens will be reduced to two terminals because grammar does not have any unit production. So for last two token =1 ) For remaining (n ) tokens = (n
Merging of two state depends on core part (production rule with dotoperator), not on look ahead. The two states are not containing reduce item, so after merging the merged state cannotcontain any S – R conflict As there is no Reduce item in any of the state, so can’t have R – R conflict Merging of state does not depend on further goto on any terminal. So all statements are false
20.
[Ans. D] No any conflict, because both items will be in different states of canonical sets.
21.
[Ans. B] Consider the following derivation tree S T T
Total = 1 + n – 2 =n 1
*
U
P
* U
Q
id
id
P
+ Q id
id
+
P Q id
String = (id ∗ id) ∗ (id (id id)) ‘*’ is left associative ‘ ’ is right associative
Syntax Directed Translation CS-2005 Linked Answer Questions 1 & 2 Consider the following expression grammar. The semantic rules for expression calculation are stated next to each grammar production. E number | |
The above grammar and the semantic rules are fed to a yacc tool (Which is an LALR(1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar? (A) It detects recursion and eliminates recursion (B) It detects reduce-reduce conflict, and resolves (C) It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action (D) It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action Assume the conflicts in Q.1 are resolved and an LALR (1) parser is generated for parsing arithmetic expressions as per the given grammar. Consider an expression 3 2 + 1. What precedence and associativity properties does the generated parser realize? (A) Equal precedence and left associativity; expression is evaluated to 7 (B) Equal precedence and right associativity; expression is evaluated to 9 (C) Precedence of is higher than that of , and both operators are left associative; expression is evaluated to 7
(D) Precedence of is higher than that of , and both operators are left associative; expression is evaluated to 9 CS-2006 3. Consider the following translation scheme. S→ R R → * *print *‘*’); R | ε E→ F *print (‘ ’); }| F F→ (S) | id {print (id.value);} Here id is a token that represents an integer and id.value represents the corresponding integer value. For an input ‘ * 3 4’, this translation scheme prints (A) 2 * 3 + 4 (C) 2 3 * 4 + (B) 2 * + 3 4 (D) 2 3 4 + * CS-2008 4. Which of following are true? I. A programming language which does not permit global variables of any kind & has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation II. Multi-level access link(or display) arrangement is needed to arrange activation records only if the programming language being implemented has nesting of producers/ functions III. Recursion in programming languages cannot be implemented with dynamic storage allocation. IV. Nesting of producers/ functions & recursion require a dynamic heap allocation scheme and cannot be implemented with a stack based allocation scheme for activation records V. Programming languages which permits a function to return a th
function as its result cannot be implemented with a stack based storage allocation scheme for activation records (II) & (V) only (I),(III) & (IV) only (I),(II) & (V) only (II),(III) & (V) only
Answer Keys & Explanations 1.
[Ans. C] E number | ‘ ’ | ‘ ’ Then A compiler detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action. Consider the following configuration where shiftreduce conflict occurs Stack Input … × …$
2.
[Ans. C] With look ahead we would prefer to shift because the look ahead has higher precedence than × over + and both operation are left associative. So expression 3 6 7 will be evaluated.
3.
[Ans. D]
So an input 2 * 3 + 4, it prints from the above parse tree as 234 +*. 4.
[Ans. A] Consider each statement separately I. If a programming language doesn’t permit global variables and no nesting procedures then we can’t use the recursion with static storage because there is no stack support. For example Fortran doesn’t support the recursion. So statement is false II. Statement is true. III. Recursion in programming languages will be implemented with dynamic storage. For example C language implement recursion with the help of heap if size is also increases because heap stores the all activation records of a recursion. So statement is false. IV. Statement is false because we can implement recursion either with the help of heap or a stack. V. Statement is true.
Intermediate Code Generation CS-2006 1. Consider the following C code segment. for(i=0; i
Consider these two functions and two statements S1 and S2 about them. int work1(int *a, int i, int j) { int x = a [i + 2]; a[ j ] = x + 1 ; return a [i+2] 3; } int work2 (int *a, int i, int j) { int t1 = i + 2; int t2= a [t1]; a [ j] = t2 1; return t2 3; } S1: The transformation from work 1 to work2 is valid, i.e., for any program state and input arguments, work2 will compute 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
the performance (i.e. reduce CPU time) of work2 compared to work1 (A) S1 is false and S2 is false (B) S1 is false and S2 is true (C) S1 is true and S2 is false (D) S1 is true and S2 is true CS-2008 3. Some code optimizations are carried out on the intermediate code because (A) They enhance the portability of the compiler to other target processors (B) Program analysis is more accurate on intermediate code than on machine code (C) The information from data flow analysis cannot otherwise be used for optimization (D) The information from the front end cannot otherwise be used for optimization CS-2009 4. Which of the following statements are TRUE? I. There exists parsing algorithm for some programming languages whose complexities are less than θ(n3) II. A programming language which allows recursion to be implemented with static storage allocation III. No L-attributed definition can be evaluated in the framework of bottom-up parsing IV. Code improving transformations can be performed at both source language & intermediate code level (A) I & II (C) III & IV (B) I & IV (D) I, III & IV
CS-2010 5. Which languages necessarily need heap allocation in the runtime environment? (A) Those that support recursion. (B) Those that use dynamic scoping. (C) Those that allow dynamic data structures. (D) Those that use global variables. CS-2011 6. Consider two binary operators ‘ ’ and ' ' with the precedence of operator being lower than that of the operator . Operator is right associative while operator is left associative. Which one of the following represents the parse tree for expression (7 3 4 3 )
(A)
c a b; d c ∗ a; e c a; x c ∗ c; if (x a) * y a ∗ a; + else { d d ∗ d; e e ∗ e; } 7.
Suppose the instruction set architecture of the processor has only two registers. The only allowed compiler optimization is code motion, which moves statements from one place to another while preserving correctness. What is the minimum number of spills to memory in the compiled code? (A) 0 (C) 2 (B) 1 (D) 3
8.
What is the minimum number of register needed in the instruction set architecture of the processor to compile this code segment without any spill to memory? Do not apply any optimization other than optimizing register allocation (A) 3 (C) 5 (B) 4 (D) 6
(B) 7 2 3
7 4
3 3
4
2
(C)
3
(D) 2
7 2 3 3 4 3
4 7
3
CS-2013 Common Data for Questions 7 & 8 The following code segment is executed on a processor which allows only register operands in its instructions. Each instruction can have almost two source operands and one destination operand. Assume that all variables are dead after this code segment.
Compiler Design
CS-2014 9. One of the purposes of using intermediate code in compilers is to (A) make parsing and semantic analysis simpler. (B) Improve error recovery and error reporting. (C) Increase the chances of reusing the machine-independent code optimizer in other compilers. (D) Improve the register allocation.
Consider the basic block given below. a b c c a d d b c e d b a e b The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are (A) 6 and 6 (C) 9 and 12 (B) 8 and 10 (D) 4and4
11.
Compiler Design
Which one of the following is FALSE? (A) A basic block is a sequence of instructions where control enters the sequence at the beginning and exits at the end. (B) Available expression analysis can be used for common sub expression elimination. (C) Live variable analysis can be used for dead code elimination. (D) x 4 ∗ 5 x 0 is an example of common sub expression elimination.
Answer Keys & Explanations 1.
2.
[Ans. D] (A) i%2 is inner loop invariant, it can be moved before inner loop (B) 4*j is common sub – expression appeared in two statements (C) 4*j can be reduced to j<<2 by strength reduction. (D) There is no dead code in given code segment. So there is not scope of dead code elimination in this code. Hence only option (D) is FALSE. [Ans. D] Both work1 and work2 performs the same task so S1 is true. But code in work2 will improve performance. In work1: int x = a[i+2]; Here a[i+2] is computed twice. return a[i + 2] – 1 In work2; t i t a,t -; return t 3 Therefore option S2 is also correct.
3.
[Ans. B] Some code optimizations are carried out on the intermediate code because program analysis is more accurate on intermediate code than on machine code.
4.
[Ans. B] Recursion cannot be implemented with static storage allocation. L – attributed definition can be evaluated if all rules are at the end and all attributes are synthesized. So I and IV are correct.
5.
[Ans. C] Runtime environment mean we deal with dynamic memory allocation and heap is a dynamic data structure. So it is clear that those languages that allow dynamic data structure necessarily need heap allocation in the runtime environment.
[Ans. B] c a b; x c ∗ c; if (x a) *… … (i) y a ∗ a; + else { d c ∗ a; e c a; … … . (ii) d d ∗ d; e e ∗ e; + (i) Is to store c*c, it needs one memory spill. (ii) Is uses previous same(i) memory 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.
10.
Compiler Design
[Ans. A] e, d c
a, d
d
b
11.
th
c
[Ans. D] x=4*5 x= 20 is the example of constant folding not of common sub expression elimination
Introduction to Software and Software Engineering CS-2009 1. The coupling between different modules as a software is categorized as follows I. Content coupling II. Common coupling III. Control coupling IV. Stamp coupling V. Data coupling Coupling between modules can be ranked in the order as strong (least desirable) to weakest (most desirable) as follows (A) I – II – III – IV - V (B) V – IV – III – II – I (C) I – III – V – II – IV (D) IV – II – V – III – I CS-2014 2. Match the following: 1) Waterfall a) model
2)
Evolutionary model
b)
3)
Componentbased software engineering Spiral development
c)
4)
d)
3.
Which one of the following is TRUE? (A) The requirements document also describes how the requirements that are listed in the document are implemented efficiently. (B) Consistency and completeness of functional requirements are always achieved in practice. (C) Prototyping is a method of requirements validation. (D) Requirements review is carried out to find the errors in system design.
4.
In the context of modular software design, which one of the following combinations is desirable? (A) High cohesion and high coupling (B) High cohesion and low coupling (C) Low cohesion and high coupling (D) Low cohesion and low coupling
Specifications can be developed incrementally Requirements compromises are inevitable Explicit recognition of risk Inflexible partitioning of the project into stages
[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
Content coupling
Common coupling
Control coupling
Stamp coupling
Low coupling
Data coupling
Procedural cell Inclusion coupling coupling
External coupling
Coupling spectrum
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
Process Modeling CS – 2009 1. Consider the following statements about the Cyclomatic complexity of the control flow graph as a program module. Which of these are true? I. The Cyclomatic complexity of a module is level to maximum number of linear independent circuits in a graph. II. The Cyclomatic complexity of a module is the number of decisions in the module plus one where a decision is effectively any conditional statement in the module. III. The Cyclomatic complexity can also be used as a number of linearly independent paths that should be tested during path coverage testing. (A) I &II (C) I & III (B) II & III (D) I, II & III
CS – 2011 3. Which one of the following is NOT defined in a correct good Software Requirement Specification (SRS) document? (A) Functional Requirement (B) Non - Functional Requirements (C) Goals of Implementation (D) Algorithms for software Implementation CS – 2013 4. The following figure represents access graphs of two modules M1 and M2. The filled circles represent methods and the unfilled circles represent attributes. If method m is moved to module M2 keeping the attributes where they are, what can we say about the average cohesion and coupling between modules in the system of two modules? Module M1
CS – 2010 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.
Module M2
m
(A) There is no change. (B) Average cohesion goes up but coupling is reduced. (C) Average cohesion goes down and coupling also reduces. (D) Average cohesion and coupling increased.
[Ans. B] Cyclomatic complexity V(c) can be evaluated by
4.
[Ans. A] If a method m is moved to module M2 by Keeping the attributes where they are average cohesion and coupling between modules will not change in the system. Cohesion M2 and M1 are interchanged but average cohesion will be the same for the given system after moving the method m to module M2
V(c) = Number of internal persons +1 External Regions 2.
[Ans. A] 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
A
B
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.
Project Management CS-2009 1. Which of the following statements are true? I. The context diagram should depict the system as a single bubble. II. External entities should be identified clearly at all levels of DFDs III. Control information should not be represented in a DFD IV. A data store can be connected either to another data store or to an external entity. (A) II & III (C) I & III (B) I, II & IV (D) I, II & III
(A) 4000 (B) 5000 3.
(C) 4333 (D) 4667
A company needs to develop digital signal processing software for one of its newest inventions. The software is expected to have 40000 lines of code. The company needs to determine the effort in person months needed to develop this software using basic COCOMO model. The multiplicative factor for this model is given as 2.8 for the software development on embedded systems, while the exponentiation factor is given as 1.20. What is the estimated effort in person months? (A) 234.25 (C) 287.80 (B) 932.50 (D) 122.40
CS-2011 2. A company needs to develop a strategy for Software Product development for which it 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 for which the cost of the project intenance using L is equal to the cost of the project 1 year using ?
[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
Validation and Verification CS - 2010 1. What is the appropriate paring of items in the two columns listing various activities encountered in a software use cycle. P. Requirements 1. Module Capture development & integration Q. Design 2. Domain Analysis R. Implementation 3. Structures & Behavioral Modeling S. Maintenance 4. Performance Tuning (A) (B) (C) (D) 2.
The following program is to be tested for statement coverage: Begin if (a==b),{S1;exit; } else if(c==d){S2;} else {S3; exit;} S4; end The test cases T1, T2, T3& T4 given below are expressed in terms of the properties satisfied by the values of variables a, b, c & d. The exact values are not given. T1: a, b, c & d are all equal T2: a, b, c & d are all distinct T3: a = b &c != d T4 : a!=b & c = d Which of the test suites given below ensures coverage of statements S1, S2, S3& S4. (A) T1,T2,T3 (C) T3,T4 (B) T2,T4 (D) T1,T2,T4
CS - 2011 3. The following is comment written for a C function. /*This function computes the roots of quadratic equation. ax2 + bx + c = 0 the function stores two real roots in * root1 & * root2 & returns the status of validity of roots. In handles four different kinds of cases i. When coefficient a is zero irrespective of discriminant ii. When discriminant is positive. iii. When discriminant is zero iv. When discriminant is negative Only in cases (ii) & (iii) the stored roots are valid otherwise 0 is stored in the roots. The function returns 0 when the roots are valid & 1 otherwise. The function also ensures root1 >= root2 int get_QuadRoots (float a, float b, float c, float *root 1, float *root2)*/ A software test engineer is assigned the job of doing black box testing. He comes up with the following test cases, many of which are redundant Test Input set Expected output set case a b c Root Root 2 Return 1 value T1 0.0 0.0 7.0 0.0 0.0 1 T2 0.0 1.0 3.0 0.0 0.0 1 T3 1.0 2.0 1.0 1.0 1.0 0 T4 4.0 12.0 9.0 1.5 1.5 0 T5 1.0 2.0 3.0 3.0 1.0 0 T6 1.0 1.0 4.0 0.0 0.0 1 Which one of the following options provide the set of non – redundant tests using equivalence class partitioning approach from input perspective for black testing? (A) T1, T2, T3, T6 (C) T2, T4, T5, T6 (B) T1, T3, T4, T5 (D) T2, T3, T4, T5
CS - 2013 Common Data for Question 4 and 5 The procedure given below is required to find and replace certain characters inside an input character string supplied in array A. The characters to be replaced are supplied in array oldc, while their respective replacement characters are supplied in array newc. Array A has a fixed length of five characters, while arrays oldc and newc contains three characters each. However, the procedure is flawed. void find_and_replace (char *A, char *oldc, char *newc) { for (int i = 0 ; i < 5 ; i++) for (int j = 0 ; j < 3 ; j++) if (A[i] == oldc [j]) A [i] = newc[j] ; } The procedure is tested with the following four test cases.
4.
5.
SE & WT
1. “ ” w “ ” 2. “ ” w “ ” 3. “ ” w “ ” 4. “ ” w “ ” The tester now tests the program on all input strings of length five consisting of h ‘ ’ ‘ ’ ‘ ’ ‘ ’ ‘ ’ w h duplicates allowed. If the tester carries out this testing with the four test cases given above, how many test cases will be able to capture the flaw? (A) Only one (C) Only three (B) Only two (D) All four If array A is made to hold the string “ ” which of the above four test cases will be successful in exposing the flaw in this procedure? (A) None (C) 3 and 4 only (B) 2 only (D) 4 only
Answer keys and Explanations 1.
2.
[Ans. B] These are all the activities encountered in a software life cycle. Requirement capture means requirement analysis we gather the information about a particular domain.
4.
[Ans. B] 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 or not, flaw is due to oldc and newc string only. Flaw is in test case 3 and 4. “ ” i = 0, j = 0 A[0] = a oldc [0] = b a i = 0, j = 1 A[0] = a
[Ans. D] h h h h
3.
[Ans. C] T1, & T2 checking same condition a = 0 hence, any one of T1 & T2 is redundant T3 and T4: in both cases discriminant (D) = b2 4ac = 0 Hence any one of it is redundant. T5 : D > 0 T6: D < 0 th
oldc [1] = c a c i=0j=2 A[0] = a oldc [2] = a A [0] == oldc[2] 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.
SE & WT
i= 0 j = 1 a [0] = b a [0] = oldc[1] a [0] = newc[1] array content abcde flow a two replacements
[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
HTML Structure CS - 2005 1. Consider the three commands: PROMPT, HEAD and RCPT. Which of the following options indicate a correct association of these commands with protocols where these are used? (A) HTTP, SMTP, FTP (B) FTP, HTTP, SMTP (C) HTTP, FTP, SMTP (D) SMTP, HTTP, FTP CS - 2009 2. Consider the HTML table definition given below:
ab
cd
ef
gh
ij
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)
CS - 2011 3. HTML (Hyper Text Markup language) has language elements which permit certain actions other than describing the structure of the web document. Which one of the actions is NOT supported by pure HTML (without any client or server side scripting) pages? (A) Embed web objects from different sites into same page (B) Refresh the page automatically after a specified interval (C) Automatically redirect to another page upon download (D) Display the client time as part of the page
[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.