GATE Chapter-wise Computer Science and Information Technology Solved Papers (2000-2020) 9788126575428, 9788126595433

372 86 29MB

English Pages [411]

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

GATE Chapter-wise Computer Science and Information Technology Solved Papers (2000-2020)
 9788126575428, 9788126595433

Table of contents :
Front Cover
TCY's Unique Success Mantra
Title Page
Copyright
Note to the Aspirants
Contents
C H A P T E R 1 Engineering Mathematics
C H A P T E R 2 Digital Logic
C H A P T E R 3 Computer Organizationand Architecture
C H A P T E R 4 Programming and DataStructures
C H A P T E R 5 Algorithms
C H A P T E R 6 Theory of Computation
C H A P T E R 7 Compiler Design
C H A P T E R 8 Operating System
C H A P T E R 9 Databases
C H A P T E R 10 Computer Networks
APPENDIX Solved GATE (CSIT) 2019
APPENDIX Solved GATE (CSIT) 2020
Back Cover

Citation preview

GATE The Graduate Aptitude Test in Engineering (GATE) is an All-India level examination for engineering graduates aspiring to pursue Master’s or Ph.D. programmes in India. The Public Sector Undertakings (PSU’s) also use GATE used as a recruiting examination. The examination is highly competitive, and the GATE score plays an important role in fulfilling the academic and professional aspirations of the students. This book is aimed at supporting the efforts of GATE aspirants in achieving a high GATE score. The book comprises previous years’ (2000 to 2020) GATE questions in Computer Science and Information Technology covered chapter-wise with detailed solutions. Each chapter begins with a detailed year-wise analysis of topics on which questions are based and is followed by listing of important formulas and concepts for that chapter. The book is designed to make the students well-versed with the pattern of examination, level of questions asked and the concept distribution of questions and thus bring greater focus to their preparation. It aims to be a must-have resource for an essential step in their preparation, that is, solving and practicing previous years’ papers.

Salient Features Chapter-wise coverage of GATE Computer Science and Information Technology previous years’ questions (2000 to 2018). Chapter-wise 2019 and 2020 GATE papers available as appendix

l

Chapter on Engineering Mathematics included for complete coverage of the technical section of the GATE paper

l

Detailed topic-wise analysis of questions for each chapter

l

Important Formulas and Concepts summarized for easy recall in each chapter

l

All questions marked for level of difficulty (i.e. 1 Mark or 2 Marks)

l

Detailed solutions for all questions, tagged topic-wise

l

Packaged with unique scratch code for free 7-day subscription for online GATE tests

CHAPTER-WISE SOLVED PAPERS

(2000-2020)

eISBN 978-81-265-9543-3

9 788126 595433

Inside

Verma,Sharma, Singh

Wiley India Pvt. Ltd. Customer Care +91 120 6291100 [email protected] www.wileyindia.com www.wiley.com

GATE

COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

CHAPTER-WISE SOLVED PAPERS (2000-2020)

l

COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

About the Book

Anil Kumar Verma Gaurav Sharma Kuldeep Singh

l l l

Detailed Exam Analysis Chapter-wise and Topic-wise. Questions from previous years’ (2000 – 2020) papers. Unique scratch code that provides access to w Free online test with analytics. w 7-Day free subscription for topic-wise GATE tests. w Instant correction report with remedial action.

To get access code for the free tests, please write to us at [email protected], with a copy of the Invoice to verify purchase.

GATE

COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

CHAPTER-WISE SOLVED PAPERS

(2000-2020)

Anil Kumar Verma Associate Professor, Department of Computer Science and Engineering, Thapar University, Patiala Gaurav Sharma Cyber Security Research Center, Université Libre De Bruxelles (ULB) Brussels, Belgium

Kuldeep Singh Department of Computer Science and Engineering, Thapar University, Patiala

Engineering Mathematics Contributed by Dr Anil Kumar Maini Outstanding Scientist and former Director of Laser Science and Technology Centre DRDO, New Delhi

Varsha Agrawal Senior Scientist, Laser Science and Technology Centre DRDO, New Delhi

Nakul Maini Analyst Ericsson (India)

GATE Computer Science and Information Technology Chapter-wise Solved Papers 2000-2020 Copyright © 2020 by Wiley India Pvt. Ltd., 4436/7, Ansari Road, Daryaganj, New Delhi-110002. All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or scanning without the written permission of the publisher. Limits of Liability: While the publisher and the author have used their best efforts in preparing this book, Wiley and the author make no representation or warranties with respect to the accuracy or completeness of the contents of this book, and specifically disclaim any implied warranties of merchantability or fitness for any particular purpose. There are no warranties which extend beyond the descriptions contained in this paragraph. No warranty may be created or extended by sales representatives or written sales materials. Disclaimer: The contents of this book have been checked for accuracy. Since deviations cannot be precluded entirely, Wiley or its author cannot guarantee full agreement. As the book is intended for educational purpose, Wiley or its author shall not be responsible for any errors, omissions or damages arising out of the use of the information contained in the book. This publication is designed to provide accurate and authoritative information with regard to the subject matter covered. It is sold on the understanding that the Publisher is not engaged in rendering professional services. Other Wiley Editorial Offices: John Wiley & Sons, Inc. 111 River Street, Hoboken, NJ 07030, USA Wiley-VCH Verlag GmbH, Pappellaee 3, D-69469 Weinheim, Germany John Wiley & Sons Australia Ltd, 42 McDougall Street, Milton, Queensland 4064, Australia John Wiley & Sons (Asia) Pte Ltd, 1 Fusionpolis Walk #07-01 Solaris, South Tower Singapore 138628 John Wiley & Sons Canada Ltd, 22 Worcester Road, Etobicoke, Ontario, Canada, M9W 1L1 Edition: 2020 ISBN: 978-81-265-7542-8 ISBN: 978-81-265-9543-3 (ebk) www.wileyindia.com Printed at:

Note to the Aspirants About the Examination Graduate Aptitude Test in Engineering (GATE) is an examination conducted jointly by the Indian Institute of Science (IISc), Bangalore and the seven Indian Institutes of Technology (at Bombay, Delhi, Guwahati, Kanpur, Kharagpur, Madras and Roorkee) on behalf of the National Coordination Board (NCB)GATE, Department of Higher Education, Ministry of Human Resource Development (MHRD), and Government of India. Qualifying in GATE is a mandatory requirement for seeking admission and/or financial assistance to:



• M  aster’s programs and direct Doctoral programs in Engineering/Technology/Architecture. • Doctoral programs in relevant branches of Science, in the institutions supported by the MHRD and other Government agencies. Even in some colleges and institutions, which admit students without MHRD scholarship/assistantship, the GATE qualification is mandatory. • Many Public Sector Undertakings (PSUs) have been using the GATE score in their recruitment process.

Graduate Aptitude Test in Engineering (GATE) is basically an examination on the comprehensive understanding of the candidates in various undergraduate subjects in Engineering/Technology/ Architecture and post-graduate level subjects in Science. GATE is conducted for 24 subjects (also referred to as “papers”) are generally held at the end of January or early February of the year. The GATE examination centres are spread in different cities across India, as well as, in six cities outside India. The examination is purely a Computer Based Test (CBT). The GATE score reflects the relative performance level of the candidate in a particular subject, which is quantified based on the several years of examination data.

Eligibility for GATE Computer Science and Information Technology

Bachelor’s degree holders in Computer Science and Information Technology (4 years after 10+2 or 3 years after B.Sc./Diploma in Computer Science and Information Technology).

About the Book This book GATE Chapter-wise Computer Science and Information Technology Solved Papers is designed as a must have resource for the students preparing for the M.E./M.Tech./ M.S./Ph.D. in Computer Science and Information Technology. It offers Chapter-wise solved previous years’ GATE Computer Science and Information Technology questions for the years 2000–2020. This book will help students become well-versed with the pattern of examination, level of questions asked and concept distribution in questions. Key Features of the Book



• C  omplete solutions provided for every question, tagged for the topic on which the question is based. • Chapter-wise analysis of GATE questions provided at the beginning of the book to make students familiar with chapter-wise marks distribution and weightage of each. • Topic-wise analysis of GATE Questions provided at the beginning of each chapter to make students familiar with important topics on which questions are commonly asked. • Unique scratch code in the book that provides access to Free online test with analytics. 7-Day free subscription for topic-wise GATE tests. Instant correction report with remedial action. These features will help students develop problem-solving skills and focus in their preparation on important chapters and topics. ■





Validity

The GATE score is valid for THREE YEARS from the date of announcement of the results.

FM.indd 3

7/28/2020 11:56:23 AM

FM.indd 4

7/28/2020 11:56:23 AM

GATE 2011

GATE 2012

GATE 2013

GATE 2014

GATE 2015

GATE 2016

GATE 2017

GATE 2018

GATE 2019

GATE 2020

3

2

Databases

Computer Networks

9

10

4

1

1

Theory of Computation

6

Compiler Design

1

Algorithms

5

Operating System

3

Programming and Data Structures

4

7

1

Computer Organization and Architecture

3

8

3

Digital Logic

2

5

Engineering Mathematics

3

2

2

1

3

5

2

4

2

3

2

1

3

2

3

2

2

2

3

0

2

2

2

0

3

5

3

3

2

5

3

3

1

0

2

5

1

2

1

5

3

4

5

3

3

3

4

2

2

1

3

1

2

2

2

4

2

1

3

4

2

3

4

0

3

4

3

5

1

1

9

6

4

4

6

9

10

3

7

21

8

10

9

2

6

17

7

8

4

20

6

5

8

4

3

9

9

3

3

13

8

6

9

1

6

12

14

5

6

12

4

4

2

2

6

8

3

2

6

11

7

4

8

3

6

7

10

5

2

12

5

4

4

5

4

5

6

1

5

10

5

6

5

4

6

5

9

6

4

8

3

4

4

0

2

0

4

1

2

5

2

1

5

1

5

1

9

1

2

3

1

2

2

2

2

1

4

1

3

7

4

3

4

2

3

1

7

1

2

3

2

2

5

1

3

1

5

0

2

4

2

4

2

0

3

2

7

5

2

3

1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 Mark Marks Mark Marks Mark Marks Mark Marks Mark Marks Mark Marks Mark Marks Mark Marks Mark Marks Mark Marks Mark Marks

1

S.No. Chapter Name

GATE 2010

The table given below depicts the chapter-wise question and marks distribution of previous years’ (2010–2020) GATE Computer Science and Information Technology papers. This will help students understand the relative weightage of each chapter in terms of number of questions asked and thus bring focus in their preparation.

GATE Computer Science and Information Technology: Chapter-Wise Question Distribution Analysis 2010–2020

Contents

FM.indd 5

Note to the Aspirants

iii

Chapter 1: Engineering Mathematics Important Formulas Question Paper Answers with Explanation

1 1 17 40

Chapter 2: Digital Logic Important Formulas Question Paper Answers with Explanation

69 69 70 85

Chapter 3: C  omputer Organization and Architecture Important Formulas Question Paper Answers with Explanation

101 101 101 117

Chapter 4: Programming and Data Structures Important Formulas Question Paper Answers with Explanation

129 129 130 162

Chapter 5: Algorithms Important Formulas Question Paper Answers with Explanation

183 183 184 204

Chapter 6: Theory of Computation Important Formulas Question Paper Answers with Explanation

221 221 222 239

Chapter 7: Compiler Design Important Formulas Question Paper Answers with Explanation

249 249 249 259

Chapter 8: Operating System Important Formulas Question Paper Answers with Explanation

265 265 266 289

Chapter 9: Databases Important Formulas Question Paper Answers with Explanation

307 307 308 328

Chapter 10: Computer Networks Important Formulas Question Paper Answers with Explanation

341 341 342 356

Solved GATE (CS&IT) 2019

A1

Solved GATE (CS&IT) 2020

B1

7/28/2020 11:56:23 AM

FM.indd 6

7/28/2020 11:56:23 AM

Engineering Mathematics

CHAPTER1

Syllabus Discrete Mathematics: Propositional and first order logic. Sets, relations, functions, partial orders and lattices. Groups. Graphs: connectivity, matching, coloring. Combinatorics: counting, recurrence relations, generating functions. Linear Algebra: Matrices, determinants, system of linear equations, eigenvalues and eigenvectors, LU decomposition. Calculus: Limits, continuity and differentiability. Maxima and minima. Mean value theorem. Integration. Probability: Random variables. Uniform, normal, exponential, poisson and binomial distributions. Mean, median, mode and standard deviation. Conditional probability and Bayes theorem.

CHAPTER ANALYSIS Topic

GATE 2009

Discrete Mathematics

GATE 2010

6

Linear Algebra

GATE 2011

GATE 2012

GATE 2013

GATE 2014

GATE 2015

GATE 2016

GATE 2017

GATE 2018

5

1

4

1

19

11

13

9

3

1

1

1

1

8

7

5

5

2

2

8

6

2

2

1

1

6

1

3

2

2

Calculus

1

1

1

Probability

1

1

2

1

IMPORTANT FORMULAS Discrete Mathematics

2.

Inclusion-Exclusion Principle X ∪Y ∪ Z = X + Y + Z − X ∩ Y

1. Let P and Q be two propositions. If P → Q is an implication proposition then

− Y ∩ Z − X ∩ Z + X ∩Y ∩ Z

(a) Converse Q → P



(b) Inverse ¬P → ¬Q



(c) Contrapositive ¬Q → ¬P



(d)  Exclusive OR of P and Q

n

∪X i =1



= ∑ i =1 X i − n

i

1≤ i < j < k ≤ n

3.

(e) NAND P ↑ Q = ¬( P ∧ Q )



(f) NOR P ↓ Q = ¬( P ∨ Q )

(g)  ∀a∃b P(x, y) ≠ ∃a∀b P(x, y)

(h)  De Morgan’s Law: ¬{∃ x P ( x )} ≡ ∀x {¬P ( x )} ¬{∀x P ( x )} ≡ ∃x {¬P ( x )}

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 1

Xi ∩ X j +

X i ∩ X j ∩ X k −  + ( −1) n −1 X i ∩  ∩ X n

Symmetric Difference X ⊕ Y = ( X − Y ) ∪ (Y − X )

P ⊕ Q = ( P ∧ ¬Q ) ∨ ( ¬P ∧ Q )



1≤ i < j ≤ n

4.

Number of Relations on a Set X with n Elements Reflexive

2n( n −1)

Symmetric

2n( n +1)/ 2

Irreflexive

2n( n −1)

Anti-Symmetric

2n × 3n( n −1)/ 2

Reflexive and Anti-Symmetric 3n( n −1)/ 2 Total Relations

2n

2

11/13/2018 9:34:04 AM

2

GATE CS AND IT Chapter-wise Solved Papers

5. Let f : X → Y where X has n elements and Y has m elements. The number of functions will be m n 6. Let f : X → Y and g :Y → Z be two bijective mappings. −1 Then, g  f is also bijective and ( g  f ) = f −1  g −1 7. Let f : X → Y and X 1 and X 2 be two subsets of X. Then



(c) Square matrix: A matrix in which the number of rows is equal to the number of columns, say n, is called a square matrix of order n.



(d)  Diagonal matrix: A square matrix is called a diagonal matrix if all the elements except those in the leading diagonal are zero, i.e. aij = 0 for all i ≠ j.



(e) Scalar matrix: A matrix A = [aij]n×n is called a scalar matrix if





•  aij = 0, for all i ≠ j.





•  aii = c, for all i, where c ≠ 0.



(f)  Identity or unit matrix: A square matrix A = [aij]n×n is called an identity or unit matrix if





•  aij = 0, for all i ≠ j.





•  aij = 1, for all i.



(g) Null matrix: A matrix whose all the elements are zero is called a null matrix or a zero matrix.



(h) Upper triangular matrix: A square matrix A = [aij] is called an upper triangular matrix if aij = 0 for i > j.



(i) Lower triangular matrix: A square matrix A = [aij] is called a lower triangular matrix if aij = 0 for i < j.

f ( X1 ∪ X 2 ) = f ( X1 ) ∪ f ( X 2 ) f ( X1 ∩ X 2 ) ⊆ f ( X1 ) ∪ f ( X 2 ) 8.

The total number of arrangements of n distinct objects without repetition is called permutation and is denoted by n Pr where r objects have chosen out of n objects. n! n Pr = ( n − r )!

9. The number of arrangements of a multi-set objects, some of which are alike, say n1 are alike of first kind, n2 are alike of the second kind,…, nr are alike of r th kind, n! is given by P ( n; n1 , n2 , n3 ,..., nr ) = where n1 ! n2 ! n3 ! nr ! n1 + n2 + n3 +  + nr ≤ n 10. The number of ways to select r objects out of n, denoted by C ( n, r ) or n Cr , is n

Cr =

n! r !( n − r )!

11. Total number of combinations of ( n1 + n2 + n3 +) objects where n1 are alike, n2 are alike and so on taken any number of times is ( n1 + 1)( n2 + 1)( n3 + 1) − 1 12. Generalized Pigeonhole Principle: If m pigeons are to occupy n pigeonholes, then there is at least one pigeon⎡m⎤ hole containing at least ⎢ ⎥ pigeons. ⎢n⎥ 13. The sum of degrees of all vertices of a graph G is twice the number of edges.

15. Types of a Square Matrix (a) Nilpotent matrix: A square matrix A is called a nilpotent matrix if there exists a positive integer n such that An = 0. If n is least positive integer such that An = 0, then n is called index of the nilpotent matrix A.

(b) Symmetrical matrix: It is a square matrix in which aij = aji for all i and j. A symmetrical matrix is necessarily a square one. If A is symmetric, then AT = A.



(c) Skew-symmetrical matrix: It is a square matrix in which aij = −aji for all i and j. In a skew-symmetrical matrix, all elements along the diagonal are zero.



(d) Hermitian matrix: It is a square matrix A in which (i, j)th element is equal to complex conjugate of the (j, i)th element, i.e. aij = a ji for all i and j.



(e) Skew-Hermitian matrix: It is a square matrix A = [aij] in which aij = − aij for all i and j.



(f) Orthogonal matrix: A square matrix A is called orthogonal matrix if AAT = ATA = I.

n



∑ d (v ) = 2e, where e is the number of edges. i =1

i

Linear Algebra 14. Types of Matrices (a) Row matrix: A matrix having only one row is called a row matrix or a row vector. Therefore, for a row matrix, m = 1. (b) Column matrix: A matrix having only one column is called a column matrix or a column vector. Therefore, for a column matrix, n = 1.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 2

16. Equality of a Matrix Two matrices A = [aij]m×n and B = [bij]x×y are equal if (a) m = x, i.e. the number of rows in A equals the number of rows in B. (b) n = y, i.e. the number of columns in A equals the number of columns in B. (c) aij = bij for i = 1, 2, 3, …, m and j = 1, 2, 3, …, n.

11/13/2018 9:34:07 AM

Chapter 1  • Engineering Mathematics

17. Some of the important properties of matrix addition are: (a) Commutativity: If A and B are two m × n matrices, then A + B = B + A, i.e. matrix addition is commutative. (b) Associativity: If A, B and C are three matrices of the same order, then (A + B) + C = A + (B + C) i.e. matrix addition is associative. (c) Existence of identity: The null matrix is the identity element for matrix addition. Thus, A + O = A = O + A (d) Existence of inverse: For every matrix A = [aij]m×n, there exists a matrix [aij]m×n, denoted by −A, such that A + (−A) = O = ( −A) + A (e) Cancellation laws: If A, B and C are matrices of the same order, then A+B=A+C⇒B=C B+A=C+A⇒B=C 18. Some important properties of matrix multiplication are: (a)  Matrix multiplication is not commutative. (b) Matrix multiplication is associative, i.e. (AB)C = A(BC). (c)  Matrix multiplication is distributive over matrix addition, i.e. A(B + C) = AB + AC. (d) If A is an m×n matrix, then ImA = A = AIn. (e) The product of two matrices can be the null matrix while neither of them is the null matrix. 19. Some of the important properties of scalar multiplication are: (a)  k(A + B) = kA + kB (b) (k + l) ⋅ A = kA + lA (c) (kl) ⋅ A = k(lA) = l(kA) (d) (−k) ⋅ A = −(kA) = k(−A) (e) 1 ⋅ A = A (f)  −1 ⋅ A = −A Here A and B are two matrices of same order and k and l are constants. If A is a matrix and A2 = A, then A is called idempotent matrix. If A is a matrix and satisfies A2 = I, then A is called involuntary matrix. 20. Some of the important properties of transpose of a matrix are: (a)  For any matrix A, (AT)T = A (b)  For any two matrices A and B of the same order (A + B)T = AT + BT (c) If A is a matrix and k is a scalar, then (kA)T = k(AT)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 3

3



(d) If A and B are two matrices such that AB is defined, then (AB)T = BTAT 21. Some of the important properties of inverse of a matrix are: (a) A−1 exists only when A is non-singular, i.e. |A| ≠ 0. (b) The inverse of a matrix is unique. (c) Reversal laws: If A and B are invertible matrices of the same order, then

(AB)−1 = B−1A−1

(d) If A is an invertible square matrix, then (AT)−1 = (A−1)T



(e) The inverse of an invertible symmetric matrix is a symmetric matrix. (f) Let A be a non-singular square matrix of order n. Then







(g) If A and B are non-singular square matrices of the same order, then



adj (AB) = (adj B)(adj A)

(h) If A is an invertible square matrix, then



|adj A| = |A|n−1

adj AT = (adj A)T

(i) If A is a non-singular square matrix, then



adj (adj A) = |A|n−2 A



(j) If A is a non-singular matrix, then





|A−1| = |A|−1, i.e. | A−1 | =

1 | A|



(k) Let A, B and C be three square matrices of same type and A be a non-singular matrix. Then AB = AC ⇒ B = C    and BA = CA ⇒ B = C 22. The rank of a matrix A is commonly denoted by rank (A). Some of the important properties of rank of a matrix are: (a) The rank of a matrix is unique. (b) The rank of a null matrix is zero.

(c) Every matrix has a rank.



(d) If A is a matrix of order m × n, then rank (A) ≤ m × n (smaller of the two)



(e) If rank (A) = n, then every minor of order n + 1, n + 2, etc., is zero.



(f) If A is a matrix of order n × n, then A is non-singular and rank (A) = n.



(g) Rank of IA = n.

11/13/2018 9:34:08 AM

4

GATE CS AND IT Chapter-wise Solved Papers

(h) A is a matrix of order m × n. If every kth order minor (k < m, k < n) is zero, then rank (A) < k (i) A is a matrix of order m × n. If there is a minor of order (k < m, k < n) which is not zero, then rank (A) ≥ k (j) If A is a non-zero column matrix and B is a non-zero row matrix, then rank (AB) = 1. (k) The rank of a matrix is greater than or equal to the rank of every sub-matrix. (l) If A is any n-rowed square matrix of rank, n − 1, then adj A ≠ 0 (m) The rank of transpose of a matrix is equal to rank of the original matrix. rank (A) = rank (AT) (n)  The rank of a matrix does not change by pre-multiplication or post-multiplication with a ­ non-singular matrix. (o) If A − B, then rank (A) = rank (B). (p) The rank of a product of two matrices cannot exceed rank of either matrix. rank (A × B) ≤ rank A    or rank ( A × B) ≤ rank B (q) The rank of sum of two matrices cannot exceed sum of their ranks. (r) Elementary transformations do not change the rank of a matrix.



23. Determinants Every square matrix can be associated to an expression or a number which is known as its determinant. If A = [aij] is a square matrix of order n, then the determinant of A is denoted by det A or |A|. If A = [a11] is a square matrix of order 1, then determinant of A is defined as |A| = a11 a12 ⎤ ⎡a If A = ⎢ 11 ⎥ is a square matrix of order 2, then ⎣ a21 a23 ⎦ determinant of A is defined as |A| = a11a23 − a12a21 ⎡ a11 a12 a13 ⎤ ⎢ If A = ⎢ a21 a22 a23 ⎥⎥ is a square matrix of order 3, ⎢⎣ a31 a32 a33 ⎥⎦ then determinant of A is defined as   |A| = a11 (a22a33 − a23a32) − a21 (a12a33 − a13a32) + a21 (a12a23 − a13a22) or  |A| = a11 (a22a33 − a23a32) − a12 (a21a33 − a23a31) + a13 (a21a32 − a22a31)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 4

24. Minors The minor Mij of A = [aij] is the determinant of the square sub-matrix of order (n − 1) obtained by removing ith row and jth column of the matrix A. 25. Cofactors The cofactor Cij of A = [aij] is equal to (−1)i+j times the determinant of the sub-matrix of order (n − 1) obtained by leaving ith row and jth column of A. 26. Some of the important properties of determinants are: (a) Sum of the product of elements of any row or column of a square matrix A = [aij] of order n with their cofactors is always equal to its determinant. n

∑a c i =1



ij ij

n

= | A| = ∑ aij cij j =1

(b) Sum of the product of elements of any row or column of a square matrix A = [aij] of order n with the cofactors of the corresponding elements of other row or column is zero. n

∑a c i =1

ij ik

n

= 0 = ∑ aij ckj j =1



(c) For a square matrix A = [aij] of order n, |A| = |AT|. (d) Consider a square matrix A = [aij] of order n ≥ 2 and B obtained from A by interchanging any two rows or columns of A, then |B| = −A.



(e) For a square matrix A = [aij] of order (n ≥ 2), if any two rows or columns are identical, then its determinant is zero, i.e. |A| = 0.



(f) If all the elements of a square matrix A = [aij] of order n are multiplied by a scalar k, then the determinant of new matrix is equal to k|A|.



(g) Let A be a square matrix such that each element of a row or column of A is expressed as the sum of two or more terms. Then |A| can be expressed as the sum of the determinants of two or more matrices of the same order.



(h) Let A be a square matrix and B be a matrix obtained from A by adding to a row or column of A a scalar multiple of another row or column of A, then |B| = |A|.



(i) Let A be a square matrix of order n (≥ 2) and also a null matrix, then |A| = 0.



(j) Consider A = [aij] as a diagonal matrix of order n (≥ 2), then |A| = a × a × a × … × a



11

22

33

nn



(k) Suppose A and B are square matrices of same order, then





|AB| = |A| ⋅ |B|

11/13/2018 9:34:08 AM

Chapter 1  • Engineering Mathematics

27. There are two cases that arise for homogeneous systems: (a) Matrix A is non-singular or |A| ≠ 0.     The solution of the homogeneous system in the above equation has a unique solution, X = 0, i.e. x1 = x2 = … = xj = 0. (b) Matrix A is singular or |A| = 0, then it has infinite many solutions. To find the solution when |A| = 0, put z = k (where k is any real number) and solve any two equations for x and y using the matrix method. The values obtained for x and y with z = k is the solution of the system. 28. The method to solve a non-homogeneous system of simultaneous linear equations. Please note the number of unknowns and the number of equations. (a) Given that A is a non-singular matrix, then a system of equations represented by AX = B has the unique solution which can be calculated by X = A−1 B. (b) If AX = B is a system with linear equations equal to the number of unknowns, then three cases arise: • If A ≠ 0, system is consistent and has a unique solution given by X = A−1 B. • If A = 0 and (adj A)B = 0, system is consistent and has infinite solutions. • If A = 0 and (adj A)B ≠ 0, system is inconsistent. 29. Cramer’s Rule Suppose we have the following system of linear equations: a1x + b1  y + c1z = k1 a2x + b2  y + c2z = k2 a3x + b3  y + c3z = k3 Now, if ⎡ a1 Δ = ⎢⎢ a2 ⎢⎣ a3

b1 b2 b3

c1 ⎤ c2 ⎥⎥ ≠ 0 c3 ⎥⎦

⎡ k1 Δ1 = ⎢⎢ k2 ⎢⎣ k3 ⎡ a1 Δ 2 = ⎢⎢ a2 ⎢⎣ a3

b1 b2 b3

c1 ⎤ c2 ⎥⎥ ≠ 0 c3 ⎥⎦

k1 k2 k3

c1 ⎤ c2 ⎥⎥ ≠ 0 c3 ⎥⎦

⎡ a1 Δ 3 = ⎢⎢ a2 ⎢⎣ a3

b1 b2 b3

k1 ⎤ k2 ⎥⎥ ≠ 0 k3 ⎥⎦

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 5



5

Thus, the solution of the system of equations is given by



x=

Δ1 Δ

y=

Δ2 Δ

z=

Δ3 Δ

30. Augmented Matrix Consider the following system of equations: a11 x1 + a12 x2 +  + a1n xn = b1 a21 x1 + a22 x2 +  + a2 n xn = b2 





am1 x1 + am 2 x2 +  + amn xn = bm

This system can be represented as AX = B.

⎡ a11 ⎢a where A = ⎢ 21 ⎢  ⎢ ⎣ am1

a12 a22  am 2

 a1n ⎤ ⎡ x1 ⎤ ⎢ ⎥ ⎥ x  a2 n ⎥ , X = ⎢ 2 ⎥ and ⎢ ⎥    ⎥ ⎢ ⎥ ⎥  amn ⎦ ⎢⎣ xn ⎥⎦



⎡b1 ⎤ ⎢ ⎥ b B = ⎢ 2 ⎥. ⎢ ⎥ ⎢ ⎥ ⎢⎣bn ⎥⎦



⎡ a11 ⎢ a21 The matrix [ A B] = ⎢⎢  ⎢ ⎢⎣ am1

a12 a22  am 2

 a1n  a2 n    amn

b1 ⎤ ⎥ b2 ⎥ is called ⎥ ⎥ bm ⎥⎦

augmented matrix. 31. Cayley–Hamilton Theorem According to the Cayley–Hamilton theorem, every square matrix satisfies its own characteristic equations. Hence, if A − λ I = ( −1) n ( λ n + a1λ n −1 + a2 λ n − 2 +  + an )

is the characteristic polynomial of a matrix A of order n, then the matrix equation X n + a1 X n −1 + a2 X n − 2 +  + an I = 0



is satisfied by X = A.

11/13/2018 9:34:10 AM

6

GATE CS AND IT Chapter-wise Solved Papers

Calculus

32. Eigenvalues and Eigenvectors If A = [aij]n×n is a square matrix of order n, then the vector ⎡ x1 ⎤ ⎢x ⎥ equation AX = lX, where X = ⎢ 2 ⎥ is an unknown vector ⎢⎥ ⎢ ⎥ ⎣ xn ⎦ and l is an unknown scalar value, is called an eigenvalue problem. To solve the problem, we need to determine the value of X’s and l’s to satisfy the above-mentioned vector. Note that the zero vector (i.e. X = 0) is not of our interest. A value of l for which the above equation has a solution X ≠ 0 is called an eigenvalue or characteristic value of the matrix A. The corresponding solutions X ≠ 0 of the equation are called the eigenvectors or characteristic vectors of A corresponding to that eigenvalue, l. The set of all the eigenvalues of A is called the spectrum of A. The largest of the absolute values of the eigenvalues of A is called the spectral radius of A. The sum of the elements of the principal diagonal of a matrix A is called the trace of A. 33. Properties of Eigenvalues and Eigenvectors Some of the main characteristics of eigenvalues and eigenvectors are discussed in the following points: (a) If l1, l2, l3, …, ln are the eigenvalues of A, then kl1, kl2, kl3, …, kln are eigenvalues of kA, where k is a constant scalar quantity. (b) If l1, l2, l3, …, ln are the eigenvalues of A, then 1 1 1 1 , , , ..., are the eigenvalues of A−1. λ1 λ 2 λ3 λn

(c) If l1, l2, l3, …, ln are the eigenvalues of A, then λ1k , λ 2k , λ3k , ..., λ nk are the eigenvalues of Ak. (d) If l1, l2, l3, …, ln are the eigenvalues of A, then A

A

A

A

, , , ..., are the eigenvalues of adj A. λ1 λ 2 λ3 λn

(e) The eigenvalues of a matrix A are equal to the eigenvalues of AT. (f) The maximum number of distinct eigenvalues is n, where n is the size of the matrix A. (g) The trace of a matrix is equal to the sum of the eigenvalues of a matrix. (h) The product of the eigenvalues of a matrix is equal to the determinant of that matrix. (i) If A and B are similar matrices, i.e. A = IB, then A and B have the same eigenvalues. (j) If A and B are two matrices of same order, then the matrices AB and BA have the same eigenvalues. (k) The eigenvalues of a triangular matrix are equal to the diagonal elements of the matrix.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 6

34. Limits Limits are used to define continuity, derivatives and integrals. Consider a function f(x). Now, if x approaches a value c, and if for any number a > 0, we find a number b > 0 such that |  f(x) − l | < a whenever 0 < |x  − c| < b, then l is called the limit of function f(x). Limits are denoted as lim f ( x ) = l x→c

35. Left-Hand and Right-Hand Limits If the values of a function f(x) at x = c can be made as close as desired to the number l1 at points closed to and on the left of c, then l1 is called left-hand limit. It is denoted by lim f ( x ) = l1

x →c−





If the values of a function f(x) at x = c can be made as close as desired to the number l2 at points on the right of and close to c, then l2 is called right-hand limit. It is denoted by lim f ( x ) = l2

x → c+

36. Properties of Limits

Suppose we have lim f ( x ) = a, lim g ( x ) = b and if a x→c

x→c

and b exist, some of the important properties of limits are: (a)  lim ( f ( x ) ± g ( x ) ) = lim f ( x ) ± lim g ( x ) = a ± b x→c

x→c

x→c

(b)  lim ( f ( x ) ⋅ g ( x ) ) = lim f ( x ) ⋅ lim g ( x ) = a ⋅ b x→c

x→c

x→c

f ( x) a ⎛ f ( x ) ⎞ lim x→c (c)  lim ⎜ = = , where b ≠ 0 x→c ⎝ g( x) ⎟ ⎠ lim g ( x ) b x→c

(d)  lim kf ( x ) = k lim f ( x ), where k is a constant x→c

x→c

(e)  lim | f ( x ) | = | lim f ( x ) | = | a | x→c

x→c

(f)  lim ( f ( x )) g ( x ) = a b x→c

(g)  If lim f ( x ) = ±∞, then lim x→c



x→c

1 =0 f ( x)

Some of the useful results of limits are given as follows:

(a)  lim

sin x =1 x

(b)  lim

tan x =1 x

x→0

x→0

(c)  lim cos x = 1 x→0

11/13/2018 9:34:12 AM

7

Chapter 1  • Engineering Mathematics

40. Rolle’s Mean Value Theorem Consider a real-valued function defined in the closed interval [a, b], such that (a)  It is continuous on the closed interval [a, b]. (b)  It is differentiable on the open interval (a, b). (c)  f(a) = f(b). Then, according to Rolle’s theorem, there exists a real number c ∈( a, b) such that f ′(c) = 0.

x

⎛ 1⎞ (d)  lim(1 + x )1/ x = lim ⎜1 + ⎟ = e x→0 x →∞ ⎝ x⎠ (e)  lim

log(1 + x ) =1 x

(f)  lim

( a x − 1) = log a, if ( a > 0) x

(g)  lim

x n − an = na n −1 x−a

(h)  lim

log x = 0, if (m > 0) xm

x→0

x→0

x→0

x →∞

37. L’Hospital’s Rule If lim f ( x ) = lim g ( x ) = 0 or ± ∞, lim x→c

x→c

x→c

f ′( x ) exists and g ′( x )

41. Lagrange’s Mean Value Theorem Consider a function f(x) defined in the closed interval [a, b], such that (a)  It is continuous on the closed interval [a, b]. (b)  It is differentiable on the closed interval (a, b). Then, according to Lagrange’s mean value theorem, there exists a real number c ∈( a, b), such that

g ′( x ) ≠ 0 for all x, then lim x→c

f ( x) f ′( x ) = lim g ( x ) x → c g ′( x )

38. Continuity and Discontinuity A function f(x) at any point x = c is continuous if lim f ( x ) = f (c) x→c

and

f ′( c ) =

42. Cauchy’s Mean Value Theorem Consider two functions f(x) and g(x), such that (a)  f (x) and g(x) both are continuous in [a, b]. (b)  f ′(x) and g ′(x) both exist in (a, b). Then there exists a point c ∈( a, b) such that

lim f ( x ) = lim+ f ( x ) = f (c)

x →c−

f ( b) − f ( a) b−a

f ′( c ) f ( b) − f ( a) = g ′( c ) g ( b) − g ( a)

x→c



A function f(x) is continuous for an open interval (a, b) if it is continuous at every point on the interval (a, b). 43. Taylor’s Theorem A function f(x) is continuous on a closed interval [a, b] if If f(x) is a continuous function such that f ′( x ), f ′′( x ), …, f n −1 ( x ) (a)  f is continuous for (a, b) f ′( x ), f ′′( x ), …, f n −1 ( x ) are all continuous in [a, a + h] and f n ( x ) exists (b)  lim+ f ( x ) = f ( a) x→a

(c)  lim− f ( x ) = f (b) x→b



If the conditions for continuity are not satisfied for a function f(x) for a point or an interval, then the function is said to be discontinuous.

39. Differentiability Consider a real-valued function f(x) defined on an open interval (a, b). The function is said to be differentiable for x = c, if lim h→ 0

f ( c + h) − f ( c ) exists for every c ∈(a, b) h

A function is always continuous at a point if the function is differentiable at the same point. However, the converse is not always true.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 7

in (a, a + h) where h = b − a, then according to Taylor’s theorem, f ( a + h) = f ( a) + hf ′( a) + +

h2 hn −1 f ′′( a) +  + f n −1 ( a) 2! (n − 1)!

hn n f (a) n!

44. Maclaurin’s Theorem If the Taylor’s series is centered at 0, then the series we obtain is called the Maclaurin’s series. According to Maclaurin’s theorem, f ( h) = f (0) + hf ′(0) + +

h2 hn −1 f ′′(0) +  + f n −1 (0) 2! (n − 1)!

hn n f (0 ) n!

11/13/2018 9:34:15 AM

8

GATE CS AND IT Chapter-wise Solved Papers

45. Differentiation Some of the important properties of differentiation are:

d 1 (p) tan −1 x = dx 1+ x2

d d d (a) ( f ( x ) + g ( x )) = f ( x) + g( x) dx dx dx

d 1 (q) cosec −1 x = − dx x x2 −1

d d d f ( x) − g( x) (b) ( f ( x ) − g ( x )) = dx dx dx

d 1 (r) sec −1 x = − dx x x2 −1

d d d (c) ( f ( x ) ⋅ g ( x )) = f ( x ) ⋅ ( g ( x )) + ( f ( x )) ⋅ g ( x ) dx dx dx d d f ( x) ⋅ g( x) − f ( x) g( x) d ⎛ f ( x ) ⎞ dx dx (d) ⎜ = dx ⎝ g ( x ) ⎟⎠ ( g ( x )) 2

Some of the derivatives of commonly used functions are given as follows:

d (a) x n = nx n −1 dx d 1 (b) ln x = dx x d ⎛ 1⎞ (c) log a x = log a e ⋅ ⎜ ⎟ ⎝ x⎠ dx d (d) e x = e x dx d (e) a x = a x log e a dx d (f) sin x = cos x dx d (g) cos x = − sin x dx d (h) tan x = sec 2 x dx d (i) sec x = sec x tan x dx d (j) cosec x = − cosec x cot x dx d (k) cot x = − cosec 2 x dx d (l)  sin h x = cos h x dx d (m) cos hx = sin hx dx d 1 (n) sin −1 x = dx 1 − x2 d −1 (o) cos −1 x = dx 1 − x2

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 8

d 1 (s) cot −1 x = dx 1+ x2 46. Increasing and Decreasing Functions Any function f(x) is said to be increasing on an interval (a, b) if   x1 ≤ x2 ⇒ f(x1) ≤ f(x2) for all values of x1, x2 ∈ (a, b) A function f(x) is said to be strictly increasing on an interval (a, b) if   x1 < x2 ⇒ f(x1) < f(x2) for all values of x1, x2 ∈ (a, b) A function f(x) is said to be decreasing on an interval (a, b) if   x1 ≤ x2 ⇒ f(x1) ≥ f(x2) for all values of x1, x2 ∈ (a, b)

A function f(x) is said to be strictly decreasing on an interval (a, b) if   x1 < x2 ⇒ f(x1) > f(x2) for all values of x1, x2 ∈ (a, b)

A monotonic function is any function f(x) which is either increasing or decreasing on an interval (a, b).

47. Some important conditions for increasing and decreasing functions are: (a) Consider f(x) to be continuous on [a, b] and differentiable on (a, b). Now, • If f(x) is strictly increasing on (a, b), then f ′( x ) > 0 for all x ∈ (a, b). • If f(x) is strictly decreasing on (a, b), then f ′( x ) < 0 for all x ∈ (a, b).

(b) Consider f(x) to be a differentiable real function defined on an interval (a, b). Now,

• If f ′( x ) > 0 for all x ∈ (a, b), then f(x) is increasing on (a, b). • If f ′( x ) < 0 for all x ∈ (a, b), then f(x) is decreasing on (a, b). 48. Maxima and Minima Suppose f(x) is a real-valued function defined at an internal (a, b). Then f(x) is said to have maximum value, if there exists a point y in (a, b) such that

f(x) = f(y) for all x ∈ (a, b)

11/13/2018 9:34:18 AM

9

Chapter 1  • Engineering Mathematics

Suppose f(x) is a real-valued function defined at the interval (a, b). Then f(x) is said to have minimum value, if there exists a point y in (a, b) such that f(x) ≥ f(y) for all x ∈ (a, b) Local maxima and local minima of any function can be calculated as: Consider that f(x) be defined in (a, b) and y ∈ (a, b). Now, (a) If f ′( y ) = 0 and f ′( x ) changes sign from positive to negative as ‘x’ increases through ‘y’, then x = y is a point of local maximum value of f(x). (b) If f ′( y ) = 0 and f ′( x ) changes sign from negative to positive as ‘x’ increases through ‘y’, then x = y is a point of local minimum value of f(x). 49. Some important properties of maximum and minima are given as follows: (a) If f(x) is continuous in its domain, then at least one maxima and minima lie between two equal values of x. (b) Maxima and minima occur alternately, i.e. no two maxima or minima can occur together. 50. Maximum and minimum values in a closed interval [a, b] can be calculated using the following steps: (a) Calculate f ′( x ).

(b) Put f ′( x ) = 0 and find value(s) of x. Let c1, c2, …, cn be values of x. (c) Take the maximum and minimum values out of the values f(a), f(c1), f(c2), …, f(cn), f(b). The ­maximum and minimum values obtained are the absolute maximum and absolute minimum values of the function, respectively.

51. Integration Using Table Some of the common integration problems can be solved by directly referring the tables and computing the results. Table 1 shows the result of some of the common integrals we use. Table 1 |  Table of common integrals Integration

Result

∫ ax + b dx

1

1 ln ax + b + C where C is a constant a

1

1 − +C a( ax + b)

∫ (ax + b)

2

1

∫ (ax + b)

n

dx

dx



1 a ( n − 1) ( ax + b )

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 9

n −1

+C

Integration

∫a ∫

1 dx + x2

2

f ′( x ) dx f ( x)

Result 1 ⎛ x⎞ tan −1 ⎜ ⎟ + C ⎝ a⎠ a ln f ( x ) + C

∫ sin

2

xdx

x 1 − sin x cos x + C 2 2

∫ sin

3

xdx

1 − cos x + cos3 x + C 3

∫ sin

n

xdx

1 n −1 − sin n −1 x cos x + sin n − 2 xdx + C ∫ n n

∫ cos

2

xdx

x 1 + sin x cos x + C 2 2

∫ cos

3

xdx

1 sin x − sin 3 x + C 3

∫ cos

n

xdx

1 n −1 cos n −1 x sin x + cos n − 2 xdx + C ∫ n n

n ∫ cos xdx

∫x

2

dx − a2 dx



x ± a2 2

tan −1 x − tan n − 2 xdx + C n −1 ∫ 1 x−a ln +C 2a x + a ln x + x 2 ± a 2 + C

∫ x sin nxdx

1 (sin nx − nx cos nx ) + C n2

∫ x cos nxdx

1 (cos nx + nx sin nx ) + C n2

ax ∫ e sin bxdx

e ax ( a sin bx − b cos bx ) +C a2 + b2

ax ∫ e cos bxdx

e ax ( a cos bx + b sin bx ) +C a2 + b2

∫x

2

sin nxdx

1 ( − n2 x 2 cos nx + 2 cos nx + 2nx sin nx ) + C n3

∫x

2

cos nxdx

1 2 2 ( n x sin nx − 2 sin nx + 2nx cos nx ) + C n3

11/13/2018 9:34:24 AM

10

GATE CS AND IT Chapter-wise Solved Papers

52. Integration by Partial Fraction



1 dx = ln ( x − a) + C x−a

1 1 −1 ⎛ x ⎞ ∫ a2 + x 2 dx = a tan ⎜⎝ a ⎟⎠ + C

∫a

2

∫∫

(b) When y1, y2 are functions of x and x1, x2 are constants, f(x, y) is first integrated with respect to y, keeping x constant and between the limits y1, y2 and the resulting expression is integrated with respect to x within the limits x1, x2.

53. Integration Using Trigonometric Substitution

(a) For

a − x , use x = a sin θ .



(b) For

a 2 + x 2 , use x = a tan θ .



(c) For

∫∫

b

∫ a

b

f ( x ) ⋅ dx = ∫ f ( y ) ⋅ dy

b

a

a

b

b

c

b

a

a

c

2a

a

a

0

0

0

(d)  ∫ f ( x) ⋅ dx = ∫ f ( x) ⋅ dx + ∫ f (2a − x) ⋅ dx a

a

0

0

a

−a

0



f ( x ) ⋅ dx = 0 , if the function is odd.

−a

na

a

0

0

(g)  ∫ f ( x) ⋅ dx = n∫ f ( x) ⋅ dx if f(x) = f(x + a) 55. Some of the important properties of double integrals are: (a) When x1, x2 are functions of y and y1, y2 are constants, then f(x, y) is integrated with respect to x keeping y constant within the limits x1, x2 and the resulting expression is integrated with respect to y between the limits y1, y2.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 10

y1 x1

∫∫

∫∫

f ( x, y ) dydx

x1 y1

x2 y 2

f ( x, y ) dxdy =

y1 x1



∫∫

f ( x, y ) dydx

x1 y1

Hence, in a double integral, the order of integration does not change the final result provided the limits are changed accordingly. However, if the limits are variable, the change of order of integration changes the limits of integration.

57. Stokes’ Theorem

∫ A ⋅ dr = ∫∫ (∇ × A) ⋅ nds c

s

58. Green’s Theorem ⎛ ∂f1

∂f 2 ⎞

∫∫ ⎜⎝ ∂x − ∂y ⎟⎠ dxdy = ∫ ( f dx + f dy) 2

s

1

c

59. Gauss Divergence Theorem

(f)  ∫ f ( x) ⋅ dx = 2∫ f ( x) ⋅ dx , if the function is even. a

∫∫

x2 y2

f ( x, y ) dxdy =

y2 x2

(e)  ∫ f ( x) ⋅ dx = ∫ f (a − x) ⋅ dx a

y2 x2

f ( x, y ) dxdy =

56. Change of Order of Integration As already discussed, if limits are constant



(c)  ∫ f ( x) ⋅ dx = ∫ f ( x) ⋅ dx + ∫ f ( x) ⋅ dx  if a < c < b

f ( x, y ) dydx

x1 y1

Q

a

(b)  ∫ f ( x) ⋅ dx = − ∫ f ( x) ⋅ dx

∫∫

(c) When x1, x2, y1 and y2 are constants, then

∫∫

x 2 − a 2 , use x = a sec θ .

54. Some of the important properties of definite integrals are given as follows: (a) The value of definite integrals remains the same with change of variables of integration provided the limits of integration remain the same.

x2 y2

f ( x, y ) dxdy =

Q

2



∫ ∫ f ( x, y) dxdy y1 x1

Q

x 1 dx = ln ( a 2 + x 2 ) + C 2 + x2

2

y2 x2

f ( x, y ) dxdy =

 ∫∫∫ ∇ ⋅ AdV = ∫∫ A ⋅ ndS v



s

Divergence theorem states that the surface integral of  the normal components of a vector A taken over a closed  surface is equal to the integral of the divergence of A taken over the volume enclosed by the surface.

Probability 60. Types of Events 1. Each outcome of a random experiment is called an elementary event. 2. An event associated with a random experiment that always occurs whenever the experiment is performed is called a certain event.

11/13/2018 9:34:26 AM

Chapter 1  • Engineering Mathematics











3. An event associated with a random experiment that never occurs whenever the experiment is performed is called an impossible event. 4. If the occurrence of any one of two or more events, associated with a random experiment, presents the occurrence of all others, then the events are called mutually exclusive events. 5. If the union of two or more events associated with a random experiment includes all possible outcomes, then the events are called exhaustive events. 6. If the occurrence or non-occurrence of one event does not affect the probability of the occurrence or non-occurrence of the other, then the events are independent. 7. Two events are equally likely events if the ­probability of their occurrence is same. 8. An event which has a probability of occurrence equal to 1− P, where P is the probability of o­ ccurrence of an event A, is called the complementary event of A.

61. Approaches to Probability These are two basic approaches of quantifying probability of an event. (a) Classical approach: Probability of an event E is calculated by the ratio of number of ways an event can occur to the number of ways a sample space can occur. This approach assumes that occurrence of all outcomes is equally probable or likely P( E ) =

n( E ) n( S )

  where n( E ) is the number of favorable outcomes and n( S ) is the number of total outcomes or sample space.

(b) Frequency approach: Probability of an event E is defined as the relative frequency of occurrence of E. This approach is used when all outcomes are not equally probable or likely

n( E ) N →∞ N   where N is the number of times an experiment is performed and n( E ) is the number of times an event occurs. P ( E ) = lim

62. Axioms of Probability (a)  The numerical value of probability lies between 0 and 1.    Hence, for any event A of S, 0 ≤ P ( A) ≤ 1. (b) The sum of probabilities of all sample events is unity. Hence, P(S) = 1. (c) Probability of an event made of two or more sample events is the sum of their probabilities.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 11

11

63. Conditional Probability Let A and B be two events of a random experiment. The probability of occurrence of A if B has already occurred and P ( B ) ≠ 0 is known as conditional probability. This is denoted by P ( A/B). Also, conditional probability can be defined as the probability of occurrence of B if A has already occurred and P ( A) ≠ 0. This is denoted by P ( B /A). 64. Geometric Probability Due to the nature of the problem or the solution or both, random events that take place in continuous sample space may invoke geometric imagery. Hence, geometric probabilities can be considered as non-negative quantities with maximum value of 1 being assigned to subregions of a given domain subject to certain rules. If P is an expression of this assignment defined on a domain S, then 0 < P ( A) ≤ 1, A ⊂ S and P ( S ) = 1

The subsets of S for which P is defined are the random events that form a particular sample spaces. P is defined by the ratio of the areas so that if σ ( A) is defined as the area of set A, then P ( A) =

σ ( A) σ ( s)

65. Rules of Probability Some of the important rules of probability are given as follows: (a)  Inclusion – Exclusion principle of probability: P ( A ∪ B) = P ( A) + P ( B) − P ( A ∩ B)    If A and B are mutually exclusive events, P ( A ∩ B) = 0 and then formula reduces to P ( A ∪ B) = P ( A) + P ( B) (b)  Complementary probability: P ( A) = 1 − P ( Ac )    where P ( Ac ) is the complementary probability of A. (c)  P ( A ∩ B) = P ( A) ∗ P ( B /A) = P ( B) ∗ P ( A/B)    where P ( A/B) represents the conditional prob­ ability of A given B and P ( B /A) represents the conditional probability of B given A.    If B1 , B2 ,..., Bn are pairwise disjoint events of positive probability, then ⎛ A⎞ ⎛ A⎞ ⎛ A⎞ P ( A) = P ⎜ ⎟ P ( B1 ) + P ⎜ ⎟ P ( B2 ) +  + P ⎜ ⎟ P ( Bn ) ⎝ B1 ⎠ ⎝ B2 ⎠ ⎝ Bn ⎠ (d)  Conditional probability rule: P ( A ∩ B) = P ( B) ∗ P ( A/B)

11/13/2018 9:34:30 AM

12

GATE CS AND IT Chapter-wise Solved Papers

Or

⇒ P ( A/B ) =

P ( A ∩ B) P ( B)

P ( B /A) =

P ( A ∩ B) P ( A)



(e) Bayes’ theorem: Suppose we have an event A corresponding to a number of exhaustive events B1 , B2 ,..., Bn .

   If P ( Bi ) and P ( A/Bi ) are given, then P ( Bi /A) =

P ( Bi ) P ( A/Bi ) ∑ P ( Bi ) P ( A/Bi )



(f) Rule of total probability: Consider an event E which occurs via two different values A and B. Also, let A and B be mutually exhaustive and c­ollectively exhaustive events.    Now, the probability of E is given as P( E ) = P( A ∩ E ) + P( B ∩ E ) = P ( A) ∗ P ( E /A) + P ( B) ∗ P ( E /B)

This is called the rule of total probability.

66. Arithmetic Mean Arithmetic Mean for Raw data

Suppose we have values x1 , x2 ,..., xn and n are the total number of values, then arithmetic mean is given by x=

1 n ∑ xi n i =1

where x = arithmetic mean. Arithmetic Mean for Grouped Data (Frequency Distribution) Suppose f i is the frequency of xi , then the arithmetic mean from frequency distribution can be calculated as x= where

1 n ∑ f i xi N i =1 n

N = ∑ fi i =1

67. Median Median for Raw Data Suppose we have n numbers of ungrouped/raw values and let values be x1 , x2 ,..., xn . To calculate median, arrange all the values in ascending or descending order. th

⎡ ( n + 1) ⎤ Now, if n is odd, then median = ⎢ ⎥ value ⎣ 2 ⎦ If n is even, then median

th ⎡⎛ n ⎞ th ⎤ ⎛n ⎞ = ⎢⎜ ⎟ value + ⎜ + 1⎟ value ⎥ ⎝2 ⎠ ⎢⎣⎝ 2 ⎠ ⎥⎦ 2

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 12

Median for Grouped Data To calculate median of grouped values, identify the class containing the middle observation.

⎤ ⎡ ( N + 1) − ( F + 1) ⎥ ⎢ ⎥×h Median = L + ⎢ 2 fm ⎥ ⎢ ⎥⎦ ⎢⎣ where L = lower limit of median class N = total number of data items = ∑ f F = cumulative frequency of class immediately preceding the median class f  = frequency of median class m h = width of class 68. Mode Mode of Raw Data Mode of raw data is calculated by simply checking which value is repeated the most number of times. Mode of Grouped Data Mode of grouped values of data is calculated by first identifying the modal class, i.e. the class which has the target frequency. The mode can then be calculated using the following formula:

Mode = L +

f m − f1 ×h 2 f m − f1 − f 2

where L = lower limit of modal class f = frequency of modal class m f 1 = frequency of class preceding modal class f 2 = frequency of class following modal class h = width of model class 69. Relation Between Mean, Median and Mode Empirical mode = 3 Median − 2 Mean When an approximate value of mode is required, the given empirical formula for mode may be used. There are three types of frequency distribution: (a) Symmetric distribution: It has lower half equal to upper half of distribution. For symmetric distribution, Mean = Median = Mode (b) Positively skewed distribution: It has a longer tail on the right than on the left. Mode ≤ Median ≤ Mean (c) Negatively skewed distribution: It has a long tail on the left than on the right. Mean ≤ Median ≤ Mode

11/13/2018 9:34:33 AM

13

Chapter 1  • Engineering Mathematics



Figure 1 shows the three types of frequency distribution.



Harmonic Mean of Grouped Data Harmonic mean for a frequency distribution is calculated as N

H.M. =

n

∑ ( f /x ) i

i =1

i

n

where N = ∑ f i . i =1

72. Mean Deviation (a)

(b)



Mean Deviation of Raw Data Suppose we have a given set of n values x1 , x2 , x3 ,..., xn , then the mean deviation is given by M.D. =

1 n ∑ xi − X n i =1

where x = mean.

(c) Figure 1 |  (a)  Symmetrical frequency distribution, (b) positively skewed frequency distribution and (c)  negatively skewed frequency distribution. 70. Geometric Mean Geometric Mean of Raw Data Geometric mean of n numbers x1 , x2 ,..., xn is given by ⎛ n⎞ ⎜⎝ iπ=1⎟⎠



n

(c) Obtain the total of these deviations, i.e. ∑ x2 − X .



(d) Divide the total obtained in step 3 by the number of observations. Mean Deviation of Discrete Frequency Distribution For a frequency deviation, the mean deviation is given by



x1 ⋅ x2 ⋅ x3 ⋅⋅⋅⋅⋅ xn

Geometric Mean of Grouped Data Geometric mean for a frequency distribution is given by log G.M. =

1 N

i =1

i =1

i

xi − x

n



i =1

71. Harmonic Mean Harmonic Mean of Raw Data Harmonic mean of n numbers x1 , x2 , x3 ,..., xn is calculated as n 1

∑x i =1

n

∑f

where N = ∑ f i .



where  N = ∑ fi .

n

1 N

i =1

f i log( xi )

n

H.M. =

i =1

M.D. =

n



n



1/ n

=

The following steps should be followed to calculate mean deviation of raw data: (a)  Compute the central value or average ‘A’ about which mean deviation is to be calculated. (b)  Take mod of the deviations of the observations about the central value ‘A’, i.e. xi − x .

i

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 13



The following steps should be followed to calculate mean deviation of discrete frequency deviation: (a) Calculate the central value or average ‘A’ of the given frequency distribution about which mean deviation is to be calculated. (b) Take mod of the deviations of the observations from the central value, i.e. xi − x .



(c) Multiply these deviations by respective frequencies and obtain the total ∑ f i xi − x .



(d) Divide the total obtained by the number of observan

tions, i.e. N = ∑ f i to obtain the mean deviation. i =1

11/13/2018 9:34:36 AM

14

GATE CS AND IT Chapter-wise Solved Papers



Mean Deviation of Grouped Frequency Distribution For calculating the mean deviation of grouped frequency distribution, the procedure is same as for a discrete frequency distribution. However, the only difference is that we have to obtain the mid-points of the various classes and take the deviations of these mid-points from the given central value.

73. Standard Deviation Standard Deviation of Raw Data If we have n values x1 , x2 , ..., xn of X, then s2 = ⇒ s=

1 n ∑ ( xi − x )2 n i =1 1 n ∑ ( xi − x )2 n i =1

The following steps should be followed to calculate standard deviation for discrete data: (a)  Calculate mean ( X ) for given observations.



(b) Take deviations of observations from the mean, i.e. ( xi − X ).



(c) Square the deviations obtained in the previous step and find n

∑ (x i =1



1 n ∑ ( xi − X )2 n i =1

(e) Take out the square root of variance to obtain standard deviation,

σ2 =

− X )2

(d) Divide the sum by n to obtain the value of variance, i.e.

σ2 =

i

1 n ∑ ( xi − X )2 n i =1

Standard Deviation of Discrete Frequency Distribution If we have a discrete frequency distribution of X, then

σ2 =

⎤ 1 ⎡ n ∑ ( xi − X )2 ⎥ N ⎢⎣ i =1 ⎦

σ=

⎤ 1 ⎡ n ( xi − X ) 2 ⎥ ∑ ⎢ N ⎣ i =1 ⎦



(c) Take deviations of observations from the mean, i.e. ( xi − X ).



(d) Square the deviations obtained in the previous step and multiply the squared deviations by respective frequencies, i.e. f i ( xi − X ).



(e)  Calculate the total, i.e. ∑ f i ( xi − X ) 2 .



n

i =1

n

(f) Divide the sum ∑ f i ( xi − X ) 2 by N, where N = ∑ f i , i =1

to obtain the variance, σ 2.

(g) Take out the square root of the variance to obtain standard deviation, σ =



1⎡n ⎤ ∑ f i ( xi − X ) 2 ⎥ . n ⎢⎣ i =1 ⎦

Standard Deviation of Grouped Frequency Distribution For calculating standard deviation of a grouped frequency distribution, the procedure is same as for a discrete frequency distribution. However, the only difference is that we have to obtain the mid-point of the various classes and take the deviations of these midpoints from the given central point.

74. Coefficient of Variation Coefficient of variation (C.V.) is a measure of variability which is independent of units and hence can be used to compare two data sets with different units.

σ × 100 X where σ represents standard deviation and X represents mean. C.V. =

75. Random Variable Random variable can be discrete and continuous. Discrete random variable is a variable that can take a value from a continuous range of values. Continuous random variable is a variable that can take a value from a continuous range of values. If a random variable X takes x1 , x2 ,..., xn with respective probabilities P1 , P2 ,..., Pn , then X : x1 P ( X ) : P1

x2 P2

x3 P3

... xn ... Pn

is known as the probability distribution of X.

n

where N = ∑ f .

76. Properties of Discrete Distribution



(a)  ∑ P( x) = 1

i =1



The following steps should be followed to calculate variance if discrete distribution of data is given: (a)  Obtain the given frequency distribution.



(b)  Calculate mean ( X ) for given frequency distribution.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 14

(b)  E ( x ) = ∑ xP ( x ) (c)  V ( x ) = E ( x 2 ) − [ E ( x )] = ∑ x 2 P ( x ) − [ ∑ xP ( x )] 2

2

11/13/2018 9:34:39 AM

Chapter 1  • Engineering Mathematics

where E(x) denotes the expected value or average value of a random variable x and V(x) denotes the variable of a random variable x. 77. Properties of Continuous Distribution (a)  Cumulative distribution function is given by

n

E ( x ) = ∑ xi f ( xi ) i =1



Variable of a distribution is given by n

σ 2 = ∑ ( xi − x ) 2 f ( xi ) i =1

x

F ( x) =



f ( x ) dx

−∞

(b)  E ( x) =





xf ( x ) dx

−∞

(c)  V ( x ) = E ( x 2 ) − [ E ( x )]

2





⎤ ⎡ = ∫ x f ( x )dx − ⎢ ∫ xf ( x )dx ⎥ −∞ ⎣ −∞ ⎦

2

2

P ( a < x < b) = P ( a ≤ x ≤ b) = P ( a < x ≤ b) (d)  b

= P ( a ≤ x ≤ b) = ∫ f ( x ) dx a

78. General Discrete Distribution Suppose a discrete variable X is the outcome of some random experiment and the probability of X taking the value xi is Pi , then P ( X = xi ) = Pi for i = 1, 2,... where, P ( xi ) ≥ 0 for all values of i and ∑ P ( xi ) = 1.

The set of values xi with their probabilities Pi of a discrete variable X is called a discrete probability distribution. For example, the discrete probability distribution of X, the number which is selected by picking a card from a well-shuffled deck is given by the following table: X = xi : Ace 1 Pi : 13 X = xi : 8 1 Pi : 13



2 1 13 9 1 13

15

3 4 5 6 7 1 1 1 1 1 13 13 13 13 13 10 Jack Queen King 1 1 1 1 13 13 13 13

The distribution function F(x) of discrete variable X is defined by

79. Binomial Distribution Binomial distribution is concerned with trails of a respective nature whose outcome can be classified as either a success or a failure. Suppose we have to perform n independent trails, each of which results in a success with probability P and in a failure with probability X which is equal to 1 − P. If X represents the number of successes that occur in the n trails, then X is said to be binomial random variable with parameters (n, p). The binomial distribution occurs when the experiment performed satisfies the following four assumptions of Bernoulli’s trails. (a)  They are finite in number. (b)  There are exactly two outcomes: success or failure. (c) The probability of success or failure remains same in each trail. (d)  They are independent of each other. The probability of obtaining x successes from n trails is given by the binomial distribution formula, P ( X ) = nC x P x (1 − p) n − x where P is the probability of success in any trail and (1 − p) is the probability of failure. 80. Poisson Distribution Poisson distribution is a distribution related to the probabilities of events which are extremely rare but which have a large number of independent opportunities for occurrence. A random variable X, taking on one of the values 0, 1, 2, …, n, is said to be a Poisson random variable with parameters m if for some m > 0, P( x) =

n

F ( x ) = P ( X ≤ x ) = ∑ Pi i =1

where x is any integer. The mean value (x ) of the probability distribution of a discrete variable X is known as its expectation and is denoted by E(x). If f(x) is the probability density function of X, then

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 15



e−m mx x!

For Poisson distribution,



Mean = E ( x ) = m



Variance = V ( x ) = m



Therefore, the expected value and the variable of a Poisson random variable are both equal to its parameters m.

11/13/2018 9:34:43 AM

16

GATE CS AND IT Chapter-wise Solved Papers

81. Hypergeometric Distribution If the probability changes from trail to trail, one of the assumptions of binomial distribution gets violated; hence, binomial distribution cannot be used. In such cases, hypergeometric distribution is used; say a bag contains m white and n black balls. If y balls are drawn one at a time (with replacement), then the probability that x of them will be white is m

P( x) =

C xn C y − x m+ n

Cx

84. Uniform Distribution If density of a random variable X over the interval −∞ < a < b < ∞ is given by 1 , a< x 0 is given by ⎧λ e − λ x f (x) = ⎨ ⎩ 0

if x ≥ 0 if x < 0



Then the distribution is called exponential distribution with parameter l.



The cumulative distribution function F(a) of an exponential random variable is given by a

F ( a) = P ( x ≤ a) = ∫ λ e − λ x dx = ( −e − λ x ) a 0

= 1 − e− λa , a ≥ 0

Mean for exponential distribution is given by E ( x ) = 1/λ



Variance of exponential distribution is given by

f ( x )dx = 1

The expectation for general continuous distribution is given by

b

In uniform distribution, x takes the values with the same probability. The variance of uniform distribution is given by

V ( x) =

−∞



1 x2 b−a 2

1 λ2

86. Normal Distribution

A random variable X is a normal random variable with 2 parameters m and σ , if the probability density function is given by f ( x) =

1

σ 2π

e −( x − μ )

2

/ 2σ

2

,

−∞ < x < ∞

where μ is mean for normal distribution and σ is standard deviation for normal distribution.

11/13/2018 9:34:47 AM

Chapter 1  • Engineering Mathematics

Substituting p(A), we get

87. Bayes’ Theorem

According to Bayes’ theorem, if an event A corresponds to a number of exhaustive events B1, B2, B3 …, Bn, and if P(Bi) and P(A/Bi) are given, then P ( Bi /A) =

⎛ A⎞ ⎛B⎞ P ( ABi ) = P ( A) P ⎜ i ⎟ = P ( Bi ) P ⎜ ⎟ ⎝ A⎠ ⎝ Bi ⎠ This leads to ⎛ B ⎞ P ( Bi ) P ( A/Bi ) P⎜ i⎟ = ⎝ A⎠ P ( A)

⎛B⎞ P⎜ i⎟ = ⎝ A⎠

P ( Bi ) P ( A/Bi ) ΣP ( Bi ) P ( A/Bi )

Probabilities P (Bi); i = 1, 2, 3, …, n are called priori probabilities because these exist before we get any information. Probabilities P(A/Bi) are called posteriori probabilities because these are found after experiment results are known. Bayes’ theorem can be proved as follows. By multiplication law of probability,



17

From addition law of probability, P ( A) = P ( AB1 ) + P ( AB2 ) + P ( AB3 ) +  + P ( ABn ) ⎛ A⎞ = ∑ P ( ABi ) = ∑ P ( Bi ) P ⎜ ⎟ ⎝ Bi ⎠

P ( Bi ) P ( A/Bi ) ∑ P( Bi ) P( A/Bi )

Bayes’ theorem may also be written as P ( Bi ∩ A) ⎛B⎞ P⎜ i⎟ = ⎝ A ⎠ P ( B1 ∩ A) + P ( B2 ∩ A) +  P ( Bn ∩ A)

because ⎛ A⎞ P ( Bi ∩ A) = P ( Bi ) P ⎜ ⎟ ⎝ Bi ⎠ 88. Bayes’ theorem should be considered for application when the following conditions exist: (a) The sample space is divided into a set of mutually exclusive events (B1, B2, …, Bn). (b) Within the sample space there exists an event, while P(A) > 0. (c) The analytical goal is to compute a conditional probability of the form P(Bi  /A). (d) At least one of the two following sets of probabilities is known, namely, P ( Bi ∩ A) for each Bi and P(Bi) and P(A/Bi) for each Bi .

QUESTIONS Discrete Mathematics 1.

3.

A relation R is defined on the set of integers as xRy iff (x + y) is even. Which of the following statements is true? (a) R is not an equivalence relation (b) R is an equivalence relation having 1 equivalence class (c) R is an equivalence relation having 2 equivalence classes (d) R is an equivalence relation having 3 equivalence classes (GATE 2000: 2 Marks)

4.

Let P(S) denotes the powerset of set S. Which of the following is always true? (a) P ( P ( S )) = P ( S ) (b) P ( S ) ∩ P ( P ( S )) = {ϕ} (c) P ( S ) ∩ S = P ( S ) (d) S ∉ P ( S ) (GATE 2000: 2 Marks)

X, Y and Z are closed intervals of unit length on the real line. The overlap of X and Y is half a unit. The overlap of Y and Z is also half a unit. Let the overlap of X and Z be k units. Which of the following is true? (a) k must be 1 (b) k must be 0 (c) k can take any value between 0 and 1 (d) None of the above (GATE 2000: 2 Marks)

2.

Lets S =

100

∑i i=3

log2i, and T =



100 2

x log 2 xdx

Which of the following statements is true? (a) S > T (b) S = T (c) S < T and 2S > T

(d) 2S ≤ T (GATE 2000: 2 Marks)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Important Formula.indd 17

11/13/2018 9:34:50 AM

18

GATE CS AND IT Chapter-wise Solved Papers

5.

Let a, b, c, d be propositions. Assume that the equivalence a ↔ (b ∨ -b) and b ↔ c hold. Then the truth-value of the formula ( a ∧ b) → ( a ∧ c) ∨ d is always (a) True (b) False (c) Same as the truth-value of b (d) Same as the truth-value of d (GATE 2000: 2 Marks)

s 6.

Consider the following functions f(n) = 3n



7.

8.

g(n) = 2 n log2 n h(n) = n! Which of the following is true? (a) h(n) is O(f(n)) (b) h(n) is O(g(n)) (c) g(n) is not O(f(n)) (d) f(n) is O(g(n)) (GATE 2000: 2 Marks) Consider the following relations: R1 (a, b) iff (a + b) is even over the set of integers R2 (a, b) iff (a + b) is odd over the set of integers R3 (a, b) iff a.b > 0 over the set of non-zero rational numbers R4 (a, b) iff |a – b| ≤ 2 over the set of natural numbers Which of the following statements is correct? (a) R1 and R2 are equivalence relations, R3 and R4 are not (b) R1 and R3 are equivalence relations, R2 and R4 are not (c) R1 and R4 are equivalence relations, R2 and R3 are not (d) R1, R2, R3 and R4 are all equivalence relations (GATE 2001: 1 Mark) Consider two well-formed formulas in prepositional logic F 1 : P ⇒ ¬P



9.

n

F 2 : ( P ⇒ ¬P ) ∨ ( ¬P ⇒ P )

Which of the following statements is correct? (a) F1 is satisfiable, F2 is valid (b) F1 unsatisfiable, F2 is satisfiable (c) F1 is unsatisfiable, F2 is valid (d) F1 and F2 are both satisfiable (GATE 2001: 1 Mark) Let f(n) = n2logn and g(n) = n(log n)10 be two positive functions of n. Which of the following statements is correct? (a) f(n) = O(g(n)) and g(n) ≠ O(f(n)) (b) g(n) = O(f(n)) and f(n) ≠ O(g(n))

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 18

(c) f(n) ≠ O(g(n)) and g(n) ≠ O(f(n)) (d) f(n) = O(g(n)) and g(n) = O(f(n)) (GATE 2001: 1 Mark) 10. How many 4-digit even numbers have all 4 digits distinct? (a) 2240 (b) 2296 (c) 2620 (d) 4536 (GATE 2001: 2 Marks) 11. Consider the following statements: S1: There exists infinite sets A, B, C such that A ∩ ( B ∩ C ) is finite. S2: There exists two irrational numbers x and y such that (x + y) is rational. Which of the following is true about S1 and S2? (a) Only S1 is correct (b) Only S2 is correct (c) Both S1 and S2 are correct (d) None of S1 and S2 is correct (GATE 2001: 2 Marks) 12. Let f: A → B be a function, and let E and F be subsets of A. Consider the following statements about images. S1: f ( E ∪ F ) = f ( E ) ∪ f ( F ) S2: f ( E ∩ F ) = f ( E ) ∩ f ( F ) Which of the following is true about S1 and S2? (a) Only S1 is correct (b) Only S2 is correct (c) Both S1 and S2 are correct (d) None of S1 and S2 is correct (GATE 2001: 2 Marks) 13. The solution to the recurrence equation T(2k) = 3T(2k – 1) + 1, T (1) = 1 is (3k + 1 - 1) (a) 2k (b) 2 (c) 3log2 k

(d) 2log3 k (GATE 2002: 1 Mark)

14. The minimum number of colours required to colour the vertices of a cycle with n nodes in such a way that no two adjacent nodes have the same colour is (a) 2 (b) 3 (c) 4

⎡n⎤ (d) n - 2 ⎢ ⎥ + 2 ⎣2⎦ (GATE 2002: 1 Mark)

15. Which of the following is true? (a) The set of all rational negative numbers forms a group under multiplication.

11/13/2018 9:28:50 AM

Chapter 1  • Engineering Mathematics

(b) The set of all non-singular matrices forms a group under multiplication. (c) The set of all matrices forms a group under multiplication. (d) Both (b) and (c) are true. (GATE 2002: 1 Mark) 16. “If X then Y unless Z” is represented by which of the following formulas in prepositional logic? ( “ ¬” , is negation, “∧” is conjunction, and “→” is implication) (a) (X ∧ ¬Z) →Y (b) (X ∧ Y) →¬Z (c) X→ (Y ∧ ¬Z) (d) (X→Y) ∧ ¬Z (GATE 2002: 1 Mark) 17. The binary relation S = ϕ (empty set) on set A = {1, 2, 3} is (a) Neither reflexive nor symmetric (b) Symmetric and reflexive (c) Transitive and reflexive (d) Transitive and symmetric (GATE 2002: 2 Marks) 18. Let G be an arbitrary graph with n nodes and k components. If a vertex is removed from G, the number of components in the resultant graph must necessarily lie between (a) k and n (b) k - 1 and k + 1 (c) k - 1 and n - 1 (d) k + 1 and n - k (GATE 2003: 1 Mark)

20. Let ( S , ≤) be a partial order with two minimal elements a and b, and a maximum element c. Let P : S → [ True, False ] be a predicate defined on S. Suppose that P ( a) = True, P (b) = False and P ( x ) ⇒ P ( y ) for all x, y ∈ S satisfying x ≤ y. where ⇒ stands for logical implication. Which one of the following statements CANNOT be true? (a) P(x) = True for all x ∈ S such that x ≠ b (b) P(x) = False for all x ∈ S such that x ≠ a and x ≠ c (c) P(x) = False for all x ∈ S such that b ≤ x and x ≠ c (d) P(x) = False for all x ∈ S such that a ≤ x and a ≤ x

(GATE 2003: 2 Marks) 21. Consider the following formula a and its two interpretations I1 and I2

a : ( ∀x ) ⎡⎣ Px ⇔ ( ∀y ) [ Qxy ⇔ ¬Qyy ]⎤⎦ ⇒ ( ∀x ) [ ¬P ]

19. Consider the following graph a

19

I1: Domain: the set of natural numbers Px = “x is a prime number” Qxy = “y divides x” I2: Same as I1 except that Px = “x is a composite number” Which one of the following statements is true? (a) I1 satisfies a, I2 does not (b) I2 satisfies a, I1 does not (c) Neither I1 nor I2 satisfies a (d) Both I1 and I2 satisfy a (GATE 2003: 2 Marks)

22. Consider the following logic program P A( x ) ← B( x, y ), C ( y ) ← B( x, x )

e b f h

g



Which one of the following first-order sentences is equivalent to P? (a) (∀x ) ⎡⎣(∃y ) [ B( x, y ) ∧ C ( y )]⎤⎦ ⇒ A( x ) ∧ ¬ (∃x ) [ B( x, x )]

(b) (∀x ) ⎡⎣(∀y ) [ B( x, y ) ∧ C ( y )]⎤⎦ ⇒ A( x ) ∧ ¬ (∃x ) [ B( x, x )]

Among the following sequences   (I)  a b e g h f  (II)  a b f e h g (III)  a b f h g e (IV)  afghbe

(c) (∀x ) ⎡⎣(∃y ) [ B( x, y ) ∧ C ( y )]⎤⎦

Which are depth first traversals of the above graph (a) I, II and IV only (b) II, III and IV only (c) I and IV only (d) I, III and IV only (GATE 2003: 1 Mark)

(d) (∀x ) ⎡⎣(∀y ) [ B( x, y ) ∧ C ( y )]⎤⎦

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 19

⇒ A( x ) ∧ ¬ (∃x ) [ B( x, x )] ⇒ A( x ) ∧ ¬ (∃x ) [ B( x, x )]

(GATE 2003: 2 Marks)

11/13/2018 9:28:53 AM

20

GATE CS AND IT Chapter-wise Solved Papers

23. The following resolution rule is used in logic programming: Derive clause ( P ∨ Q ) from clauses ( P ∨ R ) , ( Q ∨ ¬R ) Which one of the following statements related to this rule is FALSE? (a) (( P ∨ R) ∧ (Q ∨ ¬R)) ⇒ ( P ∨ Q ) is logically valid (b) ( P ∨ Q ) ⇒ (( P ∨ R) ∧ (Q ∨ ¬R)) is logically valid (c)

(P ∨ Q)

is

satisfiable

if

and

only

(c) 1.3, 1.3 and 0.6, respectively (d) 1.3, 0.6 and 1.3, respectively (GATE 2003, 2 Marks) 27. Identify the correct translation into logical notation of the following assertion. Some boys in the class are taller than all the girls Note: taller (x, y) is true if x is taller than y.

if

(a) (∃x )( boy(x ) → (∀y )(girl(y ) ∧ taller(x, y )))

( P ∨ R) ∧ (Q ∨ ¬R) is satisfiable

(b) (∃ x ) ( boy(x ) ∧ (∀y ) (girl(y ) ∧ taller(x, y )))

(d) ( P ∨ Q ) ⇒ FALSE if and only if both P and Q are unsatisfiable (GATE 2003: 2 Marks) 24. How many perfect matchings are there in a complete graph of 6 vertices? (a) 15 (b) 24 (c) 30 (d) 60 (GATE 2003: 2 Marks) 25. A graph G = (V, E) satisfies |E | ≤ 3 |V | − 6. The mindegree of G is defined as minv ∈V {degree (v)}. Therefore, min-degree of G cannot be (a) 3 (b) 4 (c) 5 (d) 6 (GATE 2003: 2 Marks) 26. A piecewise linear function f ( x ) is plotted using thick solid lines in the figure below (the plot is drawn to scale). f(x) 1.0

(2.05, 1.0) a

d (1.55, 0.5) (0.5, 0.5) x1 1.3

x0

1.55 x2 2.05

0.6

(c) (∃ x ) ( boy(x ) → (∀y )(girl (y ) → taller(x, y ))) (d) (∃x ) ( boy(x ) → (∀y ) (girl(y ) ∧ taller(x, y ))) (GATE 2004: 1 Mark) 28. Consider the binary relation: S = {(x, y)| y = x + 1 and x, y ∈ {0, 1, 2,…}} The reflexive transitive closure of S is (a) {(x, y) | y > x and x, y∈ {0, 1, 2,…}} (b) {(x, y) | y ≥ x and x, y∈ {0, 1, 2,…}} (c) {(x, y) | y < x and x, y∈ {0, 1, 2,…}} (d) {(x, y) | y ≤ x and x, y∈ {0, 1, 2,…}} (GATE 2004: 1 Mark) 29. The inclusion of which of the following sets into

S = {1, 2}, {1, 2, 3}, {1, 3, 5}, {1, 2, 4}, {1, 2, 3, 4, 5}}



is necessary and sufficient to make S a complete lattice under the partial order defined by set containment? (a) {1} (b) {1}, {2, 3} (c) {1}, {1, 3} (d) {1}, {1, 3}, {1, 2, 3, 4}, {1, 2, 3, 5} (GATE 2004: 2 Marks)

30. The following propositional statement is ( P → (Q ∨ R)) → (( P ∧ Q ) → R)

b

c

(0.8, 1.0)

If we use the Newton–Raphson method to find the roots of f ( x ) = 0 using x0, x1 and x2, respectively, as initial guesses, the roots obtained would be (a) 1.3, 0.6 and 0.6, respectively (b) 0.6, 0.6 and 1.3, respectively

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 20

(a) satisfiable but not valid (b) valid (c) contradiction (d) none of the above (GATE 2004: 2 Marks) 31. The minimum number of colours required to colour the following graph, such that no two adjacent vertices are assigned the same colour, is

11/13/2018 9:28:54 AM

Chapter 1  • Engineering Mathematics

21

37. Which one of the following graphs is NOT planar? G: G:

(a) 2 (c) 4

(b) 3 (d) 5





(GATE 2004: 2 Marks) G:

G :

32. How many graphs on n labeled vertices exist which have ( n2 - 3n) edges? at least 2 (a)

( n2 - n ) / 2

( n2 - 3 n )/ 2

C( n2 -3n ) / 2 (b) ∑ (n

2

k =0

(c)

( n2 - n ) /2

n

- n)

Ck

Ck Cn (d) ∑ ( n2 - n ) / 2

k =0

(GATE 2004: 2 Marks) 33. Let G1 = (V, E1) and G2 = (V, E2) be connected graphs on the same vertex set V with more than two vertices. If G1 ∩ G2 = (V, E1 ∩ E2) is not a connected graph, then the graph G1 ∪ G2 = (V, E1 ∪ E2) (a) cannot have a cut vertex (b) must have a cycle (c) must have a cut-edge (bridge) (d) has chromatic number strictly greater than those of G1 and G2 (GATE 2004: 2 Marks) 34. 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 (b) 8 (c) 9 (d) 13 (GATE 2005: 1 Mark) 35. Let G be a simple graph with 20 vertices and 100 edges. The size of the minimum vertex cover of G is 8. Then, the size of the maximum independent set of G is (a) 12 (b) 8 (c) Less than 8 (d) More than 12 (GATE 2005: 1 Mark) 36. 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) X ⊂ Y (c) Y ⊂ X (d) None of these (GATE 2005: 1 Mark)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 21



(a) G1 (c) G3

(b) G2 (d) G4 (GATE 2005: 2 Marks)

38. Consider the following two problems on undirected graphs: α : Given G(V, E), does G have an independent 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 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 (GATE 2005: 2 Marks) 39. Let P, Q and R be three atomic propositional assertions. Let X denote ( P ∨ Q ) → R and Y denote ( P → R) ∨ (Q → R). Which one of the following is a tautology? (a) X ≡ Y (c) Y → X

(b) X → Y (d) ⎤ Y → X (GATE 2005: 2 Marks)

40. What is the first-order predicate calculus statement equivalent to the following? Every teacher is liked by some student (a) ∀( x )[teacher ( x ) → ∃( y )[student ( y ) → likes ( y, x )]] (b) ∀( x )[teacher ( x ) → ∃( y )[student ( y ) ∧ likes ( y, x )]] (c) ∃( y )∀( x )[teacher ( x ) → [student ( y ) ∧ likes( y, x )]] (d) ∀( x )[teacher ( x ) ∧ ∃( y )[student ( y ) → likes ( y, x )]] (GATE 2005: 2 Marks)

11/13/2018 9:28:57 AM

22

GATE CS AND IT Chapter-wise Solved Papers

41. 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 (a) z (b) z × 2xy (c) z

(d) 2xyz (GATE 2006: 1 Mark)

42. 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 or threatened. (a)

⎡( tiger (x ) ∧ lion (x )) ⎤ ⎢ ⎥ ∀( x ) ⎢ ⎛ (hungry (x ) ∨ threatened (x ))⎞ ⎥ → ⎟⎠ ⎥ ⎢⎣ ⎜⎝ → attacks (xx ) ⎦

(b)

⎡( tiger (x ) ∨ lion (x )) ⎤ ⎢ ⎥ ∀( x ) ⎢ ⎛ hungry (x ) ∨ threatened (x )⎞ ⎥ → ⎟⎠ ⎥ ⎢⎣ ⎜⎝ ∧ attacks(x ) ⎦

(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 neighbours in G (GATE 2006: 2 Marks) 45. 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 (GATE 2007: 1 Mark) 46. Consider the DAG with V = {1, 2, 3, 4, 5, 6}, shown below. 2 5

3

6

(c)

⎡( tiger (x ) ∨ lion (x )) ⎤ ⎢ ⎥ ∀( x ) ⎢ ⎛ attacks (x ) → ⎞⎥ → ⎢⎣ ⎜⎝ ( hungry ( x ) ∨ threatened (x ))⎟⎠ ⎥⎦



(d)

⎡( tiger (x ) ∨ lion (x )) ⎤ ⎢ ⎥ ∀( x ) ⎢ ⎛ ( hungry (x ) ∨ threatened (x )) →⎞ ⎥ →⎜ ⎟⎠ ⎥ ⎢⎣ ⎝ attacks (x ) ⎦

47. 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: “Not every graph is connected”?

(GATE 2006: 2 Marks)

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 (GATE 2007: 1 Mark)

(a) ¬∀x (Graph (x ) ⇒ Connected (x ))

43. Consider the following propositional statements:



4

1

P1 : ((( A ∧ B) → C )) ≡ (( A → C ) ∧ ( B → C ))

(b) ∃ x(Graph ( x ) ∧ ¬Connected (x ))

P2 : ((( A ∨ B) → C )) ≡ (( A → C ) ∨ ( B → C ))

(c) ¬∀x ( ¬Graph (x ) ∨ Connected ( x ))

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 (GATE 2006: 2 Marks)

44. Let T be a depth first search tree of 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 disconnects u and v in G

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 22

(d) ∀x (Graph (x ) ⇒ ¬Connected (x )) 

(GATE 2007: 2 Marks) xn 9 + , x0 = 0.5 obtained 2 8 xn from the Newton–Raphson method. The series converges to (a) 1.5 (b) 2 (c) 1.6 (d) 1.4 (GATE 2007: 2 Marks)

48. Consider the series xn +1 =

49. If P, Q, R are subsets of the universal set U, then ( P ∩ Q ∩ R) ∪ ( P c ∩ Q ∩ R) ∪ Q c ∪ Rc is (a) Q c ∪ Rc (b) P ∪ Q c ∪ Rc (c) P c ∪ Q c ∪ Rc (d) U (GATE 2008: 1 Mark)

11/13/2018 9:28:59 AM

Chapter 1  • Engineering Mathematics

50. P and Q are two propositions. Which of the following logical expressions are equivalent?



I. P ∨ ∼ Q II. ∼ ( ∼ P ∧ Q ) III. (P ∧ Q ) ∨ ( P ∧ ∼ Q ) ∨ ( ∼ P ∧ ∼ Q ) IV. (P ∧ Q ) ∨ ( P ∧ ∼ Q ) ∨ ( ∼ P ∧ Q ) (a) (b) (c) (d)



(GATE 2008: 2 Marks) 51. Which of the following statements is true for every planar graph on n vertices? (a) The graph is connected (b) The graph is Eulerian (c) The graph has a vertex-cover of size at most 3n/4 (d) The graph has an independent set at least n/3 (GATE 2008: 2 Marks) 52. 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 subgraph has at most 2k - 2 edges (b) The minimum cut in G has at least two edges (c) There are two edge-disjoint paths between every pair of vertices (d) There are two vertex-disjoint paths between every pair of vertices  (GATE 2008: 2 Marks)

be used to compute the (a) square of R (c) square root of R

1⎛ R⎞ xn + ⎟ can ⎜ 2⎝ xn ⎠

(b) reciprocal of R (d) logarithm of R (GATE 2008: 2 Marks)

54. The minimum number of equal length subintervals 2

∫ xe dx x

(b) 3 (d) n (GATE 2009: 1 Mark)

56. 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. (GATE 2009: 1 Mark)

Only I and II Only I, II and III Only I, II and IV All of I, II, III and IV

53. The Newton–Raphson iteration xn +1 =

(a) 2 (c) n - 1

23

57. 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  (GATE 2009: 1 Mark) 58. Consider the binary relation R = {(x, y), (x, z), (z, x), (z, y)} on the set {x, y, z}. Which one of 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. (GATE 2009: 1 Mark) 59. Which one of the following is the most appropriate ­logical formula to represent the statement: “Gold and silver ornaments are precious” The following notations are used: G(x): x is a gold ornament. S(x): x is a silver ornament. P(x): x is precious. (a) ∀x ( P ( x ) → (G ( x ) ∧ S ( x ))) (b) ∀x ((G ( x ) ∧ ( S ( x )) → P ( x )) (c) ∃ x ((G ( x ) ∧ ( S ( x ) → P ( x )) (d) ∀x ((G ( x ) ∨ ( S ( x )) → P ( x ))

to an accuracy of at

(GATE 2009: 2 Marks)

least 1/3 × 10−6 using the trapezoidal rule is (a) 1000e (b) 1000 (c) 100e (d) 100 (GATE 2008: 2 Marks)

60. For the composition table of a cyclic group shown below

needed to approximate

1

55. What is the chromatic number of an n-vertex simple connected graph which does not contain any odd length cycle? Assume n ≥ 2.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 23

a b c d a a b c d b b a d c c c d b a d d c a b

11/13/2018 9:29:00 AM

24



GATE CS AND IT Chapter-wise Solved Papers

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 (GATE 2009: 2 Marks)

61. Let G = (V, E) be a graph. Define ξ (G ) = ∑ id × d , d



(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 (GATE 2011: 2 Marks) 67. What is the correct translation of the following statement into mathematical logic? “Some real numbers are rational” (a) ∃ x ( real (x ) ∨ rational ( x ))

where id is number of 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 (GATE 2010: 1 Mark)

62. What is the possible number of reflexive relations on a set of 5 elements? (a) 210 (b) 215 (c) 220 (d) 225 (GATE 2010: 1 Mark) 63. Consider the set S = {1, ω, ω 2}, where ω and ω 2 are cube roots of unity. If * denotes the multiplication operation, then structure {S, *} forms (a) a group (b) a ring (c) an integral domain (d) a field (GATE 2010: 1 Mark) 64. Newton–Raphson method is used to compute a root of the equation x 2 - 13 = 0 with 3.5 as the initial value. The approximation after one iteration is (a) 3.575 (b) 3.677 (c) 3.667 (d) 3.607 (GATE 2010: 1 Mark) 65. 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 ∀x∃y∃ t ( ¬ F ( x, y, t )) ? (a) (b) (c) (d)

Everyone can fool some person at some time No one can fool everyone all the time Everyone cannot fool some person all the time No one can fool some person at some time (GATE 2010: 2 Marks)

66. Which one of the following options is CORRECT given three positive integers x, y and z and a predicate ⎞ ⎛ ∃z ( x = y ∗ z ) P ( x ) = ¬ ( x = 1) ∧ ∀y ⎜ ⎝ ⇒ ( 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 a number other than 1

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 24

(b) ∀x ( real (x ) → rational ( x )) (c) ∃ x ( real (x ) ∧ rational ( x )) (d) ∃ x ( rational (x ) → real ( x )) (GATE 2012: 1 Mark) 68.

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 a correct inference. (c) I1 is not correct but I2 is a correct inference. (d) Both I1 and I2 are not correct inferences. (GATE 2012: 1 Mark)

69. 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 (b) 4 (c) 5 (d) 6 (GATE 2012: 1 Mark) 70. The bisection method is applied to compute a zero of the function f ( x ) = x 4 - x 3 - x 2 - 4 in the interval [1, 9]. The method converges to a solution after iterations. (a) 1 (b) 3 (c) 5 (d) 7 (GATE 2012: 2 Marks) 71. Which one of the following is NOT logically equivalent to ¬ ∃ x (∀y (a ) ∧ ∀z (β )) ? (a) ∀x (∃ x( ¬β ) → ∀y (a )) (b) ∀x (∀z (β ) → ∃y ( ¬ a ))

11/13/2018 9:29:01 AM

Chapter 1  • Engineering Mathematics

(c) ∀x (∀y (a ) → ∃ z ( ¬β )) (d) ∀x (∃ y ( ¬ a ) → ∃ z ( ¬β )) (GATE 2013: 2 Marks) 72. Consider the statement: “Not all that glitters is gold” Predicate glitters (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) ∀x; glitters(x) ⇒ ¬gold(x) (b) ∀x; gold(x) ⇒ glitters(x) (c) ∃x; gold(x) ∧ ¬ glitters(x) (d) ∃x; glitters(x) ∧ ¬ gold(x) (GATE 2014: 1 Mark) 73. Let G = (V, E) be a directed graph where V is the set of vertices and E the set of edges. Then which one of the following graphs has the same strongly connected components as G? (a) G1 = (V, E1) where E1 = {(u, v) | (u, v) ∉ E)} (b) G2 = (V, E2) where E2 = {(u, v) | (v, u) ∉ E)} (c)  G3 = (V, E3) where E3 = {(u, v) | there is a path of length ≤ 2 from u to v in E} (d)  G4 = (V, E4) where V4 is the set of vertices in G which are not isolated (GATE 2014: 1 Mark) 74. 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) (b) Θ(n + m) (c) Θ(n2) (d) Θ(m2) (GATE 2014: 1 Mark) 75. Consider the directed 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 orderings (c) Both PSRQ and SPRQ are topological orderings. (d) PSRQ is the only topological ordering. (GATE 2014: 1 Mark)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 25

25

76. The maximum number of edges in a bipartite graph on 12 vertices is       . (GATE 2014: 1 Mark) 77. 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. (GATE 2014: 1 Mark) 78. 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. (GATE 2014: 1 Mark) 79. Let X and Y be finite sets and f : X → Y 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) ∩ f (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 -1(S ∩ T) = f -1(S) ∩ f -1(T) (GATE 2014: 1 Mark) 80. Let G be a group with 15 elements. Let L be a subgroup of G. It is known that L ≠ G and that the size of L is at least 4. The size of L is       . (GATE 2014: 1 Mark) 81. If V1 and V2 are 4-dimensional subspaces of a 6dimensional vector space V, then the smallest possible dimension of V1 ∩ V2 is       . (GATE 2014: 1 Mark)

11/13/2018 9:29:02 AM

26

GATE CS AND IT Chapter-wise Solved Papers

82. 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       .

(GATE 2014: 1 Mark) 83. Consider the following relation on subsets of the set S of integers between 1 and 2014. For two distinct subsets U and V of S we say U < V if the minimum element in the symmetric difference of the two sets is in U. Consider the following two statements: S1: There is a subset of S that is larger than every other subset. S2: There is a subset of S that is smaller than every other subset. Which one of the following is CORRECT? (a) Both S1 and S2 are true (b) S1 is true and S2 is false (c) S2 is true and S1 is false (d) Neither S1 nor S2 is true (GATE 2014: 2 Marks) 84. A cycle of n vertices is isomorphic to its complement. The value of n is       . (GATE 2014: 2 Marks) 85. Let S be a sample space and two mutually exclusive events A and B be such that A∪B = S. If P(.) denotes the probability of the event, the maximum value of P(A) P(B) is       . (GATE 2014: 2 Marks) 86. Consider the set of all functions f : {0, 1, …, 2014}→ {0, 1, …, 2014} such that f (f (i)) = i, for 0 ≤ i ≤ 2014. 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. 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 (GATE 2014: 2 Marks)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 26

87. 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 x * x = y * y = x * y *x * y = y * x * y *x = e where e is the identity element. The maximum number of elements in such a group is       . (GATE 2014: 2 Marks) 88. If G is a forest with n vertices and k connected components, how many edges does G have? (a) [n/k] (b) [n/k] (c) n - k (d) n - k +1 (GATE 2014: 2 Marks) 89. Let δ denote the minimum degree of a vertex in a graph. For all planar graphs on n vertices with δ ≥ 3, which one of the following is TRUE? (a) In any planar embedding, the number of faces is at n least + 2 2 (b) In any planar embedding, the number of faces is n less than + 2 2 (c) There is a planar embedding in which the number n of faces is less than + 2 2 (d) There is a planar embedding in which the number n of faces is at most δ +1 (GATE 2014: 2 Marks) 90. The CORRECT formula for the sentence, “not all rainy days are cold” is (a) ∀d (Rainy(d) ∧ ∼ Cold(d)) (b) ∀d (∼Rainy(d) → Cold(d)) (c) ∃d (∼Rainy(d) → Cold(d)) (d) ∃d (Rainy(d) ∧ ∼ Cold(d)) (GATE 2014: 2 Marks) 91. Which one of the following is NOT equivalent to p ↔ q? (a) ( ⎤ p ∨ q) ∧ ( p∨ ⎤ q) (b) ( ⎤ p ∨ q) ∧ ( q → p) (c) ( ⎤ p ∧ q) ∨ ( p ∧ ⎤ q) (d) ( ⎤ p ∧ ⎤ q) ∨ ( p ∧ q) (GATE 2015: 1 Mark) 92. For a set A, the power set of A is denoted by 2A. If A = {5, {6}, {7}}, which of the following options are TRUE? (i)

ϕ ∈ 2A

(iii) {5, {6}} ∈ 2 A

(ii) ϕ ⊆ 2 A (iv) {5, {6}} ⊆ 2 A

11/13/2018 9:29:05 AM

Chapter 1  • Engineering Mathematics

(a) (b) (c) (d)

(i) and (iii) only (ii) and (iii) only (i), (ii) and (iii) only (i), (ii) and (iv) only

(a) (b) (c) (d) (GATE 2015: 1 Mark)

93. Let G be a connected planar graph with 10 vertices. If the number of edges on each face is three, then the number of edges in G is      . (GATE 2015: 1 Mark) 94. An unordered list contains n distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is (a) O(n log n) (b) O(n) (c) O(log n) (d) O(1) (GATE 2015: 1 Mark) 95. Consider the following two statements. (i) If a candidate is known to be corrupt, then he will not be elected. (ii)  If a candidate is kind, he will be elected Which one of the following statements follows from (i) and (ii) as per sound inference rules of logic? (a) If a person is known to be corrupt, he is kind. (b) If a person is not known to be corrupt, he is not kind. (c) If a person is kind, he is not known to be corrupt. (d) If a person is not kind, he is not known to be corrupt. (GATE 2015: 1 Mark) 96. Which one of the following well-formed formulae is a tautology? (a) ∀x ∃y R( x, y ) ↔ ∀xR( x, y ) (b) ∀x [∃y R( x, y ) → S ( x, y )]) → ∀x∃yS ( x, y ) (c) [∀x ∃y P ( x, y ) → R( x, y )]) ↔ ∀x∃y(¬P ( x, y ) ∨ R( x, y )]

(a) ∀X ∈ U ( X = X 1 ) (b) ∃X ∈ U ∃Y ∈ U ( x = 2, Y = 5 and X ∩ Y = 0) (c) ∀X ∈ U ∀Y ∈ U ( x = 2, Y = 3 and X \ Y = 0) (d) ∀X ∈ U ∀Y ∈ U ( X \ Y = Y 1 \ X 1 ) (GATE 2015: 2 Marks) 100. Let R be a relation on the set of ordered pairs of positive integers such that [(p, q), (r, s)] ∈R, if and only if p - s = q - r. Which one of the following is true about R? (a) Both reflexive and symmetric (b) Reflexive but not symmetric (c) Not reflexive but symmetric (d) Neither reflexive nor symmetric (GATE 2015: 2 Marks) 101. Let f(n) = n and g(n) = n(1 + sin n), where n is a positive integer. Which of the following statements is/are correct? (i)  f(n) = O(g(n)) (ii)  f(n) = Ω(g(n)) (a) only (i) (b) only (ii) (c) Both (i) and (ii) (d) Neither (i) nor (ii) (GATE 2015: 2 Marks) 102. Let p, q, r, s represent the following propositions: p : x ∈{8, 9, 10, 11,12}

(GATE 2015: 1 Mark)

98. Consider the equality ∑ i = 0 i 3 = X and the following choices for X: (i) θ (n4) (ii) θ (n + 5) (iii) O(n5) (iv) Ω(n3) n

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 27

Only (i) Only (ii) (i) or (iii) or (iv) but not (ii) (ii) or (iii) or (iv) but not (i) (GATE 2015: 1 Mark)

99. Suppose U is the power set of the set S = {1, 2, 3, 4, 5, 6}. For any T ∈ U , let |T | denote the number of elements in T and T ′ denote the complement of T. For any T , R ∈ U , let T ″ R be the set of all elements in T which are not in R. Which one of the following is true?

(d) ∀x∀yP ( x, y ) → ∀x∀yP ( x, y ) 97. The number of four-digit numbers having their digits in non-decreasing order (from left to right) constructed by using the digits belonging to the set {1, 2, 3} is      . (GATE 2015: 1 Mark)

27



q: x is a composite number r: x is a perfect square s: x is a prime number The integer x ≥ 2 which satisfies ¬(( p ⇒ q) ∧ (¬rV ¬s)) is      . (GATE 2016: 1 Mark)

103. Let an be the number of n-bit strings that do NOT contain two consecutive 1s. Which one of the following is the recurrence relation for an? (a) an = an-1 + 2an-2 (b) an = an-1 + an-2 (c) an = 2an-1 + an-2 (d) an = 2an-1 + 2an-2 (GATE 2016: 1 Mark)

11/13/2018 9:29:06 AM

28

GATE CS AND IT Chapter-wise Solved Papers

104. G = (V, E) is an undirected simple graph in which each edge has a distinct weight, and e is a particular edge of G. Which of the following statements about the minimum spanning trees (MSTs) of G is/are TRUE? I. If e is the lightest edge of some cycle in G, then every MST of G includes e II. If e is the heaviest edge of some cycle in G, then every MST of G excludes e (a) I only (b) II only (c) both I and II (d) neither I nor II (GATE 2016: 1 Mark) 105. Consider the following expressions: (i) false (ii) Q (iii) true

(iv) P ∨ Q

(v) ¬Q ∨ P

The number of expressions given above that are logically implied by P ∧ ( P ⇒ Q )     .



(GATE 2016: 1 Mark)

106. The minimum number of colours that is sufficient to vertex-colour any planar graph is     . (GATE 2016: 1 Mark) 107. Consider the systems, each consisting of m linear equations in n variables. I. If m < n, then all such systems have a solution. II. If m > n, then none of these systems has a solution. III. If m = n, then there exists a system which has a solution. Which one of the following is CORRECT? (a) I, II and III are true (b) Only II and III are true (c) Only III is true (d) None of them is true (GATE 2016: 1 Mark)   

108. Consider the recurrence relation a1 = 8, an = 6n2 + 2n + an-1. Let a99 = K × 104. The value of K is    . (GATE 2016: 2 Marks) 109. A function f :  + →  + , defined on the set of positive integers N+, satisfies the following properties: f(n) = f(n/2) if n is even f(n) = f(n + 5) if n is odd Let R = {i | ∃ j : f ( j ) = i} be the set of distinct values that f takes. The maximum possible size of R is      . (GATE 2016: 2 Marks)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 28

110. Consider the weighted undirected graph with 4 vertices, where the weight of edge {i, j} is given by the entry Wij in the matrix W. ⎡0 ⎢2 W =⎢ ⎢8 ⎢ ⎣5

2 0 5 8

8 5⎤ 5 8 ⎥⎥ 0 x⎥ ⎥ x 0⎦

The largest possible integer value of x, for which at least one shortest path between some of vertices will contain the edge with weight x is      . (GATE 2016: 2 Marks)

111. Let G be a complete undirected graph on 4 vertices, having 6 edges with weights being 1, 2, 3, 4, 5 and 6. The maximum possible weight that a minimum weight spanning tree of G can have is      . (GATE 2016: 2 Marks) 112. Which one of the following well-formed formulae in predicate calculus is NOT valid? (a) (∀xp( x ) ⇒ ∀xq( x )) ⇒ (∃x¬p( x ) ∨ ∀xq( x )) (b) (∃xp( x ) ∨ ∃xq( x )) ⇒ ∃x( p( x ) ∨ q( x )) (c) ∃x( p( x ) ∧ q( x )) ⇒ (∃xp( x ) ∧ ∃xq( x )) (d) ∀x( p( x ) ∨ q( x )) ⇒ (∀xp( x ) ∨ ∀xq( x ))

(GATE 2016: 2 Marks)

113. Consider a set U of 23 different compounds in a Chemistry lab. There is a subject S of U of 9 compounds, each of which reacts with exactly 3 compounds of U. Consider the following statements: I. Each compound in U\S reacts with an odd number of compounds. II. At least one compound in U\S reacts with an odd number of compounds. Which one of the above statements is ALWAYS TRUE? (a) Only I (b) Only II (c) Only III (d) None (GATE 2016: 2 Marks) 114. The value of the expression 1399 (mod 17), in the range 0 to 16, is      . (GATE 2016: 2 Marks) 115. The statement ( ¬p) ⇒ ( ¬q) is logically equivalent to which of the below statements? p ⇒ q II. I. q⇒ p III. ( ¬q) ∨ p IV. ( ¬p ) ∨ q (a) I only (b) I and IV only (c) II only (d) II and III only (GATE 2017: 1 Mark)

11/13/2018 9:29:08 AM

Chapter 1  • Engineering Mathematics

116. Consider the first-order logic sentence F : ∀x(∃yR( x, y )). Assuming non-empty logical domains, which of the below sentences are implied by F ? I. ∃ y(∃ x R( x, y )) II. ∃ y(∀xR( x, y )) III. ∀y(∃ xR( x, y )) IV. ¬∃ x(∀y ¬R( x, y )) (a) IV only (c) II only

(b) I and IV only (d) II and III only (GATE 2017: 1 Mark)

117. Let T be a tree with 10 vertices. The sum of the degrees of all the vertices in T is _____________. (GATE 2017: 1 Mark) 118. Let p, q and r denote the statements “It is raining,” “It is cold,” and “It is pleasant,” respectively. Then the statement “It is not raining and it is pleasant, and it is not pleasant only if it is raining and it is cold ” is represented by (a) ( ¬p ∧ r ) ∧ ( ¬r → ( p ∧ q)) (b) ( ¬p ∧ r ) ∧ (( p ∧ q) → ¬r ) (c) ( ¬p ∧ r ) ∨ (( p ∧ q) → ¬r )

121. Let p, q and r be propositions and the expression (p → q) → r be a contradiction. Then, the expression (r → p) → q is (a) a tautology (b) a contradiction (c) always TRUE when p is FALSE (d) always TRUE when q is TRUE (GATE 2017: 2 Marks) 122. The number of integers between 1 and 500 (both inclusive) that are divisible by 3 or 5 or 7 is _________. (GATE 2017: 2 Marks) 123. If the ordinary generating function of a sequence {an }∞n= 0 1+ z is , then a3 - a0 is equal to ________. (1 - z )3 (GATE 2017: 2 Marks) 124. Which one of the following is a closed form expression for the generating function of the sequence {an}, where an = 2n + 3 for all n = 0, 1, 2, …? (a)

3 3x (b) 2 (1 - x ) (1 - x ) 2

(c)

2- x 3- x (d) 2 (1 - x ) (1 - x ) 2

(d) ( ¬p ∧ r ) ∨ ( r → ( p ∧ q)) (GATE 2017: 1 Mark) 119. Consider the set X = {a, b, c, d, e} under the partial ordering R = {(a, a), (a, b), (a, c), (a, d), (a, e), (b, b), (b, c), (b, e), (c, c), (c, e), (d, d), (d, e), (e, e)}

The Hasse diagram of the partial order (X, R) is shown below: d

c

e b

a



The minimum number of ordered pairs that need to be added to R to make (X, R) a lattice is ________. (GATE 2017: 1 Mark)

120. G is an undirected graph with n vertices and 25 edges such that each vertex of G has degree at least 3. Then the maximum possible value of n is __________. (GATE 2017: 1 Mark)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 29

29

(GATE 2018: 1 Mark) 125. Let G be a finite group on 84 elements. The size of a largest possible proper subgroup of G is . (GATE 2018: 1 Mark) 126. Let N be the set of natural numbers. Consider the following sets. P: Set of Rational numbers (positive and negative) Q: Set of functions from {0, 1} to N R: Set of functions from N to {0, 1} S: Set of finite subsets of N. Which of the sets above are countable? (a) Q and S only (b) P and S only (c) P and R only (d) P, Q and S only (GATE 2018: 2 Marks)

Linear Algebra 127. The determinant of the matrix ⎡2 ⎢8 ⎢ ⎢2 ⎢ ⎣9

0 0 0⎤ 1 7 2⎥⎥ is: 0 2 0⎥ ⎥ 0 6 1⎦

11/13/2018 9:29:10 AM

30

GATE CS AND IT Chapter-wise Solved Papers

(a) 4 (c) 15

(b) 0 (d) 20 (GATE 2000: 1 Mark)

128. A polynomial p(x) satisfies the following: p(1) = p(3) = p(5) = 1 p(2) = p(4) = –1 The minimum degree of such a polynomial is (a) 1 (b) 2 (c) 3 (d) 4 (GATE 2000: 2 Marks) 129. Consider the following statements: S1: The sum of two singular n × n matrices may be non-singular. S2: The sum of two n × n non-singular matrices may be singular. Which of the following statements is correct? (a) S1 and S2 are both true (b) S1 is true, S2 is false (c) S1 is false, S2 is true (d) S1 and S2 are both false (GATE 2001: 1 Mark) ⎡1 1 ⎤ 130. The rank of the matrix ⎢ ⎥ is ⎣0 0⎦ (a) 4 (b) 2 (c) 1 (d) 0 (GATE 2002: 1 Mark)

133. How many solutions does the following system of linear equations have? - x + 5 y = -1 x- y=2 x + 3y = 3 (a) (b) (c) (d)

(GATE 2004: 2 Marks) 134. Consider the following system of equations in three real variables x1, x2 and x3: 2 x1 - x2 + 3 x3 = 1 3 x1 - 2 x2 + 5 x3 = 2 - x1 - 4 x2 + x3 = 3 This system of equations has (a) no solution (b) a unique solution (c) more than one but a finite number of solutions (d) infinite number of solutions (GATE 2005: 2 Marks) 135. What are the eigenvalues of the following 2 × 2 matrix? ⎡ 2 -1⎤ ⎢ -4 5⎥ ⎣ ⎦ (a) −1 and 1 (c) 2 and 5

131. Consider the following system of linear equations: ⎡ 2 1 -4 ⎤ ⎡ x ⎤ ⎡a ⎤ ⎢ 4 3 -12⎥ ⎢ y ⎥ = ⎢ 5⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢⎣ 1 2 -8⎥⎦ ⎢⎣ z ⎥⎦ ⎢⎣ 7⎥⎦

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 30

(b) 1 and 6 (d) 4 and −1 (GATE 2005: 2 Marks)

136. Consider the set of (column) vector defined by X = {x ∈ R3 | x 1 + x2 + x3 = 0, where xT = ( x1 , x2 , x3 )T }. Which one of the following options is true? (a) {(1, -1, 0)T ,(1, 0, -1)T } is a basis for the subspace X.

Notice that the second and third columns of the coefficient matrix are linearly dependent. For how many values of a , does this system of equations have infinitely many solutions? (a) 0 (b) 1 (c) 2 (d) Infinitely many (GATE 2003: 2 Marks)

132. Let A, B, C and D be n × n matrices, each with non-zero determinant. If ABCD = I, then B−1 (a) is D −1C −1A−1 (b) is CDA (c) is ADC (d) does not necessarily exist (GATE 2004: 1 Mark)

infinitely many two distinct solutions unique solution no solution

(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 a subspace for R3 (d) None of the above (GATE 2007: 2 Marks) 137. The following system of equations: x1 + x2 + 2 x3 = 1 x1 + 2 x3 + 3 x3 = 2 x1 + 4 x2 + ax3 = 4

has a unique solution. The only possible value(s) for a is/are

11/13/2018 9:29:11 AM

Chapter 1  • Engineering Mathematics

(a) 0 (b) either 0 or 1 (c) one of 0, 1 or −1 (d) any real number other than 5 (GATE 2008: 1 Mark)

1 x( x + 1) (a) 1 y( y + 1) 1 z ( z + 1)

⎡ 1 0 ⎤ ⎡0 1⎤ ⎡1 -1⎤ ⎡ -1 0 ⎤ ⎢0 0 ⎥ , ⎢0 0 ⎥ , ⎢1 -1⎥ and ⎢ 1 -1⎥ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ (b) Two (d) Four (GATE 2008: 2 Marks)

139. Consider the following matrix: ⎡2 A= ⎢ ⎣x

3⎤ y ⎥⎦

(c)

0 x- y 0 y-z 1 z

x2 - y2 y2 - z2 z2

(d)

2 x+ y 2 y+z 1 z

x2 + y2 y2 + z2 z2 (GATE 2013: 1 Mark)

If the eigenvalues of A are 4 and 8, then (a) x = 4, y = 10 (b) x = 5, y = 8 (c) x = −3, y = 9 (d) x = −4, y = 10 (GATE 2010: 2 Marks)

143. Consider the following system of equations: 3x + 2y = 1 4x + 7z = 1 x+y+z=3 x - 2y + 7z = 0

140. Consider the following matrix:

⎡ 1 2 3⎤ ⎢0 4 7 ⎥ ⎢ ⎥ ⎢⎣0 0 3⎥⎦

Which one of the following options provides the correct values of the eigenvalues of the matrix? (a) 1, 4, 3 (b) 3, 7, 3 (c) 7, 3, 2 (d) 1, 2, 3 (GATE 2011: 2 Marks)

141. Let A be the 2 × 2 matrix with elements a11 = a12 = a21 = + 1 and a22 = −1. Then the eigenvalues of the matrix A19 are (a) 1024 and −1024 (b) 1024 2 and -1024 2 (c) 4 2 and -4 2 (d) 512 2 and -512 2 one of the following options does not equal x2 y ? z2

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 31

. The number of solutions for this system is (GATE 2014: 1 Mark)

144. The value of dot product of the eigenvectors corresponding to any pair of different eigenvalues of a 4-by-4 symmetric positive definite matrix is . (GATE 2014: 1 Mark) 145. Let the function sin θ cos θ tan θ f (θ ) = sin(p / 6) cos(p / 6) tan(p / 6) sin(p / 3) cos(p / 3) tan(p /3) ⎡p p ⎤ where θ ∈ ⎢ , ⎥ and f ′(θ ) denote the derivative of f ⎣6 3⎦ with respect to q. Which of the following statements is/ are TRUE?

(GATE 2012: 1 Mark) 142. Which 1 x 1 y 1 z

x +1 y +1 z +1

1 x + 1 x2 + 1 (b) 1 y + 1 y 2 + 1 1 z + 1 z2 + 1

138. How many of the following matrices have an eigenvalue 1?

(a) One (c) Three

31

⎡p p ⎤ (I)  There exists θ ∈ ⎢ , ⎥ such that f ′(θ ) = 0 ⎣6 3⎦

p p (II)  There exists θ ∈ ⎡⎢ , ⎤⎥ such that f ′(θ ) ≠ 0 ⎣6 3⎦ (a) I only (c) Both I and II

(b) II only (d) Neither I nor II (GATE 2014: 1 Mark)

11/13/2018 9:29:13 AM

32

GATE CS AND IT Chapter-wise Solved Papers

146. If the matrix A is such that ⎡2⎤ A = ⎢⎢ -4 ⎥⎥ [1 9 5] ⎢⎣ 7 ⎥⎦ then the determinant of A is equal to . (GATE 2014: 1 Mark) 147. 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 (0) ⋅ f (4) < 0 (c) f (0) + f (4) > 0

(b) f (0) ⋅ f (4) > 0 (d) f (0) + f (4) < 0 (GATE 2014: 1 Mark)

148. 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. (GATE 2014: 1 Mark)

. 152. The number of divisors of 2100 is (GATE 2015: 1 Mark) ⎡ 4 5⎤ 153. The larger of the two eigenvalues of the matrix ⎢ ⎥ ⎣ 2 1⎦ is . (GATE 2015: 1 Mark) ⎡1 -1 2⎤ 154. In the given matrix ⎢⎢0 1 0 ⎥⎥ , one of the eigenvalues ⎢⎣1 2 1 ⎥⎦ is 1. The eigenvectors corresponding to the eigenvalue 1 are (a) {a ( 4, 2,1) | a ≠ 0, a ∈ R} (b) {a ( -4, 2,1) | a ≠ 0, a ∈ R} (c) {a ( 2 , 0,1) | a ≠ 0, a ∈ R} (d) {a ( - 2 , 0,1) | a ≠ 0, a ∈ R} (GATE 2015: 1 Mark) 155. Consider the following 2 × 2 matrix A where two elements are unknown and are marked by a and b. The eigenvalues of this matrix are −1 and 7. What are the values of a and b? ⎛ 1 4⎞ A= ⎜ ⎝ b a⎟⎠

149. 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 be 323 gm. Then the product of the labels of the bags having 11 gm coins is . (GATE 2014: 2 Marks) 150. The product of the non-zero eigenvalues of the matrix ⎡1 ⎢0 ⎢ ⎢0 ⎢ ⎢0 ⎢⎣1 is

0 1 1 1 0

0 1 1 1 0

 .

151. If g(x) = 1 - x and h( x ) =

0 1 1 1 0

1⎤ 0 ⎥⎥ 0⎥ ⎥ 0⎥ 1 ⎥⎦ (GATE 2014: 2 Marks)

g[h( x )] x is , then x -1 h[ g ( x )]

(a)

h( x ) -1 (b) g( x) x

(c)

g( x) x (d) h( x ) (1 - x ) 2 (GATE 2015: 1 Mark)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 32

(a) (b) (c) (d)

a = 6, b = 4 a = 4, b = 6 a = 3, b = 5 a = 5, b = 3 (GATE 2015: 2 Marks)

156. Perform ⎡3 4 ⎢7 9 ⎢ ⎢⎣13 2

the following operations on the matrix 45 ⎤ 105⎥⎥ 195⎥⎦

(i)  Add the third row to the second row. (ii)  Subtract the third column from the first column. . The determinant of the resultant matrix is (GATE 2015: 2 Marks)

157. If the following system has non-trivial solution px + qy + rz = 0 qx + ry + pz = 0 rx + py + qz = 0 then which one of the following options is TRUE?

11/13/2018 9:29:14 AM

Chapter 1  • Engineering Mathematics

(a) (b) (c) (d)

p - q + r = 0 or p = q = −r p + q - r = 0 or p = -q = r p + q + r = 0 or p = q = r p - q + r = 0 or p = −q = −r (GATE 2015: 2 Marks)

158. Two eigenvalues of a 3 × 3 real matrix P are ( 2 + -1) and 3. The determinant of P is __________. (GATE 2016: 1 Mark) 159. Suppose that the eigenvalues of matrix A are 1, 2, 4. The determinant of (A−1)T is __________. (GATE 2016: 1 Mark) 160. Consider the recurrence relation a1 = 8, an = 6n2 + 2n + an − 1. Let a99 = K × 104. The value of K is __________. (GATE 2016: 2 Marks) 161. A function f :  + →  + , defined on the set of positive integers N+, satisfies the following properties: f(n) = f(n/2), if n is even f(n) = f(n + 5),  if n is odd Let R = {i | ∃j : f (j) = i} be the set of distinct values that f takes. The maximum possible size of R is __________. (GATE 2016: 2 Marks) 162. Let A1, A2, A3, and A4 be four matrices of dimensions 10 × 5, 5 × 20, 20 × 10, and 10 × 5, respectively. The minimum number of scalar multiplications required to find the product A1A2A3A4 using the basic matrix multiplication method is __________. (GATE 2016: 2 Marks) 163. Let c1, …, cn be scalars, not all zero, such that n

∑ca i =1



i

i

= 0, where ai are column vectors in Rn.

Consider the set of linear equations Ax = b, where A = n

[a1 … an] and b = ∑ a i . The set of equations has i =1

(a) a unique solution at x = Jn, where Jn denotes an n-dimensional vector of all 1 (b) no solution (c) infinitely many solutions (d) finitely many solutions (GATE 2017: 1 Mark) 164. Consider a quadratic equation x2 - 13x + 36 = 0 with coefficients in a base b. The solutions of this equation in the same base b are x = 5 and x = 6. Then b = ____________. (GATE 2017: 1 Mark)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 33

33

165. Let u and v be two vectors in R2 whose Euclidean norms satisfy ||u|| = 2 ||v||. What is the value of a such that w = u + a v bisects the angle between u and v? (a) 2 (b) 1/2 (c) 1 (d) -1/2 (GATE 2017: 2 Marks) 166. Let A be n × n real-valued square symmetric matrix n

of rank 2 with

n

∑∑ A i =1 j =1



2 ij

= 50. Consider the following

statements. I.  One eigenvalue must be in [-5, 5]. II. The eigenvalue with the largest magnitude must be strictly greater than 5. Which of the above statements about eigenvalues of A is/are necessarily CORRECT? (a) Both I and II (b) I only (c) II only (d) Neither I nor II (GATE 2017: 2 Marks)

167. If the characteristic polynomial of a 3 × 3 matrix M over  (the set of real numbers) is l3 - 4l2 + al + 30, a ∈ and one eigenvalue of M is 2, then the largest among the absolute value of the eigenvalues of M is _____________. (GATE 2017: 2 Marks) ⎛ 1⎞ ⎛ 1⎞ 168. Consider a matrix A = uvT where u = ⎜ ⎟ , v = ⎜ ⎟ . ⎝ 2⎠ ⎝ 1⎠ Note that vT denotes the transpose of v. the largest eigenvalue of A is . (GATE 2018: 1 Mark) 169. Consider a matrix P whose only eigenvectors are the ⎡1 ⎤ multiples of ⎢ ⎥ . ⎣4⎦ Consider the following statements. (I)  P does not have an inverse (II)  P has a repeated eigenvalue (III)  P cannot be diagonalized Which one of the following options is correct? (a) Only I and III are necessarily true (b) Only II is necessarily true (c) Only I and II are necessarily true (d) Only II and III are necessarily true (GATE 2018: 2 Marks)

Calculus 170. The trapezoidal rule for integration gives exact result when the integrand is a polynomial of degree

11/13/2018 9:29:15 AM

34

GATE CS AND IT Chapter-wise Solved Papers

(a) 0 but not 1 (c) 0 or 1

(b) 1 but not 0 (d) 2 (GATE 2002: 1 Mark)

177. Function f is known at the following points: x

0 0.3 0.6 0.9 1.2 1.5 1.8 2.1 2.4 2.7 3.0

f(x) 0 0.09 0.36 0.81 1.44 2.25 3.24 4.41 5.76 7.29 9.00 3 ⎛X ⎞ 171. The Newton-Raphson iteration X n +1 = ⎜ n ⎟ + ⎝ 2 ⎠ (2 X n ) 3 The value of ∫ f ( x )dx computed using the ­trapezoidal can be used to solve the equation 0 rule is (a) X 2 = 3 (b) X 3 = 3 (a) 8.983 (b) 9.003 (c) X 2 = 2 (d) X 3 = 2 (c) 9.017 (d) 9.045 (GATE 2002: 2 Marks) x - sin x (GATE 2013: 1 Mark) 172. lim equals x →∞ x + cos x 2p (a) 1 (b) −1 178. If ∫ | x sin x | dx = k p , then the value of k is equal to 0 (c) ∞ (d) −∞ . (GATE 2008: 1 Mark) (GATE 2014: 1 Mark) p / 4 (1 - tan x ) dx evaluates to 173. ∫ 179. The minimum number of comparisons required to find 0 (1 + tan x ) the minimum and the maximum of 100 numbers is (a) 0 (b) 1 . (c) ln 2 (d) 1/2 ln 2 (GATE 2014: 2 Marks) (GATE 2009: 2 Marks) 180. The function f(x) = x sin x satisfies the following equa2n tion f ″(x) + f(x) + t cos x = 0. The value of t is  . ⎛ 1⎞ 174. What is the value of lim ⎜1 - ⎟ ? n →∞ ⎝ (GATE 2014: 2 Marks) n⎠ (a) 0 (c) e−1/2

(b) e−2 (d) 1 (GATE 2010: 1 Mark)

181. A function f (x) is continuous in the interval [0,2]. It is known that f (0) = f (2) = −1 and f (1) = 1. Which one of the following statements must be true? (a) There exists a y in the interval (0,1) such that f (y) = 175. Given i = -1, what will be the evaluation of the defif (y + 1). p / 2 cos x + i sin x nite integral ∫ dx ? (b) For every y in the interval (0,1), f (y) = f (2 − y). 0 cos x - i sin x (c) The maximum value of the function in the interval (a) 0 (b) 2 (0.2) is 1. (c) −i (d) i (d) There exists a y in the interval (0,1) such that f (y) = (GATE 2011: 2 Marks) f (2 − y). (GATE 2014: 2 Marks) 176. Which one of the following functions is continuous at x = 3? 182. In the Newton-Raphson method, an initial guess of

(a)

⎧ ⎪2, if x = 3 ⎪ f ( x ) = ⎨ x - 1, if x > 3 ⎪x +3 ⎪ , if x < 3 ⎩ 3

(b)

if x = 3 ⎧4, f ( x) = ⎨ ⎩8 - x, if x ≠ 3

(c)

⎧ x + 3, if x ≤ 3 f ( x) = ⎨ ⎩ x - 4, if x > 3

(d)

f ( x) =



1 , if x ≠ 3 x 3 - 27 (GATE 2013: 1 Mark)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 34

x0 = 2 is made and the sequence x0, x1, x2, ... is obtained for the function 0.75x3 − 2x2 − 2x + 4 = 0 Consider the statements (I)  x3 = 0. (II) The method converges to a solution in a finite number of iterations. Which of the following is TRUE? (a) Only I (b) Only II (c) Both I and II (d) Neither I nor II (GATE 2014: 2 Marks)

183. The number of distinct positive integral factors of 2014 is  . (GATE 2014: 2 Marks)

11/13/2018 9:29:18 AM

35

Chapter 1  • Engineering Mathematics

184. With respect to the numerical evaluation of the definite b

integral, K = ∫ x 2 dx, where a and b are given, which

(b)

1 a2 - b2

47b ⎤ ⎡ ⎢ a( 2 ln 2 - 25) - 2 ⎥ ⎣ ⎦

(c)

1 a2 - b2

47b ⎤ ⎡ ⎢ a( 2 ln 2 - 25) + 2 ⎥ ⎣ ⎦

a





of the following statements is/are TRUE? (I) The value of K obtained using the trapezoidal rule is always greater than or equal to the exact value of the definite integral. (II) The value of K obtained using the Simpson’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 (GATE 2014: 2 Marks)

47b ⎤ ⎡ ⎢ a(ln 2 - 25) - 2 ⎥ ⎣ ⎦ (GATE 2015: 2 Marks) 191. The velocity v (in kilometer/minute) of a motorbike which starts from rest is given at fixed intervals of time t (in minutes) as follows: (d)

185. The value of the integral given below is p

∫x

2

cos x dx

0

(a) −2p (b) p (c) −p (d) 2p (GATE 2014: 2 Marks) 186. The value of lim(1 + x 2 )e

-x

x →∞

1 2 (d) ∞ (GATE 2015: 1 Mark)

(a) 0

(b)

(c) 1 2 /p

187.



1 /p

is

cos(1/x ) dx = ____________ . x2 (GATE 2015: 2 Marks)



t

2

4

6

8

10

12

14

16

18

20

v

10

18

25

29

32

20

11

5

2

0

The approximate distance (in kilometers) rounded to two places of decimals covered in 20 min using Simp. son’s 1/3rd rule is (GATE 2015: 2 Marks)

192. lim x→4

0

(GATE 2015: 2 Marks) 189. Let f(x) = x−(1/3) and A denote the area of the region bounded by f(x) and the X-axis, when x varies from −1 to 1. Which of the following statements is/are TRUE? (i)  f is continuous in [−1, 1] (ii)  f is not bounded in [−1, 1] (iii)  A is non-zero and finite (a) (ii) only (b) (iii) only (c) (ii) and (iii) only (d) (i), (ii) and (iii) (GATE 2015: 2 Marks) ⎛ 1⎞ 1 190. If for non-zero x, af ( x ) + bf ⎜ ⎟ = - 25 where a ≠ b ⎝ x⎠ x 2

(a)

1 a - b2 2

2R , then the constants R and S are, p

respectively, 2 16 2 (b) and and 0 p p p 4 4 16 (c) and 0 (d) and p p p (GATE 2017: 1 Mark) (a)

195. The value of lim x →1

47b ⎤ ⎡ ⎢ a(ln 2 - 25) + 2 ⎥ ⎣ ⎦

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 35

x7 - 2 x5 + 1 x 3 - 3x 2 + 2

(a) is 0 (b) is -1 (c) is 1 (d) does not exist (GATE 2017: 2 Marks)

is

1

(GATE 2016: 1 Mark)

⎛ px⎞ ⎛ 1⎞ 194. If f ( x ) = R sin ⎜ ⎟ + S , f ′ ⎜ ⎟ = 2 and ⎝ 2⎠ ⎝ 2⎠

∫ f ( x)dx =

1 188. ∑ = __________ . x ( x + 1) x =1

∫ f ( x)dx

sin( x - 4) = __________. x-4

193. The coefficient of x12 in (x3 + x4 + x5 + x6 + ⋅⋅⋅)3 is __________. (GATE 2016: 2 Marks)

1

99

then

1 a2 - b2

196. The value of



p 4

0

x cos ( x 2 )dx correct to three decimal

places (assuming that p = 3.14) is . (GATE 2018: 1 Mark)

11/13/2018 9:29:21 AM

36

GATE CS AND IT Chapter-wise Solved Papers

Probability 197. The minimum number of cards to be dealt from an arbitrarily shuffled deck of 52 cards to guarantee that three cards are from some same suit is (a) 3 (b) 8 (c) 9 (d) 12 (GATE 2000: 1 Mark) 198. E1 and E2 are events in a probability space satisfying the following constraints: • Pr(E1) = Pr(E2)





Pr( E1 ∪ E2 ) = 1



E1 and E2 are independent

The value of Pr(E1), the probability of the event E1, is 1 (a) 0 (b) 4 1 (c) (d) 1 2 (GATE 2000: 2 Marks)

199. Seven (distinct) car accidents occurred in a week. What is the probability that they all occurred on the same day? 1 77 1 (c) 27

1 76 7 (d) 7 2 (GATE 2001: 2 Marks)

(a)

(b)

200. Four fair coins are tossed simultaneously. The probability that at least one head and one tail turn up is 1 1 (a) (b) 16 8 7 15 (c) (d) 8 16 (GATE 2002: 2 Marks) 201. Let P(E) denotes the probability of the event E. Given P(A) = 1, P(B) = 1/2, the values of P(A/B) and P(B/A), respectively, are (a) 1/4, 1/2 (b) 1/2, 1/4 (c) 1/2, 1 (d) 1, 1/2 (GATE 2003: 1 Mark) 202. A program consists of two modules executed sequentially. Let f1 (t) and f 2 (t), respectively, denote the probability density functions of time taken to execute the two modules. The probability density function of the overall time taken to execute the program is given by (a)

f1 (t ) + f 2 (t ) t

(b)

∫ f ( x) f 1

2

1

(c)

∫ f ( x) f 1

2

(t - x )dx

0

(d) max { f1 (t ), f 2 (t )} (GATE 2003: 2 Marks) 203. If a fair coin is tossed four times, then what is the probability that two heads and two tails will result? (a) 3/8 (b) 1/2 (c) 5/8 (d) 3/4 (GATE 2004: 1 Mark) 204. Two n bit binary strings, S1 and S2 are chosen randomly with uniform probability. The probability that the hamming distance between these strings (the number of bit positions where the two strings differ) is equal to d is (a)

n

n Cd /2n (b) Cd /2d

(c) d/2n

(d) 1/2d (GATE 2004: 2 Marks)

205. A point is randomly selected with uniform probability in the x – y plane within the rectangle with corners at (0, 0), (1, 0), (1, 2) and (0, 2). If p is the length of the position 2 vector of the point, the expected value of p is (a) 2/3 (c) 4/3

(b) 1 (d) 5/3 (GATE 2004: 2 Marks)

206. 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) (b) f(b) − f(a) (c)

b

b

a

a

∫ f ( x)dx (d) ∫ xf ( x)dx (GATE 2005: 1 Mark)

207. For each element in a set of size 2n, an unbiased coin is tossed. The 2n coins tossed are independent. An element is chosen if the corresponding coin toss were head. The probability that exactly n elements are chosen is (a)

2n

2n Cn (b) Cn n 4 2n

1 1 (d) 2 Cn (GATE 2006: 2 Marks) 208. Suppose we uniformly and randomly select a permutation from the 20! permutations of 1, 2, 3, …, 20. What is the probability that 2 appears at an earlier position than any other even number in the selected permutation? (c)

2n

( x )dx

0

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 36

11/13/2018 9:29:25 AM

37

Chapter 1  • Engineering Mathematics

(a)

1 2

(b)

1 10

(c)

9! 20!

(d) None of these (GATE 2007: 2 Marks)

209. Aishwarya studies either computer science or mathematics everyday. 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 (b) 0.36 (c) 0.4 (d) 0.6 (GATE 2008: 2 Marks) 210. Let X be a random variable following normal distribution with mean +1 and variance 4. Let Y be another normal variable with mean −1 and variance unknown. If P(X ≤ −1) = P(Y ≥ 2), the standard deviation of Y is (a) 3 (b) 2 (c) 2 (d) 1 (GATE 2008: 2 Marks) 211. 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 (b) 0.468 (c) 0.485 (d) 0.492 (GATE 2009: 2 Marks) 212. 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? (a) pq + (1 − p) (1 − q) (b) (1 − q)p (c) (1 − p)q (d) pq (GATE 2010: 2 Marks) 213. A deck of five 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?

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 37

(a)

1 4 (b) 5 25

(c) 1.4

(d)

2 5

(GATE 2011: 2 Marks) 214. Consider the finite sequence of random ­ values X  = [ x1 , x2 ,… , xn ] . Let m x be the mean and σ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 constant. Let m y be the mean and σ 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) my = amx + b (d) σy = aσx + b (GATE 2011: 2 Marks) 215. 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 = −1 and +1 are (a) 0 and 0.5 (b) 0 and 1 (c) 0.5 and 1 (d) 0.25 and 0.75  (GATE 2012: 1 Mark) 216. Suppose p is the number of cars per minute passing through a certain road junction around 5 PM, and p has Poisson distribution with mean 3. What is the probability of observing fewer than 3 cars during any given minute in this interval? (a) 8 ( 2e 3 ) (b) 9 ( 2e 3 ) (c) 17 ( 2e 3 ) (d) 26 ( 2e 3 ) (GATE 2013: 1 Mark) 217. Suppose you break a stick of unit length at a point chosen uniformly at random. Then the expected length of the shorter stick is . (GATE 2014: 1 Mark) 218. 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 = . (GATE 2014: 1 Mark)

11/13/2018 9:29:29 AM

38

GATE CS AND IT Chapter-wise Solved Papers

219. Each of the nine words in the sentence ‘The quick brown fox jumps over the lazy dog’ is written on a separate 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.) (GATE 2014: 1 Mark) 220. 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 . (GATE 2014: 2 Marks) 221. The probability that a given positive integer lying between 1 and 100 (both inclusive) is NOT divisible by 2, 3 or 5 is . (GATE 2014: 2 Marks) 222. Let S be a sample space and two mutually exclusive events A and B be such that A ∪ B = S. If P(.) denotes the probability of the event, the maximum value of P(A) P(B) is . (GATE 2014: 2 Marks) 223. Let X and Y denote the sets containing 2 and 20 distinct objects, respectively, and F denote the set of all possible functions defined from X to Y. Let f be randomly chosen from F. The probability of f being chosen from F. The probability of f being one-to-one is . (GATE 2015: 2 Marks) 224. A probability density function on the interval [a, 1] is given by 1/x2 and outside this interval the value of the function is zero. The value of a is __________. (GATE 2016: 1 Mark) 225. Suppose that a shop has an equal number of LED bulbs of two different types. The probability of an LED bulb lasting more than 100 hours given that it is of Type 1 is 0.7, and given that it is of Type 2 is 0.4. The probability that an LED bulb chosen uniformly at random lasts more than 100 hours is __________. (GATE 2016: 1 Mark) 226. Consider the following experiment.

Step 1. Flip a fair coin twice. Step 2. If the outcomes are (TAILS, HEADS) then output Y and stop.



Step 3. If the outcomes are either (HEADS, HEADS) or (HEADS, TAILS), then output N and stop.



Step 4. If the outcomes are (TAILS, TAILS), then go to Step 1.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 38

The probability that the output of the experiment is Y is (up to two decimal places) __________. (GATE 2016: 2 Marks) 227. Let X be a Gaussian random variable with mean 0 and variance s  2. Let Y = max (X, 0), where max (a, b) is the maximum of a and b. The median of Y is _____________. (GATE 2017: 1 Mark) 228. If a random variable X has a Poisson distribution with mean 5, then the expectation E[(X + 2)2] equals ______. (GATE 2017: 2 Marks) 229. Two people, P and Q, decide to independently roll two identical dice, each with 6 faces, numbered 1 to 6. The person with the lower number wins. In case of a tie, they roll the dice repeatedly until there is no tie. Define a trial as a throw of the dice by P and Q, assume that all 6 numbers on each dice are equi-probable and that all trials are independent. The probability (rounded to 3 decimal places) that one of them wins on the third trial is . (GATE 2018: 1 Mark) 230. Consider Guwahati (G) and Delhi (D) whose temperatures can be classified as high (H), medium (M) and low (L). Let P(HG) denote the probability that Guwahati has high temperature. Similarly, P(MG) and P(LG) denotes the probability of Guwahati having medium and low temperatures respectively. Similarly, we use P(HD), P(MD) and P(LD) for Delhi. The following table gives the conditional probabilities for Delhi’s temperature given Guwahati’s temperature. HD

MD

LD

HG

0.40

0.48

0.12

MG

0.10

0.65

0.25

LG

0.01

0.50

0.49

Consider the first row in the table above. The first entry denotes that if Guwahati has high temperature (HG) then the probability of Delhi also having a high temperature (HD) is 0.40; i.e., P(HD)(HG) = 0.40. similarly, the net two entries are P(MD)(HG) = 0.48 and P(LD)(HG) = 0.12 Similarly for the other rows. If it is known that P(HG) = 0.2P(MG) = 0.5, and P(LG) = 0.3, then the probability (correct to two decimal places) that Guwahati has temperature given that Delhi has high temperature is . (GATE 2018: 2 Marks)

11/13/2018 9:29:30 AM

39

Chapter 1  • Engineering Mathematics

ANSWER KEY Discrete Mathematics   1. (d)

  2. (a)

  3. (c)

  4. (b)

  5. (a)

  6. (d)

  7. (b)

  8. (a)

  9. (b)

  10. (b)

  11. (c)

  12. (a)

  13. (b)

  14. (d)

  15. (b)

  16. (a)

  17. (d)

  18. (a)

  19. (d)

  20. (c)

  21. (a)

  22. (c)

  23. (b)

  24. (a)

  25. (d)

  26. (d)

  27. (c)

  28. (b)

  29. (a)

  30. (a)

  31. (c)

  32. (d)

  33. (b)

  34. (b)

  35. (a)

  36. (a)

  37. (a)

  38. (c)

  39. (b)

  40. (b)

  41. (d)

  42. (d)

  43. (d)

  44. (b)

  45. (b)

  46. (d)

  47. (d)

  48. (a)

  49. (d)

  50. (d)

  51. (c)

  52. (d)

  53. (c)

  54. (a)

  55. (a)

  56. (b)

  57. (a)

  58. (d)

  59. (d)

  60. (c)

  61. (c)

  62. (c)

  63. (a)

  64. (d)

  65. (d)

  66. (d)

  67. (c)

  68. (b)

  69. (d)

  70. (b)

  71. (d)

  72. (d)

  73. (b)

  74. (c)

  75. (c)

  76. (36)

  77. (b)

  78. (d)

  79. (d)

  80. (5)

  81. (2)

  82. (19)

  83. (a)

  84. (5)

  85. (0.25)   86. (b)

  87. (4)

  88. (c)

  89. (a)

  90. (d)

  91. (c)

  92. (c)

  93. (24)   94. (d)

  95. (c)

  96. (c)

  97. (1)

  98. (c)

  99. (d)

100. (c)

101. (d)

102. (11)

103. (b)

104. (b)

105. (3)

106. (4)

107. (c)

108. (198) 109. (2)

111. (7)

112. (d)

113. (b)

114. (4)

115. (d)

116. (b)

117. (18) 118. (a)

121. (d)

122. (271) 123. (15) 124. (d)

125. (42)

126. (d)

119. 0

110. (12) 120. (16)

Linear Algebra 127.  (a)

128.  (d)

129.  (a)

130.  (c)

131.  (b)

132.  (b)

133.  (c)

134.  (b)

135.  (b)

136.  (a)

137.  (d)

138.  (a)

139.  (d)

140.  (a)

141.  (d)

142.  (a)

143.  (1)

144.  (0)

145.  (c)

146.  (0)

147.  (a)

148.  (a)

149.  (12)

150.  (6)

151.  (a)

152.  (36)

153.  (6)

154.  (b)

155.  (d)

156.  (0)

157.  (c)

158.  (15)

159.  (0.125)

160.  (198)

161.  (2)

162.  (1500)

163.  (c)

164.  (8)

165.  (a)

166.  (b)

167.  (5)

168.  (3)

169.  (d)

Calculus 170.  (c)

171.  (a)

172.  (a)

173.  (d)

174.  (b)

175.  (d)

176.  (a)

177.  (d)

178.  (4)

180.  (-2) 181.  (a)

182.  (a)

183.  (8)

184.  (c)

185.  (a)

186.  (a)

187.  (-1)

188.  (0.99) 189.  (a)

192.  (1)

193.  (10) 194.  (c)

195.  (c)

196.  (0.289)

190.  (a)

191.  (309.33)

179.  (148)

Probability 197. (c)

198. (d)

199. (b)

200. (c)

201. (d)

202. (c)

203. (a)

204. (a)

205. (d)

206. (c)

207. (a)

208. (d)

209. (c)

210. (a)

211. (b)

212. (a)

213. (a)

214. (d)

215. (c)

216. (c)

217. (0.25)

218. (11.92) 219. (3.88)

220. (10) 221.  (0.259 to 0.261)

225. (0.55)

226. (0.33)

228. (54) 229. (0.023) 230. (0.601)

223. (0.95) 224. (0.5)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Qns.indd 39

227. (0)

222. (0.25)

11/13/2018 9:29:30 AM

40

GATE CS AND IT Chapter-wise Solved Papers

ANSWERS WITH EXPLANATION Discrete Mathematics

1.

From Eq. (1) we have ( a ∧ b) → (( a ∧ c) ∨ d ) ↔ -( a ∧ b) ∨ (( a ∧ c) ∨ d ) ↔ -(1 ∧ b) ∨ ((1 ∧ c) ∨ d ) (d)  Given X, Y, Z are closed intervals of unit length on ( a ∧ b) → (( a ∧ c) ∨ d ) ↔ -( a ∧ b) ∨ (( a ∧ c) ∨ d ) ↔ -(1 ∧ b) ∨ ((1 ∧ c) ∨ d ) real line.    Now using Eq. (2) we get Overlap of X and Y is half a unit. ( a ∧ b) ↔ - b ∨ ( c ∨ d ) ↔ - c ∨ ( c ∨ d ) Overlap of Y and Z is also half a unit. ( a ∧ b) ↔ ( - c ∨ c ) ∨ d ↔ 1 ∨ d ↔ 1 Overlap of X and Z is k units. The value of k can be either 0 or 1. So, none of the given statements is true Therefore, option (d) is true.

2.

6.

f ( n) = 3n

100

S = ∑ i log 2 i i=3

100



∫ x log

2

x dx

2

Hence, statement (a) is true.

7.

(b)  R1(a, b) is equivalence relation since R1(a, b) is reflexive, symmetric and transitive. R2(a, b) is not equivalence relation since R2(a, b) is not reflexive. R3(a, b) is equivalence relation since R3(a, b) is reflexive, symmetric and transitive. R4(a, b) is not equivalence relation since R4(a, b) is not transitive. Therefore, R1 and R3 are equivalence relations, R2 and R4 are not.

8.

(a)  According to the question, F1: P ⇒ ¬P F 2 : ( P ⇒ ¬P ) ∨ ( ¬P ⇒ P )

100

⎡1 x ⎤ x dx = ⎢ x 2 log 2 x ⎥ 4 ln 2 ⎦ 2 ⎣2 2 1 25000 ⇒ T = 10 4 log 2 10 -2+ ln 2 ln 2 100

T=

∫ x log

2

2

⇒ T = 29611.98604 100

S = ∑ i log 2 i = 29943.6486



and



Therefore,

3.

(c)  R is defined as, xRy if f (x + y) is even. R is an equivalent relation having 2 equivalence classes. 1. All odd integers: sum of two odd is even so reflexive + operation is symmetric and transitive. 2. All even integers: sum of two even is even so reflexive + operation is symmetric and transitive.

i=3

4.

S>T

The formula is satisfiable if there is an assignment of truth values which makes that expression true. The formula is unsatisfiable if there is no such assignment which makes the expression true. The formula is valid if the expression is tautology. F1 is satisfiable because F1 will be true if P is false and F1 will be false when P is true. F1: P ⇒ ¬P = ¬P ∨ ¬P = ¬P F2 is a tautology and is therefore valid F 2:( P ⇒ ¬P ) ∨ ( ¬P ⇒ P ) = ( ¬P ∨ ¬P ) ∨ ( ¬( ¬P ) ∨ P )) = ( ¬P ) ∨ ( P ) Therefore, F1 is satisfiable and F2 is valid.

(b)  P(S) is power set of set S Let S = {1} Then, P ( S ) = {{1}, ϕ} or

P ( P ( S )) = {ϕ ,{ϕ},{1},{ϕ ,{1}}}

So, P ( P ( S )) ∩ P ( S ) = {ϕ} Therefore, option (b) is always true. 5.

(a)  Let a, b, c, d be propositions. Then Equivalences a ↔ (b ∨ -b) ↔ 1 (1)

b ↔ c

Then ( a ∧ b) → (( a ∧ c) ∨ d ) is always true.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 40

n

g ( n) = 2 n log2 n h(n) = n! here f (n) and g(n) are of same asymptotic order. So, f (n) = O(g(n)) g(n) = O( f (n)) Therefore, f (n) is O(g(n)).

(a)  Given that,

T=

(d)  Given

(2)

9.

(b)  Given f (n) = n2logn g(n) = n(logn)10

11/13/2018 9:32:38 AM

41

Chapter 1  • Engineering Mathematics

Removing common factors in f (n) and g(n) we get f (n) = n g(n) = (log n)9 Here f (n) is asymptotically larger than g(n) because n is very large compared to logn. Therefore, g(n) = O(f (n)) and f (n) ≠ O(g(n)) 10. (b)  There are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 that is total 10 digits. Even numbers can have 0, 2, 4, 6, and 8 as last digits. When last digit is 0 – total numbers = 9 × 8 × 7 = 504 When last digit is 2 – total numbers = 9 × 8 × 7 = 504 removing number having 0 as first digit = 8 × 7 = 56 So, total numbers having 2 as last digit = 504 – 56 = 448 Similarly, total numbers having 4, 6, and 8 as last digit also equals 448 Therefore, total 4 digit even numbers = 4 × 448 + 504 = 2296. 11. (c)  Given that S1: There exists infinite set A, B, C such that A ∩ ( B ∪ C ) is finite. S2: There exists two irrational numbers x and y such that (x + y) is rational. Let A = {2, 4, 6, 8…} B = {1, 3, 5, 7…} C = {2, 3, 5, 7, 11…} So, B ∪ C = {1, 2, 3, 5, 7, 9,11} And A ∩ ( B ∪ C ) = {2} This is finite so statement S1 is correct. Now let, x = 2- 3 y = 2+ 3 x+ y = 2- 3+2+ 3 = 4 Then, This is rational so statement S2 is correct. 12. (a)  Given that S1: f ( E ∪ F ) = f ( E ) ∪ f ( F ) S2 : f ( E ∩ F ) = f ( E ) ∩ f ( F ) In statement S1 S1: f ( E ∪ F ) = f ( E ) ∪ f ( F ) f ( E ∪ F ) and f ( E ) ∪ f ( F ) both contain exactly the images of all elements in E and F. So statement S1 is correct. But, in S2 statement S2 : f ( E ∩ F ) = f ( E ) ∩ f ( F )

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 41

f ( E ∩ F ) and f ( E ) ∩ f ( F ) both may or may not contain exactly the images of all elements in E and F. Therefore, S2 statement is not correct. 13. (b)  Given that, T ( 2k ) = 3T ( 2k -1 ) + 1 T (1) = 1 We can write T ( 2k ) = 3T ( 2k -1 ) + 1 T ( 2k ) = 3 ⋅ (3T ( 2k - 2 ) + 1) + 1 = 32 T ( 2k - 2 ) + 1 + 3

T ( 2k ) = 32 (3T ( 2k - 3 ) + 1) + 1 + 3 = 32 T ( 2k - 3 ) + 1 + 3 + 9 and so on, at kth step, T ( 2k ) = 3k T ( 2k - k ) + 1 + 3 + 9 +  + 3k -1 T ( 2k ) = 3k T (1) + (1 + 3 + 9 +  + 3k -1 ) ⎛ 3k - 1⎞ 2 ⋅ 3k ⋅1 + 3k - 1 T ( 2k ) = 3k ⋅1 + ⎜ = 2 ⎝ 2 ⎟⎠



3 ⋅ 3k - 1 3k +1 - 1 = 2 2 Thus, solution of given recurrence equation is T ( 2k ) =

(3k +1 - 1) 2 14. (d)  In order that no two adjacent nodes have same colour a cycle with odd number of nodes require three colours and a cycle with even number of nodes require two colours. Thus, minimum number of colours needed to colour the vertices of a cycle with n nodes is ⎡n⎤ n- 2⎢ ⎥ + 2 ⎣2⎦ 15. (b)  A group is a set of elements with following properties: 1. Closure 2. Associative 3. Identity 4. Inverse Among the given options, option (b) is correct as the set of all non- singular matrices forms a group under multiplication. 16. (a)  The statement “If X then Y unless Z” implies that if Z does not occur then X implies Y. In propositional logic this can be represented as ( X ∧ ¬ Z) → Y 17. (d)  A relation is reflexive if every element of set is paired with itself. A relation is symmetric if for ( a, b) ∈ s∃(b, a) ∈ s

11/13/2018 9:32:41 AM

42

GATE CS AND IT Chapter-wise Solved Papers

A relation is transitive if for ( a, b) and (b, c) ∈ s∃( a, c) ∈s Given s = ϕ on set A = {1, 2, 3} is transitive and ­symmetric 18. (a)  Minimum: It may be possible that the removed vertex doesn’t disconnect its component. Maximum: It may be possible that the removed vertex disconnects all components. 19. (d)  For the sequence (II), that is, a b f e h g, it can be seen that there is no direct connection between f and e. 20. (c)  ( S , ≤) is partial order in which S is reflexive, symmetric and transitive. We have P ( a) = True, P (b) = False and P ( x ) ⇒ P ( y ) Since P(x) implies P(y) and a, y ∈ S satisfies x < y. Therefore - P ( x ) ∪ P ( y ) ⇒ False ∪ False ⇒ 1 False Hence, P ( x ) = False for all x ∈ S , such that b ≤ x and x ≠ c. 21. (a)  We have

α = (∀x )[ Px ⇔ (∀y )[Qxy ⇔ ¬Qyy ]] ⇒ (∀x )[¬P ] I1: Domain: the set of natural numbers Px= “x is a prime number” = 2, 3, 5, 7, 11, 13, … Qxy = “y divides x” = 2, 3, 5, 7, 11, 13, … I2: Px = “x is a composite number means number is not a prime number” = 4, 6, 8, 9, 10, 12, 14, … Qxy = 2, 3, 5, 7, 11, 13, … Thus, I1 satisfies α , I2 does not. 22. (c)  We have A( x ) ← B( x, y ), C ( y ) ← B( x, x ) Now, we can write B( x, x ) → B( x, y ), C ( y ) → A( x ) B(x, x) → ⎤ [B (x, y), C ( y)] ∪ A(x) B(x, x) ∪ ⎤ [B (x, y), C (y)] ∪ A(x) Also, we can write ∀ (⎤ B)( x, x ) ∪ ⎤ ( B( x, y )), C ( y )) ∪ A( x ) Rewriting option (c),

⇒ ( ∀x ) ⎡⎣( ∀y ) ⎤ ⎡⎣ B ( x, y ) ∧ C ( y ) ⎤⎦ ∪ A ( x ) ∪ ( ∀x ) [⎤B(x, x)] ⇒ ( ∀xy ) [⎤B(x, y) ∪ ⎤C(y) ∪ A(x) ⎤B(x, x)] ⇒ ∀ [⎤(B(x, y), C(y)) ∪ A(x) ⎤B(x, x)] Thus, the correct answer is (c). 23. (b) If P = True, Q = False, and R = True, then (T ∪ F ) ⇒ ( (T ∪ T ) ∧ ( F ∪ F ) ) T ⇒ (T ∧ F ) T⇒F Therefore F ∪ F = False (is not valid)

Hence, “ ( P ∨ Q ) ⇒ ( ( P ∨ R ) ∧ ( Q ∨ ¬R ) ) is logically valid” is the incorrect statement. 24. (a)  In a perfect matching, every vertex of the graph is incident to exactly one edge of the matching. A perfect matching is therefore a matching of a graph containing n/2 edges, the largest possible, meaning perfect matching are only possible on graphs with an even number of vertices. 25. (d)  Let the min-degree of G be x. Then G has at least v ∗ x / 2 edges. v ∗ x / 2 0, x2 replaces x1 and x0 = 1 and x1 = 3. After third iteration, 1+ 3 x2 = = 2 which is exactly a root. 2 Therefore, the method converges exactly to the root in 3 iterations. 71. (a) and (d)  We have ¬∃x ( ∀y (α ) ∧ ∀z ( β ) ) . Using the identity ¬ ( p ∧ q ) ≡ p ⇒ ¬q, we get

¬∃x ( ∀y (α ) ∧ ∀z ( β ) ) ≡ ∀× ⎡⎣∀y (α ) → ∃z ( ¬β ) ⎤⎦ Using the identity p ⇒ q ≡ ¬q ⇒ ¬p, we get ¬∃x ( ∀y (α ) ∧ ∀z ( β ) ) ≡ ∀× ⎡⎣∀z ( β ) → ∃y ( ¬α ) ⎤⎦ Hence, the correct options are (a) and (d). 72. (d)  S: “Not all that glitters is gold” means there exist some glitters that are not gold. So ∃x is used along with AND operator. ∃x; glitters(x) ∧ ¬ gold(x) 73. (b) Let G be the below graph.

A

B

Then G3 is a graph with below structure.

47

74. (c)  Tightest upper bound for running depth first search using adjacency matrix is Θ(V2). Number of vertices here are n. So, Θ(n2) is the correct option. 75. (c)  Topological order of a directed graph is the linear arrangement of vertices in which if there is an edge between u to v, then u comes before v in order. Option (c) satisfies this property, so both PSRQ and SPRQ are topological orderings. 76. (36)  The maximum number of edges in bipartite n2 graph = 4 For n = 12, maximum number of edges in bipartite 12 × 12 graph = = 36 edges 4 77. (b)  Application of BFS is to find shortest path from u to v. In the given statement, W is the source node. It will calculate shortest path to every node from W. So, option (b) is correct. 78. (d)  P: good mobile phones are not cheap Q: Cheap mobile phones are not good. P → Q and Q → P Hence, P ↔ Q. So, L, M and N are true. 79. (d)  We have f : X → Y defined by f (a) = 1, f (b) = 1, f (c) = 2, where X = {a, b, c}, Y = {1, 2}. 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 ) = {2} ; f ( A) = {1, 2} ; f ( B ) = {1, 2}

f ( A) ∩ f ( B ) = {1, 2} f ( A ∩ B) = 1

Therefore, options (a), (b) and (c) are not true. Hence, option (d) is true. 80. (5)  According to Lagrange’s theorem, the order of subgroup divides order of group. Order of group is 15. 3, 5, 15 divide 15. According to the given condition, size should be atleast 4 and cannot be equal to that of group. So, 5 is the order of subgroup. 81. (2) Let V be {e1, e2, e3, e4, e5, e6} V1 = {e1, e3, e5, e6} V2 = {e2, e3, e4, e5} Smallest possible set of V1∩V2 = 2

A

B

In G the numbers of strongly connected components are 2 whereas in G3 it is only one.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 47

82. (19)  In depth first search, the nodes are traversed in depth. Maximum possible depth is 19.

11/13/2018 9:33:06 AM

48

GATE CS AND IT Chapter-wise Solved Papers

83. (a)  Both S1 and S2 are true.

So, the elements of such group are 4 which are { x, y, e, x × y} .

84. (5) Consider n = 5. V2 V2

V3

V3

88. (c)  In forest each component is a tree. There are G1, G2, …, Gk components. Each has n - 1 edges. k

∑n - i = n - k edges

V1

V1

V5

i =1

V5

V4

Cycle graph

V4

Complement of cycle graph

By checking properties, these two graphs are isomorphic. The value of n is 5. 85. (0.25)  Maximum value of P(A) P(B) = ? P(A)P(B) = P(A)[1 -P(A)] Let P(A) = x

89. (a) Degree ≥ 3 is of n vertices means 3n ≤ 2e → e ≥ 3n/2. We know that e = n + r - 2. So n + r - 2 ≥ 3n/2 ⇒ r ≥ n/2 + 2 90. (d)  “Not all rainy days are cold” can be represented as ∼ ∀d ( Rainy (d ) → Cold ( d )) → ∃d ( Rainy (d ) ∼ Cold (d )) 91. (c) p ↔ q ≡ ( p → q) ∧ ( q → p)

f (x) = x - x2

≡ (⎤ p ∨ q) ∧ (⎤ p ∨ q) (∵ p → q ≡ ⎤ p ∨ q)

f ′(x) = 1 - 2x = 0

≡ ( ⎤ p ∧ ⎤ q) ∨ ( q ∧ ⎤ q)

So, x = 1/2 and f ″(x) = -2 and x is maximum at 1/2. P(A) P(B) = 0.25 86. (b)  Let us consider a function as f (0) = 1, f (1) = 0, f ( 2) = 3, f (3) = 2,… , f ( 2012) = 2013, f ( 2013) = 2012 andd f ( 2014) = 2014 Clearly, f ( f (i )) = i for 0 ≤ i ≤ 2014 Here, f (i ) ≠ i for every i and f (i) = i for some i. Also, f is onto. Hence, only Q and R are true. 87. (4)  We are given x × x = e ⇒ x is its own inverse. y × y = e ⇒ y is its own inverse. ( x × y ) × ( x × y ) = e ⇒ *( x × y ) is its own inverse. ( y × x ) × ( y × x ) = e ⇒ ( y × x ) is its own inverse. Also, x × x × e = e × e can be rewritten as follows: x × y × y × x = e × y × y × e = e [∵ y × y = e ] ( x × y ) × ( y × x ) = e shows that ( x × y ) and ( y × x ) Are each other’s inverse and we already know that ( x × y ) and ( y × x ) are inverse of their own. In order for (G , ∗) to be group any element should have only one inverse element. (Unique) This process x × y = y × x (is one element)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 48

∨ (⎤ p ∧ p) ∨ ( q ∧ p) ( usingg distributive laws) ≡ ( ⎤ p ∧ ⎤ q) ∨ ( q ∧ p) ( using complement and commutative laws) Thus, p ↔ q is not equivalent to ( ⎤ p ∧ q) ∨ ( p ∧ ⎤ q). 92. (c)  2 A → Power set of A, that is set of all subsets of A. Since empty set is a subset of every set, therefore

ϕ ⊆ 2 A and ϕ ∈ 2 A Since, {5, {6}} ⊆ A and 5 ∉ 2 A Thus, {5, {6}} ∈ 2 A and{5, {6}} ⊆ 2 A Hence, (i), (ii) and (iii) are true. 93. (24)  By Euler’s formula, v + f = e + 2, where v, e and f are respectively number of vertices, edges and faces. We are given, v = 10 and number of edges on each face = 3. Thus 2 3 f = 2e ⇒ f = e 3 Putting all the values in Euler’s formula, we get 2 e 10 + e = e + 2 ⇒ = 8 ⇒ e = 24 3 3 94. (d)  Consider first three element of the list, at least one of them will be neither minimum nor maximum. Therefore, the correct answer is option (d).

11/13/2018 9:33:11 AM

Chapter 1  • Engineering Mathematics

95. (c) Let p : candidate known to be corrupt q : candidate will be elected r : candidate is kind Then, s1 : p →∼ q ⇒ q →∼ p ( contrapositive rule ) And  s2 : r → q ⇒ r →∼ p ( transitive rule ) That is if a person is kind, he is not known to be corrupt. Therefore, option (c) is correct.

Now, x ∈ {8, 9, 10, 11, 12} AND (x is not a composite number). However, here only 11 is not composite so the correct answer is x = 11. 103. (b)  Let us consider an be the number of n-bit strings that do not contain two consecutive 1’s. Also, let us develop a recurrence relation for an.

96. (c) Since P → R = ¬P ∨ R [∀x∃y{ p( x, y ) → R( x, y )}] → [∀x∃y{¬p( x, y ) ∨ R( x, y )}] 97. (1)  Four-digit numbers with first digit as 1: 1111, 1112, 1113, 1122, 1123, 1133, 1222, 1223, 1233, 1333, that is 10 Four-digit numbers with first digit as 2: 2222, 2223, 2233, 2333, that is 4 Four-digit numbers with first digit 3: 3333, that is 1. 98. (c)  X = Sum of the cubes of first n natural numbers n2 ( n + 1) 2 = which is θ ( n4 ), 0( n5 ) and Ω( n3 ). 4 99. (d) X \ Y = X - Y = X ∩ Y ′ and Y ′ \ X ′ = Y ′ - X ′ = Y ′ ∩ ( X ′)′ = Y ′ ∩ X = X ∩ Y ′ Therefore, X \ Y = Y ′ \ X ′, ∀X,Y ∈ U 100. (c) Since p - q ≠ q - p Thus, ( p, q) R( p, q) ⇒ R is not reflexive. Let ( p, q) R( r , s) . Then

p-s = q-r ⇒ r-q = s- p ⇒ ( r , s) R( p, q) Thus, R is symmetric.

101. (d) As -1 ≤ sin x ≤ 1, neither of them is true. 102. (11)  We have ¬(( P ⇒ q) ∧ (¬rV ¬s)) = ¬(¬pvq)) ∨ (¬(¬rV ¬S )

= ( p ∧ ¬q ) ∨ ( r ∧ s )

49



• Let us assume 1-bit strings 0, 1: That is, a1 = 2. • Let us also assume 2-bit strings 00, 01, 10, 11: In this case, 00, 01, 10 do not have two consecutive 1s. Therefore, a2 = 3. • Now, let us assume 2-bit strings as shown below: 0 00 1 0 01 1 0 10 1 In this case, only the five strings 000, 001, 010, 100 and 101 do not have two consecutive 1s; therefore, a3 = 5. Therefore, the three numbers a1 = 2, a2 = 3 and a2 = 3 satisfy the following recurrence relation: an = an-1 + an-2.

104. (b)  Since MST is asked so if e is any heaviest edge in cycle, it obviously will not be involved. Therefore, only statement (II) is true. 105. (3)  We know that P→Q. Therefore, P  (modus ponens) (1) Q Q ∨ P  (by addition) (2) P ∧ ( P → Q )  (by applying simplification and then addition)  (3) Therefore, Q, P ∨ Q, ¬Q ∨ P can be logically implied. 106. (4)  By hit and trial approach. Or by 4-colour theorem, every planar graph is 4-colourable.

which can be read as follows: • x ∈ {8, 9, 10, 11, 12} AND (x is not a composite number) OR (x is a perfect square and x is a prime number)

107. (c) Case I: Let us consider a system with two linear equations (m) of three variables (n):

Now, x is a perfect square and x is a prime number can never be true as every square has at least 3 factors 1, x and x2. Thus, the second condition due to AND can never be true. This means the first condition has to be true.

x−y+z=1 −x + y − z = 2 This system (i.e. when m < n) has no solution (inconsistent). Therefore, statement I is incorrect.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 49

11/13/2018 9:33:15 AM

50

GATE CS AND IT Chapter-wise Solved Papers

Case II:  Let us consider a system with three linear equations (m) of two variables (n):

A

x+y=2 x–y=0 3x + y = 4 This system (i.e. when m > n) has a unique solution. Therefore, statement II is also incorrect. Case III: Let us consider a system with two equations (m) of two variables (n): x+y=2 x-y=0 This system (i.e. when m = n) has a solution: x = 1 and y = 1. Therefore, statement III is the correct one. 108. (198)  The recurrence relation is given by an − an − 1 = 6n2+ 2n(1) Let the complementary function be C1 and the particular solution be (An2 + BnC)n On substituting in Eq. (1), we get A = 2; B = 4; C = 2. The solution is an = C1+ 2n3+ 4n2+ 2n It is given that   a1 = 8; therefore, 8 = C1 + 8 ⇒ C1 = 0 Also, a99 = 2[(993) + 2(992) + 99] = 2[(100 – 1)3+ 2(100 – 1)2+ (100 – 1)] = 104(198) That is, a99 = 104(198) ⇒ K = 198 109. (2)  It is given that f (n) = f (n/2) if n is even f (n) = f (n + 5) if n is odd Let us use the definition of function to show the following: • f  (1) = f (2) = f (3) = f (4) = f (6) = f (7) = f (8) = f (9) = ...

8

C x D

B

It is obvious that if we set x = 12 on the edge joining CC and DD, there can be two shortest paths (both of length 12):  1.  C→DC→D  2.  C→B→A→D Hence, if x ≤ 12, there can be at least one shortest path that passes through x, as requested. We can see that a larger x (say, 13) cannot be used because all the existing shortest paths are already smaller or equal to 12. Note: The question reads as follows: The largest possible integer value of x, for which at least one shortest path between some pair of vertices will contain the edge with weight x. The question means that “at least one shortest path”, but not “every shortest path”. If it is misunderstood, then it would mean as “every shortest path”. Then, in such case, the answer would be 11 because we had to “beat” the shortest path C→B→A→D = 12. However, since the question asks for “at least one” among the shortest paths, then the answer is 12 because having two shortest paths of length 12 is reasonable since one contains the edge x. 111. (7)  We can have MST (minimum spanning tree) of 1, 2 or 3 and 1, 2 or 4. Therefore, 1+2+4=7 1 2

1 5

Hence, we conclude that the range of f (n) comprises two distinct components.

2

3 6 3

110. (12)  Let us exclude the edge labeled x. Therefore, the shortest paths are given as follows:

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 50

5 8

• f (5) = f (10) = f (15) = f (20) = ...

AB = 2; AC = 7; AD = 5; BC = 5; BD = 7; CD = 12 Here, the lengths of the shortest paths can only decrease (or remain equal) if we add a new edge. The most likely is the longest shortest path CD = 12.

2

5

4 4

112. (d)  (a) Since L.H.S ⇔ R.H.S, the well-formed formula is valid. (b)  Same as option (a).

11/13/2018 9:33:16 AM

Chapter 1  • Engineering Mathematics

(c)  i.  ∃x{p(x) ∧q(x)″

Premise

ii. p(a) ∧q(a)

(i) E.S

iii. p(a)

(ii) Simplification

iv.  q(a)

(ii) Simplification

v.  ∃xp(x)

(iii) E.G

vi.  ∃xq(x)

(iv) E.G

vii.  ∃xp(x) ∃xq(x)

(v), (vi) Conjunction

Hence, option (c) is proved to be valid. (d) Let p(x): x be a flower and q(x): x be an animal. Now, let U = {Tiger, Lion, Rose} be the universe of discourse. It is obvious that the antecedent of the implication is true but the consequent is false. Hence, option (d) is proved to be valid. 113. (b)  Let us denote the problem by a non-directed graph with 23 vertices (compounds). If two compounds react with each other, then there exists an edge between the corresponding vertices. In the graph, we have nine vertices with degree 3 (i.e. odd degree). From sum of degrees of vertices theorem, at least one of the remaining vertices should have odd degree. 114. (4)  By Fermat’s theorem, a p-1 = d (mod p). It is a fact that 17 is a prime number and it is not a divisor of 13. Therefore, 1316 = 1 (mod p) 1399 = (13)96 × (13)3 = (1316)6 × 2197 = 16 × 2197 (mod 17) By modulo arithmetic, we get (16 × 2197) mod 17 = 4 115. (d)  From the given statement, we have ¬p ⇒ ¬q ≡ ¬( ¬p ) ∨ ¬q ≡ p ∨ ¬q Now, considering the statements given in the options, we have I. p ⇒ q ≡ ¬p ∨ q, False II. q ⇒ p ≡ ¬q ∨ p, True III. ( ¬q) ∨ p ≡ ¬q ∨ p, True IV.

( ¬p) ∨ q ≡ ¬p ∨ q, False

Therefore, only II and III are correct. 116. (b) Given F : ∀x(∃ yR( x, y )) Now, considering the sentences given in the options, we have I. ∃ y(∃ xR( x, y ))

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 51

∀x(∃ yR( x, y )) → ∃y(∃ xR( x, y )) ∃y(∃ xR( x, y )) ≡ ∃ x(∃yR( x, y )) .

51

is true, since

II. ∃ y(∀xR( x, y )) ∀x(∃yR( x, y )) → ∃y(∀xR( x, y )) is false, since ∃y when it is outside is stronger when it is inside. III. ∀y(∃ xR( x, y )) ∀x(∃ yR( x, y )) → ∀y(∃ xR( x, y )) is false, since R(x, y) may not be symmetric in x and y. IV. ¬∃ x(∀y ¬R( x, y )) ∀x(∃yR( x, y )) → ¬∃ x(∀y ¬R( x, y )) is true, since ¬(∃ x∀y ¬R( x, y )) ≡ ∀x ∃yR( x, y ), So, IV will reduce to ∀x(∃yR( x, y )) → ∀x(∃yR( x, y )) which is trivially true. Therefore, only I and IV are correct. 117. (18) Given, V = 10 As we know, Sum of degrees = 2 × Number of edges and

   e = V - 1 ⇒ e = 10 - 1 ⇒ e=9 Therefore, sum of degrees = 2 × 9 = 18. 118. (a) It is not raining and it is pleasant: ⌐p ^ r. It is not pleasant only if it is raining and it is cold: ⌐ r → (p ^ q). It is not raining and it is pleasant, and it is not pleasant only if it is raining and it is cold = (⌐ p ^ r ) ^ (⌐ r → (p ^ q)). 119. (0)  As the given POSET is already a lattice, there is no need to add any ordered pair. 120. (16)  As we know, Sum of degree of n vertices = 2 × Number of edges Since each vertex has degree at least 3. We have, from the above equation ⇒ 2 × 25 ≥ 3 × n ⇒ n ≤ 50/3 ⇒ n ≤ 16 121. (d)  Given that (p → q) → r = False    ⇒ ~ (~ p ∨ q) ∨ r = False    ⇒ ( p ∧ ~ q) ∨ ( r ) = False This is possible when p ∧ ~ q = False

11/13/2018 9:33:19 AM

52

GATE CS AND IT Chapter-wise Solved Papers

and r = False We have to check (r → p) → q ⇒ ~ (~ r ∨ p) ∨ q ⇒ ( r ∧ ~ p) ∨ q Given r is false ⇒ r ∧ ~ p → False ⇒ ( r → p) → q ≡ q So, ( r → p) → q is true only if q is true. 122. (271)  The number of integers divisible by 3 or 5 or 7 is given by

n(3 ∨ 5 ∨ 7) = n(3) + n(5) + n(7) - n(3 ∧ 5) - n(5 ∧ 7) - n(3 ∧ 7) + n(3 ∧ 5 ∧ 7) ⎡ 500 ⎤ ⎡ 500 ⎤ ⎡ 500 ⎤ ⎡ 500 ⎤ =⎢ ⎥+⎢ ⎥+⎢ ⎥-⎢ ⎥ ⎣ 3 ⎦ ⎣ 5 ⎦ ⎣ 7 ⎦ ⎣ 15 ⎦ ⎡ 500 ⎤ ⎡ 500 ⎤ ⎡ 500 ⎤ -⎢ ⎥-⎢ ⎥+⎢ ⎥ ⎣ 35 ⎦ ⎣ 21 ⎦ ⎣ 105 ⎦ = 166 + 100 + 71 - 33 - 14 - 23 + 4 = 271

123. (15)

1+ z = (1 + z ) (1 - z ) -3 (1 - z )3 = (1 + z ) (1 + 3 z + 6 z 2 + 10 z 3 + …)



= (1 + 4z + 9z2  + 16z3 + …) As from equation, a0 = 1 and a3 = 16. Therefore, a3 − a0 = 16 − 1 = 15

124. (d) an = 2n + 3 1 1- x x Generating function of n = (1 - x ) 2 ∴ Generating function of Now generating function of 1 =

⎛ x ⎞ ⎡ 1 ⎤ an = 2 ⎜ + 3⎢ ⎥ ⎝ (1 - x ) 2 ⎟⎠ ⎣1 - x ⎦ =

2 x + 3(1 - x ) 3- x = (1 - x ) 2 (1 - x ) 2

Generating function of an =

3- x (1 - x ) 2

125. (42)  According to Lagrange’s theorem the order of every subgroup of group G must be a divisor of G. Also

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 52

a proper subgroup cannot have same size as group. Thus proper subgroup of group having order 84 would have order 1, 2, 4, 21, 42. So, largest proper subgroup can have size 42. 126. (d)  Set P which is a set of rational numbers positive or negative is countable. Set Q which is a function from {0, 1} to set of natural number N is countable. Set R which is a function from N to {0, 1} is not countable sets which is a set of finite subsets N is countable.

Linear Algebra 127. (a)  We have matrix let it be A. ⎡2 0 0 0⎤ ⎢8 1 7 2⎥ ⎥ A= ⎢ ⎢2 0 2 0⎥ ⎢ ⎥ ⎣9 0 6 1⎦ Now, determinant of matrix A is 1 7 2 8 7 2 8 1 2 8 1 7 A = 2 0 2 0 -0 2 2 0 +0 2 0 0 -0 2 0 2 0 6 1 9 6 1 9 0 1 9 0 6 1 7 2 ⇒ A = 2 0 2 0 = 2[1( 2 - 0) - 7(0 - 0) + 2(0 - 0)] 0 6 1 ⇒ |A| = 2 × 2 = 4 Therefore, determined of given matrix is 4. 128. (d)  Given, P(x) satisfies P(1) = P(3) = P(5) = 1 P(2) = P(4) = −1 From x = 1 to x = 2, P(x) touches 0 so there is one root between x =1 and x = 2. From x = 2 to x = 3, P(x) touches 0 so there is one root between x = 2 and x = 3. From x = 3 to x = 4, P(x) touches 0 so there is one root between x = 3 and x = 4. From x = 4 to x = 5, P(x) touches 0 so there is one root between x = 4 and x = 5. So, there are minimum 4 roots. Therefore, minimum degree of polynomial is 4. 129. (a)  Given that S1: the sum of two singular n × n matrices may be non-singular S2: the sum of two n × n non-singular matrices may be singular

11/13/2018 9:33:21 AM

Chapter 1  • Engineering Mathematics

A square matrix is singular if and only if it’s determinant is 0. S1 is true – for example ⎡1 1⎤ ⎡ 1 -1⎤ A= ⎢ and B = ⎢ ⎥ ⎥ ⎣1 1⎦ ⎣ -1 1 ⎦ Here A and B are singular. ⎡2 0⎤ A+ B = ⎢ ⎥ ⎣0 2⎦ Here A + B is non-singular. S1 is true – for example ⎡1 0 ⎤ ⎡ -1 0 ⎤ A= ⎢ ⎥ and B = ⎢ 0 -1⎥ 0 1 ⎣ ⎦ ⎣ ⎦ Here A and B are non-singular. ⎡0 0 ⎤ A+ B = ⎢ ⎥ ⎣0 0⎦ Here A + B is singular. Hence, both S1 and S2 are true. 130. (c)  Rank of the matrix is defined as the maximum numbers of linearly independent vectors or numbers of non-zero rows in its row-echelon matrix form. ⎡1 1 ⎤ Here given matrix ⎢ ⎥ is already in echelon form. ⎣0 0⎦ There is only one non-zero row in its row-echelon form. Therefore, rank of the matrix is 1. 131. (b)  The given system of equations is ⎡ 2 1 -4 ⎤ ⎡ x ⎤ ⎡α ⎤ ⎢ 4 3 -12⎥ ⎢ y ⎥ = ⎢ 5⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢⎣ 1 2 -8⎥⎦ ⎢⎣ z ⎥⎦ ⎢⎣ 7⎥⎦ The augmented matrix for the given system is ⎡ 2 1 -4 α ⎤ ⎢ ⎥ ⎢ 4 3 -12 5⎥ ⎢⎣ 1 2 -8 7⎥⎦ For infinite solutions to exist, the rank of the augmented matrix should be less than the total unknown variables, i.e. 3. Therefore, 2 1 α 4 3 5 =0 1 2 7 ⇒ α (8 - 3) - 5( 4 - 1) + 7(6 - 4) = 0 1 ⇒α = 5 Therefore, there is only one value of α for which infinite solutions exist. 132. (b)  Given that A, B, C and D are n × n matrices. Also, ABCD = I − ABCDD −1C −1 = D −1C −1

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 53

Now,

53

- AB = D -1C -1 - A-1 AB = A-1 D -1C -1 - B = A-1 D -1C -1

B -1 = ( A-1 D -1C -1 ) -1 = (C -1 ) -1 ( D -1 ) -1 ( A-1 ) -1 = CDA 133. (c)  The given equations are - x + 5 y = -1 x- y=2 x + 3y = 3 The system of equations can be represented as ⎡ -1⎤ ⎡ -1 5 ⎤ ⎢ 1 -1⎥ ⎡ x ⎤ = ⎢ 2 ⎥ ⎢ ⎥ ⎢ y⎥ ⎢ ⎥ ⎢⎣ 1 3 ⎥⎦ ⎣ ⎦ ⎢⎣ 3 ⎥⎦ ⎡ -1 5 -1⎤ ⎢ ⎥ The augmented matrix is given by ⎢ 1 -1 2 ⎥ . ⎢ 1 3 3⎥ ⎣ ⎦ Using Gauss elimination on above matrix, we get ⎡ -1 5 -1⎤ ⎡ -1 5 -1⎤ ⎢ ⎥ R2 + R1 ⎢ ⎥ → ⎢ 0 4 1⎥ ⎢ 1 -1 2 ⎥ ⎯R⎯⎯ 3 + R1 ⎢ 1 3 3⎥ ⎢ 0 8 2⎥ ⎣ ⎦ ⎣ ⎦ ⎡ -1 5 -1⎤ ⎢ ⎥ R3 - 2 R2 ⎯⎯⎯⎯ → ⎢ 0 4 1⎥ ⎢ 0 0 0⎥ ⎣ ⎦ Rank[A| B] = 2(number of non-zero rows in [A| B]) Rank[A] = 2(number of non-zero rows in [A]) Rank[A| B] = Rank [A] = 2 = number of variables Therefore, the system has a unique solution. 134. (b)  The equations can be represented as follows: ⎡ 2 -1 3⎤ ⎡ x1 ⎤ ⎡1 ⎤ ⎢ 3 -2 5⎥ ⎢ x ⎥ = ⎢ 2⎥ ⎢ ⎥ ⎢ 2⎥ ⎢ ⎥ ⎢⎣ -1 -4 1⎥⎦ ⎢⎣ x3 ⎥⎦ ⎢⎣3 ⎥⎦ The augmented matrix for the given system is ⎡ 2 -1 3 1⎤ ⎢ ⎥ ⎢ 3 -2 5 2⎥ ⎢⎣ -1 -4 1 3⎥⎦ Now, 2 -1 3 3 -2 5 = ( 2)( -2 + 20) - (3)( -1 + 12) -1 -4 1 + ( -1)( -5 + 6) = 36 - 33 - 1 = 2 ≠ 0

11/13/2018 9:33:24 AM

54

GATE CS AND IT Chapter-wise Solved Papers

Hence, rank (A) = 3 and rank (A|B) = 3. As rank [ A| B] = rank [ A] = number of variables, system has a unique solution.

137. (d)  The equations can be represented as follows: the

135. (b)  We have ⎡ 2 -1⎤ A= ⎢ ⎥ ⎣ -4 5⎦

The augmented matrix for the above system is

The characteristic equation of this matrix is given by A - lI = 0 2-l -1 =0 -4 5 - l ( 2 - l )(5 - l ) - 4 = 0 l = 1, 6 Therefore, the eigenvalues of A are 1 and 6. 136. (a)  To be basis for subspace X, two conditions are to be satisfied. 1. The vectors have to be linearly independent. 2. They must span X. Here, X = {x ∈ R3 | x1 + x2 + x3 = 0} xT = {x1 , x2 , x3 }T Now, {[1, -1, 0]T , [1, 0, -1] } is a linearly independent set because it cannot be obtained from another by scalar multiplication. The fact that it is independent can also be established by seeing that the rank of ⎡1 -1 0 ⎤ ⎢1 0 -1⎥ is 2. ⎣ ⎦ T

Next, we need to check if the set spans X. Here,   X = { x ∈ R3 | x1 + x2 + x3 = 0} ⎡ - k1 - k2 ⎤ The general infinite solution of X is ⎢⎢ k1 ⎥⎥ . ⎢⎣ k2 ⎥⎦ ⎡ k1 ⎤ ⎡ 0 ⎤ ⎡ k1 ⎤ ⎡ k ⎤ Choosing k1, k2 as ⎢ ⎥ = ⎢ ⎥ and ⎢ ⎥ = ⎢ ⎥ , we get ⎣ k2 ⎦ ⎣ k ⎦ ⎣ k2 ⎦ ⎣ 0 ⎦ two linearly independent solutions, for X, ⎡ -k ⎤ ⎡ -k ⎤ X = ⎢⎢ 0 ⎥⎥ or ⎢⎢ k ⎥⎥ ⎢⎣ k ⎥⎦ ⎢⎣ 0 ⎥⎦ Now, since both of these can be generated by linear combinations of [1, -1, 0]T and [1, 0, -1]T , the set spans X. Also we have shown that the set is not only linearly independent but also spans X, therefore by definition it is for the subspace X.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 54

⎡1 1 2 ⎤ ⎡ x1 ⎤ ⎡1 ⎤ ⎢1 2 3 ⎥ ⎢ x ⎥ = ⎢ 2 ⎥ ⎢ ⎥⎢ 2⎥ ⎢ ⎥ ⎢⎣1 4 a ⎥⎦ ⎢⎣ x3 ⎥⎦ ⎢⎣ 4 ⎥⎦ ⎡1 1 2 1⎤ ⎡1 1 2 1⎤ ⎢ ⎥ R2 - R1 ⎢ ⎥ 1 1⎥ → ⎢0 1 ⎢1 2 3 2⎥ ⎯R⎯⎯ 3 - R1 ⎢⎣1 4 a 4 ⎥⎦ ⎢⎣0 3 a - 2 3⎦⎥ ⎡1 1 2 1⎤ ⎢ ⎥ R3 - 3 R2 1 1⎥ ⎯⎯⎯→ ⎢0 1 ⎢⎣0 0 a - 5 0 ⎥⎦ Now as long as a - 5 ≠ 0, rank( A) = rank( A| B ) = 3. Therefore, a can take any real value except 5. ⎡ 1 0⎤ 138. (a)  Eigenvalues of ⎢ ⎥ can be calculated using ⎣0 0 ⎦ characteristic equation, 1- l 0 =0 0 0-l (1 - l ) - l = 0 l = 0,1 ⎡0 1⎤ Eigenvalues of ⎢ ⎥ is given by ⎣0 0⎦ 1⎤ ⎡ -l ⎢ 0 -l ⎥ = 0 ⎦ ⎣ l2 = 0 l = 0, 0 ⎡1 -1⎤ Eigenvalues of ⎢ ⎥ is given by ⎣1 1⎦ -1⎤ ⎡1 - l ⎢ 1 1- l⎥ = 0 ⎦ ⎣ 2 (1 - l ) + 1 = 0 (1 - l ) 2 = -1 1 - l = i , -i l = (1 - i ), (1 + i ) ⎡ -1 0 ⎤ Eigenvalues of ⎢ ⎥ is given by ⎣ 1 -1⎦ 0⎤ ⎡ -1 - l ⎢ 1 -1 - l ⎥⎦ ⎣

11/13/2018 9:33:26 AM

Chapter 1  • Engineering Mathematics

(iii) In a matrix if we interchange two rows or columns, then the determinant of the resultant matrix is multiplied by −1. So by concepts (i) and (ii), matrix in options (b), (c) and (d) gives the same result as our given matrix. By concept (iii), matrix in option a gives a different result

( -1 - l )( -1 - l ) = 0 (1 + l ) = 0 l = -1, - 1 2

So, only one matrix has an eigenvalue of 1 which is ⎡ 1 0⎤ ⎢0 0 ⎥ . ⎣ ⎦ 139. (d)  Sum of eigenvalues = Trace (A) = 2 + y Product of eigenvalues = |A| = 2y − 3x Therefore, 4 + 8 = 2 + y(1) y = 10 4 × 8 = 2y − 3x(2) Substituting the value of y in Eq. (2), we get 20 − 3x = 32

1 x 1 y 1 z

Hence, the answer is (a). 143. (1)  The given equations are 3x + 2y = 1 4x + 7z = 1

140. (a)  As the given matrix is upper triangular, its eigenvalues are the diagonal elements themselves, which are 1, 4 and 3. Hence, the correct option is the first one.



141. (d)  We have



⎡1 1⎤ A= ⎢ ⎥ ⎣1 -1⎦ Eigenvalues of A are the roots of the characteristic polynomial given as follows: A - lI = 0 1- l 1 =0 1 -1 - l

l2 - 2 = 0 2 and - 2 , respectively.

( 2) , (- 2 )

19

= 219 / 2 , - 219 / 2 = 29 ⋅ 21/ 2 , - 29 ⋅ 21/ 2 = 512 2 , - 512 2 . 142. (a)  We know that (i) In a matrix if we add or subtract any constant to any row or column, then the determinant of the matrix remains same. (ii) In a matrix if we apply any row or column transformation, then also the determinant of the matrix remains same.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 55

ρ( A) = 3 = number of variables. So equations have a  unique solution.

145. (c)  By applying mean value theorem, both I and II are found to be true.

l=± 2 19

0 1⎤ 7 1 ⎥⎥ 1 3⎥ ⎥ 7 0⎦ Applying row operations, the resultant matrix will be 1 3 ⎤ ⎡1 1 ⎢0 -4 3 -11⎥ ⎢ ⎥ ⎢0 0 -15 -21⎥ ⎢ ⎥ 0 0 ⎦ ⎣0 0 ⎡3 2 ⎢4 0 ⎢ Augmented matrix ρ( A : B ) = ⎢ 1 1 ⎢ ⎣ 1 -2

144. (0)  The eigenvectors for symmetric positive matrix corresponding to different eigenvalues are orthogonal. Hence, their dot product is zero always.

(1 - l )( -1 - l ) - 1 = 0 -(1 - l )(1 + l ) - 1 = 0

So, eigenvalues of A19 =

y +1 y +1 z +1

x - 2y + 7z = 0

Hence, x = −4 and y = 10.

Eigenvalues of A are

x2 1 x( x + 1) 2 y = - 1 y( y + 1) z2 1 z ( z + 1)

x + y + z = 3

⇒ x = -12 / 4 = -3



55

146. (0)  The determinant of the given matrix A is 2 18 10 4 36 20 determinant of A = 7 63 35 = {2(( -36 × 35) - ( -20 × 63)) + 4((18 × 35) - (10 × 63)) + 7(( -20 × 18) - ( -36 × 10))} = {2(( -1260) - ( -1260)) + 4((630) - (630)) + 7(( -360) - ( -360))} = {2(0) + 4(0) + 7(0)} =0 147. (a)  Given that f (x) has degree = 3. For f (x) = 0, roots are x = 1, 2, 3 which lie between 0 and 4. So, f (0) and

11/13/2018 9:33:28 AM

56

GATE CS AND IT Chapter-wise Solved Papers

f (4) have opposite signs. Therefore, f (0) × f (4) should be less than zero. 148. (a)  If the trace of the matrix is positive and the determinant of the matrix is negative, then at least one of its eigenvalues is negative. Determinant of matrices = product of eigenvalues 149. (12)  Let the weight of coins in the respective bags (1 through 5) be a, b, c, d and e – each of which can take one of two values namely 10 or 11 (gm). Now, the given information on total weight can be expressed as the following equation: a + 2b + 4c + 8d + 16e = 323 ⇒ a must be odd ⇒ a = 11 The equation then becomes 11 + 2b + 4c + 8d + 16e = 323 ⇒ 2b + 4c + 8d + 16e = 312 ⇒ b + 2c + 4 d + 8e = 156 ⇒ b must bee odd ⇒ b = 10

h( x ) =

Replace x by h(x) in Eq. (1), we get g[h( x )] = 1 - h( x ) = 1 -

10 + 2c + 4 d + 8e = 156 ⇒ 2c + 4 d + 8e = 146 ⇒ c + 2d + 4e = 73 ⇒ c must be odd ⇒ c = 11 The equation now becomes 11 + 2d + 4e = 73 ⇒ 2d + 4e = 62 ⇒ d + 2e = 31 ⇒ d = 11 and e = 10

Replacing x by g(x) in Eq. (2), we get h[ g ( x )] =

152. (36) Let N = 2100 = 22 + 3 × 52 × 7 (i.e. product of primes) Then the number of division of 2100 is given by ( 2 + 1)(1 + 1)( 2 + 1)(1 + 1) = (3)( 2)(3)( 2) = 36 ⎡ 4 5⎤ 153. (6)  The given matrix is ⎢ ⎥. ⎣ 2 1⎦ Hence, 4-l 5 =0 2 1- l ⇒ l 2 - 5l - 6 = 0 ⇒ ( l - 6)( l + 1) = 0 ⇒ l = 6, - 1 Therefore, larger eigenvalue is 6. 154. (b) Let X be an eigenvector corresponding to eigenvalue l = 1, then AX = l X ⇒ ( A - l ) X = 0 ⎡0 -1 2⎤ ⎡ X ⎤ ⇒ ⎢⎢0 0 0 ⎥⎥ ⎢⎢Y ⎥⎥ = 0 ⎢⎣1 2 0 ⎥⎦ ⎢⎣ Z ⎥⎦ ⇒ - y + 2 z = 0 and x + 2 y = 0 x ⇒ y = 2 z and =y -2

150. (6)  Eigenvector is AX = lX 0 1 1 1 0

0 1 1 1 0

1⎤ 0⎥⎥ 0⎥ ⎥ 0⎥ 1⎥⎦

Convert the given matrix in diagonal matrix. The diagonal entries are called eigenvalues. Eigenvalues = 2, 3 Product of eigenvalues = 2 × 3 = 6 151. (a)  We have, g(x) = 1 - x(1)

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 56

1- x g( x) = g( x) - 1 - x

x h( x ) g[h( x )] x ⇒ = = x -1 = h[ g ( x )] ( x - 1)(1 - x ) 1 - x g ( x )

Therefore, bags labeled 1, 3 and 4 contain 11 gm coins ⇒ Required product = 1 × 3 × 4 = 12.

0 1 1 1 0

-1 x = x -1 x -1

The characteristic equation is given by A - l I = 0

The equation then becomes

⎡1 ⎢0 ⎢ A= ⎢0 ⎢ ⎢0 ⎢⎣1

x (2) x -1

Therefore, x x y z = y = 2z ⇒ = = = α (say ) -2 -4 2 1 ⎡ -4 ⎤ ⇒ X = ⎢⎢ 2 ⎥⎥ α ; α ≠ 0 ⎢⎣ 1 ⎥⎦ Thus, eigenvectors are {α ( -4, 2,1) α ≠ 0, ∠ ∈ R }

11/13/2018 9:33:31 AM

Chapter 1  • Engineering Mathematics

155. (d)  Given that l1 = -1 and l 2 = 7 are eigenvalues of A. Using the properties of matrices,  (1) l1 + l 2 = tr ( A)

l1 ⋅ l 2 = A



(2)

⇒ 6 = 1+ a ⇒ a = 5 Also, a - 4b = -7 ⇒ 5 - 4b = -7 ⇒ b = 3 156. (0)

1 p + q + r = 0 or 0 0

q r-q p-q

r p-r = 0 q-r

⇒ ( r - q) 2 - ( p - q)( p - r ) = 0 ⇒ p 2 + q 2 + r 2 - pq - qr - pr = 0 ⇒ ( p - q) 2 + ( q - r ) 2 + ( r - p) 2 = 0 ⇒ p - q = 0, q - r = 0, r - p = 0 ⇒ p=q=r 158. (15)  For a 3 × 3 real matrix, we have 2 ± -1

⎡ 3 4 45 ⎤ ⎢ ⎥ Let A = ⎢ 7 9 105⎥ ⎢⎣13 2 195⎥⎦

Eigen values

 

3

Applying row transformation,

For real matrix, the eigenvalues must ( 2 + -1, 2 - -1 and 3) = (2 + i, 2 − i and 3). Now,

R2 → R2 + R3 ⎡ 3 4 45 ⎤ ⎢ ∼ ⎢ 20 11 300 ⎥⎥ ⎢⎣13 2 195 ⎥⎦

= Product of eigenvalues = ( 2 + i )( 2 - i )(3)

C1 → C2 - C3 ⎡ -42 4 45 ⎤ ∼ ⎢⎢ -280 11 300 ⎥⎥ = B ( resultant matriix ) ⎢⎣ -182 2 195 ⎥⎦ Now, - 42 4 3 3 4 3 B = 280 11 300 = ( -14 )(15) 20 11 20 = 0 -182 2 195 13 2 13 157. (c)  For non-trivial solution, A = 0. q r p

r p =0 q

Therefore, the determinant of the matrix P is 15. 159. (0.125)  It is given that for matrix A, the eigenvalues are 1, 2, 4. Therefore, det(A) = Product of eigenvalues trace(A) = Sum of eigenvalues Now, the eigenvalues of A−1 are 1, 1/2, 1/4. Therefore, | A-1 | = 1 ×

1 1 1 × = 2 4 8 1 = 0.125 8

160. (198)  The recurrence relation is given by

C1 → C1 + C2 + C3 r p =0 q

Applying row transformation, [ R2 → R2 - R1 ; R3 → R3 - R1 ]

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 57

= ( 22 - i 2 ) × 3 = ( 4 + 1) × 3 = 15

| A-1 |T = | A-1 | =

Applying column transformation,

1 q ( p + q + r) 1 r 1 p

be

Determinant of the matrix P

Applying column transformation,

p That is q r

57

an − an − 1 = 6n2 + 2n(1) Let the complementary function be C1 and the particular solution be (An2 + BnC)n On substituting in Eq. (1), we get A = 2; B = 4; C = 2. The solution is an = C1 + 2n3 + 4n2 + 2n It is given that a1 = 8; therefore, 8 = C1 + 8 ⇒ C1 = 0

11/13/2018 9:33:34 AM

58

GATE CS AND IT Chapter-wise Solved Papers

Also, a99 = 2[(99 ) + 2(99 ) + 99] = 2[(100 − 1)3 + 2(100 − 1)2 + (100 − 1)] = 104(198) That is, a99 = 104(198) ⇒ K = 198 3

2

161. (2)  It is given that f(n) = f(n/2), if n is even f(n) = f(n + 5),  if n is odd Let us use the definition of function to show the following: (i) f(1) =  f(2) =  f(3) =  f (4) =  f(6) =  f(7) =  f(8) =  f(9) = ⋅⋅⋅ (ii)  f(5) =  f(10) =  f(15) =  f(20) = ⋅⋅⋅ Hence, we conclude that the range of f(n) comprises two distinct components. 162. (1500)  Here, there are five possible cases: A(B(CD)) A((BC)D) ((AB)C)D (A(BC))D (AB)(CD) The scalar multiplications required are 1750, 1500, 3500, 2000, 3000, respectively. Therefore, the minimum number of scalar multiplications is 1500. 163. (c)  For the system, Ax = b, the vectors a1, a2, …, an are linearly dependent. Therefore, rank(A) < n. Hence, the system has infinitely many solutions.

As it is given, x = 6 is a solution of this equation in same base b. Therefore, 6 2 - (b + 3)6 + (3b + 6) = 0 ⇒ - 3b + 24 = 0 ⇒b=8 165. (a)  To find a such that w = u + a v bisects the angle between u and v, we can choose two vectors of equal length, i.e. ||u|| = ||v|| Then u + v bisects the angle between u and v. Given that ||u|| = 2 ||v||, so u is twice as long as v. So if the vector 2v has same length as u and hence u + 2v will bisect angle between u and 2v. Now, angle between u and v is same as angle between u and 2v. Since 2 is only a scalar, hence the required vector is u + 2v. So w = u + 2v ⇒ a=2 166. (b)  Given that Rank of A n   ×  n symmetric matrix = 2 Let l1, l2, 0, 0, …, 0 be the eigenvalues. So (n - 2) eigenvalues are zero. Given that n

n

∑∑ A i =1 j =1

2 ij

= 50 = Trace of ( AAT ) = l12 + l 22 + 0 + 0 +  + 0

⇒ l12 + l 22 = 50

164. (8) x2 - 13x + 36 = 0 The solutions of this equation are 4 and 9. Now, 13 in base 10 can be represented as 1 × 101 + 3 × 100 and 36 in base 10 as 3 × 101 + 6 × 100 Therefore, 13 in base b can be represented as 1 × b1 + 3 × b0 = b + 3 and 36 as 3 × b1 + 6 × b0 = 3b + 6 As the quadratic equation can be represented as x - (Sum of roots)x + Product of roots Now, the equation will be 2

x - (b + 3)x + (3b + 6) = 0 2

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 58

As eigenvalue lies in [-5, 5], statement I is true. Also as eigenvalues are l1 = ± 5, l2 = ± 5, statement II is false. 167. (5)  The characteristic equation of M is l3 - 4l2 + al + 30 = 0 Substituting l = 2 in the above equation as 2 is one of the root of the equation, we get a = -11 Now, the characteristic equation is l3 - 4l2 - 11l + 30 = 0 ⇒ (l - 2) (l2 - 2l - 15) = 0 ⇒ l = 2, -3, 5 Therefore, the maximum eigenvalue among the absolute values of the eigenvalues is 5.

11/13/2018 9:33:35 AM

Chapter 1  • Engineering Mathematics

172. (a)  We have

168. (3)  Given, 1 1 U =   , V =    2  1 1  1 1  ∴ A = UV T =  (1 1) =   2 2 2

x - sin x = lim lim x →∞ x + cos x x →∞

1 − l   2

sin x x = cos x 1 + lim x →∞ x x →∞

1   ⇒ (1 − l )(2 − l ) − 2 = 0 2 − l 

=

⇒ 2 − 2λ − λ + λ 2 − 2 = 0 ⇒ λ 2 − 3λ = 0 ⇒ λ(λ − 3) = 0



Therefore, largest eigen value of A = 3. 169. (d)  Given, matrix P’s eigen vectors are the multiples  1 of   . This implies eigen value of P are repeated. If  4

eigen values are distinct then more than one independent eigen vectors will be obtained. Now since matrix P has repeated eigen values therefore it cannot be diagonalizable. Hence statement II and III are necessarily true.

170. (c)  The trapezoidal rule is a numerical approach to find definite integrals. The trapezoidal rule gives the exact result for polynomials of degree up to or equal to one. 171. (a)  We have, ⎛X ⎞ ⎛ 3 ⎞ = ⎜ n⎟ +⎜ ⎝ 2 ⎠ ⎝ 2 × n ⎟⎠

In Newton’s Raphson method, next values is calculated as X n +1 = X n -

f (Xn) f ′( X n )

p /4

0

⎛p ⎞ 1 - tan x tan ⎜ - x ⎟ = ⎝4 ⎠ 1 + tan x Now, substituting the value of we get



p /4

X 2 = 3 ⇒ f ( x) = X 2 - 3 Therefore, X -3 X X 3 3 = Xn - n + = n+ 2Xn 2 2Xn 2 2Xn 2 n

So, option (a) is correct.

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 59

1 - tan x in Eq. (1), 1 + tan x

1 ⎛p ⎞ tan ⎜ - x ⎟ dx = ln 2 = ln 2 ⎝4 ⎠ 2

174. (b)  We have 1⎞ ⎛ lim ⎜1− ⎟ n →∞ n⎠ ⎝

2n

2

n 2n n ⎡ ⎡⎛ 1⎞ 1⎞ ⎤ 1⎞ ⎤ ⎛ ⎛ lim ⎜1− ⎟ = lim ⎢⎜1− ⎟ ⎥ = ⎢ lim ⎜1− ⎟ ⎥ n →∞ n →∞ n⎠ n ⎠ ⎥⎦ n ⎠ ⎥⎦ ⎝ ⎢⎣⎝ ⎢⎣ n →∞ ⎝

2

= (e -1 )2 = e -2 175. (d)  We have



p /2

0

cos x + i sin x dx cos - i sin x =∫

p /2

0

Where f ′( xn ) is derivative of f ( xn )

(1 - tan x ) dx (1) (1 + tan x )

We know that

0

Calculus

1- 0 =1 1+ 0

173. (d)  We have

⇒ l = 0, 3

X n +1

⎛ sin x ⎞ sin x lim ⎜1 ⎟ x ⎠ x = x →∞ ⎝ cos x ⎛ cos x ⎞ 1+ lim ⎜1 + ⎟ x →∞ ⎝ x x ⎠ 1-

1 - lim

Finding eigen values of A

X n +1 = X n -

59

p /2 e ix dx = ∫ e 2ix dx - ix 0 e p /2

⎡ e 2ix ⎤ =⎢ ⎥ ⎣ 2i ⎦ 0

=

1 ip [e - e 0 ] 2i

=

1 [ -1 - 1] (∵ e ip = -1) 2i

=

-2 -1 = =i 2i i

11/13/2018 9:33:40 AM

60

GATE CS AND IT Chapter-wise Solved Papers

176. (a)  Considering the first option,

181. (a) Let g(x) = f (x) − f (x + 1) defined in [0, 1]

⎧ ⎪2, if x = 3 ⎪ ⎨ x - 1, if x > 3 ⎪x +3 ⎪ , if x < 3 ⎩ 3



x+3 lim- f ( x ) = lim=2 x →3 x →3 3 lim+ f ( x ) = lim+ x - 1 = 2

x →3 x →3 So it is continuous at x = 3.

Hence, option (a) is correct. 177. (d)  According to Trapezoidal rule, we get



3

0

f ( x )dx =

h [ f ( x0 ) + f ( x10 ) 2 + 2 ( f ( x1 ) + f ( x2 ) +  + f ( x9 ) )⎤⎦

=

0.3 ⎡9.00 + 2 ( 25.65)⎤⎦ = 9.045 2 ⎣

g(0) = f (0) − f (1) = −1 − 1 = −2 g(1) = f (1) − f (2) = 1 + 1 = +2 g(0) is negative and g(1) is positive. Therefore, there exists some x for which g(x) = 0. ⇒ g(x) = 0 = f (x) − f (x+1) ⇒ f (x) = f (x + 1) 182. (a)  According to Newton–Raphson method: f (x) = 0.75x3 − 2x2 − 2x + 4 f ′(x) = 2.25x2 − 4x − 2 x0 = 2, f0 = −2, f 0′ = −1 x1 = 2 − (−2)/(−1) = 0 f1 = 4, f1′ = −2 x2 = 0 − (4)/(−2) = 2 f2 = −2, f 2′ = −1 x3 = 2 − (−2)/(−1) = 0 Hence, statement (I) is true. Also the value diverges, thus statement (II) is false. 183. (8) 2014 = 2 × 19 × 53 (product of prime factors)

178. (4)  We are given 2p

Number of distinct positive integral factors of 2014 = (1 + 1) × (1 + 1) × (1 + 1) = 8

∫ | x sin x | dx = kp 0

Now

x1 = x0 - f 0 /f 0′



| sin x | = - sin x [from p to 2 p]

184. (c) 1

2 ∫x dx =

So 2p

p

2p

0

0

p

0

x3 1 = = 0. 33333 3 3

As N = 4, we have

∫ | x sin x dx | = ∫ x sin x dx + ∫ - x sin x dx = x( - cos x ) - 1( - sin x )| - ( - x cos x + sin x )|

x

0

0.25

= 4p

y = x2

0

0.0625 0.25

1

∫x

2

dx =

0

f´(x) = sinx + x  cosx(2) Differentiating Eq. (2) w.r.t. x, we get f ˝(x) = cosx + x(−sinx) + cosx = 2 cosx − x  sinx 2 cosx − x  sinx + x  sinx + t cosx = 0 2 cosx + t cosx = 0 ⇒ t = −2

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 60

y2

0.75

1

0.5625

1

y3

y4

Trapezoidal rule:

Here n = 100, so (300/2) − 2 = 148 180. (−2)  We are given f (x) = x  sinx(1) We are also given that f˝(x) + f (x) + t cosx = 0 Differentiating Eq. (1) w.r.t. x, we get

y1

y0

179. (148)  Number of comparisons for finding minimum 3 and maximum of n numbers = n - 2 2

0.5

0.25 [(0 + 1) + 2(0.0625 + 0.25 + 0.5625)] 2

= 0.34375 Simpson’s 1/3 rule: 1

∫x 0

2

dx =

0.25 [(0 + 1) + 2 (0.25) + 4(0.0625 + 0.5625)] 2

= 0.3333 185. (a)  We have to find the value of p

∫x

2

cos x dx

0

11/13/2018 9:33:41 AM

Chapter 1  • Engineering Mathematics p

0

⇒ ∫ x 2 cos x dx = x 2 sin x - 2 x( - cos x )

A=

-1

0

+ 2( - sin x )[0 to p ] = -2p

1 + x 2 is ∞ form. x →∞ ∞ ex

x →∞

= lim

x →∞



2 x (using L-Hospital’s rule) ex

Therefore, lim(1 + x )e 2

-x

x →∞

2x = lim x = 0 x →∞ e



1 /p

cos(1/x ) dx x2

Putting 1/x = t 1 ⇒ - 2 dx = dt x

p

∫ cos tdt

p /2

⎛ ⎜ since ⎝

b

∫ a



⎛ 1⎞ 1 af ( x ) + bf ⎜ ⎟ = - 25 (1) ⎝ x⎠ x



⎛ 1⎞ ⇒ af ⎜ ⎟ + bf ( x ) = x - 25 (2) ⎝ x⎠ Solving Eqs. (1) and (2), we get f (x) =

= (sin t )



f ( x )dx =

1

=

1 1 1 1 1 = + + ++ ∑ 1( 2) 2(3) 3( 4) 99(100) x =1 x ( x + 1) 2 -1 3 - 2 4 - 3 100 - 99 = + + ++ 1( 2) 2(3) 3( 4) 99(100) 1 1 1 1 1 1 1 1 1 = - + - + ++ - + 1 2 2 3 3 98 99 99 100 1 99 = 1= = 0.99 100 100 189. (a) Since f (0) → ∞ Therefore, f is not bounced in [ -1,1] and hence f is not continuous in [ -1,1].

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 61

1 a2 - b2

47 ⎤ ⎡ ⎢ a {ln 2 - 25} + 2 b ⎥ ⎣ ⎦

191. (309.33)   Let S be the distance covered in 20 min, then by Simpson’s 1/3rd rule. Here length of each sub-interval is h = 2. 20

S = ∫ Vdt = 0

2 [(0 + 0) + 4(10 + 25 + 32 + 11 + 2) 3 + 2(18 + 29 + 20 + 5)]

= sin p - sin(p /2) = -1

99

⎤ ⎡ ⎛1 ⎞ ⎢ a ⎜⎝ x - 25⎟⎠ - b( x - 25) ⎥ ⎣ ⎦

2 ⎧ x2 ⎫ ⎤ 1 ⎡ 2 ⎥ ⎢ 25 25 a {ln x x } b x ⎨ ⎬ 1 a2 - b2 ⎢ ⎩2 ⎭1 ⎥⎦ ⎣ 1 ⎡ ⎧3 ⎫⎤ = 2 a{ln 2 - 25} - b ⎨ - 25⎬ ⎥ 2 ⎢ a -b ⎣ ⎩2 ⎭⎦

2

a

188. (0.99)  We are given

1 a2 + b2

Therefore,

⎞ f ( x )dx = - ∫ f ( x )dx ⎟ ⎠ b

p p /2

0

190. (a)  We are given,

and x = 2 /p ⇒ t = p / 2 x = 1/p ⇒ t = p

-1

dx + ∫ x -1/ 3 dx

Thus, only statement (ii) is true.

187. (-1)  We have, 2 /p

1

-1/ 3

2 2 = ( x 2 / 3 )0-1 + ( x 2 / 3 )10 = 0 3 3

186. (a)  If we substitute the value of the limit in the given equation, we get lim(1 + x 2 )e - x = lim

0

∫ f ( x)dx = ∫ x

61

= 309.33 km 192. (1)   lim x→4



⇒ lim x→4

That is,

sin( x - 4) x-4 

⎛0 ⎞ ⎜⎝ form⎟⎠ 0

cos( x - 4) 1

( using L-Hospital s rules)

cos 0 = 1.

193. (10)  We have ( x 3 + x 4 + x 5 + x 6 + )3 = [ x 3 (1 + x1 + x 2 + )]3 = x 9 (1 + x + x 2 + )3 =

x9 (1 - x )3 ∞

= x 9 ∑ (3 - 1) + rCr X r r=0

11/13/2018 9:33:44 AM

62

GATE CS AND IT Chapter-wise Solved Papers

Substituting r = 3 in the above equation, we get coefficient of x12 in (x3 + x4 + x5 + x6 + ⋅⋅⋅)3 as follows: 3+ 2

Hence, from Eq. (6), solving for S, we get -8 2R +S = 2 p p

C3 = C3 = C2 = 10 5

5

⇒ S = 0

194. (c) ⎛ p x⎞ f ( x ) = R sin ⎜ ⎟ + S (1) ⎝ 2⎠ ⎛ p x⎞ p ⇒ f ′ ( x ) = R cos ⎜ ⎟ ⎝ 2 ⎠2

195. (c) x7 - 2 x5 + 1 1 - 2 + 1 0 = = x →1 x 3 - 3 x 2 + 2 1- 3 + 2 0 Therefore, applying L’Hospital’s rule, we have lim

lim

p p 1 ⇒ f ′ ⎛⎜ ⎞⎟ = R cos ⎛⎜ ⎞⎟ (2) ⎝ 2⎠ ⎝ 4⎠ 2

As given, ⎛ 1⎞ f ′ ⎜ ⎟ = 2 (3) ⎝ 2⎠ From Eqs. (2) and (3), we get R



2 ⇒  R=



×

p = 2 2

4  p



Let x2 = u ⇒ 2x dx = dt or  x dx =

⎛ px⎞ ⎟ +S 2⎠

I= =

(5)

I=

Substituting Eq. (4) in Eq. (5), we get



∫ f ( x)dx = ∫

4 ⎛ px⎞ sin ⎜ ⎟ + ∫S dx ⎝ 2⎠ p

px - cos 4 2 + Sx = × p p 2



=



px -8 cos + Sx 2 2 p



x/4



1 2



-8 ⎛ p ⎞ cos - cos(0)⎟ + S (1 - 0) (6) 2 ⎜ ⎝ ⎠ 2

0

1

∫ f ( x)dx = 0

2R p

Also 4 R= p

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 62

∫ 0

2 1 cos dt = [sin t ](0p / 4) 2

2 1   p   sin    = 0.289  2   4    

x cos( x 2 )dx = 0.289

0

Probability 197. (c)  In a deck of 52 cards, total number of suits = 4 Using pigeon-hole principle, we have p holes which is represents by 4 suits and n pigeon represents number of cards drawn. ⎡ ( n - 1) ⎤ ⎢ p ⎥ +1 = 3 ⎣ ⎦

So,

∫ f ( x)dx = p

As given

( x / 4)

2  1   p   sin   − sin 0  2  4  

Taking limits from 0 to 1, we get 1

dt 2

Limits change from 0 to (p /4)2, therefore

(4)

∫ f ( x)dx = ∫R sin ⎜⎝

x cos( x 2 )dx = I

0

Now, integrating Eq. (1), we get



196. (0.289) x/4



x →1

x7 - 2 x5 + 1 7 x 6 - 10 x 4 7 - 10 = lim = =1 x 3 - 3 x 2 + 2 x →1 3 x 2 - 6 x 3-6



⎡ ( n - 1) ⎤ ⇒  ⎢ ⎥=2 ⎣ 4 ⎦



⇒ 



( n - 1) ≥2 4 ⇒ n–1≥8

⇒ n≥9 So minimum number of cards to be dealt = 9

11/13/2018 9:33:49 AM

Chapter 1  • Engineering Mathematics

198. (d)  Given conditions 1. Pr(E1) = Pr(E2) 2. Pr( E1 ∪ E2 ) = 1 3. E1 and E2 are independent events We know, Pr( E1 ∪ E2 ) = Pr( E1 ) + Pr( E2 ) - Pr( E1 ∩ E2 ) By using condition 3, we get Pr( E1 ∩ E2 ) = Pr( E1 ) Pr( E2 ) Therefore, Pr( E1 ∪ E2 ) = Pr( E1 ) + Pr( E2 ) - Pr( E1 ) Pr( E2 ) Now using condition 1, we get Pr(E1) = Pr(E2)

63

1 P (A ∩ B) 2 P(A | B) = = =1 1 P (B ) 2 1 P (A ∩ B) 2 1 P ( B | A) = = = 1 2 P ( A) 202. (c)  Let the time taken for first and second modules be represented by x and y and total time = t. Therefore, t = x + y is a random variable. Now the joint density function, t

t

0

0

g (t ) = ∫ f ( x, y ) dx = ∫ f ( x, t - x ) dx

Therefore, Pr( E1 ∪ E2 ) = Pr( E1 ) + Pr( E1 ) - Pr( E1 ) Pr( E1 ) = 2 Pr( E1 ) - Pr( E1 ) 2 t = ∫ f1 ( x ) f 2 (t - x ) dx Pr( E1 ∪ E2 )            = Pr( E1 ) + Pr( E1 ) - Pr( E1 ) Pr( E1 ) = 2 Pr( E1 ) - Pr( E1 ) 2 0 Now using condition 2, we get Pr( E1 ∪ E2 ) = 1 which is also called as convolution of f1 and f 2 , abbreviated as f1 ∗ f 2 . 2Pr(E1) – Pr(E1)2 = 1 Therefore, the correct answer is option (c). ⇒ Pr(E)2 – 2Pr(E1) + 1 = 0 On solving 203. (a)  Coin is tossed four times. Hence, the total out(Pr(E1) – 1)2 = 0 ⇒ Pr(E1) = 1 comes = 24 = 16. Therefore, probability of event E1 = 1. Favorable outcomes (the condition getting 2 heads and 2 tails) = {HHTT, HTHT, HTTH, TTHH, THTH, 199. (b)  Total accidents occurred = 7 THHT} = 6 1 6 3 Probability that all accidents occur on Monday = 7 Hence, the required probability = = 7 16 8 1 204. (a)  If hamming distance between two n bit strings is d, Probability that all accidents occur on Tuesday = 7 7 we are asking d out of n trials to be a success (success and so on here means that the bits are different). So, this is a binoTherefore, probability that the accidents occurred on mial distribution with n trials and d successes and the 1 1 probability of success is same day = 7 × 7 = 6 7 7 P = 2/4 = 1/2 200. (c)  Total number of possibilities = 24 = 16 (Because out of the four possibilities {(0, 0), (0, 1), There are only two possibilities when at least one head (1, 0), (1, 1)}, only two, (0, 1) and (1, 0), are success.) and one tail won’t turn up So, That is, HHHH and TTTT Therefore, required probability P ( X = d ) = nCd (1/ 2) d (1/ 2) n - d = nCd / 2n (16 - 2) 14 7 = = = 16 16 8 205. (d)  Length of position vector of point, 201. (d)  We are given, p = x2 + y2 P(A) = 1 and P(B) = 1/2 Both events are independent. p2 = x 2 + y 2 So, E ( p2 ) = E ( x 2 + y 2 ) = E ( x 2 ) + E ( y 2 ) P(A ∩ B) = P(A) ⋅ P(B) = 1 − 1/2 = 1/2

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 63

11/13/2018 9:33:51 AM

64

GATE CS AND IT Chapter-wise Solved Papers

y

(1, 2) (0, 2) (x, y) p x (0, 0)

(1, 0)

Now x and y are uniformly distributed 0 ≤ x ≤ 1 and 0 ≤ y ≤ 2. Probability density function of x =

1 =1 1- 0

Probability density function of y =

1 = 1/ 2 2-0

208. (d)  Number of permutations with ‘2’ in the first place = 19! Number of permutations with ‘2’ in the second place = 10 × 18! Number of permutations with ‘2’ in the third place = 10 × 9 × 17! ! and so on until ‘2’ is in the eleventh place. After that, it is not possible to satisfy the given condition, because there are only 10 odd numbers available to fill before ‘2’. So, the desired number of permutations which satisfies the given condition is 19 ! + 10 × 18! + 10 × 9 × 17 ! + 10 × 9 × 8 × 16 ! +  + 10 ! × 9 ! Now, the probability of this happening is given by 19 ! + 10 × 18! + 10 × 9 × 17 ! +  + 10 ! × 9 ! 20 ! which is clearly not options (a), (b) or (c). Therefore, correct option is (d), that is, none of these.

1

⎡ x3 ⎤ 1 E ( x ) = ∫ x p( x )dx = ∫ x ⋅1⋅ dx = ⎢ ⎥ = 3 ⎣ ⎦0 3 0 0 1

1

2

2

2

2

2 2 ⎡ y3 ⎤ E ( y 2 ) = ∫ y 2 p( y )dy = ∫ y 2 ⋅1 / 2 ⋅ dy = ⎢ ⎥ ⎣ 6 ⎦0 0 0 8 4 = = 6 3

209. (c)  Let C denote computer science study and M denote maths study. Now by rule of total probability, we total up the desired branches and get the answer as shown below: P(C on Monday and C on Wednesday) = P(C on Monday, C on Tuesday and C on Wednesday) + P(C on Monday, M on Tuesday and C on Wednesday)

∴ E ( p2 ) = E ( x 2 ) + E ( y 2 ) =

1 4 5 + = 3 3 3

= 1 × 0.6 × 0.4 + 1 × 0.4 × 0.4 = 0.24 + 0.16 = 0.40

206. (c) If f (x) is the continuous probability density function of a random variable X, then b

P ( a < x ≤ b) = P ( a ≤ x ≤ b) = ∫ f ( x )dx a

210. (a) Given, mx = 1, σx2 = 4 ⇒ σ y = 2 Also given, my = -1 and σ y is unknown

In general, we say that X is a uniform random variable on the interval (a, b) if its probability density function is given by

Given, P(X ≤ -1) = P(Y ≥ 2) Converting into standard normal variates. ⎛ 2 - μy ⎞ ⎛ -1 - μ x ⎞ = P⎜z ≥ P⎜z ≤ ⎟ σx ⎠ σ y ⎟⎠ ⎝ ⎝

⎧ 1 if α < x < β ⎪ f ( x) = ⎨ β - α ⎪ 0 otherwise ⎩

⎛ 2 - ( -1) ⎞ -1 - 1⎞ ⎛ = P⎜z ≥ P⎜z ≤ ⎟ ⎝ 2 ⎠ σ y ⎟⎠ ⎝

As f (x) is a constant, all values of x between α and β are equally likely (uniform). 207. (a)  The probability that exactly n elements are chosen is equal to the probability of getting n heads out of 2n tosses, that is

=

2n

Cn (1/ 2) n (1/ 2) 2 n - n (Binomial formula)



=

2n

Cn (1/ 2) n (1/ 2) n

2n

Cn

=

22 n

2n

2n C C = 2 nn = n n (2 ) 4



Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 64



⎛ 3⎞ (1) P ( z ≤ -1) = P ⎜ z ≥ σ y ⎟⎠ ⎝ Now, we know that in standard normal distribution, P(z ≤ −1) = P(z ≥ 1)

(2)

Comparing Eqs. (1) and (2), we can say that 3 = 1⇒ σy = 3 σy

11/13/2018 9:33:55 AM

Chapter 1  • Engineering Mathematics

211. (b)  It is given that P(odd) = 0.9P(even) ∑ p( x) = 1

215. (c)  The probability distribution table of the random variable is x

−1

+1

P(x)

0.5

0.5

Now, P(odd) + P(even) = 1 0.9P(even) + P(even) = 1 P(even) = 1/1.9 = 0.5263 Now, it is given that P(any even face) is same

The cumulative distribution function F (x) is the probability up to x as follows:

⇒ P ( 2) = P ( 4) = P (6) Now, P(even) = P(2) or P(4) or P(6) = P(2) + P(4) + P(6) ∴ P(2) = P(4) = P(6) = 1/3P(even) = 1/3(0.5263) = 0.1754 It is given that P(even | face > 3) = 0.75 ⇒ ⇒

P (even ∩ face > 3) P (face > 3)

P (face = 4, 6 ) P (face > 3)

⇒ P (face > 3) = = =

= 0.75

0.75 0.1754 + 0.1754 = 0.4677  0.468 0.75

212. (a)  The probability of a faulty assembly of any ­computer = p The probability of a computer being declared faulty from a faulty assembly = pq The probability of a non-faulty assembly of any ­computer = 1 − q The probability of a computer being declared faulty from a non-faulty assembly = (1 − p)(1 − q) Required probability = pq + (1 − p)(1 − q) 213. (a)  The five cards are {1, 2, 3, 4, 5}

−1

+1

F (x)

0.5

1.0

216. (c)  Poisson formula for (p = x) is given as

e- x l x . x!

l = mean of Poisson distribution = 3 (given) Probability of observing fewer than 3 cars = (p = 0) + (p = 1) + (p = 2) =

P (face = 4, 6 ) 0.75

x

Hence, the values of cumulative distributive function are 0.5 and 1.0.

= 0.75

P ( 4 ) + P (6 )

e -3 l 0 e -3 l 1 e -3 l 2 17 + + = 3 0! 1! 2! 2e

217. (0.25)  The length of shorter stick ranges between 0 and 0.5 meters, with each length equally possible. So, the average expected length is 0.25 m. 218. (11.92) If p is the probability that system is functional means at least three systems are working, p will be calculated as: p for at least 3 systems are working All 4 systems working + 3 systems working = Number of ways to pick 4 systems from 100 p that 3 systems are working = ( Number of systems not select ed ) × ( Number of ways to pick 3 from 4 selected systems) = 6 × 4 ×3× 2× 4

Sample space = 5 × 4

Therefore,

Favorable outcome = P {( 2,1) , (3, 2) , ( 4, 3) , (5, 4 )}

p for at least 3 systems are working ( 4 × 3 × 2 × 1) + (6 × 4 × 3 × 2 × 4) = = 0.1192 10 × 9 × 8 × 7

=

1 4 = 5× 4 5

214. (d)  Standard deviation is affected by scale but not by shift of origin. So, yi = axi + b ⇒ sy = asx and not sy = asx + b

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 65

65

So, 100p = 11.92 219. (3.88)  The given 9 words are as follows: The, Quick, Brown, Fox, Jumps, Over, The, Lazy, Dog Words with length 3 are THE, FOX, THE, DOG (4) Words with length 4 are OVER, LAZY (2)

11/13/2018 9:33:57 AM

66



GATE CS AND IT Chapter-wise Solved Papers



1

-∞

f ( x )dx = 1 ⇒ ∫ a

Words with length 5 are QUICK, BROWN, JUMPS (3) Probability for drawn 3 length words = 4/9 Probability for drawn 4 length words = 2/9 Probability for drawn 5 length words = 3/9

1

⎡ 1⎤ ⇒ ⎢- ⎥ = 1 ⎣ x ⎦a 1 ⇒ -1 = 1 a 1 ⇒ a = = 0.5 2

Expected word length



⎧⎛ 3⎞ ⎫ 4⎞ ⎛ 2⎞ ⎛ = ⎨⎜ 3 × ⎟ + ⎜ 4 × ⎟ + ⎜ 5 × ⎟ ⎬ = 3.88 ⎝ ⎠ ⎝ ⎠ ⎝ ⎠⎭ 9 9 9 ⎩

220. (10)  Sum 22 comes with following possibilities: 6 + 6 + 6 + 4 = 22 (numbers can be arranged in 4 ways) 6 + 6 + 5 + 5 = 22 (numbers can arranged in 6 ways) Therefore, the total ways X = 4 + 6 = 10 221. (0.259 to 0.261) Let A event → Divisible by 2, B event → Divisible by 3, C event → Divisible by 5 P(A′ ∩ B′ ∩ C′) = 1 − P(A ∪ B ∪ C) P(A) = 50/100, P(B) = 33/100, P(C) = 20/100 P(A ∩ B) = 16/100, P(B ∩ C) = 6/100, P(A ∩ C) = 10/100, P(A ∩ B ∩ C) = 3/100 P(A ∪ B ∪ C) = P(A) + P(B) + P(C) − P(A ∩ B) − P(B ∩ C) − P(A ∩ C) + P(A ∩ B ∩ C) P(A ∪ B ∪ C) = (50 + 33 + 20 − 16 − 6 − 10 + 3)/ 100 = 74/100 P(A′ ∩ B ′ ∩ C ′) = 1 − 74/100 = 26/100 = 0.26 222. (0.25)  Maximum value of P(A) P(B) = ?

225. (0.55) (i)  Type 1 LED bulb: The probability that the bulb is of Type 1 and it lasts more than 100 hours is 1 × 0.7 2 (ii)  Type 2 LED bulb: The probability that the bulb is of Type 2 and it lasts for more than 100 hours is 1 × 0.4 2 Therefore, the probability that an LED bulb chosen uniformly at random and lasts more than 100 hours is ⎛1 ⎞ ⎛1 ⎞ ⎜⎝ × 0.7⎟⎠ + ⎜⎝ × 0.4⎟⎠ = 0.55 2 2 226. (0.33)  The probability, that the output of the given

experiment is Y, can be written as follows: ⎛ 1⎞ ⎛ 1 1⎞ ⎛ 1 1 1⎞ P (Y ) = ⎜ ⎟ + ⎜ × ⎟ + ⎜ × × ⎟ ⎝ 4⎠ ⎝ 4 4⎠ ⎝ 4 4 4⎠

P(A)P(B) = P(A)[1 − P(A)] Let P(A) = x f (x) = x − x2

=

f ′(x) = 1 − 2x = 0 So, x = 1/2 and f ˝(x) = −2 and x is maximum at 1/2. hence

1 dx = 1 x2

1/ 4 1 = = 0.33 1 - (1/ 4) 3

1st time HEADS HEADS TAILS TAILS 2nd time HEADS TAILS HEADS TAILS

P(A) P(B) = 0.25 223. (0.95) 

X = 2, Y = 20

N

Number of functions from X to Y is 202, that is 400 and number of one-one functions from X to Y is 20 × 19 = 380. Therefore, probability of a function f  being one-one is 380 = 0.95 400 224. (0.5)  It is given that ⎧1/x 2 , for a ≤ x ≤ 1 f ( x) = ⎨ ⎩ 0, otherwise

Y

227. (0) As X is a Gaussian random variable, the distribution of x is N(0, s  2). Given Y = max (X, 0) ⎧X, =⎨ ⎩ 0,

if 0 < X < ∞ if - ∞ < X ≤ 0

Therefore, median remains at 0, as it is a positional average. Hence, median (Y ) = 0. 228. (54)

That is, ∞



-∞

1

f ( x )dx = 1 ⇒ ∫ a

1 dx = 1 x2

In Poisson distribution, if X is a random variable, then E(X) = Mean = l = 5

1

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd

⎡ 1⎤ ⇒ ⎢- ⎥ = 1 ⎣ x ⎦a 1 ⇒ -1 = 1 a 1 66 ⇒ a = = 0.5

11/13/2018 9:33:58 AM

Chapter 1  • Engineering Mathematics

and

67

5 1 1 5 ∴ P (one of them wins 3rd trial) = × × = 6 6 6 216

E(X) = V(X) = 5 Now,

= 0.023 E(X ) = V(X) + (E(X)) = 5 + 5 = 30 2

2

2

Therefore, E[(X + 2)2] = E (X2 + 4X + 4)

= E (X2) + 4 E (X) + 4



= 30 + 4 × 5 + 4 = 54

229. (0.023)  Probability that one of them wins 3rd trial is probability that there is a tie in 1st and 2nd trial, i.e., P (one of them wins 3rd trial) = P (tie in 1st trial) × P (tie in 2nd trial) × P (one of them wins 3rd trial) 8 1 Now P (tie in a trial) = = 36 6 1 5 P (one of them wins) = 1− P( tie) = 1− = 6 6

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 67

230. (0.601)  By definition of conditional probability, P ( H G /H D ) = and    P( H D /H G ) =

P( H G ∩ H D ) P( H D )

P( H D ∩ H G ) P( H G )

\ P ( H G /H D ) = P ( H D /H G ) ×

P( H G ) P( H D )

=

0.40× 0.2 P( H D )

Now, P(HD) = P(HD/HG) × P(HG) + P(HD/MG) ×P(MG) + P(HD/HG) × P(HG) = 0.4 × 0.2 + 0.1 × 0.5 + 0.01 × 0.3 = 0.133 \ P ( H G /H D ) =

0.40× 0.20 = 0.601 0.133

11/13/2018 9:34:00 AM

Ch wise GATE_CSIT_Ch1_Engineering Mathematics_Exp.indd 68

11/13/2018 9:34:00 AM

Digital Logic

CHAPTER2

Syllabus Boolean algebra. Combinational and sequential circuits. Minimization. Number representations and computer arithmetic (fixed and floating point).

Chapter Analysis Topic

GATE 2009

GATE 2010

Boolean algebra

2

1

Combinational circuits

1

1

1

1

1

2

3

2

Sequential circuits

GATE 2011

1 1

GATE 2013

GATE 2014

GATE 2015

GATE 2016

3

3

2

2

4

4

2

1

2

2

1

1

2

1

1

Minimization Number representations

GATE 2012

1

Computer arithmetic (fixed and floating point)

1

2

GATE 2017

GATE 2018 1 1

3 2

3

Important Formulas   1. Null − All the outputs are zero.

17. X + (∼X) = 1

  2. Identity − All the outputs are one.

18. X + X = X

  3. X inhibit Y - Represented as (x ⋅ ∼y)

19. X + 1 = 1

  4. Y inhibit X - Represented as (y ⋅ ∼x)

20. X + Y = Y + X

  5. Transfer - Same as y

21. X + (Y + Z) = (X + Y) + Z

  6. AND - x ⋅ y (Similar to intersection in set theory)

22. X ⋅ (Y + Z) = X ⋅Y + X ⋅ Z

  7. OR - x + y (Similar to union in set theory)

23. ∼(X +Y) = ∼X ⋅ ∼Y (Also called De Morgan’s law)

  8. NOT X− ∼x (Also known as complement of x)

24. X + (X ⋅Y) = X

  9. NOT Y− ∼y (Also known as complement of y)

25. ∼(∼X) = X

10. XOR − (∼x ⋅ y) + (x ⋅ ∼y) (Also known as parity checker)

Duality Theorem:

11. XNOR − (x ⋅ y) + (∼x ⋅ ∼y)

26. X ⋅ 1 = X

12. NAND − ∼(x ⋅ y)

27. (X ⋅ ∼X) = X ⋅ X′ = 0

13. NOR − ∼(x + y)

28. X ⋅ X = X

14. X implication Y (∼x + y)

29. X ⋅ 0 = 0

15. Y implication X (∼y + x)

30. X ⋅ Y = Y ⋅ X

16. X + 0 = X

31. X ⋅ (Y ⋅ Z) = (X ⋅ Y ) ⋅Z

Ch wise GATE_CSIT_CH02_Digital Logic.indd 69

11/13/2018 9:42:57 AM

70

GATE CS AND IT Chapter-wise Solved Papers

32. X + (Y ⋅ Z) = (X + Y) ⋅ (X + Z)

Half Subtractor:

33. (X ⋅ Y)′ = X′ + Y′

39. D = XY ′ + X ′Y 40. B = X ′Y

34. X ⋅ (X + Y) = X

Full Subtractor:

Half Adder:

41. D = X ′Y ′Bin + X ′YBin′ + XY ′Bin′ + XYBin

35. S = X′Y + XY′

42. B = X ′Y + X ′YBin + YBin

36. C = XY

Characteristic Equations: 43. SR flip–flop: Qn + 1 = S + R ′Qn

Full Adder:

44. D flip–flop: Qn + 1 = D

37. S = X ′Y ′Cin + X ′YCin′ + XY ′Cin′ + XYCin

45. JK flip–flop: Qn +1 = JQn′ + KQn

38. Cout = ACin + XY + YCin

46. T flip–flop: Qn −1 = TQn′ + T ′Qn

QUESTIONS 1.

The number 43 in 2’s complement representation is (a) 01010101 (b) 11010101 (c) 00101011 (d) 10101011 (GATE 2000: 1 Mark)

2.

The simultaneous equations on the Boolean variables x, y, z and w, x+y+z=1 xy = 0 xz + w = 1 xy + zw = 0

4.

The following arrangement of master–slave flip–flops has the initial state of P, Q as 0, 1 (respectively). After the clock cycles the output state P, Q is (respectively) Q 1

P

J

Which functions does NOT implement the Karnaugh map given below? 00

01

11

10

00

0

×

0

0

01

0

×

1

1

11

1

1

1

1

10

0

×

0

0

wz→ xy↓

(a) (w + x) y

(b) xy + yw

(c) ( w + x )( w + y )( x + y )

(d) None of the above (GATE 2000: 2 Marks)

Ch wise GATE_CSIT_CH02_Digital Logic.indd 70

D

1

have the following solution for x, y, z and w, respectively: (a) 0 1 0 0 (b) 1 1 0 1 (c) 1 0 1 1 (d) 1 0 0 0 (GATE 2000: 2 Marks) 3.

K

Clock (a) 1, 0 (c) 0, 0 5.

(b) 1, 1 (d) 0, 1 (GATE 2000: 2 Marks)

Consider the values of A = 2.0 × 1030, B = –2.0 × 1030, C = 1.0, and the sequence  X = A + B  Y = A + C X = X + C  Y = Y + B Executed on a computer where floating point numbers are represented with 32 bits. The values for X and Y will be (a) X = 1.0, Y = 1.0 (b) X = 1.0, Y = 0.0 (c) X = 0.0, Y = 1.0 (d) X = 0.0, Y = 0.0 (GATE 2000: 2 Marks)

11/13/2018 9:42:59 AM

71

Chapter 2  •  Digital Logic

6.

Given the following Karnaugh map, which one of the following represents the minimal Sum-Of-Products of the map?

9.

Consider the circuit shown below. The output of a 2:1 MUX is given by the function ( ac + bc).

wx

yz

00

01

11

10 ×

00

0

×

0

01 11

×

×

0

1 ×

1

1 0

10

0

1

×

0

(a) xy + yz

(b) wx y + xy + xz

(c) wx + yz + xy

(d) xz + y

2:1 MUX 0

D1

D0

Q1

Clock

f

b b

c x2

Which of the following is true? (a)

f = x1 + x2 (b) f = x1 x2 + x1 x2

(c)

f = x1 x2 + x1 x2 (d) f = x1 + x2 (GATE 2001: 2 Marks)

10. Consider the circuit given below with initial state Q0 = 1, Q1 = Q2 = 0. The state of the circuit is given by the value 4Q2 + 2Q1 + Q0

Y

D0

Q0

2:1 MUX

x1

Consider the following circuit with initial state Q0 = Q1 = 0. The D flip–flops are positive edged triggered and have set up times 20 nanosecond and hold times 0.

X

g

c

(GATE 2001: 1 Mark) 7.

a

a

1

Q0

D1

Q1

D2

Q2

Clock

Consider the following timing diagrams of X and C; the clock period of C ≥ 40 nanosecond. Which one is the correct plot of Y ?

LSB

MSB

Clock

Which one of the following is the correct state sequence of the circuit? (a) 1,3,4,6,7,5,2 (b) 1,2,5,3,7,6,4 (c) 1,2,7,3,5,6,4 (d) 1,6,5,7,2,3,4 (GATE 2001: 2 Marks)

C X (a)

11. Minimum sum of product expression for f (w, x, y, z) shown in Karnaugh-map below is

(b) (c) (d) (GATE 2001: 2 Marks) 8.

The 2’s complement representation of ( −539)10 in hexadecimal is (a) ABE (b) DBC (c) DE5 (d) 9E7 (GATE 2001: 2 Marks)

Ch wise GATE_CSIT_CH02_Digital Logic.indd 71

yz 00 01 11 10

wx

00

01

11

10

0 ×

1 0

1 0

0 1

× 0

0

0

1

1

1

×

xz + zx (a) xz + yz (b) (c) xy + zx

(d) None of the above (GATE 2002: 1 Mark)

11/13/2018 9:43:02 AM

72

GATE CS AND IT Chapter-wise Solved Papers

12. The decimal value 0.25 (a) is equivalent to the binary value 0.1 (b) is equivalent to the binary value 0.01 (c) is equivalent to the binary value 0.00111… (d) cannot be represented precisely in binary (GATE 2002: 1 Mark)

17. Consider the following multiplexor where 10, 11, 12, 13 are four data input lines selected by two address line combinations A1A0 = 00, 01, 10, 11 respectively and f is the output of the multiplexor. EN is the Enable input. 10 4 to 1 11 Multiplexor 12 13 Output A1 A0 EN

13. The 2’s complement representation of the decimal value −15 is (a) 1111 (b) 11111 (c) 111111 (d) 10001 (GATE 2002: 1 Mark) 14. Sign extension is a step in (a) floating point multiplication (b) signed 16 bit integer addition (c) arithmetic left shift (d) converting a signed integer from one size to another (GATE 2002: 1 Mark) 15. In 2’s complement addition, overflow (a) is flagged whenever there is carry from sign bit addition (b) cannot occur when a positive value is added to a negative value (c) is flagged when the carries from sign bit and previous bit match (d) None of the above (GATE 2002: 1 Mark) 16. Consider the following logic circuit whose inputs are functions f1, f2, f3 and output is f.

The function f (x, y, z) implemented by the above circuit is (a) xyz (b) xy + z (c) x + y (d) None of the above (GATE 2002: 2 Marks) 18. Let f ( A, B ) = A + B. Simplified expression for function f (   f (x + y, y), z) is (a) x + z (b) xyz (c) xy + z (d) None of the above (GATE 2002: 2 Marks) 19. Assuming all numbers are in 2’s complement ­representation, which of the following numbers is divisible by 11111011? (a) 11100111 (b) 11100100 (c) 11010111 (d) 11011011 (GATE 2003: 1 Mark) 20. Consider an array multiplier for multiplying two n bit numbers. If each gate in the circuit has a unit delay, the total delay of the multiplier is

f1(x, y, z) f2(x, y, z)

f(x, y, z)

Given that

(c) Θ(n)

(d) Θ(n2) (GATE 2003: 1 Mark)

Bit position

15

14.....9

8.....0

 

s

e

m

f 2 ( x, y, z ) = ∑ (6, 7) , and

 

sign

exponent

mantissa



f3 is

∑ (1, 4, 5) (b) ∑ (6, 7) (d) None of the above ∑ (0,1, 3, 5) (GATE 2002: 2 Marks)

Ch wise GATE_CSIT_CH02_Digital Logic.indd 72

(b) Θ(log n)

f1 ( x, y, z ) = ∑ (0,1, 3, 5) ,

f ( x, y, z ) = ∑ (1, 4, 5) ,

(c)

(a) Θ(1)

21. The following is a scheme for floating point number representation using 16 bits.

f3(x, y, z) = ?

(a)

f(x, y, z) = ?



Let s, e, and m be the numbers represented in binary in the sign, exponent, and mantissa fields, respectively. Then the floating point number represented is ⎧( −1) s (1 + m × 2 −9 )2e − 31 if the exponent ≠ 111111 ⎨ 0 otherwise ⎩ What is the maximum difference between two successive real numbers representable in this system?

11/13/2018 9:43:05 AM

Chapter 2  •  Digital Logic

(a) 2−40 (c) 222

(b) 2−9 (d) 231

transition(s) (change of logic levels) occur(s) at B during the interval from 0 to 10 ns?

(GATE 2003: 2 Marks)

Logic 1 A Logic 0 8 9 Time 0 1 2 3 4 5 6 7 10 11 (ns)

22. A 1-input, 2-output synchronous sequential circuit behaves as follows: Let zk, nk denote the number of 0’s and 1’s, respectively, in initial k bits of the input (zk + nk= k). The circuit outputs 00 until one of the following conditions holds. (A)  zk − nk = 2. In this case, the output at the kth and all subsequent clock ticks is 10. (B)  nk − zk = 2. In this case, the output at the kth and all subsequent clock ticks is 01. What is the minimum number of states required in the state transition graph of the above circuit? (a) 5 (b) 6 (c) 7 (d) 8 (GATE 2003: 2 Marks) 23. The literal count of a Boolean expression is the sum of the number of times each literal appears in the expression. For example, the literal count of (xy + xz′) is 4. What are the minimum possible literal counts of the product-of-sum and sum-of-product representations, respectively, of the function given by the following ­Karnaugh map? Here, × denotes “don’t care”. zw xy 00

00

01

11

10

×

1

0

1

01

0

1

×

0

11

1 ×

× 0

0

10

× 0

(a) (11, 9) (c) (9, 10)

×

(GATE 2003: 2 Marks) 24. Consider the following circuit composed of XOR gates and non-inverting buffers. A



B d2 = 4

The non-inverting buffers have delays d1 = 2 ns and d2  = 4 ns as shown in the figure. Both XOR gates and all wires have zero delay. Assume that all gate inputs, outputs and wires are stable at logic level 0 at time 0. If the following waveform is applied at input A, how many

Ch wise GATE_CSIT_CH02_Digital Logic.indd 73

(a) 1 (c) 3

(b) 2 (d) 4 (GATE 2003: 2 Marks)

25. A Boolean function x′y′ + xy + x′y is equivalent to (a) x′ + y′ (b) x+y (c) x + y′ (d) x′ + y (GATE 2004: 1 Mark) 26. In an SR latch made by cross-coupling two NAND gates, if both S and R inputs are set to 0, then it will result in (a) Q = 0, Q ′ = 1 (b) Q = 1, Q ′ = 0 (c) Q = 1, Q ′ = 1 (d) Indeterminate states (GATE 2004: 1 Mark) 27. If 73x (in base-x number system) is equal to 54y (in base-y number system), the possible values of x and y are (a) 8, 16 (b) 10, 12 (c) 9, 13 (d) 8, 11 (GATE 2004: 1 Mark) 28. What is the result of evaluating the following two expressions using three-digit floating point arithmetic with rounding? (113 + −111) + 7.51 113 + (−111 + 7.51)

(b) (9, 13) (d) (11, 11)

d1 = 2

73

(a) (b) (c) (d)

9.51 and 10.0, respectively 10.0 and 9.51, respectively 9.51 and 9.51, respectively 10.0 and 10.0, respectively (GATE 2004: 1 Mark)

29. Consider a multiplexer with X and Y as data inputs and Z as control input. Z = 0 selects input X, and Z = 1 selects input Y. What are the connections required to realize the 2-variable Boolean function f = T + R, without using any additional hardware? (a) R to X, 1 to Y, T to Z (b) T to X, R to Y, T to Z (c) T to X, R to Y, 0 to Z (d) R to X, 0 to Y, T to Z (GATE 2004: 2 Marks)

11/13/2018 9:43:05 AM

74

GATE CS AND IT Chapter-wise Solved Papers

30. A circuit outputs a digit in the form of 4 bits, where 0 is represented by 0000, 1 by 0001, …, 9 by 1001. A combinational circuit is to be designed which takes these 4 bits as input and output 1 if the digit ≥ 5, and 0 otherwise. If only AND, OR and NOT gates are used, what is the minimum number of gates required? (a) 2 (b) 3 (c) 4 (d) 5

(a) 1100 0100 (c) 1010 0101

(GATE 2004: 2 Marks) 35. Consider the following circuit. X Y

(GATE 2004: 2 Marks) 31. Which are the essential prime implicants of the following Boolean function? f (a, b, c) = a′c + ac′ + b′c (a) a′c and ac′ (b) a′c and b′c (c) a′c only (d) ac′ and bc′

X T2

Q2

MSB

T1

Q1 LSB

CLK

To complete the circuit, the input X should be (a) Q2′ (b) Q2 + Q1 (c) (Q1 ⊕ Q2 ) ′ (d) Q1 ⊕ Q2 (GATE 2004: 2 Marks) 33. A 4-bit carry look-ahead adder, which adds two 4-bit numbers, is designed using AND, OR, NOT, NAND, NOR gates only. Assuming that all the inputs are available in both complemented and uncomplemented forms and the delay of each gate is one time unit, what is the overall propagation delay of the adder? Assume that the carry network has been implemented using two-level AND-OR logic. (a) 4 time units (b) 6 time units (c) 10 time units (d) 12 time units

Which one of the following is TRUE? (a) f is independent of X. (b) f is independent of Y. (c) f is independent of Z. (d) None of X, Y, Z is redundant. (GATE 2005: 1 Mark) 36. The range of integers that can be represented by an n-bit 2’s complement number system is (a) −2n − 1 to (2n − 1 − 1) (b) −2(2n − 1 − 1) to (2n − 1 − 1) (c) −2n − 1 to 2n − 1 (d) −2(2n − 1+ 1) to (2n − 1 − 1) (GATE 2005: 1 Mark) 37. The hexadecimal representation of 6578 is (a) 1AF (b) D78 (c) D71 (d) 32F (GATE 2005: 1 Mark) 38. The switching expression corresponding to f (A, B, C, D) = ∑(1,4,5,9,11,12) is (a) BC ′D ′+ A′C ′D + AB ′D (b) ABC ′+ ACD + B ′C ′D (c) ACD ′+ A′BC ′+ AC ′D ′ (d) A′BD + ACD ′+ BCD ′ (GATE 2005: 1 Mark) 39. Consider the following circuit involving a positive-edge triggered D flip–flops. A X

(GATE 2004: 2 Marks) 34. Let A = 1111 1010 and B = 0000 1010 be two 8-bit 2’s complement numbers. Their product in 2’s complement is

Ch wise GATE_CSIT_CH02_Digital Logic.indd 74

f

Z

(GATE 2004: 2 Marks) 32. Consider the partial implementation of a 2-bit counter using T flip–flops following the sequence 0-2-3-1-0, as shown in the following figure.

(b) 1001 1100 (d) 1101 0101

D

Q Y

CLK Q´

Consider the following timing diagram. Let Ai represent the logic level on the line A in the ith clock period.

11/13/2018 9:43:07 AM

75

Chapter 2  •  Digital Logic

0’s are padded in while shifting a field. The normalized ­representation of the above number (0.239 × 213) is CLK 0

1

2

3

4

5

(a) 0A 20 (c) 49 D0

(b) 11 34 (d) 4A E8 (GATE 2005: 2 Marks)

X



Let A′ represent the complement of A. The correct output sequence on Y over the clock periods 1 through 5 is (a)

A0 A1 A1′ A3 A4 (b) A0 A1 A2′ A3 A4

(c)

A1 A2 A2′ A3 A4 (d) A1 A2′ A3 A4 A5′

43. You are given a free running clock with a duty cycle of 50% and a digital waveform of 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 off by 180°? (a)

f

D

D Q Q

(GATE 2005: 2 Marks) CLK

40. Consider the following circuit.

Q0

D1

D0

Q1

(b)

f

D Q

D Q

D Q

D Q

CLK

Q 0′

Q 1′

(c)

CLK The flip–flops are positive-edge triggered D flip–flops. Each state is designated as a 2-bit string Q0Q1. Let the initial state be 00. The state transition sequence is (a) 00-11-01 (c) 00-10-01-11

(b) 00-11 (d) 00-11-01-10 (GATE 2005: 2 Marks)

f CLK

(d)

f

D

D Q Q

CLK

Linked Answer Questions 41 and 42: Consider the following floating-point format. 15

14

8 7

0

(GATE 2006: 1 Mark) 44. Consider the circuit shown. Which one of the following options correctly represents f(x, y, z)? X 0

Sign bit

Excess-64 Exponent

Mantissa is a pure fraction in sign-magnitude form. 41. The decimal number 0.239 × 213 has the following hexadecimal representation (without normalization and rounding off): (a) 0D 24 (b) 0D 4D (c) 4D 0D (d) 4D 3D (GATE 2005: 2 Marks) 42. 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

Ch wise GATE_CSIT_CH02_Digital Logic.indd 75

MUX

Mantissa 1 Y Z

0 MUX f 1

X Y xz + xy + yz (a) xz + xy + yz (b) (c) xz + xy + yz (d) xz + xy + yz (GATE 2006: 1 Mark)

11/13/2018 9:43:09 AM

76

GATE CS AND IT Chapter-wise Solved Papers

45. Given two 3-bit numbers a2a1a0 and b2b1b0 and c, the carry in the function that represents the carry generate function when these two numbers are added is (a) a2 b2 + a2 a1b1 + a2 a1a0 b0 + a2 a0 b1b0

(d) an−1 ⊕ bn−1 ⊕ cn−1

+ a1a0 b2 + a1a0 b2 b0 + a2 a0 b1b0 (c) a2 + b2 + ( a2 ⊕ b2 )( a1 + b1 + ( a1 ⊕ b1 )( a0 + b0 )) (d) a2 b2 + a2 a1b1 + a2 a1a0 b0 + a2 a0 b1b0 + a1b2 b1 + a1a0 b2 b0 + a0 b2 b1b0 (GATE 2006: 1 Mark) 46. Consider the circuit in the diagram. The ⊕ operator represents XOR. The D flip–flops are initialized to zeroes (cleared).

Data q1 Q

clk

D clk

q0 Q

D clk Clock



The following data 100110000 is supplied to the “data” terminal in nine clock cycles. After that the values of q2 q1q0 are (a) 000 (c) 010

(b) 001 (d) 101 (GATE 2006: 1 Mark)

47. 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 i1 = (w1, x1, y1, z1) and i2 = (w2, x2, y2, z2), we would like the function to remain true as the input changes from i1 to i2 (i1 and i2 differ in exactly 1 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) (b) (c) (d)

w′xz, wxy′, xy′z, xyz, wyz wxy, w′xz, wyz wxyz, xz, wx′yz wzy, wyz, wxz, w′xz, xy′z, xyz (GATE 2006: 1 Mark)

48. We consider the addition of two 2’s complement numbers bn −1bn −2 … b0 and an −1an −2 … a0 . A binary adder for adding unsigned binary numbers is used to add the two numbers. The sum is denoted by cn −1cn −2 … c0 and the carry-out by cout.

Ch wise GATE_CSIT_CH02_Digital Logic.indd 76

(a) cout ( an −1 ⊕ bn −1 ) (c) cout ⊕ cn−1

(b) a2 b2 + a2 b1b0 + a2 a1b1b0 + a1a0 b2 b1

D

Which one of the following options correctly identifies the overflow condition?

(b) an −1bn −1 cn −1 + an −1bn −1cn −1

+ a1b2 b1 + a1a0 b2 b0 + a0 b2 b1b0

q2 Q



(GATE 2006: 1 Mark) 49. Consider numbers represented in 4-bit gray code. Let h3h2h1h0 be the gray code representation of a number n and let g3g2g1g0 be the gray code of (n + 1) (modulo 16) value of the number. Which one of the following functions is correct? (a) g0(h3h2h1h0) = ∑(1, 2, 3, 6, 10, 13, 14, 15) (b) g1(h3h2h1h0) = ∑(4, 9, 10, 11, 12, 13, 14, 15) (c) g2(h3h2h1h0) = ∑ (2, 4, 5, 6, 7, 12, 13, 15) (d) g3(h3h2h1h0) = ∑(0, 1, 6, 7, 10, 11, 12, 13) (GATE 2006: 1 Mark) 50. What is the maximum number of different Boolean functions involving n Boolean variables? (a) n2 (b) 2n n

2

(c) 22 (d) 2n (GATE 2007: 1 Mark) 51. 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 (b) 8 (c) 9 (d) 10 (GATE 2007: 1 Mark) 52. 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) (b) (c) (d)

independent of one variable independent of two variables independent of three variables dependent on all the variables (GATE 2007: 1 Mark)

53. 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) (Q) (R) (S)

x′y′z′ + w′xy′ + wy′z + xz w′y′z′ + wx′y′ + xz w′y′z′ + wx′y′ + xyz + xy′z x′y′z′ + wx′y′ + w′y

11/13/2018 9:43:10 AM

77

Chapter 2  •  Digital Logic

(a) P only (c) R and S

The counter is connected as follows:

(b) Q and S (d) S only

A4

(GATE 2007: 2 Marks)

A3

A2

A1

54. Define the connective * for the Boolean variables X and Y as X * Y = XY + X′Y′. Let Z = X * Y. Consider the ­following expressions P, Q and R. P: X = Y * Z  Q: Y = X * Z  R: X * Y * Z = 1

Count = 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. (GATE 2007: 2 Marks) 55. 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? (a) 2n line to 1 line (b) 2n + 1 line to 1 line (c) 2n − 1 line to 1 line (d) 2n − 2 line to 1 line (GATE 2007: 2 Marks) 56. In a look-ahead carry generator, the carry generate function Gi and the carry propagate function Pi for inputs Ai and Bi are given by Pi = Ai ⊕ Bi and Gi = AiBi

The expressions for the sum bit Si and the carry bit Ci + 1 of the look-ahead carry adder are given by Si = Pi ⊕ Ci and Ci + 1 = Gi + PiCi, where C0 is the input carry. Consider a two-level logic implementation of the lookahead carry generator. Assume that all Pi and Gi 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 lookahead carry generator for a 4-bit adder with S3, S2S1, S0, and C4 as its outputs are, respectively, (a) 6, 3 (b) 10, 4 (c) 6, 4 (d) 10, 5 (GATE 2007: 2 Marks)

Clear

Load = 0

4-bit counter

Clock

Inputs

0

0

1

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 (b) 0, 3, 4, 5 (c) 0, 1, 2, 3, 4 (d) 0, 1, 2, 3, 4, 5 (GATE 2007: 2 Marks)

58. In the Karnaugh map shown below, × denotes a don’t care term. What is the minimal form of the function represented by the Karnaugh map? ab cd 00 01

00

01

1

1

1

11

× 1

1

×

10

11

10

×

a ⋅ b + b ⋅ d + ab ⋅ d (a) b ⋅ d + a ⋅ d (b) (c) b ⋅ d + a ⋅ b ⋅ d (d) a ⋅b + b ⋅d + a ⋅d (GATE 2008: 1 Mark)

Clear

Clock

Load

Count

1

×

×

×

Clear to 0

0

×

0

0

No change

59. In the IEEE floating-point representation, the hexadecimal value 0x00000000 corresponds to (a) The normalized value 2−127 (b) The normalized value 2−126 (c) The normalized value +0 (d) The special value +0 (GATE 2008: 1 Mark)

0

1

×

Load input

60. Let r denote number system radix. The only value(s) of

0

0

1

Count next

57. The control signal functions of a 4-bit binary counter are given below (where × is “don’t care”):

Ch wise GATE_CSIT_CH02_Digital Logic.indd 77

Function

r that satisfy the equation

121r = 11r is/are

11/13/2018 9:43:11 AM

78

GATE CS AND IT Chapter-wise Solved Papers

(a) Decimal 10 (c) Decimal 10 and 11

(b) Decimal 11 (d) Any value > 2 (GATE 2008: 1 Mark)

61. Given f1, f3 and f in canonical sum of products form (in decimal) for the circuit f1 f2

f

Which one of the following is equivalent to P ∨ Q? P ¬Q (a) ¬Q ¬P (b) (c) ¬P Q (d) ¬P ¬Q (GATE 2009: 1 Mark) 66. How many 32 K × 1 RAM chips are needed to provide a memory capacity of 256 K-bytes? (a) 8 (b) 32 (c) 64 (d) 128 (GATE 2009: 1 Mark)

f3

67. The minterm expansion of f ( P , Q, R) = PQ + QR + PR

f1 = ∑m(4, 5, 6, 7, 8) f3 = ∑m(1, 6, 15)

is

f = ∑m(1, 6, 8, 15) then f2 is

(a) (b) (c) (d)

(a) ∑m(4, 6) (c) ∑m(6, 8)

(b) ∑m(4, 8) (d) ∑m(4, 6, 8) (GATE 2008: 1 Mark)

62. If P, Q, R are Boolean variables, then ( P + Q )( P ⋅ Q + P ⋅ R)( P ⋅ R + Q ) simplifies to (a) P ⋅ Q (b) P⋅R

m2 + m4 + m6 + m7 m0 + m1 + m3 + m5 m0 + m1 + m6 + m7 m2 + m3 + m4 + m5 (GATE 2010: 1 Mark)

68. P is a 16-bit signed integer. The 2’s complement representation of P is (F87B)16. The 2’s complement representation of 8 × P is (a) (C3D8)16 (b) (187B)16 (c) (F878)16 (d) (987B)16

P⋅R +Q (c) P ⋅ Q + R (d) (GATE 2008: 2 Marks) 63. (1217)8 is equivalent to (a) (1217)16 (c) (2297)10

(b) (028F)16 (d) (0B17)16 (GATE 2009: 1 Mark)

(GATE 2010: 1 Mark) 69. The Boolean expression for the output f of the multiplexer shown below is

R R

64. 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 (b) 3 (c) 4 (d) 5 (GATE 2009: 1 Mark) 65. The binary operation

Ch wise GATE_CSIT_CH02_Digital Logic.indd 78

is defined as follows

P

Q

P

Q

T

T

T

T

F

T

F

T

F

F

F

T

f R R

P

Q

P⊕Q⊕R (a) P ⊕ Q ⊕ R (b) (c) P ⊕ Q ⊕ R (d) P+Q+R (GATE 2010: 1 Mark) 70. What is the Boolean expression for the output f of the combinational logic circuit of NOR gates given below?

11/13/2018 9:43:13 AM

Chapter 2  •  Digital Logic

79

( P + Q ⋅ R) (a) ( P ⋅ Q + R ) (b)

P Q

(c) ( P ⋅ Q + R) (d) ( P ⋅ Q + R) (GATE 2011: 1 Mark)

Q R f P R

74. The minimum number of D flip–flops needed to design a Mod-258 counter is (a) 9 (b) 8 (c) 512 (d) 258 (GATE 2011: 1 Mark)

Q R (a) Q + R (b) P+Q

Common Data Questions 75 and 76: Consider the following circuit involving three D-type flip–flops used in a certain type of counter configuration.

(c) P + R (d) P+Q+R (GATE 2010: 2 Marks) 71. In the sequential circuit shown below, if the initial value of the output Q1Q0 is 00, what are the next four values of Q1Q0?

P D

Q

clock Q 1

T

Q

T

Q

Clock D

Q

Q

clock Q0

Q

Q1

(a) 11,10,01,00 (b) 10,11,01,00 (c) 10,00,01,11 (d) 11,10,00,01

R D (GATE 2010: 2 Marks)

Q

clock Q

72. Which one of the following circuits is NOT equivalent to a 2-input XNOR (exclusive NOR) gate? (a)

(b)

(c)

(d)

75. If at 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 (b) 001 (c) 010 (d) 011 (GATE 2011: 2 Marks)

  

(GATE 2011: 1 Mark) 73. The simplified SOP (Sum-of-Product) form of the Boolean expression ( P + Q + R ) ⋅ ( P + Q + R ) ⋅ ( P + Q + R ) is

Ch wise GATE_CSIT_CH02_Digital Logic.indd 79

76. If all the flip–flops were reset to 0 at power on, what is the total number of distinct outputs (states) represented by PQR generated by the counter? (a) 3 (b) 4 (c) 5 (d) 6 (GATE 2011: 2 Marks)

11/13/2018 9:43:15 AM

80

GATE CS AND IT Chapter-wise Solved Papers

77. The truth table

Inputs

Outputs

X

Y

f (X,Y )

D0

D1

D2

D3

X0

X1

V

0

0

0

0

0

0

0

×

×

0

0

1

0

1

0

0

0

0

0

1

1

0

1

1

1

1

×

1

0

0

0

1

1

×

×

1

0

1

0

1

×

×

×

1

1

1

1

represents the Boolean function (a) X (b) X+Y (c) X ⊕ Y (d) Y

What function does the truth table represent? (a) Priority encoder (b) Decoder (c) Multiplexer (d) Demultiplexer

(GATE 2012: 1 Mark) 78. The decimal value 0.5 in IEEE single-precision floatingpoint representation has (a) Fraction bits of 000…000 and exponent value of 0 (b)  Fraction bits of 000…000 and exponent value of −1 (c) Fraction bits of 100…000 and exponent value of 0 (d) No exact representation (GATE 2012: 1 Mark)

(GATE 2013: 1 Mark) 82. Which one of the following expressions does NOT represent exclusive NOR of x and y? (a) xy + x′y′ (b) x ⊕ y′ (c) x′ ⊕ y (d) x′ ⊕ y′ (GATE 2013: 1 Mark)

ab cd 00

00

01

11

10

1

×

×

1

83. A RAM chip has a capacity of 1024 words of 8 bits each (1K × 8). The number of 2 × 4 decoders with enable line needed to construct a 16K × 16 RAM from 1K × 8 RAM is (a) 4 (b) 5 (c) 6 (d) 7

01

×

1

(GATE 2013: 2 Marks)

79. What is the minimal form of the Karnaugh map shown below? Assume that × denotes a don’t care term.

11 10

1

84. Consider the following Boolean expression for F: ×

(a) b d (b) b d + bc (c) b d + abcd

The minimal sum-of-products form of F is (a) PQ + QR + QS (b) P + Q + R + S (c) P + Q + R + S

(d) b d + bc + cd (GATE 2012: 2 Marks) 80. The smallest integer that can be represented by an 8-bit number in 2’s complement form is (a) −256 (b) −128 (c) −127 (d) 0 (GATE 2013: 1 Mark) 81. In the following truth table, V = 1 if and only if the input is valid.

Ch wise GATE_CSIT_CH02_Digital Logic.indd 80

F ( P , Q, R, S ) = PQ + PQR + PQRS

(d) PR + P RS + P (GATE 2014: 1 Mark) 85. The base (or radix) of the number system such that the . following equation holds is (GATE 2014: 1 Mark) 86. The dual of a Boolean function F ( x1 , x2 , … xn , +, ) written as F D, is the same expression as that of F with + and ⋅ swapped. F is said to be self-dual if F = F D.

11/13/2018 9:43:16 AM

Chapter 2  •  Digital Logic

The number of self-dual functions with n Boolean ­variables  is (a) 2n (b) 2n−1 n−1 2n (c) 2 (d) 22 (GATE 2014: 1 Mark) 87. Let k = 2n. A circuit is built by giving the output of an n-bit binary counter as input to an n-to-2n 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.

Which one of the following digital logic blocks is the most suitable for implementing this function? (a) Full adder (b) Priority encoder (c) Multiplexor (d) Flip–flop (GATE 2014: 1 Mark)

91. Consider the 4-to-1 multiplexer with two lines S1 and S0 given below.

0 1 R R

(GATE 2014: 1 Mark) 88. Consider the equation (123)5 = (x8)y with x and y as unknown. The number of possible solutions is . (GATE 2014: 1 Mark)





F(P, Q, R, S) = ∑ 0, 2, 5, 7, 8, 10, 13, 15

The minterms 2, 7, 8 and 13 are do not care terms. The minimal sum-of-products form for F is

F

The minimal sum-of-products form of the Boolean expression for the output F of the multiplexer is (a) PQ + QR + PQR (b) PQ + PQR + PQR + PQR

(a) Q S + Q S

(c) PQR + PQR + QR + PQR

(b) Q S + QS

(d) PQR

(c) Q RS + Q RS + Q R S + QRS

(GATE 2014: 2 Marks)

(d) P QS + P Q S + PQ S + PQ S

92. 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 biased exponent and 23 bits for mantissa. A float type variable X is assigned the decimal value of −14.25. The representation of X in hexadecimal notation is (a) C1640000H (b) 416C0000H (c) 41640000H (d) C16C0000H

(GATE 2014: 1 Mark) 90. 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.



0 4 - to - 1 1 Multiplexer 2 3 S S 1 0

P Q

89. Consider the following minterm expression for F.

81

f (x, y, a, b) { if (x is 1) y = a; else y = b; }

(GATE 2014: 2 Marks)

93.

J

Q2

C

Q1

Q2

J

Q0

K

Q0

C

C K

Ch wise GATE_CSIT_CH02_Digital Logic.indd 81

J

K

Q1

11/13/2018 9:43:18 AM

82

GATE CS AND IT Chapter-wise Solved Papers



The given synchronous sequential circuit built using JK flip–flops is initialized with Q2Q1Q0 = 000. The state sequence for this circuit for the next 3 clock cycles is (a) 001, 010, 011 (b) 111, 110, 101 (c) 100, 110, 111 (d) 100, 011, 001 (GATE 2014: 2 Marks)

94. Let ⊕ denote the Exclusive OR (XOR) operation. Let ‘1’ and ‘0’ denote the binary constants. Consider the following Boolean expression for F over two variables P and Q. F(P,Q) = ((1 ⊕ P) ⊕ (P ⊕ Q)) ⊕ ((P ⊕ Q) ⊕ (Q ⊕ 0)) The equivalent expression for F is (a) P + Q (b) P+Q (c) P ⊕ Q (d) P⊕Q (GATE 2014: 2 Marks) 95. Consider a 4-bit Johnson counter with an initial value of 0000. The counting sequence of this ­counter is (a) 0, 1, 3, 7, 15, 14, 12, 8, 0 (b) 0, 1, 3, 5, 7, 9, 11, 13, 15, 0 (c) 0, 2, 4, 6, 8, 10, 12, 14, 0 (d) 0, 8, 12, 14, 15, 7, 3, 1, 0 (GATE 2015: 1 Mark) 96. The minimum number of JK flip–flops required to construct a synchronous counter with the count sequence (0, 0, 1, 1, 2, 2, 3, 3, 0, 0, …….) is . (GATE 2015: 1 Mark) 97.

Let # be a binary operator defined as X # Y = X ′+Y ′ where X and Y are Boolean variables. Consider the following two statements S1: (P # Q) # R = P # (Q # R) S2: Q # R = R # Q Which of the following is/are true for the Boolean variables P, Q and R? (a) Only S1 is true (b) Only S2 is true (c) Both S1 and S2 are true (d) Neither S1 nor S2 are true (GATE 2015: 1 Mark)

98. The binary operator ≠ is defined by the following truth table.

Ch wise GATE_CSIT_CH02_Digital Logic.indd 82



Which one of the following is true about the binary operator ≠? (a) Both commutative and associative (b) Commutative but not associative (c) Not commutative but associative (d) Neither commutative nor associative (GATE 2015: 2 Marks)

99. A positive edge-triggered D flip–flop is connected to a positive edge-triggered JK flip–flop as follows. The Q output of the D flip–flop is connected to both the J and K inputs of the JK flip–flop, while the Q output of the JK flip–flop is connected to the input of the D flip–flop is connected to both the J and K inputs of the JK flip– flop, while the Q output of the JK flip–flop is connected to the input of the D flip–flop. Initially, the output of the D flip–flop is set to logic one and the output of the JK flip–flop is cleared. Which one of the following is the bit sequence (including the initial state) generated at the Q output of the JK flip–flop when the flip–flops are connected to a free-running common clock? Assume that J = K = 1 is the toggle mode and J = K = 0 is the state-holding mode of the JK flip–flop. Both the flip– flops have non-zero propagation delays. (a) 0110110….. (b) 0100100…. (c) 011101110…. (d) 011001100… (GATE 2015: 2 Marks) 100. The number of min-terms after minimizing the following Boolean expression is .

[D′ + AB  ′ + A′C + AC  ′D + A′C  ′D]′ (GATE 2015: 2 Marks)

101. A half adder is implemented with XOR and AND gates. A full adder is implemented with two half adders and one OR gate. The propagation delay of an XOR gate is twice that of an AND/OR gate. The propagation delay of an AND/OR gate is 1.2 microseconds. A 4-bit ripple-carry binary adder is implemented by using four full adders. The total propagation time of this 4-bit binary . adder in microseconds is (GATE 2015: 2 Marks) 102. Given the function F = P′ + QR, where F is a function in three Boolean variables P, Q and R and P′ = !P, consider the following statements.

p

q

p≠q

0

0

0

0

1

1

1

0

1



1

1

0



(S1) F = ∑ (4, 5, 6) (S2) F = ∑ (0, 1, 2, 3, 7) (S3) F = ∏ (4, 5, 6) (S4) F = ∏ (0, 1, 2, 3, 7)

Which of the following is true?

11/13/2018 9:43:19 AM

83

Chapter 2  •  Digital Logic

(a) (S1)−False, (S2)−True, (S3)−True, (S4)−False (b) (S1)−True, (S2)−False, (S3)−False, (S4)−True (c) (S1)−False, (S2)−False (S3)−True, (S4)−True (d) (S1)−True, (S2)−True, (S3)−False, (S4)−False (GATE 2015: 2 Marks) 103. The total number of prime implicants of the f­unction . f (w, x, y, z) = ∑(0, 2, 4, 5, 6, 10) is (GATE 2015: 2 Marks) 104. Consider the Boolean operator # with the following properties: x#0 = x, x # 1 = x , x#x = 0 and x # 1 = 1. Then, x#y is equivalent to (a) xy + xy (b) xy + x y (c) xy + xy (d) xy + x y (GATE 2016: 1 Mark) 105. The 16-bit 2’s complement representation of an integer is 1111 1111 1111 0101; its decimal representation is . (GATE 2016: 1 Mark) 106. We want to design a synchronous counter that counts the sequence 0-1-0-2-0-3 and then repeats. The minimum number of JK flip–flops required to implement this counter is . (GATE 2016: 1 Mark) 107. Consider an eight-bit ripple-carry adder for computing the sum of A and B, where A and B are integers represented in 2’s complement form. If the decimal value of A is one, the decimal value of B that leads to the longest latency for the sum to stabilize is _____. (GATE 2016: 1 Mark) 108. Let, x1 ⊕ x2 ⊕ x3 ⊕ x4 = 0 where x1, x2, x3, x4 are Boolean variables, and ⊕ is the XOR operator. Which one of the following must always be TRUE? (a) x1 x2 x3 x4 = 0 (b) x1 x3 + x2 = 0 (c) x1 ⊕ x3 = x2 ⊕ x4 (d) x1 + x2 + x3 + x4 = 0 (GATE 2016: 1 Mark) 109. Let X be the number of distinct 16-bit integers in 2’s complement representation. Let Y be the number of distinct 16-bit integers in sign magnitude representation. Then X − Y is _____. (GATE 2016: 1 Mark) 110. Consider the two cascaded 2-to-1 multiplexers as shown in the figure.

Ch wise GATE_CSIT_CH02_Digital Logic.indd 83

R 0 1

0 1

2—to—1 MUX

2—to—1 MUX

X

The minimal sum of products form of the output X is (a) PQ + PQR (b) PQ + QR (c) PQ + PQR (d) QR + PQR (GATE 2016: 2 Marks) 111. Consider a carry look ahead adder for adding two n-bit integers, built using gates of fan-in at most two. The time to perform addition using this adder is (a) Θ(1) (b) Θ(log(n)) Θ(n) (c) Θ( n ) (d) (GATE 2016: 2 Marks) 112. The n-bit fixed-point representation of an unsigned real number X uses f bits for the fraction part. Let i = n - f. The range of decimal values for X in this representation is (a) 2- f to 2i (b) 2- f to (2i - 2- f) (c) 0 to 2i (d) 0 to (2i - 2- f) (GATE 2017: 1 Mark) 113. When two 8-bit numbers A7 … A0 and B7 … B0 in 2’s complement representation (with A0 and B0 as the least significant bits) are added using a ripple-carry adder, the sum bits obtained are S7 … S0 and the carry bits are C7 … C0. An overflow is said to have occurred if (a) the carry bit C7 is 1 (b) all the carry bits (C7 … C0) are 1 (c) ( A7 ⋅ B 7 ⋅ S7 + A7 ⋅ B7 ⋅ S7 ) is 1 (d) ( A0 ⋅ B0 ⋅ S0 + A0 ⋅ B0 ⋅ S0 ) is 1 (GATE 2017: 1 Mark) 114. Consider the Karnaugh map given below, where × represents “don’t care” and blank represents 0. ba dc 00

00

01

1

11

1

10

01

11

×

×

10

× 1 ×

×

11/13/2018 9:43:20 AM

84

GATE CS AND IT Chapter-wise Solved Papers



Assume for all inputs (a, b, c, d), the respective complements ( a , b , c , d ) are also available. The above logic is implemented using 2-input NOR gates only. The minimum number of gates required is ________. (GATE 2017: 1 Mark)

115. The representation of the value of a 16-bit unsigned integer X in hexadecimal number system is BCA9. The representation of the value of X in octal number system is (a) 571244 (b) 736251 (c) 571247 (d) 136251 (GATE 2017: 1 Mark) 116. Given the following binary number is 32-bit (single precision) IEEE-754 format:

(c) ( wx ( y + xz ) + w x ) y = xy (d) (w + y) (wxy + wyz) = wxy + wyz (GATE 2017: 2 Marks) 119. Given f (w, x, y, z) = Σm(0, 1, 2, 3, 7, 8, 10) + Σd(5, 6, 11, 15), where d represents the don’t-care condition in Karnaugh maps. Which of the following is a minimum product-of-sums (POS) form of f (w, x, y, z)? (a)

f = ( w + z )( x + z )

(b)

f = ( w + z )( x + z )

(c)

f = ( w + z )( x + z )

(d)

f = ( w + z )( x + z )

(GATE 2017: 2 Marks) 120. The next state table of a 2-bit saturating up-­counter is given below.

001111100110110100000000000000000

The decimal value closest to this floating point number is (a) 1.45 × 101 (b) 1.45 × 10−1 −1 (c) 2.27 × 10 (d) 2.27 × 101 (GATE 2017: 1 Mark)

117. Consider a combination of T and D flip–flops connected as shown below. The output of the D flip–flop is connected to the input of the T flip–flop and the output of the T flip–flop is connected to the input of the D flip–flop.



Q1

Q0

Q1+

Q0+

0

0

0

1

0

1

1

0

1

0

1

1

1

1

1

1

The counter is built as a synchronous sequential circuit using T flip–flops. The expressions for T1 and T0 are (a) T1 = Q1Q0, T0 = Q1Q0 (b) T1 = Q1Q0 , T0 = Q1 + Q0 (c) T1 = Q1 + Q0, T0 = Q1 + Q0 (d) T1 = Q1Q0 , T0 = Q1 + Q0

Q1

Q0

T Flip—Flop

D Flip—Flop

Clock



Initially, both Q0 and Q1 are set to 1 (before the 1st clock cycle). The outputs (a)  Q1Q0 after the 3rd cycle are 11 and after the 4th cycle are 00, respectively. (b)  Q1Q0 after the 3rd cycle are 11 and after the 4th cycle are 01, respectively. (c)  Q1Q0 after the 3rd cycle are 00 and after the 4th cycle are 11, respectively. (d)  Q1Q0 after the 3rd cycle are 01 and after the 4th cycle are 01, respectively.

(GATE 2017: 2 Marks) 121. Let ⊕ and  denote the Exclusive OR and Exclusive NOR operations, respectively. Which one of the following is NOT CORRECT? (a) P ⊕ Q = P  Q (b) P ⊕ Q = P  Q (c) P ⊕ Q = P ⊕ Q (d)

(P ⊕ P ) ⊕ Q = (P  P )  Q (GATE 2018: 1 Mark)

122. Consider the sequential circuit shown in the figure, where both flip–flops used are positive edge-triggered D flip–flops.

(GATE 2017: 2 Marks) 118. If w, x, y, z are Boolean variables, then which one of the following is INCORRECT? (a) wx + w(x + y) + x(x + y) = x + wy (b) wx ( y + z ) + wx = w + x + yz

Ch wise GATE_CSIT_CH02_Digital Logic.indd 84

in

out D

Q

D

Q

Clock

11/13/2018 9:43:23 AM

Chapter 2  •  Digital Logic



The number of states in the state transition diagram of this circuit that have a transition back to the same state on some value of “in” is .

(a) None of (i), (ii), (iii), (iv) cab be exactly represented (b) Only (ii) cannot be exactly represented (c) Only (iii) and (iv) cannot be exactly represented (d) Only (i) and (ii) cannot be exactly represented

(GATE 2018: 1 Mark) 123. Consider the unsigned 8-bit fixed point binary number representation below, b7 b6 b5 b4 b3 . b2 b1 b0



where the position of the binary point is between b3 and b2. Assume b7 is the most significant bit. Some of the decimal numbers listed below cannot be represented exactly in the above representation: (i) 31.500 (ii) 0.875 (iii) 12.100 (iv) 3.001 Which one of the following statements is true?

85

(GATE 2018: 2 Marks) 124. Consider the minterm list from of a Boolean function F given below. F(P, Q, R, S) = Σm(0, 2, 5, 7, 9, 11) + d(3, 8, 10, 12, 14) Here, m denotes a minterm and d denotes a don’t care term. The number of essential prime implicants of the function F is .



(GATE 2018: 2 Marks)

Answer Key   1. (c)

2. (c)

 3. (d)

 4. (a)

 5. (b)

 6. (a)

 7. (c)

 8. (c)

 9. (c)

10. (b)

11. (b)

12. (b)

13. (d)

14. (d)

15. (b)

16. (a)

17. (a)

18. (c)

19. (a)

20. (d)

21. (c)

22. (c)

23. (c)

24. (c)

25. (d)

26. (d)

27. (d)

28. (a)

29. (a)

30. (b)

31. (a)

32. (d)

33. (b)

34. (a)

35. (a)

36. (a)

37. (a)

38. (a)

39. (a)

40. (d)

41. (d)

42. (d)

43. (c)

44. (a)

45. (d)

46. (c)

47. (a)

48. (c)

49. (c)

50. (c)

51. (c)

52. (b)

53. (d)

54. (d)

55. (c)

56. (b)

57. (c)

58. (a)

59. (d)

60. (d)

61. (c)

62. (a)

63. (b)

64. (b)

65. (b)

66. (c)

67. (a)

68. (a)

69. (b)

70. (a)

71. (a)

72. (d)

73. (b)

74. (a)

75. (d)

76. (b)

77. (a)

78. (b)

79. (b)

80. (b)

81. (a)

82. (d)

83. (b)

84. (a)

85. (5)

86. (d)

87. (c)

88. (3)

89. (b)

90. (c)

91. (a)

92. (a)

93. (c)

94. (d)

95. (d)

96. (2)

97. (b)

98. (a)

99. (a)

100. (1)

101. (19.2) 102. (a)

103. (3)

104. (a)

105. (–11)

106. (3)

107. (–1) 108. (c)

109. (1)

110. (d)

111. (b)

112. (d)

113. (c)

114. (1)

115. (d)

116. (c)

117. (b)

119. (a)

120. (b)

121. (d)

122. (2)

123. (c)

124. (3)

118. (c)

Answers with Explanation 1.

Topic: Boolean Algebra



(c)  In 2’s complement negative numbers are represented by doing 1’s complement and then adding 1 to the result. Positive numbers are represented as their binary representation. So, 2’s complement or binary representation of 43 is 00101011.

Ch wise GATE_CSIT_CH02_Digital Logic.indd 85

2.

Topic: Minimization (c)  Given that, x + y + z = 1 xy = 0

(1) (2)

xz + w = 1

(3)



xy + z w = 0 (4)

11/13/2018 9:43:23 AM

86

GATE CS AND IT Chapter-wise Solved Papers

Options

x

y

z

w

x+y+z

xy

xz + w

xy + z w

(a)

0

1

0

0

1

0

0

1

(b)

1

1

0

1

1

1

1

1

(c)

1

0

1

1

1

0

1

0

(d)

1

0

0

0

1

0

0

1

Therefore, x, y, z, w = 1 0 1 1 is the solution. 3.

Given, initial state P = 0 and Q = 1.

Topic: Minimization (d)  We have

For J = 1 and K = 1, output of first flip–flop is 1.

00

01

11

10

For P = 0 as input in D flip–flop, output of second flip– flop is 0.

00

0

×

0

0

01

0

×

1

1

So, after the clock cycles the output state P, Q is 1, 0 respectively.

11

1

1

1

1

10

0

×

0

0

xy

wz

5.

Using sum-of-products (SOP) the map can be represented by function xy + yw = (w + x) y and using product-of-sums (POS) the map can be represented by function (w + x) (w + y) ( x + y)

B = −2.0 × 1030 C = 1.0 and numbers are represented using 32 bits. So, A + C should make 31st digit 1 which is outside precision level of A.

Therefore, all the given options implement the given Karnaugh map. 4.

Then, Y = A + C = A

Topic: Sequential Circuits (a)  Truth table of JK flip–flop and D flip–flop are J

K

Q

0

0

Q0 (no change)

0

1

1

1

0

0

1

1

Q0 (toggles)

D

Q

0

0

1

1

J

Q1

1

K

also

Y + B returns 0.0

and

X + C returns 1.0

Therefore, X = 1.0 and Y = 0.0 6.

Topic: Minimization (a)  The minimal Sum-Of-Products of the given ­Karnaugh map is represented as yz

We have the following arrangement of master-slave flip– flops, P

Topic: Computer Arithmetic (Fixed and Floating Point) (b)  Given, A = 2.0 × 1030

D

wx

00

01

11

10

00

0

×

0

×

01

×

1

×

1

11

0

×

1

0

10

0

1

×

0

Thus, the given Karnaugh map represents xy + yz.

Clock

Ch wise GATE_CSIT_CH02_Digital Logic.indd 86

11/13/2018 9:43:25 AM

87

Chapter 2  •  Digital Logic

7.

Topic: Sequential Circuits (c)  Given that,

10. Topic: Sequential Circuits (b)  Given that, Initial state: Q0 = 1, Q1 = Q2 = 0 D1

D0

X

Clock

Q0

Q1

Y

Clock

State of circuit: 4Q2 + 2Q1 + Q0 CLK

Q0

Q1

Q2

4Q2 + 2Q1 + Q0

Initial value

1

0

0

1

1

0

1

0

2

2

1

0

1

5

3

1

1

0

3

4

1

1

1

7

5

0

1

1

6

6

0

0

1

4

Initial condition Q0 = Q1 = 0 Setup times = 20 nanosecond Hold times = 0 C X

Therefore, correct state sequence is 1, 2, 5, 3, 7, 6, 4. Y During first clock cycle nothing will change since input does not come before rising edge of the clock cycle. Q0 = 0 on rising edge of the next clock cycle. So, D1 = 1 for only one clock cycle. Therefore, the correct output Y is represented by option (c). 8.

Topic: Number Representations (c)  We have decimal number (−539)10 Binary representation of 1 this number

010 0001

1011

1’s complement of this 1 number is

101 1110

0100

2’s complement of this 1 number is

101 1110

0101

Now, hexadecimal representation of this number is DE5. 9.

Topic: Sequential Circuits (c)  The given function is f = ( ac + bc) So, f = ( a and x2 ) or (b and x2 ) And, f = ( g and x2 ) or ( x1 and x2 ) Now, g = ( a and x1 ) or (b and x1 ) = (1 and x1 ) or (0 and x1 ) = x1 So, f = ( x1 and x2 ) or ( x1 and x2 ) Therefore, f = x1 x2 + x1 x2

Ch wise GATE_CSIT_CH02_Digital Logic.indd 87

11. Topic: Minimization (b)  According to the question, yz

wx

00

01

11

10

00

0

1

1

0

01

×

0

0

1

11

×

0

0

1

10

0

1

1

×

Thus, minimum sum-of-product expression is xz + zx 12. Topic: Number Representations (b)  Given decimal value is 0.25 Binary equivalent of 0.25 is given by 0.25 × 2 = 0.50

0

0.50 × 2 = 1.00 1 Therefore, binary equivalent of 0.25 is 0.01 13. Topic: Number Representations (d)  Given decimal value –15 Binary representation of 15 is 1111 So, binary representation of –15 is 11111 Now, 1’s complement of –15 is 10000 Therefore, 2’s complement of –15 is 10001

11/13/2018 9:43:26 AM

88

GATE CS AND IT Chapter-wise Solved Papers

14. Topic: Computer Arithmetic (Fixed and Floating Point) (d)  Sign extension is operation of increasing the number of bits of a binary number while presenting the number’s sign and value. Thus, sign extension is a step in converting a signed integer from one size to another.

18. Topic: Minimization (c)  Given that, f ( A, B) = A + B Now, f ( f ( x + y, y ), z ) is

15. Topic: Number Representations (b)  In 2’s complement addition, overflow cannot occur when a positive value is added to a negative number.

f ( x + y, y ) = ( x + y ) + y = x y + y = ( x + y) × ( y + y) = ( x + y) × 1 f ( x + y, y ) = x + y

16. Topic: Minimization (a)  We have

f ( f ( x + y, y ), z ) = f ( x + y, z ) = ( x + y ) + z ) = xy + z 19. Topic: Number Representations (a)

f1(x, y, z) f2(x, y, z)

f(x, y, z) 2’s Complement

f3(x, y, z) = ? Given that, f1 ( x, y, z ) = ∑ (0,1, 3, 5)

Decimal Value

11100111

00011001

25

11100100

00011100

28

11010111

00101001

41

11011011

00100101

37

11111011 is 5 in decimal. Only 25 is divisible by 5.

f 2 ( x, y, z ) = ∑ (6, 7)

20. Topic: Sequential Circuits

f ( x, y, z ) = ∑ (1, 4, 5)



f = (( f1 ⋅ f 2 ) ⋅ f 3 )

Here,

Binary Number

Using Boolean laws f = (( f1 + f 2 ) ⋅ f 3 ) = ( f1 + f 2 ) + f 3 = f1 ⋅ f 2 + f 3 Now f1 ⋅ f 2 = 0 since there is no common term in f1 and f2. Therefore f 3 = ∑ (1, 4, 5)

(d)  Delay = 1 + 2 +  + n =

21. Topic: Computer Arithmetic (Fixed and Floating Point) (c)  Largest positive number, m = 11111111 exponent, e = 111110 Second largest positive number = 11111110 exponent, e = 111110 Difference = 231 (2 − 2−9 − 2 + 2−8) = 222 22. Topic: Sequential Circuits (c)  Number of transition states are 7.

17. Topic: Combinational Circuits (a)  We have f ( x, y, z ) = ( A1 A0 I 0 + A1 A0 I1 + A1 A0 I 2 + A1 A0 I 3 ) × I 3 f ( x, y, z ) = ( xyz + xyz + yzy + zy ) z

23. Topic: Minimization (c)

f ( x, y, z ) = [ xyz + xyz + zy ( y +1)]z f ( x, y, z ) = ( xyz + xyz + zy × 1) z

zw

00

01

11

10

00

×

1

0

1

01

0

1

×

0

( zz = 0)

11

1

×

×

0

( 0 xy = 0)

10

×

0

0

×

( y + 1 = 1)

f ( x, y, z ) = [ xyz + xyz + zy ]z = ( xy( z + z ) + zy ) z f ( x, y, z ) = ( xy × 1 + zy ) z

( z + z = 1)

f ( x, y, z ) = ( xy + zy ) z = xyz + zzy = xyz + 0 xy f ( x, y, z ) = xyz + 0 f ( x, y, z ) = xyz

Ch wise GATE_CSIT_CH02_Digital Logic.indd 88

n( n + 1) = Θ( n 2 ) 2

xy

11/13/2018 9:43:29 AM

89

Chapter 2  •  Digital Logic

SOP: wy + w′y′ + z′wx ′ + xyz′ Literal count: 10 POS: (y′ + z′)(w′ + z′)(z′ + y)(x + z + w) Literal count: 9 24. Topic: Sequential Circuits (c)  Total number of transitions is 3. 1: 0 to 0 2: 0 to 1 3: 1 to 1

b

c

d

Output

0

1

0

1

1

1

0

0

0

1

1

0

1

1

1

Now using K-map, the expression becomes a + bd + bc→a + b(d + c). Hence, three gates will be required. 31. Topic: Boolean Algebra (a)  f (a, b, c) = a′c + ac′ + b′c

25. Topic: Minimization (d) x′y′ + xy + x′y = x′(y′ + y) + xy(as y ′ + y = 1)

= a′(b + b′)c + a(b + b′)c′ + (a + a′)b′c

= x′ + xy(as x + x′y = x + y)

= a′bc + a′b′c + abc′ + ab′c′ + a′b′c

= x′ + y

Using K-map:

26. Topic: Sequential Circuits (d)  If both S and R are 0, using SR latch with NAND gate output state will be invalid state. 27. Topic: Number Representations (d)  By doing hit and trial with the options, we arrive at If x = 8,   (73)8 = 7 × 81 + 3 × 80 = 59 If y = 11,    (54)11 = 5 × 111 + 4 × 110 = 59 28. Topic: Computer Arithmetic (Fixed and Floating Point) (a)  (113 + −111) + 7.51 = 9.51  

a

 113 + (−111 + 7.51) = 10.0

29. Topic: Sequential Circuits (a)  Connect R to X, 1 to Y and T to Z.

ab 00

01

0 1

1

11

10

1

1

1

Here ca′ and c′a are essential prime implicants, we ­cannot remove them. 32. Topic: Sequential Circuits (d)  Sequence 0 - 2 - 3 - 1 - 0 means 00 - 11 - 01 - 00 If x = Q1 ⊕ Q2 , then the given output will be produced. 33. Topic: Sequential Circuits (b)  Equations for carry look-ahead adder are as follows:

30. Topic: Combinational Circuits (b)

C1 = G0 + P0 ⋅ C0

a

b

c

d

Output

0

0

0

0

0

0

0

0

1

0

0

0

1

0

0

0

0

0

1

0

0

1

0

0

0

0

1

1

1

1

0

1

1

0

1

Ch wise GATE_CSIT_CH02_Digital Logic.indd 89

c

C2 = G1 + P1 ⋅ C1 C3 = G2 + P2 ⋅ C2 C4 = G3 + P3 ⋅ C3 The total number of gate delay will be 6. 34. Topic: Number Representations (a) A = 1111 1010 = 0000 0110 = −6 B = 0000 1010 = 10 A × B = −60 −60 = 11000100

11/13/2018 9:43:29 AM

90

GATE CS AND IT Chapter-wise Solved Papers

35. Topic: Combinational Circuits (a)

0

3D

42. Topic: Minimization

= Y ′ + Z′

(d)  Using normalized form

So, f is independent of X.

1.11101 × 210

36. Topic: Number Representations (a)  Negative numbers are one more than positive number. So, the range of 2’s complement is −2n−1 to (2n−1 − 1).

64 + 10 = 74 0

100 1010



37. Topic: Number Representations (a) (657)8 = (110 101 111)8

11101000

4A E8

43. Topic: Sequential Circuits (c)  Left flip–flop is activated, the clock for right will be 0. There will be delay of 180°.

(0001 1010 1111)16 = (1AF)16 38. Topic: Minimization (a) 00

0011 1101

4D

f = XY ′ + (YZ ) ′

AB CD

100 1101

44. Topic: Minimization (a)

01

11

f1 = zx + zy

10

f = y ( zx + zy ) + yx 00

= yzx + yzy + yx = yx + yzx + zy

1

01

1

11

1

= yx + y ( z + zx ) = yx + y ( z + x )

1

= yx + yz + yx Now use K-map, we have

10

1

yz

1

x f = BC ′D ′ + A′C ′D + AB ′D

00

01

0

11

10

1

1

1

39. Topic: Sequential Circuits

(a)  The correct output sequence on Y is A0 A1 A1′ A3 A4 .

40. Topic: Sequential Circuits (d)

1

1

Hence, xy + yz + xz is the correct option.

D0

D1

Q0

Q1

1

1

1

1

0

1

0

1

1

0

1

0

0

0

0

0

Therefore, the state transition sequence is 00-11-01-10 41. Topic: Number Representations (d)     0.239 × 213 = 0.00111101 × 213 64 + 13 = 77

Ch wise GATE_CSIT_CH02_Digital Logic.indd 90

1

45. Topic: Computer Arithmetic (Fixed and Floating Point) (d)  Option (d) generates carry c always. 46. Topic: Sequential Circuits (c) Clock

Input

q2

q1

q0

0

1

0

0

1

1

0

0

1

0

2

0

1

0

0

11/13/2018 9:43:30 AM

Chapter 2  •  Digital Logic

Clock

Input

q2

q1

q0

wx yz

3

1

0

1

1

00

4

1

1

1

1

5

0

1

0

0

01

1

1

6

0

0

1

0

11

1

1

7

0

1

0

0

10

8

0

0

1

0

00

01

11

10

00 01 11

1

10

01

11

1

10

1

1

1

Quadruple is formed, indicating the function is independent of two variables.

47. Topic: Minimization (a) yz wx

00

91

53. Topic: Minimization (d) wx yz

00

1

1

00

1

1

1

01

1

1

11 10

1

01

11

1

1

1

1

10

1

From the K-map, we have w′xz, wxy′, xy′z, xyz, wyz. 48. Topic: Computer Arithmetic (Fixed and Floating Point) (c)  The overflow will be identified cout and cn − 1 are XORed. 49. Topic: Computer Arithmetic (Fixed and Floating Point) (c)  (n + 1) mod 16 is a 5-bit number; range is from 0 to 31. g2(2,4,5,6,7,12,13,15) 50. Topic: Boolean Algebra (c)  Maximum Boolean functions with n elements can n

be  22 . 51. Topic: Combinational Circuits (c)  We need to construct 6 to 64 decoder so apply the following:



log 64 i =1

64 64 64 = + =9 8 64 8i

52. Topic: Minimization (b)  f (w, x, y, z) = ∑(1, 3, 4, 6, 9, 11, 12, 14) can be ­ represented in K-map as

Ch wise GATE_CSIT_CH02_Digital Logic.indd 91

Option (d) does not contain essential prime implicants. 54. Topic: Boolean Algebra (d)  P: Y * Z = YZ + Y′Z′ = Y(XY + X′Y′) + Y′(X′Y + XY′) = X So, P is valid. Q: Y = X * Z X * Z = XZ + X′Z′ = X(XY + X′Y′) + X′(X′Y + XY′) = Y So, Q is valid. R: X * Y * Z = 1 X * Y * Z = Z * Z = ZZ + Z′Z′ = 1 So, R is also valid. 55. Topic: Sequential Circuits (c)  Since only one inverter is allowed, so n −1 variable will be used for selection and one as input. 2n − 1 line to 1 line multiplexer will be required. 56. Topic: Sequential Circuits (b)  Two 1-bit adders are required, where each 1-bit adder required 5 AND and 2 OR gates. So, 10 AND gates and 4 OR gates are required.

11/13/2018 9:43:31 AM

92

GATE CS AND IT Chapter-wise Solved Papers

57. Topic: Combinational Circuits (c)  The counter will count if count = 1 and load = 0, the sequence will be 0, 1, 2, 3, 4. 58. Topic: Minimization (a) ab 00 01 cd 00 1 1

11

10 1

64. Topic: Boolean Algebra (b) (AB + C ) = (A + C)(B + C)  = ((A + C )′ + (B + C)′)′ Thus, it requires three NOR gates. 65. Topic: Boolean Algebra (b)  Try using different values of P and Q. For example, P = True and Q = False. 66. Topic: Combinational Circuits (c)  Number of chips required =

01

11

×

67. Topic: Boolean Algebra (a)

×

f ( P , Q, R) = PQ + QR ′ + PR ′

10 1

256 × 8 = 64 32 × 1

1

= PQ( R + R ′ ) + ( P + P ′ )QR ′ + P (Q + Q ′ ) R ′

×

= PQR + PQR ′ + P ′QR ′ + PQ ′R ′ = m7 + m6 + m2 + m4

So, b ⋅ d + a ⋅ d

68. Topic: Number Representations

59. Topic: Number Representations (d)  IEEE floating point standard represent number in normalized form. This is the smallest positive number, that is, +0. 60. Topic: Number Representations (d) (1 + 2r 2 + r 3 )1/ 2 = 1 + r

(a)  (F87B)16 = (1925)2 1925 × 8 = (15400)2 = 2’s complement of (15400)2 = (C3D8)16 69. Topic: Sequential Circuits (b) Input

Output

P

Q

⇒1 + 2r 2 + r 3 = (1 + r ) 2 = 1 + r 2 + 2r

0

0

R

P′Q′R

r 3 + r 2 − 2r = 0 ⇒r > 2

0

1

R′

P′QR′

1

0

R′

PQ′R′

1

1

R

PQR

61. Topic: Combinational Circuits (c)  To get f = ∑m(1, 6, 8, 15), f2 should set 6 and 8. 62. Topic: Boolean Algebra (a)  ( P + Q )( P ⋅ Q + P ⋅ R)( P ⋅ R + Q ) = ( P ⋅ Q + P ⋅ Q + P ⋅ Q ⋅ R + PR)( P ⋅ R + Q )

P′Q′R + P′QR′ + PQ′R′ + PQR = P ⊕ Q ⊕ R 70. Topic: Combinational Circuits (a)

= P ⋅Q + P ⋅Q + P ⋅Q⋅ R + P ⋅Q⋅ R = P ⋅Q

P+Q+Q+ R+ P+ R+Q+ R

(as 1 + R = 1)

63. Topic: Number Representations

= ( P + Q + Q + R ) ⋅ ( P + R + Q + R)

= ( PQ + QR)( P R + QR)

(b)     (1217)8 = (001 010 001 111)8

= PQP R + PQ Q R + QRP R + QRQR

   (0010 1000 1111) = (28F)16 = (028F)16

= PQR + PQR + PQR + QR = PQR + QR = QR( P + 1) = QR = Q + R

Ch wise GATE_CSIT_CH02_Digital Logic.indd 92

11/13/2018 9:43:32 AM

P+Q+Q+ R+ P+ R+Q+ R = ( P + Q + Q + R) ⋅ ( P + R + Q + R) = ( PQ + QR)( P R + QR) = PQP R + PQ Q R + QRP R + QRQR

93

Chapter 2  •  Digital Logic

= PQR + PQR + PQR + QR

77. Topic: Boolean Algebra (a)  From the given truth table, equation formed is

= PQR + QR = QR( P + 1) = QR = Q + R

XY  ′ + XY⇒X(Y  ′ + Y) ⇒ X

71. Topic: Sequential Circuits (a) Clock

Q1

Q0

1

0

0

2

1

1

3

1

0

4

0

1

5

0

0

78. Topic: Computer Arithmetic (Fixed and Floating Point) (b)  Binary representation of 0.5 is 0.1000, which can be written as 1.000 × 2−1 Here, exponent = −1 and fraction bits are 000…000. 79. Topic: Minimization (b)

73. Topic: Minimization (b) QR

00

01

11

10

0

0

1

1

1

1

0

0

0

0

P

×

1

72. Topic: Combinational Circuits (d)  Option (d) does not show XNOR gate functionality.

×

1

×

1

1

×

From above grouping, the equation obtained is cb + d b

which implies ( P + R )( P + Q )



80. Topic: Computer Arithmetic (Fixed and Floating Point) (b)  Smallest integer for 2’s complement is −2n − 1

74. Topic: Sequential Circuits (a)  2n ≥ 258 = 9 D flip–flops

So here n = 8, −28 − 1 = −128 81. Topic: Sequential Circuits (a)  From the given truth table it is clear that it is 4:2 priority encoder.

75. Topic: Sequential Circuits (d) Clock D1 = R

D2 = (P + R)′

D3 = QR′

P

Q

R

82. Topic: Combinational Circuits

1

0

1

0

0

1

0

2

0

1

1

0

1

1

3

1

0

0

1

0

0

83. Topic: Sequential Circuits

4

0

0

0

0

0

0



After 010, value of PQR is 011. 76. Topic: Sequential Circuits (b)  Clock cycles can be seen from the table given in Question 75. The number of district o­ utputs is 4.

Ch wise GATE_CSIT_CH02_Digital Logic.indd 93

(d)  x′ ⊕ y′ = (x′y + y′x) = x ⊕ y, this r­epresents XOR. So, option (d) is not exclusive NOR.

(b)  Number of chips required =

16 × 16 = 16 × 2 1× 8

So, it requires 16 vertical and 2 horizontal chips. For this five 2 × 4 decoders are required.

11/13/2018 9:43:33 AM

94

GATE CS AND IT Chapter-wise Solved Papers

84. Topic: Boolean Algebra (a)    PQ + PQR + PQRS

89. Topic: Minimization (b)

PQ + PQ(R + RS) Applying property [A + BC = (A + B)(A + C)],

PQ 

we have

PQ

RS

RS

RS

RS

RS ×

1

PQ + PQ (R + R)(R + S) ⇒ PQ + P Q(R + S)

PQ

1

×

⇒ PQ + PQR + PQS

PQ

×

1

⇒ Q(P + P R) + PQS ⇒ Q(P + R) + PQS ⇒ QP + QR + PQS ⇒ Q(P + P )(P + S) + QR ⇒ PQ + QS + QR

×

PQ

1

QS + Q S 90. Topic: Combinational Circuits (c)      y = x′ b + xa

85. Topic: Number Representations (5)  (312/20)x = (13.1)x

b

3x 2 + x + 2 x 2 + 3x + 1 = ⇒ x 2 − 5 x = 0 ⇒ x = 0, 5 2x x Base of number system cannot be 0. So, answer is 5. 86. Topic: Boolean Algebra (d)  A function is called self-dual if it has equal number of maxterms and minterms. n Total function = 22 Number of mutual exclusive terms = 2n/2 Number of possible function by using minterms or maxterms taking any one at a time is (without mutual excun−1 sive terms) = 22 87. Topic: Sequential Circuits (c)  In case of a k-bit ring encounter, single output will be 1 and remaining will be zero at a time. 88. Topic: Computer Arithmetic (Fixed and Floating Point) (3)  Converting both sides of (123)5 = (x 8)y into decimal number system, we get 1 × 52 + 2 × 51 + 3 × 50 = x × y1 + 8 × y 0 25 + 10 + 3 = xy + 8 38 = xy + 8 ⇒ xy = 30 Factors of 30 are −1, 2, 3, 15, 30 If x = 1 then y = 30 If x = 2 then y = 15 If x = 3 then y = 10 So, we have three solutions to the given problem.

Ch wise GATE_CSIT_CH02_Digital Logic.indd 94

y

2:1 a

x 91. Topic: Minimization (a) PQ 0 + PQ1+ PQR + PQR PQ + PQR + PQR Q( P + P R) + PQR Q( P + P )( P + R) + PQR QP + QR + P QR 92. Topic: Computer Arithmetic (Fixed and Floating Point) (a) S

E

1 bit

M

8 bits

23 bits

(14.25)10 = (1110.01)2 Now, normalize the binary number 1.11001 × 23 E = e + Bias E = 3 + 127 = 130 Binary equivalent of 130 = (10000010)2 Therefore, S = 1 (Since negative number) M = (11001000…) E = 10000010 1100

0001

0110

0100

0000

….

C

1

6

4

0

000

11/13/2018 9:43:36 AM

Chapter 2  •  Digital Logic

95

93. Topic: Sequential Circuits (c) Present State

Next State

Q2

Q1

Q0

Q2(J = Q1′, K = Q0)

Q1(J = Q2, K = Q2′ )

Q0(J = Q1, K = Q0′)

0

0

0

1

0

0

1

0

0

1

1

0

1

1

0

1

1

1

94. Topic: Boolean Algebra

Q′ ⊕ P

(d)   ( P ′ ⊕ ( P ⊕ Q )) ⊕(( P ⊕ Q ) ⊕ Q )

( P ⊕ Q)′

( P ′ ⊕ ( PQ ′ + P ′Q )) ⊕ (( PQ ′ + P ′Q ) ⊕ Q )

95. Topic: Sequential Circuits (d)  This inversion of Q is feedback to input D of flip– flop A and this causes the counter to “count” in a unique way. Counting pattern is as follows

( P ′( PQ ′ + P ′Q ) + P ( PQ ′ + P ′Q )′ ) ⊕ (Q( PQ ′ + P ′Q ) ′ + Q ′( PQ ′ + P ′Q ))

4-bit Parallel output QB QC

QA

Q

D

Flip—Flop A

D

Q

D

Flip—Flop B

Q

Flip—Flop C

QD

D

Q

Flip—Flop D Q

CLK

CLR

Clock Pulse Number

Flip –Flop A

Flip –Flop B

Flip –Flop C

Flip –Flop D

Initial

0

0

0

0

1

1

0

0

0

2

1

1

0

0

3

1

1

1

0

4

1

1

1

1

5

0

1

1

1

6

0

0

1

1

7

0

0

0

1

Ch wise GATE_CSIT_CH02_Digital Logic.indd 95

11/13/2018 9:43:37 AM

96

GATE CS AND IT Chapter-wise Solved Papers

96. Topic: Sequential Circuits (2)  Number of distinct states = 4. Hence, minimum flip–flops required is 2.

100. Topic: Minimization (1)  F(A, B, C, D) = [D′ + AB  ′+ A′C + AC  ′D + A′C  ′D]′ CD

97. Topic: Boolean Algebra (b)        X#Y = X ′ + Y ′ S1: (P#Q)#R = P#(Q#R) LHS (P ′ + Q ′)′ + R ′ PQ + R ′ RHS

AB

P ′ + (Q ′ + R ′)′ P′ + QR

LHS ≠ RHS S1 is False. S2: Q#R = R#Q Q′ + R′ = R′ + Q′ S2 is True.

00

01

11

10

00

0

0

0

0

01

0

0

0

0

11

0

0

1

0

10

0

0

0

0

The number of min-terms = 1. 101. Topic: Sequential Circuits (19.2)  Total delay = 4 × 4.8 = 19.2 ms

98. Topic: Boolean Algebra (a)  Looking at the truth table, we analyze that this is the same as XOR operation. XOR is both commutative (i.e., x * y = y * x) and associative (i.e., a * (b * c) = (a * b) * c).

102. Topic: Boolean Algebra (a)  F = P′ + QR = P′(Q + Q′) (R + R′) + (P+P′)QR F = P′Q + P′Q′(R + R′) + PQR + P′QR F = P′QR + P′QR′ + P′Q′ R+ P′Q′R′+ PQR + P′QR

99. Topic: Sequential Circuits (a)

Q

D

P

00

01

11

10

0

1

1

1

1

1

0

0

1

0

Q1

J

FF1

F = ∑(0, 1, 2, 3, 7)

FF2

= ∏ (4, 5, 6) S2 and S3 are true.

K Clock

Q

Q1

0 (initial)

1

0

1

0

1

2

1

1

3

1

0

4

0

1

5

1

1

6

1

0

7

0

1

Ch wise GATE_CSIT_CH02_Digital Logic.indd 96

QR

103. Topic: Minimization (3) wx

yz

00

01

11

10

0

0

1

00

∗1

01

1

1∗

0

1∗

11

0

0

0

0

10

0

0

0

1∗

11/13/2018 9:43:38 AM

97

Chapter 2  •  Digital Logic

104. Topic: Boolean Algebra (a)  We have x#0 = x , x #1 = x , x#x = 0 and x #1 = 1.

108. Topic: Boolean Algebra (c)  By checking all combinations of x1, x2, x3 and x4, we conclude that options (a), (b) and (d) are false.

x

0

x#0

0 1

0 0

0 1

x

1

x#1

0 1

1 1

0 0

x

x

0

110. Topic: Sequential Circuits (d)  At X, the output of the first multiplexer (MUX-1) is

0 1

0 1

0 0

( P ⋅ 0 + PR) = PR

109. Topic: Number Representations

(1)  For 2’s complement, we have

−(2n−1) to +(2n−1 − 1)

(1)

For sign magnitude, we have −(2n−1) to +(2n−1 − 1)(2) Subtracting (1) from (2), we get −2n−1 + 1 + 2n−1 = 1

and the output of the second multiplexer (MUX-2) is x

x

x#x

0 1

1 0

1 1

It is obvious that # is equivalent to XOR operation. Therefore, x # y = x ⊕ y = xy + xy

(Q ⋅ R + PRQ ) = QR + PQR 111. Topic: Sequential Circuits (b)  The time to perform addition using this adder is Q(log(n)) 112. Topic: Computer Arithmetic (Fixed and Floating Point) (d)  Given that i=n-f The decimal value range of integer part is

105. Topic: Number Representations (-11)  We have the 16 bit 2’s complement r­ epresentation 1111 1111 1111 0101 We know that the sign bit is copied to rest of bits

0 to (2i - 1) The decimal value range of fraction part is 0 to (1 - 2-f   )

1 0 1 0 1 ↑ ↑ ↑ ↑ ↑ −16 0 4 0 1 Therefore, -16 + 4 + 1 = -11. 106. Topic: Sequential Circuits (3)  The sequence is 0-1-0-2-0-3. Therefore, the number of states is 6 ⇒ 2i ≥ 3 ⇒ i = 3. 107. Topic: Sequential Circuits (-1)  When it happens that all bits in register B is 1, then, we get only highest delay. Therefore, the decimal value of B is −1 in longest latency (8-bit notation) of 2’s complement (i.e., 1111 1111).

Ch wise GATE_CSIT_CH02_Digital Logic.indd 97

Therefore, the real number range is 0 to (2i - 1 + 1 - 2- f  ) = 0 to (2i - 2f  ) 113. Topic: Computer Arithmetic (Fixed and Floating Point)

(c)  Carry ⇒ C7 C6 C5 C4 C3 C2 C1 C0   A ⇒ A7 A6 A5 A4 A3 A2 A1 A0   B ⇒ B7 B6 B5 B4 B3 B2 B1 B0

Sum ⇒ S7 S6 S5 S4 S3 S2 S1 S0

When numbers are positive, overflow occurs when A7 B7 S7 is 1. When numbers are negative, overflow occurs when A7 B7 S7 is 1.

11/13/2018 9:43:40 AM

98

GATE CS AND IT Chapter-wise Solved Papers

Therefore, overflow is said to have occurred if ( A7 ⋅ B7 ⋅ S7 + A7 ⋅ B7 ⋅ S7 ) in 1. 114. Topic: Minimization (1)  Consider the following Karnaugh map ba dc

00

00

01

11

×

×

1

×

11

1

1 ×

CLK

Q1

Q0

0

1

1

1

0

1

2

1

0

3

1

1

4

0

1

10

01

10

117. Topic: Sequential Circuits (b)

Q1Q0 after 3rd cycle - 11 Q1Q0 after 4th cycle - 01

×

118. Topic: Minimization (c)

Its output is ac . ac is implemented using 2-input NOR gate. Now,

  = wx + wx + wy + x + xy

ac = a + c

  = x ( w + 1 + y ) + wy

which can be shown as follows a + c−

a − c

(a)  wx + w ( x + y ) + x ( x + y )

Therefore, the number of NOR gates required is 1. 115. Topic: Number Representations (d)  (BCA9)16 = (1011 1100 1010 1001) = (1 011 110 010 101 001)2 = (136251)8 116. Topic: Computer Arithmetic (Fixed and Floating Point) (c)  We know,

  = x + wy Therefore, option (a) is correct. (b)  wx ( y + z ) + wx   = w + wx + x + yz   = w + x + yz Therefore, option (b) is correct. (c)  ( wx ( y + xz ) + wx ) y   = ( wxy + wx ) y

Decimal value expression = (−1)S × 1.M × 2E − 127

  = wxy + wxy

Now,

  = xy( w + w )  S = 0

  = xy

E = 01111100

Therefore, option (c) is incorrect.

M = 11011010……0

(d)  ( w + y )( wxy + wyz )

Therefore, Decimal value expression = (−1)0 × 1.11011010 × 2−3 = 2.27 × 10−1

Ch wise GATE_CSIT_CH02_Digital Logic.indd 98

  = wxy + wyz Therefore, option (d) is correct.

11/13/2018 9:43:42 AM

Chapter 2  •  Digital Logic

119. Topic: Minimization (a)  Consider the following Karnaugh map.

0/0 0/0 00

yz

00

01

11

10

00

1

1

1

1

01

0

×

1

×

wx

01 1/0 0/1

11

1/1

1/0

10 1/1

11

0

0

×

0

10

1

0

×

1

0/1 Number of self-loop states are 00 and 11. Thus, number of states in the state transition diagram of this circuit that have a transition back to the same state on some value of “in” is 2.

Therefore, f = (w + z ) ( x + z ) 120. Topic: Sequential Circuits (b)

123. Topic: Number Representations (c)  Fixed point binary number is represented as b7 b6 b5 b4 b3 b2 b1 b0 Now (31.5)10 = (11111.100)2 However, (12.100)10 and (3.001)10 cannot be represented in the given format. Hence, option (c) is correct.

Q1

Q0

Q1+

Q0+

T1

T0

0

0

0

1

0

1

0

1

1

0

1

1

1

0

1

1

0

1

F ( P , Q, R, S ) = ∑ m(0, 2, 5, 7, 9, 11) + d (3, 8, 10, 12, 14)

1

1

1

1

0

0

m is minterm d is don’t case condition

Therefore,

00

T0 = Q1 Q0 + Q1Q0 + Q1 Q0 = Q1 + Q0

=Q



(P  P)  Q = O  Q  = Q

Therefore ( P ⊕ P ) ⊕ Q ≠ ( P  P )  Q 122. Topic: Sequential Circuits (2)  State transition diagram is given as

Ch wise GATE_CSIT_CH02_Digital Logic.indd 99

R1S

0

00

01 1

5

( 1⊕ Q = Q ) ( ∵ P  P = 0)

13

1 6

1 15

14

´

11 8

10

7

1 12

10 2

´

01 ( P ⊕ P = 1)

11 3

1 4

121. Topic: Boolean Algebra (d)  ( P ⊕ P ) ⊕ Q = 1 ⊕ Q 

124. Topic: Number Representations (3)  Given,

P 1Q

T1 = Q1 Q0



99

´ 9

´

11

1

10

1

´

(∵ O  Q = Q ) Therefore

F = SQ + RSQ + RS

All three are essential prime implicants of F. Thus, answer is 3.

11/13/2018 9:43:45 AM

Ch wise GATE_CSIT_CH02_Digital Logic.indd 100

11/13/2018 9:43:45 AM

Computer Organization and Architecture

CHAPTER3

Syllabus Machine instructions and addressing modes. ALU, data-path and control unit. Instruction pipelining. Memory hierarchy: cache, main memory and secondary storage; I/O interface (interrupt and DMA mode).

Chapter Analysis Topic

GATE 2009

GATE 2010

Machine Instructions

GATE 2011

GATE 2012

1

Addressing Modes

GATE 2013

GATE 2014

GATE 2015

GATE 2016

GATE 2017

3

2

2

1

1

1

GATE 2018

1

ALU

1

Data-Path Control Unit

1

1

1

Instruction Pipelining

1

1

1

1

1

3

2

2

Memory Hierarchy

5

3

3

2

2

5

2

3

6

2

Important Formulas •  Amdahl’s law F⎤ ⎡ Soverall = ⎢(1 - ∑ Fi ) + ∑ i ⎥ S⎦ ⎣

•  Hit ratio (h) =

-1

•  T  he speed up of pipelined system over non-­pipelined system is given by: n × Tn S= ( k + n - 1) × T p

S=

Tn

•  Average access time = Hit ratio × Tc + (1 - Hit ratio)(Tc + Tm ) where Tc is cache access time and Tm is main memory access time.

•  D  irect mapping

•  M  aximum speed up that a pipelined system can achieve is given by: kT p

Number of hits Number of hits + Number of misses

=k

Tag (m - n) bits

Block (n - k) bits

Word (k bits)

•  S  et-associative mapping Tag

Set

Word

QUESTIONS 1. To put the 8085 microprocessor in the wait state (a) lower the HOLD input (b) lower the READY input (c) raise the HOLD input (d) raise the READY input (GATE 2000: 1 Mark)

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 101

2. Comparing the time T1 taken for a single instruction on a pipelined CPU with time T2 taken on a non–pipelined but identical CPU, we can say that (a) T1 ≤ T2 (b) T1 ≥ T2 (c) T1 < T2

11/13/2018 9:49:13 AM

102

GATE CS AND IT Chapter-wise Solved Papers

(d) T1 is T2 plus the time taken for one instruction fetch cycle (GATE 2000: 1 Mark) 3. The 8085 microprocessor responds to the presence of an interrupt (a) as soon as the TRAP pin becomes ‘high’ (b) by checking the TRAP pin for ‘high’ status at the end of each instruction each (c) by checking the TRAP pin for ‘high’ status at the end of the execution of each instruction. (d) by checking the TRAP pin for ‘high’ status at regular intervals. (GATE 2000: 1 Mark) 4. The most appropriate matching for the following pairs

X: Indirect addressing

1: Loops

Y: Immediate addressing

2: Pointers

Z: Auto decrement addressing 3: Constants is (a) X – 3, Y – 2, Z – 1 (b) X – 1, Y – 3, Z – 2 (c) X – 2, Y – 3, Z – 1 (d) X – 3, Y – 1, Z – 2 (GATE 2000: 1 Mark) 5. Which of the following requires a device driver? (a) Register (b) Cache (c) Main memory (d) Disk (GATE 2001: 1 Mark)

8. In 8085 which of the following modifies the program counter? (a) Only PCHL instruction (b) Only ADD instruction (c) Only JMP and CALL instructions (d) All instructions (GATE 2002: 1 Mark) 9. In the absolute addressing mode (a) the operand is inside the instruction (b) the address of the operand is inside the instruction (c) the register containing the address of the operand is specified inside the instruction (d) the location of the operand is implicit (GATE 2002: 1 Mark) 10. What are the states of the Auxiliary Carry (AC) and Carry Flag (CY) after executing the following 8085 program? MVI H, 5DH MIV L, 6BH MOV A, H ADD L (a) AC = 0 and CY = 0 (b) AC = 1 and CY = 1 (c) AC = 1 and CY = 0 (d) AC = 0 and CY = 1 (GATE 2002: 2 Marks)

11. The performance of a pipelined processor suffers if (a) the pipeline stages have different delays (b) consecutive instructions are dependent on each X: Indirect addressing I: Array implementation other (c) the pipeline stages share hardware resources Y: Indexed addressing II: Writing re-locatable code (d) All of the above Z: Base register addressing III: Passing array as parameter (GATE 2002: 2 Marks) (a) (X, III) (Y, I) (Z, II) 12. Horizontal microprogramming (b) (X, II) (Y, III) (Z, I) (a) does not require use of signal decoders (c) (X, III) (Y, II) (Z, I) (b) results in larger sized microinstructions than verti(d) (X, I) (Y, III) (Z, II) cal microprogramming (GATE 2001: 2 Marks) (c) uses one bit for each control signal 7. A device employing INTR line for device interrupt puts (d) all of the above the CALL instruction the data bus while (GATE 2002: 2 Marks) (a) INTA is active 13. For a pipelined CPU with a single ALU, consider the (b) HOLD is active ­following situations: (c) READY is active I. The j + 1-st instruction uses the result of the jth (d) None of the above instruction as an operand. (GATE 2002: 1 Mark) II. The execution of a conditional jump instruction. 6. Which is the most appropriate match for the items in the first column with the items in second column

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 102

11/13/2018 9:49:15 AM

Chapter 3  •  Computer Organization and Architecture



III. The j-th and j + 1-st instructions require the ALU at the same time. Which of the above can cause a hazard? (a) I and II only (b) II and III only (c) III only (d) All the three (GATE 2003: 1 Mark)

Common Data Questions 14 and 15: Consider the following assembly language program for a hypothetical processor. A, B and C are 8-bit registers. The meanings of various instructions are shown as comments: MOV B, #0 MOV C, #8 Z: CMP C, #0 JZ X SUB C, #1 RRC A, #1

; B ← 0 ; C ← 8 ; Compare C with 0 ; Jump to X if zero flag is set ; C ← C − 1 ; Right rotate A through carry by one bit. Thus: ; if the initial values of A and the carry flag are a7…a0 and; c0 respectively, their values after the execution of this; instruction will be c0 a7..a1 and a0, respectively. JC Y ; Jump to Y if carry flag is set JMP Z ; Jump to Z Y: ADD B, #1 ; B ← B + 1 JMP Z ; Jump to Z X: 14. If the initial value of register A is A0, the value of register B after the program execution will be (a) The number of 0 bits in A0 (b) The number of 1 bits in A0 (c) A0 (d) 8 (GATE 2003: 2 Marks) 15. Which of the following instructions when inserted at location X will ensure that the value of register A after program execution is the same as its initial value? (a) RRC A, #1 (b) NOP; no operation (c) LRC A, #1; left rotate A through carry flag by one bit (d) ADD A, #1 (GATE 2003: 2 Marks) 16. Which of the following addressing modes are suitable for program relocation at run time?

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 103

(i) (iii) (a) (c)

Absolute addressing Relative addressing (i) and (iv) (ii) and (iii)

(ii) (iv) (b) (d)

103

Base addressing Indirect addressing (i) and (ii) (i), (ii) and (iv)

(GATE 2004: 1 Mark) Common Data Questions 17 and 18: Consider the following program segment for a hypothetical CPU having three-user registers R1, R2 and R3. Instruction

Operation

Instruction Size (in words)

MOV R1, 5000

; R1 ← Memory [5000]

2

MOV R2 (R1)

; R2 ← Memory [(R1)]

1

ADD R2, R3

; R2 ← R2 + R3

1

MOV 6000, R2

; Memory [6000] ← R2

2

HALT

; Machine halts

1

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

(b) 1020 (d) 1028 (GATE 2004: 2 Marks)

18. Let the clock cycles required from various operations be as follows:



Register to/from memory transfer: 3 clock cycles ADD with both operands in register: 1 clock cycle instruction fetches and decodes: 2 clock cycles per word The total number of clock cycles required to execute the program is (a) 29 (b) 24 (c) 23 (d) 20 (GATE 2004: 2 Marks)

19. Consider a small two-way set-associative cache memory, consisting of four blocks. For choosing the block to be replaced, use the least recently used (LRU) scheme. The number of cache misses for the following sequence of block addresses 8, 12, 0, 12, 8 is

11/13/2018 9:49:16 AM

104

GATE CS AND IT Chapter-wise Solved Papers

(a) 2 (c) 4

(b) 3 (d) 5 (GATE 2004: 2 Marks)

20. A hard disk with a transfer rate of 10 MB/s is constantly transferring data to memory using DMA. The processor runs at 600 MHz, and takes 300 and 900 clock cycles to initiate and complete DMA transfer, respectively. If the size of the transfer is 20 KB, what is the percentage of processor time consumed for the transfer operation? (a) 5.0% (b) 1.0% (c) 0.5% (d) 0.1% (GATE 2004: 2 Marks) 21. A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 ns, respectively. Registers that are used between the stages have a delay of 5 ns each. Assuming constant clocking rate, the total time taken to process 1000 data items on this pipeline will be (a) 120.4 µs (b) 160.5 µs (c) 165.5 µs (d) 590.0 µs (GATE 2004: 2 Marks) 22. Consider a multiplexer with X and Y as data inputs and Z as control input. Z = 0 selects input X, and Z = 1 selects input Y. What are the connections required to realize the 2-variable Boolean function f = T + R, without using any additional hardware? (a) (b) (c) (d)

R to X, 1 to Y, T to Z T to X, R to Y, T to Z T to X, R to Y, 0 to Z R to X, 0 to Y, T to Z

(b) 8, 5, 256 (d) 10, 3, 512 (GATE 2004: 2 Marks)

24. 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. (GATE 2005: 1 Mark) 25. 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(s). (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. (GATE 2005: 1 Mark)

(GATE 2004: 2 Marks) 23. The microinstructions stored in the control memory of a processor have a width of 26 bits. Each microinstruction is divided into three fields: a micro-operation field of 13 bits, a next address field (X), and a MUX select field (Y). there are 8 status bits in the inputs of the MUX. How many bits are there in the X and Y fields, and what is the size of the control memory in number of words?

Load Control address register Increment Control memory MUX

(a) 10, 3, 1024 (c) 5, 8, 2048

Y

8 Status bits X

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 104

13 Micro operations

26. Consider a three word machine instruction ADD A[R0], @B The first operand (destination) “A [R0]” uses indexed addressing mode with R0 as the index register. The second operand (source) “@B” uses indirect addressing 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 operand). The number of memory cycles needed during the execution cycle of the instruction is: (a) 3 (b) 4 (c) 5 (d) 6 (GATE 2005: 2 Marks) 27. Match each of the high level language statements given on the left-hand side with the most natural addressing mode from those listed on the right-hand side.

11/13/2018 9:49:16 AM

Chapter 3  •  Computer Organization and Architecture

(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) (c) (1, b), (2, c), (3, a)

(b) (1, a), (2, c), (3, b) (d) (1, a), (2, b), (3, c)

105

Common Data Questions 31 and 32: Consider the following data path of a CPU. 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.

(GATE 2005: 2 Marks)

MAR

28. Consider a direct mapped cache of size 32 KB 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 (b) 10, 22 (c) 15, 17 (d) 5, 17

MDR

S IR

T

PC GPRs

ALU

(GATE 2005: 2 Marks) 29. A 5-stage pipelined CPU has the following sequence of stages: IF:  Instruction fetch from instruction memory RD:  Instruction decodes and register read EX:  Execute ALU operation for data and address computation MA: Data memory access for write access, the register read at RD state is used. WB:  Register write back. Consider the following sequence of instructions: I1: L R0, loc 1; R0 ⇐ M[loc1] I2: A R0, R0 1; R0 ⇐ R0 + R0 I3: S R2, R0 1; 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 I1? (a) 8 (c) 12

(b) 10 (d) 15 (GATE 2005: 2 Marks)

30. A device with data transfer rate 10 KB/s is connected to a CPU. Data is transferred byte-wise. Let the interrupt overhead be 4 s. The byte transfer time between the device interfaces 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 (GATE 2005: 2 Marks)

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 105

31. The instruction “add R0, R1” 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 (GATE 2005: 2 Marks)

32. The instruction “call Rn, sub” is a 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 (GATE 2005: 2 Marks)

33. 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; similarly, for writing, the disk interface reads a 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 (GATE 2005: 2 Marks)

11/13/2018 9:49:17 AM

106

GATE CS & IT Chapter-wise Solved Papers

34. 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 (GATE 2006: 1 Mark)

35. 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 wrap 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, the latency of retrieving a cache block starting at address zero from the main memory is (a) 92 ns (b) 104 ns (c) 172 ns (d) 184 ns (GATE 2006: 2 Marks) 36. A CPU has a 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 109 instructions out of which 20% are conditional branches. If each instruction takes one cycle to complete on average, the total execution time of the program is (a) 1.0 s (b) 1.2 s (c) 1.4 s (d) 1.6 s (GATE 2006: 2 Marks) 37. Consider a new instruction named branch-on-bit-set (mnemonic bbs). The instruction “bbs reg, pos, label” 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 & 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 × 1  pos (b) mask ← 0 × ffffffff  pos

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 106

(c) mask ← pos (d) mask ← 0 × f (GATE 2006: 2 Marks) Common Data Questions 38 and 39: 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 a 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 h1 while that of the direct mapped one is h2. 38. The value of h1 is (a) 2.4 ns (c) 1.8 ns

(b) 2.3 ns (d) 1.7 ns (GATE 2006: 2 Marks)

39. The value of h2 is (a) 2.4 ns (c) 1.8 ns

(b) 2.3 ns (d) 1.7 ns (GATE 2006: 2 Marks)

Common Data Questions 40 and 41: 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=0; i 24).



its

its 5

R2

I

edi te

its

Therefore, the immediate operand field is



In 1 cycle, we see that the DMA controller transfers 216 bytes, that is, 1 byte is transferred by DMA is



 1  16 2

  cycles 

Now, for the full file of size 29154 KB, the minimum number of cylces is 29154 × 210 bytes = 455.53 216

Therefore, the number of cylces to transfer the file from the disk to main memory can be taken to be 456.



(33.33)  The initial throughput is 1 instruction for 3200 picoseconds, that is, 4 × 800 = 3200 ­picoseconds. Here, 800 is the maximum stage delay of any stage in an instruction; thus, it is selected as synchronous clock cycle time.



In the next design, throughput is 1 instruction for 2400 picoseconds, that is, 4 × 600 = 2400 picoseconds. Here, 600 is the maximum stage delay of any stage in an instruction; thus, it is selected as synchronous clock cycle time. Now, the increase in throughput is calculated as follows:



 (1/ 2400 ) − (1/ 3200 )    × 100 = 33.33 1/ 3200  







Now, there is an assumption that the pipeline used is synchronous and if asynchronous is used, the throughput is dropped, but it is not increased.

it

R1

5



29154 KB = 29154 × 210 byte

110. Topic: Instruction Pipelining

107. Topic: Memory Hierarchy: Main Memory (31)  • Memory = 4 GB = 232 (or 32-bit). • Size of address bus = M − 1 for 2M bits ⇒ 32 − 1 = 31 bits.

6

Therefore, 2 bytes are transferred in 1 cycle. Now, for the given file, we have the file size





106. Topic: Machine Instructions (b)  There occurs a name dependency here (write after read). This is anti-dependency and it always causes a stall of one or more cycles.

Opcode

1 word = 1 byte 16 



105. Topic: Instruction Pipelining (3.33) For S1 latency = 0 + 4 For S2 latency = 1 + 3 For S3 latency = 2 Average latency = 10/3 = 3.33

32

109. Topic: Memory Hierarchy: I/O Interface (Interrupt and DMA Mode) (456) The data count register gives the number of words the DMA controller can transfer in a single cycle and here, it is 16 bits. Thus, a maximum of 216 words can be ­transferred in one cycle since the memory is byteaddressable. We know that

-

125

32 − (6 + 5 + 5) = 16

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 125

111. Topic: Machine Instructions (500) Single instruction needs 34 bit; therefore, the total number of bytes required is 5. Here, the size of the program is given as 100 instructions. Therefore, the amount of memory (in bytes) consumed by the program text is

5 × 100 = 500

11/13/2018 9:49:24 AM

126

GATE CS AND IT Chapter-wise Solved Papers

112. Topic: Memory Hierarchy: Cache (24)  Since the given machine uses 8-way set associative, the tag size would be 24 bits. Cache Tag

219 Bytes

Tag

40

113. Topic: Instruction Pipelining (4)  We have Cycle time = Maximum stage delay (non-uniform pipelines) Therefore, 1 Cycle time = Clock frequency



1 = (1)t 2 3 1 3 •  For case 2 (new pipeline): = t 2 x 4 From the above two cases, we get x = 4.

•  For case 1 (old pipeline):



528 ≈ 1.51 350

Occurrence of the misses in cache L2 =

=

116. Topic: Memory Hierarchy: Cache (76)  Given that 2-way set associative cache has Number of blocks = 256 Now, 256 Number of sets in cache memory = = 128 2 Block access sequence 0, 128, 256, 128, 0, 128, 256, 128, 1, 129, 257, 129, 1, 129, 257, 129 Expression of mapping is k mod 128. First Time Access: 0 mod 128 = 0 → Miss 128 mod 128 = 0 → Miss 256 mod 128 = 0 → Miss 128 mod 128 = 0 → Hit

114. Topic: Memory Hierarchy: Cache (0.05)  Given that 1.4 memory accesses are required per instruction on average. For 1000 instructions → 1400 memory accesses

Time taken by naive pipelined Time taken by efficient pipelined

216

3

21



 Speedup =

Final tag

40



Therefore,

7 = 0.005 1400



Conflict

0 mod 128 = 0 → Miss

128 mod 128 = 0 → Hit

Conflict

256 mod 128 = 0 → Miss

128 mod 128 = 0 → Hit 1 mod 128 = 1 → Miss

Therefore, L2 cache miss rate =

L2 cache misses L1 cache miss rate

129 mod 128 = 1 → Miss



0.005 = 0.05 0.1

129 mod 128 = 1 → Hit

=

115. Topic: Machine Instructions (1.51)  In naive pipelined CPU, k = 5 and n = 20 (given). Now, time taken by the pipeline segment, TP = 20 + 2 = 22 ns and Execution time = (k + n - 1) TP = (5 + 20 - 1) 22 = 528 ns In efficient pipelined processor, k = 6 and n = 20 (given). Now, TP = 12 + 2 = 14 ns and Execution time = (6 + 20 - 1) × 14 = 350 ns

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 126

257 mod 128 = 1 → Miss

Conflict

1 mod 128 = 1 → Miss

129 mod 128 = 1 → Hit

Conflict

257 mod 128 = 1 → Miss

129 mod 128 = 1 → Hit ⇒ Total number of conflict misses = 6

Second Time Access: Block id 0

Type Conflict miss

128

Hit

256

Conflict miss

128

Hit

0

Conflict miss

11/13/2018 9:49:25 AM

Chapter 3  •  Computer Organization and Architecture

Block id



120. Topic: Memory Hierarchy: Cache

Type

128

Hit

256

Conflict miss

128

Hit



Similarly for {1, 129, 257, 129, 1, 129, 257, 129, Conflict miss = 4} Each time conflict misses = 8 (=4 + 4) Therefore, total conflicts misses = 9 × 8 + 4 = 76

117. Topic: Memory Hierarchy: Cache (14)  Total number of bits = Tag bits + Line offset bits + Word offset bits In a direct mapped cache, Tag bits = 10 In direct mapped Tag number

Line number

Offset

10 bits

When cache is configured as a 16-way set-­associative, the tag size increases. In set associative Tag number

Set number

32 bit

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 127

Block offset

18

log2512 = 9 bit

Word offset log232 = 5 bit



One refresh operation takes 50 ns.



Total number of rows = 214.



Refresh period = 2 ms.



Total time to refresh all rows = 214 × 50 ns



Tag bits = 14

119. Topic: Memory Hierarchy: Cache (2.74) Let h1, h2, h3 and h4 be the hit ratio of I-cache, D-cache, L2-cache and main memory, respectively. Let t1, t2, t3 and t4 be the read access time of I-cache, D-cache, L2-cache and main memory, respectively. Now, Average read access time = h1t1 + h2 (1 − h1) (t2 + t1) + h3 (1 − h2) (1 − h1) (t3 + t2 + t1) + h4 (1 − h3) (1 − h2) (1 − h1) (t4 + t3 + t2 + t1) Substituting the values, we get Average read access time = 2.74 ns

Tag

121. Topic: Memory Hierarchy: Main Memory (59.04)  Capacity of main memory unit = 1 GB.

Offset

118. Topic: Memory Hierarchy: Cache (a)  We know 2 = 1 + M(L2) × 18 ⇒ M(L2) = 0.056 Now, M(L1) = 0.056 × 2 = 0.111

(18)  Physical address is of 32 bits. Block offset = log2(512) = 9 bits

Word offset = log2(32) = 5 bits Therefore, tag field consists of 32 - 9 - 5 = 18 bits

10 + 4 = 14 bits (log216 = 4)

127



= 819200 ns

Therefore, Percentage time spent in refresh =

Total time to refresh all rows × 100 Refresh period

=

819200 × 10 -9 s × 100 = 40.96% 2.0 × 10 -3 s

Therefore, Total time spent in read/write = 100 – 40.96 = 59.04%

122. Topic: Memory Hierarchy: I/O Interface (Interrupt and DMA Mode) (219)  Given, total instructions = 100

Number of stages = 5



Therefore, Total number of cycles = 100 + 5 - 1 = 104



In PO stage, 40 instructions take 3 cycles.



35 instructions take 2 cycles.



25 instructions take 1 cycle.



These instructions are suffering from 2 stall cycles, 1 stall cycle and 0 stall cycle, respectively.

Therefore, Extra-cycles = 40 × 2 + 35 × 1 + 20 × 0 = 115

Therefore, Total cycles = 104 + 115 = 219

11/13/2018 9:49:26 AM

Ch wise GATE_CSIT_CH03_Computer Organization and Architecture.indd 128

11/13/2018 9:49:26 AM

Programming and Data Structures

CHAPTER4

Syllabus Programming in C. Recursion. Arrays, stacks, queues, linked lists, trees, binary search trees, binary heaps, graphs.

Chapter Analysis Topic

GATE 2009

GATE 2010

GATE 2011

GATE 2012

2

1

3

Programming in C Recursion

1

GATE 2013

2

1

GATE 2014

GATE 2015

GATE 2016

GATE 2017

GATE 2018

6

9

6

9

5

3

4

1

1

1

1

1

2

Arrays Stacks Queues

1

Linked Lists Trees

1

2

1

1

2

2

1

Binary Search Trees Binary Heaps

1

1

1

1

1

1

2

1

1

1

5

2

2

2

3

1

1

4

1

Graphs

2

1

Important Formulas   1. Insertion/Deletion in array: O(n)

11. Complexity of inorder, preorder and postorder tree traversal: O(n)

  2. Split/Merge in array: O(n)

12. Minimum number of moves for tower of Hanoi: 2n − 1

  3. Time complexity of Push(): O(1)

2n n

C n +1

  4. Time complexity of Pop(): O(1)

13. Number of unique binary trees:

  5. Time complexity of Enqueue(): O(1)

14. One-dimensional arrays In one dimension, an array ‘A’ is declared as:

  6. Time complexity of Dequeue(): O(1)



  7. Number of elements in queue = ⎧ rear - front + 1, if rear = front ⎨ ⎩ rear - front + n, otherwise   8. Number of nodes in full binary tree: 2

h+1



-1 [h: levels]

  9. Number of leaf nodes in full binary tree: 2h 10. Number of waste pointers in complete binary tree of n nodes: n + 1

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 129



A[lb … … ub]

where lb is the lower bound of array and ub is the upper bound of array. Suppose we want to calculate the ith element address, then Address (arr[i]) = BA + (i − lb) * c



where BA is the base address of array and lb is the lower bound of array and c is the size of each element

11/13/2018 10:19:07 AM

130

GATE CS AND IT Chapter-wise Solved Papers

15. Two-dimensional arrays In two dimensions, an array ‘A’ is declared as:

Row major order Address (arr[i][j]) = BA + [i − lb1) * Nc + ( j − lb2)] * c

A[lb1 … … ub1][lb2 … … ub2]

Column major order Address (arr[i][j]) = BA + [ j − lb2) * Nr + (i − lb1)] * c where BA is the base address, Nr is the number of rows  = (lb2 − lb1 + 1), and Nc is the number of columns = (ub2 − ub1 +1).

where lb1 is the lower bound for row, lb2 is the lower bound for column, ub1 is the upper bound for row and ub2 is the upper bound for column.

QUESTIONS 1. An n × n array v is defined as follows:

sub stress, respectively, of node X. Note that Y and Z may be NULL, or further nested. Which of the following ­represents a valid binary tree? (a) (1 2 (4 5 6 7)) (b) (1 (2 3 4) 5 6) 7) (c) (1 (2 3 4)(5 6 7)) (d) (1 (2 3 NULL) (4 5)) (GATE 2000: 1 Mark)

V [i, j] = i – j for all i, j, 1 ≤ i ≤ n, 1 ≤ j ≤ n The sum of the elements of the array v is (a) 0 (b) n – 1 (c) n2 – 3n + 2

2.

3.

( n + 1) 2 (GATE 2000: 1 Mark)

(d) n2

The following C declarations struct node{ int i: float j; }; struct node *s[10]; define s to be (a) An array, each element of which is a pointer to a structure of type node (b) A structure of 2 fields, each field bang a pointer to an array of 10 elements (c) A structure of 3 fields: an integer, a float, and an array of 10 elements (d) An array, each element of which is a structure of type node (GATE 2000: 1 Mark)

5. Aliasing in the context of programming languages refers to (a) multiple variables having the same memory location (b) multiple variables having the same value (c) multiple variables having the same identifier (d) multiple uses of the same variable (GATE 2000: 1 Mark) 6.

The most appropriate matching for the following pairs is

X: m = malloc(5); m = NULL;

Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is (a) 22 bytes (b) 14 bytes (c) 18 bytes (d) 10 bytes (GATE 2000: 1 Mark)

1: u sing dangling pointers

Y: free(n); n → value = 5; 2: using uninitialized pointers Z: char*p; *p = ‘a’; is: (a) X – l Y – 3 Z – 2 (c) X – 3 Y – 2 Z – l 4.

3: lost memory (b) X – 2 Y – l Z – 3 (d) X – 3 Y – l Z – 2 (GATE 2000: 1 Mark)

Consider the following nested representation of binary trees: (X Y Z) indicates Y and Z are the left and right

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 130

Consider the following C declaration struct { short s [5] union { float y; long z; } u; } t;

7.

The number of tokens in the following C statement printf(“i = %d, &i = %x”,i,&i); is (a) 3 (b) 26 (c) 10 (d) 21 (GATE 2000: 1 Mark)

11/13/2018 10:19:08 AM

Chapter 4  • Programming and Data Structures

8. B+- trees are preferred to binary trees in databases because (a) Disk capacites are greater than memory capacities (b) Disk access is much slower than memory access (c) Disk data transfer rates are much less than memory data transfer rates (d) Disks are more reliable than memory (GATE 2000: 1 Mark) 9.

Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal. Respectively, of a compete binary tree. Which of the following is always tree? (a) LASTIN = LASTPOST (b) LASTIN = LASTPRE (c) LASTPRE = LASTPOST (d) None of the above (GATE 2000: 2 Marks)

10. The value of j at the end of the execution of the following C program int incr (int i) { static int count = 0; count = count + i; return (count); } main () { int i,j; for (i = 0; i data next -> data) && f(p-> next))); }

U

Q T

N

VXZ

(c) (d) None of the above (GATE 2003: 2 Marks) 31. In the following C program fragment, j, k, n and TwoLog_n are integer variables, and A is an array of integers. The variable n is initialised to an integer ≥ 3, and TwoLog_n is initialised to the value of n 2*log2(n) for (k=3; k 0 */ m = x; n = y; while (m! = n) { if (m > n) m = m - n; else

11/13/2018 10:19:12 AM

137

Chapter 4  • Programming and Data Structures

}

n = n - m; } printf(“%d”,n);

The program computes (a) x + y using repeated subtraction. (b) x mod y using repeated subtraction. (c) The greatest common divisor of x and y. (d) The least common multiple of x and y. (GATE 2004: 2 Marks) 50. What does the following algorithm approximate? (Assume m > 1, ε > 0) x = m; y = 1; while (x - y > ε) { x = (x + y)/2; y = m/x; } print(x);

52. Choose the best matching between the programming styles in Group 1 and their characteristics in Group 2. Group 1

Group 2

I.  Functional

A. Command-based, procedural

II.  Logic

B. Imperative, abstract data types

III. Object-oriented

C. Side-effect free, declarative, expression evaluation

IV. Imperative

D. Declarative, clausal representation, theorem proving

(a) (b) (c) (d)

I-B, II-C, III-D, IV-A I-D, II-C, III-B, IV-A I-C, II-D, III-A, IV-B I-C, II-D, III-B, IV-A

(a) log m (b) m2 (GATE 2004: 2 Marks) 1/2 (c) m (d) m1/3 (GATE 2004: 2 Marks) 53. What does the following C-statement declare? 51. Consider the following C program segment: struct CellNode{ st ructCellNode *leftChild; int element; st ructCellNode *rightChild; }; intDosomething (structCellNode *ptr) { int value = 0; if (ptr ! = NULL) {  if (ptr -> leftChild ! = NULL) va lue = 1 + DoSomething (ptr >leftChild); if (ptr -> rightChild ! = NULL) va lue = max(value,1 + DoSomething (ptr->rightChild)); } return (value); }



The value returned by the function DoSomething when a pointer to the root of a non-empty tree is passed as argument is (a) The number of leaf nodes in the tree. (b) The number of nodes in the tree. (c) The number of internal nodes in the tree. (d) The height of the tree. (GATE 2004: 2 Marks)

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 137

int (*f) (int * );

(a) A function that takes an integer pointer as argument and returns an integer. (b) A function that takes an integer 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 and returns a function pointer. (GATE 2005: 1 Mark) 54. 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. (GATE 2005: 1 Mark) 55. A common property of logic programming languages and functional languages is: (a) Both are procedural languages. (b) Both are based on l calculus. (c) Both are declarative. (d) Both use Horn-clauses. (GATE 2005: 1 Mark) 56. Which one of the following are essential features of an object-oriented programming language?

11/13/2018 10:19:12 AM

138

GATE CS AND IT Chapter-wise Solved Papers

   I  Abstraction and encapsulation   II  Strictly typedness III  Type-safe property coupled with sub-type rule IV  Polymorphism in the presence of inheritance (a) I and II only (b) I and IV only (c) I, II and IV only (d) I, III and IV only (GATE 2005: 1 Mark) 57. A program P reads in 500 integers in the range [0, 100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies? (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 (GATE 2005: 1 Mark) 58. 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); printf (“%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 (GATE 2005: 2 Marks)

59. 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 compiled without any error or warning. If line 1 is deleted, the above code will show: (a) No compile warning or error. (b) Some compiler warnings not leading to unintended results.

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 138

(c)  Some compiler warnings due to type-mismatch eventually leading to unintended results. (d) Compiler errors. (GATE 2005: 2 Marks) 60. 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 (GATE 2005: 2 Marks) 61. A priority queue is implemented as a max-heap. Initially, it has five 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 elements 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 (GATE 2005: 2 Marks) 62. How many distinct binary search trees can be ­created out of 4 distinct keys? (a) 5 (b) 14 (c) 24 (d) 42 (GATE 2005: 2 Marks) 63. 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) nk (b) (n − 1)k + 1 (c) n(k − 1) + 1 (d) n(k − 1) (GATE 2005: 2 Marks) 64. Consider line number 3 of the following C program: int min ( ) { int I, N; fro (I =0, IleftChild) + GetValue (ptr->rightChild); } return(value); }



The value returned by GetValue when a pointer to the root of a binary tree is passed as its argument 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 (GATE 2007: 2 Marks)

88. Consider the process of inserting an element into a max-heap, where the max-heap is represented by an array. Suppose we perform a 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: Θ (log2log2n) (a) Θ (log2n) (b) (c) Θ (n) (d) Θ (nlog2n) (GATE 2007: 2 Marks) 89. An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers need to be determined. Which of the following is TRUE about the number of comparisons needed? (a) At least 2n − c comparisons, for some constant, c are needed. (b) At most 1.5 − 2 comparisons are needed. (c) At least nlog2n comparisons are needed. (d) None of the above. (GATE 2007: 2 Marks) 90. 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) (b) (c) (d)

x = 3, y = 4, z = 2 x = 6, y = 5, z = 3 x = 6, y = 3, z = 5 x = 5, y = 4, z = 5 (GATE 2008: 1 Mark)

91. 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

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 142

M

R

N

Q

O

P

(a) MNOPQR (b) NQMPOR (c) QMNPRO (d) QMNPOR (GATE 2008: 1 Mark) 92. You are given the postorder traversal, P, of a binary search tree on the n elements 1, 2, …, n. You have to determine the unique binary search tree that has P as its postorder traversal. What is the time complexity of the most efficient algorithm for doing this? (a) Θ (logn) (b) Θ (n) (c) Θ (n log n) (d) None of the above, as the tree cannot be uniquely determined (GATE 2008: 2 Marks) 93. 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) (b) Θ (n) (c) Θ (nlog n) (d) Θ (n2) (GATE 2008: 2 Marks) 94. 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; print f("%d", f(c, b, a)); }

(a) 18 (c) 21

(b) 19 (d) 22 (GATE 2008: 2 Marks)

11/13/2018 10:19:13 AM

Chapter 4  • Programming and Data Structures

95. Choose the correct option to fill ? 1 and ? 2 so that the program below prints an input string in reverse order. Assume that the input string is terminated by a newline character. void reverse (void) { int c; if (?1) reverse (); ?2 } main () { pr int f (“Enter Text”); print f (“\ n”);   reverse (); print f (“\ n”); }

(a) ? 1 is (getchar ( )! = ‘n’) ? 2 isgetchar (c);

(b) ? 1 is (c = getchar ( ) )! = ‘n’) ? 2 isgetchar (c); (c) ? 1 is (c ! = ‘n’) ? 2 isputchar (c);

(d) ? 1 is ((c = getchar ( ) )! = ‘n’) ? 2 isputchar (c); (GATE 2008: 2 Marks) 96. The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the given 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 { te mp = 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 (c) 1, 3, 2, 5, 4, 7, 6

(b) 2, 1, 4, 3, 6, 5, 7 (d) 2, 3, 4, 5, 6, 7, 1 (GATE 2008: 2 Marks)

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 143

143

97. 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 (GATE 2008: 2 Marks)

Common Data Questions 98 and 99: 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 2. (d)  Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even. (GATE 2008: 2 Marks) 101. The correction needed in the program to make it work properly is (a) Change line 6 to: if (Y[k] < x) i = k + 1; else j = k − 1; (b) Change line 6 to: if (Y[k] < x) i = k  − 1; else j = k + 1; (c)  Change line 6 to: if (Y[k] next; } _______________________________ return head; }

6

4

5

2

1

(b) 10

8

4

6

5

1

2

(c) 10

5

Choose the correct alternative to replace the blank line. (a) q = NULL; p → next = head; head = p;

4

6

8

2

1

(b) q → next = NULL; head = p; p → next = head; (c) head = p; p → next = q; q → next = NULL;

(d) 5

(d) q → next = NULL; p → next = head; head = p; (GATE 2010: 2 Marks) 111. What does the following fragment of C program print? char c [] char *p

=

= c;

2

8

“GATE2011”;

printf(”%s”, p + p[3] — p[1]):

(a) GATE2011 (c) 2011

(b) E2011 (d) 011 (GATE 2011: 1 Mark)

112. A max-heap is a heap where the value of each parent is greater than or equal to the value of its children. Which of the following is a max-heap?

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 145

1

4

6

10 (GATE 2011: 1 Mark)

113. 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↓343↓2)?

11/13/2018 10:19:14 AM

146

GATE CS AND IT Chapter-wise Solved Papers

(a)

Common Data Questions 114 and 115: 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; }

7

3

114. What is the return value of the function foo when it is called foo(345, 10)? (a) 345 (b) 12 (c) 5 (d) 3 (GATE 2011: 2 Marks)

4

3

2

115. What is the return value of the function foo when it is called foo(513, 2)? (a) 9 (b) 8 (c) 5 (d) 2 (GATE 2011: 2 Marks)

(b)

2

116. What will be the output of the following C program ­segment?

7

char inChar = ‘A’ ; switch(inChar) { case ‘A’ : printf(“Choice A\ n”) ; case ‘B’ : case ‘C’ : printf(“Choice B”) ; case ‘D’ : case ‘E’ : default :printf(“No Choice”) ; }

3

4

3

(c)

(a) (b) (c) (d)

7

2

3

3

4

(d)

2

3

4

7

3 (GATE 2011: 2 Marks)

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 146

No choice Choice A Choice A choice B no choice Program gives no output as it is erroneous (GATE 2012: 1 Mark)

117. 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 (GATE 2012: 2 Marks)

11/13/2018 10:19:15 AM

Chapter 4  • Programming and Data Structures

118. 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 B1 ;

}



// Box 1

else { h1 = height (n → left); if(n → right == NULL) return (1+h1);           else { h2 = height (n → right); // Box 2 return B2 ; } }

The appropriate expressions for the two boxes B1 and B2 are (a) B1: (1 + height (n → right)) B2: (1 + max (h1, h2)) (b) B1: (height (n → right)) B2: (1 + max (h1, h2)) (c) B1: height (n → right) B2: max (h1, h2) (d) B1: (1 + height (n → right)) B2: max (h1, h2) (GATE 2012: 2 Marks)

Common Data Questions 119 and 120: Consider the following C code segment: int a, b, c = 0; void prtFun(void); main( ) { staticint a = 1; /*Line 1*/ prtFun( ); a += 1; prtFun( ); printf(“ \n %d %d “, a, b); } voidprtFun(void) { staticint a = 2; /*Line 2*/ int b = 1; a += ++b; printf(“ \n %d %d “, a, b); }

119. What output will be generated by the given code segment? (a) 3 1 (b) 4 2 4 1 61 4 2 61

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 147

147

(c) 4 2 (d) 3 1 6 2 52 2 0 52 (GATE 2012: 2 Marks) 120. What output will be generated by the given code segment if: Line 1 is replaced by autoint a = 1; Line 2 is replaced by registerint a = 2; (a) (c)

3 1 (b) 4 2 4 1 61 4 2 61 4 2 (d) 4 2 6 2 42 2 0 20 (GATE 2012: 2 Marks)

121. 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 (b) 1 (c) 7 (d) 8 (GATE 2013: 1 Mark) 122. Which of the following statements 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 (GATE 2013: 1 Mark) 123. What is the return value of f(p, p), if the value of p is initialised 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 (GATE 2013: 2 Marks)

124. The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of 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 (GATE 2013: 2 Marks)

11/13/2018 10:19:15 AM

148

GATE CS AND IT Chapter-wise Solved Papers

125. 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) Q(n) (b) Q(n + k) k (c) Q(n ) (d) Q(n2) (GATE 2013: 2 Marks)

126. 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

(a) 17 (c) 19

(b) 18 (d) 20 (GATE 2014: 1 Mark)

127. Consider the following program in C language: #include main() { int i; int *pi=&i; scanf(“%d”, pi); printf(“%d \n”, i+5); }

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. (GATE 2014: 1 Mark) 128. Let P be a quick sort program to sort numbers in ascending order using the first element as the pivot.

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 148

Let t1 and t2 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) t1 = 5 (b) t1 < t2 (c) t1 > t2 (d) t1 = t2 (GATE 2014: 1 Mark) 129. 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 (GATE 2014: 1 Mark) 130. Suppose n and p are unsigned int variables in a C program. We wish to set p to nC3. If n is large, which one of the following statements is most likely to set p ­correctly? (a) p = n × (n − 1) × (n − 2)/6; (b) p = n × (n − 1)/2 × (n − 2)/3; (c) p = n × (n − 1)/3 × (n − 2)/2; (d) p = n × (n − 1)/2 × (n − 2)/6.0; (GATE 2014: 1 Mark) 131. 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 (GATE 2014: 1 Mark) 132. Which one of the following is NOT performed during compilation? (a) Dynamic memory allocation (b) Type checking (c) Symbol table management (d) Inline expansion (GATE 2014: 1 Mark) 133. Let A be a square matrix 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

11/13/2018 10:19:16 AM

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]);

Chapter 4  • Programming and Data Structures

(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 these (GATE 2014: 1 Mark) 134. The minimum number of arithmetic operations required to evaluate the polynomial P(X) = X 5 + 4X 3 + 6X + 5 for a given value of X, using only one temporary variable is . (GATE 2014: 1 Mark) 135. Consider the following rooted tree with the vertex labelled P as the root P

Q

S

R

T

U

V

The order in which the nodes are visited during an inorder traversal of the tree is (b) SQPTUWRV (d) SQPTRUWV (GATE 2014: 1 Mark)

136. Consider a hash table with 9 slots. The hash function is h(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 (b) 3, 3, and 3 (c) 4, 0, and 1 (d) 3, 0, and 2 (GATE 2014: 2 Marks) 137. Consider the following C function in which size is the number of elements in the array E:

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 149

int int MyX(int MyX(int *E, *E, unsigned unsigned int int size) size) { { int int Y Y = = 0; 0; int int Z; Z; int int i, i, j, j, k; k; for(i for(i = = 0; 0; i i < < size; size; i++) i++) Y Y = = Y Y + + E[i]; E[i]; for(i for(i = = 0; 0; i i < < size; size; i++) i++) for(j for(j = = i; i; j j < < size; size; j++) j++) { { Z Z = = 0; 0; for(k for(k = = i; i; k k Y) Y) Y = Z; Y = Z; } } return return Y; Y; } }

The value returned by the function MyX is the (a) maximum possible sum of elements in any subarray 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. (GATE 2014: 2 Marks) 138. Consider the following pseudo code. What is the total number of multiplications to be performed?

W

(a) SQPTRWUV (c) SQPTWUVR

149

D = for for for D =

2 i j k D

= = = *

1 to n do i to n do j + 1 to n do 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. (GATE 2014: 2 Marks) 139. 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. t0 t1 t2 t3 t4 t5

= = = = = =

i * 1024 j * 32 k * 4 t1 + t0 t3 + t2 X[t4]

11/13/2018 10:19:17 AM

150

GATE CS AND IT Chapter-wise Solved Papers

Which one of the following statements about the source code for the C program is CORRECT? (a) X is declared as “int X[32] [32] [8]”. (b) X is declared as “int X[4] [1024] [32]”. (c) X is declared as “char X[4] [32] [8]”. (d) X is declared as “char X[32] [16] [2]”. (GATE 2014: 2 Marks)

140. 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) (97 × 97 × 97)/1003 (b) (99 × 98 × 97)/1003 (c) (97 × 96 × 95)/1003 (d) (97 × 96 × 95)/(3! × 1003) (GATE 2014: 2 Marks) 141. Consider the pseudocode 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 treeNode. typedef typedef struct struct treeNode* treeNode* treeptr; treeptr; Struct treeNode Struct treeNode { { Treeptr Treeptr leftMostchild, leftMostchild, rightSibiling; rightSibiling; }; }; Int Dosomething Dosomething (treeptr (treeptr tree) tree) Int { { int int value value =0; =0; if (tree if (tree ! ! = = NULL) NULL) { { If (tree -> leftMostchild If (tree -> leftMostchild = = = = NULL) NULL) else else value value = = Dosomething Dosomething (tree->leftMostchild); (tree->leftMostchild); value value = = value value + + Dosometing Dosometing (tree->rightsibiling); (tree->rightsibiling); } } return return (value); (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. (GATE 2014: 2 Marks)

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 150

142. Consider the C function given below. Assume that the array listA contains n (> 0) elements, sored in ascending order. int ProcessArray (int * listA, int x, int n) { int 1, 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 (1 < = j); If (listA [k] = = x) return (k) ; else return -1; }

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 listA. (b) It is an implementation of binary search. (c) It will always find the maximum element in listA. (d) It will return – 1 even when x is present in listA. (GATE 2014: 2 Marks) 143. The height of a tree is the length of the longest rootto-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are (a) 63 and 6, respectively (b) 64 and 5, respectively (c) 32 and 6, respectively (d) 31 and 5, respectively (GATE 2015: 1 Mark) 144. Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)? I.  3, 5, 7, 8, 15, 19, 25 II.  5, 8, 9, 12, 10, 15, 25 III.  2, 7, 10, 8, 14, 16, 20 IV.  4, 6, 7, 9, 18, 20, 25 (a) I and IV only (c) II and IV only

(b) II and III only (d) II only (GATE 2015: 1 Mark)

11/13/2018 10:19:18 AM

Chapter 4  • Programming and Data Structures

145. Consider the following function written in the C ­programming language. void foo (char *a) { if (*a && *a != ‘ ‘) { foo (a+1); putchar *a; } }

The output of the above function on input “ABCD EFGH” is (a) ABCD EFGH (b) ABCD (c) HGFE DCBA (d) DCBA (GATE 2015: 1 Mark) 146. A binary tree T has 20 leaves. The number of nodes in . T having two children is (GATE 2015: 1 Mark) 147. Consider the following C function. int fun(int n) { int x=1, k; if (n==1) return x; for (k=1; k 1; j = j/2) ++p; for(k = 1; k < p; k = k*2) ++q; } return q; }

Which one of the following most closely approximates the return value of the function fun1? (a) n3 (b) n(log n)2 (c) n log n (d) n log(log n) (GATE 2015: 2 Marks) 155. Consider the following pseudo code, where x and y are positive integers. begin q: = 0 r: = x while r ≥ y do    being    r: = r – y    q: = q + 1    end end

The post condition that needs to be satisfied after the program terminates is (a) {r = qx + y ∧ r < y} (b) {x = qy + r ∧ r < y} (c) {y = qx + r ∧ 0 < r < y} (d) {q + 1 < r - y ∧ y > 0} (GATE 2015: 2 Marks) 156. Consider the intermediate code given below. (1)  i = 1 (2)  j=1 (3)  t1 = 5 * i (4)  t2 = t1+ j (5)  t3 = 4 * t2 (6)  t4 = t3 (7)  a[t4] = −1 (8)  j=j+1 (9) if j < = 5 goto (3) (10)  i = i + 1  (11) if i < 5 goto (2)

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 152

The number of nodes and edges in the control-flowgraph constructed for the above code, respectively, are (a) 5 and 7 (b) 6 and 7 (c) 5 and 5 (d) 7 and 8 (GATE 2015: 2 Marks) 157. Suppose you are provided with the following function declaration in the C programming language int partition (int a[], int n);

The function treats the first element of a[  ] as a pivot, and rearranges the array so that all elements less than or equal to the pivot is in the left part of the array, and all elements greater than the pivot is in the right part. In addition, it moves the pivot so that the pivot is the last elements of the left part. The return value is the number of elements in the left part. The following partially given function in the C programming language is used to find the k th smallest element in an array a [ ] of size n using the partition function. We assume k ≤ n. int kth_smallest(int a[], int n, int k) { int left_end partition (a,n); if (left_end + 1 == k) { return a [left_end]; } if ((left_end + 1) > k) { return kth_smallest (__________); } else return kth_smallest (__________); } }

The missing argument lists are respectively (a) (a, left _ end, k) and (a + left _ end +1, n − left _ end −1, k − left _ end −1) (b) (a, left _ end, k) and (a, n − left _ end −1, k − left _ end −1) (c) (a + left _ end +1, n − left end −1, k − left _ end −1) and (a, left _ end, k) (d) (a, n − left _ end −1, k − left _ end −1) and (a, left _ end, k) (GATE 2015: 2 Marks) 158. The secant method is used to find the root of an equation f(x) = 0. It is started from two distinct estimates, xa and xb for the root. It is an iterative procedure involving linear interpolation to a root. The iteration stops if f(xb) is very small and then xb is the solution. The procedure is given below. Observe that there is an expression which is

11/13/2018 10:19:18 AM

Chapter 4  • Programming and Data Structures

missing and is marked by? Which is the suitable ­expression that is to be put in place of ? so that it follows all steps of the secant method? Secant

{

Initialize: xa, xb, ε, N

stkFunc(0, 10);

// ε =convergence indicator

// N = maximum no. of iterations fb = f(xb)

i = 0

while (i < N and |fb| > ε) do i = i + 1 // update counter

xt = ? // missing expression for xa = xb

xb = xt // intermediate value

fb = f(xb) // function value at new xb end while

if |fb| > ε then // loop is terminated with i=N write “Non-convergence” else

end if

xb− (  fb−f (xa))  fb  /(xb− xa) xa− (  fa−f (xa))  fa  /(xb− xa) xb− (xb− xa)  fb  /(  fb−f (xa)) xa− (xb− xa)  fa  /(  fb−f (xa))

159. Consider the C program below. #include int *A, stkTop;

int stkFunc (int opcode, int val) {

static int size =0, stkTop=0; switch (opcode) {

case-1: size = val; break;

case 0: if (stkTop < size) A (stktop++] = val; break;

default: if (stktop) return A [--stkTop]; return -1; }

int main()

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 153

stkFunc(-1, 10); stkFunc(0, 5);

printf(“%d/n”, stkFunc(1, 0) + stkfunc(1, 0); }

. The value printed by the above program is (GATE 2015: 2 Marks) 160. Consider the following recursive C function. void get(int n) { if (n1) count(n—1); printf(“%d ”, d); } void main() { count(3); } (a) 3 1 2 2 1 3 4 4 4 (b) 3 1 2 1 1 1 2 2 2 (c) 3 1 2 2 1 3 4 (d) 3 1 2 1 1 1 2 (GATE 2016: 2 Marks) 172. Let Q denote a queue containing sixteen numbers and S be an empty stack. Head (Q) returns the element at the head of the queue Q without removing it from Q. Similarly, Top (S) returns the element at the top of S without removing it from S. Consider the algorithm given below. while Q is not Empty do if S is Empty OR Top(S) £ Head(Q) then x:= Dequeue(Q); Push(S, x); else x := Pop(S); Enqueue(Q, x); end end The maximum possible number of iterations of the while loop in the algorithm is _____. (GATE 2016: 2 Marks)

11/13/2018 10:19:19 AM

156

GATE CS AND IT Chapter-wise Solved Papers

173. The attributes of three arithmetic operators in some programming language are given below. Operator Precedence Associativity + High Left − Medium Right * Low Left

Arity Binary Binary Binary



The New-order traversal of the expression tree corresponding to the reverse polish expression 3 4 * 5 − 2 ^ 6 7 * 1 + − is given by:

The value of the expression 2 − 5 + 1 − 7 * 3 in this language is ______. (GATE 2016: 2 Marks)

(a) (b) (c) (d)

174. The following function computes XY for positive integers X and Y. int exp(int X, int Y) {   int res = 1, a = X, b = Y;   while ( b ! = 0 ) {    if (b% == 0) { a = a*a; b = b/2; )    else  { res = res*a; b = b−1; }   }   return res; }

• Visit the root; • Visit the right subtree using New-order; • Visit the left subtree using New-order;

+ − − 1

− + + 7

1 1 1 6

6 * * *

7 6 7 +

* 7 6 2

2 ˆ ˆ 5

ˆ 2 2 4

5 − − 3

− 3 4 * 5 * 3 4 5 * 4 3 * − ˆ − (GATE 2016: 2 Marks)

176. Consider the following program:

Which one of the following conditions is TRUE before every iteration of the loop? (a)  XY = ab (b) (res*a)Y = (res*X)b (c) XY = res*ab (d) XY = (res*a)b (GATE 2016: 2 Marks) 175. Consider the following New-order strategy for traversing a binary tree:

int f(int *p, int n) {   if (n 0) { x = x + foo (val - -); } return val; } int bar (int val) {

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 158

int x = 0; while (val > 0) { x = x + bar (val -1); return val; } Invocations of foo(3) and bar(3) will result in: (a) Return of 6 and 6, respectively. (b)  Infinite loop and abnormal termination, respectively. (c) Abnormal termination and infinite loop, respectively. (d) Both terminating abnormally. (GATE 2017: 2 Marks) 187. Consider the following C program. #include #include void printlength (char *s, char *t) { unsigned int c = 0; int len = ((strlen(s) - strlen(l)) > c) ? strlen(s): strlen(l); printf(%d\n”, len); } void main ( ) { char *x = “abc” char *y = “defgh” printlength (x, y); Recall that strlen is defined in string.h as returning a value of type size_t, which is an unsigned int. The output of the program is ________. (GATE 2017: 2 Marks) 188. The output of executing the following C program is _______________. #include int total (int v) { static int count = 0 while (v) { count += v & 1; v >> = 1; } return count; } void main ( ) { static int x = 0; int i = 5; for (; i > 0; i — —) { x = x + total (i); }

11/13/2018 10:19:19 AM

Chapter 4  • Programming and Data Structures

}

printf(“%d\n”, x); (GATE 2017: 2 Marks)

189. The pre-order traversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20. Then the post-order traversal of this tree is: (a) 2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20 (b) 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12 (c) 7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12 (d) 7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12 (GATE 2017: 2 Marks) 190. Consider the C program fragment below which is meant to divide x by y using repeated subtractions. The variables x, y, q and r are all unsigned int. while (r >= y) { r = r - y; q = q + 1; }

Which of the following conditions on the variables x, y, q and r before the execution of the fragment will ensure that the loop terminates in a state satisfying the condition x == (y*q + r)? (a) (q == r) && (r == 0) (b) (x > 0) && (r == x) && (y > 0) (c) (q == 0) && (r == x) && (y > 0) (d) (q == 0) && (y > 0) (GATE 2017: 2 Marks)

191. Consider the following snippet of a C program. Assume that swap (&x, &y) exchanges the contents of x and y. int main ( ) { int array[ ] = {3, 5, 1, 4, 6, 2}; int done = 0; int i; while (done == 0) { done = 1; for (i = 0, i = 1; i −−) {    if (array[i] > array[i - 1])   {    swap(&array[i], &array[i - 1]);   done = 0;      }

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 159

159

  } } printf(“%d”, array[3]); } The output of the program is _________. (GATE 2017: 2 Marks) 192. Consider the following C program #include int main(){ int m = 10; int n, n1; n = ++m; n1 = m++; n—-; −−n1; n−=n1; printf(“%d”, n); return 0; }

The output of the program is __________. (GATE 2017: 2 Marks) 193. Consider the following C program. #include #include int main() { char* c = “GATECSIT2017”; char* p = c;  printf(“%d”, (int) strlen (c+2[p]− 6[p]−1)); return 0; } The output of the program is _________. (GATE 2017: 2 Marks) 194. Consider the following C program. # include < stdio.h> struct ournode { char x, y, z; }; int main ( ) { struct Ournode p = { ʽ1’, ʽ0’, ʽa’+2}; struct Ournode *q = &p; printf {“%c, %c”, *((char*)q+1}, *{(char*) q+2}; }

11/13/2018 10:19:19 AM

160

GATE CS AND IT Chapter-wise Solved Papers

The output of this program is: (a) 0, c (b) 0, a + 2 (c) ‘0’, ‘a + 2’ (d) ‘0’, ‘c’ (GATE 2018: 1 Mark) 195. A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let enqueue be implemented by inserting a new node at the head, and dequeue be implemented by deletion of a node from the tail.

Head

Tail

Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure? (a) q (1), q (1) (b) q (1), q (n) (c) q (n), q (1) (d) q (n), q (n) (GATE 2018: 1 Mark)

196. The chromatic number of the following graph is a

198. Consider the following C program: # include Void funl (char*sl, char*s2) Char*tmp; Tmp = sl; s1 = s2; s2 = tmp; } void fun2 (char**s1, char **s2){ char*tmp; tmp = *sl; *s1 = *s2; *s2 = tmp; } int main ( ) { Char*str1 = “Hi”, *str2 = “Bye”; fun1 (str1, str2); printf (“%s %s”, str1, str2); fun2 (&str1, &str2); printf (“%s %s”, str1, str2); The output of the program above is (a) Hi Bye Bye Hi (b) Hi Bye Hi Bye (c) Bye Hi Hi Bye (d) Bye Hi Bye Hi (GATE 2018: 2 Mark)

.

e

c

d

b

f (GATE 2018: 1 Mark)

197. Consider the following C program: #include int counter = 0; int calc {int a, int b} { int c; Counter + + ; if (b ==3) return {a*a*a}; else{ c = calc(a,b/3); return {c*c*c}; } } int main ( ) { calc (4, 81 ); printf{“%d”, counter}; } The output of this program is

. (GATE 2018: 1 Mark)

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 160

199. Let G be a simple undirected graph. Let TD be a depth first search tree of G. Let TB be a breadth first search tree of G. Consider the following statements. (I) No edge of G is a cross edge with respect to TD. (A cross edge in G is between two nodes neither of which is an ancestor of the other in TD.) (II) For every edge (u,v) of G, if u is at depth i and v is at depth j in TB , then i - j = 1.

Which of the statements above must necessarily be true? (a) I only (b) II only (c) Both I and II (d) Neither I nor II (GATE 2018: 2 Mark)

200. Consider the following C code. Assume that unsigned long int type length is 64 bits. unsigned long int fun (unsigned long int n){ unsigned long int i, j = 0, sum = 0; for (i = n; i > 1; i = i/2) j++; for (;j > 1 ; j = j/2) sum++; return (sum); }

11/13/2018 10:19:20 AM

Chapter 4  • Programming and Data Structures

The value returned when we call fun with the input 240 is (a) 4 (c) 6

(b) 5 (d) 40 (GATE 2018: 2 Marks)

201. Consider the following parse tree for the expression a≠b$c$d≠e≠f, involving two binary operators $ and #. # a

# #

S e

S b

f

d c

Which one of the following is correct for the given parse tree? (a) $ has higher precedence and is left associative; associative # is right associative (b) ≠ has higher precedence and is left associative; associative $ is right associative (c) $ has higher precedence and is left associative; associative # is left associative (d)  ≠ has higher precedence and is right associative; associative $ is left associative (GATE 2018: 2 Marks) 202. Consider the following four relational schemas. For each schema, all non-trivial functional dependencies are listed. The underlined attributes are the respective primary keys. Schema I: Registration (rollno, courses) Field ‘courses’ is a set-valued attribute containing the set of courses a student has registered for. Non-trivial functional dependency. rollno → courses

Which one of the relational schemas above is in 3NF but not in BCNF? (a) Schema I (b) Schema II (c) Schema III (d) Schema IV (GATE 2018: 2 Marks) 203. Let G be a graph with 100! Vertices, with each vertex labelled by a distinct permutation of the numbers 1, 2, …, 100. There is an edge between vertices u and v if and only if the label of u can be obtained by swapping two adjacent numbers in the label v. Let y denote the degree of a vertex in G, and z denote the number of connected components in G. Then, y + 10z = . (GATE 2018: 2 Marks) 204. Consider the following program written in pseudo-code. Assume that x and y are integers. Count (x,y) { if (y ! = 1){ if (x ! = 1){ print (“*”); count (x/2, y); } else { y = y − 1 ; count (1024, y) ; } } } 

The number of times that the print statement is executed by the call count (1024,1024) is . (GATE 2018: 2 Marks)

205. The number of possible min-heaps containing each value from {1, 2, 3, 4, 5, 6, 7} exactly once is . (GATE 2018: 2 Marks) 206. Consider the following undirected graph G:

Schema II: Registration (rollno, coursed, email) Non-trivial functional dependencies: rollno, coursed → email email → rollno Schema III: Registration (rollno, coursed, marks, grade) rollno, coursed → marks, grade marks → grade Schema IV: Registration (rollno, coursed, credit) Non-trivial functional dependencies: Rollno, coursed → credit Coursed → credit

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 161

161

4

x

1

3

4

5

4 Choose a value for x that will maximize the number of minimum weight spanning trees (MWSTs) of G. The numbers of MWSTs of this value of x is . (GATE 2018: 2 Marks)

11/13/2018 10:19:20 AM

162

GATE CS AND IT Chapter-wise Solved Papers

Answer Key 1. (a)

2. (a)

3. (d)

4. (c)

5. (a)

6. (c)

7. (c)

8. (b)

9. (b)

10. (a)

11. (b)

12. (a)

13. (b)

14. (b)

15. (c)

16. (d)

17. (b)

18. (b)

19. (d)

20. (d)

21. (b)

22. (b)

23. (a)

24. (a)

25. (c)

26. (b)

27. (d)

28. (d)

29. (a)

30. (c)

31. (d)

32. (a)

33. (b)

34. (d)

35. (d)

36. (c)

37. (d)

38. (d)

39. (b)

40. (c)

41. (b)

42. (d)

43. (c)

44. (a)

45. (d)

46. (c)

47. (a)

48. (a)

49. (c)

50. (c)

51. (d)

52. (d)

53. (c)

54. (c)

55. (c)

56. (b)

57. (a)

58. (d)

59. (c)

60. (a)

61. (d)

62. (b)

63. (c)

64. (c)

65. (a)

66. (a)

67. (b)

68. (a)

69. (d)

70. (b)

71. (a)

72. (c)

73. (c)

74. (d)

75. (a)

76. (c)

77. (d)

78. (a)

79. (d)

80. (b)

81. (c)

82. (a)

83. (a)

84. (b)

85. (d)

86. (c)

87. (c)

88. (a)

89. (b)

90. (a)

91. (a)

92. (c)

93. (b)

94. (d)

95. (d)

96. (b)

97. (a)

98. (b)

99. (c)

100. (c)

101. (c)

102. (b)

103. (b)

104. (c)

105. (d)

106. (a)

107. (d)

108. (a)

109. (c)

110. (d)

111. (c)

112. (b)

113. (b)

114. (b)

115. (d)

116. (c)

117. (a)

118. (a)

119. (c)

120. (d)

121. (c)

122. (c)

123. (a)

124. (d)

125. (a)

126. (c)

127. (d)

128. (c)

129. (9)

130. (b)

131. (a)

132. (a)

133. (a)

134. (7)

135. (a)

136. (a)

137. (a)

138. (c)

139. (a)

140. (a)

141. (d)

142. (d)

143. (a)

144. (a)

145. (d)

146. (19) 147. (51)

148. (c)

149. (199) 150. (b)

151. (c)

152. (c)

153. (a)

154. (d)

155. (b)

156. (b)

157. (a)

158. (c)

159. (15)

161. (230) 162. (140) 163. (c)

164. (10)

165. (0)

166. (d)

167. (2016) 168. (30) 169. (d)

170. (d)

171. (a)

172. (256) 173. (9)

174. (c)

175. (c)

176. (3)

177. (2.32) 178. (64) 179. (b)

180. (b)

181. (d)

182. (d)

183. (a)

184. (c)

185. (a)

186. (c)

187. (3)

188. (23) 189. (b)

190. (c)

191. (3)

192. (0)

193. (2)

194. (a)

195. (b)

196. (3)

197. (4)

198. (a)

200. (b)

201. (a)

202. (b)

203. (109) 204. (10230) 205. (80) 206. (4)

199. (d)

160. (b)

Answers with Explanation 1.

Topic: Arrays (a)  An n × n array v is defined as follows:

2.

Topic: Arrays (a)  Given a C program struct node { int i; float j; }; struct node *s[10]; s is an array, each element of which is a pointer to a structure of type node.

3.

Topic: Programming in C (d)  The correct match is: X: m = malloc(5); m = NULL – 3: lost memory Y: free(n); n → value = 5; – 1: using dangling pointers Z: char *p; *p = ‘a’; – 2: using uninitialized pointers

v[i, j] = i – j for all i, j, 1 ≤ i ≤ n, 1 ≤ j ≤ n So, we have 0

–1

–2

–3

1

0

2

1

3

2

. . .

. . .

. . .

. . .

n

n–1

n–2

n–3

0 0

…………..

–n

…………..

–(n – 1)

…………..

–(n – 2)

…………..

–(n – 3) . . .

…………..

0

Therefore, sum of the elements of array v is zero.

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 162

11/13/2018 10:19:21 AM

Chapter 4  • Programming and Data Structures

4.

Topic: Binary Search Trees (c)  We have, X as a node, Y as left subtree (can be null or further nested and Z as right subtree (can be null or further nested). A binary tree is a tree data structure in which each node has at most two children called left and right child. Here, option (c) represents a valid binary tree.

2

5.

5

4

6

7

Topic: Programming in C (a)  Aliasing in the context of programming languages refers to multiple variables having the same memory location.

6.

Topic: Programming in C (c)  For the given C program we have Short s[5] is array of length 5 – this will take 10 bytes. Union s[5] will have size – max of float y and long z, that is, max(4, 8) = 8 bytes Therefore, memory requirement for variable t is 10 + 8 = 18 bytes.

7.

Topic: Programming in C (c)  The basic element recognized by the compiler is taken. It is a source-program text that compiler does not break into component elements. Identifiers, keywords, constants, operators, string literals and other separators are tokens. In the given C statement: printf (“i = %d, &i = %x”, i, &i); there are 10 tokens.

8.

9.

In preorder traversal – Root node is visited first, then left node and right node is visited in the last. In inorder traversal – Left node is visited first, then root node and right node is visited in the last. So last visited node will always be same for inorder and preorder traversal. Therefore, LASTIN = LASTPRE 10. Topic: Programming in C (a)  Given C programming

1

3

163

Topic: Binary Search Trees (b)  B+ tress are preferred to binary trees in database because disk access is much slower than memory access. B+ trees have very high fan-out which reduces the number of I/O operations required to find an element in the tree. Topic: Binary Search Trees (b)  In postorder traversal – Left node is visited first, right node is visited next and root node is visited in the last.

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 163

int incr (int i) { static int count = 0; count = count + i; return (count); }

main ( ) {    int i, j; for (i = 0; i < = 4, i++) j = incl (i); } Input and output of the given C programming are i = 0; incr (0) ⇒ count = 0 i = 1; incr (1) ⇒ count = 1 i = 2; incr (2) ⇒ count = 2 + 1 = 3 i = 3; incr (3) ⇒ count = 3 + 3 = 6 i = 4; incr (4) ⇒ count = 6 + 4 = 10 So, output is 10. 11. Topic: Binary Heaps (b)  A binary tree is represented as an array by storing elements in an array and using their relative positions to represent child-parent relationships. For an n element binary heap where elements are stored from index i to index n of the array, the index of the i parent is . 2 12. Topic: Graphs (a)  An undirected graph is a graph in which all nodes are connected together and edges have no orientation. In an undirected graph, there can be maximum of n( n -1) edges and we can choose to use any of the 2 n( n -1) edges to make graph. 2

11/13/2018 10:19:22 AM

164

GATE CS AND IT Chapter-wise Solved Papers

So, total number of undirected graphs with n vertices is n( n - 1) . 2 2 13. Topic: Stacks (b)  A queue can be implemented using two stacks. Stack 1 is used to push all elements. Stack 2 is used to push all elements from stack 1 to stack 2 and pop the element from stack 2 and return it. 14. Topic: Programming in C (b)  In the given code, parameters of function func1 are passed using call by reference x = 10: y = 3; func1 (y, x, x);  implies func1 (3, 10, 10); func (x, y, z) { } implies y points to x That is, x = 3 x points to y  That is, y = 10 x points to z  That is, z = 10 So, y = y + 4 ⇒ y = 10 + 4 = 14 z = x + y + z ⇒ z = 3 + 14 + 14 = 31

16. Topic: Programming in C (d)  In dynamic scoping, also called run time scoping, the free variables are referred as the variables in the most recent frame of function call stack. The program will print 4. 17. Topic: Graphs (b)  A graph is a set of vertices and a collection of edges such that each connects a pair of vertices. In an undirected graph there is no direction in the edges that link the vertices in the graph. Maximum number of edges in a n-node undirected graph without self-loops is n( n -1) . 2 18. Topic: Arrays (b)  We have declaration of a two-dimensional array in C: Char a[100][100], Array is stored starting from memory address 0. Address of a [ 40][50] = Base address + 40 × 100 × Element size + 50 × Element size

Therefore, x = z = 31 y=3 15. Topic: Programming in C (c)  P1 and P2 functions will cause problems with pointers. [P1] int*g(void) { int x = 10; return (&x); } Here, x is local variable to g( ). g returns pointer to variable x which has no scope outside g ( ). Therefore, &x becomes invalid. Now, [P2] int*g(void) { int*px; *px = 10; return px; } px has not been allocated memory. [P3] function works without any errors.

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 164

= 0 + 40 × 100 × 1 + 50 × 1 = 4000 + 50 = 4050 Address of a [40][50] = 4050 19. Topic: Trees (d)  A rooted tree is a tree in which a special node called root of the tree is singled out. The number of leaf nodes in a rooted tree of n nodes with each node having 0 or 3 ( 2n + 1) . children is 3 20. Topic: Trees (d)  Let the maximum possible height of a tree with n nodes be represented by H(n). Now using recursion, maximum possible value of H(n) will be ⎛ 2n ⎞ H ( n) = H ⎜ ⎟ + 1 ⎝ 3⎠ Solving recursion gives H ( n) = log3/ 2 n Therefore, maximum possible height of tree is log3/ 2 n.

11/13/2018 10:19:24 AM

Chapter 4  • Programming and Data Structures

21. Topic: Programming in C (b)  The C language is a context sensitive language. A context sensitive language is a language that can be defined by context sensitive grammar. It is equivalent to linear bounded non-deterministic turing machine also called linear bounded automaton. 22. Topic: Programming in C (b)  Applying iterative method: i=1

p = x/1

s=1+x

i=2

p = x * x/2

s = 1 + x + x2/2

25. Topic: Binary Search Trees (c)  Inorder traversal of a binary search tree arranges the elements in increasing order. 26. Topic: Binary Heaps (b)  Time taken by heap to insert and delete n elements is O(n). Only balanced binary search tree takes O(log n) time for insertion and deletion. 27. Topic: Trees (d)  Time taken by Pop and Push operations : X + X = 2X Time delay between two stack operations = Y Total time taken = 2X + Y

s = 1 + x + x2/2 + x3/ 6 From the above iterations: s = 1 + x + x2/2 + x3/ 6 + … s = 1 + x + x2/2! + x3/ 3! + x4/ 4! + … = ex i=3

p = x3/ 6

28. Topic: Programming in C (d)  In static scoping, the variables and values are resolved at compile time. P(100 + 5) = P(105)

23. Topic: Programming in C (a)  B[1] is address of second one dimensional array. Address can not be assigned to simple variable. So, it will produce compile time error.

Print x + 10 will print 115 Print x will print 105 29. Topic: Programming in C (a)  In dynamic scoping, the variables and values are resolved at run time. P(100 + 5) = P(105) First Print x + 10 will print 115 Second Print x will update x = 200 + 20 = 220 and will print 220.

24. Topic: Binary Search Trees (a)  Given that:  T(n) =

165

n

∑T (k - 1)T ( x ) k =0

T(n) = T(x) [T(0) + … + T(n−1)] x=n−k+1

30. Topic: Trees (c)  2-3-4 B tree has minimum degree 2 and maximum 4. According to max degree, atmost 3 elements can be there in node.

L

P

L

U

P

G VXZ

VXZ BGH

BHI N

N

QT

Q

This node will spilt due to 4 elements Result will be

I

BGH

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 165

L

P

N

U

Q T

VXZ

11/13/2018 10:19:24 AM

166

GATE CS AND IT Chapter-wise Solved Papers

31. Topic: Arrays (d)  The condition ! A[j] is equivalent to A[j] == 0. But in array A no element is zero. So, it will print nothing. 32. Topic: Programming in C (a)  P(&x) where x = 5

Both stacks will grow from both ends and if any of the stack top reaches near to the other top then stacks are full. So, the condition will be top1 = top2 −1 (given that top1 < top2) 39. Topic: Binary Search Trees (b)

x = *y + 2 = 5 + 2 = 7

10

Q(x) = Q (7) → Here z = 7

1

15

→ z = z + x = 7 + 5 = 12 → Print 12

3 12 16

*y = x − 1 = 7 − 1 = 6 print(x) = print 7 Value returned by function P is 6. So, main will print 6. So, output of program is 12 7 6. 33. Topic: Linked Lists (b)  The given function returns 1 if the elements are unique and are sorted in increasing order. 34. Topic: Programming in C (d)  Px = newQ(); Qy = newQ(); Pz = newQ();

x : f(1); print 2 * i = 2

((P)y) : f(1);

z : f(1) print 2 * i = 2

It will print 2 because typecast to parent class cannot prevent overriding. So, function f(1) of class Q will be called not f(1) of class P. 35. Topic: Linked Lists (d)  The shared, dynamic linked libraries use smaller sizes of executable files, lesser overall page fault rate and faster startup of programs. 36. Topic: Programming in C (c)  The goal of structured programming is that the user can control the flow according his requirement. 37. Topic: Programming in C (d)  The value will not be interchanged. The values are passed by value, not by reference. 38. Topic: Stacks (d)  If we are to use space efficiently then size of any stack can be more than MAXSIZE/2.

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 166

5 40. Topic: Queues (c)  Mod 10 of all the elements in the list is given below: 4322 mod 10 = 2 1334 mod 10 = 4 1471 mod 10 = 1 9679 mod 10 = 9 1989 mod 10 = 9 6171 mod 10 = 1 6173 mod 10 = 3 4199 mod 10 = 9 From the list, it is clearly seen that 9679, 1989 and 4199 have same hash values 9. But, 1471 and 6171 have hash value of 1. So, statements I and II are correct. 41. Topic: Stacks (b)  Stack is used to check balancing of parenthesis. 42. Topic: Trees (d)  Breath first search gives the level order traversal. 43. Topic: Programming in C (c) Iteration

n

i

0

1

1

1

1+1=2

2

2

2+2=4

3

3

4+3=7

4

4

7 ≥ 5 Return 7

11/13/2018 10:19:24 AM

Chapter 4  • Programming and Data Structures

44. Topic: Recursion (a)  A loop invariant is a condition that must be true before and after each iteration of a loop. So, n = d1d2… dm−1 and rev = dmdm−1…dm−1+1 provides the correct loop invariant condition. 45. Topic: Programming in C (d)  In C value of pointer variable cannot be assigned to ­normal character variable. 46. Topic: Linked Lists (c)  Required condition is not possible with single pointer. 47. Topic: Binary Heaps (a)  Root is greater than both left and right children. 32

30

15

20

of the tree. Note that this implementation follows the convention where height of a single node is 0. 52. Topic: Recursion (d)  Functional languages have no side effects and follow the declarative approach. Logic languages are declarative and used for theorem proving. Objectoriented languages use abstract data types. Imperative languages are command based and procedural. 53. Topic: Programming in C (c) ⇒ int ( * f) (int * ) ⇒ return type is int, (*f) means pointer to function with argument as integer pointer. 54. Topic: Recursion (c)  ADT is user-defined data type that specifies the set of operations. 55. Topic: Programming in C (c)  Both are declarative because we declare variable before use.

25

12

167

16

56. Topic: Programming in C (b)  Common property of OOP is abstraction and encapsulation and polymorphism in the presence of inheritance. 57. Topic: Arrays (a)  We need to know the frequency of numbers above 50. So, array of size 50 will be sufficient.

48. Topic: Trees (a) a + b × c−d ∧ e ∧ f a+b×c−d∧ef∧ a+b×c−def∧∧ a+bc×−def∧∧ abc×+−def∧∧ abc×+def∧∧− 49. Topic: Programming in C (c)  The given program finds greatest common divisor of x and y. 50. Topic: Programming in C (c)  The given program finds the square root of program. 51. Topic: Trees (d)  DoSomething( ) returns max(height of left child + 1, height of left child + 1). So given that pointer to root of tree is passed to DoSomething( ), it will return height

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 167

58. Topic: Recursion (d) Iteration

k

j

foo(n, sum)

1, n = 2048, Sum = 0

8

204

foo(204,8)

2, n = 204, Sum = 8

4

20

foo(20, 12)

3, n= 20, Sum = 12

0

2

foo(2,12)

4, n = 2, Sum = 12

2

0

foo(0,14), for this call function will return.

For recursive function calls, stack is used to store values. So the values will be printed as 2 0 4 8. And value of sum is 0. Because sum is passed by value not by reference. Changes are not reflected back to the main program.

11/13/2018 10:19:25 AM

168

GATE CS AND IT Chapter-wise Solved Papers

59. Topic: Programming in C (c)  Compilation error will be thrown by deleting line 1. Function is called before it is declared anywhere. 60. Topic: Binary Search Trees (a)  Inorder traversal is always sorted in increasing order.

/

/

8 5 / / 3 2 1 7

8 / 3 2

7 / 1 5

/

/ / 3 2 1

/

/

/ 3 2

5

/

8

10 /

/

5

10 /

/

/

/

/ 8

/

61. Topic: Binary Heaps (d) 10 10

Level order traversal is 10, 8, 7, 3, 2, 1, 5 62. Topic: Binary Search Trees (b)  Number of distinct binary trees = 1/1 + n (2nCn) = 14 63. Topic: Trees (c)  If there are n internal nodes, then number of leave nodes will be n(k − 1) + 1. 64. Topic: Programming in C (c)  Misspellings of int keyword in line 2 and there should be ‘for’ instead of ‘fro’ in line 3. 65. Topic: Graphs (a)  Minimum weight edge is included in minimum spanning tree. 66. Topic: Graphs (a)  Path from s to t in the minimum weighted spanning tree is the path of minimum congestion. 67. Topic: Binary Heaps (b)  In max heap smallest element will be present in the leaf node. To get it, n nodes need to be traversed.

⇒n+m ⇒n+m≤x ⇒ n + m ≤ x < 2n and 2m ≤ y ≤ n + m 72. Topic: Arrays (c)  x[i] ∧ ~y[i]) = only 1’s in x where corresponding entry in y is 0 → x − y ~x[i] ∧ y[i] = only 1’ s in y where corresponding entry in x is 0 → y − x. The operator ‘∨’ results in union of the above two sets. 73. Topic: Arrays (c)  To find the largest span (i, j), average Θ(n) time and space is required. 74. Topic: Programming in C (d)  S1: True, both work1 and work2 perform the same task S2: True, work2 will improve the performance because it reduces calculations using temporary variables to store results. S1 and S2 are correct statements. 75. Topic: Programming in C (a)  S1 and S2 are correct statements. 76. Topic: Programming in C (c)  S2: May generate segmentation fault if value at pointers px or py is constant or px or py points to a memory location that is invalid. S4: May not work for all inputs as arithmetic overflow can occur. 77. Topic: Binary Heaps (d)  The 3-ary max heap can be formed by 9, 5, 6, 8, 3, 1. 9 5 6 8

68. Topic: Graphs (a)  There must exist a vertex w adjacent to both u and v in G. So, option (a) is true. 69. Topic: Binary Search Trees (d)  In case of right skewed tree, the size of array will be 2n − 1. 70. Topic: Arrays (b)  Best algorithm to find leader is pass the array from right side. With each traversal of node, maximum will be updated. Hence, leader can be updated in Θ(n). So, option (b) is correct. 71. Topic: Queues (a)  Number of push operation = insert operation + delete operation

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 168

3

1

78. Topic: Binary Heaps (a)  After inserting 7, 2, 10, 4, the heap sequence will be 10, 7, 9, 8, 3, 1, 5, 2, 6, 4. 79. Topic: Programming in C (d)  Check using values n = 3,4,5…. Let n = 5, we have the following 4 comparisons: 1 < = 5 (T) 2 < = 5 (T) 4 < = 5 (T) 8 < = 5 (F) [log2 n]+1

11/13/2018 10:19:25 AM

Chapter 4  • Programming and Data Structures

80. Topic: Trees (b)  Maximum number of binary trees = 2n − n = 23 − 3 = 5 81. Topic: Trees (c)  Maximum number of node with height h = 1 + 2 + 4 + ….. + 2h = 2h+1 − 1 82. Topic: Graphs (a) Expression

TOS

8

8

2

8,2

3

8,2,3



8,8

/

1

2

1,2

3

1,2,3

*

1,6

Top of stack contain 1,6. 83. Topic: Trees (a)  Construct equivalent tree from inorder and preorder ­traversal. a / / b c / / / / d e f g Postorder traversal is: d e b f g c a 84. Topic: Queues (b)  Hash function is: (3x + 4) mod 7 X = 1 7 mod 7 = 0 X = 3 13 mod 7 = 6 X = 8 28 mod 7 = 0 since 0 occupied, it will be on 1st position X = 10 34 mod 7 = 6 since 6,0,1 is occupied it will at 2nd position So, 1 8 10 - - - 3 85. Topic: Programming in C (d) f(5)

r = 5 , 2 + f(3)

f(3)

2 + 5 + f(2)

f(2)

7 + 5 + f(1)

f(1)

12 + 5 + f(0)

f(0)

17 + 1 = 18

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 169

169

86. Topic: Trees (c)     I [n − 1] + 1 = L N = (L − 1)/I + 1 = 40/10 + 1 = 5 87. Topic: Binary Search Trees (c)  As we can see in else part of given program, left and right subtrees are traversed recursively and value is incremented if they have leaf nodes. 88. Topic: Binary Heaps (a)  Inserting an element in binary tree takes Θ(1) and binary search takes Θ(log2 n). 89. Topic: Arrays (b)  Using divide and conquer technique problem is divided into two parts of n/2. T(n) = 2 T(n/2) + 2 Solution of this equation is 3/2 n − 2 comparisons 90. Topic: Programming in C (a)  In option A, 3 > 4 is false so it moves to else part. In else condition, 4 > 2 is true and 4 will be printed. 91. Topic: Queues (a)  In BFS, all the children of node will be traversed first. 92. Topic: Binary Search Trees (c)  Step 1: The last element in the postorder traversal P will act as the root element. Step 2: Now in P the elements that are smaller than root will form the left subtree Step 3: The elements in P that are greater than root will form the right subtree Step 4: Binary search could be used to find the left and right tree elements 93. Topic: Binary Heaps (b)  Time require to re-heapify is Θ(n). 94. Topic: Programming in C (d)  ** ppz = 4 +1 = 5 z=5 y=5+2=7 x = 7 + 3 = 10 x + y + z = 10 + 7 + 5 = 22 95. Topic: Programming in C (d)  ?1 checks the end of string, if not end of string it calls reverse function. ?2 prints the reverse string.

11/13/2018 10:19:26 AM

170

GATE CS AND IT Chapter-wise Solved Papers

96. Topic: Linked Lists (b)  The program is simply swapping two consecutive numbers. Here, input: 1, 2, 3, 4, 5, 6, 7 Output: 2, 1, 4, 3, 6, 5, 7

12

/

/

8

15*30

/ //

/ /

97. Topic: Trees (a)  Insertion of 3 keys 10 20 30 Insertion of 4th key (1st split)

5

1 0 1 3 1 7 * 2 0 40

98. Topic: Recursion (b)  For f1 recurrence relation is, T (n) = T(n −1) + T(n −2)

30 / / 10*20 40 Insertion of 5th key no split To maximize splits, let us insert a value in a node that has key in access. Let us insert 5

/

30 5*10*20

40

Insertion of 6th key (2nd Split) To maximize splits, let us insert a value in a node that has key in access. Let us insert 6 8 *30 5 10 * 20 40 Insertion of 7th key To maximize splits, let us insert a value in a node that has key in access. Let us insert 15 8*30 5 10 *15* 20 40 Insertion of 8th key (3rd Split) To maximize splits, let us insert a value in a node that has key in access. Let us insert 12 8*12*30 5 10 15*20 40 Insertion of 9th key To maximize splits, let us insert a value in a node that has key in access. Let us insert 17 8*12*30 / / / 5 10 15*17*20 40 Insertion of 10th key (4th and 5th Splits)

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 170

To maximize splits, let us insert a value in a node that has key in access. Let us insert 13

This type of relations has non-polynomial complexity. Only option (b) looks closest. 99. Topic: Recursion (c)  Implementing the code will give the output 1640, 1640. 100. Topic: Binary Search Trees (c)  Binary search fails for Y [2 2 2 2 2 2 2 2 2 2] and x>2 101. Topic: Binary Search Trees (c)  Change line 6 according to option (a) to correct the ­program. 102. Topic: Recursion (b) Iteration

n

*f_p

t

f

5

15 → 3

5

8 → Ans

4

15 → 2

3

5

3

15 → 1

2

3

2

15 → 1

1

2

1

15

The function will return 8. 103. Topic: Trees (b)  The height of an AVL tree storing n items is Θ(log(n)). 104. Topic: Binary Heaps (c)  Conditions for max heap: Data at every node should be greater than its children nodes Left child is at 2i + 1 and right at 2i + 2 105. Topic: Binary Heaps (d)  Deletion can be done by following steps: • Replace the root with last node • Re-heapify the tree

11/13/2018 10:19:27 AM

171

Chapter 4  • Programming and Data Structures

100

101

102

103

104

105

106

107

G

A

T

E

2

0

1

1

/

14 /

12

/

2011 will be printed.

/ 8

/

/

/

/ 13

10

106. Topic: Trees (a)  The given tree is called full binary tree which has 0 or 2 children. No node will have exactly one child node. 107. Topic: Programming in C (d)  i and j are passed by address, any modification by function will be reflected back. When p = q means address of q is changed. *p = 2 will modify value of q to 2. 108. Topic: Binary Heaps (a)  Runtime environment require dynamic memory allocation. Heap data structure is used for dynamic memory allocation. 109. Topic: Programming in C (c) f(a,6)

12 + f(7,5)

f(7,5)

12 + 7 − f(13,4)

f(13,4)

12 + 7 − (13 − f(4,3))

f(4,3)

12 + 7 − (13 − ( 4 + f(11,2)))

f(11,2)

12 + 7 − (13 − (4 + 11 − f(6,1)))

f(6,1)

12 + 7 − (13 − (4 + 11 − 6 )) = 15

110. Topic: Linked Lists (d)  When the while loop ends, q contains address of second last node and p contains address of last node. So, we need to do the following things after while loop.   (i)  Set next of q as NULL (q->next = NULL). (ii)  Set next of p as head (p->next = head). (iii)  Make head as p (head = p) Step (ii) must be performed before step (iii). If we change head first, then we lose track of head node in the original linked list. 111. Topic: Programming in C (c)  Let base address is 100 So, 100 + E − A = 104

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 171

112. Topic: Binary Heaps (b)  Heap is also complete binary tree. 113. Topic: Binary Search Trees (b)  Given expression is: Precedence of ↑ is higher, so first the sub-expression (3↑ 4 ↑3) will be solved. In this 4 ↑ 3 will be solved first because ↑ is right to left associative. So, the expression will be solved as ((7 ↓(3↑(4 ↑3))). ↓ operator is left to right associative, so ((7 ↓(3↑(4 ↑3))) will be solved first. Build the in order expression considering operator precedence. ((7 ↓(3↑(4 ↑3)))↓2 114. Topic: Recursion (b) n = 345 and r = 10

345 % 10 + foo(34,10) = 5 + ….

n = 34, r = 10

5 + 4 + foo(3,10)

n = 3, r = 10

9 + 3 + foo (0,10)

n = 0, r = 10

12 + 0 = 12

115. Topic: Recursion (d) n = 513 and r = 2

513 % 2 + foo(256, 2) = 1 + ….

n = 256, r = 2

1 + 0 + foo(128, 2)

n = 128, r = 2

1 + foo (64, 2)

n = 64, r = 2

1 + foo(32, 2)

….. n = 2, r = 2

…. 1 + foo(1, 2)

n = 1, r = 2

1+1+0=2

116. Topic: Programming in C (c)  No break statement is available, it will execute all the cases. Choice A Choice B No Choice 117. Topic: Queues (a)  Condition for queue full: (Rear + 1) mod n = = front Condition for queue free: Rear = = front

11/13/2018 10:19:28 AM

172

GATE CS AND IT Chapter-wise Solved Papers

118. Topic: Binary Search Trees (a)  The above pseudocode is traversing tree to calculate the tree height. Box 1: it should be replaced with the code that will traverse the right sub tree, so B1: (1 + height(n → right)) Box2: Now both left and right sub tree height is calculated. So, the maximum out of both will be chosen. B2: (1 + max(h1, h2)).

126. Topic: Graphs (c)  By following the given path in graph, maximum possible depth is 19.

119. Topic: Programming in C (c)  A is static variable, its value will be preserved between different function calls. First call to prtFun ( ): a = 2 and b = 1 a=2+2=4 Print 4 2 Second call to prtFun ( ): a = 4 and b = 1 a=4+2=6 Print 6 2 Main printf function prints: 2 0

127. Topic: Programming in C (d)  In the program, pi is a pointer variable that contains the address of i. scanf gets the value at address of i and printf prints value 5 more than i.

120. Topic: Programming in C (d)  Line 2 is replaced with register storage class, the values will not be preserved. So, it will print 4 2 4 2 2 0 121. Topic: Graphs (c)  P(e) = (1/2) Number of ways vertices can be chosen of cycle three = 8 C3 × (1/2)3 = 7 122. Topic: Graphs (c)  Both statements P and Q are correct. 123. Topic: Recursion (a)  For p = 5, f(6, 4) * 6 = 9 * 8 * 7 * 6 = 3024 124. Topic: Binary Search Trees (d)  Postorder traversal: Left Right Root 15, 10, 23, 25, 20, 35, 42, 39, 30 is the correct order. 125. Topic: Queues (a)  Any combination of n Enqueue and Dequeue operations will take Q(n).

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 172

128. Topic: Linked Lists (c)  Worst case of quick sort is when the list is already sorted. It requires n2 comparisons. Whereas an unsorted list requires nlogn comparisons. List 1 is sorted, so the number of comparisons are more for list 1. Therefore, (c) is the correct option (t1 > t2). 129. Topic: Programming in C (9)  The given function has a while loop and termination condition for loop is, until num will not be zero. Function have a count variable which will count number of times will execute. Every time loop is executed, a right shift will be performed on the number. Initially, num = 435, binary equivalent = 110110011. After first execution num = 011011001 and count = 1 After second execution num = 001101100 and count = 2 After third execution num = 000110110 and count = 3 After eight execution num = 000000001 and count = 8 After nine execution num = 000000000 and count = 9 The function will return count = 9. 130. Topic: Recursion (b)    P = nC3 = n × (n − 1) × (n − 2)/6 Computing n × (n − 1) × (n − 2) together can go beyond the range; so, options (a) and (d) are not true. If n is even or odd then n × (n − 1)/2 will always result in integer value, thus more accuracy whereas in the case of n × (n − 1)/3, it is not certain to get integer always so less accuracy. Hence, option (b) is more accurate.

11/13/2018 10:19:28 AM

Chapter 4  • Programming and Data Structures

131. Topic: Queues (a)

8 3

8

5

5

3

2

2

10 5 2

This Z = Z + E[k] calculates the sum of sub-array and compare it with Y. If sum is greater, then it is assigned to the Y. Hence, it calculates maximum possible sum of any subarray.

1

10

8 3

137. Topic: Arrays (a)  The following code calculates sum of all the elements in array. for(i = 0; i < size; i++) Y = Y + E[i];

10

10

1

8 7

3

138. Topic: Programming in C (c)

7 2 1

5

132. Topic: Programming in C (a)  Dynamic memory allocation is done at the run time, not at compile time. 133. Topic: Arrays (a)  A[i][j] and A[j][i] exchanging their values. Perform the operation for atleast three iterations. 134. Topic: Programming in C (7)   P(X) = X 3(X 2 + 4) + 6X + 4 X 2 = 1 X 3 = 1 X 3 × (X 2 + 4) = One multiplication + One addition = 2 operations 6X = 1 multiplication 5 + 2 additions = 7 operations 135. Topic: Trees (a)  Left Root Middle Right SQPTRWUV 136. Topic: Linked Lists (a) 0 1 2 3 4 5 6 7 8

28 20 × 12 × 5 × 15

19

33 ×

Length 0 3 10 × 1 1 0 1 2 0

17 ×

1 9

Thus, average length =

9 =1 9

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 173

173

∑ ( n - 1) + ∑ ( n - 2) + ∑ 1 =

n( n - 1)( n + 1) 6

139. Topic: Programming in C (a)  Let X be declared as X[A][B][C] From t0 = i*1024, we have A * B = 1024. From t1 = j*32, we have C*(size of Type) = 32. From t2 = k*4, we have size of Type = 4. Therefore, Type = int, A = 32, B = 32 and C = 8. 140. Topic: Recursion (a)  Using same index:

97 × 97 × 97 100 × 100 × 100

141. Topic: Trees (d)  Pseudocode recursively finds the leaf nodes and counts them. 142. Topic: Arrays (b)  Checking the logic of code clearly show that binary search has been implemented. 143. Topic: Trees (a)  If height of the binary tree is h, then Minimum number of nodes in a tree = h + 1 Maximum number of nodes = 2h+1 − 1 Here, h = 5 Therefore, minimum nodes = 5 + 1 = 6 maximum nodes = 26 − 1 = 63 Hence, answer is 63 and 6, respectively. 144. Topic: Binary Search Trees (a)  Inorder traversal of tree is the sorted order of nodes of the tree. Check the given sequences; the one which is in sorted order is the correct inorder traversal. 145. Topic: Programming in C (d)  If condition fails when the space is encountered, then output will be DCBA.

11/13/2018 10:19:29 AM

174

GATE CS AND IT Chapter-wise Solved Papers

146. Topic: Binary Search Trees (19)  The number of nodes with two children is always one less than the number of leaf nodes. Here, Leaf nodes = 20 ⇒ Number of two children nodes = 19.

152. Topic: Graphs (c) p =q +r 1

147. Topic: Programming in C (51)  For n = 1, f (n) = 1 For n > 1, f (n) = 1 +



n -1 k =1

u =s ∗v f (k ) f (n - k )

f(5) = 51

2

v =r +u

3

148. Topic: Programming in C (c)  The given character array representation: 4

\0

1

2

3

4

100

101

102

103

2

0

4

100

101

102

103

Output will be: 1204 149. Topic: Binary Search Trees (199)  Leaf (p) = 200 Total nodes = 2p − 1 = 399 Nodes with degree exactly two children = 399 − 200 = 199 150. Topic: Binary Search Trees (b)  67 is at the lowest level. 71 65

83

67

6

10

10

5

15 +

2

3

4

5

6

7

8

9

10

11

12

As given in question, integer takes 4 bytes to store Here, X + 3 ⇒ 2000 + (3 × 3) × 4 = 2036 *(X + 3) ⇒ Value at address 2036, %u will print the address only, that is, 2036 *(X + 2) + 3 ⇒ 2000 + (3 × 2)4 + 3 × 4 = 2036

155. Topic: Programming in C (b)  In this program, q counts the number of times y is subtracted from x and at the remaining r value will act as remainder. So, x = qy + r and r < y.

151. Topic: Graphs (c)

10

1

154. Topic: Queues (d)  First for loop will execute n times, the others are sequential not nested, so both execute log(n) and log(p) times but the value returned by fun1 is “q” which is calculated in the second loop. so, n × (log(p)), [where p = log (n)] ⇒ n log (log n)times.

84

69

q =v +r

153. Topic: Programming in C (a)

\0

1

q =s ∗u

Checking the three conditions given in question, r is live at block2 since r is used in block4 and has a path from block2 to block4 in the control flow graph. Also there isn’t any modification of r in the path. Hence, r is live at block2. Similarly, check for u.

s1: Base address = 100 p = 100 + 2 = 102 *p = 102 = 0

5

s =p +q

60

60

10

15

15

60

6

15 /

Ch wise GATE_CSIT_CH04_Programming and Data Structures.indd 174

8 150 ∗

150 8

142 −

156. Topic: Graphs (b)  Number of nodes = 6 Number of edges = 7

11/13/2018 10:19:30 AM

175

Chapter 4  • Programming and Data Structures

161. Topic: Programming in C (230)   x = x + f 1() + f 2() + f 3() + f 2() After evaluating the functions through the given code, we get f1() ⇒ 26 f2() ⇒ 51 f3() ⇒ 100 f2() ⇒ 52 [Static variable is there in f2(). Thus, its value is initialized only once and the value computed in 1st call of f2() is retained in the next call of function]

i=1 j=1 t1 = 5 * i t2 = t1 + j t3 = 4 * t2 t4 = t3 a[t4] = −1 j = j+1 if j d(r, v) (c) d(r, u) ≤ d(r, v) (d) None of the above (GATE 2001: 2 Marks) 8. Consider the following algorithm for searching for a given number x in an unsorted array A[1…n] having n distinct values: 1. Choose an i uniformly at random from 1…n; 2. If A[i] = x then Stop else Goto 1;

11/13/2018 4:32:30 PM

Chapter 5  • Algorithms



Assuming that x is present A, what is the expected n­ umber of comparisons made by the algorithm before it ­terminates? (a) n (b) n – 1 n (c) 2n (d) 2 (GATE 2002: 2 Marks)

9. The running time of the following algorithm

Procedure A(n) If n < = 2 return (1) else return ( A( n )); is best described by (a) O(n) (b) O(log n) (c) O(log log n) (d) O(1) (GATE 2002: 2 Marks)

10. Consider the following three claims: (I) (n + k)m = Q(nm), where k and m are constants (II) 2n+1 = O(2n) (III) 22n+1 = O(2n) Which of these claims is correct? (a) I and II (b) I and III (c) II and III (d) I, II and III (GATE 2003: 1 Mark) 11. Let G be an arbitrary graph with n nodes and k components. If a vertex is removed from G, the number of components in the resultant graph must necessarily lie between (a) k and n (b) k − 1 and k + 1 (c) k − 1 and n − 1 (d) k + 1 and n − k (GATE 2003: 1 Mark)

(a) (b) (c) (d)

185

I, II and IV only I and IV only II, III and IV only I, III and IV only (GATE 2003: 1 Mark)

13. The usual Q(n2) implementation of insertion sort to sort an array uses linear search to identify the position where an element is to be inserted into the already sorted part of the array. If, instead, we use binary search to identify the position, the worst-case running time will (a) remain Q(n2) (b) become Q(n(log n)2) (c) become Q(n log n) (d) become Q(n) (GATE 2003: 1 Mark) 14. In a heap with n elements with the smallest element at the root, the 7th smallest element can be found in time (a) Q(n log n) (b) Q(n) (c) Q(log n) (d) Q(1) (GATE 2003: 1 Mark) 15. It has not been proved yet that P = NP. Consider the language L defined as follows: ⎧(0 + 1)* if P = NP L=⎨ otherwise ⎩ f

12. Consider the following graph: a

Which of the following statements is true? (a) L is recursive. (b)  L is recursively enumerable but not recursive. (c) L is not recursively enumerable. (d) Whether L is recursive or not will be known after we find out if P = NP. (GATE 2003: 1 Mark)

16. A graph G = (V, E ) satisfies |E | ≤ 3 |V | −6. The mindegree of G is defined as e

b

min{degree(v )}

f

v∈ V

h

g Among the following sequences: (I) a b e g h f (II) a b f e h g   (III) a b f h g e (IV) a f g h b e

Which are depth-first traversals of the above graph?

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 185

Therefore, min-degree of G cannot be (a) 3 (b) 4 (c) 5 (d) 6 (GATE 2003: 2 Marks)

17. Consider two languages L1 and L2, each on the alphabet ∑. Let f: ∑ → ∑ be a polynomial time computable bijection such that (∀ x)[x ∈ L1 iff f (x) ∈ L2]. Further, let f −1 also be polynomial time computable. Which of the following CANNOT be true?

11/13/2018 10:29:25 AM

186

GATE CS AND IT Chapter-wise Solved Papers

(a) (b) (c) (d)

L1 ∈ P and L2 is finite L1 ∈ NP and L2 ∈ P L1 is undecidable and L2 is decidable L1 is recursively enumerable and L2 is recursive (GATE 2003: 2 Marks)

22. What is the weight of a minimum spanning tree of the following graph? 2

19

g

j

b 6

8

14

3

Common Data Questions 18 and 19: In a permutation a1 ... an of distinct integers, an inversion is a pair (ai, aj) such that i  aj .

2

1 a

2

(c)

i 8

21. Let G = (V, E) be an undirected graph with a subgraph G1 = (V1, E1). Weights are assigned to edges of G as f­ ollows:

A single-source shortest path algorithm is executed on the weighted graph (V, E, w) with an arbitrary vertex v1 of V1 as the source. Which of the following can always be inferred from the path costs computed? (a) Number of edges in the shortest paths from v1 to all vertices of G. (b) G1 is connected. (c) V1 forms a clique in G. (d) G1 is a tree. (GATE 2003: 2 Marks)

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 186

9

A f 2

e

(a) 29 (c) 38

(b) 31 (d) 41 (GATE 2003: 2 Marks)

23. The following are the starting and ending times of activities A, B, C, D, E, F, G and H, respectively, in chronological order: ‘as bs as ae ds ae es fs be de gs ee fe hs ge he’ Here, xs denotes the starting time and xe denotes the ending time of activity X. We need to schedule the activities in a set of rooms available to us. An activity can be scheduled in a room only if the room is reserved for the activity for its entire duration. What is the minimum number of rooms required? (a) 3 (b) 4 (c) 5 (d) 6 (GATE 2003: 2 Marks) 24. Let G = (V, E) be a directed graph with n vertices. A path from vi to vj in G is a sequence of vertices (vi, vi+1, …, vj) such that (vk, vk+1) ∈ E for all k in i through j − 1. A simple path is a path in which no vertex appears more than once. Let A be an n × n array initialized as follows:

0 if e ∈ E1 w (e) =  1 otherwise

8 11

n( n +1) (d) 2n[log 2 n] 4 (GATE 2003: 2 Marks)

20. The cube root of a natural number n is defined as the largest natural number m such that m3 ≤ n. The complexity of computing the cube root of n (n is represented in binary notation) is (a) O(n) but not O(n0.5) (b) O(n0.5) but not O((log n)k) for any constant k > 0 (c) O((logn)k) for some constant k > 0 but not O((log log n)m) for any constant m > 0 (d) O((log log n)k) for some constant k > 0.5 but not O((log log n)0.5) (GATE 2003: 2 Marks)

4

h 4

n( n −1) n( n −1) (b) 4 2

19. What would be the worst-case time complexity of the insertion sort algorithm, if the inputs are restricted to permutations of 1…n with at most n inversions? (a) Q(n2) (b) Q(n log n) (c) Q(n1.5) (d) Q(n) (GATE 2003: 2 Marks)

15 d

18. If all permutations are equally likely, what is the expected number of inversions in a randomly chosen permutation of 1…n? (a)

5

c

⎧1 if ( j , k ) ∈ E A[ j , k ] = ⎨ ⎩0 otherwise

Consider the following algorithm:

for i for j for k A [j,



= 1 to n = 1 to n = 1 to n k] = max (A[j, k] (A[j, i]+ A [i, k]);

Which of the following statements is necessarily true for all j and k after terminal of the above algorithm? (a) A[j, k] ≤ n. (b) If A[j, j] ≥ n − 1, then G has a Hamiltonian cycle.

11/13/2018 10:29:26 AM

Chapter 5  • Algorithms

(c) If there exists a path from j to k, A[j, k] contains the longest path lens from j to k. (d) If there exists a path from j to k, every simple path from j to k contain most A[j, k] edges. (GATE 2003: 2 Marks) 25. Consider the label sequences obtained by the following pairs of traversals on a labelled binary tree:   (i)  Preorder and postorder  (ii)  Inorder and postorder (iii)  Preorder and inorder   (iv)  Level order and postorder Which of these pairs identifies a tree uniquely? (a) (i) only (b) (ii) and (iii) (c) (iii) only (d) (iv) only (GATE 2004: 2 Marks) 26. Two matrices M1 and M2 are to be stored in arrays A and B, respectively. Each array can be stored in either row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1M2 will be (a) best if A is in row-major and B is in column-major order. (b) best if both are in row-major order. (c) best if both are in column-major order. (d) independent of the storage scheme. (GATE 2004: 2 Marks) 27. Suppose each set is represented as a linked list with elements in an arbitrary order. Which of the operations among union, intersection, membership and cardinality will be the slowest? (a) Union only (b) Intersection and membership (c) Membership and cardinality (d) Union and intersection (GATE 2004: 2 Marks) 28. Suppose we run Dijkstra’s single-source shortest-path algorithm on the following edge-weighted directed graph with vertex P as the source: 1

Q 1

2

6

1

P

S 2 3 7 T

U 2

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 187



In what order do the nodes get included into the set of vertices for which the shortest path distances are finalized? (a) P, Q, R, S, T, U (b) P, Q, R, U, S, T (c) P, Q, R, U, T, S (d) P, Q, T, R, U, S (GATE 2004: 2 Marks)  29. Let A [1, …, n] be an array storing a bit (1 or 0) at each



location, and f(m) is a function whose time complexity is Θ(m). Consider the following program fragment written in a C-like language: counter = 0; for (i = l ; i < = n; i++) {if (A [i] == 1) counter++; else {f (counter); counter = 0;} }



The complexity of this program fragment is (a) W(n2) (b) W(n log n) and O(n2) (c) Q(n) (d) o(n) (GATE 2004: 2 Marks)

30. The time complexity of the following C function is (assume n > 0): int recursive (int n) { if (n == 1) return (1); else return (recursive (n – 1) + recursive (n – 1)); }

(a) O(n) (c) O(n2)

(b) O(n log n) (d) O(2n) (GATE 2004: 2 Marks)

31. The recurrence equation T (1) = 1 T (n) = 2T (n − 1) + n, n ≥ 2

evaluates to: (a) 2n+1 − n − 2 (c) 2n+1 − 2n − 2

R

4

187

(b) 2n − n (d) 2n + n (GATE 2004: 2 Marks)

32. Let G1 = (V, E1) and G2 = (V, E2) be connected graphs on the same vertex set V with more than two vertices. If G1 ∩ G2 = (V, E1 ∩ E2) is not a connected graph, then the graph G1 ∪ G2 = (V, E1 ∪ E2) (a) cannot have a cut vertex. (b) must have a cycle.

11/13/2018 10:29:28 AM

188

GATE CS AND IT Chapter-wise Solved Papers

(c) must have a cut-edge (bridge). (d) has chromatic number strictly greater than those of G1 and G2. (GATE 2004: 2 Marks)

a: Given G(V, E), does G have an independent set of size |V | −4? b: Given G(V, E), does G have an independent set of size 5?

33. A program takes as input a balanced binary search tree with n leaf nodes and computes the value of a function g(x) for each node x. If the cost of computing g(x) is min{number of leaf-nodes in left-subtree of x, number of leaf-nodes in right-subtree of x}, then the worst-case time complexity of the program is (a) O(n) (b) O(n log n) (c) O(n2) (d) O(n2 log n)

Which one of the following is TRUE? (a) a is in P and b is NP-complete (b) a is NP-complete and b is in P (c) a Both and b are NP-complete (d) a Both and b are in P (GATE 2005: 2 Marks)

(GATE 2004: 2 Marks)

Linked Answer Questions 39 and 40: 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 2 Let n = 2m, so T(n) = T ( 2m ) Let T(2m) = S(m) From the above two expressions, we have T(n) = S(m) S(m) = S(m/2) + C1 S(m) = O(log2m) (by Master Theorem) S(m) = O(log2log2n) (because n = 2m) From the above, we have S(m) = T(n) = O(log2log2n) 57. Topic: Hashing (a) a

b

c

d

e

f

1/2 1/4 1/8 1/16 1/32 1/32 abcdef: 1 0 a:1/2

1 bcdef: 1/2 0 b:1/4

1 cdef: 1/4 0

1 def: 1/8

c:1/8 0 d:1/16

1 ef: 1/16 0 1 e: f: 1/32 1/32

a: 0 b: 10 c: 110 d: 1110 e: 11110 f: 11111

58. Topic: Hashing (d) The average length =  

1 1 1 1 1 1 1× + 2 × + 3 × + 4 × + 5 × + 5 × = 1.9375 2 4 8 16 32 32

59. Topic: Asymptotic Worst Case Time and Space Complexity (c) DFS can be used to find out the number of connected components in an undirected graph. The time complexity of DFS is Θ(m + n). 60. Topic: Shortest Paths (a) The minimum number of comparison would be 1 since if an element exists more than n/2 times in a sorted list than it has to be in middle. The middle index of an array can be reached in a constant time. 61. Topic: Graph Search (d) Option (a) is true since the induced sub-graph on k vertices can be constructed as the union of the induced

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 209

209

sub-graphs on k vertices of two edge disjoint spanning tree and each of the induced spanning trees has atmost k − 1 edges. Option (b) is true otherwise G cannot be partitioned into two edge disjoint spanning trees. Option (c) is true otherwise G has minimum cut of one edge. Option (d) is false. 62. Topic: Sorting (c) The recurrence relation is T(n) = T(a) + T(b) + n, a ≥ n/5, b ≥ n/5 and a + b = n  4n  Thus, a ≤ 4n/5 and b ≤ 4n/5, so T ( n) ≤ 2T   + n  5  63. Topic: Searching (b) Since we know that subset sum is a NP-hard problem, thus problem may take linear time when the input encoded is unary. 64. Topic: Algorithm Design Techniques: Divide and ­Conquer (b) X[i, j] (2 ≤ i ≤ n and ai ≤ j ≤ W) is true if any of the following is true: (1) Sum of weights excluding ai is equal to j, that is, if X[i − 1, j] is true. (2)  Sum of weights including ai is equal to j, that is, if X[i −1, j − ai] is true so that we get (j − ai) + ai as j. 65. Topic: Algorithm Design Techniques: Dynamic Programming (c) If we get the entry X[n, W] as true, then there is a subset of {a1, a2, …, an} that has sum as W. 66. Topic: Shortest Paths (d) Following the Dijkstra’s algorithm’s single-source shortest paths, we can reach all the vertices here. Taking ‘a’ as the source: minimum distance is computed by checking all the adjacent nodes, as follows: D ( a) = 0 D(b) = cos t ( a → b) = 1 Here, the minimum distance from source is computed, but since there is only one adjacent node, there is no need to check any other node for minimum. Now, here b node has two adjacent nodes e and c. But since cost(b → e) has a negative weight, we ignore that path as Dijkstra does not entertain negative weights. Thus, we will proceed with node c: D(c) = D(b) + cos t (b → c) = 2 + 1 = 3 Also c node could be reached only through b, so that is the only possible minimum weight of c.

11/13/2018 10:29:48 AM

210

GATE CS AND IT Chapter-wise Solved Papers

As similar to node b, node c is also left with one child d due to negative edge removal c → h: D( d ) = D(c) + cos t (c → d ) = 3 + 3 = 6

73. Topic: Asymptotic Worst Case Time and Space Complexity (b) The recursive expression is n  3n  T ( n) = T   + T   + cn  4  4 T ( n) = Θ( n log n)

Similarly, proceeding further the same way, we can reach all nodes and compute the shortest path. 67. Topic: Asymptotic Worst Case Time and Space Complexity (d) The functions can be arranged in an increasing order as h(n) < f(n) < g(n). Hence, option (d) is the correct one. 68. Topic: Searching (c) Option (a) is incorrect because NP includes both P and NPC. Option (b) is also incorrect because X may belong to P but it does not mean that P = NP. Option (c) is correct because NP-complete set is intersection of NP and NP-hard sets. Option (d) is incorrect because all NP problems are decidable in finite set of operations. 69. Topic: Sorting (a) Selection sort select the minimum element and the swap with first position. In the worst case, all n elements will be swapped. 70. Topic: Hashing (c) 12 mod 10 → 2 18 mod 10 → 8 13 mod 10 → 3 2 mod 10 → 2 [2, 3 are occupied] so will go to 4 3 mod 10 → 3 [3, 4 are occupied] so will go to 5 23 mod 10 → 3 [3, 4, 5 are occupied] so will go to 6 5 mod 10 → 5 [5, 6 occupied] so will go to 7 15 mod 10 → 5 [5, 6, 7, 8 are occupied] will go to 9 71. Topic: Minimum Spanning Trees (d) In Kruskal’s algorithm edges are chosen in increasing order of weights. So, (b, e) = 2, (e, f) = 3, (b, c) = 4, (a, c) = 3, (f, g) = 4 and (c, d) = 5. 72. Topic: Asymptotic Worst Case Time and Space Complexity (a) As per the master theorem, case 3, we have a = 1, b = 3 and f(n) = cn. Thus log b a = log 3 1 = 0 n 0 < f ( n) So, the answer is Q(n).

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 210

This expression is of randomized quick sort. 74. Topic: Algorithm Design Techniques: Dynamic Programming (c) LCS problem is solved using dynamic programing in which every row is dependent upon previous row and column. So, if two characters at ith row and jth column do not match then the length is ­calculated as: expr2 = max(l(i − 1, j), l(i, j − 1)) The values of l(i, j) could be obtained by dynamic programming based on the correct recursive definition of l(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] = l(i, j). 75. Topic: Algorithm Design Techniques: Dynamic Programming (b) The value can be computed in either row-major or column-major order. 76. Topic: Sorting (c) 0.0001 n2< 10 n logn ⇒ 10−5 n < log n ⇒ 10−5 × 10k < k (as log10 n = k ) Hence, k − 5 > 0 or k > 6. Thus, for k = 6, B will be preferred. 77. Topic: Algorithm Design Techniques: Dynamic Programming (b) This involves dynamic programming in algorithms. Given that X = Maximum weight from the sequence (a0,a1,a2, …an −1) an −1 a1 a2 = a0 + + +  + n −1 2 4 2 Y = Maximum weight from the sequence (a1,a2, … an−1) a a2 a3 + +  + nn−−12 2 4 2 Here, we have to find X in terms of Y. = a1 +

So, X = a1 +

a a2 a3 + +  + nn−−12 = Y 2 4 2

a a1 a2 + +  + nn −−11 2 4 2 an −1 a2 a3 < a1 + + +  + n − 2 2 4 2

if

a0 +

11/13/2018 10:29:50 AM

Chapter 5  • Algorithms

OR X = a0 +

a a1 a2 + +  + nn −−11 = a0 +Y/2 if 2 4 2

a a1 a2 + +  + nn−−11 2 4 2 a a2 a3 > a1 + + +  + nn−−12 2 4 2 Hence, we sum up as: X = max(Y,a0+Y/2) a0 +

78. Topic: Minimum Spanning Trees (d) To get the minimum spanning tree with vertex 0 as leaf, first remove 0th row and 0th column and then get the minimum spanning tree (MST) of the remaining graph. Once we have MST of the remaining graph, connect the MST to vertex 0 with the edge with minimum weight (we have two options as there are two 1’s in the 0th row). 79. Topic: Minimum Spanning Trees (b) Path: 1 → 0 → 4 → 2 Weight: 1 + 4 + 3 = 8 80. Topic: Sorting (c) Check the options according to linear probing. The correct sequence is 46, 34, 42, 23, 52, 33. 81. Topic: Hashing (c) We have n( n − 1) = 6 × 5 = 30 82. Topic: Hashing (b) Heap is also a complete binary tree. 83. Topic: Algorithm Design Techniques: Divide-andConquer (a) In the given algorithm, length of the longest monotonically increasing sequence is calculated as: Li in terms of Li+1. So, it uses dynamic programing technique. 84. Topic: Graph Search (b) We can populate only in one way because minimum value will be in the leftmost node, and the maximum value will be in the rightmost node. Recursively, we can define for other nodes. 85. Topic: Asymptotic Worst Case Time and Space Complexity (a) Take n as a large value and evaluate functions. Let n = 32, then

87. Topic: Minimum Spanning Trees (b) Let us have 2 nodes in the tree, then minimum spanning tree is 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 From the above examples, we observe that when we add ith node, the weight of spanning tree increases by 2i − 2. Let T(n) be the weight of minimum spanning tree. T ( n − 1) + ( 2n − 2 ) , n > 2  T ( n) =  3, n = 1 1  0, n = 2  The recurrence can be written as sum of series (2n − 2) + (2n − 4) + (2n − 6) + (2n − 8) + … 3, and solution of this recurrence is n2 − n + 1. 88. Topic: Graph Search (c) Basic structure of all MSTs with more than 5 nodes (for the above given graph specification) would be following: 1

4

2

6

even number of nodes 3

5 odd number of nodes MST with 6 nodes have weight = 3 + 4 + 6 + 8 + 10 = 31 89. Topic: Sorting (b)

f1 = 4294967296  f2 = 181.019  f3 = 160 f4 = 33554432

211

NP P

NPC NP-hard

f 3 < f 2 < f 4 < f1 86. Topic: Hashing (c) Hashing will outperform ordered indexing on Q1, but not Q2.

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 211

Diagram clearly shows that NP-complete ∩ P = Φ.

11/13/2018 10:29:51 AM

212

GATE CS AND IT Chapter-wise Solved Papers

90. Topic: Asymptotic Worst Case Time and Space Complexity (c) The worst-case complexity of a balanced binary search tree is O(log n), where n is the number of elements; here, n is n2n, so n

log( n2 ) = log n + n log 2 = log n + n So, the complexity is O(n). 91. Topic: Sorting (d) Recurrence relation for Tower of Hanoi is T ( n) = 2T ( n − 1) + 1

E × V = n3

We know that V − E + F = 2 10 − 15 + F = 2 ⇒ F = 7 So, the bounded faces = F − 1 = 7 − 1 = 6 93. Topic: Asymptotic Worst Case Time and Space Complexity (c) A(n) = O(W(n)) 94. Topic: Graph Search (c) The number of distinct cycles of length 4 is C4 × ( 4 − 1)! = C4 × 3! = 90

95. Topic: Asymptotic Worst Case Time and Space Complexity (b) The worst-case runtime: n log n. For n strings: n(n log n), which gives n2 log n. 96. Topic: Shortest Paths (d) Apply Dijkstra’s shortest path algorithm. S

A

B

C

D

E

G

T

0















0

4

3



7







0

4

3

5(A)

7







0

4

3

5(A)

7

6(C)





0

4

3

5(A)

7

6(C)

8(E)

10(E)

100. Topic: Asymptotic Worst Case Time and Space Complexity (a)  (1) True. Complexity for detecting cycle using DFS is O(E + V) = O(V2), which is solvable in polynomial time. (2) True. Every problem in P is also NP. (3) True. NP-Complete problems are solvable in nondeterministic time. 101. Topic: Graph Search (a)  It can be observed by taking different examples for graph with cycle, clique and planner graph and with tree. Then we find that only option (a) is correct. 102. Topic: Sorting (d)  Heap sort sorts k elements in time Q(k log k)

6



So, the minimum path will cover S → A → C → E → T, with total weight 10. 97. Topic: Sorting (b) The maximum number of swaps required for n elements is n.

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 212

99. Topic: Asymptotic Worst Case Time and Space Complexity (c) The complexity for Bellman-Ford = O(E ×V). Thus, we have n( n − 1) E = = n2 2 V =n

92. Topic: Graph Search (d) We have Given that vertices (V ) = 10 and edges (E) = 15 Number of bounded and unbounded faces (F) = ?

6

98. Topic: Asymptotic Worst Case Time and Space Complexity (c) In case of skewed binary tree, the tightest upper bound of the insert node is O(n).

 log n  K = Θ   log log n   log n log n  log Θ( k log k ) = Θ   log log n   log log n  log n  ⇒ Θ (log log n − log log log n)   log log n   log n  ⇒ Θ (log log n)  ⇒ Θ(log n)  log log n  103. Topic: Sorting (b) for(i=n/2; i n/2,n/2+1… n => n/2 times { for(j=2; j log n times { k = k + n/2; } return k; }

11/13/2018 10:29:53 AM

Chapter 5  • Algorithms

104. Topic: Asymptotic Worst Case Time and Space Complexity (a)  Any combination of n enqueue and dequeue operations will take Q(n). 105. Topic: Graph Search (b)  Using topological sort, strongly connected components can be found. According to the property, if (u, v) belongs to E2, (v, u) will not belong to E. 106. Topic: Graph Search (c)  Tightest upper bound for running depth first search using adjacency matrix is O(V2). Number of vertices here are n. So, Θ(n2) is the correct option. 107. Topic: Graph Search (1)  On taking input, the root of the binary tree prints all the subtrees of size 4 in Θ(n) time, so a = 1, b = 0, and thus a + 10b = 1. 108. Topic: Graph Search (c)  Topological order of a directed graph is the linear arrangement of vertices in which if there is an edge between u to v, then u comes before v in order. Option (c) satisfies this property, so both PSRQ and SPRQ are topological orderings. 109. Topic: Graph Search (36)  The maximum number of edges in bipartite n2 graph = 4 For n = 12, maximum number of edges in bipartite 12 × 12 = 36 edges graph = 4 110. Topic: Sorting (a)  Applying master theorem, T(n) = aT(n/b) + f(n) T(n) = 2T(n/2) + logn; a = 2, b = 2, f (n) = logn

⇒ g(n) = ( nlogb a ) = nlog2 2 = Θ(n) log 2− ε

⇒ f (n) = log n = O( n 2 ), ⇒ f (n) is smaller than g(n) [as per Case 1 of Master Theorem] ⇒ T(n) = Θ ( n)

So, option (a) is correct.

111. Topic: Shortest Paths (b)  Application of BFS is to find the shortest path from u to v. In the given statement, W is the source node. It will calculate shortest path to every node from W. So, option (b) is correct.

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 213

213

112. Topic: Graph Search (19)  In depth first search, the nodes are traversed in depth. Maximum possible depth is 19. 113. Topic: Asymptotic Worst Case Time and Space Complexity (a)  Worst case is if the list is already sorted. So, worst case complexity is O(n2). 114. Topic: Algorithm Design Techniques: Divide-andConquer (12)  From the given information, we have a + 2b + 4c + 8d + 16e = 323

As other terms are multiples of 2, so a = odd = 11. Substituting, we get 2b + 4c + 8d + 16e = 312 ⇒ b + 2c + 4 d + 8e = 156

So, b must be even = 10. Solving in similar manner, we find that c = 11, d = 11 and e = 10. So, the product of the labels of the bags having 11 gm coins is 1 × 3 × 4 = 12. 115. Topic: Algorithm Design Techniques: Dynamic Programming (d)  Largest clique problem is known NP-Complete problem. In the question, it is given that there exists a polynomial time algorithm for largest clique problem. Thus, P = NP = NP-Complete. 116. Topic: Sorting (148)  Number of comparisons for finding minimum 3 and maximum of n numbers = n − 2 2 Here, n = 100, so (300/2) − 2 = 148 117. Topic: Graph Search (506)  According to the given graph: 4 vertices have degree 3, 40 vertices with degree 5 and 100 vertices with degree 8. Total degree = 12 + 200 + 800 = 1012 So, 1012 = 2 edges ⇒ edges = 506 118. Topic: Sorting (34)  Given that A = “qpqrr” and B = “pqprqrp” The LCS between A and B is having length 4, so x = 4 and possible common subsequences are as follows: (1)  qpqr (2)  pqrr (3)  qprr So, y = 3. Hence, x + 10y = 4 + 10 × 3 = 34.

11/13/2018 10:29:54 AM

214

GATE CS AND IT Chapter-wise Solved Papers

119. Topic: Sorting (358)  Merging two lists requires m + n − 1 comparisons. 20, 24, 30, 35, 50 Merge 20, 24 = 44 elements and 44 − 1 = 43 comparisons Merge 30, 35 = 65 elements and 65 − 1 = 64 comparisons Merge 44, 50 = 94 elements and 94 − 1 = 93 comparisons Merge 94, 65 = 159 elements and 159 − 1 = 158 comparisons Total comparisons = 43 + 64 + 93 + 158 = 358 120. Topic : Minimum Spanning Trees (6) 6

124. Topic: Graph Search (5)  Consider n = 5 V2 V2

V1

V1 V5

V4

V4

V5 Complement of cycle graph

Cycle graph

By checking properties, these two graphs are isomorphic.

125. Topic: Minimum Spanning Trees (6) 1 2 2 1 2 1

+

2

2 2

3

1

3 −

V3

V3

1

1

+

2

2

Applying Kruskal’s − −1

2 +



+ 2

1

2 2

2 1

1

2

2

1

1

0

1

1

0

1

2 1

121. Topic: Algorithm Design Techniques: Dynamic Programming (1.72)

2 2 2 2 1

2

2

1

1 2

2

4 2 2 1

2 1

2

2 2

1

(OR)



2 1

1

Enqueue: Reverse, Push, Reverse Dequeue: POP Enqueue: Push Dequeue: Reverse, POP, Reverse

2

3

this will be true for x = 1.72

122. Topic: Algorithm Design Techniques: Dynamic Programming (c)  An ENQUEUE & DEQUEUE operation takes four sequences of instructions:

1

1

if(abs(p × p−3) < 0.01) return p ;



2

1

1

1 2

2

5 2

So, option (c) is correct.

2

2 2

2 123. Topic: Algorithm Design Techniques: Dynamic Programming (d)  Condition i == j becomes true for j = 50 and program will go to infinite loop.

2 1

2

1

2

1 2

2

6 2 2

2 1

1 2

2 2

1

2 Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 214

1

1 2 11/13/2018 10:29:55 AM

2

2

5 2 2

2 2

2 2 1

2

1

2

Chapter 5  • Algorithms

1 2

2

6 2 2

2 1

1 2

2 2

1

1

1 2



2

Hence, number of distinct minimum spanning trees are 6.

126. Topic: Sorting (150)   T(9) = 1 + min(T(x), T(y)) T(x) and T(y) can be two values: either move right or short cut. Moving right means: 10 and shortcut from 9 is 15 So, product is 15 × 10 = 150. 127. Topic: Searching (b)  The decision problem 2CNFSAT is solvable in polynomial time by reduction to directed graph reachability. 128. Topic: Graph Search (110)  Time complexity is O(log n + m) According to this, a = 0, b = 1, c = 1 and d = 0 Put these in given equation: a + 10b + 100c + 1000d = 0 + 10 + 100 + 0 = 110 129. Topic: Graph Search (c)  In forest each component is a tree. There are G1, G2, … G k components. Each has n − 1 edges.

132. Topic: Algorithm Design Techniques (b)  Quicksort’s worst case is when the list is already sorted or when it is in reverse order. In both cases, the pivot element is already in sorted order and list will always be divided into two lists containing 1 and n − 1 elements.

134. Topic: Sorting (d)  In an unordered list, if we consider any three elements, one of them would neither be maximum or minimum. Hence, in constant time we can find the required element. 135. Topic: Hashing (a)  Left and right subtrees of binary tree are max heaps. Thus, to convert the tree into heap we only need to compare the roots. This would always be done on the number of levels which is log(n). 136. Topic: Sorting (a)  3-SAT is NPC problem.

Q1 ≤p 3-SAT and 3-SAT ≤p Q2



If an NP problem A is polynomial time reducible to another NP problem B, then B is NPC. But if we do not know the type of B problem, then B is said to be NP hard. Hence, Q1 is in NP and Q2 is NP hard.

i =1

131. Topic: Minimum Spanning Trees (c)  Merge sort firstly divides the list and then merges it to sort. Hence, it uses divide and conquer strategy. All pair shortest path algorithm uses the concept of overlapping while computing the shortest path. Hence, it uses dynamic programming. Hamiltonian circuit means covering all the vertices and while doing so backtracking is required. Prim’s algorithm for minimum spanning tree is greedy method.

T(n) = T(n − 1) + T(1) + cn

133. Topic: Asymptotic Worst Case Time and Space Complexity (b)  Worst case for insertion and deletion could be if we have to traverse all the nodes. In that case, the complexity is Θ(n) in both.

∑n − i = n − k edges 130. Topic: Graph Search (a)  Degree ≥ 3 is of n vertices. Means 3n ≤ 2e → e ≥ 3n/2 We know that e = n + r − 2 n + r − 2 ≥ 3n/2 or r ≥ n/2 + 2

Thus, the recurrence relation formed is as follows:



k

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 215

215

137. Topic: Searching (c) X = 13 + 23 + 33 + 43 +  + n3 =

n2 ( n + 1) 2 4

This is equivalent to Q (n4), O(n5) and W(n3).

138. Topic: Hashing Size Complexity



(80)  Load factor (a ) =



Size: Number of elements = 2000



Capacity: Number of slots = 25

α=

2000 = 80 25

11/13/2018 10:29:55 AM

216

GATE CS AND IT Chapter-wise Solved Papers

139. Topic: Hashing (d) 89 19 17 5

50 12

100

89

15

19

Swap 2 100 & 15 17

7 11 6 9 100

5

19

50 12

100

89

Swap 100 & 50 17 2 5

7 11 6 9 15

89

19

100

Swap 12

50

20

17

89 & 100 5

7 11 6 9 15

12

2

50

7 11 6 9 15

140. Topic: Hashing (b)  40

40

30

10

20

15

8

16

30

Insert 35 17

10

4

8

20

15

4

40

35

8

4

30

20

30

17

35

40

10

16

16

10

17

8

15

20

35

4

16

17

15

40, 35, 20, 10, 30, 16, 17, 8, 4, 15 141. Topic: Sorting (a) Suppose n = 3, possible strings are ⇒ 011, 110, 111 For n = 2 ⇒ 11 is the only possible string    a3 = a1 + a2 + 21 = 0 + 1 + 2 = 3 ⇒ True    a3 = a1 + 2a2 + 21 = 0 + 2 + 2 = 4 ⇒ False    a3 = 2a1 + a2 + 21 = 0 + 1 + 2 = 3 ⇒ True    a3 = 2a1 + 2a2 + 21 = 0 + 2 + 2 = 4 ⇒ False

Now, for options (a) and (c), check by considering n = 4. The answer comes out to be (a).

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 216

142. Topic: Shortest Paths (d)  In BFS traversal of given graph, we can either visit node u first or node v. Let us assume node u if visited first. Then all neighbors of node u will be in the queue to be visited. Since v is also a neighbor of u and v is not visited before, d(v) will become d(u) + 1. So, d(u) − d(v) = 2 is not possible. 143. Topic: Asymptotic Worst Case Time and Space Complexity

(a)  Suppose if we use an unsorted array then, search operation will require Θ(N) time.

11/13/2018 10:29:56 AM

217

Chapter 5  • Algorithms

(logN)1/2 search operations will take = Θ(N(log N)1/2) time. Insertion will take a constant time, that is, Θ(1). N insert operations need = N × Θ(1) = Θ(N) time. Delete operations will also be done in constant time since the pointer to be deleted is provided and no time will be required for search. (log N)1/2 delete operations will be completed in = Θ((log N)1/2) time Decrease key operation will also take = Θ((log N)1/2) time If we use sorted order array, insertion will take more time since we need to find its exact position in the list where to insert the data. And in the case of min heap, more time will be required in insertion and deletion since heapify algorithm needs to be implemented after each insertion or deletion.

146. Topic: Algorithm Design Techniques: Greedy (5)

E 4

14

4

6

23

3

4

6

10

12

18 25

10 12

18 25

31



∞ ∞

32 ∞

∞ ∞

Shift element 2 with ∞ 2



5

14

23

3

4

6

23

12 18

25

10 12 18 25

∞ ∞



31 ∞ ∞ ∞

2

4

5

14

3



6

10 31

Shift 4 with ∞

2

4

5

14

5 18

14 23

3

6

∞ 23

10 12 18 25

10 12 ∞

25

31 ∞ ∞ ∞

31 ∞ ∞



Shift 18 with ∞

2 3

4 6

F

2 9

Shift 25 with ∞

6 C

D Final table

15 B

2

4

5

3

6

18 23



4 2

7

9

F 6

C

D

14

10 12

25 ∞



∞ ∞

E

10 A

5

5

Shift 6 with ∞

15

A

2

2

Intial state

144. Topic: Minimum Spanning Trees (69)  B

14 After removing ∞ element 1 3 23

1

31

So, minimum number of entries to be shifted = 5.

147. Topic: Hashing (b)  If we take the first 10 elements, number of collisions taken by the hash function is given by option (b), which is less when compared to others.

16 Sum = 10 + 9 + 2 + 15 + 16 + 7 + 4 + 6 = 69 145. Topic: Algorithm Design Techniques (c)  Dijkstra uses the Greedy approach. All pair shortest path algorithm uses the concept of overlapping while computing the shortest path. Hence, it uses dynamic programming. Binary search divides the list and then searches for an element. Hence, it uses divide and conquer strategy. Backtracking is used in DFS. Once we have covered one path, we need to backtrack to move on to another.

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 217

148. Topic: Asymptotic Worst Case Time and Space Complexity (a)  Merge sort worst case time complexity = O(nlog n) For input of size 64, it takes 30 seconds n log n = 30 for n = 64 64 log 64 = 30 seconds For 6 minutes, factor is 12. So, multiply by 12 on both sides 12 × (64 log 64) = 12 × 30 seconds 512 log 512 generates the factor of 12 So, maximum 512 size array can be sorted.

11/13/2018 10:29:56 AM

218

GATE CS AND IT Chapter-wise Solved Papers

149. Topic: Algorithm Design Techniques: Dynamic Programming (c) Given, L1 ≤ L2

L3 ≤ L2 L2 ≤ L4

If L4 is polynomial, then it implies that L2 is also polynomial. Similarly, if L2 is polynomial this also implies that L1 and L3 are also polynomials. 150. Topic: Minimum Spanning Trees (995)  In a spanning tree containing 100 vertices, number of edges will be 99. Therefore, weight is increased by = 500 + 5 × 99 = 995 151. Topic: Sorting (d)  f (n) = n and g(n) = n1 + sin n Minimum value of g(n) = n1−1 = 1 Maximum value of g(n) = n2 In either case, it is not equal to f (n). Hence, f (n) can’t be best or worst case for g(n). 152. Topic: Algorithm Design Techniques (a)  On applying queue using an array we get the following: •  For enqueue operation:       Check for the array if full or not.       Decide if array is full.      Stop.      Or else, enter the element in the end of array, it will take O(1) time. •  For dequeue operation:       Check for array it empty or not.       Decide if array is empty.      Stop.      Or else, delete the element from the front of the array and increment the head value (pointer to the starting element of array), which will take O(1) time. Hence, for the array implementation of queue, both enqueue and dequeue operations take O(1) time.  

154. Topic: Asymptotic Worst Case Time and Space ­Complexity (d)  Worst case complexity: •  Insertion sort = Θ(n2) •  Merge sort = Θ(nlogn) •  Quick sort = Θ(n2) 155. Topic: Shortest Paths (a)  When every weight is increased, obviously, earlier when any tree was spanning so after increasing every edge weight, the minimum spanning tree does not change. However, between two paths, the path may change as earlier when it was rejected (may be due to cycle). Now, it may not be included in the cycle, but the shortest path between that pair of vertices change so the correct answer is that the minimum spanning tree of G does not change. 156. Topic: Graph Search (31) The given vertex t is located at a ­distance ‘four’ from root. Therefore, •  At distance 0 from root = 1 •  At distance 1 from root = 3 [i.e. (1 × 2) +1] •  At distance 2 from root = 7 [i.e. (3 × 2) + 1] •  At distance 3 from root = 15 [i.e. (7 × 2) + 1] •  At distance 4 from root = 31 [i.e. (15 × 2) + 1]

 

   

153. Topic: Sorting (6)  Topological ordering a  b  d  c  e  f a  b  d  c  e  f a  b  d  e  c  f a  b  d  e  c  f Hence, the number of different topological orderings of the vertices of the graph is 4! =6 2! 2!

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 218



Therefore, if t is the n-th vertex in this BFS traversal, then the maximum possible value of n is 31.

157. Topic: Sorting (d) • Quicksort worst case (unbalanced sorting) = Θ(n2) •  Insertion = Θ(n) •  Mergesort = Θ(n log n) [All cases] 158. Topic: Shortest Paths (c)  Floyd−Warshall computer problem based on several subproblems in tabular format. 159. Topic: Asymptotic Worst Case Time and Space ­Complexity (c)  The time complexity of all the given operations put together results in option (c).

11/13/2018 10:29:57 AM

Chapter 5  • Algorithms

160. Topic: Graph Search (b)  It is given that depth d (number of edges on the path from the root to the farthest leaf). Therefore, O(logd) is required to remove any node. Thus, O(d) ↔ O(1)

is 12 because having two shortest paths of length 12 is reasonable since one contains the edge x. 162. Topic: Minimum Spanning Trees (7)  We can have MST (minimum spanning tree) of 1, 2 or 3 and 1, 2 or 4. Therefore, 1+2+4=7

161. Topic: Graph Search (12)  Let us exclude the edge labeled x, therefore, the shortest paths are given as follows:

1

 AB = 2; AC = 7; AD = 5; BC = 5; BD = 7; CD = 12

219

2

1 5

Here, the lengths of the shortest paths can only decrease (or remain equal) if we add a new edge. The most likely is the longest shortest path: CD = 12.

3

2 6

A

4

3 4

163. Topic: Minimum Spanning Trees (b)  Since MST asked so if e is any ­heaviest edge in cycle, it obviously will not be involved. Therefore, only statement (II) is true.

8 5

2

x D

164. Topic: Sorting (8) It is obvious that as a worst case, the maximum depth is 8.

5 8

B

165. Topic: Sorting (1500)  Here, there are five possible cases:

It is obvious that if we set x = 12 on the edge joining CC and DD, there can be two shortests paths (both of length 12): 1. C → DC → D 2. C→B→A→D







Hence, if x ≤ 12, there can be at least one shortest path that passes through x, as requested. We can see that a larger x (say, 13) cannot be used because all the existing shortest paths are already smaller or equal to 12. Note: The question reads as follows: The ­largest possible integer value of x, for which at least one shortest path between some pair of vertices will contain the edge with weight x. The question means that “at least one shortest path”, but not “every shortest path”. If it is misunderstood, then it would mean as “every shortest path”. Then, in such case, the answer would be 11 because we had to “beat” the shortest path C → B → A → D = 12. However, since the question asks for “at least one” among the shortest paths, then the answer

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 219

A(B(CD)) A((BC)D) ((AB)C)D (A(BC))D (AB)(CD)

The scalar multiplications required are 1750, 1500, 3500, 2000, 3000, respectively. Therefore, the minimum number of scalar multiplications is 1500.

166. Topic: Graph Search (b)  It is obvious that the time complexity is Θ(n + m). 167. Topic: Asymptotic Worst Case Time and Space Complexity (b) When n approaches infinity, the increasing order of asymptotic complexity is

100 < 10 < log 2 n < n < n n

Therefore, (b) is the correct option.

11/13/2018 10:29:57 AM

220

GATE CS AND IT Chapter-wise Solved Papers

168. Topic: Algorithm Design Techniques: Divide-andConquer (c)  (P) Kruskal algorithm is based on greedy approach. (Q) Quicksort algorithm is based on divide and conquer. (R) Floyd–Warshall algorithm is based on dynamic programming. 169. Topic: Asymptotic Worst Case Time and Space Complexity (c)  (P) Towers of Hanoi with n disks → T(n) = 2T(n - 1) + 1 = Θ(2n). (Q)  Binary search given n sorted numbers → T(n) = T(n/2) + c = Θ(log n). (R) Heap sort given n numbers at the worst case → T(n) = 2T(n /2) + n = Θ(n log n). (S) Addition of two n × n matrices → T(n) = 4T(n/2) + 1 = Θ(n2).

174. Topic: Sorting (b)  Using master theorem, we have T(n) = Θ(log n) 175. Topic: Asymptotic Worst Case Time and Space Complexity

n n n + ++ 2 3 n

1  1 1 = n 1 + + +  +  n  2 3 = Θ( n log n)



176. Topic: Graph Search (225)  Consider the following tree. 1.0

0.41

170. Topic: Searching (b)  Front

(c)  Time complexity = n +

0.22 P

0.59

0.19 S

0.34

0.25

Rear 0.17

0.08 T



As we can see from the above figure, the next pointer of the rear node points to the front node.

171. Topic: Algorithm Design Techniques (d)  (a) False. After traversing vertices M and N, vertex O cannot be traversed. (b) False. After traversing vertex M, vertex P cannot be traversed, vertex O should be traversed. (c) False. After traversing vertex N, vertex R cannot be traversed, vertex O or P should be traversed. (d) True.

Now, Message length = 100 × (Average length of characters) = 100 × (2 × (0.22 + 0.19) + 2 × 0.34 + 3 × (0.17 + 0.08)) = 225 bits 177. Topic: Asymptotic Worst Case Time and Space Complexity (16)  Greedy algorithm will pick item of highest weight provided that total value does not exceed 11 kg. Greedy algorithm

172. Topic: Minimum Spanning Trees (a)  The minimum spanning tree of G is always unique. Therefore, statement I is true. The shortest path between the two vertices of G need not be unique. Therefore, statement II is false. 173. Topic: Asymptotic Worst Case Time and Space Complexity (5)  In worst case, by using optimal searching algorithm, “5” comparisons are needed because η = 31 = 25 − 1

Ch wise GATE_CSIT_CH05_Algorithms.indd.indd 220



Optimal algorithm

Item

Weight

Value

Item

Weight

Value

4

2

24

1

10

60 60

3

2

20 44

Optimal value – Greedy value = 60 - 44 = 16

11/13/2018 10:29:59 AM

Theory of Computation

CHAPTER6

Syllabus Regular expressions and finite automata. Context-free grammars and pushdown automata. Regular and contexfree languages, pumping lemma. Turing machines and undecidability.

Chapter Analysis Topic

GATE 2009

GATE 2010

Regular Expressions

2

1

Finite Automata

2

1

GATE 2011

GATE 2012

GATE 2013

GATE 2014 2

2

3

1

2

Context-Free Grammar Pushdown Automata

2

2

1

1

2

GATE 2016

GATE 2017

GATE 2018

2

2

1

1

1

1 3 1

1

1

1

4

1

2

1

2

2

3

4

4

1

2

1

1

Regular Languages Context-Free Languages

GATE 2015

Pumping Lemma Turing Machines

2

Undecidability

1

1 1

1

2

1

1

Important Formulas 1.

Number of states in a machine which accept m a’s and n b’s: [(m + 1)*(n + 1) + 1]

2. Mod n machines have n states. 3.

Mod machine have no trap states.

4.

If a machine accepts string length exactly n, then it has (n + 2) states.

5.

If a machine accepts string length ≤ n, then it has (n + 2) states.

6.

If a machine accepts string length ≥ n, then it has (n + 1) states.

7.

m States, n outputs Mealy machine ≡ Moore machine containing ≤ mn + 1 states.

8.

m States, n outputs Moore machine ≡ Mealy machine containing ≤ m states.

9.

Output length of Mealy machine is equal to input length.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 221

10. Output length of Moore machine is one greater than the input length because first output symbol is additional without reading any symbol from the input. 11. If language is finite then it will surely be regular. Example: Let L = {ambn, m + n = 10} as m and n are finite so it is a regular language. But it does not mean that if a language is infinite then it cannot be regular such as (a*b*) is an infinite and regular language. 12. If there is a comparison between m and n then it will be a CFL. Example: Let L = {ambn, (m ≥ n)}. 13. Let language L = {ambn} and if m or n is non-linear then it will not be accepted by PDA, so it will fall in the ­category of CSL. 14. If there are more than one comparison then it will be a CSL. Example: Language L = {ambnco, m ≥ n and o ≥ n }. 15. All modular machines are regular language. 16. All palindrome languages are CFL language.

11/13/2018 11:11:09 AM

222

GATE CS AND IT Chapter-wise Solved Papers

Variation of NFA/DFA 17. DFA/NFA + (left ↔ right) move ≡ (2 − DFA)/(2 − NFA) means whatever a 2 − DFA can do, that can be done by simple DFA with left – right move. 18. DFA/NFA + (left ↔ right) move + (read/write) head ≡ (2 − DFA)/(2 − NFA). 19. DFA + 1 stack ≡ DPDA.

21. DFA + 2 stack ≡ TM. 22. DFA/NFA + 2 counter ≡ TM. 23. DFA/NFA + 2 stack ≡ DFA/NFA + 2 counter. 24. Power of {(DFA/NFA) < (DFA/NFA + 1 ­ counter) 3Nb(w)} (b) {w |Nb(w) > 3Nb(w)} (c) {w |Na(w) = 3k, k ∈ {0, 1, 2, ...}} (d) {w |Nb(w) = 3k, k ∈ {0, 1, 2, ...}} (GATE 2004: 2 Marks) 28. L1 is a recursively enumerable language over Σ. An algorithm A effectively enumerates its words as w1, w2, w3, …. Define another language L2 over Σ ∪ {#} as {wi # wj: wj ∈ L1, i < j}. Here # is a new symbol. Consider the following assertions: S1: L1 is recursive implies L2 is recursive S2: L2 is recursive implies L1 is recursive Which of the following statements is true? (a) Both S1 and S2 are true. (b) S1 is true but S2 is not necessarily true. (c) S2 is true but S1 is not necessarily true. (d) Neither is necessarily true. (GATE 2004: 2 Marks)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 225

1/0 1/1 Q0

Q1

Which one of the following is TRUE? (a) It computes 1’s complement of the input number (b) It computes 2’s complement of the input number (c) It increments the input number (d) It decrements the input number (GATE 2005: 2 Marks) 31. Consider the machine M: a

b a

b a

bc

b

a a, b

The language recognized by M is (a)  {w ∈ {a, b}* every a in w is followed by exactly two b’s}. (b)  {w ∈ {a, b)* every a in w is followed by at least two b’s}. (c) {w ∈ (a, b}* w contains the substring “abb”}. (d)  {w ∈ {a, b}* w does not contain “aa” as a substring}. (GATE 2005: 2 Marks) 32. Let Nf and Np denote the classes of languages accepted by non-deterministic finite automata and non-deterministic push-down automata, respectively. Let Df and Dp denote the classes of languages accepted by deterministic finite automata and deterministic push-down automata, respectively.

11/13/2018 11:11:12 AM

226

GATE CS AND IT Chapter-wise Solved Papers

Which one of the following is TRUE? (a) Df ⊂ Nf and Dp ⊂ Np (b) Df ⊂ Nf and Dp = Np (c) Df = Nf and Dp = Np (d) Df = Nf and Dp ⊂ Np (GATE 2005: 2 Marks) 33. Consider the languages L1 = {anbncm | n, m > 0} and L2 = {anbmcm | n, m > 0} Which one of the following statements is FALSE? (a) (b) (c) (d)

L1 ∩ L2 is a context-free language. L1 ∪ L2 is a context-free language. L1 and L2 are context-free languages. L1 ∩ L2 is a context-sensitive language. (GATE 2005: 2 Marks)

34. Let L1 be a recursive language, and let L2 be a recursively enumerable but not a recursive language. Which one of the following is TRUE? (a) L1 is recursive and L2 is recursively enumerable. L1 is recursive and L2 is not recursively enumera(b)  ble. (c) L1 and L2 are recursively enumerable. (d) L1 is recursively enumerable and L2 is recursive. (GATE 2005: 2 Marks) 35. Consider the languages L1 = {wwR | w ∈ {0, 1}*} L2 ={w # wR | w ∈ {0, 1}*}, where # is a special symbol L3 = {ww | w ∈ {0, 1}*} Which one of the following is TRUE? (a) L1 is a deterministic CFL. (b) L2 is a deterministic CFL. (c) L3 is a CFL, but not a deterministic CFL. (d) L3 is a deterministic CFL. (GATE 2005: 2 Marks) 36. Let L1 = {0n+m1n0m |n, m ≥ 0}, L2 = {0n+m1n+m0m |n, m ≥ 0} and L3 = {0n+m1n+m0n+m |n, m ≥ 0} Which of these languages are NOT context-free? (a) L1 only (b) L3 only (c) L1 and L2 (d) L2 and L3 (GATE 2006: 1 Mark) 37. If s is a string over (0 + 1)*, then let n0(s) denote the number of 0’s in s and n1(s) the number of 1’s in s. Which one of the following languages is not regular?

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 226

(a) L = [s ∈ (0 + 1)* | n0(s) is a 3-digit prime} (b)  L = {s ∈ (0 + 1)* | 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} (GATE 2006: 2 Marks) Linked Answer Questions 38 and 39: 38. Which one of the following grammars generates the ­language L = {ai bi | i ≠ j)? (a) S → AC  |CB (b) S → aS |Sb |a |b C → aCb |a |b A → aA | ∈ B → Bb | ∈ (c) S → AC  |CB (d) S → AC  |CB C →aCb | ∈ C →aCb | ∈ A → aA | ∈ A → aA | a B → Bb | ∈ B → Bb | b (GATE 2006: 2 Marks)  

39. In the correct grammar above, what is the length of the derivation (number of steps starring from S) to generate the string al bm with l ≠ m? (a) max(l, m) + 2 (b) l + m + 2 (c) l + m + 3 (d) max(l, m) + 3 (GATE 2006: 2 Marks) 40. For s ∈ (0 + 1)*, let d(s) denote the decimal value of s (e.g., d(101) = 5). Let L = {s ∈ (0 + 1)*l d(s) mod 5 = 2 and 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. (GATE 2006: 2 Marks) 41. Consider the following statements about the context-free grammar: G = {S → SS , S → ab, S → ba, S → e} I. G is ambiguous. II. G produces all strings with equal number of a’s and b’s. III. G can be accepted by a deterministic PDA. Which combination below expresses all the true statements about G? (a) I only (b) I and III only (c) II and III only (d) I, II, and III (GATE 2006: 2 Marks)

11/13/2018 11:11:13 AM

227

Chapter 6  • Theory of Computation

42. Let L1 be a 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 ∩ L2 is a deterministic CFL. (b) L3 ∩ L1 is recursive. (c) L1 ∪ L2 is context-free. (d) L1 ∩ L2 ∩ L3 is recursively enumerable. (GATE 2006: 2 Marks) 43. 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 (GATE 2006: 2 Marks) 44. Which of the following problems is undecidable? (a) Membership problem for CFGs (b) Ambiguity problem for CFGs (c) Finiteness problem for FSAs (d) Equivalence problem for FSAs (GATE 2007: 1 Mark) 45. 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. (GATE 2007: 1 Mark) 46. A minimum state deterministic finite automaton accepting the language

L = {w | w ∈ {0, 1}*, number of 0’s and 1’s in w are divisible by 3 and 5, respectively} has (a) 15 states (b) 11 states (c) 10 states (d) 9 states (GATE 2007: 2 Marks)

47. The language L = {0i 21i i ≥ 0} over the alphabet {0, 1, 2} is (a) not recursive (b) recursive and is a deterministic CFL (c) a regular language (d) not a deterministic CFL but a CFL (GATE 2007: 2 Marks) 48. Which of the following languages is regular? (a) {wwR ⁄ w ∈ {0, 1}+} (b) {wwRx ⁄ x, w ∈ {0, 1}+}

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 227

(c) {wxwR ⁄ x, w ∈ {0, 1}+} (d) {xwwR ⁄ x, w ∈ {0, 1}+} (GATE 2007: 2 Marks) Common Data Questions 49 and 50: Consider the following finite state automaton q3

b

q0

b

a

q1

a

b a

q2

b

a 49. The language accepted by this automaton is given by the regular expression (a) b*ab*ab*ab* (b) (a + b)* (c) b*a (a + b)* (d) b*ab*ab* (GATE 2007: 2 Marks) 50. The minimum state automaton equivalent to the above FSA has the following number of states (a) 1 (b) 2 (c) 3 (d) 4 (GATE 2007: 2 Marks) 51. Which of the following is true for the language {aP | P is a prime}? (a) It is not accepted by a Turing 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 Turing machine. (GATE 2008: 1 Mark) 52. Which of the following are decidable? I. Whether the intersection of two regular languages is infinite. II. Whether a given context-free language is regular. III. Whether two pushdown automata accept the same language. IV. Whether a given grammar is context-free. (a) I and II (b) I and IV (c) II and III (d) II and IV (GATE 2008: 1 Mark) 53. If L and L are recursively enumerable, then L is (a) Regular (b) Context-free (c) Context-sensitive (d) Recursive (GATE 2008: 1 Mark)

11/13/2018 11:11:14 AM

228

GATE CS AND IT Chapter-wise Solved Papers

54. Which of the following statements 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. (GATE 2008: 2 Marks)



a

b

→P

S

Q

Q

S

R

R(F)

Q

P

A

Q

P (GATE 2008: 2 Marks)

a

b

→P

S

R

56. Which of the following statements are true? I. Every left-recursive grammar can be converted to a right-recursive grammar and vice versa. II. All e productions can be removed from any context-free grammar by suitable transformations. III. The language generated by a context-free grammar all of whose productions are of the form X → w or X → wY (where w is a string of terminals and Y is a non-terminal) is always regular. IV. The derivation trees of strings generated by a context-free grammar in Chomsky normal form are always binary trees. (a) I, II, III and IV (b) II, III and IV only (c) I, III and IV only (d) I, II and IV only (GATE 2008: 2 Marks)

Q

R

S

57. Match the following.

R(F)

Q

P

S

Q

P

a

b

→P

Q

S

Q

R

S

R(F)

Q

P

S

Q

P

55. Given below are two finite state automata (→ indicates the start state and F indicates the final state)

Y:

(d)

a

b

→1

1

2

2(F)

2

1

Z:

a

b

→1

2

2

2(f)

1

1

Which of the following represents the product automaton Z × Y ? (a)

(b)

List I

List II

(E) Checking that identifiers are declared before their use

(P)  L = {anbmcndm | n ≥ 1, m ≥ 1}

(F) Number of formal (Q)  X → XbX |XcX |dXf |g parameters in the declaration of a function agrees with the number of actual parameters in use of that function

a

b

→P

S

Q

(G) Arithmetic expressions with matched pairs of parantheses

Q

R

S

(H) Palindromes

R(F)

Q

P

S

P

Q

(c)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 228

(R)  L = {wcw | w ∈ (a|b)*}

(S)  X → bXb|cXc|e

Codes: (a) E – P, F – R, G – Q, H – S (b) E – R, F – P, G – S, H – Q

11/13/2018 11:11:14 AM

229

Chapter 6  • Theory of Computation

(c) E – R, F – P, G – Q, H – S (d) E – P, F – R, G – S, H – Q (GATE 2008: 2 Marks) 58. Match the following NFAs with the regular expressions they correspond to. (P)

(Q) 1 0

1

0 0

1 0

1

(R)

0

1

1

(S) 0

0

1 0

1

0

0

1 0

1

62. 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 non-deterministic PDA can be converted to an equivalent deterministic PDA. (GATE 2009: 1 Mark) 63. Match all items in Group 1 with correct options from those given in Group 2.

1. e + 0(01*1 + 00)*01* 2. e + 0(10*1 + 00)*0 3. e + 0(10*l + 10)*l 4. e + 0(10*1 + 10)*10* Codes: (a) P – 2, Q – 1, R – 3, S – 4 (b) P – 1, Q – 3, R – 2, S – 4 (c) P – 1, Q – 2, R – 3, S – 4 (d) P – 3, Q – 2, R – 1, S – 4

Group 1

(GATE 2008: 2 Marks) 59. Which of the following are regular sets? I. {anb2m |n ≥ 0, m ≥ 0} II. {anbm |n = 2m} III. {anbm|n ≠ m} IV. {xcy | x, y ∈ (a, b}*} (a) I and IV only (b) I and III only (c) I only (d) IV only (GATE 2008: 2 Marks) 60. S → aSa|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. (GATE 2009: 1 Mark)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 229

61. Which one of the following languages over the alphabet {0, 1} is described by the regular expression (0 + 1)* 0(0 + 1)*0(0 + 1)*? (a) The set of all strings containing the substring 00. (b) The set of all strings containing at most two 0’s. (c) The set of all strings containing at least two 0’s. (d) The set of all strings that begin and end with either 0 or 1. (GATE 2009: 1 Mark)

Group 2

P.  Regular expression

1.  Syntax analysis

Q.  Pushdown automata

2.  Code generation

R.  Dataflow analysis

3.  Lexical analysis

S.  Register allocation

4.  Code optimization

Codes: (a) P – 4, Q – 1, R – 2, S – 3 (b) P – 3, Q – 1, R – 4, S – 2 (c) P – 3, Q – 4, R – 1; S – 2 (d) P – 2, Q – 1, R – 4, S – 3 (GATE 2009: 1 Mark) 64. Given the following state table of an FSM with two states A and B, one input and one output; Present Present Input State A State B State C

Next State A

Next State B

Output

0

0

0

0

0

1

0

1

0

1

0

0

1

0

0

0

1

0

1

1

0

1

0

0

0

0

1

0

1

0

0

1

1

0

0

1

1

0

1

0

1

1

1

1

1

0



1

11/13/2018 11:11:14 AM

230

GATE CS AND IT Chapter-wise Solved Papers

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 (b) 4 (c) 5 (d) 6 (GATE 2009: 2 Marks)

65. Let L = L1 ∩ L2, where L1 and L2 are languages as defined below: L1 = {ambmcanbn |  m, n3 ≥ 0} L2 = {aibick | i, j, k ≥ 0} Then L is (a) not recursive. (b) regular. (c) context-free but not regular. (d) recursively enumerable but not context-free. (GATE 2009: 2 Marks) 66. In the following figure, DFA accepts the set of all strings over {0, 1} that 1

1 0

0 0

1 (a) (b) (c) (d)

begin either with 0 or 1 end with 0 end with 00 contain the substring 00 (GATE 2009: 2 Marks)

67. Let L1 be a recursive language. Let L2 and L3 be languages 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) L2 ∩ L3 is recursively enumerable. (d) L2 ∪ L3 is recursively enumerable. (GATE 2010: 1 Mark) 68. Let L = {w ∈ (0 + 1)*|w has even number of 1’s}, i.e., L is the set of all bit strings with even number of 1’s. Which one of the regular expressions below represents L? (a) (0*10*1)* (b) 0*(10*10*)* (c) 0*(10*1)*0* (d) 0*1(10*1)*10* (GATE 2010: 2 Marks)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 230

69. Consider the languages L1 = {0i1 j | i ≠ j}, L2 = {0i1 j | i = j}, L3 = {0i1 j | i = 2 j + 1}, L4 = {0i1 j | i ≠ 2 j}

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 (GATE 2010: 2 Marks)

70. 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 nondeterministic finite automaton that accepts L? (a) n − 1 (b) n (c) n + 1 (d) 2n − 1 (GATE 2010: 2 Marks) 71. 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 p*q* and Q be [ pnqn | n ∈ N ]. Then which of the following is ALWAYS regular? (a) P ∩ Q (b) P−Q (c) Σ* − p (d) Σ* − Q (GATE 2011: 1 Mark) 72. 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 (GATE 2011: 1 Mark) 73. Which of the following pairs have DIFFERENT expressive power? (a)  Deterministic finite automata (DFA) and nondeterministic finite automata (NFA) (b)  Deterministic pushdown automata (DPDA) and non-deterministic pushdown 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 (GATE 2011: 1 Mark) 74. A deterministic finite automaton (DFA) D with alphabet Σ = {a, b} is given as follows.

11/13/2018 11:11:15 AM

Chapter 6  • Theory of Computation

a, b b

b

q

p a

a a, b

a, b s

r

t

Which of the following finite state machines is a valid minimal DFA which accepts the same language as D? (a) a, b b b p q r a a

77. Given the language L = {ab, aa, baa}, which of the ­following strings are in L*? 1. abaabaaabaa 2. aaaabaaaa 3. baaaaabaaaab 4. baaaaaba (a) 1, 2 and 3 (b) 2, 3 and 4 (c) 1, 2 and 4 (d) 1, 3 and 4 (GATE 2012: 1 Mark) 78. What is the complement of the language accepted by the NFA shown below? Assume Σ = {a} and e is the empty string.

s

e

a a, b

(b)

a, b ε

s

b

a, b

a, b p

q

a

q

a, b b

(c) a, b p (d)

r a, b r

b

b

p

q a

a s

a, b (GATE 2011: 2 Marks)

(a) ∅ (b) {e} (c) a (d) {a, e} (GATE 2012: 1 Mark) 79. Consider the set of strings on {0, 1} in which every substring of 3 symbols has at most two zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All strings of length less than 3 are also in the language. A partially completed DFA that accepts this language is shown below.

75. Definition of a language L with alphabet {a} is given as following. L = {ank | k < 0, and n is a positive integer constant}

231

00 0 1 0

What is the minimum number of states needed in a DFA to recognize L? (a) (k + 1) (b) (n + 1) (c) 2k + 1 (d) 2n + 1 (GATE 2011: 2 Marks)

e

0 1

L2 = {0p1q |p, q ∈ N and p = q} L3 = {0p1q0r |p, q, r ∈ N, r ∈ N and p = q = r). Which of the following statements is NOT TRUE? (a) Pushdown automata (PDA) can be used to recognize L1 and L2. (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. (GATE 2011: 2 Marks)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 231

0

1

−0,1

q

1 10

11

76. Consider the languages L1, L2 and L3 as given below. L1 = {0p1q |p, q ∈ N)

01

0

1 The missing arcs in the DFA are (a) 00 01 10 0 1 00 01 10 0 11 0 (b)

00 00 01 10 11

01 0 1

10

11

q

1

11

q 1

0 0

11/13/2018 11:11:16 AM

232

GATE CS AND IT Chapter-wise Solved Papers

(c)

00 00 01 10 11

(d)

10

11

q 0



4.  Turing recognizable languages are closed under union and intersection. (a) 1 and 4 only (c) 2 only

0

(b) 1 and 3 only (d) 3 only (GATE 2013: 1 Mark)

0 00

00 01 10 11

01 1 1

01 1

10

11

q 0

84. Consider the DFA A given below. 1

1 1

0 0 (GATE 2012: 2 Marks)

80. 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 a correct inference (c) I1 is not correct but I2 is a correct inference (d) Both I1 and I2 are not correct inferences (GATE 2012: 2 Marks) 81. 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, is L also context-free? 3. If L is a regular language, then, is L also regular? 4. If L is a recursive language, then, is L also recursive? (a) 1, 2, 3, 4 (b) 1, 2 (c) 2, 3, 4 (d) 3, 4 (GATE 2012: 2 Marks) 82. Consider the languages L1 = Φ and L2 = {a}. Which one of the following represents L1 L*2 ∪ L*1 ? (a) {e} (b) Φ (c) a* (d) {e, a} (GATE 2013: 1 Mark) 83. Which of the following statements is/are FALSE? 1.  For every non-deterministic Turing machine, there exists an equivalent deterministic Turing machine. 2.  Turing recognizable languages are closed under union and complementation. 3. Turing decidable languages are closed under intersection and complementation.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 232

0

0

0, 1



85.

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. A accepts all strings over {0, 1} of length at least 2. (a) 1 and 3 only (b) 2 and 4 only (c) 2 and 3 only (d) 3 and 4 only (GATE 2013: 2 Marks) 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 (b) 3 and 4 only (c) 2 and 3 only (d) 2 and 3 only (GATE 2013: 2 Marks)

86. Consider the following languages.

{ = {0 1 0

}

L1 = 0 p1q 0 r p, q, r ≥ 0 L2

p q

r

p, q, r ≥ 0, p ≠ r

}

Which one of the following statements is FALSE? (a) L2 is context-free. (b) L1 ∩ L2 is context-free. (c) Complement of L2 is recursive. (d) Complement of L1 is context-free but not regular. (GATE 2013: 2 Marks) 87. Which one of the following is TRUE? (a) The language L = {a n b n | n ≥ 0} is regular. (b) The language L = {a n | n is prime} is regular.

11/13/2018 11:11:17 AM

Chapter 6  • Theory of Computation

233

(c) The language L = {w | w has 3k + 1b ’s for some k ∈ 93. Let N with ∑ = {aa,language b}} L be and L be its complement. Which of = {w | w has 3k + 1b ’s for some k ∈ N with ∑ = {a, b}} is regular. the following is NOT a viable possibility? (d) The language L = {ww | w ∈∑ * with ∑ = {0,1}} is regular. (GATE 2014: 1 Mark) 88. Consider the finite automaton in the following figure. 1

0,1 1 q0

q1

0,1

q2

0,1

q3

What is the set of reachable states for the input string 0011? (a) {q1, q2, q3} (b) {q0, q1} (c) {q0, q1, q2, q3} (d) {q3} (GATE 2014: 1 Mark)

89. If L1 = {a n | n ≥ 0} and L2 = {b n | n ≥ 0} , Consider (I) L1⋅L2 is a regular language (II) L1⋅L2 = {an bn | n ≥ 0}

Which one of the following is CORRECT? (a) Only (I) (b) Only (II) (c) Both (I) and (II) (d) Neither (I) nor (II) (GATE 2014: 1 Mark)

90. Let A ≤m B denotes that language A is mapping reducible (also known as many-to-one reducible) to language B. Which one of the following is FALSE? (a) If A ≤m B and B is recursive then A is recursive. (b) If A ≤m B and A is undecidable then B is undecidable. (c) If A ≤m B and B is recursively enumerable then A is recursively enumerable. (d) If A ≤m B and B is not recursively enumerable then A is not recursively enumerable. (GATE 2014: 1 Mark) 91. The length of the shortest string NOT in the language (over S = {a,b}) of the following regular expression is . a*b* (ba)* a* (GATE 2014: 1 Mark) 92. Let ∑ be a finite non-empty alphabet and let 2∑* be the power set of ∑ *. Which one of the following is TRUE? (a) Both 2∑* and ∑* are countable (b) 2∑* is countable ∑* is uncountable (c) 2∑* is uncountable and ∑* is countable (d) Both 2∑* and ∑* are uncountable (GATE 2014: 1 Mark)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 233

(a) Neither L nor (b) One of L and is not r.e. (c) Both L and L (d) Both L and L

L is recursively enumerable (r.e.). L is r.e. but not recursive; the other are r.e. but not recursive. are recursive. (GATE 2014: 2 Marks)

94. Which of the regular expressions given below represent the following DFA? (I) 0*1(1 + 00*1)* (II) 0*1*1 + 11*0*1 (III) (0 + 1)*1 (a) I and II only (b) I and III only (c) II and III only (d) I, II, and III (GATE 2014: 2 Marks) 95. Let be the encoding of a Turing machine as a string over S = {0,1}. Let L = { | M is a Turning 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 (GATE 2014: 2 Marks) 96. Let L1 = {w ∈ {0,1}*|w has at least as many occurrences of (110)’s as (011)’s}. Let L2 = {w ∈ {0,1}*|w has at least as many occurrence of (000)’s as (111)’s}. Which one of the following is TRUE? (a) L1 is regular but not L2 (b) L2 is regular but not L1 (c) Both L1 and L2 are regular (d) Neither L1 nor L2 are regular (GATE 2014: 2 Marks) 97. 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. (GATE 2014: 2 Marks) 98. Consider the following languages over the alphabet = {0,1,c}

11/13/2018 11:11:17 AM

234

GATE CS AND IT Chapter-wise Solved Papers

Consider the DFAs M and N given above. The number of states in a minimal DFA that accepts the languages L(M) ∩ L(N) is . (GATE 2015: 2 Marks)

L1 = {0 n1n | n ≥ 0} L2 = {wcw r | w ∈{0,1}*} {} L3 = {ww r | w ∈{0,1}*} Here, w r is the reverse of the string w. Which of these languages are deterministic context-free languages? (a) None of the languages (b) Only L1 (c) Only L1 and L2 (d) All the three languages (GATE 2014: 2 Marks) 99. For any two languages L1 and L2 such that L1 is context-free and L2 is recursively enumerable but not recursive, which of the following is/are necessarily true? I. L1 (complement of L1) is recursive II. L2 (complement of L2) is recursive IV. L1 ∪ L2 is recursively enumerable (b) III only (d) I and IV only (GATE 2015: 1 Mark)

100. Consider the following statements

  I. The complement of every Turing decidable language is Turing decidable.



II. There exists some language which is in NP but is not Turing decidable.



III. If L is a language in NP, L is Turing decidable.



Which of the above statements is/are true?

(a) Only II (c) Only I and II

(b) Only III (d) Only I and III (GATE 2015: 1 Mark)

101. Let L be the language represented by the regular expression ∑*0011∑* where ∑ = {0, 1}. What is the minimum number of states in a DFA that ­recognizes  L (complement of L)? (a) 4 (b) 5 (c) 6 (d) 8 (GATE 2015: 1 Mark) 102. b

a

a

a

b b

N:

M: b

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 234

1, Z → 1 Z 0, Z → 0 Z q0

0, 1Z → Z 1, 0Z → Z q1

0/1/∈, Z → Z

III. L1 is context-free (a) I only (c) III and IV only

103. Consider the NPDA 〈Q = {q0, q1, q2}, ∑ = {0, 1}, Γ = {0, 1, Γ} ⊥ d, q0, ⊥, F = {q2}〉, where (as per usual convention) Q is the set of states, ∑ is the input alphabet, d is the stack alphabet, d is the state transition function, q0 is the initial state, ⊥ is the initial stack symbol, and F is the set of accepting states. The state transition is as follows:

a

q2

∈, ⊥ → ∈

Which one of the following sequences must follow the string 101100 so that the overall string is accepted by the automaton? (a) 10110 (b) 10010 (c) 01010 (d) 01001 (GATE 2015: 2 Marks) 104. The number of states in the minimal deterministic finite automaton corresponding to the regular expression . (0 + 1)*(10) is (GATE 2015: 2 Marks) 105. Which of the following languages is/are regular? L1:{wxw R|w, x ∈ {a,b}* and |w|, |x| > 0}, w R is the reverse of string w L2: {anbm | m ≠ n and m, n ≥ 0} L3: {apbqcr | p, q, r ≥ 0} (a) L1 and L3 only (c) L2 and L3 only

(b) L2 only (d) L3 only (GATE 2015: 2 Marks)

106. Consider the alphabet Σ = {0.1}, the null/empty string l and the sets of strings X0, X1, and X2 generated by the corresponding non-terminals of a regular grammar X0, X1, and X2 are related as follows. X0 = 1 X1 X1 = 0 X1 + 1 X2 X2 = 0 X1 + {l} Which one of the following choices precisely represents the strings in X0?

11/13/2018 11:11:18 AM

Chapter 6  • Theory of Computation

(a) (b) (c) (d)

10(0* + (10)*)1 10(0* + (10)*)*1 1(0 + 10)*1 10(0 + 10*)*1 + 110(0 + 10)*1 (GATE 2015: 2 Marks)

107. Which of the following languages are context-free? L1 = {ambnanbm|m, n ≥ 1} L2 = {ambnambn|m, n ≥ 1} L3 = {ambn|m = 2n + 1} (a) L1 and L2 only (b) L1 and L3 only (c) L2 and L3 only (d) L3 only (GATE 2015: 2 Marks)

Consider the following statements: P: L1 is regular Q: L2 is regular Which one 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 (GATE 2016: 1 Mark) 113. Consider the following types of languages: L1: Regular L2: Context-free, L3: Recursive, L4: Recursively enumerable. Which of the following is/are TRUE?    I.  L3 ∪ L4 is recursively enumerable

108. Which of the following language is generated by the given grammar? S → aS | bS |ε n m (a) {a b | n, m ≥ 0} (b)  {w ∈ {a,b}}*|w has equal number of a’s and b’s} (c) {a | n ≥ 0} ∪ {b | n ≥ 0} ∪ {a b | n ≥ 0} (d) {a, b}* (GATE 2016: 1 Mark) n

n

n

110. Which one of the following regular expressions represents the language: the set of all binary strings having two consecutive 0s and two consecutive 1s? (a) (0 + 1)*0011(0 + 1)* + (0 + 1)*1100(0 + 1)* (b) (0 + 1)*(00(0 + 1)*11 + 11(0 + 1)*00) (0 + 1)* (c) (0 + 1)*00(0 + 1)* + (0 + 1)*11(0 + 1)* (d) 00(0 + 1)*11 + 11(0 + 1)*00 (GATE 2016: 1 Mark) 111. The number of states in the minimum sized DFA that accepts the language defined by the regular expression (0 + 1)*(0 + 1)(0 + 1)* is ______. (GATE 2016: 1 Mark) 112. Language L1 is defined by the grammar: S1 → aS1b|ε Language L2 is defined by the grammar: S2 → abS2|ε

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 235

 II.  L2 ∪ L3 is recursive III.  L*1 ∩ L2 is context-free IV.  L1 ∪ L2 is context-free (a) I only (c) I and IV only

n

109. Which of the following decision problems are undecidable? I. Given NFAs N1 and N2, is L(N1) ∩ L(N2) = Φ? II. Given a CFG G = (N, ∑, P, S) and a string x ∈ ∑*, does x ∈ L(G)? III. Given CFGs G1 and G2, is L(G1) = L(G2)? IV. Give a TM M, is L(M) = Θ? (a) I and IV only (b) II and III only (c) III and IV only (d) II and IV only (GATE 2016: 1 Mark)

235

(b) I and III only (d) I, II and III only (GATE 2016: 1 Mark)

114. Consider the following context-free grammars: G1 : S → aS|B, B → b|bB G2 : S → aA|dB, A → aA|B|ε, B → bB|ε

Which one of the following pairs of languages is generated by G1 and G2, respectively? (a)  {ambn|m > 0 or n > 0} and {ambn|m > 0 and n > 0} (b) (ambn|m > 0 and n > 0} and {ambn|m > 0 or n ≥ 0} (c)  {ambn|m ≥ 0 or n > 0} and {ambn|m > 0 and n > 0} (d)  {ambn|m ≥ 0 and n > 0} and {ambn|m > 0 or n > 0} (GATE 2016: 2 Marks)

115. Consider the transition diagram of a PDA given below with input alphabet ∑ = {a, b} and stack alphabet Γ = {X, Z}. Z is the initial stack symbol. Let L denote the language accepted by the PDA. a,X/XX a,Z/XZ

b,X/ε b,X/ε

ε,Z/Z

Which one of the following is TRUE? (a)  L = {ambn|n ≥ 0} and is not accepted by any finite automata (b)  L = {a n | n ≥ 0} ∪ {a n b n | n ≥ 0} and is not accepted by any deterministic PDA (c)  L is not accepted by any Turing machine that halts on every input

11/13/2018 11:11:20 AM

236

GATE CS AND IT Chapter-wise Solved Papers

(d)  L = {a n | n ≥ 0} ∪ {a n b n | n ≥ 0} and is deterministic context-free (GATE 2016: 2 Marks) 116. Let X be a recursive language and Y be recursively enumerable but not recursive language. Let W and Z be two languages such that Y reduces to W, and Z reduces to X (reduction means the standard many-one reduction). Which one of the following statements is TRUE? (a) W can be recursively enumerable and Z is recursive. (b) W can be recursive and Z is recursively enumerable. (c) W is not recursively enumerable and Z is recursive. (d) W is not recursively enumerable and Z is not recursive. (GATE 2016: 2 Marks) 117. Consider the following two statements: I. If all states of an NFA are accepting states then the language accepted by the NFA is ∑*. II. There exists a regular language A such that for all languages B, A ∩ B is regular.

Which one of the following is CORRECT? (a) Only I is true (b) Only II is true (c) Both I and II are true (d) Both I and II are false (GATE 2016: 2 Marks)

118. Consider the following languages: L1 = {anbmcn+m : m, n ≥ 1} L2 = {anbnc2n : n ≥ 1}

Which one of the following is TRUE? (a) Both L1 and L2 are context-free. (b) L1 is context-free while L2 is not context-free. (c) L2 is context-free while L1 is not context-free. (d) Neither L1 nor L2 is context-free. (GATE 2016: 2 Marks)

119. Consider the following languages. L1 = {〈M〉|M takes at least 2016 steps on some input}, L2 = {〈M〉|M takes at least 2016 steps on all inputs} and L3 = {〈M〉|M accepts ε},

where for each Turing machine M, 〈M〉 denotes a specific encoding of M. Which one of the following is TRUE? (a) L1 is recursive and L2, L3 are not recursive (b) L2 is recursive and L1, L3 are not recursive (c) L1, L2 are recursive and L3 is not recursive (d) L1, L2, L3 are recursive (GATE 2016: 2 Marks)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 236

120. Consider the language L given by the regular expression (a + b) * b(a + b) over the alphabet {a, b}. The smallest number of states needed in a deterministic finite-state automation (DFA) accepting L is ______. (GATE 2017: 1 Mark) 121. Let L1, L2 be any two context-free languages and R be any regular language. Then which of the following is/are CORRECT? I. L1 ∪ L2 is context-free. II. L1 is context-free. III. L1 - R is context-free. IV. L1 ∩ L2 is context-free. (a) I, II and IV only (c) II and IV only

(b) I and III only (d) I only (GATE 2017: 1 Mark)

122. Identify the language generated by the following grammar, where S is the start variable. S → XY X → aX | a Y → aY b | ∈ m n (a) {a b | m ≥ n, n > 0} (b) {ambn | m ≥ n, n ≥ 0} (c) {ambn | m > n, n ≥ 0} (d) {ambn | m > n, n > 0} (GATE 2017: 1 Mark) 123. The minimum possible number of states of a deterministic finite automaton that accepts the regular language L = {w1aw2 | w1 , w2 ∈ ( a, b)*, w1 = 2, w2 ≥ 3} is ______. (GATE 2017: 1 Mark) 124. Consider the context-free grammars over the alphabet {a, b, c} given below. S and T are non-terminals. G1 : S → aSb | T, T → cT | ∈ G2 : S → bSa | T, T → cT | ∈ The language L(G1 ) ∩ L(G2 ) is (a) finite (b) not finite but regular (c) context-Free but not regular (d) recursive but not context-free (GATE 2017: 2 Marks) 125. Consider the following languages over the alphabet ∑ = {a, b, c}. Let L1 = {an bn cm | m, n ≥ 0} and L2 = {am bn cn | m, n ≥ 0}. I.  L1 ∪ L2 II.  L1 ∩ L2

11/13/2018 11:11:22 AM

Chapter 6  • Theory of Computation

(a) I only (c) I and II

(b) II only (d) Neither I nor II (GATE 2017: 2 Marks)

126. Let A and B be finite alphabets and let # be a symbol outside both A and B. Let f be a total function from A* to B*. We say f is computable if there exists a Turing machine M which given an input x in A*, always halts with f(x) on its tape. Let Lf denote the language {x # f(x) | x ∈ A*}. Which of the following statements is true? (a)  f is computable if and only if Lf is recursive. (b)  f is computable if and only if Lf is recursively enumerable. (c) If f is computable, then Lf is recursive but not conversely. (d) If f is computable, then Lf is recursively enumerable but not conversely. (GATE 2017: 2 Marks) 127. Let d denote the transition function and dˆ  denote the extend transition function of the ∈-NFA whose transition table is given below:

d

1. e

a

b

q0

{q2}

(q1)

(q0)

q1

{q2}

(q2)

(q3)

q2

{q0}





q3





(q2)

The dˆ ( q2 , aba) is iˆ

(a) ∅ Æ (c) (q0, q1, q2)

(b) (q0, q1, q3) (d) (q0, q2, q3) (GATE 2017: 2 Marks)

128. Consider the following languages. L1 = {ap| p is a prime number} L2 = {anbmc2m | n ≥ 0, m ≥ 0} L3 = {anbnc2n | n ≥ 0} L4 = {anbn | n ≥ 1} Which of the following are CORRECT? I. L1 is context-free but not regular. II. L2 is not context-free. III. L3 is not context-free but recursive. IV. L4 is deterministic context-free. (a) I, II and IV only (c) I and IV only

(b) II and III only (d) III and IV only (GATE 2017: 2 Marks)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 237

237

129. Let L(R) be the language represented by regular expression R. Let L(G) be the language generated by a context-free grammar G. Let L(M) be the language accepted by a Turing machine M. Which of the following decision problems are undecidable? I. Given a regular expression R and a string w, is w ∈ L( R ) ? II. Given a context-free grammar G, is L(G) = Æ∅? III. Given a context-free grammar G, is L(G) = Σ* for some alphabet Σ? IV.  Given a Turing machine M and a string w, is w ∈ L( M ) ? (a) I and IV only (c) II, III and IV only

(b) II and III only (d) III and IV only (GATE 2017: 2 Marks)

130. Let N be an NFA with n states. Let k be the number of states of a minimal DFA which is equivalent to N. Which one of the following is necessarily true? k≥n (a) k ≥ 2n (b) k ≤ 2n (c) k ≤ n2 (d) (GATE 2018: 1 Mark) 131. Which one of the following statements is FALSE? (a) Context-free grammar can be used to specify both lexical and syntax rules. (b) Type checking is done before parsing. (c) High-level language programs can be translated to different Intermediate Representations. (d) Arguments to function can be passed using the program stack. (GATE 2018: 1 Mark) 132. Assume that multiplying a matrix G1 of dimension p × q with another matrix G2 of dimension q × r requires pqr scalar multiplications. Computing the product of n matrices G1G2G3….Gn can be done by parenthesizing in different ways. Define GjGi + j as an explicitly computed pair for a given paranthesization if they are directly multiplied. For example, in the matrix multiplication chain G1G2G3G4G5G6 using parenthesization (G1(G2G3)) (G4(G5G6)), G2G3 and G5G6 are the only explicitly computed pairs. Consider a matrix multiplication chain F1F2F3F4F5, where matrices F1,F2,F3,F4 and F5 are of dimensions 2 × 25, 25 × 3, 3 × 16, 16 × 1 and 1 × 1000, respectively. In the parenthesization of F1F2F3F4F5 that minimizes the total number of scalar multiplications, the explicitly computed pairs is/are

11/13/2018 11:11:24 AM

238

GATE CS AND IT Chapter-wise Solved Papers

(a) F1F2 and F3F4 only (c) F3F4 only

(b) F2F3 only (d) F1F2 and F4F5 only (GATE 2018: 2 Marks)

133. Consider the following languages: I. {am bn cp dq | m + p = n + q, where m, n, p, q ≥ 0} II. {am bn cp dq | m = n and p = q, where m, n, p, q ≥ 0} III.  {am bn cp dq | m = n = p and p q, where m, n, p, q ≥ 0} IV.  {am bn cp dq | mn = p + q, where m, n, p, q ≥ 0} Which of the languages above are context-free? (a) I and IV only (b) I and II only (c) II and III only (d) II and IV only (GATE 2018: 2 Marks) 134. Consider the following problems. L(G) denotes the language generated by a grammar G. L(M) denotes the language accepted by a machine M. (I) For an unrestricted grammar G and a string w, whether w ∈ L(G) (II) Given a Turing machine M, whether L(M) is regular (III)  Given two grammars G1 and G2, whether L(G1) = L(G2) (IV) Given an NFA N, whether there is a deterministic PDA P such that N and P accept the same language. Which one of the following statements is correct? (a) Only I and II are undecidable (b) Only III is undecidable (c) Only II and IV are undecidable (d) Only I, II and III are undecidable (GATE 2018: 2 Marks)

135. A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a, b, c}. T1 : a? (b/c)* a T2 : b? (a/c)*b T3 : c? (b/a)*c Note that ‘x?’ means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix. If the string bbaacabc is processed by the analyzer, which one of the following is the sequence of tokens it outputs? (a) T1T2T3 (b) T1T1T3 (c) T2T1T3

(d) T3T3 (GATE 2018: 2 Marks)

136. Given a language L, define Li as follows: L0 = {e} Li = Li −1 ⋅ L for all i > 0 The order of a language L is defined as the smallest k such that Lk = Lk+1. consider the language L1 (over alphabet 0) accepted by the following automaton. 0 0 0 The order of L1 is

. (GATE 2018: 2 Marks)

Answer Key  1. (c)

 2. (b)

 3. (d)

 4. (a)

 5. (a)

 6. (b)

 7. (b)

 8. (d)

 9. (d)

10. (b)

11. (b)

12. (a)

13. (b)

14. (a)

15. (a)

16. (c)

17. (d)

18. (a)

19. (c)

20. (b)

21. (a)

22. (b)

23. (b)

24. (c)

25. (a)

26. (b)

27. (c)

28. (b)

29. (c)

30. (b)

31. (b)

32. (d)

33. (a)

34. (b)

35. (b)

36. (d)

37. (c)

38. (c)

39. (a)

40. (d)

41. (b)

42. (b)

43. (d)

44. (b)

45. (b)

46. (a)

47. (b)

48. (c)

49. (c)

50. (b)

51. (d)

52. (a)

53. (d)

54. (d)

55. (a)

56. (c)

57. (c)

58. (c)

59. (a)

60. (b)

61. (c)

62. (d)

63. (b)

64. (a)

65. (c)

66. (c)

67. (b)

68. (b)

69. (d)

70. (c)

71. (c)

72. (c)

73. (b)

74. (a)

75. (b)

76. (c)

77. (c)

78. (b)

79. (d)

80. (b)

81. (d)

82. (a)

83. (c)

84. (d)

85. (d)

86. (d)

87. (c)

88. (a)

89. (a)

90. (d)

91. (3)

92. (c)

93. (c)

94. (d)

95. (b)

96. (a)

97. (a)

98. (c)

99. (d)

100. (d)

101. (b)

102. (1)

103. (b)

104. (3)

105. (a)

106. (c)

107. (b)

108. (d)

109. (c)

110. (b)

111. (2)

112. (c)

113. (d)

114. (d)

115. (d)

116. (c)

117. (d)

118. (b)

119. (c)

120. (4)

121. (b)

122. (c)

123. (8)

124. (b)

125. (a)

126. (a)

127. (c)

128. (d)

129. (d)

130. (d)

131. (b)

132. (c)

133. (b)

134. (d)

135. (d)

136. (2)

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 238

11/13/2018 11:11:24 AM

Chapter 6  • Theory of Computation

239

ANSWERS WITH EXPLANATION 1.

Topic: Regular and Context-Free Languages (c) Given S and T are languages over Σ = {a, b}, where,

6.

Topic: Context-Free Languages (b) A context-free language is closed under, union, reversal, concatenation, kleene star. Therefore, statement (b) is true. The union of two context free languages is context free.

7.

Topic: Finite Automata (b)  Given an arbitrary non-deterministic finite automaton (NFA) with N states, the maximum number of states in an equivalent minimized DFA is at least 2N.

8.

Topic: Finite Automata (d)  Given that Σ = {a, b}

S = (a + b*)* T = (a + b)* Using deterministic finite automata we can determine the state to which it can move. So, DFA of S is (a + b)* Therefore, S=T 2.

Topic: Regular Expressions and Finite Automata (b)  Given grammar is S → 0S0/00. L denotes the language generated by this grammar. Here, L is regular because a regular expression can be written for this as,

a’s are divisible by 6 and b’s are divisible by 8. So, we can construct DFA for strings divisible by 6 and 8. Then, minimum states in DFA divisible by 6 are 0, 1, 2, 3, 4, and 5. And, minimum states in DFA divisible by 8 are 0, 1, 2, 3, 4, 5, 6, and 7. Therefore, minimum states in DFA over Σ = {a, b} is 6 × 8 = 48.

(00)+ L is not 0+ because 0+ contains arbitrary string over alphabet 0 with any number of 0’s but L can have only even number of 0’s. Therefore, L is regular but not 0+. 3.

4.

5.

Topic: Regular Languages (d)  A regular language L over {a} whose minimal finite state automation has two states then either L must be {an/n is odd} or L must be {an/n is even}. When first state is final, it accepts odd number of a’s and when second state is final, it accepts even number of a’s. Topic: Context-Free Languages (a)  Given (P1): Does a given finite state machine accept a given string. A finite state machine always halts in final or non-final state. Therefore, (P1) is decidable. Given (P2): Does a given context-free grammar generate on infinite number of strings. If the given context free grammar generates any string of length between n and (2n – 1) then it is infinite. Therefore, (P2) is decidable. Thus, both (P1) and (P2) are decidable. Topic: Regular Expressions (a) Given: S1: {02n |n ≥ 1|} is a regular language. S2: {0m|n 0m+n |m ≥ 1 and n ≥ 1|} is a regular language. Here, a deterministic finite automaton can be built for S1. The input string has even number of 0’s so S1 is regular. Deterministic finite automaton cannot be built for S2. This requires stack thus S2 is not regular.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 239

9.

Topic: Regular Languages (d)  Given that L1 = {ww | w ∈{a, b}*} L 2 = {ww R | w ∈{a, b}*, w R is the reverse of w} L3 = {0 2i | i is an integer} 2

L 4 = {0i | i is an integer} A language is known as regular language if there exists a finite automaton which recognizes it. Here, L3 is regular since, a DFA can be constructed that accepts a string if it is either empty or contains even number of zeros. 10. Topic: Turing Machines (b)  Given Turing machine M over the input alphabet ∑ state q of M and a word w ∈Σ *. This is a state entry problem. This problem can be reduced as construct a Turing machine M with final state q. Run Turing machine R with inputs M, q, w. Put w as input to M. If M halts in final state q then X is decidable. If M goes in infinite loop then X is undecidable. Therefore, X is undecidable but partially decidable.

11/13/2018 11:11:25 AM

240

GATE CS AND IT Chapter-wise Solved Papers

11. Topic: Pushdown Automata (b)  A pushdown automaton is used for context-free languages in which length of elements is unrestricted and length of one element is related to the other. In the given case, the stack is limited to 10 items therefore, the language accepted by a pushdown automaton is best described as regular. 12. Topic: Finite Automata (a)  We have 0/01 A

B

0/00

0/01

20. Topic: Context-Free Grammars (b)  Option (a) is False. G is ambiguous due to the possibility of two parsing trees for the same string. Option (b) is True. Let x = ab and y = ba, so abba does not belong to L(G). 21. Topic: Turing Machines (a)  M does not halt on any string in (0+1)+.

1/10

22. Topic: Context-Free Languages (b)  L contains strings that halts on w and does not halt on w. L can be recursively enumerable if it contains valid strings. So, L is not recursively enumerable, but L is recursively enumerable.

The output of the given finite state machine is the sum of the present and previous bits of the input. Let assume input be 1101. Then, we have (A,1) → (B,01) Present bit + Previous bit = 0 + 1 = 01 13. Topic: Finite Automata (b)  Given that, language {x | length of x is divisible by 3} The smallest finite automaton which accepts the language has 3 states. 14. Topic: Context-Free Grammar (a) The complement of a recursive language is recursive; this statement is true. The complement of a recursively enumerable language is recursively enumerable; this statement is false. The complement of a recursive language is either recursive or recursively enumerable; this statement is false. The complement of a context-free language is context free; this statement is false. 15. Topic: Turing Machine (a) To evaluate an expression without any embedded function calls only one stack is enough. 16. Topic: Pumping Lemma (c)  Reduction from the 3-SAT problem to Π is NP hard and reduction from Π to 3-SAT shows that Π is in NP. As Π is in NP and it is NP hard, so it can be inferred that Π is NP complete. 17. Topic: Context-Free Languages (d)  L is recursive because recursive languages can be effectively enumerated in lexicographic order.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 240

19. Topic: Finite Automata (c) Strings that are accepted are: 1001001, 1001011, 1001101, 1001111, 1111001, 1101001, and 1011001.

C 1/10

1/01

18. Topic: Regular Expressions (a) 

23. Topic: Pushdown Automata (b) 0 0, 1

0, 1 Strings accepted by resulting NFA: {∈,0,1,00,01,10,11….} = (0+1)* 24. Topic: Pumping Lemma (c) 3-SAT are NP-complete problems. 2-SAT are P problems. 25. Topic: Finite Automata (a)  The machine accepts strings that have 1’s divisible by 3 and 0’s divisible by 2. For example, strings 11100, 10011, 00111 will be accepted by this machine and strings 1001, 10111 will be rejected. 26. Topic: Pushdown Automata (b) The given language can be accepted by PDA, but cannot be accepted by finite automata. So, it is only context-free not regular. Finite automata cannot accept context free language, it only accepts regular language. 27. Topic: Context-Free Languages (c) Strings formed from given grammar are: b, bb, babaab, abbb, and so on. This means the number of a’s are multiples of 3.

11/13/2018 11:11:26 AM

Chapter 6  • Theory of Computation

According to given grammar, string accepted is baaa. Options (a), (b) and (d) are false. Only option (c) is ­correct. 28. Topic: Regular Languages (b) For L1, the membership algorithm can be constructed as follows. For an arbitrary wi # wj,

(i)  If wi, wj ∈ L1 and i < j then wi # wj (ii) If wi ∉ L1 or wj ∉ L2 or i ≥ j, then wi # wj ∉ L2. This implies that L2 is also recursive, so S1 is true. A similar membership algorithm is not possible for L2, so S2 is not necessarily true.

29. Topic: Pumping Lemma (c)  Any problem P is undecidable if any known undecidable problem can be reduced to P. So, option (c) is correct. 30. Topic: Finite Automata (b)  Output function is:

37. Topic: Finite Automata (c)  Option (a) is finite, can be accepted by DFA. Option (b), only prefix comparison is possible by DFA, so it is regular. Option (c), whole string is compared, which is not possible by DFA because it does not have memory. Option (d), mod machines can be made using DFA. 38. Topic: Context-Free Grammars (c)  Both options (a) and (b) can produce equal number of a’s and b’s, which should not be produced according to grammar. Option (d) cannot produce all the strings. So, option (c) is the correct answer. 39. Topic: Context-Free Grammars (a) This can be checked by producing various strings of different length. S → AC

PS

0

1

0

0

1

1

1

0

The output computes 2’s complement of input number. 31. Topic: Finite Automata (b)  DFA contains every “a” followed by at least two b’s due to self-loops. 32. Topic: Pushdown Automata (d) Power of NFA and DFA is same. But nondeterministic PDA is more powerful than deterministic PDA. 33. Topic: Context-Free Grammar (a)  L1 and L2 both are context-free l­anguages. Their intersection may or may not be context-free. So, option (a) is false. 34. Topic: Regular Languages (b)  Recursive languages are closed under complementation but recursive enumerable languages are not. 35. Topic: Context-Free Languages (b)  L2 can be accepted by DPDA, so it is a deterministic context-free language. L1 is non-deterministic context free and L3 in not context-free language. 36. Topic: Context-Free Languages (d) Only L1 is accepted by pushdown automata as only L1 can be written as a context-free language. L2 is not context free, while L3 is context sensitive.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 241

241

S → aC S → aaCb S → aab Here, l = 2 and m = 1, which satisfies the equation max (l, m) + 2 = 4. 40. Topic: Context-Free Languages (d)  DFA is possible for L. If for any ­language, we can make DFA then that language will be regular language. So, L is regular. 41. Topic: Context-Free Grammar (b)  I. G is ambiguous. Null can be produced using multiple rules [S → e and S → SS]. Two parse trees will be formed.  II. It cannot produce all the combinations of equal a’s and b’s such as string aabb is not possible. III. Language accepted is (ab + ba)*, which is ­regular. Regular languages are also accepted by DPDA. 42. Topic: Context-Free Languages (b) Option (a) is true. DCFL is closed under regular intersection. Option (b) is false. Intersection is recursively enumerable. Options (c) and (d) are true. 43. Topic: Finite Automata (d)  Nine states are required. The length of string will be 8. Total states required are 8 + 1 = 9.

11/13/2018 11:11:26 AM

242

GATE CS AND IT Chapter-wise Solved Papers

44. Topic: Undecidability (b) No algorithm exists to check the ambiguity of grammar. 45. Topic: Regular Expressions (b)  In option (a), anbn is subset of a* b*; but it is not regular. Option (b) is correct. Option (c) is union of two context-free languages, and thus is regular. Option (d) is infinite union of finite sets, and thus is not regular. 46. Topic: Finite Automata (a)  Divisible by 3 and 5 = 3 × 5 = 15 states are required. 47. Topic: Context-Free Languages (b)  L is accepted by DPDA. So, it is deterministic CFL. 48. Topic: Regular Languages (c)  Finite automata do not have memory element. So, they cannot remember the symbols. Hence, options (a) and (d) are incorrect. 49. Topic: Push-Down Automata (c) One a is compulsory. Minimum string is a that is accepted by the automaton. b*a (a + b)* is regular and accepted by the automaton. 50. Topic: Finite Automata (b)  Minimized DFA is: b a, b q0

a

q1

51. Topic: Turing Machines (d)  The options are checked by using pumping lemma for regular and context-free languages. It is found that the language is not regular, and hence not context free; but is accepted by the Turing machine. 52. Topic: Undecidability (a)  Statements II and III are undecidable. The intersection of two regular languages is determined by an algorithm, and it can be determined whether the given grammar is context-free or not. So, statements I and II are decidable. 53. Topic: Context-Free Languages (d)  A theorem states that when L and L both are RE, then L is recursive.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 242

54. Topic: Turing Machines (d)  Option (d) is not necessarily true. Every recursive set is recursively enumerable, but the reverse is not necessarily true. 55. Topic: Finite Automata (a)  Option (a) represents the product correctly. 56. Topic: Context-Free Grammar (c)  Statement II: If e belongs to L(G), then the statement becomes false. 57. Topic: Regular Expressions (c)  E – R: In R, first w is checking the declaration of an identifier. F – P: Actual parameters anbm and formal parameters cndm. G – Q:  Arithmetic expressions with matched pair of parenthesis. H – S: S is generating palindrome strings. 58. Topic: Finite Automata (c)  P → e + 0(01*1 + 00)*01* Q → e + 0(10*1 + 00)*0 R → e + 0(10*1 + 10)*1 S  → e + 0(10*1 + 10)*10* 59. Topic: Finite Automata (a)  In statements II and III, m and n are dependent. As DFA do not have memory, cannot be accepted by DFA. Statements I and IV are regular sets. 60. Topic: Regular Expressions (b)  Strings generated by this grammar are odd length palindromes, for example, aaa, aba, ababa. 61. Topic: Regular Expressions (c) Given regular expression must have atleast two zeros 0(0 + 1)*0…. 62. Topic: Context-Free Languages (d)  Both non-deterministic and deterministic PDA have different powers. Non-deterministic PDA can accept ambiguous grammars also. 63. Topic: Push-Down Automata (b)  Regular expressions: Lexical analysis Pushdown automata: Syntax analysis Dataflow analysis: Code optimization Register allocation: Code generation

11/13/2018 11:11:26 AM

Chapter 6  • Theory of Computation

64. Topic: Finite Automata (a) Present State

Output

(0, 0) →

1

(0, 1) →

0

(1, 0) →

0

(0, 1) →

1

With A = 0, B = 1 and output = 1 will require a string of length 3. 65. Topic: Context-Free Languages (c)  Intersection of two regular languages is regular, but L1 is not regular. 66. Topic: Finite Automata (c) The given DFA accepts all the strings ending with 00. 67. Topic: Context-Free Languages (b) Subtraction of recursive language and recursive enumerable is not necessarily recursive enumerable.

243

75. Topic: Finite Automata (b) Let n = 4, so L = a4k Five states are required for this machine. (n + 1) states are required for such a machine. 76. Topic: Turing Machines (c)  L1 is a regular language; L2 is a context-free language, and L3 is a context-sensitive language. 77. Topic: Context-Free Languages (c)  baaaaabaaaab is not derived from the given language. 78. Topic: Finite Automata (b)  Language accepted by this machine is a. First convert NFA to DFA: a

a

Take compliment of this DFA: a

68. Topic: Regular Expressions (b) Option (c) produces odd 1’s also, option (a) produces strings ending with 1 and option (d) does not produce zero 1’s. 69. Topic: Context-Free Languages (d) All are context-free languages as they are recognized by pushdown automata.

a Language accepted is {e}. 79. Topic: Finite Automata (d)  Complete DFA is given below: 00

70. Topic: Finite Automata (c)  n + 1 states are required for string of length n. 71. Topic: Context-Free Languages (c)  Regular languages are closed under complementation. 72. Topic: Undecidability (c) Tokens are recognized in lexical analysis phase of compiler. 73. Topic: Turing Machines (b)  NDPDA is more powerful than DPDA. 74. Topic: Finite Automata (a)  Given DFA does not accept bba which is accepted by option (c) and (d), and string b accepted by option (b). So, option (a) is answer.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 243

0

0 1 0

0

01

0, 1

0 q ε

0 1

0

1

10 0

1

1

1

11 1 80. Topic: Finite Automata (b)  R: It rains. C: Cricket match played.

11/13/2018 11:11:26 AM

244

GATE CS AND IT Chapter-wise Solved Papers

I1: R → ∼ C can be written as ∼R U ∼C C ∼R I2: R → ∼ C can be written as ∼R U ∼C ∼R ∼R U  C I1 is correct but I2 is not a correct inference. 81. Topic: Undecidability (d)  Regular and recursive languages are closed under complementation, but CFLs are not. 82. Topic: Context-Free Languages (a)  L*1 = e . So, L1 L*2 ∪ L*1 = e 83. Topic: Undecidability (c)  Option (a) is true. The power of non-deterministic and deterministic Turing machines is equivalent. Option (b) is true. Option (c) is false. They are not closed under complementation. Option (d) is true. 84. Topic: Finite Automata (d)  Statement (3) is false because minimal DFA can be constructed using two states only. Statement (4) is false, DFA accepts string “0”, of length 1. 85. Topic: Turing Machines (d) CFG is empty or not is decidable, and to test whether language accepted by DFA and NFA is same is also decidable. 86. Topic: Context-Free Languages (d)  L1 is regular and complement of regular language is also regular. 87. Topic: Regular Languages (c) (a) False. The language is not regular, because it requires memory for remembering number of a’s and b’s. (b) False. This is a recursive language. (c) True. The language is regular because DFA construction is possible. (d) False. It is a context-sensitive language. 88. Topic: Finite Automata (a)  With string ‘0011’, we can reach {q0, q1, q2} states. 89. Topic: Regular Languages (a)  In statement (1), concatenation of two regular languages is regular (property).

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 244



But in statement (2) L1⋅L2 = {an bn | n ≥ 0} is not regular because both the variables are independent in the given languages L1 and L2. So, only option (a) is correct.

90. Topic: Regular Languages (d)  As language A is mapping reducible to language B, we have f : ∈* → ∈* where for every w, w ∈ A ⇔ f (w) ∈B Hence, if A ≤m B and B is not recursively enumerable then A is not recursively enumerable. 91. Topic: Regular Expressions (3)  String of length 3 bab is not present. 92. Topic: Regular Expressions (c)  ∑* is countable infinite. The power set of countable infinite sets is uncountable. 93. Topic: Regular Languages (c)  Recursively enumerable languages are not closed under complement. Thus, both L and L cannot be both recursive enumerable. 94. Topic: Finite Automata (d)  The given DFA accepts all the strings ending with any number of 1’s. All the three expressions are ending with 1 and are accepted by the given DFA. 95. Topic: Undecidability (b)  Languages accepted by Turing machine are recursively enumerable. L is undecidable because Turing machine can halt or get stuck in infinite loop. 96. Topic: Context-Free Languages (a)  Only L1 is regular, construction of DFA is possible for L1. L2 is context free grammar, requires stack to remember count of 0’s and 1’s. 97. Topic: Undecidability (a)  There is no algorithm to check ambiguity of CFG. 98. Topic: Context-Free Languages (c)  L1 and L2 are accepted by DPDA, L3 is accepted by NDPDA. 99. Topic: Context-Free Languages (d)  Context-free language is also recursive and recursive is closed under complement. Therefore, statement I is true. Complement of recursive enumerable is not recursive. Hence, statement II is false. Context-free language is not closed under complement. Hence, statement III is false.

11/13/2018 11:11:27 AM

Chapter 6  • Theory of Computation

∼L1 is recursive and hence also recursive enumerable. L2 is recursive enumerable. RE languages are closed under union. Hence, statement IV is true. 100. Topic: Undecidability

(d)  Turing decidable languages are recursive languages. Recursive languages are closed under complement, that is, complement of every recursive language is recursive.

101. Topic: Finite Automata (b)  5 (n + 1) states are sufficient to represent 0011. 102. Topic: Finite Automata (1)  M accepts the strings ending with ‘a’. N accepts the strings ending with ‘b’. Thus, their intersection should accept an empty string.

245

106. Topic: Context-Free Grammars (c)  Strings formed by the given equations are represented by regular expression: 1(0 + 10)*1. 107. Topic: Context-Free Languages (b)  For identifying the context-free language, check whether the stack implementation is possible or not. L1 = {ambnanbm|m, n ≥ 1} Here, when we put m number of a’s and n number of b’s in stack, top of stack will contain n number of b’s. Thus, when n number of a’s comes in the string then pop b’s and when m number of b’s comes then pop a’s from stack. Thus, it is possible to count the a’s and b’s properly. Hence, this is a context-free language. Similarly, check for others. Thus, L1 and L3 are context free. 108. Topic: Context-Free Languages (d)

a,b 103. Topic: Pushdown Automata (b)  This PDA is accepts all strings of the form x0x′ or x1x′, where x′ is the reverse of the 1’s complement of x. The given string 101100 has 6 letters and we are given 5 letter strings. So, x0 is done, with x = 10110. Now, the stack contains 10110 and remaining string should be opposite and reverse to it, so that the stack becomes empty. So, 1’s complement of x = 01001 and x′ = 10010. 104. Topic: Finite Automata (3) 0,1 1

S → aS

bS

ε

↓ Clearly, these will produce any combination of a and b. Hence, {a, b}* is the correct answer. 109. Topic: Undecidability (c)  Instead of deciding on ‘Which problems are undecidable?’, let us focus on the decidability: I.  NFA’s are almost decidable. II.  Membership property. Problems III and IV are undecidable.

0

A

B

C

C

110. Topic: Regular Expressions (b)  Let us find a regular expression for the set of all binary strings containing two consecutive 0s and two consecutive 1s: •  Option (a) cannot generate 00011. •  Option (b) is correct. •  In option (c), 00 is given, which does not belong to given language. •  Option (d) ends with 11 or 00 and hence it cannot ­generate 001101.

105. Topic: Regular Languages (a)  L1 and L3 are regular since we can make a regular expression for them.

111. Topic: Finite Automata (2)  We have r = (0 + 1)* (0 + 1) (0 + 1)*. The number of states in minimal DFA is 2.

The equivalent DFA is 0

1 1

A

B 0

1

0

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 245

11/13/2018 11:11:27 AM

246

GATE CS AND IT Chapter-wise Solved Papers

0, 1

Now, it is clear that we have to produce one a and one b. Therefore,

0, 1 90

{a m b n m > 0 – n > 0

91  OR

0, 1 112. Topic: Regular Languages (c)  We have L1: S1 → aS1b|ε L2: S2 → abS2|ε •  L1: {a b |n < 0| → CFL (PDA) •  L2: (ab)* → Regular Therefore, statement P is false and statement Q is true. n n

113. Topic: Context-Free Languages (d)  It is given that L1: Regular language L2: Context-free language (CFL) L3: Recursive language L4: Recursively enumerable language (REL) •  Case I: L3 → Recursive; L3 ∪ L4 → REL •  Case II: L2 → Recursive; L3 → Recursive ⇒ L2 ∪ L3 → Recursive •  Case III: L*1 → Regular; L2 → CFL ⇒ L*1 ∩ L2 → CFL As CFL is closed when its intersection is with Regular, we have RL ∩ CFL → CFL •  Case IV: L1 is → Regular; L 2 → Recursive ⇒ L1 ∪ L2 → CFL which is not possible. Therefore, only the first three cases [Cases (I), (II) and (III)] are correct. 114. Topic: Context-Free Grammar (d) •  G1 : S → aS|B B → b|bB For both of the above cases, we cannot reach NULL. However, it is clear that a can be 0 if we reach S → B and then b has to be produced and it is clear that b has to be 1. Therefore, am, bn; m ≥ 0 and n > 0 •  G2 : S → aA|bB A → aA|B|ε B → bB|ε

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 246

 AND

We know that A and B as individuals can be NULL, but both simultaneously cannot be NULL. 115. Topic: Pushdown Automata (d) Since anbn cannot be accepted by any finite automata and first state is also a final state, option (d) is the true statement. 116. Topic: Regular Languages (c) •  X is recursive language, so X is also recursive. •  Y is recursively enumerable, but it is not ­recursive, so Y is not recursively enumerable language. •  A < B (i.e. A is reducible to B). That is, solving A cannot be “harder” than solving B.   1. If A is reducible to B, and B is decidable, then A is decidable. i. If A is reducible to B, and B is recursive, then A is recursive.   2. If A is undecidable, and reducible to B, then B is undecidable. ii. If B is recursively enumerable, and A is reducible to B, then A is recursively enumerable. iii. If A is not recursively enumerable, and reducible to B, then B is not recursively enumerable. Now, going back to the question, we have the following: •  Y is not recursively enumerable, and reducible to W, then W is not recursively enumerable [using statement 2(ii) given above]. •  Z is reducible to X and X is recursive, then Z is recursive [using statement 1(i) given above]. 117. Topic: Finite Automata (d)  Regular ∩ NCFL = CFL. Hence, both statements I and II are false. 118. Topic: Context-Free Languages (b) ⎫ ⎧ • L1 = ⎪⎨ a n b m c n + m : m, n ≥ 1⎪⎬ ↓ ↓ ↓ ⎩⎪ push push pop ⎭⎪ ⎧ ⎫ ⎪ n m ⎪ 2n • L2 = ⎨ a b c : n ≥ 1⎬ ↓ ↓ ↓ ⎪ push pop No technique ⎪ to check ⎩ ⎭ Hence, L1 is context-free while L2 is not context-free.

11/13/2018 11:11:30 AM

Chapter 6  • Theory of Computation

119. Topic: Turing Machines (c)  L1 is recursive; L2 is recursive; L3 is not recursive.

247

So the minimal DFA is a,b a,b

120. Topic: Finite Automata (4)  Regular expression = (a + b) * b(a + b) This is all strings whose second last bit is ‘b’. Minimal NFA is

a,b

a

a,b

a,b

a,b a, b

b

a, b

A

B

C

Converting it into minimal DFA by subset con­struction algorithm, we get a a

124. Topic: Context-Free Grammars (b)  Given that G1 : S → aSb | T, T → cT | ∈ G1 : S → bSb | T, T → cT | ∈ Language

a

L(G1 ) ∩ L(G2 ) = {a n c m b n } ∩ {a n c m b n } = {c m /m ≥ = 0}

b A

AB

AC

b b a

b

Hence, the minimum possible number of states of a DFA is 8.

ABC

Therefore, intersection is not finite but regular. 125. Topic: Context-Free Languages (a)  Given that 1.  L1 = {anbncm | m, n ≥ 0} 2.  L2 = {ambncn | m, n ≥ 0} As both L1 and L2 are context-free languages, according to the closure property, we have L1 ∪ L2 = CFL

which is a minimal DFA with 4 states. 121. Topic: Context-Free Languages (b) I. True. L1 is context-free and L2 is context-free. As we know, CFL ∪ CFL = CFL. So, L1 ∪ L2 is context-free. II. False. L1 = CFL = CSL. So, L1 is not context-­free. III. True. L1 − R = L1 ∩ R = CFL Regular = CFL. So,

L1 ∩ L2 ≠ CFL 126. Topic: Turing Machines (a)  Since the way computable is defined based on halting TM, it means computable is same as recursive. So, clearly f is computable iff Lf is recursive. 127. Topic: Finite Automata (c) b

L1 - R is context-free. IV. False. L1 ∩ L2 = CFL ∩ CFL = CSL. So, L1 ∩ L2 is not context-free.

q0

122. Topic: Context-Free Languages (c)  We know

a

∈ ∈

q2

∈,

a

b

X → {am | m ≥ 1} Y → {an bn | n ≥ 0}

q1



Therefore, S → {am bn | m > n, n ≥ 0} 123. Topic: Regular Languages (8)  Regular expression for L is (a + b) (a + b) a(a + b) (a + b) (a + b) (a + b)*

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 247

b

q3

From the above figure, we have

d ( q2 , aba) = q2 ⎯∈⎯ → q1 ⎯a⎯ → q0 ⎯∈⎯ → q2 ⎯∈⎯ → q0 ⎯b⎯ → q0 ⎯a⎯ → q1 As we can see, by taking transition of ‘aba’ from q2, we can reach three states, i.e. {q0, q1, q2}.

11/13/2018 11:11:32 AM

248

GATE CS AND IT Chapter-wise Solved Papers

128. Topic: Context-Free Languages (d) I. L1 is not context-free but it is context sensitive language (CSL). II.  L2 is context-free (only 1 comparison is there). III. L3 is not context-free but recursive (as it is CSL because two comparisons are there and every CSL is recursive). IV.  L4 is deterministic context-free. 129. Topic: Turing Machines (d) I. Membership property of regular language is decidable. II. Emptiness property of CFL is decidable. III. Universal property of CFL is undecidable. IV. Membership property of RE language is undecidable. 130. Topic: Finite Automata (d)  Number of states of NFA N = n Number of states of minimal DFA = k Converting NFA to DFA using subset construction algorithm, we have ∴ number of states of DFA = 2n These states can be converted from DFA to a minimal DFA with k number of states. Therefore, k ≤ 2n 131. Topic: Context-Free Grammar (b)  Type checking is not done before parsing, but compiler type checking is done after parsing phase. Type checking is the process of verifying that each operation execute in a program respects the type system of the language. Hence, option (b) is false. 132. Topic: Context-Free Languages (c) Since F5 is 1 * 1000 matrix, so anything multiplied by F6 will give a greater multiplication cost. So, F5 is multiplied in the last step. Therefore, sequence of minimal cost is

133. Topic: Context-Free Languages (b) Context-free grammar is a certain type of formal grammar. It is a set of production rules that describes all possible strings in a given formal language. Among the given languages, | ambncpdq | m + p = n + q is context-free language. We can arrange the equation as m - n + p - q = 0, which can be implemented using push, pop, push pop operations. | ambncpdq | m = n and p = q is context-free language, one comparison at a time can be done by PDA. 134. Topic: Context-Free Languages (d)       I. Membership problem of unrestricted grammar (i.e. REL) is undecidable as there is a possibility of entering into infinite loop.   II. Every regular language is REL, but REL may or may not be regular, i.e. undecidable. III. As the type of grammar is not given, the equivalence problem is undecidable in REL. IV.  Every regular language is deterministic CFL, i.e. decidable. Therefore, only I, II and III are undecidable. 135. Topic: Turing Machines (d)  Given string is bbaacabc The longest possible prefix can be obtained from T3, i.e. bbaac. Next abc prefix also obtained by T3. So prefix bbaacabc is obtained by T3T3. 136. Topic: Context-Free Languages (2) Given, L0 = {ε} Li = Li -1 - L for all i > 0 Now,

L1 = ∈+ 0(00) * L2 = 0* L3 = L2 L = 0 * ⋅ (∈+ 0(00)*) = 0 *



Therefore, L2 = L3 Thus, order of L is 2 such that L2 = L2+1.

(F1(F2(F3F4))(F5)) = 48 + 75 + 50 + 2000 = 2173 Thus, explicitly computed pairs are F3F4 only.

Ch wise GATE_CSIT_CH06_Theory of Computation.indd 248

11/13/2018 11:11:32 AM

Compiler Design

CHAPTER7

Syllabus Lexical analysis, parsing, syntax-directed translation. Runtime environments. Intermediate code generation.

Chapter Analysis Topic

GATE 2009

GATE 2010

GATE 2011

2

1

Lexical Analysis Parsing

1

GATE 2012

GATE 2013

GATE 2014

GATE 2015

GATE 2016

1 2

2

1

1

1

1

Runtime Environments

4

2

3

1

GATE 2018

2 2

Syntax-Directed Translation Intermediate Code Generation

GATE 2017

1

1

1

4 1 2

Important Formulas   7. Every LL(1) grammar will surely be LALR(1), but if any grammar is LALR(1) then it may or may not be LL(1).

1.

Time complexity of RDP is O(2n).

2.

Every regular grammar need not be LL(1), because that grammar may contain left factoring.

3.

Any ambiguous grammar cannot be LL(1).

  8. If any grammar is LALR(1), then it will surely be CLR(1).

4.

If any grammar contains left factoring, then it can’t be LL(1) grammar.

  9. CLR(1) is also known as LR(1).

5.

If given grammar contains left recursion, then it can’t be LL(1) grammar.

6.

10. Every LL(1) grammar will surely be CLR(1). 11. All LL(k) parsers are subset of LR(k) parser. 12. If the number of states in LR(0), SLR(1), CLR(1) and LALR(1) is n1, n2, n3, n4, respectively, then relation between them is

If grammar G is LL(1), then • It may be LR(0). • It may be SLR(1). • It will surely be LALR(1).

n1 = n2 = n4 ≤ n3

QUESTIONS 1.

Which of the following derivations does a top-down parser use while parsing an input string? The input is assumed to be scanned in left to right order. (a) Leftmost derivation

Ch wise GATE_CSIT_CH07_Compiler Design.indd 249

(b) Leftmost derivation traced out in reverse (c) Rightmost derivation (d) Rightmost derivation traced out in reverse (GATE 2000: 1 Mark)

11/13/2018 11:17:27 AM

250

GATE CS and IT Chapter-wise Solved Papers

2.

Given the following expression grammar: E→E*F|F+E|F F → F – | id Which of the following is true? (a) * has higher precedence than + (b) – has higher precedence than * (c) + and – have same precedence (d) + has higher precedence than * (GATE 2000: 2 Marks)

3.

Which of the following statements is false? (a) An unambiguous grammar has same leftmost and rightmost derivation (b) An LL(1) parser is a top-down parser (c) LALR is more powerful than SLR (d) An ambiguous grammar can never be LR(k) for any k (GATE 2001: 1 Mark)

4.

Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar? (a) Removing left recursion alone (b) Factoring the grammar alone (c) Removing left recursion and factoring the grammar (d) None of the above (GATE 2003: 1 Mark)

5.

Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between nl and n2 is (a) n1 is necessarily less than n2. (b) n1 is necessarily equal to n2. (c) n1 is necessarily greater than n2. (d) None of the above. (GATE 2003: 1 Mark)

6.

In a bottom-up evaluation of a syntax-directed definition, inherited attributes can (a) always be evaluated. (b) be evaluated only if the definition is L attributed. (c) be evaluated only if the definition has synthesized attributes. (d) never be evaluated. (GATE 2003: 1 Mark)

7.

Which of the following statements is FALSE? (a) In statically typed languages, each variable in a program has a fixed type. (b) In untyped languages, values do not have any types. (c) In dynamically typed languages, variables have no types.

Ch wise GATE_CSIT_CH07_Compiler Design.indd 250

(d) In all statically typed languages, each variable in a program is associated with values of only a single type during the execution of the program. (GATE 2003: 1 Mark) 8.



Consider the grammar shown below: S → iEtSS ′|a S ′ → eS |e E→b In the predictive parse table, M, of this grammar, the entries M[S ′,e] and M[S ′,$], respectively, are (a) {S ′ → eS } and {S ′e} (b) {S ′ → eS } and { } (c) {S ′ → e} and {S ′ → e} (d) {S ′ → eS, S ′ → e} and {S ′ → e} (GATE 2003: 2 Marks)

9.

Consider the grammar shown below: S → CC C → cC |d This grammar is (a) LL(1) (b) SLR(1) but not LL(1) (c) LALR(1) but not SLR(1) (d) LR(l) but not LALR(1) (GATE 2003: 2 Marks)

10. Consider the translation scheme shown below: S → TR R → +T {print(‘+’);} R|e T → num {print(num.val);} Here num is a token that represents an integer and num. val represents the corresponding integer value. For an input string ‘9 + 5 + 2’, this translation scheme will print (a) 9 + 5 + 2 (b) 9 5 + 2 + (c) 9 5 2 + + (d) + + 9 5 2 (GATE 2003: 2 Marks) 11. Consider the syntax-directed definition shown below. S → id: = E

{gen(id.place = E.place;);}

E → E1 + E2

{t = newtemp( ); gen(t = E1.place + E2.place;); E.place = t;}

E → id

{E.place = id.place;}

11/13/2018 11:17:28 AM

Chapter 7  •  Compiler Design



Here, gen is a function that generates the output code, and newtemp is a function that returns the name of a new temporary variable on every call. Assume that ti’s are the temporary variable names generated by newtemp. For the statement ‘X: = Y + Z’, the 3-address code sequence generated by this definition is (a) X = Y + Z (b) t1 = Y + Z; X = t1 (c) t1 = Y; t2 = t1 + Z; X = t2 (d) t1 = Y; t2 = Z; t3 = t1 + t2; X = t3 (GATE 2003: 2 Marks)

12. Consider a program P that consists of two source ­modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the ­reference will be resolved at (a) edit time. (b) compile time. (c) link time. (d) load time. (GATE 2004: 1 Mark) 13. Which of the following grammar rules violate the requirements of an operator grammar? P, Q, R are non-terminals, and r, s, t are terminals. (i) P → QR (ii) P → QsR (iii) P → e (iv) P → QtRr (a) (i) only (b) (i) and (iii) only (c) (ii) and (iii) only (d) (iii) and (iv) only (GATE 2004: 1 Mark) 14. Consider the grammar rule E − E1 − E2 for arithmetic expressions. The code generated is targeted to a CPU having a single-user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have any common sub-expression, in order to get the shortest possible code (a) E1 should be evaluated first. (b) E2 should be evaluated first. (c)  evaluation of E1 and E2 should necessarily be interleaved. (d) order to evaluation of E1 and E2 is of no consequence. (GATE 2004: 1 Mark) 15. Consider the grammar with the following translation rules and E as the start symbol. E → E1 #T {E.value = E1.value * T.value} |T {E.value = T.value} T → T1 & F {T.value = T1.value + F.value} |F {T.value = F.value} F → num {F.value = num.value}

Ch wise GATE_CSIT_CH07_Compiler Design.indd 251

251

Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4. (a) 200 (b) 180 (c) 160 (d) 40 (GATE 2004: 2 Marks) 16. The grammar A → AA|(A)|e is not suitable for predictive parsing because the grammar is (a) ambiguous. (b) left recursive. (c) right recursive. (d) an operator grammar. (GATE 2005: 1 Mark) 17. 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 (GATE 2005: 2 Marks) 18. 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 (b) n1 = n3 < n2 (c) n1 = n2 = n3 (d) n1 ≥ n3 ≥ n2 (GATE 2005: 2 Marks)

Linked Answer Questions 19 and 20: Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar production. E → number E.val = number.val |E ‘+’ E E(1).val = E(2).val + E(3).val |E ‘×’ E E(1).val = E(2).val × E(3).val. 19. 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 favour of a shift over a reduce action. (d) It detects shift-reduce conflict, and resolves the conflict in favour of a reduce over a shift action. (GATE 2005: 2 Marks)

11/13/2018 11:17:28 AM

252

GATE CS and IT Chapter-wise Solved Papers

20. Assume the conflicts in Part (a) of this question 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. (GATE 2005: 2 Marks) 21. Consider the following grammar: S → S*E S→E E→F+E E→F F → id Consider the following LR(0) items corresponding to the grammar above.    (i) S → S*.E     (ii) S → F. + E (iii) S → 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) (b) (ii) and (iii) (c) (i) and (iii) (d) None of the above (GATE 2006: 1 Mark)

22. Consider the following translation scheme: S → ER R → *E{print(‘*’);}R|e E → F + E{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 2*3 + 4, this translation scheme prints (a) 2*3 + 4 (b) 2* + 34 (c) 23*4 (d) 234 + * (GATE 2006: 2 Marks)

23. Consider the following grammar: S → FR R → *S |e F → id

Ch wise GATE_CSIT_CH07_Compiler Design.indd 252



In the predictive parser table, M, of the grammar, the entries M[S, id] and M[R, $], respectively, (a) {S → FR} and {R → S} (b) {S → FR} and { } (c) {S → FR} and {R → *S} (d) {F → id} and {R → e} (GATE 2006: 2 Marks)

24. 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 (GATE 2007: 1 Mark) 25. Consider the grammar with non-terminals N = {S, C, S1}, terminals T = {a, b, i, t, e}, with S as the start symbol, and the following set of rules: S → iCtSS1|a S1 → eS |e C→b 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. (GATE 2007: 2 Marks) 26. Consider the following two statements: A. Every regular grammar is LL(1). B. Every regular set has an LR(1) grammar. Which of the following is TRUE? (a) Both A and B are true. (b) A is true and B is false. (c) A is false and B is true. (d) Both A and B are false. (GATE 2007: 2 Marks) 27. Which of the following describes a handle (as applicable to LR parsing) appropriately? (a) It is the position in a sentential form where the next shift or reduce operation will occur. (b) It is 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. (GATE 2008: 1 Mark)

11/13/2018 11:17:28 AM

Chapter 7  •  Compiler Design

28. 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 dataflow analysis cannot otherwise be used for optimization. (d) The information from the front end cannot otherwise be used for optimization. (GATE 2008: 1 Mark) 29. An LALR(1) parser for a grammar G can have shiftreduce (S-R) conflicts if and only if (a) The SLR(1) parser for 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. (GATE 2008: 2 Marks) 30. Which of the following are true? I. A programming language which does not permit global variables of any kind and 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 procedures/functions. III. Recursion in programming languages cannot be implemented with dynamic storage allocation. IV. Nesting procedures/functions and recursion require a dynamic heap allocation scheme and cannot be implemented with a stack-based allocation scheme for activation records. V. Programming languages which permit a function to return a function as its result cannot be implemented with a stack-based storage allocation scheme for activation records. (a) II and V only (b) I, III and IV only (c) I, II and V only (d) II, III and V only (GATE 2008: 2 Marks) 31. Match all items in Group 1 with correct options from those given in Group 2. Group 1

Group 2

P.  Regular expression

1.  Syntax analysis

Q.  Pushdown automata

2.  Code generation

R.  Dataflow analysis

3.  Lexical analysis

S.  Register allocation

4.  Code optimization

Ch wise GATE_CSIT_CH07_Compiler Design.indd 253

253

(a) P-4, Q-1, R-2, S-3

(b) P-3, Q-1, R-4, S-2

(c) P-3, Q-4, R-1, S-2

(d) P-2, Q-1, R-4, S-3 (GATE 2009: 1 Mark)

32. Which of the following statements are TRUE? A. There exist parsing algorithms for some programming languages whose complexities are less than q(n3). B. A programming language which allows recursion can be implemented with static storage allocation. C. No L-attributed definition can be evaluated in the framework of bottom-up parsing. D. Code improving transformations can be performed at both source language and intermediate code level. (a) A and B (c) C and D

(b) A and D (d) A, C and D (GATE 2009: 2 Marks)

33. Which data structure in a compiler is used for managing information about variables and their attributes? (a) Abstract syntax tree (b) Symbol table (c) Semantic stack (d) Parse table (GATE 2010: 1 Mark) 34. The grammar S → aSa|bS|c is (a) LL(1) but not LR(1) (b) LR(1) but not LR(1) (c) Both LL(1) and LR(1) (d) Neither LL(1) nor LR(1) (GATE 2010: 2 Marks) 35. In a compiler, 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. (GATE 2011: 1 Mark) 36. 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 (GATE 2011: 1 Mark) 37. Consider the given program, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.

11/13/2018 11:17:28 AM

254

GATE CS and IT Chapter-wise Solved Papers

Program main; Var ... Procedure A1; Var ... Call A2; End A1 Procedure A2; Var ...

A

Procedure A21; Var ... Call A1; End A21 Call A21; End A2 Call A1; End main.



Consider the calling chain: Main → A1 →A2 → A21 → A1 The correct set of activation records along with their access links is given by (a)

(b) Main

Main

A1

A1

A2

A2

A21

A21

Frame A1 pointer

Access links

(c)

A1

Frame pointer

Access links

(d) Main

Main

Frame A1 pointer A2

A1 A2

A21

A21 Access links

A1 Frame pointer

Access links

(GATE 2012: 2 Marks) Linked Answer Questions 38 and 39: 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. e is the empty string, $ indicates end of input, and, | separates alternate right-hand sides of productions. S → aAbB|bAaB|e A→S B→S

Ch wise GATE_CSIT_CH07_Compiler Design.indd 254

$

B

S

E1

E2

S→e

A

A→S

A→S

Error

B

B→S

B→S

E3

38. The FIRST and FOLLOW set for the ­non-terminals A and B are (a) FIRST(A) = {a, b, e} = FIRST(B) (b) FOLLOW(A) = {a, b} (c) FOLLOW(B) = {a, b, $} (d) FIRST(A) = {a, b, $} (e) FIRST(B) = {a, b, e} (f) FOLLOW(A) = {a, b} (g) FOLLOW(B) = {$} (h) FIRST(A) = {a, b, e} = FIRST(B) (i) FOLLOW(A) = {a, b} (j) FOLLOW(B) = ∅ (k) FIRST(A) = {a, b, e} = FIRST(B) (l) FOLLOW(A) = {a, b} (m) FOLLOW(B) = {a, b} (GATE 2012: 2 Marks) 39. The appropriate entries for E1, E2 and E3 are (a) E1:S → aAbB, A → S (b) E2:S → bAaB, B → S (c) E3:B → S (d) E1:S → aAbB, S → e (e) E2:S → bAaB, S → e (f) E3:S → e (g) E1:S → aAbB, S → e (h) E2:S → bAaB, S → e (i) E3:B → S (j) E1:A → S, S → e (k) E2:B → S, S → e (l) E3:B → S (GATE 2012: 2 Marks) 40. 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 → e and A → a) to parse a string with n tokens? (a) n/2 (b) n−1 (c) 2n − 1 (d) 2n (GATE 2013: 1 Mark) 41. Consider the following two sets of LR(1) items of an LR(1) grammar: X → c.X, c/d X → .cX, c/d

11/13/2018 11:17:29 AM

Chapter 7  •  Compiler Design

X → .d, c/d X → c.X, $ X → .cX, $ X → .d, $

Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE? A. Cannot be merged since look aheads are different. B. Can be merged but will result in S-R conflict. C. Can be merged but will result in R-R conflict. D. Cannot be merged since goto on c will lead to two different sets. (a) A only (b) B only (c) A and D only (d) A, B, C and D (GATE 2013: 1 Mark)

42. 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 subexpression elimination. (c) Live variable analysis can be used for dead code elimination. (d)  x = 4 × 5 ⇒ x = 20 is an example of common subexpression elimination. (GATE 2014: 1 Mark) 43. Consider the grammar defined by the following production rules, with two operators * and + S →T *P T → U | T *U P →Q+P|Q Q → 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) Both + and * are right associative (d) Both + and * are left associative (GATE 2014: 1 Mark) 44. 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 machineindependent code optimizer in other compliers. (d) improve the register allocation. (GATE 2014: 1 Mark)

Ch wise GATE_CSIT_CH07_Compiler Design.indd 255

255

45. 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. (3) 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 (GATE 2014: 1 Mark)

46. A canonical set of items is given below s → L. > R Q → 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 reduce-reduce conflict. (GATE 2014: 2 Marks) 47. 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 (b) 8 and 10 (c) 9 and 12 (d) 4 and 4 (GATE 2014: 2 Marks)

48. Which one of the following is TRUE at any valid state in shift – reduce parsing? (a) Viable prefixes appear only at the bottom of the stack and not inside (b) Viable prefixes appear only at the top of the stack and not inside (c) The stack contains only a set of viable prefixes (d) The stack never contains viable prefixes (GATE 2015: 1 Mark)

11/13/2018 11:17:29 AM

256

GATE CS and IT Chapter-wise Solved Papers

49. Match the following: (P)  Lexical analysis

(1)  Graph coloring

(Q) Parsing

(2)  DFA minimization

(R)  Register allocation

(3)  Post-order traversal

(S) Expression evaluation

(4)  Production tree

(a)  P − 2, Q − 3, R −1, S − 4 (b)  P − 2, Q − 1, R − 4, S − 3 (c)  P − 2, Q − 4, R − 1, S − 3 (d)  P − 2, Q − 3, R − 4, S − 1



(GATE 2015: 1 Mark) 50. In the context of abstract-syntax-tree (AST) and controlflow-graph (CFG), which one of the following is TRUE? (a) In both AST and CFG, let node, N2 be the successor of node N1. In the input program, the code corresponding to N2 is present after the code corresponding in N1. (b) For any input program, neither AST nor CFG will contain a cycle. (c) The maximum number of successors of a node in an AST and a CFG depends on the input program. (d) Each node is AST and CFG corresponds to atmost one statement in the input program. (GATE 2015: 1 Mark) 51. Among simple LR (SLR), canonical LR, and look-ahead LR (LALR), which of the following pairs identify the method that is very easy to implement and the method that is the most powerful, in that order (a) SLR, LALR (b) Canonical LR, LALR (c) LSR, canonical LR (d) LALR, canonical LR (GATE 2015: 1 Mark) 52. Consider the following grammar G S→FH F→pc H→dc where S, F, and H are non-terminal symbols, p, d, and c are terminal symbols. Which of the following statement(s) is/are correct? S1: LL(1) can parse all strings that are generated using grammar G S2: LR(1) can parse all strings that are generated using grammar G (a) Only S1 (c) Both S1 and S2

Ch wise GATE_CSIT_CH07_Compiler Design.indd 256

53. Consider the following code segment. x = u — t; y = x * v; x = y + w; y = t — z; y = x * y;

(b) Only S2 (d) Neither S1 nor S2 (GATE 2015: 2 Marks)

The minimum number of total variables required to convert the above code segment to static single assignment form is _____. (GATE 2016: 1 Mark)

54. Match the following: (P) Lexical analysis         (i)  Leftmost derivation (Q) Top down parsing     (ii)  Type checking (R) Semantic analysis    (iii)  Regular expressions (S) Runtime         (iv) Activation records (a) P ↔ i, Q ↔ ii, R ↔ iv, S ↔ iii (b) P ↔ iii, Q ↔ i, R ↔ ii, S ↔ iv (c) P ↔ ii, Q ↔ iii, R ↔ i, S ↔ iv (d) P ↔ iv, Q ↔ i, R ↔ ii, S ↔ iii (GATE 2016: 1 Mark) 55. Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S, A} and terminals {a, b}.     S → aA {print 1}     S → a {print 2}     A → Sb {print 3}

Using the above SDTS, the output printed by a bottom-up parser, for the input aab is: (a) 1 3 2 (b) 2 2 3 (c) 2 3 1 (d) syntax error (GATE 2016: 2 Marks)

56. Which one of the following grammars is free from left recursion? (a) S → AB A → Aa | b B→c (b) S → AB | Bb | c A → Bd | ε B→e (c) S → Aa | B A → Bb | Sc | ε B→d (d) S → Aa | Bb | c A → Bd | ε B → Ae | ε (GATE 2016: 2 Marks)

11/13/2018 11:17:30 AM

257

Chapter 7  •  Compiler Design

57. A student wrote two context-free grammars G1 and G2 for generating a single C-like array declaration. The dimension of the array is at least one. For example, int a[10] [13]; The grammars use D as the start symbol, and use six terminal symbol int ; id [ ] num. Grammar G1 Grammar G2 D → int L; D → int L; L → id [E L → id E E → num] E → E [num] E → num] [E E → [num] Which of the grammars correctly generate the declaration mentioned above? (a) Both G1 and G2 (b) Only G1 (c) Only G2 (d) Neither G1 nor G2 (GATE 2016: 2 Marks) 58. Consider the following context-free grammar over the alphabet ∑ = {a, b, c} with S as the start symbol: S → abScT | abcT T → bT | b

Which one of the following options represent the language generated by the above grammar? (a) {(ab)n (cb)n | n ≥ 1} (b) {(ab)n cbm1 cbm2 … cbmn | n, m1, m2, …, m2 ≥ 1} (c) {(ab)n (cbm)n | m, n ≥ 1} (d) {(ab)n (cbn)m | m, n ≥ 1} (GATE 2017: 1 Mark)

59. Consider the following intermediate program in three address code: p = a - b q = p * c p = u * v q = p + q

Which one of the following corresponds to a static single assignment form of the above code? (a) p1 = a - b   q1 = p1 * c   p1 = u * v   q1 = p1 + q1 (b) p3 = a - b   q4 = p3 * c   p4 = u * v   q5 = p4 + q4

Ch wise GATE_CSIT_CH07_Compiler Design.indd 257

(c) p1   q1   p3    q2 (d) p1   q1   q2   q2

= = = = = = = =

a - b p2 * c u * v p4 + q 3 a - b p * c u * v p + q (GATE 2017: 1 Mark)

60. Consider the following grammar: P → xQRS Q → yz | z R→w|e S→y What is FOLLOW (Q)? (a) {R} (c) {w, y}

(b) {w} (d) {w, $} (GATE 2017: 1 Mark)

61. Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it: List-I

List-II

(P)  Syntax tree

    (i)  Code generator

(Q)  Character stream

  (ii)  Syntax analyzer

(R) Intermediate representation

(iii)  Semantic analyzer

(S)  Token stream

(iv)  Lexical analyzer

(a) P → (ii), Q → (iii), R → (iv), S → (i) (b) P → (ii), Q → (i), R → (iii), S → (iv) (c) P → (iii), Q → (iv), R → (i), S → (ii) (d) P → (i), Q → (iv), R → (ii), S → (iii) (GATE 2017: 1 Mark) 62. Which of the following statements about parser is/are CORRECT?      I. Canonical LR is more powerful than SLR.   II. SLR is more powerful than LALR. III. SLR is more powerful than Canonical LR. (a) I only (c) III only

(b) II only (d) II and III only (GATE 2017: 1 Mark)

11/13/2018 11:17:30 AM

258

GATE CS and IT Chapter-wise Solved Papers

63. If G is a grammar with productions S → SaS | aSb | bSa | SS | ∈ where S is the start variable, then which one of the following strings is not generated by G? (a) abab (b) aaab (c) abbaa (d) babba (GATE 2017: 2 Marks) 64. Consider the following grammar:  stmt →  if expr then expr else expr; stmt|0  expr → term relop term | term term → id | number id → a | b | c number → [0-9]



where relop is a relational operator (e.g., , …), 0 refers to the empty statement, and if, then, else are terminals. Consider a program P following the above grammar containing ten if terminals. The number of control flow paths in P is _______. For example, the program

if e1 then e2 else e3

has 2 control flow paths, e1 → e2 and e1 → e3. (GATE 2017: 2 Marks)

65. Consider the expression (a - 1)*(((b + c)/3) + d). Let X be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture, in which (i) only load and store instructions can have memory operand and (ii) arithmetic instructions can have only register or immediate operands. The value of X is _________. (GATE 2017: 2 Marks) 66. Consider the following expression grammar G: E → E - T | T T → T + F | F F → (E) | id



Which of the following grammars is not left recursive, but is equivalent to G? (a) E → E - T | T T → T + F | F F → (E) id (b) E → TE´

E → TE´| ∈

T → T + F | F F → (E) | id (c) E → TX

X → −TX | ∈ T → FY

Y → +FY | ∈

F → (E) | id

(d) E → TX | (TX)

X → −TX | +TX | ∈

T → id

(GATE 2017: 2 Marks) 67. Consider the relations r(a, B) and s(B, C), where s.B is a primary key and r.B is a foreign key referencing s.B. Consider the query. Q : r ∞ (σ B < 5 ( S ))

Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values. Which one of the following queries is NOT equivalent to Q? (a) σ B < 5 ( r ∞ S ) (b) σ B SLR.

11/13/2018 11:17:33 AM

Chapter 7  •  Compiler Design

63. Topic: Syntax-Directed Translation (d) Given, S → SaS | aSb | bSa | SS | ∈ (a)  abab: It can be generated using   S → aSb   S → abSab (S → bSa)   S → abab (S → ∈) (b)  aaab: It can be generated using   S → SaS (S → asb)   S → SaaSb (S → ∈)   S → Saab (S → SaS)   S → SaSaab (S → ∈)   S → aaab (c)  abbaa: It can be generated using   S → SS (S → bsa)   S → SbSa (S → bsa)   S → Sbbsaa (S → ∈)   S → Sbbaa (S → SaS)   S → SaSbbaa (S → ∈) (d)  babba: It can be generated using   S → bSa (S→ asb)   S → baSba Therefore, we cannot generate the string babba from the given grammar. 64. Topic: Syntax-Directed Translation (1024)  We know that for 2 “if statements”, 22 = 4 control flow paths are there. Therefore, for 10 “If statements”, 210 = 1024 control flow paths will be there. 65. Topic: Lexical Analysis (2)  The given expression is (a - 1)*(((b + c)/3) + d) Let x1 and x2 be the two registers. Now, x1 ← c x2 ← b x1 ← (b + c) x1 ← x1/3

Ch wise GATE_CSIT_CH07_Compiler Design.indd 263



263

x2 ← d x1 ← x1 + x2 x2 ← a x2 ← x2 - 1 x2 ← x1 * x2

Number of registers used to solve this expression are 2. Therefore, X = 2. 66. Topic: Syntax-Directed Translation (c)  Given that E → E - T | T T → T + F | F F → (E) | id There are two left recursions and both have to be removed. The conversion is as follows: E′ → TE′| ∈   E → TE′ T′ → +FY′ | ∈   Y → FT′   F → (E) | id Now by substituting E′ as X and T′ as Y, we get E → TX X → −TX | ∈ T → FY Y → +FY | ∈ F → (E) | id 67. Topic: Runtime Environments (c)  Given query: Q : r ∞ (σ B < 5 ( S )) Option (a): σ B < 5 ( r ∞ S ) will restrict all records with B < 5. Option (b): σ B value); do { fetch-and-set x, y; } while (y); } void V (binary_semaphore *S) { S->value = 0; }

Which one of 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. (GATE 2006: 2 Marks)

48. 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 (b) 13 bits (c) 15 bits (d) 20 bits (GATE 2006: 2 Marks) 49. 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 multi-user 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. (GATE 2006: 2 Marks) 50. Consider three processes (process id 0, 1, 2, respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF, ties are broken by giving priority to the process with the lowest process id. The average turnaround time is (a) 13 units (b) 14 units (c) 15 units (d) 16 units (GATE 2006: 2 Marks)

Ch wise GATE_CSIT_CH08_Operating System.indd 272

51. 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 gets 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% (b) 10.6% (c) 30.0% (d) 89.4% (GATE 2006: 2 Marks) 52. Consider the following snapshot of a system running n processes. Process i is holding xi instances of a resource R, 1 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 xi instances it already has. There are exactly two processes p and q such that yp = yq = 0. Which one of the following can serve as a necessary condition to guarantee that the system is not approaching a deadlock? (a) min (xp, xq) < maxk ≠  p,q  yk (b) xp+ xq ³≥ mink ≠ p,q  yk (c) max (xp, xq) > 1 (d) min (xp, xq) > 1 (GATE 2006: 2 Marks) Linked Answer Questions 53 and 54: Barrier is a synchronization construct where a set of processes synchronizes globally, that is, 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 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); }

11/13/2018 10:56:00 AM

Chapter 8  •  Operating System

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 (GATE 2007: 1 Mark)

The variables 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. 53. 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 barriers in invocations are used in immediate succession. (c) Lines 6 to 10 need not be inside a critical section. (d) The barrier implementation is correct if there are only two processes instead of three. (GATE 2006: 2 Marks) 54. 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 re-enabled at the end. (d) The variable process_left is made private instead of shared. (GATE 2006: 2 Marks) 55. Group 1 contains some CPU scheduling algorithms and Group 2 contains some applications. Match entries in Group 1 to entries in Group 2. Group I

Group II

(P)  Gang Scheduling

(1) Guaranteed ­Scheduling

(Q) Rate Monotonic Scheduling

(2) Real-time Scheduling

(R) Fair Share Scheduling

(3) Thread Scheduling

(a) P − 3; Q − 2; R − 1 (b) P − 1; Q − 2; R − 3 (c) P − 2; Q − 3; R − 1 (d) P − 1; Q − 3; R − 2 (GATE 2007: 1 Mark) 56. 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

Ch wise GATE_CSIT_CH08_Operating System.indd 273

273

57. 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. (GATE 2007: 1 Mark) 58. An operating system uses shortest remaining time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following ­processes: Process



Execution Time

Arrival Time

P1

20

 0

P2

25

15

P3

10

30

P4

15

45

What is the total waiting time for process P2? (a) 5 (b) 15 (c) 40 (d) 55 (GATE 2007: 2 Marks)

59. 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 programs 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. (GATE 2007: 2 Marks)

11/13/2018 10:56:01 AM

274

GATE CS and IT Chapter-wise Solved Papers

60. A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST? alloc 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 (GATE 2007: 2 Marks) 61. Two processes, P1 and P2, need to access a critical ­section of code. Consider the following synchronization construct used by the processes: In process P1 and P2, variables wants1 and wants2 both become true, but process P1 and P2 are stuck for infinite time in their while loops waiting for each other to finish. So, they do not prevent deadlock. But mutual exclusion is ensured.

while (true) {while (true) { wants1 = true;wants1 = true; while (wants2==true); while (wants2==true); /* Critical /* Critical Section */ Section */ Wants1=false; Wants1=false; } } /* Remainder section /* Remainder */ section */



63. Least recently used (LRU) page replacement policy is a practical approximation to optimal page replacement. For the above reference string, how many more page faults occur with LRU than with the optimal page replacement policy? (a) 0   (b) 1   (c) 2   (d) 3 (GATE 2007: 2 Marks) 64. The data blocks 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 (GATE 2008: 1 Mark)

65. 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. P2 (d) use of unfair arm scheduling policies. while (true) {while (true) { (GATE 2008: 1 Mark) wants2 = true;wants2 = true; while (wants1==true); while (wants1==true); 66. In an instruction execution pipeline, the earliest that the data /* Critical /* Critical TLB (Translation Lookaside Buffer) can be accessed is Section */ Section */ (a) before effective address calculation has started. Wants2=false; Wants2=false; } } (b) during effective address calculation. /* Remainder section /* Remainder */ section */

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. (GATE 2007: 2 Marks)

Ch wise GATE_CSIT_CH08_Operating System.indd 274

62. If optimal page replacement policy is used, how many page faults occur for the above reference string? (a) 7   (b) 8   (c) 9   (d) 10 (GATE 2007: 2 Marks)

request

X

P1

Linked Answer Questions 62 and 63: 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.

(c) after effective address calculation has completed. (d) after data cache lookup has completed. (GATE 2008: 2 Marks)

67. 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 90( Registration students ))

66. How many tuples does the result of the following relational algebra expression contain? Assume that the schema of A ∪ B is the same as that of A. ( A ∪ B)  A. Id > 40 C . Id 90

C Id

(b) 3 (d) 1 (GATE 2012: 2 Marks)

III. {T  |∃S ∈ Student, ∃R ∈ Registration (S.rollno = R.rollno ∧ R.courseno = 107 ∧ R.percent > 90 ∧ T. sname = S.name)}





{  | ∃SR∃RP( ∈ Student∧ < SR, 107, RP> ∈ RP > 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 (GATE 2013: 2 Marks)

Linked Answer Questions 70 and 71: 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 Ft is exactly the set of FDs that hold for R.

11/13/2018 11:07:11 AM

Chapter 9  •  Databases

70. How many candidate keys does the relation R have? (a) 3 (b) 4 (c) 5 (d) 6 (GATE 2013: 2 Marks)

Student D

Student Student Name

2345

Shankar Shankar@ X math

9.4

71. The relation R is (a) In 1NF, but not in 2NF (b) In 2NF, but not in 3NF (c) In 3NF, but not in BCNF (d) In BCNF

1287

Swati

Swati@ee 19

9.5

7853

Shankar Shankar@ 19 cse

9.4

9876

Swati

Swati@ mech

18

9.3

8765

Ganesh

Ganesh@ civil

19

8.7

(GATE 2013: 2 Marks) 72. 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} → {M}, {K} → {M}, {L} → {N} on R. What is the key for R? (a) {E, F} (b) {E, F, H} (c) {E, F, H, K, L} (d) {E} (GATE 2014: 1 Mark) 73. 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) reference (R) Which one of the following statements is CORRECT? (a) S1 is TRUE and S2 is a FALSE (b) Both S1 and S2 are TRUE (c) S1 is FALSE and S2 is a TRUE (d) Both S1 and S2 are FALSE (GATE 2014: 1 Mark) 74. The maximum number of super keys for the relation . schema R (E, F, G, H) with E as the key is (GATE 2014: 1 Mark) 75. Given an instance of the STUDENTS relation as shown below:

Ch wise GATE_CSIT_CH09_Databases.indd 319



319

Email Student CPI Age

For (StudentName, StudentAge) to be a key for this instance, the value X should NOT be equal to . (GATE 2014: 1 Mark)

76. What is the optimized version of the relation algebra expression (pA1(pA2(sF1(r)))), where A1, A2 are sets of attributes in with A1 ⊂ A2 and F1, F2 are Boolean expressions based on the attributes in r? (a) pA1(s (F1 ∧ F2) (r)) (b) pA1(s (F1 ∨ F2) (r)) (c) pA2(s (F1 ∧ F2) (r)) (d) pA2(s (F1 ∨ F2) (r)) (GATE 2014: 1 Mark) 77. 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 keys of R. (d) only in the primary key of R. (GATE 2014: 1 Mark) 78. Consider the following four schedules due to three transactions (indicted by the subscript) using read and write on a data item x, denoted r (x) and w (x) respectively. Which one of them is conflict serializable? (a)  r1(x); r2(x); w1(x); r3(x); w2(x) (b) r2(x); r1(x); w2(x); r3(x); w1(x) (c) r3(x); r2(x); r1(x); w2(x); w1(x) (d) r2(x); w2(x); r3(x); r1(x); w1(x) (GATE 2014: 2 Marks) 79. 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

11/13/2018 11:07:11 AM

320

GATE CS and IT Chapter-wise Solved Papers

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.

T1

80. An ordered n-tuple (d1, d2, …, dn) with d d2 …,  dn is called graphic if there exists a simple undirected graph with n vertices having degrees d1, d2, …, dn, 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) (GATE 2014: 2 Marks) employees(emp-id, first-name, last-name, hire-date, dept-id, salary) 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. (GATE 2014: 2 Marks) 82. Consider the following schedule S of transactions T1, T2, T3, T4:

Writes [X] Commit

Reads[X] Writes[X] Commit Writes[Y]

Ch wise GATE_CSIT_CH09_Databases.indd 320

T4

Reads[Y] Commit

3

81. Given the following schema:

T3

T4

Reads[X] 3 1

T2

T3

Reads [Z] Commit

(GATE 2014: 2 Marks)

T1

T2



Which one of the following statements is CORRECT? (a) S is conflict-serializable but not recoverable (b) S is conflict-serializable but is recoverable (c) S is both conflict-serializable and recoverable (d) S is neither conflict-serializable nor is it recoverable (GATE 2014: 2 Marks)

83. 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 size(r(R)) < size(s(S)), the join will have fewer number of disk block accesses if (a) relation r(R) is in the outer loop. (b) relation s(S) is in the outer loop. (c) join selection factor between r(R) and s(S) is more than 0.5. (d) join selection factor between r(R) and s(S) is less than 0.5. (GATE 2014: 2 Marks) 84. 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 (GATE 2014: 2 Marks) 85. 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 (X) ; r2 (Z) ; w2 (Z) T3 : r3 (X) ; 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)

11/13/2018 11:07:12 AM

Chapter 9  •  Databases



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 conflict-serializable. (d) Neither S1 nor S2 is conflict-serializable. (GATE 2014: 2 Marks)

321

88. SELECT operation in SQL is equivalent to (a) the selection operation in relational algebra (b) the selection operation in relational algebra, except that SELECT in SQL retains duplicates (c) the projection operation in relational algebra (d) the projection operation in relational algebra, except that SELECT in SQL retains duplicates

(GATE 2015: 1 Mark) 86. Consider the relational schema given below, where eId of the relation dependent is a foreign key referring to 89. A file is organized so that the ordering of data records is the same as or close to the ordering of data entries in empId of the relation employee. Assume that every some index. Then that index is called employee has at least one associated dependent in the dependent relation. (a) dense. (b) sparse. employee (empId, empName, empAge) (c) clustered. (d) unclustered. dependent (depId, eId, depName, depAge) (GATE 2015: 1 Mark) Consider the following relational algebra query 90. Consider the following transaction involving two bank accounts≤xdepA and y. P empId (employee) − P empId (employee  (empId = eID) ∧ (empAge ge) dependent )

ee) − P empId (employee  (empId = eID) ∧ (empAge ≤ depAge) dependent )

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. (GATE 2014: 2 Marks)

87. Consider the following relational schema: Employee (empId, empName, empDept) Customer rating)





(custId,custName,

salesRepId,

y: = y + 50; write (y) The constraint that the sum of the accounts x and y should remain constant is that of (a) Atomicity (b) Consistency (c) Isolation (d) Durability (GATE 2015: 1 Mark) 91. With reference to the B+ tree index of order 1 shown below, the minimum number of nodes (including the Root node) that must be fetched in order to satisfy the following query: “Get all records with a search key . greater than or equal to 7 and less than 15” is 9

SalesRepId is a foreign key referring to empId of the employee relation. Assume 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. (GATE 2014: 2 Marks)

Ch wise GATE_CSIT_CH09_Databases.indd 321

read (x) ; x : = x — 50; write (x); read (y);



13 17

5

1

3

5

7

9

11

13 15

17

(GATE 2015: 1 Mark) 92. Consider the following relation Cinema (theater, address, capacity) Which of the following options will be needed at the end of the SQL query? SELECT P1. address FROM Cinema P1 Such that it always finds the addresses of theaters with maximum capacity? (a) WHERE P1. capacity > = All (select P2. capacity from Cinema P2) (b) WHERE P1. capacity > = Any (select P2. capacity from Cinema P2)

11/13/2018 11:07:12 AM

322

GATE CS and IT Chapter-wise Solved Papers

(c) WHERE P1. capacity > All (select max (P2. capacity) form Cinema P2) (d) WHERE P1. capacity > Any (select max (P2. capacity) from Cinema P2) (GATE 2015: 1 Mark) 93. Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an m:n relationship R12. E1 and E3 are connected by a 1: n (1 on the side of E1 and n on the side of E3) relationship R13. E1 has two single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-valued attributes a21 and a22 of which is the key attribute. E3 has two single-valued attributes a31 and a32 of which a31 is the key attribute. The relationships do not have any attributes. If a relational model is the derived from the above ER model, then the minimum number of relations that would be generated if all the relations are in 3NF is . (GATE 2015: 2 Marks) 94. Consider the following relations: Students Roll_No



1

Raj

2

Rohit

3

Raj

Performance Roll_No



Student_Name



Course

Marks

1

Math

80

1

English

70

2

Math

75

3

English

80

2

Physics

65

3

Math

80

Consider the following SQL query. SELECT S. Student_Name, sum (P.Marks) FROM Student S, Performance P WHERE S.Roll_No = P.Roll_No GROUP BY S.Student_Name The number of rows that will be returned by the SQL . query is (GATE 2015: 2 Marks)

95. Consider a simple checkpointing protocol and the following set of operations in the log. (start, T4); (write, T4, y, 2, 3); (start, T1); (commit, T4); (write, T1, z, 5, 7);

Ch wise GATE_CSIT_CH09_Databases.indd 322



(checkpoint); (start, T2); (write, T2, x, 1, 9); (commit, T2); (start, T3), (write, T3, z, 7, 2); If a crash happens now and the system tries to recover using both undo and redo operations,what are the contents of the undo lists and the redo list? (a) Undo: T3,T1; Redo: T2 (b) Undo: T3,T1; Redo: T2,T4 (c) Undo: none; Redo: T2,T4,T3,T1 (d) Undo: T3,T1,T4; Redo: T2 (GATE 2015: 2 Marks) 96. Consider two relations R1(A,B) with the tuples (1,5), (3,7) and R2 (A,C) = (1,7), (4,9). Assume that R(A,B,C) is the full natural outer join of R1 and R2. Consider the following tuples of the form (A,B,C): a = (1,5,null), b = (1,null,7) c = (3,null,9), d = (4,7,null), e = (1,5,7), f = (3,7,null), g = (4,null,9). Which one of the following statements is ­correct? (a) R contains a, b, e, f, g but not c, d. (b) R contains all of a, b, c, d, e, f, g (c) R contains e, f, g but not a, b (d) R contains e but not f, g (GATE 2015: 2 Marks) 97. Consider a B+ tree in which the search key is 12 bytes long, block size is 1024 bytes, record pointer is 10 bytes long and block pointer is 8 bytes long. The maximum number of keys that can be accommodated in . each non-leaf node of the tree is (GATE 2015: 2 Marks) 98. Consider the following partial Schedule S involving two transactions T1 and T2. Only the read and the write operations have been shown. The read o­ peration on data item P is denoted by read (P) and the write operation on data item P is denoted by write (P). Time instance

Transaction -id T1

1

read(A)

2

write(A)

T2

3

read(C)

4

write(C)

5

read(B)

6

write(B)

7

read(A)

11/13/2018 11:07:12 AM

Chapter 9  •  Databases

8

commit

9



read(B)

Schedule S Suppose that the transaction T1 fails immediately after time instance 9. Which one of the following statements is correct? (a) T2 must be aborted and then both T1 and T2 must be re-started to ensure transaction atomicity (b) Schedule S is non-recoverable and cannot ensure transaction atomicity (c) Only T2 must be aborted and then restarted to ensure transaction atomicity (d) Schedule S is recoverable and can ensure atomicity and nothing else needs to be done (GATE 2015: 2 Marks)

99. Which of the following is NOT a superkey in a relational schema with attributes V, W, X, Y, Z and primary key VY? (a) VXYZ (b) VWXZ (c) VWXY (d) VWXYZ (GATE 2016: 1 Mark) 100. Which one of the following is NOT a part of the ACID properties of database transactions? (a) Atomicity (b) Consistency (c) Isolation (d) Deadlock-freedom (GATE 2016: 1 Mark) 101. A database of research articles in a journal uses the following schema. (Volume, Number, StartPage, EndPage, Title, Year, Price)

The primary key is (Volume, Number, StartPage, EndPage) and the following functional dependencies exist in the schema. (Volume, Number, StartPage, EndPage) → Title (Volume, Number) → Year (Volume, Number, StartPage, EndPage) → Price





The database is redesigned to use the following schemas. (Volume, Number, StartPage, EndPage, Title, Price) (Volume, Number, Year)

Ch wise GATE_CSIT_CH09_Databases.indd 323

323

Which is the weakest normal form that the new database satisfies, but the old one does not? (a) 1NF (b) 2NF (c) 3NF (d) BCNF (GATE 2016: 1 Mark)

102. B+ Trees are considered BALANCED because (a) the lengths of the paths from the root to all leaf nodes are all equal. (b) the lengths of the paths from the root to all leaf nodes differ from each other by at most 1. (c) the number of children of any two non-leaf sibling nodes differ by at most 1. (d) the number of records in any two leaf nodes differ by at most 1. (GATE 2016: 1 Mark) 103. Suppose a database schedule S involves transactions T1, …, Tn. Construct the precedence graph of S with vertices representing the transactions and edges representing the conflicts. If S is serializable, which one of the following orderings of the vertices of the precedence graph is guaranteed to yield a serial schedule? (a) Topological order (b) Depth-first order (c) Breadth-first order (d) Ascending order of transaction indices (GATE 2016: 1 Mark) 104. Consider the following two phase locking protocol. Suppose a transaction T access (for read or write operations), a certain set of objects {O1, …, O2}. This is done in the following manner: Step 1: T acquires exclusive locks to O1, …, Ok in increasing order of their addresses. Step 2: The required operations are performed. Step 3: All locks are released. This protocol will (a) guarantee serializability and deadlock-freedom (b) guarantee neither serializability nor deadlockfreedom (c) guarantee serializability but not deadlockfreedom (d) guarantee deadlock-freedom but not serializability (GATE 2016: 2 Marks) 105. Consider the following database schedule with two transactions, T1 and T2. S = r2(X); r1(X); r2(Y); w1(X); r1(Y); w2(X); a1; a2

where ri(Z) denotes a read operation by transaction Ti on a variable Z, wi(Z) denotes a write operation by Ti on a variable Z and ai denotes an abort by transaction Ti.

11/13/2018 11:07:12 AM

324

GATE CS and IT Chapter-wise Solved Papers

Which one of the following statements about the above schedule is TRUE? (a) S is non-recoverable (b) S is recoverable, but has a cascading abort (c) S does not have a cascading abort (d) S is strict (GATE 2016: 2 Marks)

106. Consider the following database table named water_ schemes:

(a) V → W V → X Y → V Y → Z

(b) V → W W → X Y → V Y → Z

(c) V → W V → X Y → V Y → X Y → Z

(d) V → W W→ X Y → V Y → X Y → Z

water-schemes

(GATE 2017: 1 Mark)

scheme-no

district-name

capacity

1

Ajmer

20

1

Bikaner

10

2

Bikaner

10

scheme-no

district-name

capacity

3

Bikaner

20

1

Churu

2 1

108. Consider a database that has the relation schema EMP (EmpId, EmpName, and DeptName). An instance of the schema EMP and a SQL query on it are given below: EMP EmpId

DeptName

1

XYA

AA

10

2

XYB

AA

Churu

20

3

XYC

AA

Dungargarh

10

4

XYD

AA

5

XYE

AB

6

XYF

AB

7

XYG

AB

8

XYH

AC

9

XYI

AC

10

XYJ

AC

11

XYK

AD

12

XYL

AD

13

XYM

AE



The number of tuples returned by the following SQL query is _______.  with total (name, capacity) as select district_name, sum (capacity) from water_schemes group by district_name   with total_avg (capacity) as select avg (capacity) from total   select name from total, total_avg where total.capacity ≥ total_avg. capacity (GATE 2016: 2 Marks) 107. The following functional dependencies hold true for the relational schema R{V, W, X, Y, Z}: V→W VW → X Y → VX Y→Z Which of the following is irreducible equivalent for this set of functional dependencies?

Ch wise GATE_CSIT_CH09_Databases.indd 324

EmpName





SELECT AVG(EC.Num) FROM EC WHERE (DeptName, Num) IN (SELECT DeptName, COUNT(EmpId) AS EC(DeptName, Num) FROM EMP GROUP BY DeptName)

11/13/2018 11:07:12 AM

Chapter 9  •  Databases



The output of executing ______________.

the

SQL

query

and on-update cascade. In table T2, R is the primary key and S is the foreign key referencing P in table T1 with on-delete set NULL and on-update cascade. In order to delete record (3, 8) from table T1, the number of additional records that need to be deleted from table T1 is ____________.

is

(GATE 2017: 1 Mark) 109. An ER model of a database consists of entity types A and B. These are connected by a relationship R which does not have its own attribute. Under which one of the following conditions, can the relational table for R be merged with that of A? (a) Relationship R is one-to-many and the participation of A in R is total. (b) Relationship R is one-to-many and the participation of A in R is partial. (c) Relationship R is many-to-one and the participation of A in R is total. (d) Relationship R is many-to-one and the participation of A in R is partial. (GATE 2017: 1 Mark)

(GATE 2017: 1 Mark) 111. Consider a database that has the relation schemas EMP(EmpId, EmpName, DeptId) and DEPT(DeptName, DeptId). Note that the DeptId can be permitted to be NULL in the relation EMP. Consider the following queries on the database expressed in tuple relational calculus.

{t | ∃u ∈ EMP(t[EmpName] = u[EmpName] ∧∀v ∈ I.  DEPT(t[DeptId] ≠ v[DeptId]))}



II. {t | ∃u ∈ EMP(t[EmpName] = u[EmpName] ∧∃ v ∈ DEPT(t[DeptId] ≠ v[DeptId]))}

P

Q

2

2

3

8

7

3

5

8

6

9

8

5

9

8 T2



R

S

2

2

8

3

3

2

9

7

5

7

7

2

In table T1, P is the primary key and Q is the foreign key referencing R in table T2 with on-delete cascade

Ch wise GATE_CSIT_CH09_Databases.indd 325

III. {t | ∃u ∈ EMP(t[EmpName] = u[EmpName] ∧∃ v ∈ DEPT(t[DeptId] = v[DeptId]))}





Which of the above queries are safe? (a) I and II only (b) I and III only (c) II and III only (d) I, II and III (GATE 2017: 2 Marks)

110. Consider the following tables T1 and T2. T1

325

112. In a database system, unique timestamps are assigned to each transaction using Lamport’s logical clock. Let TS(T1) and TS(T2) be the timestamps of transactions T1 and T2, respectively. Besides, T1 holds a lock on the resource R and T1 has requested a conflicting lock on the same resource R. The following algorithm is used to prevent deadlock in the database system assuming that a killed transaction is restarted with the same timestamp. if TS(T2) < TS(T1) then T1 is killed else T2 waits Assume any transaction that is not killed terminates eventually. Which of the following is TRUE about the database system that uses the above algorithm to prevent deadlocks? (a) The database system is both deadlock-free and starvation-free. (b) The database system is deadlock-free, but not starvation-free. (c) The database system is starvation-free, but not deadlock-free. (d) The database system is neither deadlock-free nor starvation-free. (GATE 2017: 2 Marks)

11/13/2018 11:07:14 AM

326

GATE CS and IT Chapter-wise Solved Papers

113. Consider a database that has the relation schema CR(StudentName, CourseName). An instance of the ­ schema CR is as given below:

115. Consider the following database table named top_scorer. top_scorer

CR



Country

Goals

Klose

Germany

16

StudentName

CourseName

Ronaldo

Brazil

15

SA

CA

G Muller

Germany

14

SA

CB

Fontaine

France

13

SA

CC

Pele

Brazil

12

SB

CB

Player

Country

Goals

SB

CC

Klinsmann

Germany

11

SC

CA

Kocsis

Hungary

11

SC

CB

Batistuta

Argentina

10

SC

CC

Cubillas

Peru

10

SD

CA

Lato

Poland

10

SD

CB

Lineker

England

10

SD

CC

T Muller

Germany

10

SD

CD

Rahn

Germany

10

SE

CD

SE

CA

SE

CB

SF

CA

SF

CB

SF

CC





T2 ← CR ÷ T1



The number of rows in T2 is _____________. (GATE 2017: 2 Marks)

114. Two transactions T1 and T2 are given as T1: r1(X )w1(X )r1(Y )w1(Y ) T2: r2(Y )w2(Y )r2(Z  )w2(Z ) where ri(V ) denotes a read operation by transaction Ti on a variable V and w1(V ) denotes a write operation by transaction Ti on a variable V. The total number of conflict serializable schedules that can be formed by T1 and T2 is ____________. (GATE 2017: 2 Marks)

Ch wise GATE_CSIT_CH09_Databases.indd 326

Consider the following SQL query: ELECT ta.player FROM top_scorer as ta S WHERE ta.goals > ALL (SELECT tb.goals   FROM top_scorer AS tb    WHERE tb.country = ‘Spain’) AND ta.goals > ANY (SELECT tc.goals        FROM top_scorer AS tc         WHERE tc.country = ‘Germany’)

The following query is made on the database.

T1 ← pCourseName (sStudentName = ‘SA’ (CR))



Player



The number of tuples returned by the above SQL query is _____________. (GATE 2017: 2 Marks)

116. In a B tree, if the search-key alue is 8 bytes long, the block size is 512 bytes and the block pointer size is 2 bytes, then the maximum order of the B tree is ___________. (GATE 2017: 2 Marks) 117. The set of all recursively enumerable languages is (a) closed under complementation. (b) closed under intersection. (c) a subset of the set of all recursive languages. (d) an uncountable set. (GATE 2018: 1 Mark)

11/13/2018 11:07:14 AM

Chapter 9  •  Databases

118. In an Entity-Relationship (ER) model, suppose R is a many-to-one relationship from entity set E1 to entity set E2. Assume that E1 and E2 participate totally in R and that the cardinality of E1 is greater than the cardinality of E2. Which one of the following is true about R? (a) Every entity in E1 is associated with exactly one entity in E2. (b) Some entity in E1 is associated with more than one entity in E2. (c) Every entity in E2 is associated with exactly one entity in E1. (d) Every entity in E2 is associated with most one entity in E1. (GATE 2018: 1 Mark) 119. Consider the following two tables and four queries in SQL. Book (isbn, b name) Stock (isbn, copies) Query 1:  SELECT B.isbn, S.copies FROM Book B INNER JOIN Stock S ON B.isbn = S.isbn; Query 2:  SELECT B.isbn, S.copies FROM Book B LEFT OUTER JOIN Stock S ON B.isbn = S.isbn; Query 3:  SELECT B.isbn, S.copies  FROM Book B RIGHT OUTER JOIN Stock S ON B.isbn = S.isbn; Query 4:  SELECT B.isbn, S.copies FROM Book B FULL OUTER JOIN Stock S ON B.isbn = S.isbn;



327

Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries? (a) Query 1 (b) Query 2 (c) Query 3 (d) Query 4 (GATE 2018: 1 Mark)

120. The postorder traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1. The inorder traversal of the same tree is 8, 6, 9, 4, 7, 2, 5, 1, 3. The height of a tree is the length of the longest path from the root to any leaf. The height of the binary tree above is . (GATE 2018: 1 Mark) 121. Consider the first-order logic sentence

φ ≡ ∃s∃t ∃u∀v∀ω∀x∀yψ ( s, t , u, v, w , x, y )



where ψ (s, t, u, v, w, x, y) is a quantifier-free first-order logic formula using only predicate symbols, and possibly equality, but no function symbols. Suppose φ has a model with a universe containing 7 elements. Which one of the following statements is necessarily true? (a) There exists at least one model of φ with universe of size less than or equal to 3. (b) There exists no model of φ with universe of size less than or equal 3. (c) There exists no model of φ with universe of size greater than 7. (d) Every model of φ has a universe of size equal to 7. (GATE 2018: 2 Marks)

Answer Key 1. (c)

2. (b)

 3. (a)

 4. (d)

 5. (c)

 6. (d)

 7. (c)

 8. (c)

 9. (c)

10. (a)

11. (c)

12. (c)

13. (d)

14. (a)

15. (d)

16. (c)

17. (b)

18. (a)

19. (a)

20. (b)

21. (d)

22. (c)

23. (d)

24. (d)

25. (c)

26. (c)

27. (b)

28. (c)

29. (d)

30. (d)

31. (c)

32. (c)

33. (a)

34. (c)

35. (c)

36. (b)

37. (b)

38. (b)

39. (d)

40. (b)

41. (c)

42. (a)

43. (c)

44. (c)

45. (c)

46. (a)

47. (a)

48. (b)

49. (d)

50. (a)

51. (a)

52. (b)

53. (b)

54. (c)

55. (b)

56. (a)

57. (a)

58. (a)

59. (c)

60. (a)

61. (b)

62. (c)

63. (c)

64. (a)

65. (b)

66. (a)

67. (b)

68. (c)

69. (a)

70. (b)

71. (a)

72. (b)

73. (d)

74. (8)

75. (19)

76. (a)

77. (b)

78. (d)

79. (a)

80. (c)

81. (b)

82. (c)

83. (a)

84. (c)

85. (a)

86. (d)

87. (d)

88. (d)

89. (c)

90. (d)

91. (6)

92. (a)

93. (4)

94. (2)

95. (a)

96. (c)

98. (b)

99. (b)

100. (d)

101. (b)

102. (a)

103. (a)

104. (a)

105. (c)

106. (2)

107. (a)

97. (50)

108. (2.6)

109. (c)

110. (0)

111. (d)

112. (a)

113. (4)

114. (54)

115. (7)

116. (52)

117. (b)

118. (a)

119. (d)

120. (4)

121. (b)

Ch wise GATE_CSIT_CH09_Databases.indd 327

11/13/2018 11:07:14 AM

328

GATE CS and IT Chapter-wise Solved Papers

Answers with Explanation 1. Topic: ER-Model (c) In the given relations, employee (name, salary, deptno), and department (deptno, deptname, address), the basic relational algebra operations are: 1. σ : selection 2. π : projection 3. ×: cartesion product or cross product 4. ∪ : set union 5. −: set difference 6. p: rename Many important operators like set intersection, division and natural join can be defined in terms of these basic relational algebra operations. However, aggregation is not possible with these basic relational algebra operations. Therefore, sum of all employees’ salaries cannot be expressed using the basic relational algebra. 2. Topic: Relational Model: Tuple Calculus (b)  Given:

X

Y

Z

1

4

2

1

5

3

1

6

3

3

2

2

Here, Y uniquely determines X and Z, that is, for a given value of Y we can find out values of X and Z 3. Topic: Relational Model: Tuple Calculus (a)  Given r(w, x) and s(y, z) And query: select distinct w, x from r, s It selects all attributes of r. It result of query will be r only if r does not have duplicates. Also cartesian product of two sets will be empty if any of the two sets is empty. So, s should have atleast one attribute. Therefore, the result of query is guaranteed to be same as r, provided r has no duplicates and s is non-empty. 4. Topic: Relational Model: SQL (d)  In question all pairs are equivalent. So, option (d) is the correct option. 5. Topic: Relational Model: Relational Algebra (c)  Given, schema R (A, B, C, D) and functional dependencies A → B and C → D. Now, decomposition of R into R1(AB) and R2(CD) is a dependency preserving if closure of functional dependencies after decomposition is same as closure

Ch wise GATE_CSIT_CH09_Databases.indd 328

of functional dependencies before decomposition. The decomposition is loss-less join if at least one of the functional dependencies are in closure of functional dependencies. 6. Topic: Relational Model: Relational Algebra (d)  Given that adjacency relation of vertices in graph is represented in table Adj(X, Y). Query in option (a): List of all vertices adjacent to a given vertex is simple query and can be expressed by relational algebra. Query in option (b): List of all vertices which have self-loops is also simple and can be expressed by relational algebra. Query in option (c): List all vertices which belong to cycle of less than three vertices can be expressed by relational algebra. Query in option (d): List all vertices reachable from a given vertex is very difficult and can be expressed by relational algebra. 7. Topic: Integrity Constraints (c)  Given relation R(A, B, C, D) A decomposition of R into R1 and R2 is a lossless join decomposition if at least one of the following functional dependencies are in F+ R1 ∩ R2 → R1 R1 ∩ R2 → R2 Decomposition is dependency preserving if closure of functional dependencies after decomposition is same as closure of functional dependencies before decomposition AB → C, C → AD ⇒ R1(ABC), R2(CD) Here, in decomposition R2, C is key and C → A violates BCNF condition in ABC in decomposition R1 So, in AB → C dependency is lost. and AB → C, C → AD does not have lossless join, dependency preserving BCNF decomposition. 8. Topic: Relational Model: Tuple Calculus (c)  A relational calculus expression is not safe if it generates infinite relation.

{

}

The expression t ¬ (t ∈ R1 ) is not safe because there are infinitely many tuples that do not occur in R relation. 9. Topic: Relational Model: Tuple Calculus (c)  Here, the relation schema is (primary key, foreign key) which is referencing the primary key of its own relation.

11/13/2018 11:07:15 AM

Chapter 9  •  Databases

Hence, the table is both master and child. If tuple (x, y) is deleted then, tuple (z, w) with w < x is deleted. 10. Topic: Relational Model: Relational Algebra (a) Given, relation R with an associated set of functional dependencies, F is decomposed into BCNF. If a relational schema is in BCNF than all redundancy based on functional dependency has been remove. These redundancy in the resulting set relations is zero. 11. Topic: Relational Model: Relational Algebra (c)  A query can be formulated in relational calculus if and only if it can be formulated in relational algebra. It is possible that relational query has infinite number of answers, such queries are unsafe. Queries that have finite number of answers are called safe. Therefore, relational algebra has the same power as safe relational calculus. 12. Topic: Relational Model: Relational Algebra (c)  Given relation schema R(A, B, C) A 1 1 2 2

B 1 1 3 3

C 1 0 2 2

We conclude that B does not functionally determine C. 13. Topic: Transactions (d)  In option (d), a problem will occur. Suppose first transaction A is reading data written by second transaction B, but B has not committed yet. If A acts on that data and eventually commits, but B rollbacks then, A will have “acted on” data that was never committed. So, it will lead to irrecoverable error in the database. 14. Topic: Relational Model: SQL (a)  P is projection that by default selects distinct value of attributes. Cross product will consider all the tables r1, r2, … rn. Row (s ) selects all the rows satisfying predicate P. 15. Topic: Normal Forms (d)  The applicable FDs are: Date_of_birth → Age Age → Eligibility Name → Roll_number Roll_number → Name The candidate keys are (Roll_number, Date_of_birth) and (Name, Date_of_ birth)

Ch wise GATE_CSIT_CH09_Databases.indd 329

329

For candidate key the FD Date_of_birth → Age is a partial dependency. So, the relation is in 1NF. Candidate keys for given relation are: (Date_of_birth, name) and (Date_of_birth, Roll_number) Data of Birth → Age Age (non-prime) is partially dependent upon Date of Birth which is prime attribute. According to 2NF definition, every non-prime attribute should be fully functional dependent on key, so it is not in 2NF. Therefore, it will not be in 3NF and BCNF also. 16. Topic: Relational Model: SQL (c)  Use of distinct selects the name only once. Due to distinct selected names will be unique, so one person will be selected only once, in spite of getting grade A in any number of courses taught by Shyam. 17. Topic: Relational Model: Relational Algebra (b)  C is foreign key in relation R1 referring to relation R2. So, C would not contain any a­ dditional value that is not present in D. So, ΠC(r1) − ΠD(r2) will return no value. Returns all the tuples which are in ΠC(r1) but not in ΠD(r2). 18. Topic: Relational Model: Tuple Calculus (a)  The maximum and minimum number of tuples presented in (Student * Enroll) would be represented by the minimum of these 120 and 8, that is, min(120, 8) = 8 Natural join has inbuilt condition of equality. So, in both the relations, minimum and maximum tuples will be 8. 19. Topic: ER-Model (a) getId and getName can be placed in base class. Because all the subclasses will have the same implementation for these functions. But getSalary is dependent on category of employee. So, abstract function can be placed in base class and its implementation in the subclasses. 20. Topic: Normal Forms (b)  Name and RollNo are candidate keys. The attributes are not repeated. So, the relation schema is in 1NF. There is no partial dependency. So, the relation is in 2NF. Grade is not fully dependent upon all candidate keys, so it is not in 3NF. Candidate keys for given relation are: (RollNo, CourseNo) and (Name, CourseNo) there is no partial and transitive dependencies. So, the highest normal form is 3NF. name → RollNo and RollNo → Name are violating the condition of BCNF.

11/13/2018 11:07:15 AM

330

GATE CS and IT Chapter-wise Solved Papers

21. Topic: Relational Model: Relational Algebra (d) The query is Part 1 − Part 2. Part 2 of the query results in names of girls having marks less than or equal to marks of all the boys. And Part 1 selects the names of all the girls in class. So, Part 1 − Part 2 will result in names of girl students having more marks than all the boy students. 22. Topic: Indexing (e.g., B and B+ trees) (c)  Order of  internal node is PI . CP + (PI − 1) KV x undo operations. 32. Topic: Relational Model: SQL (c)  Both Query1 and Query2 perform the same task, but none of them sort the customer according Indexed nested loop join to the decreasing balance. So, option (c) is correct. 33. Topic: Relational Model: SQL Project on course (a)  The output of Query 2, Query 3 and Query 4 will be identical. Query 1 produces duplicate rows. But row set produced by all the queries will be same. For example,

Table: Enrolled Student

Course

Table: Enrolled Student

Amount

A

C1

A

100

B

C1

B

100

A

C2

D

200

C

C1

Output of Query 1: A B Output of Query 2: A B Output of Query 3: A B Output of Query 4: A B 34. Topic: File Organization Enrolled

Paid

Probe index on student

Sequential scan select ′ amount >x

Indexed nested loop join

Project on course

Ch wise GATE_CSIT_CH09_Databases.indd 331

Enrolled

Probe index on student

331

Paid

Sequential scan

Indexed nested loop join

Select on amount > x

Project on course (c)  Plans need to load both tables’ courses and enrolled. So, disk access time is the same for both plans. Plan 2 does lesser number of comparisons compared to Plan 1. So, join operation will require more comparisons as the second table will have more rows in Plan 2 compared to Plan 1. The joined table of two tables will have more rows, so, more comparisons are needed to find amounts greater than x. Plan 1 executes faster than Plan 2. First tuples are filtered then joined, whereas in plan 2 first tuples are joined and then filtered, which takes more time. 35. Topic: Relational Model: Relational Algebra (c) Closure of AF or AF+ = {ADEF}, ­closure of AF does not contain C and G. Enrolled Paid The closure of {AF}+ is {A F D E}. It cannot drive all the members of set given in option (c). So, option (c) is false. 36. Topic: Relational Model: Relational Algebra Probe Sequential scan (b) index on   student (i) Select studId of all female students and select all courseId of all courses.   (ii)  The query performs a Cartesian product of the above select two columns in Step 1. (iii)  It subtracts enroll table from the result of Step 2. Indexed nested loop join This will remove all the (studId, courseId) pairs, which are present in enrol table. If all female students have registered in courses, then Select on amount > x this course will not be there in the subtracted result. So, the complete expression returns courses in which a proper subset of female students is enrolled. Project on course

11/13/2018 11:07:16 AM

332

GATE CS and IT Chapter-wise Solved Papers

37. Topic: Relational Model: SQL (b)  The query selects all those employees whose immediate subordinate is “male”. 38. Topic: Relational Model: SQL (b)  Q1 selects an employee but does not compute the result as after the ‘Where not exists’, it does not have statement to produce the result. Q2 selects an employee who gets higher salary than anyone in the department 5. It correctly finds employees who get higher salary than anyone in the department 5. 39. Topic: Normal Forms (d)  According to the definition of 3NF, a prime attribute can be transitively dependent on a key. Option (d) is incorrect because this does not satisfy the condition of BCNF. 40. Topic: Indexing (e.g., B and B+ trees) (b)  Let the order of the leaf node be n. Block size = 1 KB = 1024 bits 6 + 7n + (n − 1)9 = 1024 n = 64 41. Topic: Relational Model: Tuple Calculus (c) Schedule S1 T1

T2

r1(X) r1(Y) r2(X) r2(Y) w2(Y) w1(X) The schedule is not conflict serializable. Schedule S2 T1

T2

r1(X) r2(X) r2(Y) w2(Y) r1(Y) w1(X) The schedule is conflict serializable to T2T1. 42. Topic: Indexing (e.g., B and B+ trees) (a) Clustering index is defined on the fields. If the records of the file are physically ordered on a non-key field, it will not have a distinct value for each record. So,

Ch wise GATE_CSIT_CH09_Databases.indd 332

the clustering index is defined on the fields of type nonkey and ordering. 43. Topic: Relational Model: Tuple Calculus (c)  Using negation theorem, we find option (c) is true. 44. Topic: Relational Model: Relational Algebra (c)  In I, P from natural join of R and S are selected. In III, all P from intersection of (P, Q) pairs ­present in R and S. IV is also equivalent to III because (R − (R − S)) = R ∩ S. II is not equivalent as it may also include P, where Q is not same in R and S. Queries I, II and III performs the same operations, that is, they select attribute P. 45. Topic: Normal Forms (c)  Collection is in BCNF as there is only one functional dependency Title Author → Catalog_no and {Author, Title} is key for collection. Book is not in BCNF because Catalog_no is not a key and there is a functional dependency Catalog_no → Title Author Publisher Year. Book is not in 3NF because non-prime attributes (Publisher Year) are transitively dependent on key [Title, Author]. Book is in 2NF because every non-prime attribute of the table is dependent on either the key [Title, Author] or another non-prime attribute. 46. Topic: ER-Model (a)  Many-to-one and one-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the “many” side, containing the ­primary key of the “one” side. Since R1 is many to one and participation of M is total, M and R1 can be combined to form the table {M1, M2, M3, P1}. N is a week entity set, so it can be combined with P. 47. Topic: ER-Model (a) For R1 correct attribute set: M1, M2, M3, P1 For R2 correct attribute set: N1, N2, P1, P2 with P1 as ­primary key and N1 as weak entity set. 48. Topic: Transactions (b)  The serial schedule T1T2 has the following sequence of operations: R1[x]W1[x]W1[y]R2[x]R2[y]W2[y] And the schedule T2T1 has the following sequence of operations: R2[x]R2[y]W2[y]R1[x]W1[x]W1[y] The schedule S2 is conflict-equivalent to T2T1 and S3 is conflict-equivalent to T1T2.

11/13/2018 11:07:16 AM

Chapter 9  •  Databases

Only S 2 and S 3 are conflict serialzable schedules. To test for conflict serializability, make the wait for graph. If there is a cycle in graph, it means not conflict serializable. 49. Topic: Indexing (e.g., B and B+ trees) (d)  Total number of splits here are 5. 4

2

1

2

3

3

6

4

6

8 10

50. Topic: Relational Model: Relational Algebra (a)  I and II describe the division operator in relational algebra and tuple relational calculus, respectively. 51. Topic: Relational Model: SQL (a)  The sub-query “SELECT P.pid FROM Parts P WHERE P.color ‘blue’” returns pids of parts, which are not blue. The sub-query “SELECT C.sid FROM Cata-

log C WHERE C.pid NOT IN (SELECT P.pid FROM Parts P WHERE P.color ‘blue’)”

returns sid of all those suppliers who have supplied blue parts. The complete query returns the names of all suppliers who have supplied a non-blue part. Inner query SELECT P. pid FROM Parts P WHERE P. color ‘blue’ will select pid of non-blue parts. Outer query of this will produce sid of those suppliers whose pid is not in the result of inner query. The query will result the supplier names who have supplied non-blue parts. 52. Topic: Normal Forms (b)  Candidate key: sname, city Primary key: sname Alternate key: sid, sname city → street sname → city Transitivity: sname → city → street So, it is in 3NF. 53. Topic: Indexing (e.g., B and B+ trees) (b)  In B+ tree, root node has minimum two block pointers and maximum p block pointer, where p = order and key = order − 1. In the non-root node, the minimum number of keys = p/2 − 1 Here, key = 5, order = 6

Ch wise GATE_CSIT_CH09_Databases.indd 333

333

So, minimum number of keys in non-root node = 6/2 − 1 = 2 54. Topic: Relational Model: SQL (c)  The outer query selects four entries (with pid as 0, 1, 5, 3) from Reservation table. Out of these selected entries, the sub-query returns non-null values only for 1 and 3. 55. Topic: Concurrency Control (b)  Two-phase locking is a concurrency control method, which guarantees serializability. The protocol utilizes locks, applied by a transaction to data, which may block other transactions from accessing the same data during the transaction’s life. 2PL may be lead to deadlocks which result from the mutual blocking of two or more transactions. Timestamp ordering algorithm is a non-lock concurrency control method. In Timestamp based method, deadlock cannot occur as no transaction ever waits. 56. Topic: Transactions (a)  T1 can complete before T2 and T3 as there is no conflict between Write(X) of T1 and the operations in T2 and T3 which occur before Write(X) of T1. T3 can complete before T2 as the Read(Y) of T3 does not conflict with Read(Y) of T2. Similarly, Write(X) of T3 does not conflict with Read(Y) and Write(Y) ­operations of T2. After topologically sorting, the sequence is T1 → T3 → T2. 57. Topic: Relational Model: Tuple Calculus (a)  B is a candidate key of R. So, all 200 values of B must be unique in R. There is no functional dependency given for S. For the maximum number of tuples in output, there are two ways. (i) All 100 values of B in S are same and there is an entry in R, which matches with this value. So, we are having 100 tuples in output. (ii) All 100 values of B in S are different and these values are present in R also. So, we are having 100 tuples. 58. Topic: ER-Model (a)  When two students hold joint account in that case BankAccount_Num will not uniquely determine other attributes. 59. Topic: Relational Model: SQL (c)  Output as Table S: Borrower

Bank_Manager

Ramesh

Sunderajan

Suresh

Ramgopal

Mahesh

Sunderajan

11/13/2018 11:07:16 AM

334

GATE CS and IT Chapter-wise Solved Papers

Output as Table T: Bank_Manager

Loan_Amount

Sunderajan

10000.00

Ramgopal

5000.00

Sunderajan

7000.00

Natural Join of S and T : Borrower

Bank_Manager

Loan_Amount

Ramesh

Sunderajan

10000.00

Ramesh

Sunderajan

7000.00

Suresh

Ramgopal

5000.00

Mahesh

Sunderajan

10000.00

Mahesh

Sunderajan

7000.00

60. Topic: Relational Model: SQL (a)  The value of X is calculated using MX + 1 and Y is calculated using 2 × MY + 1 For example, X = 1 and Y = 1 at the next step, X = MX + 1 = 1 + 1 = 2, Y = 2 × MY + 1=2×1+1=3

63. Topic: Normal Forms (c) Any relation that is in xNF, will automatically be in ‘x-1’ NF. Now, let us see the order of NF as we discussed in the text, it is – 1NF, 2NF, 3NF, BCNF, 4NF and 5NF. Therefore, option (c) is correct. 64. Topic: Integrity Constraints (a)  B is a foreign key in r1, which refers to C in r2. r1 and r2 satisfy referential integrity constraints. So, every value that exists in column B of r1 must also exist in column C of r2. 65. Topic: ER-Model (b)  Two schedules are conflict-serializable if the actions belong to different transactions, one of the actions is a write operation, the actions access the same object (read or write). Two schedules are conflict-equivalent if both schedules involve the same set of transactions, and the order of each pair of conflicting actions in both schedules is the same. Take the following schedule: S: r1(P); r1(Q); r2(Q); r2(P); w1(Q);w2(P)

T1 X

Y

1

1

2

3

3

7

4

15

5

31

6

63

7

127

61. Topic: Relational Model: SQL (b) HAVING clause can also be used with aggregate function. If we use a HAVING clause without a GROUP BY clause, the HAVING condition applies to all rows that satisfy the search condition. 62. Topic: ER-Model (c)  In relational table, more than one value for an attribute will violate the condition of first normal form. So, option (c) is incorrect.

Ch wise GATE_CSIT_CH09_Databases.indd 334

T2

Cycle exists between two transactions, so T1 and T2 are not conflict serializable. A schedule is conflict-serializable when the schedule is conflict-equivalent to one or more serial schedules. There are two possible serial schedules–T1 followed by T2 and T2 followed by T1. In both, one of the transactions reads the value written by another transaction as a first step. 66. Topic: Relational Model: Relational Algebra (a)  A ∪ B Id

Name

Age

12

Arun

60

15

Shreya

24

99

Rohit

11

25

Hari

40

98

Rohit

20

( A ∪ B ) 

A.Id > 40  C .Id = All compares it with the all the values. So, option (a) will find address of theaters with maximum capacity. 93. Topic: ER-Model (4)  The relations are as shown: E1: E2: E3: E1−E3: for m:n relationship E1 − E2 We cannot combine any relation here as it will give rise to partial functional dependency and thus violate 3NF. 94. Topic: Relational Model: SQL (2)  Since here group by Name is done, therefore marks for roll nos. 1 and 3 are added together giving 310 and marks for roll no. 2, that is, Rohit are added up to give 140. Thus, the resulting output table is: Student_Name

Marks

Raj

310

Rohit

140

95. Topic: Transactions (a)  The transactions that are not c­ ommitted must not be saved in database. Hence, we undo transactions T1 and T 3 here as they are not yet committed. Transaction that is after the c­ heckpoint must be redone. Hence, we redo the transaction T 2.

11/13/2018 11:07:18 AM

338

GATE CS and IT Chapter-wise Solved Papers

96. Topic: Relational Model: Tuple Calculus (c)

R1 ⇒

R⇒

A

B

1

5

3

7

A

B

C

1

5

7

3

7

Null

4

Null

9

R2 ⇒   

101. Topic: Normal Forms (b)  We have

A

C

1

7

4

9

a = (1,5,null), b = (1,null,7) c = (3,null,9), d = (4,7,null), e = (1,5,7), f = (3,7,null), g = (4,null,9). a, b, c and d are not the rows of relation R but e, f, g are the rows in relation R. Hence, option (c) is correct. 97. Topic: Indexing (e.g., B and B+ trees) (50)  In B+ trees, if order of tree is p then for internal nodes: p(child pointer) + (p − 1)(Key value) ≤ Block size p(8) + (p − 1)12 ≤ 1024 20p − 12 ≤ 1024 p ≤ 51 ⇒ p = 51 So, for 51 order tree, we can save maximum 50 keys. 98. Topic: Transactions (b)  T2 transaction reads the value written by T1 transaction. T2 is committed before T1 and T1 fails. Thus, T2 has read that value of A which no more exists in the database. Hence, the schedule S is non-recoverable schedule. Also, it doesn’t ensure atomicity. 99. Topic: Integrity Constraints (b)  A superkey is one which contains a candidate key. Superkey = Candidate key + One or more attributes It is given that the candidate key = VY. However, we are asked to find ‘Which is NOT a ­superkey?’ Option (b) does not have Y; thus, here is no chance for it to become superkey. 100. Topic: ER-Model (d) A C I D ⇓ ⇓ ⇓ ⇓ Atomicity Consistency Isolation Durability

Ch wise GATE_CSIT_CH09_Databases.indd 338

Journal (Volume, Number, StartPage, EndPage, Title, Year, Price) where •  Primary key: Volume, Number, StartPage, EndPage •  FDs: Volume, Number, StartPage, EndPage → Title Now, •  (Volume, Number) → Year •  (Volume, Number, StartPage, EndPage) → Price The given relation is in 1NF; however, it is not in 2NF. The database is redesigned to following schemas: •  R1(Volume, Number, StartPage, EndPage, Title, Price) which has the following FDs:      Volume, Number, StartPage, EndPage → Title 

    Volume, Number, StartPage, EndPage → Price which is in BCNF. •  R2(Volume, Number, Year) 

Volume, Number → Year which is also in BCNF. Journal in 1NF. R1 and R2 in BCNF. The weakest normal form which satisfies R1 and R2 and fails for journal is 2NF. 102. Topic: Indexing (e.g., B and B+ trees) (a)  It is a property that a tree is balanced if the lengths of the paths from the root to all leaf nodes are all equal. 103. Topic: Transactions (a) For serial schedule topological sort is used. The algorithm is given as follows: Step 1: Visit vertex with indegree = 0. Delete the ­vertex. Step 2: Repeat Step 1 for all vertices → There can be many sequences (serial schedule). The topological order of a graph (precedence graph) yields a serial schedule. 104. Topic: Transactions (a)  The two phase locking protocol over objects O1... Ok: •  Step 1: T acquires exclusive lock to O1 ... Ok in increasing order of their address. •  Step 2: The required operations are performed. •  Step 3: All locks are released. Since we have two phase locking protocol, it guarantees serializability and objects locks in increasing order of address and all objects locks before read/write which avoids deadlock. Therefore, statement given in option (a) is the correct one.

11/13/2018 11:07:18 AM

Chapter 9  •  Databases

339

105. Topic: Transactions (c)  As there is no dirty-read problem in the given schedule, the schedule is both recoverable and it does not have a cascading abort.

110. Topic: Transactions (0)  No record will be deleted after deleting (3, 8) from Table T1. In Table T2, value of “3” is set to null in the record (8, 3).

106. Topic: Relational Model: SQL (2)  The result of the query is name Bikaner Churu

111. Topic: Relational Model: Tuple Calculus (d)  All queries are safe as they yield a finite number of tuples as their output.

Total

Total_avg

Name

Capacity

Capacity

Ajmeer

20

25

Bikaner

40

Churu

30

Dungargarh

10

107. Topic: ER-Model (a) As V → W exists ⇒ In VW → X, W is an extraneous attribute. ⇒ V→X As V → X exists ⇒ In Y → VX, X is an extraneous attribute. ⇒ Y→V Therefore, the irreducible set is V→W V→X Y→V Y→Z 108. Topic: Relational Model: SQL (2.6)  Inner query output

AA

4

AB

3

AC

3

AD

2

AE

1

CA CB CC Output of T2: StudentName

SF Therefore, the number of rows in T2 is 4. 114. Topic: Transactions (54) Number of conflict serializable schedule on T1→ T2 is 1. Number of schedules that are conflict serializable to T2 → T1 is 53.

109. Topic: ER-Model (c) Relation R merges with that of A which implies that the many-to-one relationship exists. 1 R

Towards A side, the participation is total.

Ch wise GATE_CSIT_CH09_Databases.indd 339

CourseName

SD

13 = 2.6 5

M

(4)  Output of T1:

SC

Number

A

113. Topic: Relational Model: Relational Algebra

SA

Department Name

Outer query result =

112. Topic: Transactions (a)  Elder kills younger and younger waits on elder. So both are not waiting for each other. Hence, no deadlock. Given, if TS(T2) < TS(T1) then T1 is killed else T2 waits As killed transaction restart with the same TS value, it is starvation free.

B

T1: r1(X ) w1(X ) r1(Y   ) w1(Y   ) T2 that conflicts with that of T1 at w2(Y   ). w2(Y  ) can appear in these places: 1. w2(Y  ) r1(X) w1(X) r1(Y) w1(Y) → r2(Z) w2(Z) can place in 1 × (5C1 + 5C2) = 15 2. r1(X) w2(Y  ) w1(X) r1(Y  ) w1(Y) → r2(Z) w2(Z) can place in 2 × (4C1 + 4C2) = 20

11/13/2018 11:07:19 AM

340

GATE CS and IT Chapter-wise Solved Papers

3. r1(X) w1(X) w2(Y  ) r1(Y) w1(Y) → r2(Z) w2(Z) can place in 3 × ( C1 + C2) = 18 Therefore, total conflict serializable schedules = 1 + 53 = 54 3

3

115. Topic: Relational Model: SQL (7)  The output is Klose, Ronaldo, G Muller, Fontaine, Pele, Klinsmann, Kocsis. Therefore, the number of tuples returned by the above SQL query is 7. 116. Topic: Indexing (e.g., B and B+ trees) (52) Given, Search-key = 8 bytes, Block size = 512 bytes and Block pointer = 2 bytes. Let P be the maximum order of B+ tree. Then P * 2 + (P - 1) 8 ≤ 512 ⇒ 2P + 8P - 8 ≤ 512 ⇒ 10P ≤ 520 ⇒ P ≤ 52

Every entity of E1 is associated with exactly one entity of E2. 119. Topic: Relational Model: SQL (d)  Query 4 has an output that is superset of the outputs of the other three queries. Query 4 is full outer join which is superset of records compared to inner joint, left outer join and right outer join. 120. Topic: Indexing (e.g., B and B+ trees) (4)  In inorder traversal, left subtree is visited first then the root node and in the end right subtree is visited. In postorder traversal, left subtree is visited first, then the right subtree is visited and finally root node is ­visited. Given, postorder traversal of binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1 Inorder traversal of same tree is 8, 6, 9, 4, 7, 2, 5, 1, 3 Thus, the tree is: 1

117. Topic: Relational Model (b)  Recursive enumerable language is also called turing recognizable language that can be accepted and recognized by turing machine. It will enter into final state for the strings of language and may or may not enter into rejecting state for the strings which are not part of the language. The set of recursively enumerable languages is closed under intersection. 118. Topic: ER-Model (a)  Given, two entity sets E1 and E2. R is many to one relationship from E1 to E2. Cardinality of E1 is greater than cardinality of E2. M E1

1 R

E2

Cardinality of E1 is greater than cardinality of E2. a1 a2 a3 E1

Ch wise GATE_CSIT_CH09_Databases.indd 340

b1 b2 R E2

2

4

6

8

3

5

7

9

Thus, height of given binary tree is 4. 121. Topic: Relational Model (b) Given,

φ ≡ ∃s∃t ∃u∀v∀ω∀x∀yψ ( s, t , u, v, w , x, y ) Statement in option (a) is false: There exists at least one model of φ with universe of size less than or equal to 3. Statement in option (b) is true – There exists no model of φ with universe of size less than or equal to 3. Statement in option (c) is false – There exist no model of φ with universe of size greater than 7. Statement in option (d) is false – Every model of φ has a universe of size equal to 7.

11/13/2018 11:07:19 AM

Computer Networks

C H A P T E R 10

Syllabus Concept of layering. LAN technologies (Ethernet). Flow and error control techniques, switching. IPv4/IPv6, routers and routing algorithms (distance vector, link state). TCP/UDP and sockets, congestion control. Application layer ­protocols (DNS, SMTP, POP, FTP, HTTP). Basics of Wi-Fi. Network security: authentication, basics of public key and p­ rivate key cryptography, digital signatures and certificates, firewalls.

Chapter Analysis Topic

GATE 2009

GATE 2010

GATE 2011

GATE 2012

GATE 2013

GATE 2014

GATE 2015

GATE 2016

GATE 2017

1

1

1

1

3

4

2

1

1

2

1

3

2

1

1

2

5

1

2

GATE 2018

Concept of Layering LAN Technologies (Ethernet) Flow and Error Control Techniques

3

1

1 3

Switching IPv4/IPv6

2

2

1

Routers Routing Algorithms (Distance Vector, Link State) TCP/UDP

2

2

1

1

1

2

3

Sockets Congestion Control

1

Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP)

1

1

1

2

1

1

2

2

1

1

2

Basics of Wi-Fi Network Security

1

1 1

1

2

Important Formulas Application

Protocol

SMTP

TCP

TELNET

TCP

SSH

TCP

HTTP

TCP

DNS

TCP & UDP

PING

ICMP

Ch wise GATE_CSIT_CH10_Computer Networks.indd 341

1. In early token release, Throughput for single station or N stations Data = Transmission time + (Ring latency Number of stations) 2. In delayed token release,



Throughput for single station Data = Transmission time + Ring latency + (Ring latency/Number of stations)

11/13/2018 11:11:49 AM

342



GATE CS AND IT Chapter-wise Solved Papers

Throughput for N stations Data = Ring latency + (Ring latency Number of stations)

3. Transmission time =

Message size (bits) Bandwidth (bits/s)

Distance Velocity 5. For stop-and-wait ARQ



Link utilisation of sender or throughput is given by

η=

Transmission time Transmission time + 2 × Propagation delay

6. Pure ALOHA

4. Propagation time =





Throughput (S) = G × e−2G Vulnerable time = 2 × Tfr Smax= 18.4%

7. Slotted ALOHA

Message size Transmission time = Bandwidth Distance of the link Propagation delay = Velocity



Throughput (S) = G × e−G Vulnerable time = Tfr Smax= 36.8%

IEEE standards: 802.11 Protocol

Frequency (GHz)

Bandwidth (MHz)

802.11 (1997)

Allowable MIMO streams

Modulation Type

Approx. Range (metres)



DSSS, FHSS

Indoors: 20 Outdoors: 100

802.11a (1999)

5

20



OFDM

Indoors: 35 Outdoors: 120

802.11b (1999)

2.4

22



DSSS

Indoors: 35 Outdoors: 140

 802.11g (2003)

2.4

20



OFDM DSSS

Indoors: 38 Outdoors: 140

 802.11n (2009)

2.4/5

20

4

OFDM

Indoors: 70 Outdoors: 250

802.11ac (2013)

5

20 40 80 160

8



Indoors only: 35

QUESTIONS 1. In serial data transmission, every byte of data is padded with a ‘0’ in the beginning and one or two ‘1’s at the end of byte because (a) Receiver is to be synchronized for byte reception (b) Receiver recovers lost ‘0’s and ‘1’s from these padded bits (c) Padded bits are useful in parity computation (d) None of the above (GATE 2002: 1 Mark) 2. Dynamic linking can cause security concerns because (a) Security is dynamic (b) The path for searching dynamic libraries is not known till runtime

Ch wise GATE_CSIT_CH10_Computer Networks.indd 342

(c) Linking is insecure (d) Cryptographic procedures are not available for dynamic linking (GATE 2002: 2 Marks) 3. Which of the following assertions is FALSE about the Internet Protocol (IP)? (a) It is possible for a computer to have multiple IP addresses. (b) IP packets from the same source to the same destination can take different routes in the network. (c) IP ensures that a packet is discarded if it is unable to reach its destination within a given number of hops.

11/13/2018 11:11:50 AM

343

Chapter 10  •  Computer Networks

(d) The packet source cannot set the route of an outgoing packet; the route is determined only by the routing tables in the routers on the way.

8. Choose the best matching between Groups 1 and 2. Group: 1

Group: 2

P. Data link layer

1. Ensures reliable transport of data over a physical point-to-point link

Q. Network layer

2. Encodes/decodes data for physical transmission

R. Transport layer

3. Allows end-to-end ­communication between two processes

(GATE 2003: 1 Mark) 4. Which of the following functionalities must be implemented by a transport protocol over and above the network protocol? (a) Recovery from packet losses (b) Detection of duplicate packets (c) Packet delivery in the correct order (d) End-to-end connectivity (GATE 2003: 1 Mark) 5. The subnet mask for a particular network is 255.255.31.0. Which of the following pairs of IP addresses could belong to this network? (a) 172.57.88.62 and 172.56.87.233 (b) 10.35.28.2 and 10.35.29.4 (c) 191.203.31.87 and 191.234.31.88 (d) 128.8.129.43 and 128.8.161.55 (GATE 2003: 2 Marks) 6. A 2-km long broadcast LAN has 107 bps bandwidth and uses CSMA/CD. The signal travels along the wire at 2 × 108 m/s. What is the minimum packet size that can be used on this network? (a) 50 bytes (b) 100 bytes (c) 200 bytes (d) None of the above (GATE 2003: 2 Marks) 7. Host A is sending data to host B over a full duplex link. A and B are using the sliding window protocol for flow control. The send and receive window sizes are 5 packets each. Data packets (sent only from A to B) are all 1000 bytes long and the transmission time for such a packet is 50 ms. Acknowledgement packets (sent only from B to A) are very small and require negligible transmission time. The propagation delay over the link is 200 ms. What is the maximum achievable throughput in this communication? (a) 7.69 × 106 bps (b) 11.11 × 106 bps (c) 12.33 × 106 bps (d) 15.00 × 106 bps (GATE 2003: 2 Marks)

Ch wise GATE_CSIT_CH10_Computer Networks.indd 343

4. Routes data from one ­network node to the next (a) P:1, Q:4, R:3 (c) P:2, Q:3, R:1

(b) P:2, Q:4, R:1 (d) P:1, Q:3, R:2 (GATE 2004: 1 Mark)

9. Which of the following is NOT true with respect to a transparent bridge and a router? (a) Both bridge and router selectively forward data packets. (b) A bridge uses IP addresses while a router uses MAC addresses. (c) A bridge builds up its routing table by inspecting incoming packets. (d) A router can connect between a LAN and a WAN. (GATE 2004: 1 Mark) 10. How many 8-bit characters can be transmitted per second over a 9600 baudserial communication link using asynchronous mode of transmission with one start bit, eight data bits, two stop bits, and one parity bit? (a) 600 (b) 800 (c) 876 (d) 1200 (GATE 2004: 1 Mark) 11. A and B are the only two stations on an Ethernet. Each has a steady queue of frames to send. Both A and B attempt to transmit a frame, collide, and A wins the first back-off race. At the end of this successful transmission by A, both A and B attempt to transmit and collide. The probability that A wins the second backoff race is (a) 0.5 (b) 0.625 (c) 0.75 (d) 1.0 (GATE 2004: 2 Marks)

11/13/2018 11:11:50 AM

344

GATE CS AND IT Chapter-wise Solved Papers

12. The routing table of a router is shown below: Destination

Subnet Mask

Interface

128.75.43.0

255.255.255.0

Eth0

128.75.43.0

255.255.255.128

Eth1

192.12.17.5

255.255.255.255

Eth3

Default

Eth2

On which interface will the router forward packets addressed to destinations 128.75.43.16 and 192.12.17.10, respectively? (a) Eth1 and Eth2 (c) Eth0 and Eth3

(b) Eth0 and Eth2 (d) Eth1 and Eth3 (GATE 2004: 2 Marks)

Common Data Questions 13 and 14: Consider three IP networks A, B and C. Host HA in network A sends messages each containing 180 bytes of application data to a host HC in network C. The TCP layer prefixes a 20-byte header to the message. This passes through an intermediate network B. The maximum packet size, including 20-byte IP header, in each network is A: 1000 bytes B: 100 bytes C: 1000 bytes The network A and B are connected through a 1 Mbps link, while B and C are connected by a 512 Kbps link (bps = bits per second). 1 Mbps Network A

512 Mbps Network B

Network C

13. Assuming that the packets are correctly delivered, how many bytes, including headers, are delivered to the IP layer at the destination for one application message, in the best case? Consider only data packets. (a) 200   (b) 220    (c) 240   (d) 260 (GATE 2004: 2 Marks) 14. What is the rate at which application data is transferred to host HC? Ignore errors, acknowledgements and other overheads. (a) 325.5 Kbps (b) 354.5 Kbps (c) 409.6 Kbps (d) 512.0 Kbps (GATE 2004: 2 Marks) 15. 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 (GATE 2005: 1 Mark)

Ch wise GATE_CSIT_CH10_Computer Networks.indd 344

16. 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. (GATE 2005: 1 Mark) 17. The maximum window size for data transmission using the selective reject protocol with n-bit frame sequence numbers is (b) 2n−1 (a) 2n (c) 2n − 1 (d) 2n−2 (GATE 2005: 1 Mark) 18. 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 bridgerouting? (a) For shortest path routing between LANs (b) For avoiding loops in the routing paths (c) For fault tolerance (d) For minimising collisions (GATE 2005: 1 Mark) 19. An organisation has a class B network and wishes to form subnets for 64 departments. The subnet mask would be (a) 255.255.0.0 (b) 255.255.64.0 (c) 255.255.128.0 (d) 255.255.252.0 (GATE 2005: 1 Mark) 20. 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 (GATE 2005: 2 Marks) 21. 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 (GATE 2005: 2 Marks) 22. For which one of the following reasons does Internet Protocol (IP) use the time- to-live (TTL) field in the IP datagram header?

11/13/2018 11:11:50 AM

Chapter 10  •  Computer Networks

(a) Ensure packets reach destination within that time (b) Discard packets that reach later than that time (c) Prevent packets from looping indefinitely (d) Limit the time for which a packet gets queued in intermediate routers (GATE 2006: 1 Mark) 23. 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 (b) 40 (c) 160 (d) 320 (GATE 2006: 2 Marks) 24. 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 the same network, but C1 assumes C2 is on a different network. (c) C1 assumes C2 is on the same network, but C2 assumes C1 is on a different network. (d) C1 and C2 both assume they are on different networks. (GATE 2006: 2 Marks) 25. Station A needs to send a message consisting of 9 packets to station B using a sliding window (window size 3) and Go-Back-N error control strategy. All packets are ready and immediately available for transmission. If every 5thpacket that A transmits gets lost (but no packets from B ever get lost), then what is the number of packets that A will transmit for sending the message to B? (a) 12 (b) 14 (c) 16 (d) 18 (GATE 2006: 2 Marks) Linked Answer Questions 26 and 27: Consider the diagram shown below where a number of LANs are connected by (transparent) bridges. To avoid packets looping through circuits in the graph, the bridges organize themselves in a spanning tree. First, the root bridge is identified as the bridge with the least serial number. Next, the root sends out (one or more) data units 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 multiple bridges forwarding to the same LAN (but not through the root port), ties are broken as

Ch wise GATE_CSIT_CH10_Computer Networks.indd 345

345

follows: bridges closest to the root get preference and between such bridges the one with the lowest serial number is preferred. B1 1

H1 H2

2

H3 H4

2 B5 3 1 4

4

H5 H6 1

3 B3 1 2

H7 H8 2 B4 3

H9 H10

2

1 B2 3 H11 H12

26. For the given connection of LANs by bridges, which one of the following choices represents the depth first traversal of the 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 (GATE 2006: 2 Marks) 27. 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) Hosts

Port

H1, H2, H3, H4

3

H5, H6, H9, H10

1

H7, H8, H11, H12

2

Hosts

Port

H1, H2

4

H3, H4

3

H5, H6

1

H5, H8, H9, H10, H11, H12

2

(b)

(c) Hosts

Port

H3, H4

3

H5, H6, H9, H10

1

H1, H2

4

H7, H8, H11, H12

2

11/13/2018 11:11:51 AM

346

GATE CS AND IT Chapter-wise Solved Papers

(d) Hosts

Port

H1, H2, H3, H4

3

H5, H7, H9, H10

1

H7, H8, H11, H12

4

34. The distance between two stations M and N is L km. All frames are K bits long. The propagation delay per kilometre is t s. Let R bits/s 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 utilisation, when the sliding window protocol is used, is 2 LtR + 2 K ⎤ ⎡ 2LtR ⎤ ⎡ (a) ⎢log 2 ⎥ (b) ⎢log 2 K ⎥ K ⎣ ⎦ ⎣ ⎦

(GATE 2006: 2 Marks) 28. 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 the above (GATE 2007: 1 Mark) 29. Which one of the following uses UDP as the transport protocol? (a) HTTP (b) Telnet (c) DNS (d) SMTP (GATE 2007: 1 Mark) 30. 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 (b) (1 − p)n−1 (c) p(1−p)n−1 (d) 1 − (1−p)n−1 (GATE 2007: 2 Marks) 31. In a token ring network, the transmission speed is 107 bps and the propagation speed is 200 m/ms. The 1-bit delay in this network is equivalent to: (a) 500 m of cable (b) 200 m of cable (c) 20 m of cable (d) 50 m of cable (GATE 2007: 2 Marks) 32. The address of a class B host is to be split into subnets with a 6-bit subnet number. What is the maximum number of subnets and the maximum number of hosts in each subnet? (a) 62 subnets and 262142 hosts (b) 64 subnets and 262142 hosts (c) 62 subnets and 1022 hosts (d) 64 subnets and 1024 hosts (GATE 2007: 2 Marks) 33. The message 11001001 is to be transmitted using the CRC polynomial x3 + 1 to protect it from errors. The message that should be transmitted is (a) 11001001000 (b) 11001001011 (c) 11001010 (d) 110010010011 (GATE 2007: 2 Marks)

Ch wise GATE_CSIT_CH10_Computer Networks.indd 346

2 LtR + K ⎤ ⎡ (d) ⎢log 2 2 K ⎥⎦ ⎣

2LtR + K ⎤ ⎡ (c) ⎢log 2 ⎥ K ⎣ ⎦

(GATE 2007: 2 Marks)

35. Match the following: Column I

Column II

(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 (GATE 2007: 2 Marks) 36. 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 (GATE 2008: 1 Mark) 37. Which of the following system calls results in the sending of SYN packets? (a) Socket (b) Bind (c) Listen (d) Connect (GATE 2008: 1 Mark) 38. In the slow start phase of the TCP congestion control algorithm, the size of the congestion window (a) does not increase. (b) increases linearly. (c) increase quadratically. (d) increase exponentially. (GATE 2008: 2 Marks)

11/13/2018 11:11:52 AM

Chapter 10  •  Computer Networks

39. If a class B network on the Internet has a subnet mask of 255.255.248.0, what is the maximum number of hosts per subnet? (a) 1022 (b) 1023 (c) 2046 (d) 2047 (GATE 2008: 2 Marks) 40. A computer on a 10 Mbps network is regulated by a token bucket. The token bucket is filled at a rate of 2 Mbps. It is initially filled to capacity with 16 Mbits. What is the maximum duration for which the computer can transmit at the full 10 Mbps? (a) 1.6 s (b) 2 s (c) 5 s (d) 8 s (GATE 2008: 2 Marks) 41. 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() and 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 of the following events could take place? (a) Connect() system call returns successfully (b) Connect() system call blocks (c) Connect() system call returns an error (d) Connect() system call results in a core dump (GATE 2008: 2 Marks) 42. In the RSA public key cryptosystem, the private and public keys are (e,n) and (d,n), respectively, where n = p*q and p and q are large primes. Besides, n is public and p and q are private. Let M be an integer such that 0 < M < n and f (n) = (p − 1) (q − 1). Now, consider the following equations:       I.    II. III. IV.

M′ = Memod n M = (M′)d mod n ed ≡ 1 mod n ed ≡ 1 mod f (n) M′ = Memod f (n) M = (M′)dmod f (n)

Which of the above equations correctly represent the RSA cryptosystem? (a) I and II (b) I and III (c) II and IV (d) III and IV (GATE 2009: 2 Marks)

43. While opening a TCP connection, the initial sequence number is to be derived using a time-of-day (ToD) clock

Ch wise GATE_CSIT_CH10_Computer Networks.indd 347



347

that keeps running even when the host is down. The low order 32 bits of the counter of the ToD clock is to be used for the initial sequence numbers. The clock counter increments once per millisecond. 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 (b) 0.064/s (c) 0.135/s (d) 0.327/s (GATE 2009: 2 Marks)

44. 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+xk, for any not exceeding the frame length k. (c) 1+x is a factor of G(x). (d) G(x) has an odd number of terms. (GATE 2009: 2 Marks) Linked Answer Questions 45 and 46: Frame 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 transist (within the link). 45. What is the minimum number of bits (l) that will be required to represent the sequence numbers distinctly? Assume that no time gap needs to be given between transmissions of two frames. (a) l = 2 (b) l = 3 (c) l = 4 (d) l = 5 (GATE 2009: 2 Marks) 46. Suppose that the sliding window protocol is used with the sender window size of 2l, where l is the number of bits identified in the earlier part and l acknowledgements are always piggy backed. After sending 2l 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 (b) 18 ms (c) 20 ms (d) 22 ms (GATE 2009: 2 Marks) 47. One of the header fields in an IP datagram is the time-tolive (TTL) field. Which of the following statements best explains the need for this field? (a) It can be used to prioritise packets. (b) It can be used to reduce delays. (c) It can be used to optimise throughput. (d) It can be used to prevent packet looping. (GATE 2010: 1 Mark)

11/13/2018 11:11:52 AM

348

GATE CS AND IT Chapter-wise Solved Papers

48. Which one of the following is not a client–server application? (a) Internet chat (b) Web browsing (c) E-mail (d) Ping (GATE 2010: 1 Mark)

(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 multiuser system during 9:00 PM and 5:00 AM (GATE 2011: 1 Mark)

49. Suppose computers A and B have IP addresses 10.105.1.113 and 10.105.1.91, respectively, and they both use the same net mask 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 (GATE 2010: 2 Marks)

53. Consider different activities related to email. m1: Send an email from a mail client to a mail server m2: Download an email from mailbox server to a 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 (GATE 2011: 1 Mark)

Linked Answer Questions 50 and 51: Consider a network with 6 routers R1 to R6 connected with links having weights as shown in the following diagram R2

7

R4

6 R1

Linked Answer Questions 54 and 55: Consider a network with five nodes, N1 to N5, as shown below.

8 R6

2 1

N1 3

4 R3

1

9

R5

50. All the routers use the distance vector based routing algorithm to update their routing tables. Each router starts with its routing table initialised to contain an entry for each neighbour with the weight of the respective connecting link. After all the routing tables stabilise, how many links in the network will never be used for carrying any data? (a) 4 (b) 3 (c) 2 (d) 1 (GATE 2010: 2 Marks) 51. 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 stabilise. How many links will now remain unused? (a) 0 (b) 1 (c) 2 (d) 3 (GATE 2010: 2 Marks) 52. 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

Ch wise GATE_CSIT_CH10_Computer Networks.indd 348

3 N5

N2

4

6

2 N4

N3

The network uses a distance vector routing protocol. Once the routes have stabilised, the distance vectors at different nodes are as follows: N1:(0,1, 7, 8, 4) N2: (1, 0, 6, 7, 3) N3: (7, 6, 0, 2, 6) N4: (8,7, 2,0,4) N5: (4, 3, 6, 4, 0) Each distance vector is the distance of the best-known path at that 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 neighbours. 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.

11/13/2018 11:11:52 AM

Chapter 10  •  Computer Networks

349

54. 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) (b) (3, 2, 0, 2, 6) (c) (7, 2, 0, 2, 5) (d) (7, 2, 0, 2, 6) (GATE 2011: 2 Marks)

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 (b) 14 MSS (c) 7 MSS (d) 12 MSS (GATE 2012: 2 Marks)

55. 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 (b) 9 (c) 10 (d) ∞ (GATE 2011: 2 Marks)

61. An Internet Service Provider (ISP) has the following chunk of CIDR-based IP addresses available with it: 245.248.128.0/20. The ISP wants to give half of this chunk of addresses to organisation A, and a quarter to organisation B, while retaining the remaining with itself. Which of the following is a valid allocation of addresses to A and B? (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 (GATE 2012: 2 Marks)

56. Which of the following transport layer protocols is used to support electronic mail? (a) SMTP (b) IP (c) TCP (d) UDP (GATE 2012: 1 Mark) 57. The protocol data unit (PDU) for the application layer in the Internet stack is (a) segment. (b) datagram. (c) message. (d) frame. (GATE 2012: 1 Mark) 58. In the IPv4 addressing format, the number of n­ etworks allowed under class C addresses is (a) 214   (b) 27 (c) 221 (d) 224 (GATE 2012: 1 Mark) 59. Consider a source computer (S) transmitting a file of size 106 bits to a destination computer (D) over a network of two routers (R1 and R2) and three links (L1, L2, and L3). L1 connects S to R1; L2 connects R1 to R2; and L3 connects R2 to D. Let each link be of length 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 1000 bits. Find the total sum of transmission and propagation delays in transmitting the file from S to D? (a) 1005 ms (b) 1010 ms (c) 3000 ms (d) 3003 ms (GATE 2012: 2 Marks) 60. 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

Ch wise GATE_CSIT_CH10_Computer Networks.indd 349

62. 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 (GATE 2013: 1 Mark) 63. Using public key cryptography, X adds a digital signature s to message M, encrypts < M, s >, and sends it to Y, where it is decrypted. Which one of the following sequences of keys is used for the operations? (a) Encryption: X ’s private key followed by Y’s private key; Decryption: X ’s public key followed by Y ’s public key (b) Encryption: X’s private key followed by Y’s public key; Decryption: X ’s public key followed by Y ’s private key (c) Encryption: X ’s public key followed by Y ’s private key; Decryption: Y ’s public key followed by X ’s private key (d) Encryption: X ’s private key followed by Y ’s public key; Decryption: Y ’s private key followed by X ’s public key (GATE 2013: 1 Mark) 64. Assume that source S and destination D are connected through two intermediate routers labelled R.

S

R

R

D

11/13/2018 11:11:53 AM

350

GATE CS AND IT Chapter-wise Solved Papers

Determine how many times each packet has to visit the network layer and the data link layer during a transmission from S to 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 (GATE 2013: 1 Mark)

65. 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 10000 bits. Assume the signal speed in the cable to be 200000 km/s. (a) 1 (b) 2 (c) 2.5 (d) 5 (GATE 2013: 2 Marks) 66. 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, 2400 and 2759 (c) Last fragment, 2400 and 2759 (d) Middle fragment, 300 and 689 (GATE 2013: 2 Marks) 67. 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) (b) (c) (d)

S1, S2, and S3 are all true S1, S2, and S3 are all false. S1 and S2 are true, but S3 is false S1 and S3 are true, but S2 is false. (GATE 2014: 1 Mark)

68. Which one of the following are used to generate a message digest by the network security protocols?

Ch wise GATE_CSIT_CH10_Computer Networks.indd 350

(P) RSA  (Q) SHA-1  (R) DES  (S) MD5 (a) P and R only (c) Q and S only

(b) Q and R only (d) R and S only (GATE 2014: 1 Mark)

69. 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 (b) 1, 2, 3, 4 (c) 4, 1, 2, 3 (d) 2, 4, 1, 3 (GATE 2014: 1 Mark) 70. 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 distance vector routing and RIP uses link state routing (c) Both RIP and OSPF use link state routing (d) Both RIP and OSPF use distance vector routing (GATE 2014: 1 Mark) 71. Which one of the following socket API functions converts an unconnected active TCP socket into a passive socket? (a) Connect (b) Bind (c) Listen (d) Accept (GATE 2014: 1 Mark) 72. In the diagram shown below, L1 is an Ethernet LAN and L2 is a Token-Ring LAN. An IP packet originates from sender 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 (GATE 2014: 1 Mark)

11/13/2018 11:11:53 AM

Chapter 10  •  Computer Networks

73. 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 (GATE 2014: 1 Mark) 74. 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 (b) 0111110101 (c) 0111111101 (d) 0111111111 (GATE 2014: 1 Mark) 75. Host A (on TCP/IP v4 network A) sends an IP datagram D to host B (also on TCP/IP V4 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 different from that of the original datagram D? (i)  TTL  (ii)  Checksum  (iii) Fragment Offset (a) (i) only (c) (ii) and (iii) only

(b) (i) and (ii) only (d) (i), (ii) and (iii) (GATE 2014: 1 Mark)

76. 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 × 108 m/s and the token transmission time is ignored. If each station is allowed to hold the token for 2 msec, the minimum time for which the monitoring station should wait (in msec) . before assuming that the token is lost in (GATE 2014: 2 Marks) 77. 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 in .

103 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. Consider only transmission time and ignore processing, queuing and propagation delays. Also assume that there are no errors during transmission. Let T1, T 2 and T 3 be the times taken to transmit the file in the first, second and third case, respectively. Which one of the following is CORRECT? A

R1

B

R2

(a) T1 < T 2 < T 3 (b) T1 > T 2 > T 3 (c) T 2 = T 3, T 3 < T1 (d) T1 = T 3, T 3 > T 2 (GATE 2014: 2 Marks) 80. 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 (b) Only I1 (c) Only I2 and I3 (d) Only I3 and I4 (GATE 2014: 2 Marks) 81. 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

(GATE 2014: 2 Marks)

Output Interface Identifier

78. 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 ms. To achieve a link utilization of 60%, the minimum number of bits required . to represent the sequence number field is

131.16.00/12

3

131.28.0.0/14

5

131.19.0.0/16

2

(GATE 2014: 2 Marks)

131.22.0.0/15

1

79. Consider the store and forward packet switched network given below. Assume that the bandwidth of each link is 106 bytes / s. A user on host A sends a file of size

Ch wise GATE_CSIT_CH10_Computer Networks.indd 351

351

The identifier of the output interface on which this . packet will be forwarded is (GATE 2014: 2 Marks)

11/13/2018 11:11:54 AM

352

GATE CS AND IT Chapter-wise Solved Papers

82. Every host in an IPv4 network has a 1-second r­ esolution 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? (GATE 2014: 2 Marks) 83. 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 (GATE 2014: 2 Marks) 84. Suppose two hosts use a TCP connection to transfer a large file. Which of the following statements is/are FALSE with respect to the TCP connection?       I. If the sequence number of a segment is m, then the sequence number of the subsequent segment is always m + 1.    II. If the estimated round trip time at any given point of time is t sec the value of the retransmission timeout is always set to greater than or equal to t sec. III. The size of the advertised window never changes during the course of the TCP connection. IV. The number of unacknowledged bytes at the sender is always less than or equal to the advertised window. (a) III only (c) I and IV only

(b) I and III only (d) II and IV only (GATE 2015: 1 Mark)

85. Which one of the following fields of an IP header is NOT modified by a typical IP router? (a) Checksum (b) Source address (c) Time to Live (TTL) (d) Length (GATE 2015: 1 Mark) 86. In one of the pairs of protocols given below, both the protocols can use multiple TCP connections between the same client and the server. Which one is that? (a) HTTP, FTP (b) HTTP, TELNET (c) FTP, SMTP (d) HTTP, SMTP (GATE 2015: 1 Mark) 87. A link has a transmission speed of 106 bits/s. It uses data packets of size 1000 bytes each. Assume that the acknowledgement has negligible transmission delay, and that its propagation delay is the same as the data propagation

Ch wise GATE_CSIT_CH10_Computer Networks.indd 352

delay. Also assume that the processing delays at the nodes are negligible. The efficiency of the stop-and-wait protocol in this setup is exactly 25%. The value of the one-way propagation delay (in milliseconds) is . (GATE 2015: 1 Mark) 88. Consider the following statements     I. TCP connections are full duplex   II. TCP has no option for selective acknowledgement III. TCP connections are message streams (a) (b) (c) (d)

Only I is correct Only I and III are correct Only II and III are correct All of I, II, and III are correct (GATE 2015: 1 Mark)

89. Consider a CSMA/CD network that transmits data at a rate of 100 Mbps (108 bits per second) over a 1 km (kilometer) cable with no repeaters. If the minimum frame size required for this network is 1250 bytes, what is the signal speed (km/s) in the cable? (a) 8000 (b) 10000 (c) 16000 (d) 20000 (GATE 2015: 1 Mark) 90. Suppose that the stop-and-wait protocol is used on a link with a bit rate of 64 kilobits per second and 20 milliseconds propagation delay. Assume that the transmission time for the acknowledgement and the processing time at nodes are negligible. Then the minimum frame size in bytes to achieve a link utilization of at least 50% is . (GATE 2015: 2 Marks) 91. Consider a LAN with four nodes S1, S2, S3 and S4. Time is divided into fixed-size slots, and a node can begin its transmission only at the beginning of a slot. A collision is said to have occurred if more than one node transmit in the same slot. The probability of generation of a frame in a time slot by S1, S2, S3 and S4 are 0.1, 0.2, 0.3 and 0.4, respectively. The probability of sending a frame in the first slot without any collision by any of these four stations is . (GATE 2015: 2 Marks) 92. Consider the following routing table at an IP router: Network No.

Net Mask

Next Hop

128.96.170.0

255.255.254.0

Interface 0

128.96.168.0

255.255.254.0

Interface 1

128.96.166.0

255.255.254.0

R2

128.96.164.0

255.255.252.0

R3

0.0.0.0

Default

R4

11/13/2018 11:11:54 AM

Chapter 10  •  Computer Networks

For each IP address in Group I identify the correct choice of the next hop from Group II using the entries from the routing table above. Group I

Group II

(i) 128.96.171.92

(a) Interface 0

(ii) 128.96.167.151

(b) Interface 1

(iii) 128.96.163.151

(c) R2

(iv) 128.96.165.121

(d) R3 (e) R4

(a) (b) (c) (d)

i − a, ii − c, iii − e, iv − d i − a, ii − d, iii − b, iv − e i − b, ii − c, iii − d, iv − e i − b, ii − c, iii − e, iv − d (GATE 2015: 2 Marks)

93. Host A sends a UDP datagram containing 8880 bytes of user data to host B over an Ethernet LAN. Ethernet frames may carry data up to 1500 bytes (i.e., MTU = 1500 bytes). Size of UDP header is 8 bytes and size of IP heard is 20 bytes. There is no option field in IP header. How many total number of IP fragments will be transmitted and what will be the contents of offset field in the last fragment? (a) 6 and 925 (b) 6 and 7400 (c) 7 and 1110 (d) 7 and 8880 (GATE 2015: 2 Marks) 94. Assume that the bandwidth for a TCP connection is 1048560 bits/sec. Let a be the value of RTT in milliseconds (rounded off to the nearest integer) after which the TCP window scale option is needed. Let b be the maximum possible window size the window scale option. Then the values of a and b are (a) 63 milliseconds, 65535 × 214 (b) 63 milliseconds, 65535 × 216 (c) 500 milliseconds, 65535 × 214 (d) 500 milliseconds, 65535 × 216 (GATE 2015: 2 Marks) 95. In the network 200.10.11.144/27, the fourth octet (in decimal) of the last IP address of the network which can . be assigned to a host is (GATE 2015: 2 Marks) 96. Consider a network connecting two systems located 8000 kilometers apart. The bandwidth of the network is 500 × 106 bits per second. The propagation speed of the media is 4 × 106 meters per second. It is needed

Ch wise GATE_CSIT_CH10_Computer Networks.indd 353

353

to design a Go Back − N sliding window protocol for this network. The average packet size is 107 bits. The network is to be used to its full capacity. Assume that processing delays at nodes are negligible. Then, the minimum size in bits of the sequence number field has . to be (GATE 2015: 2 Marks) 97. Two hosts are connected via a packet switch with 107 bits per second links. Each link has a propagation delay of 20 microseconds. The switch begins forwarding a packet 35 microseconds after it receives the same. If 10000 bits of data are to be transmitted between the two hosts using a packet size of 5000 bits, the time elapsed between the transmission of the first bit of data and the reception of . the last bit of the data in microseconds is (GATE 2015: 2 Marks) 98. Which one of the following protocol is NOT used to resolve one form of address to another one? (a) DNS (b) ARP (c) DHCP (d) RARP (GATE 2016: 1 Mark) 99. Anarkali digitally signs a message and sends it to Salim. Verification of the signature by Salim requires (a) Anarkali’s public key. (b) Salim’s public key. (c) Salim’s private key. (d) Anarkali’s private key. (GATE 2016: 1 Mark) 100. In an Ethernet local area network, which one of the following statements is TRUE? (a) A station stops to sense the channel once it starts transmitting a frame. (b) The purpose of the jamming signal is to pad the frames that are smaller than the minimum frame size. (c) A station continues to transmit the packet even after the collision is detected. (d) The exponential backoff mechanism reduces the probability of collision on retransmissions. (GATE 2016: 1 Mark) 101. Which of the following is/are example(s) of stateful application layer protocols? (i) HTTP (ii) FTP (iii) TCP (iv) POP3 (a) (i) and (ii) only (c) (ii) and (iv) only

(b) (ii) and (iii) only (d) (iv) only (GATE 2016: 1 Mark)

11/13/2018 11:11:54 AM

354

GATE CS AND IT Chapter-wise Solved Papers

102. Consider that B wants to send a message m that is digitally signed to A. Let the pair of private and public keys for A and B be denoted by K x− and K x+ for x = A, B, respectively. Let Kx(m) represent the operation of encrypting m with a key Kx and H(m) represent the message digest. Which one of the following indicates the CORRECT way of sending the message m along with the digital signature to A? (a) {m, K B+ ( H ( m))} (b) {m, K B− ( H ( m))} (c) {m, K A− ( H ( m))} (d) {m, K A+ ( m)} (GATE 2016: 2 Marks) 103. An IP datagram of size 1000 bytes arrives at a router. The router has to forward this packet on a link whose MTU (maximum transmission unit) is 100 bytes. Assume that the size of the IP header is 20 bytes. The number of fragments that the IP datagram will be divided into for transmission is _____. (GATE 2016: 2 Marks) 104. For a host machine that uses the token bucket algorithm for congestion control, the token bucket has a capacity of 1 megabyte and the maximum output rate is 20 megabytes per second. Tokens arrive at a rate to sustain output at a rate of 10 megabytes per second. The token bucket is currently full and the machine needs to send 12 megabytes of data. The minimum time required to transmit the data is ____ seconds. (GATE 2016: 2 Marks) 105. A sender uses the Stop-and-Wait ARQ protocol for reliable transmission of frames. Frames are of size 1000 bytes and the transmission rate at the sender is 80 Kbps (1 Kbps = 1000 bits/second). Size of an acknowledgement is 100 bytes and the transmission rate at the receiver is 8 Kbps. The one-way propagation delay is 100 milliseconds. Assuming no frame is lost, the sender throughput is _______ bytes/second. (GATE 2016: 2 Marks) 106. A network has a data transmission bandwidth of 20 × 106 bits per second. It uses CSMA/CD in the MAC layer. The maximum signal propagation time from one node to another node is 40 microseconds. The minimum size of a frame in the network is ______ bytes. (GATE 2016: 2 Marks) 107. For the IEEE 802.11 MAC protocol for wireless communication, which of the following statements is/are TRUE?       I. At least three non-overlapping channels are available for transmissions.

Ch wise GATE_CSIT_CH10_Computer Networks.indd 354

   II. The RTS-CTS mechanism is used for collision detection. III. Unicast frames are ACKed. (a) All I, II, and III (c) II and III only

(b) I and III only (d) II only (GATE 2016: 2 Marks)

108. Consider a 128 × 103 bits/second satellite communication link with one way propagation delay of 150 milliseconds. Selective retransmission (repeat) protocol is used on this link to send data with a frame size of 1 kilobyte. Neglect the transmission time of acknowledgement. The minimum number of bits required for the sequence number field to achieve 100% utilization is ______. (GATE 2016: 2 Marks) 109. Consider a TCP client and a TCP server running on two different machines. After completing data transfer, the TCP client calls close to terminate the connection and a FIN segment is sent to the TCP server. Server-side TCP responds by sending on ACK, which is received by the client-side TCP. As per the TCP connection state diagram (RFC 793), in which state does the client-side TCP connection wait for the FIN from the server-side TCP? (a) LAST-ACK (b) TIME-WAIT (c) FIN-WAIT-1 (d) FIN-WAIT-2 (GATE 2017: 1 Mark) 110. A sender S sends a message m to receiver R, which is digitally signed by S with its private key. In this scenario, one or more of the following security violations can take place. I.  S can launch a birthday attack to replace m with a fraudulent message. II. A third party attacker can launch a birthday attack to replace m with a fraudulent message. III.  R can launch a birthday attack to replace m with a fraudulent message. Which of the following are possible security violations? (a) I and II only (b) I only (c) II only (d) II and III only (GATE 2017: 1 Mark) 111. Consider the following statements about the routing protocols, Routing Information Protocol (RIP) and Open Shortest Path First (OSPF) in an IPv4 network.      I: RIP uses distance vector routing    II: RIP packets are sent using UDP III: OSPF packets are sent using TCP IV: OSPF operation is based on link-state routing

11/13/2018 11:11:55 AM

Chapter 10  •  Computer Networks

Which of the statements above are CORRECT? (a) I and IV only (b) I, II and III only (c) I, II and IV only (d) II, III and IV only (GATE 2017: 1 Mark) 112. Consider socket API on a Linux machine that supports connected UDP sockets. A connected UDP socket is a UDP socket on which connect function has already been called. Which of the following statements is/are CORRECT? I. A connected UDP socket can be used to communicate with multiple peers simultaneously. II. A process can successfully call connect function again for an already connected UDP socket. (a) I only (c) Both I and II

(b) II only (d) Neither I nor II (GATE 2017: 1 Mark)

113. The maximum number of IPv4 router addresses that can be listed in the record route (RR) option field of an IPv4 header is __________. (GATE 2017: 1 Mark) 114. A computer network uses polynomials over GF(2) for error checking with 8 bits as information bits and uses x3 + x + 1 as the generator polynomial to generate the check bits. In this network, the message 01011011 is transmitted as (a) 01011011010 (b) 01011011011 (c) 01011011101 (d) 01011011100 (GATE 2017: 2 Marks) 115. In a RSA cryptosystem, a participant A uses two prime numbers p = 13 and q = 17 to generate her public and private keys. If the public key of A is 35, then the private key of A is __________. (GATE 2017: 2 Marks) 116. The values of parameters for the Stop-and-Wait ARQ protocol are as given below: Bit rate of the transmission channel = 1 Mbps. Propagation delay from sender to receiver = 0.75 ms. Time to process a frame = 0.25 ms. Number of bytes in the information frame = 1980. Number of bytes in the acknowledge frame = 20. Number of overhead bytes in the information frame = 20. Assume that there are no transmission errors. Then, the transmission efficiency (expressed in percentage) of the

Ch wise GATE_CSIT_CH10_Computer Networks.indd 355

355

Stop-and-Wait ARQ protocol for the above parameters is _______ (correct to 2 decimal places). (GATE 2017: 2 Marks) 117. Consider a binary code that consists of only four valid code words as given below: 00000, 01011, 10101, 11110 Let the minimum Hamming distance of the code be p and the maximum number of erroneous bits that can be corrected by the code be q. Then the values of p and q are (a) p = 3 and q = 1 (b) p = 3 and q = 2 (c) p = 4 and q = 1 (d) p = 4 and q = 2 (GATE 2017: 2 Marks) 118. Consider two hosts X and Y, connected by a single direct link of rate 106 bits/sec. The distance between the two hosts is 10,000 km and the propagation speed along the link is 2 × 108 m/sec. Host X sends a file of 50,000 bytes as one large message to host Y continuously. Let the transmission and propagation delays be p milliseconds and q milliseconds, respectively. Then the values of p and q are (a) p = 50 and q = 100 (b) p = 50 and q = 400 (c) p = 100 and q = 50 (d) p = 400 and q = 50 (GATE 2017: 2 Marks) 119. Match the following: Field

Length in bits

P. UDP Header’s Port Number

I. 48

Q. Ethernet MAC Address

II. 8

R. IPv6 Next Header

III. 32

S. TCP Header’s Sequence Number

IV. 16

(a)  (b)  (c)  (d) 

P-III, Q-IV, R-II S-I P-II, Q-I, R-IV, S-III P-IV, Q-I, R-II, S-III P-IV, Q-I, R-III, S-II (GATE 2018: 1 Mark)

120. Consider the following statements regarding the slow start phase of the TCP congestion control algorithm. Note that cwnd stands for the TCP congestion window and MSS denotes the Maximum Segment Size.     (i) The cwnd increases by 2 MSS on every successful acknowledgement.   (ii) The cwnd approximately doubles on every successful acknowledgement. (iii) The cwnd increases by 1 MSS every round trip time. (iv) The cwnd approximately doubles every round trip time.

11/13/2018 11:11:55 AM

356

GATE CS AND IT Chapter-wise Solved Papers

Which one of the following is correct? (a)  Only (ii) and (iii) are true (b)  Only (i) and (ii) are true (c)  Only (iv) is true (d)  Only (i) and (iv) are true (GATE 2018: 1 Mark) 121. Consider a long-lived TCP session with an end-to-end bandwidth of 1 Gbps (= 109 bits-per-second). The session starts with a sequence number of 1234. The minimum time (in seconds, rounded to the closest integer) before this sequence number can be used again is . (GATE 2018: 1 Mark) 122. Consider an IP packet with a length of 4,500 bytes that includes a 20-byte IPv4 header and a 40-byte TCP header. The packet is forwarded to an IPv4 router that supports a Maximum Transmission Unit (MTU) of 600 bytes. Assume that the length of the IP header in all the outgoing fragments of this packet is 20 bytes. Assume that the fragmentation offset value stored in the first fragment is 0. The fragmentation offset value stored in the third fragment is . (GATE 2018: 2 Marks)

123. Consider a simple communication system where multiple nodes are connected by a shared broadcast medium (like Ethernet or wireless). The nodes in the system use the following carrier-sense based medium access protocol. A node that receives a packet to transmit will carrier-sense the medium for 5 units of time. If the node does not detect any other transmission in this duration, it starts transmitting its packet in the next time unit. If the node detects another transmission, it waits until this other transmission finishes, and then begins to carrier-sense for 5 time units again. Once they start to transmit, nodes do not perform any collision detection and continue transmission even if a collision occurs. All transmissions last for 20 units of time. Assume that the transmission signal travels at the speed of 10 meters per unit time in the medium. Assume that the system has two nodes P and Q, located at a distance d meters from each other. P starts transmitting a packet at time t = 0 after successfully completing its carrier-sense phase. Node Q has a packet to transmit at time t = 0 and begins to carrier-sense the medium. The maximum distance d (in meters, rounded to the closest integer) that allows Q to successfully avoid a collision between its proposed transmission and P’s ongoing transmission is . (GATE 2018: 2 Marks)

Answer Key 1. (a)

2. (d)

 3. (d)

 4. (d)

 5. (d)

 6. (c)

 7. (b)

 8. (a)

 9. (b)

10. (b)

11. (b)

12. (a)

13. (d)

14. (b)

15. (b)

16. (d)

17. (b)

18. (b)

19. (d)

20. (d)

21. (d)

22. (b)

23. (b)

24. (c)

25. (c)

26. (a)

27. (a)

28. (b)

29. (c)

30. (a)

31. (c)

32. (c)

33. (b)

34. (c)

35. (b)

36. (a)

37. (d)

38. (d)

39. (c)

40. (b)

41. (c)

42. (b)

43. (b)

44. (c)

45. (d)

46. (b)

47. (d)

48. (d)

49. (d)

50. (c)

51. (b)

52. (a)

53. (c)

54. (a)

55. (c)

56. (c)

57. (c)

58. (c)

59. (a)

60. (c)

61. (a)

62. (c)

63. (d)

64. (c)

65. (b)

66. (c)

67. (d)

68. (c)

69. (a)

70. (a)

71. (c)

72. (26)

73. (b)

74. (b)

75. (d)

76. (30)

77. (1100)

78. (5)

79. (d)

80. (c)

81. (1)

82. (256)

83. (a)

84. (b)

85. (b)

86. (a)

87. (12)

88. (a)

89. (d)

90. (160)

93. (c)

94. (c)

95. (158)

96. (8)

97. (1575)

98. (c)

99. (a) 100. (d)

91. (0.4404) 92. (a) 101. (c)

102. (b)

103. (13) 104. (1.1) 105. (2500) 106. (200)

111. (c)

112. (b)

113. (9)

114. (c)

115. (11)

107. (b)

108. (4) 109. (d) 110. (b)

116. (89.33) 117. (a)

118. (d) 119. (c) 120. (c)

121. (34.35) 122. (144) 123. (50)

Answers with Explanation 1. Topic: Routing Algorithms (Distance Vector, Link State) (a)  In serial data transmission, every byte of data is padded with a ‘0’ in the beginning and one or two ‘1’s at the end of byte because receiver is to be synchronized for byte reception.

Ch wise GATE_CSIT_CH10_Computer Networks.indd 356

2. Topic: Network Security: Basics of Public Key Cryptography (d)  Dynamic linkage means linking done during load on run time. Dynamic linking does not require the code to be copied, it is done just placing the name of library in

11/13/2018 11:11:56 AM

Chapter 10  •  Computer Networks

the binary file. The actual linking happens when the program is run, when both the binary file and library are in memory. Dynamic linking can cause security concerns because the path for searching dynamic libraries is not known till runtime. 3. Topic: IPv4/IPv6 (d)  The packet source can set the route of an outgoing packet; the route is determined only by the routing tables in the routers on the way. 4. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (d) End-to-end connectivity is the responsibility of a transport layer. 5. Topic: IPv4/IPv6 (d)  The two addresses should belong to the same network, if binary AND operation of both addresses with net mask should be same. The last octet of IP address of 0 is 000 0000. The last octets of IP addresses of 43 and 55 and their AND with net mask gives the same result. 6. Topic: LAN Technologies (Ethernet) (c)  Given that length L = 2 km = 2000 m Bandwidth, B = 107 bps Signal travels S = 2 × 108 m/s 3 So, propagation delay (Tp ) = L = 2 × 10 = 1 s 8 S 2 × 10 105 In CSMA/CD network, Round-trip delay = 2 × Tp = 2 × 105 s The minimum packet size must take round-trip delay to transmit. So, transmission delay (Tx) = Round-trip delay Since Tx = N/B, where N is the number of bits to be transmitted. Number of bits transmitted, N = Round-trip delay × B = 2 × 105× 107 = 200 bytes

7. Topic: Routers (b)  Throughput = 1 window/RTT Round-trip time (RTT) = Transmission time + 2 × Propagation time = 50 ms + 2 × 200 ms = 450 ms As the size of window is 5 packets and 1 packet contains 1000 bytes. The total size of the packet in bytes is 5 × 1000 = 50000 bytes 5000 bytes Therefore, throughput = = 11.11 × 106 bps 450 × 10 −6 s

Ch wise GATE_CSIT_CH10_Computer Networks.indd 357

357

8. Topic: Concept of Layering (a) Data link layer provides reliable transmission of data over a physical link. Network layer provides routing of data packets in the network. Transport layer is responsible for end-to-end ­process communication. 9. Topic: Routing Algorithms (Distance Vector, Link State) (b) Both router and bridge selectively forward data packets and both can connect between a LAN and WAN. Routing and bridge builds their routing table by inspecting incoming packets but router and bridge both use MAC address. So, option (b) is correct. 10. Topic: LAN Technologies (Ethernet) 9600 (b)  1 + 8 + 2 + 1 = 800 11. Topic: Flow and Error Control Techniques (b) At the first collision, both A and B will have first collision but A wins. So, A’s collision counter will be reinitialized to 0. At the second collision, A and B will have first and second collisions, respectively. So, A will have to select random number from [0,1]. But, B will have to select from [0, 1, 2, 3]. On mapping, the following are total favouring cases to A’s winning. 0–1  0–2  0–3  1–2  1–3 So, the probability is 5/8 = 0.625. 12. Topic: Routing Algorithms (Distance Vector, Link State) (a)  On performing AND operation between incoming IP address and subnet-mask and comparing the result with the destination. If there is a match between multiple destinations, then select the destination with the longest length subnet mask. 128.75.43.16 matches with 128.75.43.0 and 128.75.43.0. But the packets addressed to 128.75.43.16 will be forwarded to Eth1. If a result is not matching with any of the given destinations, then the packet is forwarded to the default interface (here Eth2). Therefore, the packets addressed to 192.12.17.10 will be forwarded to Eth2. 13. Topic: IPv4/IPv6 (d)  When all the 3 packets are delivered, the bytes are (80 + 20) + (80 + 20) + (40 + 20) = 260

11/13/2018 11:11:56 AM

358

GATE CS AND IT Chapter-wise Solved Papers

14. Topic: Flow and Error Control Techniques (b)  Actual data sent =180 out of 260 So, data rate (180/260) × 512 Kbps = 354.461 Kbps 15. Topic: TCP/UDP (b)  Packets travel on network layer. TCP and UDP are transport layer protocols. 16. Topic: Flow and Error Control Techniques (d)  ARP works to find the physical address of a machine. 17. Topic: Flow and Error Control Techniques (b)  For selective reject protocol, window size = 2n/2 = 2n−1 18. Topic: Routing Algorithms (Distance Vector, Link State) (b)  Spanning tree protocol is used for bridge routing to avoid loops in routing paths. 19. Topic: Routing Algorithms (Distance Vector, Link State) (d)  For class B, 16 bits are reserved as network bits. To allocate 64 subnets, 6 bits are added to network bits. 22 bits are for network. Subnet mask is created by assigning 1 to all network bits. So, mask is 255.255.252.0. 20. Topic: Flow and Error Control Techniques (d)  Optimal packet size is 9. 9 − 3 = 6 B will be transferred in one packet, so the total message will travel in 4 packets. 21. Topic: Flow and Error Control Techniques (d)  RTT = 46.4 × 10−6s 10 Mb are sent in = 1 s 1 will be sent = 1/107 48 bits will be in = 4.8 × 10−6 s Total delay = 46.4 + 4.8 = 51.2 Minimum frame size = 51.2 × 10 = 512 bits

24. Topic: IPv4/IPv6 (c) Network address of C1: 203.197.2.53 AND 255.255.128.0 = 203.197.0.0 Network address of C2: 203.197.75.201 AND 255.255.192.0 = 203.197.0.0 C1 assumes C2 is on the same network, but C2 assumes C1 on different network. 25. Topic: Flow and Error Control Techniques (c) A   B 1   → 1 2   → 2 3   → 3 4   → 4 5   → lost 6   → discard 7   → discard 8   → 5 9   → 6 10   → lost 7 11   → discard 8 12   → discard 9 13   → 7 14   → 8 15   → lost 9 16   → 9 26. Topic: Flow and Error Control Techniques (a)  DFS (depth first search) is an algorithm for traversing tree or graph. One starts at the root (selecting some arbitrary node as the root in the case of a graph) and explores as far as possible along each branch before backtracking. So depth first search traversal is B1, B5, B3, B4, B2. 27. Topic: Flow and Error Control Techniques (a)  Forwarding table for B3 is

22. Topic: IPv4/IPv6 (b)  Decrementing TTL will prevent packet from looping.

Hosts H1, H2, H3, H4

3

23. Topic: Flow and Error Control Techniques (b)  Round-trip delay = 80 ms Bandwidth = 128 Kbps In 1 s = 128 Kbits are sent In 80 ms = 128K × 80 × 10−3 = 128 × 80 bits 128 × 80 Window size = = 40 32 × 8

H5, H6, H9, H10

1

H7, H8, H11, H12

2

Ch wise GATE_CSIT_CH10_Computer Networks.indd 358

Port

28. Topic: LAN Technologies (Ethernet) (b)  For transmission of digital information, Manchester coding is used to convert digital information into electrical signals for transmission. It uses two baud for one bit.

11/13/2018 11:11:56 AM

Chapter 10  •  Computer Networks

359

29. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (c)  DNS uses services of UDP protocol.

37. Topic: TCP/UDP (d)  Connect() is called by the client and connection is established using three-way hand shake.

30. Topic: Flow and Error Control Techniques (a)  Probability of sending by one station = p(1 − p)n−1 For n stations, it is np(1 − p)n−1

38. Topic: Congestion Control (d)  In the slow start phase of the TCP congestion control algorithm, the size of the congestion window increases exponentially.

31. Topic: Flow and Error Control Techniques (c)  Transmission delay for 1 bit t = 1/(107) = 0.1 ms. 200 m can be travelled in 1 ms. Therefore, in 0.1 ms, 20 m can be travelled. 32. Topic: IPv4/IPv6 (c)  Here, 16 + 6 = 22 bits are reserved for the network Number of hosts = 232−22 = 210 − 2 = 1022 Number of subnets = 26 − 2 = 62 33. Topic: Flow and Error Control Techniques (b)  The polynomial is equivalent to 1001. Di­vide 1001 with 11001001000 and find the remainder. Remainder is 011. Append 011 at the end of input string, it will be 11001001011. 34. Topic: Congestion Control (c)  Distance between stations M and N = L km Propagation delay = t s Total propagation delay = Lt s Frame size = K bits Channel capacity = R bits/s Transmission time = K/R Let n be the window size. Propagation time n Utilization = , where a = Transmission 1 + 2a nK n = = 1 + ( 2 LtR /K ) 2 LtR + K For maximum utilization: nK = 2LtR + K 2 LtR + K K Number of bits needed for n frames is log n. Therefore,    n =

35. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (b)  SMTP: Application layer for mail transfer BGP: Network layer routing protocol TCP: Transport layer transmission protocol PPP: Data link layer protocol for direct connections 36. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (a)  There is no limit of data passing at application layer.

Ch wise GATE_CSIT_CH10_Computer Networks.indd 359

39. Topic: IPv4/IPv6 (c)  Number of network bits = 21 Number of host bits = 11 Number of hosts = 211 − 2 = 2046 40. Topic: Flow and Error Control Techniques (b)  Data transfer of token bucket = 10 Mbps Rate of transfer = 2 Mbps Initially filled capacity = 16 Mbits b 16 Maximum burst time = = =2s M − r 10 − 2 41. Topic: TCP/UDP (c)  The accept() call does not execute. So, connect() call did not get response for a time stamp to wait, therefore, connect() system call returns an error. 42. Topic: Network Security: Basics of Private Key Cryptography (b) Encryption: M′ = Me mod n Decryption: M = (M′)d mod n ed ≡ 1 mod f(n) 43. Topic: TCP/UDP (b)  The frames from the sending station are numbered sequentially. 44. Topic: Flow and Error Control Techniques (c)  To detect odd number of errors, (x + 1) must be present. 45. Topic: Flow and Error Control Techniques (d)  Transmission delay of link = 1000/106 = 1 ms Propagation delay = 25 ms Maximum 25 frames can be sent, for 25 frames bits required are 5. 46. Topic: Flow and Error Control Techniques (b)  Size of window = 32 Round trip time = 2 × 25 ms = 50 ms To send the next frame, the sender has to wait for 50 − 32 = 18 ms 47. Topic: IPv4/IPv6 (d) Value of TTL is decremented to prevent packet looping.

11/13/2018 11:11:57 AM

360

GATE CS AND IT Chapter-wise Solved Papers

48. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (d)  Ping is a command not an application. It is to check connectivity and there is no need to communicate with server. 49. Topic: IPv4/IPv6 (d) To belong to a different network, A and B should have different network address. Perform logical AND operation on all the options. For example, option (d) IP address of A: 10.105.1. 01110001 Network mask: 255.255.255. 11100000 Network address of A: 10.105.1. 01100000 IP address of B: 10.105.1. 01011011 Network mask: 255.255.255. 11100000 Network address of A: 10.105.1. 01000000 Both have different network addresses. 50. Topic: Routing Algorithms (Distance Vector, Link State) (c)  We can check all the shortest distances one by one. When we check for all shortest distances for Ri we don’t need to check its distances to R0 to Ri−1 because the network graph is undirected. Following will be distance vectors of all nodes. Shortest distances from R1 to R2, R3, R4, R5 and R6 R1 (5, 3, 12, 12, 16) Links used: R1–R3, R3–R2, R2–R4, R3–R5, R5–R6 Shortest distances from R2 to R3, R4, R5 and R6 R2 (2, 7, 8, 12) Links used: R2–R3, R2–R4, R4–R5, R5–R6 Shortest distances from R3 to R4, R5 and R6 R3 (9, 9, 13) Links used: R3–R2, R2–R4, R3–R5, R5–R6 Shortest distances from R4 to R5 and R6 R4 (1, 5) Links used: R4–R5, R5–R6 Shortest distances from R5 to R6 R5 (4) Links used: R5–R6 If we mark all the used links one by one, we can see that following links are never used. R1–R2 R4–R6 51. Topic: Routing Algorithms (Distance Vector, Link State) (b)  After the weights of unused links() are changed to following graph.

Ch wise GATE_CSIT_CH10_Computer Networks.indd 360

R2

7

R4

2

2 2

R1

1

3

R6 3

R3

9

R5

Following will be distance vectors of all nodes R1 (2, 3, 9, 10, 11) Links used: R1–R2, R1–R3, R2–R4, R4–R5, R4–R6 R2 (2, 7, 8, 9) Links used: R2–R3, R2–R4, R4–R5, R4–R6 R3 (9, 9, 11) Links used: R3–R2, R2–R4, R3–R5, R4–R6 R4 (1, 2) Links used: R4–R5, R4–R6 R5 (3) Links used: R5–R4, R4–R6 If we mark all the used links one by one, we can see that following links are never used. R5–R6 52. Topic: Network Security: Firewalls (a)  As Layer-4 firewall cannot block traffic of Layer-5 (application layer) and HTTP is an application layer protocol. So, option (a) is correct. 53. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (c)  m1: SMTP is responsible for mail transfer. m2: POP is responsible for downloading mail from mailbox server to mal client. m3: HTTP is responsible for viewing application on web browser. 54. Topic: Routing Algorithms (Distance Vector, Link State) (a)  N3: (3, 2, 0, 2, 5) 55. Topic: Routing Algorithms (Distance Vector, Link State) (c)  N3 to N1 either by N2 or by N4 N2–N1 is ∞, so N3 will choose to go via N4 to N1 (2 + 8). 56. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (c) Electronic mail does not require TCP connection between sender and receiver of email.

11/13/2018 11:11:57 AM

Chapter 10  •  Computer Networks

57. Topic: TCP/UDP (c) The protocol data unit (PDU) for Data link layer = Frame; Network layer = Datagram; Transport layer = Segment; Application layer = Message. 58. Topic: IPv4/IPv6 (c) Network bits

Host bits

24 bits

8 bits

R

100.00000000

Address allocated is 245.248.136.0/21 Allocation of addresses to B: 10 bits are required for organisation B. 00.00000000

62. Topic: TCP/UDP (c) Real-time multimedia: UDP (session less protocol, used where fast data transfer is required) File transfer: TCP DNS: UDP E-mail: TCP

D

Transmission delay for 1 packet from each of S, R1 and R2 will take 1ms. Propagation delay on L1, L2 and L3 for one packet is 1 ms. Transmission delay + Propagation delay = 2 ms First packet will reach at 6th ms Second packet will reach at 7th ms 1000 packets will reach at 1005th ms 60. Topic: Congestion Control (c)  In slow start, with each iteration, size of congestion window doubles. So, T = 1 ws = 2 T = 2 ws = 4 T = 3 ws = 8 Threshold is 8. So, now window size will increase by one using additive increase method. T = 4 ws = 9 T = 5 ws = 10, here timeout occurs. Hence, threshold = 10/2 = 5, ws is reset T = 6 ws = 2 T = 7 ws = 4 T = 8 ws = 5 [threshold was 5, so apply additive increase] T = 9 ws = 6 T = 10 ws = 7 61. Topic: IPv4/IPv6 (a)  Total numbers of addresses available are 4096. Organisation A : 2048 Organisation B : 1024 Remaining     : 1024

Ch wise GATE_CSIT_CH10_Computer Networks.indd 361

245.248. 10000

Address allocated is 245.248.128.0/22.

59. Topic: Flow and Error Control Techniques (a)

R

Allocation of addresses to A: 11 bits are required for organisation A.

245.248. 100000

Starting with 3 bits (110) reserved to recognise the class. So, the number of networks are 221.

S

361

63. Topic: Network Security: Basics of Private Key Cryptography (d)  X uses private key to add digital signature, then uses Y ’s public key to encrypt. On the other end, Y first uses its private key followed by X ’s public key. 64. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (c)  Transmission from S to D will follow these steps: At S: Network layer → Data link layer At R1: Data link layer → Network layer → Data link layer At R2: Data link layer → Network layer → Data link layer At D: Data link layer → Network layer Therefore, the packet has to visit 6 times data link layer and 4 times network layer. 65. Topic: LAN Technologies (Ethernet) (b)  Data rate: 500 Mbps = 5 × 108 bps Frame size: 10000 bits Speed: 200000 km/s 5 × 108 bits can travel = 1s 104 bits will travel =

10 4 1 = 8 5 × 10 5 × 10 4

In 1 s, distance travelled = 2 × 105 km 2 × 105 = 4 km 5 × 10 4 Hence, the maximum distance is 4/2 = 2 km In (1/5  × 104) s, distance travelled is =

66. Topic: IPv4/IPv6 (c)  M = 0 indicates no more fragment means last fragment Actual header length is 4 × 10 = 40

11/13/2018 11:11:58 AM

362

GATE CS AND IT Chapter-wise Solved Papers

Total length = 400 bytes (40-byte header + 360-byte payload) Fragment offset = 300 × 8 = 2400 bytes (measured in terms of 8 bytes) First byte sequence number of last fragment is 2400. Sequence number of last byte payload is 2400 + 360 − 1 = 2759. 67. Topic: Routing Algorithms (Distance Vector, Link State) (d) A distance vector protocol (with split horizon) avoids persistent routing loops, but not a link state protocol. So, S2 is false. 68. Topic: Network Security: Authentication (c)  Only SHA-1 and MD5 are used as message digest. 69. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (a) First of all, browser resolves IP address using DNS server, then connects to web server using TCP connection. After connection establishment, browser ­ request for the page and web server responds with the page. So, option (a) is correct. 70. Topic: Routing Algorithms (Distance Vector, Link State) (a) Distance vector routing technique is used by RIP and OSPF uses link state routing. 71. Topic: Sockets (c)  Listen function converts an unconnected active TCP socket into a passive socket. 72. Topic: LAN Technologies (Ethernet) (26)  Initially, TTL = 32. Number of routers = 5 and Last is receiver. So, TTL value will be 32 − 6 = 26 at R. 73. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (b)  The task of data link layer is to create frames. Bit synchronization is handled by physical layer. 74. Topic: Flow and Error Control Techniques (b) 01111110 is the delimiter pattern given. In output string 011111100101, 0 is stuffed. Input string is 01111110101. 75. Topic: TCP/UDP (d) TTL, checksum and fragment offset changes at every node. 76. Topic: Flow and Error Control Techniques (30)  Length = 2 km, stations = 10, signal speed = 2 × 108 m/s and token hold time = 2 ms

Ch wise GATE_CSIT_CH10_Computer Networks.indd 362

RTT =

Length 2000 m = = 10 μs Speed 2 × 108 m/s

Minimum wait time = RTT + Stations × Hold time Minimum wait time = 10 + 10 × 2 = 30 ms 77. Topic: Congestion Control (1100)  Given that RTT = 100 ms, congestion window size = 32 KB Time out =

Congestion window 32 = = 16 KB 2 2

and MSS = 2 KB. Now, 2 KB → 1 RTT (Slow Start) 4 KB → 2 RTT 8 KB → 3 RTT 16 KB → 4 RTT (Threshold) After threshold point is reached, there begins an additive increase phase. 18 KB → 5 RTT 20 KB → 6 RTT 22 KB → 7 RTT

 ˙  ˙ 30 KB → 11 RTT 32 KB Therefore, total time = 11 RTTs = 11 × 10 = 1100 ms 78. Topic: Flow and Error Control Techniques (5)  Given frame size = 1 KB, link capacity = 1.5 Mbps, one-way latency = 50 m RTT = 2 × 50 = 100 ms and link utilization = 60% Transmission time (T) = 1000 × 8 = 5.33 ms 1.5 × 106 Let window size = n then link utilization = Therefore, n =

n×T (T + RTT)

0.6(5.33 + 100) = 12 5.33

Window size in selective repeat = 2n−1 = 12; so, n − 1 = 4 ⇒ n = 5 79. Topic: Congestion Control (d) Given that bandwidth = 106 bytes/sec, file size = 1000 bytes, header size = 100 bytes Case 1: A sends complete file to B Total frame size = 1000 + 100 = 1100 bytes Transmission time = 1100/106 = 1100 ms T1 = 3300 ms

11/13/2018 11:11:58 AM

Chapter 10  •  Computer Networks

Case 2: File size in chunks of 100 bytes Total frame size = 100 + 100 = 200 bytes Transmission time for 1 packet = 200/106 = 200 ms Transmission time for 10 packets = 2000 ms T 2 = 2000 + 200 + 200 = 2400 ms Case 3: File size in chunks of 50 bytes Total frame size = 50 + 100 = 150 bytes Transmission time for 1 packet = 150/106 = 150 ms Transmission time for 20 packets = 3000 ms T 3 = 3000 + 150 + 150 = 3300 ms T1 = T 3 and T 3 > T 2 80. Topic: Routers (c) Intruder can gain only I2 and I3 information. Because sniffing at R2 will able to capture only the TCP port numbers which are encapsulated in IP datagram and IP addresses of Q and H. 81. Topic: Routing Algorithms (Distance Vector, Link State) (1)  Calculating the network address: First entry: IP: 131. 00010111.151.76 Mask: 131. 00010000. 0.0 [12 n/w bits] n/w address: 131.16.0.0 [Matched] Second Entry: IP: 131. 00010111.151.76 Mask: 131. 00011100. 0.0 [14 n/w bits] n/w address: 131.20.0.0 [Not Matched] Third Entry: IP: 131. 00010111.151.76 Mask: 131. 00010011. 0.0 [16 n/w bits] n/w address: 131.19.0.0 [Not Matched] Fourth Entry: IP: 131. 00010111.151.76 Mask: 131. 00010110. 0.0 [15 n/w bits] n/w address: 131.20.0.0 [Matched] According to longest mask, packet will be forwarded to interface 1. 82. Topic: IPv4/IPv6 (256)  50 bit unique id = 32 bit ip + 18 bit extra With 18 bits = 218 ids can be generated. 1000 ids take = 1 s 218 id will take = 218/1000 = 256 s. 83. Topic: Routers (a)  First fragment: 1480 + 20 MF = 1 Second fragment: 1480 + 20 MF = 1 Third fragment: 1444 + 20 MF = 0

Ch wise GATE_CSIT_CH10_Computer Networks.indd 363

363

84. Topic: TCP/UDP (b)  It is not necessary to have the subsequent sequence number as m + 1. So, statement I is false. Size of window is not constant during TCP connection. It changes once the threshold value of congestion window reaches. So, statement III is false. 85. Topic: Routers (b)  Source address is the only thing that remains fixed and cannot be varied. 86. Topic: TCP/UDP (a)  HTTP can use multiple TCP connections for each resource. FTP uses Telnet protocol for control information on a TCP connection and another TCP connection for data exchange. 87. Topic: Flow and Error Control Techniques (12) 1 1 In stop and wait, efficiency = = (1 + 2a) 4 ⇒ a = 3/2 Transmission time, Tt = 1000 × 8 = 8 ms 106 Propagation time, Tp = a × Tt = 3 ×

8 = 12 ms 2

88. Topic: TCP/UDP (a)   I.  True, TCP connection is full duplex connection because sender and receiver can exchange data in the same connection.    II.  False, there is no selective acknowledgement in TCP, concept of cumulative acknowledgement is used. III.  False, Data is sent in byte streams. 89. Topic: Flow and Error Control Techniques (d)  Frame size = 1250 bytes, Bandwidth = 100 Mbps, Distance = 1 km, Signal Speed = ? In CSMA/CD, L=

2dB ⇒ V = 2 dB/L = 20, 000 km/ s V

90. Topic: Routing Algorithms (Distance Vector, Link State) (160)  Minimum frame size means 100% utilization. RTT = 20 × 2 = 40 ms Bit rate = 64 Kbps 64 × 103 bytes ⇒ 1 s 40 ms ⇒ 64 × 103 × 40 × 10−3 = 2560 bits

11/13/2018 11:11:59 AM

364

GATE CS AND IT Chapter-wise Solved Papers

2560 = 320 bytes 8 hence, to achieve 50% utilization, bytes = 160 Bytes ⇒

91. Topic: LAN Technologies (Ethernet) (0.4404) P = P(S1) P(~S2) P(~S3) P(~S4) + P(~S1) P(S2) P(~S3) P(~S4) + P(~S1) P(~S2) P(S3) P(~S4) + P(~S1) P(~S2) P(~S3) P(S4)   = 0.1 × 0.8 × 0.7 × 0.6 + 0.9 × 0.2 × 0.7 × 0.6 + 0.9 × 0.8 × 0.3 × 0.6 + 0.9 × 0.8 × 0.7 × 0.4   = 0.4404 92. Topic: Routing Algorithms (Distance Vector, Link State) (a) (i) IP Address: Subnet Mask:

128.96.171.92 255.255.254.0

Network Address: 128.96.170.0 This matches with Interface 0. (ii) IP Address: Subnet Mask:

128.96.167.151 255.255.254.0

Network Address: 128.96.166.0 This matches with R2. (iii) IP Address: Subnet Mask:

128.96.163.151 255.255.252.0

Network Address: 128.96.170.0 This matches with R4. (iv) IP Address: Subnet Mask:

128.96.165.121 255.255.254.0

Network Address: 128.96.164.0 This matches with R3. So, option (a) is correct. 93. Topic: TCP/UDP (c)  Datagram size = 1500 bytes Data in one datagram = 1500 − 20 − 8 = 1472 bytes Total data to send = 8880 bytes

Ch wise GATE_CSIT_CH10_Computer Networks.indd 364

Number of datagrams = and offset =

8880 =7 1472

8872 = 1109 + 1 = 1110 8

94. Topic: TCP/UDP (c) Since sequence number in TCP header is limited to 16 bits, the maximum window size is limited. When bandwidth delay product of a link is high, scaling is required to efficiently use link. TCP allows scaling of windows when bandwidth delay product is greater than 65,535. The bandwidth delay product for given link is 1048560 × α. Window scaling is needed when this value is more than 65535 bytes, i.e., when α is greater than 65535 × 8 or 0.5 seconds = 500 milliseconds. 1048560 Scaling is done by specifying a one byte shift count in the header options field. The true receive window size is left shifted by the value in shift count. A maximum value of 14 may be used for the shift count value. Therefore maximum window size with scaling option is 65535 × 214. 95. Topic: IPv4/IPv6 (158)  IP address: 200.20.11.144 ⇒ 200.20.11.10010000 Subnet mask address: 225.225.225.11100000 Looking at the subnet address, we get to know that 1st three bits gives the subnet number and remaining are for host. Thus,    100 10000 Last host bits will be: 100 11110 ⇒ 158 96. Topic: Flow and Error Control Techniques (8)  Distance = 8000 km = 8 × 106 m Speed = 4 × 106 m/s Transmission time = Distance/Speed = 2 s Bandwidth = 500 × 106 bps Packet size = 107 bits 500 × 106 bits ⇒1 s 107 bits ⇒ 107 / 500 × 106 = 1/50 s Propagation time = 1/50 s ⇒ RTT = 2/50 = 1/25 s Full capacity network utilization is done. Therefore, efficiency is 100%. w η= = 1 ⇒ w = 1 + 2a (1 + 2a) 2 = 100 0.02 2n = 1 + 200 = 201 ⇒ n = 8 a=

11/13/2018 11:11:59 AM

365

Chapter 10  •  Computer Networks

97. Topic: Flow and Error Control Techniques (1575)  Transmission time of 5000 bits = 500 microseconds Total transmission time of first bit = 500 + 20 + 35 + 20 = 575 microseconds Total transmission time of last bit = 500 + 500 = 1000 microseconds Total time = 1000 + 575 = 1575 microseconds 98. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (c) DHCP does not resolve one form of addition to another. It is a dynamic host configuration protocol and it allocates one of the unused Internet Protocol (IP) addresses. 99. Topic: Network Security: Basics of Private Key Cryptography (a) • Digital sign − Anarkali private key • Verification − Anarkali public key 100. Topic: LAN Technologies (Ethernet) (d) The concept of binary exponential backoff algorithm is used. The exponential backoff mechanism reduces the probability of collision on retransmissions.

Therefore, S=

In 0.1s, the data transmit is given by 0.1 × Output rate = 0.1 × 20 MB per sec = 2 MB The remaining data is (12 MB – 2 MB) = 10 MB Thus, to transmit 1 MB, it takes 0.1s and then for ­transmitting 10 MB, we get 10 × 0.1s = 1s Therefore, the total time is (0.1 + 1)s = 1.1s 105. Topic: Flow and Error Control Techniques (2500)  The transmission rate Tt at the sender is L 1000 B = = 100 ms B 80 Kbps We know that 1 bit = 1/8 B. Therefore, Tt at receiver is L 1000 B = = 100 ms B 80 Kbps Therefore, 2 × Tp = 200 ms

101. Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (c)  Stateful application layer Protocols are FTP and POP3. 102. Topic: Network Security: Basics of Private Key Cryptography (b) Here, B wants to send message m to A. Private keys are denoted by K(x) and public keys are denoted by K+(x). In digital signature, the private key of sender is used to encrypt the message and its public key is used to decrypt. Thus, {m, K—(B)(H(m))} must be the correct way of sending the message. 103. Topic: TCP/UDP (13)  MTU is 100 bytes, IP header is 20 bytes, IP datagram is 1000 bytes. Therefore, the number of fragments are 13. 104. Topic: Congestion Control (1.1)  The time taken to transmit 1 MB when output rate is 20 MB per sec, the capacity is 1 MB and the token arrival rate is 10 MB per sec is C + ρS = MS Now, 1 MB + (10 MB per sec) × S ⇒ (20 MB per sec) × S

Ch wise GATE_CSIT_CH10_Computer Networks.indd 365

1 MB = 0.1s ( 20 − 10) MB per sec

100 ms

100 ms Now, Tt for acknowledgement at receiver is L 100 Bytes = = 100 ms B 1 kbps Tts 1 100 = η= = Tt R + Tt ack + 2 × TP 100 + 100 + 200 4

Tt ack =

Therefore, throughput S is S = η × BS ⎛1 ⎞ = ⎜ × 80⎟ Kbps ⎝4 ⎠ = 20 kbps ⎛ 20 ⎞ = ⎜ ⎟ Kbps ⎝ 8⎠ ⎛ 20 ⎞ = ⎜ × 1000⎟ bps ⎝ 8 ⎠ = 2500 bps

11/13/2018 11:12:00 AM

366

GATE CS AND IT Chapter-wise Solved Papers

106. Topic: Flow and Error Control Techniques (200)  For CSMA/CD T.T. = 2 * P.T. x byte = 2 * P.T. Bandwidth x = 20 × 106 × 2 * 40 × 10 −6 = 1600 bits =

1600 bytes 8

Therefore, x = 200 bytes. 107. Topic: Basics of Wi-Fi (b) RTS and CTS mechanism is used for collision avoidance, but not for collision detection. 108. Topic: Routing Algorithms (Distance Vector, Link State) (4)  It is given that B = 128 × 103 bits/seconds; Tp = 150 ms; L = 1 KB where Tp is propagation delay and L is the frame size of the data to be sent. Now, the transmission delay is given by Tt =

L 8 × 103 = = 62.5 ms B 128 × 103

To achieve 100% efficiency, we have

As per the TCP connection state diagram shown above, FIN-WAIT-2 is the state where the client-side TCP connection wait for the FIN from the server-side TCP. 110. Topic: Network Security: Digital Signatures (b) I. Sender S can launch a birthday attack to replace message m with a fraudulent message, because he has the signature and he can decrypt the signature by his own public key and get the hash value. True. II. A third party attacker can launch a birthday attack to replace m with a fraudulent message. False. III. R can launch birthday attack to replace m with a fraudulent message. False. 111. Topic: IPv4/IPv6 (c) I.  True. RIP uses distance vector routing. II.  True. RIP uses UDP as its transport protocol. III. False. OSPF does not use UDP or TCP as its transport protocol. IV.  True. OSPF uses link-state routing.

η = 100% ⇒ 1 =

112. Topic: Sockets (b)  A connected UDP socket can call connect function again if it wants to unconnect the socket and to specify a new port.

⇒ w = 1 + 2a

113. Topic: IPv4/IPv6 (9)  Maximum nine IPv4 router addresses can be listed in the record route option.

w 1 + 2a Tp 150 ms ⇒a= = = 2.4 Tt 62.5 ms 2n = 1 + 2( 2.4) = 5.8 2 ⇒ 2n = 2 × 5.8 = 11.6 ≈ 12 ≈ 24 ⇒n=4 ⇒

That is, the required of distinct sequence numbers is 12 (or 24) and hence the number of bits required to represent 12 distinct numbers is 4. 109. Topic: TCP/UDP (d) Client

Syn

Server

K

-AC

Syn

Connection Established FIN-WAIT-1

FIN

Close-Wait ACK

FIN-WAIT-2

Ch wise GATE_CSIT_CH10_Computer Networks.indd 366

114. Topic: Flow and Error Control Techniques (c)  Polynomial generator = x3 + x + 1    = 1011 Message = 01011011 1011 01011011000 0000 1011 1011 0000 0000 0001 0000 0011 0000 0110 0000 1100 1011 1110 1011 101

01000011

Therefore, the message is transmitted as 01011011101.

11/13/2018 11:12:01 AM

Chapter 10  •  Computer Networks

115. Topic: Network Security: Basics of Private Key Cryptography (11) Given, p = 13 and q = 17. In RSA cryptosystem, η = p×q   = 13 × 17 = 221 Now, f ( n) = ( p − 1)( q − 1) = 12 × 16 = 192 Also,   (d × e) mod f ( n) = 1 ⇒ ( d × 35) mod 192 = 1 ⇒ d = 11 116. Topic: Flow and Error Control Techniques (89.33) Given, Bandwidth = 1 Mbps = 106 bits/s Now, Data size = Number of bytes in the information frame + Number of bytes in the acknowledge frame = (1980 + 20) bytes = 2000 bytes Data size Transmission time = Bandwidth =

2000 bytes 106 bits/s

=

2000 × 8 bits 106 bits/s

= 16 ms Time to process a frame = 0.25 ms Transmission time (acknowledge) = Transmission efficiency =

20 × 8 = 0.16 ms 106

16 0.25 + 16 + 1.5 + 0.16

16     = × 100% = 89.33% 17.91 117. Topic: Routing Algorithms (Distance Vector, Link State) (a)  Minimum hamming distance between given every 2 pair of code words = p = 3. Equation to correct errors is 2q + 1 = p ⇒ 2q + 1 = 3 ⇒q=1 118. Topic: Flow and Error Control Techniques (d) Given: Bandwidth = 106 bps

Ch wise GATE_CSIT_CH10_Computer Networks.indd 367

367

Distance = 10000 km Propagation speed = 2 × 108 m/s Data size = 50000 bytes = 50000 × 8 bits Now, p=

Data size 50000 × 8 bits = = 400 ms Bandwidth 106 bps

q=

Distance 10000 × 103 m = = 50 ms Propagation speed 2 × 108 m/s

119. Topic: TCP/UDP (c)  UDP header’s port number is 16 bit in length. Ethernet MAC address is 48 bit in length. IPV6 next header is 8 bit in length. TCP header’s sequence Number is 32 bit in length. 120. Topic: Congestion Control (c)  Only statement (iv) is true. Statement (i) is false; cwnd increases by 1 MSS on every successful acknowledgement. Statement (ii) is false; cwnd does not double on every successful acknowledgement. Statement (iii) is false; cwnd increases exponentially on every round trip time. Statement (iv) is true; cwnd approximately doubles every round trip time. 121. Topic: TCP/UDP (34.35)  Given, end-to-end bandwidth of TCP. Session = 1 Gbps Session starts with sequence number of 1234. Now, wrap around time of 1 s = 109 bites ⇒ 1s =

10 9 bytes 8

Therefore, Wrap around time of 1 byte = 8 s 10 9 32 Wrap around time of 232 bytes = 2 × 8 = 34.35 s 10 9

122. Topic: TCP/UDP (144) Packet length = 4500 B I P payload = 4500 - 20 = 4480 B Maximum transmission unit (MTU) = 600 B MTU Payload = 600B - 20 = 580 B But MTU payload must be multiple of 8, therefore, MTU payload = 576 B IP packet size = 576 + 20B = 596 B

11/13/2018 11:12:03 AM

368

GATE CS AND IT Chapter-wise Solved Papers

Size of offset =

576 = 72 8

Therefore, 1st fragment offset = 0 2nd fragment offset = 72 3rd fragment offset = 144

Q won’t transmit. Therefore, there is no collision. Q will sense carrier up to time t = 5 Q starts transmission at t = 6 If first bit of P reaches Q at t = 5 collision happens given, signal speed is 10 m/time. Therefore, maximum distance between P and Q is 50 m.

123. Topic: LAN Technologies (Ethernet) (50)  P starts transmission at t = 0 P’s first bit reaches Q within Q’s sensing window.

Ch wise GATE_CSIT_CH10_Computer Networks.indd 368

11/13/2018 11:12:03 AM

aPPENDIX

Solved GATE (CSIT) 2019 QUESTIONS

Chapter 1: Engineering Mathematics 1. Let U = {1, 2, …, n}. Let A = {( x, X ) | x ∈ X , X ⊆ U }. Consider the following two statements on |A|. I. |A| = n2n - 1 n ⎛ n⎞ II. A = ∑ k ⎜ ⎟ k =1 ⎝ k ⎠ Which of the following is correct? (a) Only I (b) Only II (c) Both I and II (d) Neither I nor II (1 Mark) Topic: Discrete Mathematics (c)  Given, U = {1,2,…, n} and A = {( x, X ) | x ∈ X and X ⊆ U } Statement I:

|A| = n 2n - 1

n ⎛n⎞ A = ∑k ⎜ ⎟ k =1 ⎝ k ⎠ ⎛n⎞ Now number of subsets of U with k elements will be ⎜ ⎟ . ⎝k ⎠ ⎛n⎞ Number of possible ordered pairs ( x, X ) = k ⎜ ⎟ ⎝k ⎠ So total number of ordered pairs in A n ⎛n⎞ A = ∑k ⎜ ⎟ k =1 ⎝ k ⎠

Statement II:

So Statement II is true. Using combinational identity n ⎛n⎞ A = ∑ k ⎜ ⎟ = n2n −1 k =1 ⎝ k ⎠

So Statement I is also true. So option (c) is true. 2.

Which one of the following is NOT a valid identity? (a) ( x ⊕ y ) ⊕ z = x ⊕ ( y ⊕ z ) (b) ( x + y ) ⊕ z = x ⊕ ( y + z ) (c) x ⊕ y = x + y, if xy = 0 (d) x ⊕ y = ( xy + x ′y ′)′ (1 Mark)

GATE_CSIT_2019.indd 1

Topic: Discrete Mathematics (b)  (a) ( x ⊕ y ) ⊕ z = x ⊕ ( y ⊕ z ) This is associativity condition. This identity is always valid. (b) ( x + y ) ⊕ z = x ⊕ ( y + z ) ( x + y ) ⊕ z = ( x + y )′ z + ( x + y ) z ′ = x ′ ⋅ y ′ ⋅ z + xz ′ + yz ′ x ⊕ ( y + z ) = x ′( y + z ) + x( y + z )′ = x ′y + x ′z + xy ′z ′ ( x + y) ⊕ z ≠ x ⊕ ( y + z) This identity is not valid. (c) x ⊕ y = x + y ′ ′ x ⊕ y = ( x + y ) ⋅ ( x + y) = ( xy ) ′⋅ ( x + y )  [using DeMorgan’s theorem ( xy )′ = x ′ + y ′ ] ′ If xy = 0, x ⊕ y = 0 ⋅ ( x + y ) = 1⋅ ( x + y ) = x + y This identity is valid. (d)   x ⊕ y = xy ′ + yx ′ ( xy + x ′y ′) = ( xy )′ ⋅ ( x ′y ′)′ = ( x ′ + y ′) ⋅ ( x + y ) = x ′x + x ′y + y ′x + y ′y = x ′y + y ′x

⎛∵ x ′x = 1 ⎞ ⎜ ⎟ ⎝ y ′y = 1⎠ Therefore x ⊕ y = ( xy + x ′y ′)′ identity is valid.



3. Let X be a square matrix. Consider the following two statements on X: I. X is invertible. II. Determinant of X is non-zero. Which one of the following is TRUE? (a) I implies II; II does not imply I. (b) II implies I; I does not imply II. (c) I does not imply II; II does not imply I. (d) I and II are equivalent statements. (1 Mark) Topic: Linear Algebra (d)  Given X is a square matrix. If X is invertible, then |X| ≠ 0, that is, determinant of X is non-zero. If determinant of X is non-zero, then X is an invertible matrix.

6/24/2019 2:23:12 PM

A2

GATE CSIT Chapter-wise Solved papers

Thus, both statements are equivalent. So option (d) is correct. 4. Let G be an arbitrary group. Consider the following relations on G:

R1: ∀a, b ∈ G , aR1b if and only if ∃g ∈ G such that a = g−1bg R2: ∀a, b ∈ G , aR2 b if and only if a = b−1 Which of the above is/are equivalence relation/relations? (a) R1 and R2 (b) R1 only (c) R2 only (d) Neither R1 nor R2 (1 Mark)

(a) n! (c) 1

(b) (n − 1)! ( n −1)! (d) 2 (1 Mark)

Topic: Discrete Mathematics (d)  An undirected graph is a graph in which edges do not have a direction. A complete graph is a graph in which every pair of distinct vertices in connected by a unique edge. A Hamiltonian cycle is a cycle that visits each vertex exactly once. For an undirected complete graph of n vertices, number of different Hamiltonian cycles is

Topic: Discrete Mathematics ( n −1)! (b)  Given G is a group with relations 2 R1 : ∀a, b ∈ G , aR1b if and only if ∃g ∈ G −1 Such that a = g bg x 4 − 81 . 6. Compute lim 2 R2 : ∀a, b ∈ G , aR2b if and only if a = b−1 x →3 2 x − 5 x − 3 Equivalence relation is a binary relation that is reflexive, 53 (a) 1 (b) symmetric and transitive. 12 108 Reflexive: a = a for any a (d) Limit does not exist (c) 7 Symmetric: If a = b then b = c for any a, b, c (1 Mark) Transitive: If a = b and b = c then a = c for any a, b, c. Consider the relation R1 Topic: Calculus Reflexive: a = g−1ag x 4 − 81 0 (c)  lim 2 = Suppose g = e, a = e−1ae ⇒ a = a x →3 2 x − 5 x − 3 0 Therefore, R1 is reflexive. Applying L’Hospital’s rule, that is, taking derivative of Symmetric: numerator and denominator and then taking limit, we get a = g−1bg ⇒ b = gag−1 = (g−1)−1ag−1 d 4 ( x − 81) where g−1 always exists for every g ∈ G . x 4 − 81 4 x3 = lim dx lim 3 = lim x →3 2 x − 5 x − 3 x →3 d x →3 4 x − 5 Therefore, R1 is symmetric. ( 2 x 2 − 5 x − 3) −1 −1 dx Transitive: a = g1 bg1 and b = g 2 cg 2 where g1 , g 2 ∈ G . d 4 ( x − 81) 4 x − 81 4 x3 Therefore = lim dx lim 3 = lim x →3 2 x − 5 x − 3 x →3 d x →3 4 x − 5 a = g1−1 bg1 = g1−1 g 2−1 Cg 2 g1 = ( g 2 g1 ) −1 C ( g 2 g1 ) where ( 2 x 2 − 5 x − 3) dx 4(3)3 108 108 ( g 2 g1 ) ∈ G . Therefore = = = −1 −1 −1 × − −5 4 3 5 12 7 a = g1 bg1 and b = g 2 Cg 2 ⇒ a = ( g 2 g1 ) C ( g 2 g1 ) Therefore, So R1 is transitive. x 4 − 81 108 lim 2 = Thus, R1 is an equivalence relation. x →3 2 x − 5 x − 3 7 Consider relation R2 7. Two numbers are chosen independently and uniformly Reflexive: aR2a ⇒ a = a−1 at random from the set {1, 2, ..., 13}. The probabilThis is not true. Therefore R2 is not reflexive. ity (rounded off to 3 decimal places) that their 4-bit (unsigned) binary representations have the same most Thus R2 is not an equivalence relation. significant bit is . Hence option (b) is correct. Only R is an equivalence relation.

1

5. Let G be an undirected complete graph on n vertices, where n > 2. Then, the number of different Hamiltonian cycles in G is equal to

GATE_CSIT_2019.indd 2

(1 Mark) Topic: Probability (0.503)  The numbers in set {1, 2, …, 13} can be represented by binary as

6/24/2019 2:23:17 PM

appendix  •  Solved GATE (CSIT) 2019







8.

  1: 0000   2: 0011   3: 0010   4: 0101   5: 0100   6 : 0111   7: 0110   8: 1001   9: 1000 10: 1011 11: 1010 12: 1101 13: 1100 Here 1-7 have 0 as most significant bit and 8-13 have 1 as most significant bit. Probability that two numbers chosen have most ­significant bit 0 is 7 7 × 13 13 Probability that two numbers chosen have most ­significant bit 1 is 6 6 × 13 13 Thus, probability that two numbers chosen independently and uniformly have same most significant bit is 7 7 6 6 P = × + × = 0.2899 + 0.2130 = 0.5029 13 13 13 13 So, required probability is ~0.503. Consider the first-order predicate formula f:







9.

The given predicate formula implies that if there exists a prime number z in the set, then there exists a prime number greater than z. Consider S1 = {1, 2, 3 …, 100}. The predicate formula fails for prime number 97 since there does not exist any prime number greater than 97 in the set. S2 is set of all positive integers and S3 is set of all integers. These sets are infinite sets and will always satisfy predicate formula. So option (c) is correct. Consider the following matrix: ⎡1 ⎢1 R=⎢ ⎢1 ⎢ ⎣1



8 ⎤ 2 4 3 9 27 ⎥⎥ 4 16 64 ⎥ ⎥ 5 25 125⎦

The absolute value of the product of eigenvalues of R is _____ . (2 Marks)

Topic: Linear Algebra (12)  Given

⎡1 ⎢1 R=⎢ ⎢1 ⎢ ⎣1



A3

8 ⎤ 2 4 3 9 27 ⎥⎥ 4 16 64 ⎥ ⎥ 5 25 125⎦

The absolute value of the product of eigenvalues of R is equal to determinant of the matrix R. Therefore, 1 1 R = 1 1

2 4 8 20 3 9 27 30 = 0 4 16 64 4 5 25 125 50

21 31 41 51

22 32 42 52

23 33 43 53

row operations ∀x[(∀z z | x ⇒ (( z = x ) ∨ ( z = 1))) ⇒ ∃w ( w > x ) ∧ (∀z z | w ⇒Using (( w =elementary z ) ∨ ( z = 1)))] R2 → R2 - R1 x[(∀z z | x ⇒ (( z = x ) ∨ ( z = 1))) ⇒ ∃w ( w > x ) ∧ (∀z z | w ⇒ (( w = z ) ∨ ( z = 1)))] R3 → R3 - R1 Here ‘a | b’ denotes that ‘a divides b’ where a and b are R4 → R4 - R1 integers. Consider the following sets: S1: {1, 2, 3, …, 100} S2: Set of all positive integers S3: Set of all integers Which of the above sets satisfy f? (a) S1 and S2 (b) S1 and S3 (c) S2 and S3 (d) S1, S2 and S3 (2 Marks)

1 2 2 2 23 1 5 19 0 1 5 19 R = = 2 12 56 0 2 12 56 3 21 117 0 3 21 117 Using elementary row operations R2 → R2 - 2R1 R3 → R3 - 3R1

0 5 19 Topic: Discrete Mathematics 2 18 R = 0 2 18 = = 2 × 60 − 6 × 18 (c)  Given 6 60 ∀x[(∀z z | x ⇒ (( z − x ) ∨ ( z = 1)) ⇒ ∃ω (ω > x ) ∧ ∀z z | ω ⇒ ((W = Z ) ∨ ( Z0= 16))] 60    |R| = 120 - 108 = 12 ∀x[(∀z z | x ⇒ (( z − x ) ∨ ( z = 1)) ⇒ ∃ω (ω > x ) ∧ ∀z z | ω ⇒ ((W = Z ) ∨ ( Z = 1))] Thus, absolute value of the product of eigenvalues of R where a′ | b′ ⇒ a divides b. is 12.

GATE_CSIT_2019.indd 3

6/24/2019 2:23:19 PM

A4

GATE CSIT Chapter-wise Solved papers

10. Suppose Y is distributed uniformly in the open interval (1, 6). The probability that the polynomial 3x2 + 6xY + 3Y + 6 has only real roots is (rounded off to 1 decimal place) . (2 Marks) Topic: Probability (0.8)  Given polynomial 3x2 + 6xY + 3Y + 6 We know that for a quadratic equation

(1)

ax2 + bx + c = 0 The root is given as −b ± b 2 − 4 ac 2a It has following three conditions: b2 - 4ac > 0 : real and distinct roots b2 - 4ac = 0 : real and equal roots b2 - 4ac < 0 : imaginary roots It is required that the given polynomial has only real roots, therefore b2 - 4ac ≥ 0. Therefore Eq. (1) has real roots if (6Y )2 - 4(3) (3Y + 6) ≥ 0 Solving this, we get 36Y 2 - 36Y - 72 ≥ 0  ⇒   Y 2 - Y - 2 ≥ 0 Given y is distributed uniformly in open interval (1, 6). So t ∈ [2, 6). The probability distribution function is 1 f (Y ) = Y for Y ∈[2, 6) 5 Required probability will be

Topic: Boolean Algebra (c)  2’s complement of +28 = 2’s complement of −28 Binary representation +28 is 0000 0000 0001 1100

2’s complement of a binary number is obtained by adding 1 to the 1’s complement of the binary number. 1’s complement of +28 is 1111 1111 1110 0011 2’s complement of +28 is 1111 1111 1110 0100 Thus, 2’s complement representation of −28 is 1111 1111 1110 0100

12. Consider Z = X - Y, where X, Y and Z are all in sign-­ magnitude form. X and Y are each represented in n bits. To avoid overflow, the representation of Z would require a minimum of (a) n bits (b) n − 1 bits (c) n + 1 bits (d) n + 2 bits (1 Mark) Topic: Number Representations and Computer Arithmetic (Fixed and Floating Point) (c)  Given Z = X - Y, where X, Y and Z are all sign-­ magnitude form. X and Y are represented in n bits. Let n = 6 bit and let X = 31, Y = −32. Here 1 bit is for sign bit and 5 bits are for magnitude. Thus, Z = X - Y = 31 − (−32) = 31 + 32 = 63 Here Z needs 6 bits for magnitude and 1 bit for sign bit, i.e., 7 bits. Thus to avoid overflow, the representation of Z would require a minimum of (n + 1) bits. 13. The value of 351 mod 5 is

. (1 Mark)

6

1 4 P = P ( 2 ≤ Y < 6) = ∫ f (Y )dY = [Y ]62 = 5 5 2 Therefore, P = 0.8. Thus, probability that the polynomial 3x2 + 6xy + 3Y + 6 has only real root which is 0.8.

Topic: Boolean Algebra (2)  According to Fermat’s theorem, ap - 1 ≡ 1 mod p or ap ≡ a mod p where p is a prime number and a is an integer. Thus, 351 mod 5 = (34)12 ⋅ 33 mod 5 Now using relation ap - 1 ≡ 1 mod p we get

Chapter 2: Digital Logic 11. In 16-bit 2’s complement representation, the decimal number −28 is: (a) 1111 1111 0001 1100 (b) 0000 0000 1110 0100 (c) 1111 1111 1110 0100 (d) 1000 0000 1110 0100 (1 Mark)

GATE_CSIT_2019.indd 4

35 - 1 = 1 mod 5

(1)

⇒ 34 = 1 mod 5

⇒ 34 = 1 Hence, Eq. (1) becomes (1)12 33 mod 5 = 33 mod 5 Therefore, 351 mod 5 = 27 mod 5 = 2 Thus, value of 351 mod 5 is 2.

6/24/2019 2:23:23 PM

appendix  •  Solved GATE (CSIT) 2019

14. Consider three 4-variable functions f1, f2 and f3, which are expressed in sum-of-minterms as f1 = ∑(0, 2, 5, 8, 14) f2 = ∑(2, 3, 6, 8, 14, 15) f3 = ∑(2, 7, 11, 14) For the following circuit with one AND gate and one XOR gate, the output function f can be expressed as

A5

Topic: Minimization (3)  f = ∑(0, 2, 5, 7, 8, 10, 13, 15) Representing it in Karnaugh map: CD AB

f1

00

10

11

10

00

1

0

0

1

01

0

1

1

0

11

0

1

1

0

10

1

0

0

1

AND f2

XOR

f

Grouping 0s in power of 2, 4, 8, ….

f3 (a) (b) (c) (d)

∑(7, 8, 11) ∑(2, 7, 8, 11, 14) ∑(2, 14) ∑(0, 2, 3, 5, 6, 7, 8, 11, 14, 15)

Therefore, f = ( B + D )( B + D )

(2 Marks) Topic: Minimization (a)  Given f1 = ∑(0, 2, 5, 8, 14) f2 = ∑(2, 3, 6, 8, 14, 15) f3 = ∑(2, 7, 11, 14)

This function can be implemented using three NOR gates.

B D f B

f1

D AND

f2

XOR

f

Chapter 3: Computer Organization and Architecture f3

Here f1 and f2 are inputs to AND gate; thus output of AND gate will be f1 - f2 = ∑(2, 8, 14) (i.e. all terms that are common in f1 and f2) This output (f1 - f2) and f3 are inputs to XOR gate, thus output will be f = f 3 ⊕ ( f1 , f 2 ) = ∑(7, 8, 11)  [i.e. all terms that are not common in (f1 - f2 and f3)] Hence, output function f = ∑(7, 8, 11).

15. What is the minimum number of 2-input NOR gates required to implement 4-variable function expressed in sum-of-minterms form as f = ∑(0, 2, 5, 7, 8, 10, 13, 15)? Assume that all the inputs and their complements are available. (2 Marks)

GATE_CSIT_2019.indd 5

16. The chip selects logic for a certain DRAM chip in memory system design is shown below. Assume that memory has 16 address lines denoted by A15 to A0. What is the range of addresses (in hexadecimal) of the memory system that can get enabled by the chip select (CS) signal? A15 A14 A13 A12 A11 (a) C800 to CFFF (c) C800 to C8FF

CS

(b) CA00 to CAFF (d) DA00 to DFFF (1 Mark)

Topic: Machine Instructions and Addressing Modes (a)  Here, memory has 16 address lines denoted by A15 to A0.

6/24/2019 2:23:25 PM

A6

GATE CSIT Chapter-wise Solved papers

The DRAM chip selects only A15, A14, A13, A12, A11. A15 A14 A13 A12 A11 A10

⎧ A9 ⎪ ↓ ↓ ↓ ↓ ↓ 0 ⎪ 0 ⎨ 1 1 0 0 0 1 ⎪ ⎪⎩ 1



........... A0 ⎫ ........... 0 ⎪⎪ ⎬ to ⎪ ........... 1 ⎪⎭

Therefore the range of address in hexadecimal of memory system will range from 1100100 ….. 0 to 1100111 …. 1 That is, C800 to CFFF So option (a) is correct.

17. A certain processor deploys a single-level cache. The cache block size is 8 words and the word size is 4 bytes. The memory system uses a 60 MHz clock. To service a cache miss, the memory controller first takes 1 cycle to accept the starting address of the block, it then takes 3 cycles to fetch all the eight words of the block, and finally transmits the words of the requested block at the rate of 1 word per cycle. The maximum bandwidth for the memory system when the program running on the processor issues a series of read operations is × 106 bytes/sec. (2 Marks) Topic: Memory Hierarchy: Cache, Main Memory and Secondary Storage (160)  Given Cache block size = 8 words Word size = 4 bytes Number of cycles required to accept starting address =1

Number of cycles required to fetch all 8 words = 3 Number of cycles required to transmit words at rate of 1 word per cycle = 8 Hence, total time to transfer = 1 + 3 + 8 = 12 Memory uses 60 MHz clock. Therefore, 1 cycle duration = Duration of 12 cycles = 12 ×



1 sec 60 × 106

1 1 = sec 6 60 × 10 5 × 106

Now cache block size = 8 words = 8 × 4 bytes = 32 bytes 32 bytes are transferred in

1 sec 5 × 106

Number of bytes transferred 1 sec = 32 × 5 × 106 = 160 × 106 So, maximum bandwidth = 160 × 106 bytes/sec

GATE_CSIT_2019.indd 6

Chapter 4: Programming and Data ­Structures 18. The following C program is executed on a Unix/Linux system: #include int main( ) { int i; for {i = 0; i < 10; i++) if (i % 2 = = 0) fork( ); return 0; } The total number of child processes created is . (1 Mark) Topic: Programming in C (31)  The Fork( ) function is used to create a new process by duplicating the existing process from which it is called. The existing process is called parent process and newly created process is called child process. In main function for loop of i is executed 10 times between 0 and 9 and the logic (i%2 = = 0) is true only 5 times, when i = 0, 2, 4, 6 and 8. So number of child processes created = 2n - 1 = 25 - 1 = 32 - 1 = 31 Thus, the total number of child processes created is 31. 19. Consider the following C program: #include int jumble(int x, int y) { x = 2 * x + y; return x; } int main ( ) { int x = 2, y = 5; x = jumble(y, x); y = jumble(y, x); printf(“%d \n”, x); return 0; } The value printed by the program is . (1 Mark) Topic: Programming in C (26)  Given function jumble computes int jumble (int x, int y) { x=2*x+y

6/24/2019 2:23:25 PM

appendix  •  Solved GATE (CSIT) 2019

return x; } initially x = 2, y = 5



y = jumble (5, 2) ⇒ y = 2 * 5 + 2 = 12

x = jumble (y, x) ⇒ x = jumble (12, 2) = 2 * 12 + 2 = 26 Value printed by the program is 26.

20. An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) is . (1 Mark)

2 = 0.08 25

21. Consider the following C program: #include int main ( ) { int arr[ ] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 5), *ip = arr + 4; printf (“%d\n”, ip[1])’ return 0; } The number that will be displayed on execution of the program is . (1 Mark) Topic: Programming in C (6) # include int main ( ) { int arr[ ] = {1,2,3,4,5,6,7,8,9,10, 1,2,5}, *ip = arr+4; printf (“%d\n”, ip[1]) return 0; } Here *ip = arr + 4 will point at 5th element of arr [ ]

GATE_CSIT_2019.indd 7

ip [1] will point to the next element, i.e., 6th element of arr [ ] Thus, the sixth element will be displayed on execution of the program, that is, 6 will be displayed.

22. Consider the following C function: void convert (int n) { if (n < 0) printf(“%d”, n); else { convert(n/2); printf(“%d”, n%2); } } Which one of the following will happen when the ­function convert is called with any positive integer n as argument? (a) It will print the binary representation of n and ­terminate. (b) It will print the binary representation of n in the reverse order and terminate. (c) It will print the binary representation of n but will not terminate. (d) It will not print anything and will not terminate. (2 Marks)

Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (0.08)  Quick sort is a divide-and-conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot. The worst possible location for the pivot is either first place or last place. Thus, for an array of 25 distinct elements to be sorted using quick sort, the probability that the pivot element gets placed in worst possible location in first round of partitioning is P=

A7

Topic: Programming in C (d)  Given C function void convert (int n) { if (n < 0) printf{“%d”, n) else { convert (n/2) printf “%d”, n%2; } }

Since the argument of convert function is an integer, so n will never be less than 0. We start from a positive number. In else statement convert function will be called recursively.



Therefore, the convert function will not print anything and will not terminate. Thus, (d) is the correct option.

23. Consider the following C program: #include int r( ){ Static int num = 7; return num --; }

6/24/2019 2:23:26 PM

A8

GATE CSIT Chapter-wise Solved papers

int main( ) for ( r( ); r( ); r( ) ) printf(“%d”, r( ) ); return 0; } Which one of the following values will be displayed on execution of the programs? (a) 41 (c) 63

(b) 52 (d) 630 (2 Marks)

Topic: Programming in C (b)  Function r( ) is defined as int r ( ) { static int num = 7; return num --; } We know that static variables have the property of retaining their value even when out of scope of function.



So in for loop, first function call for initialization will return value 6. Second function call for condition will return value 5. Hence value printed will be 5. Then the function call for increment will return value 3. The next function call for condition will return value 2. Hence value printed will be 2. Then the function call for increment will return value 1. The condition fails and loop breaks. Thus, value displayed will be 52.

24. There are n unsorted arrays: A1, A2, An. Assume that n is odd. Each of A1, A2, …, An contains n distinct elements. There are no common elements between any two arrays. The worst-case time complexity of computing the median of the medians of A1, A2, …., An is (a) O(n) (b) O(n log n) 2 (c) O(n ) (d) Ω(n2log n) (2 Marks)

25. Consider the following statements: I. The smallest element in a max-heap is always at a leaf node. II. The second largest element in a max-heap is always a child of the root node. III.  A max-heap can be constructed from a binary search tree in Θ(n) time. IV.  A binary search tree can be constructed from a ­max-heap in Θ(n) time. Which of the above statements are TRUE? (a) I, II and III (b) I, II and IV (c) I, III and IV (d) II, III and IV (2 Marks) Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (a)  Statement I: The smallest element in a max-heap is always at a leaf node - this statement is true. Statement II: The second largest element in a max-heap is always a child of the root node - this statement is true. Statement III: A max-heap can be constructed from a binary search tree in O(n) time - this statement is true. Statement IV: A binary search tree can be constructed from a max-heap in O(n) time - this statement is false. A binary search tree can be constructed from a max-heap in O(n2) time. Thus statements I, II and III are true. So option (a) is correct. 26. Let T be a full binary tree with 8 leaves. (A full binary tree has every level full.) Suppose two leaves a and b of T are chosen uniformly and independently at random. The expected value of the distance between a and b in T (i.e., the number of edges in the unique path between a and b) is (rounded off to 2 decimal places) . (2 Marks) Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (4.25)  Given T is a full binary tree with 8 leaves.

Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs





(c)  Given, n unsorted arrays each array contains n distinct elements. We know that median is obtained for a sorted array. It is defined as the middle element when array has even number of elements. Worst case time complexity of computing the median of medians will be linear in time and will be O(n2). So, option (c) is correct.

GATE_CSIT_2019.indd 8

8 Leaves

The question says “independently”. This means the selection of first node is independent of second node. So for both leaf node selections, we have 8 × 8 = 64 choices.

6/24/2019 2:23:27 PM

appendix  •  Solved GATE (CSIT) 2019

So, expected path length

*b is a pointer *b = a + 4 implies b is pointing to 5th element of a [ ] (if the index of array starts with 0)

8 8 16 32 + 2× + 4 × + 6× 64 64 64 64 272 = = 4.25 64 = 0×

27. Consider the following C program: #include int main ( ) { float sum = 0.0, j = 1.0, i = 2.0; while (i/j > 0.0625) { j = j + j; sum = sum + i/j;



printf{“%f\n”, sum); } return 0; } The number of times the variable sum will be printed when the above program is executed, is . (2 Marks)

Topic: Programming in C (5)  Initially j = 1.0, i = 2.0 1st iteration: i/j = 2/1 > 0.0625, j = 2.0, sum = 1.0 2nd iteration: i/j = 2/2 > 0.0625, j = 4.0, j = 4.0, sum = 1.5 3rd iteration: i/j = 2/4 > 0.0625, j = 8.0, sum = 1.75 4th iteration: i/j = 2/8 > 0.0625, j = 16.0, sum = 1.875 5th iteration: i/j = 2/16 > 0.0625, j = 32.0, sum = 1.9375 6th iteration: i/j = 2/32 = 0.0625; so condition fails. Thus, variable sum will be printed 5 times. 28. Consider the following C program: #include int main ( ) { int a[ ] = (2, 4, 6, 8, 10}; int i, sum = 0, *b = a + 4; for (i = 0; i < 5; i++) sum = sum + (*b − i) − *(b − i); printf (“%d\n”, sum); return 0; } The output of the above C program is

. (2 Marks)

Topic: Programming in C (10)  In the given program a[ ] = {2, 4, 6, 8, 10} - is an array

GATE_CSIT_2019.indd 9

A9

iteration 1: i = 0 *b - i = 10 - 0  *(b - i) = 10 sum = 0 iteration 2: i = 1   *b - i = 10 - 1 = 9 *(b - i) = (a + 4 - 1) = 8 sum = 0+ (9 - 8) = 1 iteration 3: i = 2   *b - i = 10 - 2 = 8 *(b - i) = *(a + 4 - 2) = 6   sum = 1 + (8 - 6) = 3 iteration 4: i = 3 *b - i = 10 - 3 = 7 *(b - c) = *(a + 4 - 3) = 4 sum = 3 + (7 - 4) = 6 iteration 5: i = 4 *b - i = 10 - 4 = 6 *(b - i) = *(a + 4 - 4) = 2 sum = 6 + (6 - 2) = 10 iterations 6: i = 5 for conditions fails and loop breaks Hence, output of given C program is 10.

Chapter 5: Algorithms 29. Consider a sequence of 14 elements: A = [−5, −10, 6, 3, −1, −2, 13, 4, −9, −1, 4, 12, −3, 0]. The subsequence sum S (i, j ) = ∑ k =1 A[k ]. Determine the maximum of S(i, j), j

where 0 ≤ i ≤ j < 14. (Divide-and-conquer approach may be used.) (1 Mark) Topic: Algorithm Design Techniques: Greedy, Dynamic Programming and Divide-and-Conquer (29)  Divide-and-conquer is an algorithm based on multi-branched recursion. It works by recursively breaking a problem into two or more sub-problems until these become simple enough to be solved directly. Given A = [−5, −10, 6, 3, −1, −2, 13, 4, −9, −1, 4, 12, −3, 0] j

Sub-sequence sum S( i )( j ) = ∑ A[k ] , 0 ≤ i ≤ j < 14 k =1

Max. of S(i, j) = {6, 3, −1, −2, 13, 4, −9, −1, 4, 12}

6/24/2019 2:23:28 PM

A10

GATE CSIT Chapter-wise Solved papers

Adding all elements, we get 6 + 3 - 1 - 2 + 13 + 4 - 9 - 1 + 4 + 12 = 29 Therefore, maximum of S(i, j) where 0 ≤ i ≤ j ≤ 14 is 29. 30. Let G be any connected, weighted, undirected graph: I.  G has a unique minimum spanning tree, if no two edges of G have the same weight. II.  G has a unique minimum spanning tree, if for every cut of G, there is a unique minimum weight edge crossing the cut. Which of the above two statements is/are TRUE? (a) I only (b) II only (c) Both I and II (d) Neither I nor II (2 Marks) Topic: G  raph Search, Minimum Spanning Trees, Shortest Paths (c)  Given, G is a connected, weighted, undirected graph. Statement I: G has a unique minimum spanning tree, if no two edges of G have the same weight. This statement is true. Statement II: G has a unique minimum spanning tree, if for every cut G, there is a unique minimum weight edge crossing the cut. This statement is also true. Hence, both I and II are TRUE. Option (c) is correct.

Chapter 6: Theory of Computation 31. If L is a regular language over ∑ = {a, b}, which one of the following languages is NOT regular? (a) L ⋅ LR = { xy | x ∈ L, y R ∈ L} (b) {ww R | w ∈ L} (c) Prefix ( L) = { x ∈ Σ* | ∃y ∈ Σ * such that xy ∈ L} (d) Suffix ( L) = { y ∈ Σ* | ∃x ∈ Σ * such that xy ∈ L} (1 Mark) Topic: R  egular and Contex-Free Languages, Pumping Lemma (b)  A regular language is a language that can be expressed with a regular expression or a deterministic or non-deterministic finite automata or state machine. Given L is a regular language over ∑ = {a, b}. Therefore L⋅LR is also regular by closure property. Also suffix (L) and prefix (L) is also regular by closure ­property. Hence {ww R | w ∈ L} is not regular. If L is infinite regular language then {ww R | w ∈ L} will be non-regular.

GATE_CSIT_2019.indd 10

32. For ∑ = {a, b}, let us consider the regular language L = {x | x = a2 + 3k or x = b10 + 12k, k ≥ 0}. Which one of the following can be a pumping length (the constant ­guaranteed by the pumping lemma) for L? (a) 3 (b) 5 (c) 9 (d) 24 (1 Mark) Topic: Regular and Contex-Free Languages, Pumping Lemma (d)  Given, regular language L = {x⎮x = a2 + 3k or x = b10 + 12k, k ≥ 0} Therefore L = {a2, a5, a7,…, b10, b22, b34…}

The minimum pumping length should be 11, because string having length 10 does not repeat anything. But when the string length increases from 10, then states will repeat in that case. Therefore, pumping length (p) should be greater than 10. Only option (d) is having more than 10 value. So, option (d) is correct.

33. Which one of the following languages over ∑ = {a, b} is NOT context-free? (a) {ww R | w ∈ {a, b}*} (b) {wa n b n w R | w ∈ {a, b}*, n ≥ 0} (c) {wa n w R b n | w ∈ {a, b}*, n ≥ 0} (d) {a n bi | i ∈ {n, 3n, 5n}, n ≥ 0} (2 Marks) Topic: Context-Free Grammars and Push-Down Automata (c)  Context-free grammar is a set of recursive rewriting rules used to generate patterns of strings. (a)  {ωω R | ω ∈ {a, b}*} - this is a context-free ­language. (b)  {ω a n b nω R | ω ∈ {a, b}*, n ≥ 0} - this is a contextfree language. (c)  {ω a nω R b n | ω ∈ {a, b)*, n ≥ 0} - this is not a ­context-free language, because it violates pushdown automation (PDA) which employs stack. (d)  {a n bi | i ∈ {n, 3n, 5n}, n ≥ 0} - this is a context-free language. Thus option (c) is the correct answer. 34. Consider the following sets: S1: Set of all recursively enumerable languages over the alphabet {0, 1}. S2: Set of all syntactically valid C programs.

6/24/2019 2:23:32 PM

appendix  •  Solved GATE (CSIT) 2019

S3: Set of all languages over the alphabet {0, 1}. S4: Set of all non-regular languages over the alphabet {0,1}. Which of the above sets are uncountable? (a) S1 and S2 (b) S3 and S4 (c) S2 and S3 (d) S1 and S4 (2 Marks) Topic: R  egular and Contex-Free Languages, Pumping Lemma (b)  S1: Set of all recursively enumerable languages over the alphabet {0, 1} - this set corresponds to set of turing machine. It is countable. S2: Set of all syntactically valid C programs - this set is countable since it is a subset of turing machine. S3: Set of all languages over the alphabet {0, 1} - it is an uncountable set. S4: Set of all non-regular languages over the alphabet {0, 1} - it is an uncountable set; thus S3 and S4 are uncountable - option (b) is correct. 35. Let ∑ be the set of all bijections from {1, …, 5} to {1, …, 5}, where id denotes the identity function, i.e. id(j) = j, ∀j. Let ° denote composition on functions. For a string x = x1 x2  xn ∈ Σ n , n ≥ 0, let π (x) = x1 ° x2 ° ... ° xn. Consider the language L = { x ∈ Σ* | π ( x ) = id }. The minimum number of states in any DFA accepting L is . (2 Marks) Topic: Regular Expressions and Finite Automata (120)  In DFA (deterministic finite automata), for each input symbol, one can determine the state to which the machine will move. For the given set of bijections, the minimum number of states in any DFA accepting L would need one state for every possible permutation function of the elements of set {1, …, 5} to {1, …, 5}. Therefore, minimum number of states in any DFA accepting L = 5! = 120 states.

Chapter 7: Compiler Design 36. Which one of the following kinds of derivation is used by LR parsers? (a) Leftmost (b) Leftmost in reverse (c) Rightmost (d) Rightmost in reverse (1 Mark)

A11

Topic: Lexical Analysis, Parsing, Syntax-Directed Translation (d)  LR parsing is a type of bottom-up parsing. LR parser reads input text from left to right and produces rightmost derivation in reverse. Thus option (d) is ­correct. 37. Consider the grammar given below: S → Aa A → BD B → b | ∈ D → d | ∈ Let a, b, d and $ be indexed as follows:



a

b

d

$

3

2

1

0

Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210.) (1 Mark)

Topic: Lexical Analysis, Parsing, Syntax-Directed Translation (31)  Given grammar S → Aa A → BD B → b/E D → d/E a, b, d and $ are indexed as a

b

d

$

3

2

1

0

follow (x) is set of terminals that can appear right of non-terminal X. Therefore follow (B) = {d, a} index of d = 1 and index of a = 3. So follow (B) = {1, 3} Hence follow set in descending order is 31. 38. Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1, X2, X3, X4, X5 and X6 be the placeholders for the non-terminals D, T, L or L1 in the following table: Productions rule

Semantic action

D → TL

X1.type = X2.type

T → int

T.type = int

T → float

T.type = float (Continued)

GATE_CSIT_2019.indd 11

6/24/2019 2:23:33 PM

A12

GATE CSIT Chapter-wise Solved papers

Productions rule

Semantic action

L → L1, id

X3.type = X4.type



addType(id.entry, X6.type)

S → L → .L, S S → .

S → .id where “.” is used to separate two parts of a string of non-terminals and string of terminals. Thus, the number of items in the set GOTO (I0,  84. So there are 25 rows. But there are 5 different students, 25 so number of rows returned will be =5 5 50. Consider the following relations P(X, Y, Z), Q(X, Y, T) and R(Y, V). P X

Y

Z

X1

Y1

Z1

X1

Y1

Z2

Rohan

X2

Y2

Z2

Smita

X2

Y4

Z4

1

Amit

2

Priya

3

Vinit

4 5

Marks

The primary key of the Student table is Roll_no. For the Performance table, the columns Roll_no. and S ­ ubject_ code together from the primary key. Consider the SQL query given below:

Student Roll_no.

A15

6/24/2019 2:23:38 PM

A16

GATE CSIT Chapter-wise Solved papers

Chapter 10: Computer Networks

Q X

Y

T

X2

Y1

2

X1

Y2

5

X1

Y1

6

(1 Mark)

X3

Y3

1

Topic: Application Layer Protocols (DNS, SMTP, POP, FTP, HTTP) (b)  SMTP or simple mail transfer protocol is an application layer protocol used to send e-mail. POP3 or post office protocol 3 is a client/server protocol in which e-mail is received. Therefore, option (b) is correct. SMTP and POP3 protocols are used to send and retrieve e-mails.

51. Which of the following protocol pairs can be used to send and retrieve e-mails (in that order)? (a) IMAP, POP3 (b) SMTP, POP3 (c) SMTP, MIME (d) IMAP, SMTP

R Y

V

Y1

V1

Y3

V2

Y2

V3

Y2

V2

How many tuples will be returned by the following relational algebra query? Π X (σ ( P ⋅Y = R ⋅Y ∧ R ⋅V =V 2 ) ( P × R)) − Π X (σ ( Q ⋅Y = R ⋅Y ∧Q ⋅T >2 ) (Q × R)) (2 Marks)

52. Consider three machines M, N and P with IP addresses 100.10.5.2, 100.10.5.5 and 100.10.5.6, respectively. The subnet mask is set to 255.255.255.252 for all the three machines. Which one of the following is true? (a) M, N and P all belong to the same subnet (b) Only M and N belong to the same subnet (c) Only N and P belong to the same subnet (d) M, N, and P belong to three different subnets (2 Marks)

Topic: IPv4/IPv6, Routers and Routing Algorithms (Distance Vector, Link State) (c)  Given IP address of M is 100.10.5.2 Π X (σ ( P ⋅ Y = R ⋅ Y ∧ R ⋅ V = V 2 ) ( P × R)) IP address of N is 100.10.5.5 − Π X (σ ( Q ⋅ Y = R ⋅ Y ∧Q ⋅ T >2 ) (Q × R)) IP address of P is 100.10.5.6 Subnet mask is 255.255.255.252 Consider Subset address of M is X π X (σ P ⋅ Y = R ⋅ Y ∧ R ⋅ V = V 2 ( P × R)) = 100. 10 . 5 . 2 X2 255.255.255.252 Similarly, 194. 56. 10. 0 Subnet address of N is X π X (σ Q ⋅ Y = R ⋅ Y ∧Q ⋅ T > (Q × R)) = 100. 10 . 5 . 5 X1 255.255.255.252 Hence, 194. 56. 10 . 4 X X Π X (σ P ⋅Y = R⋅Y ∧ R⋅V =V 2 ( P × R)) − Π X (σ Q ⋅Y = R⋅Y ∧ Q ⋅T > 2 (Q × R)) = − Set address of P is X2 X 100. 10 . 5 . 6 1 255.255.255.252 X X Π X (σ P ⋅Y = R⋅Y ∧ R⋅V =V 2 ( P × R)) − Π X (σ Q ⋅Y = R⋅Y ∧ Q ⋅T > 2 (Q × R)) = − 194. 56. 10 . 4 X 2 X1 Thus, N and P belong to the same subnet. Option (c) is Thus, the query will generate 1 tuple only. correct. Topic: R  elational Model: Relational Algebra, Tuple Calculus, SQL (1)  Given query

GATE_CSIT_2019.indd 16

6/24/2019 2:23:39 PM

appendix  •  Solved GATE (CSIT) 2019

53. Suppose that in an IP-over-Ethernet network, a machine X wishes to find the MAC address of another machine Y in its subnet. Which one of the following techniques can be used for this? (a)  X sends an ARP request packet to the local gateway’s IP address which then finds the MAC address of Y and sends to X (b)  X sends an ARP request packet to the local gateway’s MAC address which then finds the MAC address of Y and sends to X (c)  X sends an ARP request packet with broadcast MAC address in its local subnet (d)  X sends an ARP request packet with broadcast IP address in its local subnet (2 Marks)

55. In an RSA cryptosystem, the value of the public modulus parameter n is 3007. If it is also known that ϕ ( n) = 2880, where ϕ ( ) denotes Euler’s Totient Function, then the prime factor of n which is greater than 50 is . (2 Marks) Topic: Network Security: Authentication, Basics of Public Key and Private Key Cryptography, Digital Signatures and Certificates, Firewalls (97)  RSA cryptosystem is an algorithm used by modern computers to encrypt and decrypt message. The algorithm is: Generate two large random numbers p and q of equal size such that their product n = pq is of desired length. Compute ϕ = ( p − 1)( q − 1)

Topic: L  AN Technologies (Ethernet) (c)  In an IP-over-Ethernet network, IP packets are uncapsulated in standard Ethernet frames and delivered over Ethernet-based access network. If machine X wishes to find the MAC address of another machine Y in its subnet, X sends an ARP request packet with broadcast MAC address in its local subnet. (ARP or address resolution protocol is used for discovering link layer address like MAC address of a host from on IP address.) 54. Consider that 15 machines need to be connected in a LAN using 8-port Ethernet switches. Assume that these switches do not have any separate uplink ports. The minimum number of switches needed is . (2 Marks) Topic: LAN Technologies (Ethernet) (3)  It is required to convert 15 machines in a LAN using 8-port Ethernet switches. These can be connected as 1

2

3

4

5

6

7

1

2

3

4

5

6

7

13

12

11

10

9

8

7

6

5

4

3

2

1

14

15

2

3

4

5

6

7

8

8

1

8

A17

Choose an integer e, 1 < e < ϕ such that gcd(e, ϕ ) = 1 Here given, n = 3007

 ϕ ( n) = 2880  n = p × q = 3007



ϕ ( n) = ( p − 1)( q − 1) = 2880 (2)

(1)

(2) ⇒ pq - q - p + 2 = 2880 ⇒ 3007 - p - q + 2 = 2880 ⇒ p + q = 3007 + 2 - 2880 = 129 ⇒ p = (129 - q)



Putting in Eq. (1), we get (129 - q)q = 3007 ⇒ -q2 + 129q = 3007

⇒ q2 - 129q + 3007 = 0

Therefore, 129 ± (129) 2 − 4 × 3007 2 129 ± 68 = = 98.5, 30.5 2

q=

So, for q ~ 31, p = 97. Equations (1) and (2) are satisfied, but prime factor of n should be greater than 50. Hence, the correct answer to the question is 97.

Thus, the minimum number of switches needed is three.

GATE_CSIT_2019.indd 17

6/24/2019 2:23:42 PM

GATE_CSIT_2019.indd 18

6/24/2019 2:23:42 PM

Solved GATE (CSIT) 2020

aPPENDIX

QUESTIONS Chapter 1: Engineering Mathematics 1.

Consider the functions I. e − x II. x 2 – sin x

Topic: Discrete Mathematics (a)  Given that, T(n) = T(n1/a) + 1 and T(b) = 1 where parameters a and b are ω(1). Using master theorem which provides a solution to recurrence relations of the form ⎛n⎞ T ( n) = aT ⎜ ⎟ + f ( n) ⎝b⎠

x3 + 1

III.

Which of the above functions is/are increasing everywhere in [0, 1]? (a) III only (b) II only (c) II and III only (d) I and III only

for constants a > 1 and b > 1 with f asymptotically positive, we have T(n) is Θ(log a log b n). 3.

(1 Mark)

Let R be the set of all binary relations on the set {1, 2, 3}. Suppose a relation is chosen from R at random. The probability that the chosen relation is reflexive (round off to 3 decimal places) is .

x 3 + 1 are

(1 Mark)

Topic: Discrete Mathematics (a)  Given functions e–x, x2 – sin x and shown in the following figure. f(x)

f(x)

1 e–x x

x x2 − sin x  

I

Topic: Discrete Mathematics (0.125)  Given, set {1, 2, 3} A relation R on a set A is reflexive if ( a, a) ∈ R holds for every element a ∈ R. That is, if set A = {a, b} then R = {(a, a), (b, b)} is reflexive relation. Here A = {1, 2, 3} so, number of elements n = 3. 2

II

f(x)

n2 − n

32 − 3

9−3

x P= III So, only function III is increasing everywhere in [0, 1]. For parameters a and b, both of which are ω (1), T ( n) = T ( n1/ a ) + 1, and T(b) = 1. Then T(n) is (a) Θ(log a log b n) (b) Θ(log ab n) (c) Θ(log b log a n) (d) Θ(log 2 log 2 n) (1 Mark)

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 1

are

2 =2 =2 =2 Therefore, probability that chosen relation is reflexive is

√x3 + 1

2.

2

Then, number of relations on A are 2n = 23 = 29 So, number of reflexive relations on A

4.

6

26 1 1 = = = 0.125 2 9 23 8

Let G be a group of 35 elements. Then the largest possible size of a subgroup of G other than G itself is . (1 Mark)

Topic: Discrete Mathematics (7) Given, G is a group having 35 elements. According to Lagrange’s theorem, for any finite group G, the order of every subgroup H of G divides the order of G.

8/14/2020 9:44:13 AM

B2

GATE CSIT Chapter-wise Solved papers

For group G having 35 elements possible size of subgroup of G are 1, 5, 7, 35, so largest possible size of a subgroup of G other than G itself is 7. 5.

Topic: Probability (0.5)  Given that, a ∈{0,1}n is non-zero vector and x is chosen uniformly form {0, 1}n.

Let A and B be two n × n matrices over real numbers. Let rank(M) and det(M) denote the rank and determinant of a matrix M, respectively. Consider the following statements. I. rank(AB) = rank(A)rank(B) II. det(AB) = det(A)det(B) III. rank(A + B) ≤ rank(A) + rank(B) IV. det(A + B) ≤ det(A) + det(B)

n

Let probability that

i =1

So, statement II and III are correct. 6.

The number of permutations of the characters in LILAC so that no character appears in its original position, if the two L’s are indistinguishable, is .

_L_L_, _L_ _L, _ _ _LL Now C can be arranged as CL_L_, _LCL_, CL_ _ L, _LC_L, C _ _ LL, _C_LL, _ _CLL, _L_CL A and I can be arranged as CLILA, CLALI, ILCLA, ALCLI, CLAIC, ALCIL, CAILL, ICALL, ACILL, IACLL, ILACL, AILCL

i i

to n

Therefore, P = nC1 + n C3 +  =

2n −1 1 = = 0.5 2 2n

Chapter 2: Digital Logic 8.

A multiplexer is placed between a group of 32 registers and an accumulator to regulate data movement such that at any given point in time the content of only one register will move to the accumulator. The minimum number of select lines needed for the multiplexer is . (1 Mark)

Topic: Combinational and Sequential Circuits (5)  Given, number of registers = 32 then, multiplexer required is 32 : 1. So, minimum number of select lines needed for multiplexer is log232 = log225 = 5. Therefore, minimum number of select lines is 5. 9.

If there are m input lines and n output lines for a decoder that is used to uniquely address a byte addressable 1 KB RAM, then the minimum value of m + n is .

(2 Marks) Topic: Probability (12)  Given, L’s are indistinguishable and no character can appear in its original position. So, L’s can be arranged in LILAC in 3 ways

is odd number be P.

So, total cases = 2n.

rank( A + B ) ≤ rank( A) + rank( B ) rank( AB ) = min{rank( A) rank( B )} det( AB ) = det( A) det( B) det( A + B) ≠ det( A) + det( B )

∑a x ∈0 i =1

Topic: Linear Algebra (c)  From matrix rank properties, we have

From matrix determinant properties, we have

i i

n

Here

Which of the above statements are TRUE? (a) I and II only (b) I and IV only (c) II and III only (d) III and IV only (2 Marks)

∑a x

(1 Mark) Topic: Combinational and Sequential Circuits (1034)  A decoder is a combinational circuit that has a n inputs and maximum of 2n output lines. We know, number of output lines needed to uniquely address a byte addressable of 1 kB RAM is 210. ⇒ m = 10 So, number of input lines are m = 10 and number of output lines are n = 210 = 1024. Therefore, minimum value of m + n is 10 + 1024 = 1034. 10. Consider the Boolean function z(a, b, c).

So, number of permutations is 12. a

7.

For n > 2, let a ∈{0, 1}n be a non-zero vector. Suppose that x is chosen uniformly at random from {0, 1}n. Then, the probability that is .

∑ i =1 ai xi is an odd number

z b

n

c

(2 Marks)

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 2

8/14/2020 9:44:14 AM

appendix  •  Solved GATE (CSIT) 2020

Which one of the following minterm lists represents the circuit given above? (a) z = ∑ (0, 1, 3, 7) (b) z = ∑ (1, 4, 5, 6, 7)

(c) z = ∑ ( 2, 4, 5, 6, 7)

(d) z = ∑ ( 2, 3, 5)

(2 Marks) Topic: C  ombinational and Sequential Circuits (b)  We have a

z

b b

Chapter 3: Computer Organization and Architecture 12. A computer system with a word length of 32 hits has a 16 MB byte-addressable main memory and a 64 KB, 4-way set associative cache memory with a block size of 256 bytes. Consider the following four physical addresses represented in hexadecimal notation. A1 = 0x42C8A4, A2 = 0x546888, A3 = 0x6A289C, A4 = 0x5E4880 Which one of the following is TRUE? (a) A1 and A4 are mapped to different cache sets. (b) A2 and A3 are mapped to the same cache set. (c) A3 and A4 are mapped to the same cache set. (d) A1 and A3 are mapped to the same cache set. (2 Marks)

b ⋅c

Topic: Machine Instructions and Addressing Modes (b)  We have A1 = C8A4 = 11001000 A2 = 6888 = 01101000 A3 = 289C = 01101000 A4 = 4880 = 01001000 Therefore, A2 and A3 are mapped to the same cache set.

c

Here z = a + b ⋅ c The K-map of output z is bc 00 01 11 10 a 2 0 0 11 3 1 14 15 17 16 Therefore, minterm list is z = ∑ (1, 4, 5, 6, 7) 11. Consider three registers R1, R2, and R3 that store numbers in IEEE-754 single precision floating point format. Assume that R1 and R2 contain the values (in hexadecimal notation) 0x42200000 and 0xC1200000, respectively. (b) 0xC0800000 (d) 0xC8500000 (2 Marks) Topic: N  umber Representations and Computer Arithmetic (Fixed and Floating Point) (b)  Given that, R1 = 0x42200000 and R2 = 0xC1200000 So, R3 =

R1 42200000 = R2 C1200000

0 10000100 010 +132010 = = 1 10000010 010 −13010 = − | 2 + 127 | 000 = 1 | 10000001 | 000 = C08 Therefore, R3 = 0xC0800000

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 3

13. Which one of the following predicate formulae is NOT logically valid? Note that W is a predicate formula without any free occurrence of x. (a) ∀x( p( x ) ∨ W ) ≡ ∀xp( x ) ∨ W (b) ∃x( p( x ) ∧ W ) ≡ ∃xp( x ) ∧ W (c) ∀x( p( x ) → W ) ≡ ∀xp( x ) → W

If R3 = R1 /R2 , what is the value stored in R3? (a) 0x40800000 (c) 0x83400000

B3

(d) ∃x( p( x ) → W ) ≡ ∀xp( x ) → W (2 Marks) Topic: Machine Instructions and Addressing Modes (c) Here ∀x( p( x ) → W ) ≡ ∀xp( x ) → W is not logically valid. LHS : ( p1 ∧ p2 ∧ p3 ∧  pn ) → W RHS : p1 → W , p2 → W 14. Consider a non-pipelined processor operating at 2.5 GHz. It takes 5 clock cycles to complete an instruction. You are going to make a 5-stage pipeline out of this processor. Overheads associated with pipelining force you to operate the pipelined processor at 2 GHz. In a given program, assume that 30% are memory instructions, 60% are ALU instructions and the rest are branch

8/14/2020 9:44:16 AM

B4

GATE CSIT Chapter-wise Solved papers

instructions. 5% of the memory instructions cause stalls of 50 clock cycles each due to cache misses and 50% of the branch instructions cause stalls of 2 cycles each. Assume that there are no stalls associated with the execution of ALU instructions. For this program, the speedup achieved by the pipelined processor over the non-pipelined processor (round off to 2 decimal places) is . (2 Marks) Topic: Instruction Pipelining (2.16)  Given that, clock speed of non-pipelined processor = 2.5 GHz, clock cycles required to complete on instruction = 5, clock speed for pipelined processor = 2 GHz, memory instruction = 30%, ALU instruction = 60% and branch instruction = 10%. 5% memory instruction cause stalls of 50 clock cycles 50% branch instruction cause stalls of 2 cycles Now, cycle time of non-pipelined processor 1 = 0.4 ns 2.5 GHz Time taken to finish instructions = 5 × 0.4 ns = 2 ns 1 = 0.5 ns 2 GHz Memory instructions = 30% ⇒ Number of instructions = 0.3n % causing stalls = 5% of 0.3n Therefore, number of stall cycles = 50 ALU instructions = 60% ⇒ Number of instructions = 0.6n % causing stalls = 0 Therefore, number of stall cycles = 0 Branch instructions = 10% ⇒ Number of instructions = 0.1n % causing stalls = 50% of 0.1n Therefore, number of stall cycles = 2 So, time taken to finish instruction is Cycle time of pipelined processor =

0.6n(1) + 0.3n(0.05(1 + 50) + 0.95(1)) 2 0.1n(0.5 (11 + 2) + 0.5(1)) + 2 1.85n = = 0.925 ns 2 Therefore, speed up is time taken to finish nonpiplined time taken to finish pipelined 2 ns = = 2.16 0.925 ns

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 4

15. A processor has 64 registers and uses 16-bit instruction format. It has two types of instructions: I-type and R-type. Each I-type instruction contains an opcode, a register name, and a 4-bit immediate value. Each R-type instruction contains an opcode and two register names. If there are 8 distinct I-type opcodes, then the maximum number of distinct R-type opcodes is . (2 Marks) Topic: Machine Instructions and Addressing Modes (14)  Given that, registers = 64, instruction format = 16-bit, type of instruction = I-type and R-type. I-type instruction contains opcode register name and 4-bit immediate value. R-type instruction contains opcode two register names. I-type opcodes = 8 Now, 64 registers require log2(64) = 6 bits For 16-bit instruction format I type instruction + R type instruction = 216 ⇒ (opcode × Register × Immediate value) + (opcode × 2 registers) = 216 ⇒ (8 × 26 × 24) + (x × 26 × 26) = 216 ⇒ 213 + x × 212 = 216 ⇒ x × 212 = 216 – 213 216 − 213 = 16 − 2 = 14 212 So, maximum number of distinct R-type opcodes is 14. ⇒ x=

16. Consider a paging system that uses 1-level page table residing in main memory and a TLB for address translation. Each main memory access takes 100 ns and TLB lookup takes 20 ns. Each page transfer to/from the disk takes 5000 ns. Assume that the TLB hit ratio is 95%, page fault rate is 10%. Assume that for 20% of the total page faults, a dirty page has to be written back to disk before the required page is read in from disk, TLB update time is negligible. The average memory access time in ns (round off to 1 decimal places) is . (2 Marks) Topic: Memory Hierarchy: Cache, Main Memory and Secondary Storage (154.5)  Given that, main memory access takes 100 ns, TLB lookup takes 20 ns, file transfer takes 5000 ns, hit ratio = 95% = 0.95 so miss ratio = 5% = 0.05, fault rate = 10% = 0.10 and dirty page is written for 20% total page faults = 0.2. Therefore, average memory access time = 0.95( 20 + 100) + 0.05( 20 + 100 + 100) + 0.1(0.2( 20 + 100 + 5000 + 5000) + 0.8( 20 + 100 + 5000)) = 154.5 ns

8/14/2020 9:44:17 AM

appendix  •  Solved GATE (CSIT) 2020

Chapter 4: Programming and Data Structures 17. The pre-order traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19. Which one of the following is the post-order traversal of the tree? (a) 10, 11, 12, 15, 16, 18, 19, 20 (b) 11, 12, 10, 16, 19, 18, 20, 15 (c) 20, 19, 18, 16, 15, 12, 11, 10 (d) 19, 16, 18, 20, 11, 12, 10, 15 (1 Mark) Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (b)  In pre-order traversal, root node is visited first, left node is visited next and right node is visited in the last. In post-order traversal, left node is visited first, right node is visited next and root node is visited in the last. Given pre-order traversal is 15, 10, 12, 11, 20, 18, 16, 19, the post-order traversal is 11, 12, 10, 16, 19, 18, 20, 15. 18. What is the worst case time complexity of inserting n2 elements into an AVL-tree with n elements initially? (a) Θ( n4 ) (b) Θ( n2 ) (c) Θ( n2 log n) (d) Θ( n3 ) (1 Mark) Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (c)  AVL-tree is a self balancing binary tree where the difference between heights of left and right subtrees cannot be more than one for all nodes. The time complexity of AVL insert is Θ( h) where h is height of tree. For AVL-tree with n elements, time complexity of insert is Θ(log n) since height of balanced AVL-tree is Θ(log n). So, time complexity of inserting n2 elements

end with 1 and a string of odd number of 1’s need not to end with 1. Option (B): regular expression (0*10*10*)*0*1 will force it to start with 1 and hence it is incorrect. Option (C): regular expression 10*(0*10*10*)* can create odd number of 1’s as well as even number of 1’s and hence it is incorrect. Option (D): regular expression (0*10*10*)*10* is incorrect as it does not generate strings ‘01’ or 1 or more 0 followed by 1 which is having an odd number of 1’s. 20. What is the worst case time complexity of inserting n elements into an empty linked list, if the linked list needs to be maintained in sorted order? (a) Θ( n) (b) Θ( n log n) (c) Θ( n2 ) (d) Θ(1) (1 Mark) Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (c)   Linked list is a linear collection of data elements. It is simplest and most common data structures. In the worst case, the element is to be inserted at the end of the linked list so the time complexity will be Θ( n2 ). 21. Consider the following C program. #include int main( ) { int a[4][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20} }; printf (“%d\n”. *(*(a+**a+2)+3)); return (0); } The output of the program is . (1 Mark)

is Θ( n2 log n). 19. Which one of the following regular expressions represents the set of all binary strings with an odd number of 1’s? (a) ((0 + l)*1(0 + l)*l)*10* (b) (0*10*10*)*0*1 (c) 10*(0*10*10*)* (d) (0*10*10*)*10* (1 Mark) Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (*)  Option (A): regular expression ((0 + l)*1(0 + l)*l)*10* is incorrect because it will force the strings to

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 5

B5

Topic: Programming in C (19)  Given that, ⎡ 1 2 3 4 5⎤ ⎢ 6 7 8 9 10 ⎥ ⎥ a[4][5] = ⎢ ⎢11 12 13 14 15⎥ ⎢ ⎥ ⎣16 17 18 19 20 ⎦ So, *(*(a + **a + 2) + 3)) is a44 element, so output is 19. 22. Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.

8/14/2020 9:44:18 AM

B6

GATE CSIT Chapter-wise Solved papers

CODE SECTION P wait (a); count=count+l; if (count==n) signal(b); signal(a); wait(b); signal(b); CODE SECTION Q What does the code achieve? (a)  It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P. (b) It ensures that at most two processes are in CODE SECTION Q at any time. (c)  It ensures that all processes execute CODE SECTION P mutually exclusively. (d) It ensures that at most n – 1 processes are in CODE SECTION P at any time. (2 Marks) Topic: Programming in C (a)  The given code ensures that no process executes code section Q before every process has finished code section P because wait(b) will block all processes till count==n. 23. Let G = (V, E) be a directed, weighted graph with weight function w : E → . For some function f : V → , for each edge (u, v ) ∈ E , define w ′(u, v ) as w (u, v ) + f (u ) − f ( v ). Which one of the options completes the following sentence so that it is TRUE? “The shortest paths in G under w are shortest paths under w ′ too, ”. (a) for every f : V →  (b) if and only if ∀u ∈ V , f (u ) is positive (c) if and only if ∀u ∈ V , f(u) is negative (d) if and only if f(u) is the distance from s to u in the graph obtained by adding a new vertex s to G and edges of zero weight from s to every vertex of G (2 Marks) Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (a)  The shortest paths in G under w are shortest paths under w ′ too, for every f : V →  . 24. In a balanced binary search tree with n elements, what is the worst case time complexity of reporting all elements in range [a, b]? Assume that the number of reported elements is k. (a) Θ(log n) (b) Θ(log n + k ) (c) Θ( k log n) (d) Θ( n log k )

(2 Marks)

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 6

Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (b)  A balanced tree is defined as binary tree in which the left and right subtrees of every node differ in height by no more than one. In balanced binary search tree with n elements, the worst case time complexity of reporting all element in range [a, b] is Θ(log n + k ), where k is number of reported elements. 25. Consider the following C functions. int fun1(int n) { static int i = 0; if (n > 0) { ++i; fun1(n−l); } return(i); }

int fun2(int n) { static int i = 0; if (n > 0) { i = i + fun1(n); fun2(n−1); } return(i); }

The return value of fun2(5) is

. (2 Marks)

Topic: Programming in C (55)  We have fun2(5) → i = 0, fun1(5) and fun2(4) fun1(5) → i = 1, fun1(4) fun1(4) → i = 2, fun1(3) fun1(3) → i = 3, fun1(2) fun1(2) → i = 4, fun1(1) fun1(1) → i = 5, fun1(0) loop exits fun2(4) → i = 5 + fun1(4) and fun2(3) fun1(4) → i = 6, fun1(3) fun1(3) → i = 7, fun1(2) fun1(2) → i = 8, fun1(1) fun1(1) → i = 9, fun1(0) loop exists Therefore, fun2(4) → i = 5 + 9 and fun2(3) fun2(3) → i = 14 + fun1(3) and fun2(3) fun1(3) → i = 10, fun1(2) fun1(2) → i = 11, fun1(1) fun1(1) → i = 12, fun1(0) loop exists Therefore, fun2(3) → i = 14 + 12 and fun2(2) and so on, we will have i = 5 + 9 + 12 + 14 + 15 So, return value of fun2(5) is 55. 26. Consider the array representation of a binary min-heap containing 1023 elements. The minimum number of comparisons required to find the maximum in the heap is . (2 Marks)

8/14/2020 9:44:19 AM

appendix  •  Solved GATE (CSIT) 2020

Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (511)  A binary heap is a complete binary tree. In minheap, the key at root must be minimum among all keys present in binary heap. Given, binary min-heap contains 1023 elements. So, 1023 Total number of levels = = 511 or 512 2 Therefore, minimum number of comparisons required to find maximum in the heap is 511.

int pp(int a, int b) { int arr[20]; int i, tot = 1, ex, len; ex = a; len = tob(b, arr); for(i=0; i0; i ++) { if (b%2) arr[i] = 1; else arr[i]=0; b = b/2; } return(i); }

B7

. (2 Marks)

29. Consider a double hashing scheme in which the primary hash function is h1 ( k ) = k mod 23, and the secondary hash function is h2 ( k ) = 1 + ( k mod 19). Assume that the table size is 23. Then the address returned by probe 1 in the probe sequence (assume that the probe sequence begins at probe 0) for key value k = 90 is . (1 Mark) Topic: Searching, Sorting, Hashing (13)  Given that, primary hash h1 ( k ) = k mod 23, secondary hash h2 ( k ) = 1 + ( k mod 19) and table size = 23.

function function,

Double hashing is a collision resolving technique in open addressed hash tables. It was the idea of applying a second hash function to key when a collision occurs. Address return by double hashing is given by ( h1 ( k ) + i * h2 ( k )) ÷ Table size For probe 1, i = 1 and given, k = 90. So,

Topic: Programming in C (81)  We have pp(3, 4) ⇒ a = 3, b = 4, tot = 1, ex = 3

(90 mod 23 + 1 + 90 mod 19) mod 23 = ( 21 + 1 + 14) mod 23 = 36 mod 23 = 13

len = tob(b, arr) = 3 i = 0; arr[0] = = 1; ex = 3 × 3 = 9 i = 1; arr[1] = = 1; ex = 9 × 9 = 81 i = 2; arr[2] = = 1; tot = 1 × 81 = 81 and ex = 81 × 81 = 6561 Therefore, value returned by pp(3, 4) is 81 28. Graph G is obtained by adding vertex s to K3,4 and making s adjacent to every vertex of K3,4. The minimum number of colours required to edge-colour G is .

30. Let G = (V, E) be a weighted undirected graph and let T be a minimum spanning tree (MST) of G maintained using adjacency lists. Suppose a new weighted edge ( u , v )∈ � V × V is added to G. The worst case time complexity of determining if T is still an MST of the resultant graph is (a) Θ( E + V ) (b) Θ( E V ) (c) Θ( E log V ) (d) Θ( V )

(2 Marks)

(2 Marks)

Topic: Arrays, Stacks, Queues, Linked Lists, Trees, Binary Search Trees, Binary Heaps, Graphs (7)  A complete bipartite graph Kn,m is a graph where every vertex of first set(n) is connected to every vertex of second set(m). For, K3,4 we have

Topic: Graph Search, Minimum Spanning Trees, Shortest Paths (d)  Given that, G = (V, E) is weighted undirected graph. T is minimum spanning tree (MST) of G and new weighted edge (u, v ) ∈ V × V is added to G. Here the

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 7

8/14/2020 9:44:20 AM

B8

GATE CSIT Chapter-wise Solved papers

minimum spanning tree in worst case will have (|V | – 1) edges, so the worst case time complexity of determining if T is still on MST of the resultant graph is Θ( V ). 31. Consider a graph G = (V, E), where V = {v1, v2, …, v100}, E = {(vi, vj) |1 ≤ i < j ≤ 100}, and weight of die edge (vi, vj) is |i – j|. The weight of minimum spanning tree of G is . (2 Marks) Topic: Graph Search, Minimum Spanning Trees, Shortest Paths (99)  Given that, graph G = (V, E) where V = {v1, v2, … v100}, E = {vi , v j ) | 1 ≤ i < j ≤ 100} and weight of the edge (vi, vj) is |i – j|. If vertices are consecutive, that is, 1 – 2 – 3 … 100, then we obtain spanning tree with minimum weight. So, number of edges in spanning tree = 99 and cost of each edge = 1. Therefore, weight of spanning tree = 99 × 1 = 99.

Chapter 6: Theory of Computation 32. Consider the following statements. I. If L1 ∪ L2 is regular, then both L1 and L2 must be regular. II. The class of regular languages is closed under infinite union. Which of the above statements is/are TRUE? (a) I only (b) II only (c) Both I and II (d) Neither I nor II (1 Mark) Topic: Regular and Contex-Free Languages, Pumping Lemma (d)  Statement I: If L1 ∪ L2 is regular, then both L1 and L2 must be regular – this statement is false, L1 and L2 may not be regular. Statement II: The class of regular language is closed under infinite union – this statement is false, the class of regular languages is not closed under infinite union. 33. Consider the language L = {a n | n ≥ 0} ∪ {a n b n | n ≥ 0} and the following statements. I. L is deterministic context-free. II. L is context-free but not deterministic context-free. III. L is not LL(k) for any k. Which of the above statements is/are TRUE?

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 8

(a) I only (c) I and III only

(b) II only (d) III only (1 Mark)

Topic: Context-Free Grammars and Push-Down Automata (c)  Given language is L = {a n | n ≥ 0} ∪ {a n b n | n ≥ 0} here L is deterministic context free. So, statement I is true and II is false. Statement III is true – we cannot write LL(k) grammar for any k. 34. Consider the following grammar. S → aSB|d B→b The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is . (1 Mark) Topic: Context-Free Grammars and Push-Down Automata (7)  Given grammar is S → asB|d B→b Bottom-up parsing attempts to reduce the input string W to the start symbol of grammar by tracing out the rightmost divisions of W in reverse S → asB → aasBB [S → asB] → aaasBBB [S → asB] → aaadBBB [S → d] → aaadbBB [B → b] → aaadbbB [B → b] → aaadbbb [B → b] So, total number of reduction steps = 7 35. Which of the following languages are undecidable? Note that M indicates encoding of the Turing machine M. L1 = { M | L( M ) = ϕ } L2 = { M , w , q | M on input w reaches state q in exactly 100 steps} L3 = { M | L( M ) is not recursive} L4 = { M | L( M ) contains at least 21 members} (a) L1, L3, and L4 only (c) L2 and L3 only

(b) L1 and L3 only (d) L2, L3, and L4 only (2 Marks)

8/14/2020 9:44:22 AM

B9

appendix  •  Solved GATE (CSIT) 2020

Topic: Turing Machines and Undecidability (a)  Given that,

A

B

C

D

E

F

L1 = { M | L M = ϕ } , this is non-trivial condition and therefore undecidable. L2 = { M , w , q | M } on input w reaches state q in exactly 100 steps}, this will reach exactly in 100 steps, therefore decidable. L3 = { M | L( M ) is not recursive} , this is non-trivial condition and therefore undecidable. L4 = { M | L( M ) contains at least 21 members} , this is non-trivial condition because some turing machines accept more than 21 strings and some less and is therefore undecidable. So, L1, L2, L4 are undecidable. 36. Consider the following languages. L1 = {wxyx | w , x, y ∈ (0 + 1) + } L2 = {xy | x, y ∈ ( a + b)* , x = y , x ≠ y} Which one of the following is TRUE? (a) L1 is regular and L2 is context-free. (b)  L1 is context-free but not regular and L2 is context-free. (c) Neither L1 nor L2 is context-free. (d) L1 is context-free but L2 is not context-free. (2 Marks) Topic: Regular and Contex-Free Languages, Pumping Lemma (a)  Given that, L1 = {wxyx | w , x, y ∈(0 + 1) + } and L2 = {xy | x, y ∈ ( a + b)* , | x | = | y |, x ≠ y}. Here language L1 is regular because lexical rules are quite simple and L2 is context-free because lexical rules are difficult and complex.

So, minimum number of states are 6.

Chapter 7: Compiler Design 38. Consider the following statements. I. Symbol table is accessed only during lexical analysis and syntax analysis. II. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment. III. Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis. Which of the above statements is/are TRUE? (a) I only (b) I and III only (c) II only (d) None of I, II, and III (1 Mark) Topic: Lexical Analysis, Parsing, Syntax-Directed Translation (d)  Statement I: Symbol table is accessed only during lexical analysis and syntax analysis – this statement is false as symbol table is accessed by most phases of complier. Statement II: Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment – this statement is false as compilers are not necessarily need heap storage for memory allocation. Statement III: Errors violating the condition ‘any variable must be declared before its use’ are detected during syntax analysis – this statement is false as syntax analysis checks only syntax, but variable declared before its use are detected by Semantic analyses.

37. Consider the following language. L = {x ∈ {a, b}* | number of a’s in x is divisible by 2 but not divisible by 3} The minimum number of states in a DFA that accepts L is . (2 Marks) Topic: Regular Expressions and Finite Automata (6)  Given that, L = {x ∈ {a, b}* | number of a’s in x is divisible by 2 but not divisible by 3} In deterministic finite automata for a particular input character, the machine goes to one state only.

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 9

Chapter 8: Operating System 39. Consider the following statements. I. Daisy chaining is used to assign priorities in attending interrupts. II. When a device raises a vectored interrupt, the CPU does polling to identify the source of interrupt. III. In polling, the CPU periodically checks the status bits to know if any device needs its attention. IV. During DMA, both the CPU and DMA controller can be bus masters at the same time. Which of the above statements is/are TRUE?

8/14/2020 9:44:23 AM

B10

GATE CSIT Chapter-wise Solved papers

(a) I and II only (c) I and III only

(b) I and IV only (d) III only (1 Mark)

Topic: CPU Scheduling (c)  Statement I: Daisy chaining is used to assign priorities in attending interrupts – this is true. Statement II: When a device raises a vectored interrupt, the CPU does polling to identify the source of interrupt – this statement is false because only the data bus of CPU does polling to identify the source of interrupt. Statement III: In polling, the CPU periodically checks the status bits to know if any device needs its attention – this statement is true. Statement IV: During DMA, both the CPU and DMA controller can be bus masters at the same time – this is false because only the CPU controller can be bus master. So, statements I and III are true. 40. Consider the following data path diagram. BUS TEMP1 MAR MDR IR PC

R0 R1 TEMP2 ALU

To Memory R7

Consider an instruction: R0 ← Rl + R2. The following steps are used to execute it over the given data path. Assume that PC is incremented appropriately. The subscripts r and w indicate read and write operations, respectively. 1. R2r, TEMP1r, ALUadd, TEMP2w 2. R1r, TEMP1w 3. PCr, MARw, MEMr 4. TEMP2r, R0w 5. MDRr, IRw Which one of the following is the correct order of execution of the above steps? (a) 2, 1, 4, 5, 3 (b) 1, 2, 4, 3, 5 (c) 3, 5, 2, 1, 4 (d) 3, 5, 1, 2, 4 (1 Mark) Topic: Processes, Threads, Inter-Process Communication, Concurrency and Synchronization (c)  The correct order of execution is PCr, MARw, MEMr → MDRr, IRw → R1r, TEMP1w → R2r, TEMP1r, ALUadd, TEMP2w → TEMP2r, ROw. So, the correct order is 3, 5, 2, 1, 4.

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 10

41. Consider allocation of memory to a new process. Assume that none of the existing holes in the memory will exactly fit the process’s memory requirement. Hence, a new hole of smaller size will be created if allocation is made in any of the existing holes. Which one of the following statements is TRUE? (a) The hole created by first fit is always larger than the hole created by next fit. (b) The hole created by worst fit is always larger than the hole created by first fit. (c) The hole created by best fit is never larger than the hole created by first fit. (d) The hole created by next fit is never larger than the hole created by best fit. (1 Mark) Topic: Memory Management and Virtual Memory (c)  Best fit looks for smallest block that will accommodate the request. Worst fit looks for largest block that will accommodate the request. First fit selects the first block. So, the hole created by best fit is never larger than the hole created by first fit. 42. Consider the following statements about process state transitions for a system using preemptive scheduling. I. A running process can move to ready state. II. A ready process can move to running state. III. A blocked process can move to running state. IV. A blocked process can move to ready state. Which of the above statements are TRUE? (a) I, II, and III only (b) II and III only (c) I, II and IV only (d) I, II, III, and IV (1 Mark) Topic: CPU Scheduling (c)  Preemptive scheduling is a scheduling done when the process changes from running state to ready state or from waiting for state to ready state. So, for a system using preemptive scheduling following process state transitions are true     (I) A running process to ready state    (II) A ready process to running state (IV) Blocked process to ready state 43. A direct mapped cache memory of 1 MB has a block size of 256 bytes. The cache has an access time of 3 ns and a hit rate of 94%. During a cache miss, it takes 20 ns to bring the first word of a block from the main memory, while each subsequent word takes 5 ns. The word size is 64 bits. The average memory access time in ns (round off to 1 decimal place) is . (1 Mark)

8/14/2020 9:44:23 AM

appendix  •  Solved GATE (CSIT) 2020

Topic: M  emory Management and Virtual Memory (13.5)  Given that, cache memory size = 1 MB, block size = 256 bytes, word size = 64 bits = 8 bytes, access time = 3 ns, hit rate = 94% = 0.94 so, miss rate = 1 – 0.94 = 0.06. During cache miss 1, time to bring first word from main memory = 20 ns and subsequent word takes 5 ns Therefore, average time is (0.94 × 3) + 0.06(3 + 20 + 31 × 5) = 2.82 + 0.06 × 1.78 = 2.82 + 10.68 = 13.5 ns 44. Consider the following five disk access requests of the form (request id, cylinder number) that are present in the disk scheduler queue at a given time. (P, 155), (Q, 85), (R, 110), (S, 30), (T, 115) Assume the head is positioned at cylinder 100. The scheduler follows Shortest Seek Time First scheduling to service the requests. Which one of the following statements is FALSE? (a)  T is serviced before P. (b) Q is serviced after S, but before T. (c)  The head reverses its direction of movement between servicing of Q and P. (d) R is serviced before P.

times (in ms) of SJF and RR (round off to 2 decimal places) is . (2 Marks) Topic: CPU Scheduling (5.25)  In Shortest Job First (SJF) the process having smallest execution time is chosen for the next execution. In Round Robin (RR) scheduling, a fixed time is allotted to each process called quantum for execution. For SJF the jobs are scheduled as P3 0

P4 2

P2 6

P1 13

21

For RR scheduling the jobs are scheduled as P1 0

P2 4

P3 8

P4 10

P1 14

18

21

T1 = (21 – 0) + (13 – 0) + (2 – 0) + (6 – 0) = 42 T1 avg =

42 = 10.5 4

Turnaround time for RR T2 = (18 – 0) + (21 – 0) + (10 – 0) + (14 – 0) = 63 T2 avg =

63 = 15.75 4

Therefore, absolute value of difference between the average turnaround time is 15.75 – 10.5 = 5.25

Chapter 9: Databases 46. Consider a relational database containing the following schemas.

T : number of head movement = 115 – 110 = 5 Q : number of head movement = 115 – 85 = 30

Catalogue

S : number of head movement = 85 – 30 = 55 P : number of head movement = 155 – 85 = 70 So, the sequence, Q is serviced after S, but before T, is false. 45. Consider the following set of processes, assumed to have arrived at time 0. Consider the CPU scheduling algorithms Shortest Job First (SJF) and Round Robin (RR). For RR, assume that the processes are scheduled in the order P1, P2, P3, P4.

sno

pno

cost

S1

P1

150

S1

P2

50

S1

P3

100

S2

P4

200

S2

P5

250

Processes

P1

P2

P3

P4

S3

P1

250

Burst time (in ms)

8

7

2

4

S3

P2

150

S3

P5

300

S3

P4

250

If the time quantum for RR is 4 ms, then the absolute value of the difference between the average turnaround

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 11

P2

Turnaround time for SJF

(2 Marks) Topic: C  PU Scheduling (b)  The shortest seek time first services are those that request next which requires least number of head movements from its current position regardless of direction. Head is positioned at cylinder 100, therefore the services are accessed according to following sequence R : number of head movement = 110 – 100 = 10

B11

8/14/2020 9:44:24 AM

B12

GATE CSIT Chapter-wise Solved papers

Suppliers sno

sname

location

S1

M/s Royal furniture

Delhi

S2

M/s Balaji furniture

Bangalore

S3

M/s Premium furniture

Chennai

47. Which one of the following is used to represent the supporting many-one relationships of a weak entity set in an entity-relationship diagram? (a) Diamonds with double/bold border (b) Rectangles with double/bold border (c) Ovals with double/bold border (d) Ovals that contain underlined identifiers (1 Mark)

Parts pno

pname

part_spec

P1

Table

Wood

P2

Chair

Wood

P3

Table

Steel

P4

Almirah

Steel

P5

Almirah

Wood

Topic: Relational Model: Relational Algebra, Tuple Calculus, SQL (a)  Many-one relationships of a weak entity set in an entity-relationship diagram are represented by diamond with double/bold border.

R

Entity-relation diagram

The primary key of each table is indicated by underlining the constituent fields. SELECT s.sno, s.sname FROM Suppliers s, Catalogue c WHERE s.sno = c.sno AND cost > (SELECT AVG (cost) FROM Catalogue WHERE pno = ‘P4’ GROUP BY pno); The number of rows returned by the above SQL query is (a) 4 (b) 5 (c) 0 (d) 2

48. Consider the productions A → PQ and A → XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules. Rule 1: P.i = A.i + 2, Q.i = P.i + A.i, and A.s = P.s + Q.s Rule 2: X.i = A.i + Y.s and Y.i = X.s + A.i Which one of the following is true? (a) Both Rule 1 and Rule 2 are L-attributed. (b) Only Rule 1 is L-attributed. (c) Only Rule 2 is L-attributed. (d) Neither Rule 1 nor Rule 2 is L-attributed.

(1 Mark)

(2 Marks)

Topic: R  elational Model: Relational Algebra, Tuple Calculus, SQL (a)  The number of rows returned by the given SQL query is 4. According to query the cross product of supplier table and catalogue table, where cost is greater than 225 (average) are to be selected which are:

Topic: Relational Model: Relational Algebra, Tuple Calculus, SQL (b)  L-attributed definitions are always evaluated in depth first order, here rule 1 is L-attributed by definition. In rule 2, X.i = A.i + Y.s does not satisfy L-attributed definition so it is not L attributed. Therefore, only rule 1 is L-attributed.

S2

M/s Balaji furniture

P5

250

S3

M/s Premium furniture

P1

250

S3

M/s Premium furniture

P5

250

S3

M/s Premium furniture

P4

250

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 12

49. Consider a relational table R that is in 3NF, but not in BCNF. Which one of the following statements is TRUE? (a)  R has a nontrivial functional dependency X → A, where X is not a superkey and A is a prime attribute. (b)  R has a nontrivial functional dependency X → A, where X is not a superkey and A is a non-prime attribute and X is not a proper subset of any key.

8/14/2020 9:44:24 AM

appendix  •  Solved GATE (CSIT) 2020

(c)  R has a nontrivial functional dependency X → A, where X is not a superkey and A is a non-prime attribute and X is a proper subset of some key. (d) A cell in R holds a set instead of an atomic value.

(c)

T1

Topic: Relational Model: Relational Algebra, Tuple Calculus, SQL (a)  A relation table is in 3 NF if (i) it is in 2 NF (ii) if for every non-trivial functional dependency X → A, X is superkey or A is part of some key for R. A relation table is in BCNF if (i) it is in 3NF (ii) if for every non-trivial functional dependency X → A, X is a superkey. Given that, relation table R is in 3NF but not in BCNF. Therefore, R has non-trivial functional dependency X → A, where X is not a superkey and A is prime attribute.

T2

T1

RA

RC RB

T2 T1

WB WB

Commit

RA RB

WB

T1

WD

WB

(b)

T1

RA

RC

Commit

WD

Commit WB RB Commit

T1 WB

RD

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 13

WC

RD

WB

Commit WC

Commit

RA

T1

T2

RB

WB

RD

WC

T1

RC

WD

WB

Commit Commit

T2

(2 Marks) Topic: Transactions and Concurrency Control (a)  Given schedule T1

RA

RC RB

WB

RD

WD

Commit

WB

Commit

WC

Commit

The conflict equivalent of the above schedule RA

T1 T2

RB

WB

T1

WD

WB

T2

T2

T2

RC

RD

WC

T2

WB

T2

Here, RX stands for “Read(X)” and WX stands for “Write(X)”. Which one of the following schedules is conflict equivalent to the above schedule?

T2

RB

T2

Commit

T1

WD

RD

WC

T2

(a)

(d)

T1 WD

RC

T2

(2 Marks)

50. Consider a schedule of transactions T1 and T2:

RA

T1

B13

RC

RD Commit WC

Commit

51. Consider a database implemented using B+ tree for file indexing and installed on a disk drive with block size of 4 KB. The size of search key is 12 bytes and the size of tree/disk pointer is 8 bytes. Assume that the database has one million records. Also assume that no node of the B+ tree and no records are present initially in main memory. Consider that each record fits into one disk block. The minimum number of disk accesses required to retrieve any record in the database is . (2 Marks)

8/14/2020 9:44:24 AM

B14

GATE CSIT Chapter-wise Solved papers

Topic: F  ile Organization, Indexing (e.g., B and B+ Trees) (4)  Given that, block size = 4 KB, search key = 12 bytes, tree pointer = 8 bytes and database records = 1 million = 106. B+ tree is an extension of B tree which allows efficient insertion, deletion and search operations. In B+ tree index each record fits into one block. To access any record, 3 block accesses are required to search for the record in the index along with 1 more access to actually access the record so minimum number of disk accesses required to retrieve any record in the database is 4.

Chapter 10: Computer Networks 52. Consider the following statements about the functionality of an IP based router. I. A router does not modify the IP packets during forwarding. II. It is not necessary for a router to implement any routing protocol. III. A router should reassemble IP fragments if the MTU of the outgoing link is larger than the size of the incoming IP packet. Which of the above statements is/are TRUE? (a) I and II only (b) I only (c) II and III only (d) II only (1 Mark) Topic: I Pv4/IPv6, Routers and Routing Algorithms (Distance Vector, Link State) (d)  Statement I: A router does not modify the IP packets during forwarding – this is false as a router modifies the IP packets during forwarding. Statement II: It is not necessary for a router to implement any routing protocol – this is true. Statement III: A router should reassemble IP fragments if the MTU of the outgoing link is larger than the size of the incoming IP packet – this is false because router does not assemble IP fragments; it is done at the destination. 53. Assume that you have made a request for a web page through your web browser to a web server. Initially the browser cache is empty. Further, the browser is configured to send HTTP requests in non-persistent mode. The web page contains text and five very small images. The minimum number of TCP connections required to display the web page completely in your browser is . (1 Mark)

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 14

Topic: TCP/UDP and Sockets, Congestion Control (6)  We know that in non-persistent mode, every object requires 1 TCP connection. So, 1 TCP connection for text and 5 TCP connections for five images. Therefore, total TCP connections required 6. 54. An organization requires a range of IP addresses to assign one to each of its 1500 computers. The organization has approached an Internet Service Provider (ISP) for this task. The ISP uses C1DR and serves the requests from the available IP address space 202.61.0.0/17. The ISP wants to assign an address space to the organization which will minimize the number of routing entries in the ISP’s router using route aggregation. Which of the following address spaces are potential candidates from which the ISP can allot any one to the organization? I. 202.61.84.0/21 II. 202.61.104.0/21 III. 202.61.64.0/21 IV. 202.61.144.0/21 (a) I and II only (b) II and III only (c) III and IV only (d) I and IV only (2 Marks) Topic: Concept of Layering (b)  Given, address space is 202.61.0.0/17.

202.61.0.0/11111111 11111111 100000000000000/255.255.128.0 Expanding given address spaces, we have 202.61.81.0/21 = 202.61.01010100.0 Address space I not possible because host bits should be zero. 202.61.104.0/21 = 202.61.01101000.0 Address space II is possible 202.61.64.0/21 = 202.61.01000000.0 Address space III is possible 202.61.144.0/21 = 202.61.10010000.0 Address space IV not possible because host bit should be zero. So, II and III are potential candidates.

55. Consider a TCP connection between a client and a server with the following specifications: the round trip time is 6 ms, the size of the receiver advertised window is 50 KB, slow-start threshold at the client is 32 KB, and

8/14/2020 9:44:24 AM

appendix  •  Solved GATE (CSIT) 2020

the maximum segment size is 2 KB. The connection is established at time t = 0. Assume that there are no timeouts and errors during transmission. Then the size of the congestion window (in KB) at time t + 60 ms after all acknowledgements are processed is . (2 Marks) Topic: TCP/UDP and Sockets, Congestion Control (44)  Given that, round trip time = 6 ms, size of received advertised window = 50 KB, slow start threshold at client = 32 KB and maximum ­segment size = 2 KB.

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 15

B15

At t = 0, no time outs At t = 60, that is, 60 ms, number of round trips =

60 = 10 6

Therefore, size of congestion window = 2 + 2 + 4 + 8 + 16 + 2 + 2 + 2 + 2 + 2 + 2 = 44 KB.

8/14/2020 9:44:24 AM

Solved Chapter Wise GATE CS&IT 2020 Paper.indd 16

8/14/2020 9:44:24 AM

GATE The Graduate Aptitude Test in Engineering (GATE) is an All-India level examination for engineering graduates aspiring to pursue Master’s or Ph.D. programmes in India. The Public Sector Undertakings (PSU’s) also use GATE used as a recruiting examination. The examination is highly competitive, and the GATE score plays an important role in fulfilling the academic and professional aspirations of the students. This book is aimed at supporting the efforts of GATE aspirants in achieving a high GATE score. The book comprises previous years’ (2000 to 2020) GATE questions in Computer Science and Information Technology covered chapter-wise with detailed solutions. Each chapter begins with a detailed year-wise analysis of topics on which questions are based and is followed by listing of important formulas and concepts for that chapter. The book is designed to make the students well-versed with the pattern of examination, level of questions asked and the concept distribution of questions and thus bring greater focus to their preparation. It aims to be a must-have resource for an essential step in their preparation, that is, solving and practicing previous years’ papers.

Salient Features Chapter-wise coverage of GATE Computer Science and Information Technology previous years’ questions (2000 to 2018). Chapter-wise 2019 and 2020 GATE papers available as appendix

l

Chapter on Engineering Mathematics included for complete coverage of the technical section of the GATE paper

l

Detailed topic-wise analysis of questions for each chapter

l

Important Formulas and Concepts summarized for easy recall in each chapter

l

All questions marked for level of difficulty (i.e. 1 Mark or 2 Marks)

l

Detailed solutions for all questions, tagged topic-wise

l

Packaged with unique scratch code for free 7-day subscription for online GATE tests

CHAPTER-WISE SOLVED PAPERS

(2000-2020)

eISBN 978-81-265-9543-3

9 788126 595433

Inside

Verma,Sharma, Singh

Wiley India Pvt. Ltd. Customer Care +91 120 6291100 [email protected] www.wileyindia.com www.wiley.com

GATE

COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

CHAPTER-WISE SOLVED PAPERS (2000-2020)

l

COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

About the Book

Anil Kumar Verma Gaurav Sharma Kuldeep Singh

l l l

Detailed Exam Analysis Chapter-wise and Topic-wise. Questions from previous years’ (2000 – 2020) papers. Unique scratch code that provides access to w Free online test with analytics. w 7-Day free subscription for topic-wise GATE tests. w Instant correction report with remedial action.