Gate Computer Science And Information Technology 2019 Trishna Knowledge Systems
Gate Computer Science And Information Technology 2019 Trishna Knowledge Systems
Gate Computer Science And Information Technology 2019 Trishna Knowledge Systems
Gate Computer Science And Information Technology 2019 Trishna Knowledge Systems
1. Gate Computer Science And Information Technology
2019 Trishna Knowledge Systems download
https://ebookbell.com/product/gate-computer-science-and-
information-technology-2019-trishna-knowledge-systems-22041790
Explore and download more ebooks at ebookbell.com
2. Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Gate Computer Science And Information Technology Topicwise Practice
Tests Trishna Knowledge Systems
https://ebookbell.com/product/gate-computer-science-and-information-
technology-topicwise-practice-tests-trishna-knowledge-systems-10883378
Gate 2019 Computer Science And Information Technology Previous Years
Solved Question Papers Trishna Knowledge Systems
https://ebookbell.com/product/gate-2019-computer-science-and-
information-technology-previous-years-solved-question-papers-trishna-
knowledge-systems-10883278
Wiley Acing The Gate Computer Science And Information Technology 1st
Edition Verma Et Al
https://ebookbell.com/product/wiley-acing-the-gate-computer-science-
and-information-technology-1st-edition-verma-et-al-6990852
Gate 2017 Computer Science And Information Technology Previous Years
Solved Question Papers Trishna Knowledge Systems
https://ebookbell.com/product/gate-2017-computer-science-and-
information-technology-previous-years-solved-question-papers-trishna-
knowledge-systems-10883112
3. Computer Science And Information Technology For Gate N B Venkateswarlu
https://ebookbell.com/product/computer-science-and-information-
technology-for-gate-n-b-venkateswarlu-10945194
Trisha Gate Computer Science And Information Technology 2020
https://ebookbell.com/product/trisha-gate-computer-science-and-
information-technology-2020-51335736
Gate 2020 Computer Science And Technology Disha Experts
https://ebookbell.com/product/gate-2020-computer-science-and-
technology-disha-experts-10442704
Computer Networks Semestervi Computer Science And Engineering Csvtu
4th Edition Saket Verma
https://ebookbell.com/product/computer-networks-semestervi-computer-
science-and-engineering-csvtu-4th-edition-saket-verma-28537336
Cultures Of Computer Game Concerns The Child Across Families Law
Science And Industry Estrid Srensen Editor Knowledge Unlatched Ku
Select 2019 Backlist Collection Editor
https://ebookbell.com/product/cultures-of-computer-game-concerns-the-
child-across-families-law-science-and-industry-estrid-srensen-editor-
knowledge-unlatched-ku-select-2019-backlist-collection-editor-51804052
6. Pearson is the world’s learning company, with presence across 70 countries
worldwide. Our unique insights and world-class expertise comes from a long
history of working closely with renowned teachers, authors and thought
leaders, as a result of which, we have emerged as the preferred choice for
millions of teachers and learners across the world.
We believe learning opens up opportunities, creates fulfilling careers and
hence better lives. We hence collaborate with the best of minds to deliver you
class-leading products, spread across the Higher Education and K12 spectrum.
Superior learning experience and improved outcomes are at the heart of
everything we do. This product is the result of one such effort.
Your feedback plays a critical role in the evolution of our products and you
can contact us at reachus@pearson.com. We look forward to it.
About Pearson
10. Preface ix
Key Pedagogical Features x
Syllabus: Computer Science and Information Technology xii
Chapter-wise Analysis of GATE PreviousYears’ Papers xiii
General Information about Gate xiv
Solved Papers 2017 xvi
PART I General Aptitude
PART A Verbal Ability
Chapter 1 Grammar 1.5
Chapter 2 Vocabulary 1.49
PART B Numerical Ability
UNIT I Quantitative Aptitude 1.71
Chapter 1 Simple Equations 1.73
Chapter 2 Ratio-Proportion-Variation 1.79
Chapter 3 Numbers 1.85
Chapter 4 Percentage, Profit and Loss 1.99
Chapter 5 Simple Interest and Compound Interest 1.106
Chapter 6 Average, Mixtures, Alligations 1.112
Chapter 7 Time and Work 1.118
Chapter 8 Time and Distance 1.124
Chapter 9 Indices, Surds, and Logarithms 1.130
Chapter 10 Quadratic Equations 1.136
Chapter 11 Inequalities 1.142
Chapter 12 Progressions 1.146
Chapter 13 Permutations and Combinations 1.151
Chapter 14 Data Interpretation 1.158
UNIT II Reasoning 1.177
Chapter 1 Number and Letter Series 1.179
Chapter 2 Analogies 1.185
Chapter 3 Odd Man Out (Classification) 1.188
Chapter 4 Coding and Decoding 1.191
Chapter 5 Blood Relations 1.195
Chapter 6 Venn Diagrams 1.200
Contents
solved PaPers 2018 l i
11. vi | Contents
Chapter 7 Seating Arrangements 1.204
Chapter 8 Puzzles 1.212
Chapter 9 Clocks and Calenders 1.225
PART I1 Engineering Mathematics
Chapter 1 Mathematical Logic 2.237
Chapter 2 Probability 2.250
Chapter 3 Set Theory and Algebra 2.266
Chapter 4 Combinatorics 2.287
Chapter 5 Graph Theory 2.299
Chapter 6 Linear Algebra 2.317
Chapter 8 Calculus 2.333
PART III Computer Science and Information Technology
UNIT 1 Digital Logic 3.351
Chapter 1 Number Systems 3.353
Chapter 2 Boolean Algebra and Minimization of Functions 3.364
Chapter 3 Combinational Circuits 3.384
Chapter 4 Sequential Circuits 3.405
UNIT II Computer Organization and Architecture 3.433
Chapter 1 Machine Instructions, Addressing Modes 3.435
Chapter 2 ALU and Data Path, CPU Control Design 3.448
Chapter 3 Memory Interface, I/O Interface 3.464
Chapter 4 Instruction Pipelining 3.478
Chapter 5 Cache and Main Memory, Secondary Storage 3.490
UNIT III Programming and Data Structures 3.507
PART A Programming and Data Structures
Chapter 1 Programming in C 3.509
Chapter 2 Functions 3.520
Chapter 3 Arrays, Pointers and Structures 3.535
Chapter 4 Linked Lists, Stacks and Queues 3.551
Chapter 5 Trees 3.564
12. Contents | vii
PART B Algorithms
Chapter 1 Asymptotic Analysis 3.585
Chapter 2 Sorting Algorithms 3.601
Chapter 3 Divide and Conquer 3.610
Chapter 4 Greedy Approach 3.618
Chapter 5 Dynamic Programming 3.637
UNIT 1V Databases 3.657
Chapter 1 ER Model and Relational Model 3.659
Chapter 2 Structured Query Language 3.677
Chapter 3 Normalization 3.704
Chapter 4 Transaction and Concurrency 3.719
Chapter 5 File Management 3.736
UNIT V Theory of Computation 3.753
Chapter 1 Finite Automata and Regular Languages 3.755
Chapter 2 Context Free Languages and Push Down Automata 3.776
Chapter 3
Recursively Enumerable Sets and Turing Machines, Decidability 3.788
UNIT V1 Compiler Design 3.803
Chapter 1 Lexical Analysis and Parsing 3.805
Chapter 2 Syntax Directed Translation 3.828
Chapter 3 Intermediate Code Generation 3.837
Chapter 4 Code Optimization 3.856
UNIT VII Operating System 3.873
Chapter 1 Processes and Threads 3.875
Chapter 2
Interprocess Communication, Concurrency and Synchronization 3.889
Chapter 3 Deadlock and CPU Scheduling 3.907
Chapter 4 Memory Management and Virtual Memory 3.925
Chapter 5 File Systems, I/O Systems, Protection and Security 3.945
13. viii | Contents
UNIT VIII Networks, Information Systems, Software
Engineering and Web Technology 3.969
Part A Network
Chapter 1 OSI Layers 3.971
Chapter 2 Routing Algorithms 3.991
Chapter 3 TCP/UDP 3.1003
Chapter 4 IP(V4) 3.1018
Chapter 5 Network Security 3.1032
Part B Information Systems
Chapter 1 Process Life Cycle 3.1045
Chapter 2 Project Management and Maintenance 3.1055
Part C Software Engineering and Web Technology
Chapter 1 Markup Languages 3.1077
14. GraduateAptitudeTest in Engineering (GATE) is one of the preliminary tests for undergraduate subjects in Engineering/
Technology/Architecture and postgraduate subjects in Science stream only.
The number of aspirants appearing for the GATE examination is increasing significantly every year, owing to multifac-
eted opportunities open to any good performer. Apart from giving the aspirant a chance to pursue an M.Tech. from insti-
tutions like the IITs /NITs, a good GATE score can be highly instrumental in landing the candidate a plush public sector
job, as many PSUs are recruiting graduate engineers on the basis of their performance in GATE. The GATE examination
pattern has undergone several changes over the years—sometimes apparent and sometimes subtle. It is bound to continue
to do so with changing technological environment.
GATE Computer Science and InformationTechnology, as a complete resource helps the aspirants be ready with con-
ceptual understanding, and enables them to apply these concepts in various applications, rather than just proficiency with
questions type. Topics are handled in a comprehensive manner, beginning with the basics and progressing in a step-by-step
manner along with a bottom-up approach. This allows the student to better understand the concept and to practice applica-
tive techniques in a focused manner. The content has been systematically organized to facilitate easy understanding of all
topics. The given examples will not only help the students to understand the concepts involved in the problems but also help
to get a good idea about the different models of problems on that particular topic. Due care has also been taken to cover a
very wide range of problems including questions that have been appearing over the last few years in GATE examination.
The practice exercises in every chapter, contain questions ranging simple to moderate to difficult level. These exercises are
meant to hone the examination readiness over a period of time.At the end of each unit, practice tests have been placed.These tests
will help the student assess their level of learning on a regular interval.
This book has been prepared by a group of faculty who are highly experienced in training GATE preparations and
are also subject matter experts. As a result, this book would serve as an effective tool for GATE aspirant to crack the
examination.
Salient Features
1. Elaborate question bank covering previous 12 years’ GATE question papers
2. 5 free online mock tests for practice
3. Detailed coverage of key topics
4. Complete set of solved 2017 GATE online papers with chapter-wise analysis
5. Exhaustive pedagogy:
(a) More than 1300 Solved Examples
(b) More than 6000 Practice Questions
(c) Unit-wise time-bound tests
(d) Modular approach for easy understanding
We would like to thank the below mentioned reviewers for their valuable feedback and suggestions which has helped in
shaping this book.
R. Marudhachalam Professor (Sr. Grade), Kumaraguru College of Technology Coimbatore, Tamil Nadu
Daya Gupta Professor, Delhi Technological University, Main Bawana Road, Delhi
Manoj Kumar Gupta Associate Professor, Delhi Technological University Main Bawana Road, Delhi
Gurpreet Kour Lecturer, Lovely Professional University Phagwara, Punjab
Pinaki Chakraborty Assistant Professor, Netaji Subhas Institute of Technology Dwarka, Delhi
Gunit Kaur Lecturer, Lovely Professional University Phagwara, Punjab
Despite of our best efforts, some errors may have inadvertently crept into the book. Constructive comments and suggestions
to further improve the book are welcome and shall be acknowledged gratefully.
Wishing you all the very best..!!!
—Trishna Knowledge Systems
Preface
15. Key Pedagogical Features
Learning Objectives
List of important top-
ics which are covered in
chapter.
Chapter 2 Boolean Algebra and Minimization of Functions | 29
Solution: f = {A ⊕ B ⊕ B ⊕ C } ⊕ {A ⊕ C ⊕ B ⊕ A}
= {A ⊕ 0 ⊕ C} ⊕ {0 ⊕ C ⊕ B}
= A ⊕ C ⊕ C ⊕ B = A ⊕ 0 ⊕ B = A ⊕ B
Solved Examples
Example 1: Simplify the Boolean function, x y + x′z + y z
Solution: x y + x′ z+ y z
By using consensus property
xy + x′z + yz = xy + x′z
Y = xy + x′z
Example 2: The output of the given circuit is equal to
A
B
A
B
Solution: A B AB AB
= +
A
1
2
3
X OR gate
B
A
y
B
A B AB AB
= +
So the output of above circuit is ‘0’. As two inputs are same
at third gate.
Output of XOR gate with two equal inputs is zero.
y = 0
Example 3: The circuit shown in the figure is functionally
equivalent to
A
B
A
B
Solution:
A
B
A
A · B
(A + B)
y = A ⊕ B
Y A B AB A B A B A B A B
= ⋅ ⋅ = + + ⋅ = +
( ) ( ) ( ) ( )
= + + + = ⋅ + ⋅
= ⋅ + ⋅ = ⊕
( ) ( )
A B A B A B A B
A B A B A B
Example 4: Simplify the Boolean function A AB A
⊕ ⊕
Solution: A AB A
⊕ ⊕
Associativity
= ⊕ =
= +
1 AB A B
A B ( )
De Morgan s
’
Example 5:
00
CD
00
01
01
11
11
10
10
0
1
1
1
0
0
0
1
×
AB
×
1
1
1
×
× ×
The minimized expression for the given K–map is
Solution:
00
CD
00
01
01
11
11
10
10
0
1
1
1
0
0
0
1
×
AB
×
1
1
1
×
× ×
= +
A BC
Example 6: In the figure shown, y2
, y1
, y0
will be 1s
complement of x2
x1
x0
if z = ?
x0
y0
y1
y2
z = ?
x1
x2
Solution: We are using X-OR gate
∴ XOR out-put is complement of input only when other
input is high.
∴ Z = 1
Example 7: The output y of the circuit shown is the figure is
A
B
Solved Example
Solved problems given topic-wise
to learn to apply the concepts
learned in a particular section as
per exam pattern.
Exercises
3.536 | Digital Logic
BCD addition
• BCD addition is performed by individually adding the
corresponding digits of the decimal number expressed in
4-bit binary groups starting from the LSB.
• If there is no carry and the sum term is not an illegal code,
no correction is needed.
• If there is a carry out of one group to the next group or if
the sum term is an illegal code, the (6)10
is added to the
sum term of that group, and the resulting carry is added
to the next group.
Example 43: 44 + 12
0100 0100 (44 in BCD)
0001 0010 (12 in BCD)
0101 0110 (56 in BCD)
Example 44: 76.9+ 56.6
0111 0110 . 1001
0101 0110 . 0110
1100 1100 . 1111
0110 0110 . 0110
0010 0010 . 0101
+1 +1 +1
0001 0011 0011 . 0101
1 3 3 . 5
BCD subtraction BCD subtraction is performed by sub-
tracting the digits of each 4-bit group of the subtrahend
from the corresponding 4-bit group of the minuend in
binary starting from the LSB.
Example 45: 42 0100 0010 42
12
30
0001 0010
0011 0000
( )
in BCD
(12 IN BCD)
− −
Example 46:
247 7
156 9
90 8
0010
0001
0000
0100
0101
0111
0111
0110
0000
011
.
.
.
.
.
.
−
⋅
1
1
1001
1110
01001 0110
1001 000 1000
− −
⋅
Excess-3 (XS-3) code
Excess-3 code is a non-weighted BCD code, where each
digit binary code word is the corresponding 8421 code word
plus 0011.
Find the XS-3 code of
Example 47: (3)10
→ (0011)BCD
= (0110)xS3
Example 48: (16)10
→ (0001 0110)BCD
→ (0100 1001)xS3
Gray code
Each gray code number differs from the preceding number
by a single bit.
Decimal Gray Code
0 0000
1 0001
2 0011
3 0010
4 0110
5 0111
Binary to gray conversion
Step I: Shift the binary number one position to the right,
LSB of the shifted number is discarded.
Step II: Exclusive or the bits of the binary number with
those of the binary number shifted.
Example 49: Convert (1001)2
to gray code
Binary → 1010
Shifted Binary → 101 ⊕
Gray → 1111
Gray to binary conversion
(a) Take the MSB of the binary number is same as MSB of
gray code number.
(b) X-OR the MSB of the binary to the next significant bit
of the gray code.
(c) X-OR the 2nd bit of binary to the 3rd bit of Gray code
to get 3rd bit binary and so on.
(d) Continue this till all the gray bits are exhausted.
Example 50: Convert, gray code 1010 to binary
Gray
1010
1100
= (1100)2
(all are illegal
codes)
(propagate carry)
(No borrow, so this is
the correct difference)
(Borrow
are
present,
subtract
0110)
Corrected
difference
(90.8)
1 0 1 0
1 1 0 0
⇓ ⊕ ⊕ ⊕
|| || ||
Exercises
Practice Problems 1
Directions for questions 1 to 15: Select the correct alterna-
tive from the given choices.
1. Assuming all the numbers are in 2’s complement rep-
resentation, which of the following is divisible by
11110110?
(A) 11101010 (B) 11100010
(C) 11111010 (D) 11100111
2. If (84)x
(in base x number system) is equal to (64)y
(in
base y number system), then possible values of x and y
are
(A) 12, 9 (B) 6, 8
(C) 9, 12 (D) 12, 18
3. Let A = 1111 1011 and B = 0000 1011 be two 8-bit
signed 2’s complement numbers. Their product in 2’s
complement representation is
Chapter 01.indd 536 8/12/2015 12:15:36 PM
Practice problems for stu-
dents to master the concepts
studied in chapter. Exercises
consist of two levels of prob-
lems “Practice Problem I”
and “Practice Problem II”
based on increasing difficulty
level.
Chapter 1 Number Systems | 13
(A) 11001001 (B) 10011100
(C) 11010101 (D) 10101101
4. Let r denotes number system’s radix. The only value(s)
of r that satisfy the equation ( ) ( )
1331 11
3
r r
= is/are
(A) 10 (B) 11
(C) 10 and 11 (D) any r 3
5. X is 16-bit signed number. The 2’s complement repre-
sentation of X is (F76A)16
. The 2’s complement repre-
sentation of 8 × X is
(A) (1460)16
(B) (D643)16
(C) (4460)16
(D) (BB50)16
6. The HEX number (CD.EF)16
in octal number system is
(A) (315.736)8
(B) (513.637)8
(C) (135.673)8
(D) (531.367)8
7. 8-bit 2’s complement representation a decimal number
is 10000000. The number in decimal is
(A) +256 (B) 0
(C) -128 (D) -256
8. The range of signed decimal numbers that can be rep-
resented by 7-bit 1’s complement representation is
(A) -64 to + 63 (B) -63 to + 63
(C) -127 to + 128 (D) -128 to +127
9. Decimal 54 in hexadecimal and BCD number system is
respectively
(A) 63, 10000111 (B) 36,01010100
(C) 66, 01010100 (D) 36, 00110110
10. A new binary-coded hextary (BCH) number system
is proposed in which every digit of a base -6 number
system is represented by its corresponding 3-bit binary
code. For example, the base -6 number 35 will be rep-
resented by its BCH code 011101.
In this numbering system, the BCH code
001001101011 corresponds to the following number
in base -6 system.
(A) 4651 (B) 4562
(C) 1153 (D) 1353
11. The signed 2’s complement representation of (-589)10
in Hexadecimal number system is
(A) (F24D)16
(B) (FDB3)16
(C) (F42D)16
(D) (F3BD)16
12. The base of the number system for which the following
operation is to be correct
66
5
13
=
(A) 6 (B) 7
(C) 8 (D) 9
13. The solution to the quadratic equation x2
- 11x + 13 = 0
(in number system with radix r) are x = 2 and x = 4.
Then base of the number system is (r) =
(A) 7 (B) 6
(C) 5 (D) 4
14. The 16’s complement of BADA is
(A) 4525 (B) 4526
(C) ADAB (D) 2141
15. (11A1B)8
= (12CD)16
, in the above expression A and B
represent positive digits in octal number system and C
and D have their original meaning in Hexadecimal, the
values of A and B are?
(A) 2, 5 (B) 2, 3
(C) 3, 2 (D) 3, 5
Practice Problems 2
Directions for questions 1 to 20: Select the correct alterna-
tive from the given choices.
1. The hexadecimal representation of (567)8
is
(A) 1AF (B) D77
(C) 177 (D) 133
2. (2326)8
is equivalent to
(A) (14D6)16
(B) (103112)4
(C) (1283)10
(D) (09AC)16
3. (0.46)8
equivalent in decimal is?
(A) 0.59375 (B) 0.3534
(C) 0.57395 (D) 0.3435
4. The 15’s complement of (CAFA)16
is
(A) (2051)16
(B) (2050)16
(C) (3506)16
(D) (3505)16
(A) 11111 (B) 10001
(C) 01111 (D) 10000
7. (0.25)10
in binary number system is?
(A) (0.01) (B) (0.11)
(C) 0.001 (D) 0.101
8. The equivalent of (25)6
in number system with base 7
is?
(A) 22 (B) 23
(C) 24 (D) 26
9. The operation 35 + 26 = 63 is true in number system
with radix
(A) 7 (B) 8
(C) 9 (D) 11
10. The hexadecimal equivalent of largest binary number
with 14-bits is?
(A) 2FFF (B) 3FFFF
Chapter 1
Number Systems
DIGITAL CIRCUITS
Computers work with binary numbers, which use only the digits
‘0’ and ‘1’. Since all the digital components are based on binary
operations, it is convenient to use binary numbers when analyzing
or designing digital circuits.
Number Systems with Different Base
Decimal number system
Decimal numbers are usual numbers which we use in our day-to-
day life. The base of the decimal number system is 10. There are
ten numbers 0 to 9.
The value of the nth digit of the number from the right side
= nth digit × (base)n–1
Example 1: (99)10
→ 9 × 101
+ 9 × 100
= 90 + 9 = 99
Example 2: (332)10
→ 3 × 102
+ 3 × 101
+ 2 × 100
= 300 + 30 + 2
Example 3: (1024)10
→ 1 × 103
+ 0 × 102
+ 2 × 101
+ × 100
= 1000 + 0 + 20 + 4 = 1024
Binary number system
In binary number system, there are only two digits ‘0’ and ‘1’.
Since there are only two numbers, its base is 2.
Example 4: (1101)2
= 1 × 23
+ 1 × 22
+ 0 × 21
+ 1 × 20
= 8 + 4 + 1 = (13)10
Octal number system
Octal number system has eight numbers 0 to 7. The base of the
number system is 8. The number (8)10
is represented by (10)8
.
Example 5: (658)8
= 6 × 82
+ 5 × 81
+ 8 × 80
= 384 + 40 + 8 = (432)10
Hexadecimal number system
In hexadecimal number system, there are 16 numbers 0 to 9, and
digits from 10 to 15 are represented by A to F, respectively. The
base of hexadecimal number system is 16.
Example 6: (1A5C)16
= 1 × 163
+ A × 162
+ 5 × 161
+ C × 160
= 1 × 4096 + 10 × 256 + 5 × 16 + 12 × 1
= 4096 + 2560 + 80 + 12 = (6748)10
.
Table 1 Different number systems
Decimal Binary Octal Hexadecimal
0 000 0 0
1 001 1 1
2 010 2 2
3 011 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
(Continued )
After reading this chapter, you will be able to understand:
• Digital circuits
• Number system with different base
• Conversion of number systems
• Complements
• Subtraction with complement
• Numeric codes
• Weighted and non-weighted codes
• Error detection and correction code
• Sequential, reflective and cyclic codes
• Self complementing code
LEARNING OBJECTIVES
Chapter 01.indd 529 8/17/2015 8:25:39 PM
16. above code?
(A) 5
(B) 6
(C) 8
(D) 7
17. A basic block can be analyzed by
(A) Flow graph
(B) A graph with cycles
(C) DAG
(D) None of these
What type of values is passed to the called procedure?
(A) l-values
(B) r-values
(C) Text of actual parameters
(D) None of these
19. Which of the following is FALSE regarding a Block?
(A) The first statement is a leader.
(B) Any statement that is a target of conditional / un-
conditional goto is a leader.
(C) Immediately next statement of goto is a leader.
(D) The last statement is a leader.
previousyeArs’ QuesTions
1. The least number of temporary variables required to
create a three-address code in static single assignment
form for the expression q + r/3 + s – t * 5 + u * v/w is
________ [2015]
2. 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)
The number of nodes and edges in the control-flow-
graph constructed for the above code, respectively,
are [2015]
(A) 5 and 7 (B) 6 and 7
(C) 5 and 5 (D) 7 and 8
3. Consider the following code segment. [2016]
x = u – t;
y = x * v;
x = y + w;
y = t – z;
y = x * y;
The minimum number of total variables required to con-
vert the above code segment to static single assignment
form is _____ .
4. What will be the output of the following pseudo-
code when parameters are passed by reference and
dynamic scoping is assumed? [2016]
a = 3;
void n(x) { x = x* a; print (x);}
void m(y) {a = 1; a = y – a; n(a) ; print (a)}
void main( ) {m(a);}
(A) 6,2 (B) 6,6
(C) 4,2 (D) 4,4
Answer keys
exerCises
Practice Problems 1
1. D 2. D 3. C 4. C 5. B 6. A 7. B 8. A 9. A 10. A
11. B 12. C 13. A 14. C 15. B
Practice Problems 2
1. B 2. B 3. A 4. B 5. B 6. A 7. B 8. C 9. A 10. A
11. B 12. D 13. A 14. C 15. C 16. A 17. C 18. B 19. D
PreviousYears’ Questions
1. 8 2. B 3. 10 4. D
PreviousYears’
Questions
Contains previous 10
years GATE Questions
at end of every chapter
which help students to get
an idea about the type of
problems asked in GATE
and prepare accordingly.
38 | Digital Logic
Hints/solutions
Practice Problems 1
1.
0
A
A
A
A y = 1
X-OR of two equal inputs will give you result as zero.
Hence, the correct option is (B).
2. Positive level OR means negative level AND vice versa
Hence, the correct option is (D).
3. AB CD EF GH
⋅ ⋅ ⋅
(De Morgan’s law)
= + + + +
( ) ( ) ( ) ( ( ))
A B C D E F G H
Hence, the correct option is (B).
4.
A
B
C
y
AB
AB · B = AB + B (AB + B) · B = A + B
(AB + B) · C = AC + BC
= + + +
= + + =
( )
( )
A B AC BC
A C B ABC
Hence, the correct option is (C).
5. The output should be high when at least two outputs are
high y ABC ABC ABC ABC
= + + +
The minimized output
y = AB + AC + BC
Hence, the correct option is (A).
6. f1(x, y, z)
f2(x, y, z)
f3(x, y, z)
x
f (x, y, z)
x + f3
x consists of all min terms, so x = 0, and f = f3
f3
(x1
y1
z) = (1, 4, 5)
Hence, the correct option is (A).
7.
A
I J
Z
Traal and error method
I = 1, J = B
Then Z = +
A B
Hence, the correct option is (B).
8. Error → transmits odd number of one’s, for both cases.
Hence, the correct option is (A).
9. ∑(0, 1, 2, 4, 6) P should contain minterms of each func-
tion of x as well as y
Hence, the correct option is (B).
10. AB ACD AC
+ +
= + + + + + + +
AB C C D D A B B CD A B B C D D
( )( ) ( ) ( ) ( )
= + + + + + +
AB CD CD CD C D ABCD ABCD
( )
= + + +
AC BD BD BD BD
( )
ABCD ABCD ABCD ABC D ABCD
+ + + + +
ABCD ABCD ABCD ABCD
+ + +
Hence, the correct option is (A).
11. ABCD ABCD ABCD ABCD
+ + +
= +
ABC ABC
= BC
Hence, the correct option is (C).
12.
00
YZ
WX
00
01
01
11
11
10
10
1
1
1
1 1 1
1
1
1
1
1 octet + 1 quad
= +
z wx
Hence, the correct option is (D).
13. A
B
Y
C
AB
B
A
P = AB
A + B
C AB A B
= ⋅ +
( )
= + +
= +
( ) ( )
A B A B
AB AB
Hence, the correct option is (A).
14. AB
C
0 0 0
0
0 0
0
1
0
1
⇒ + +
B A C A C
( ) ( ).
Hence, the correct option is (A).
Hints/Solutions
This section gives complete
solutions of all the unsolved
questions given in the chapter.
The Hints/Solutions are
included in the CD accompa-
nying the book.
PracticeTests
Test | 103
TesT
DigiTal logic
Time: 60 min.
Directions for questions 1 to 30: Select the correct alterna-
tive from the given choices.
1. What is the range of signed decimal numbers that can
be represented by 4-bit 1’s complement notation?
(A) –7 to + 7 (B) –16 to +16
(C) –7 to +8 (D) –15 to +16
2. Which of the following signed representation have a
unique representation of 0?
(A) Sign-magnitude (B) 1’s complement
(C) 0’s complement (D) 2’s complement
3. Find the odd one out among the following
(A) EBCDIC (B) GRAY
(C) Hamming (D) ASCII
4. Gray code for number 8 is
(A) 1100 (B) 1111
(C) 1000 (D) 1101
5. Find the equivalent logical expression for z = x + xy
(A) z = xy (B) Z = xy
(C) Z = x + y (D) Z = x + y
6. The number of distinct Boolean expression of 3 vari-
ables is
(A) 256 (B) 16
(C) 1024 (D) 65536
7. The Boolean expression for the truth table shown is
X Y Z F
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
9. The number of product terms in the minimized SOP
from is
1 0 0 1
0 D 0 0
0 0 D 1
1 0 0 1
(A) 2 (B) 4
(C) 5 (D) 3
10. The minimum number of 2 input NAND gates needed
to implement Z = XY + VW is
(A) 2 (B) 3
(C) 4 (D) 5
11. The operation a b
⊕ represents
(A) ab a b
+ (B) ab ab
+
(C) ab ab
+ (D) a b
−
12. Find the dual of X + [Y + XZ] + U
(A) X + [Y(X + Z)] + U (B) X(Y + XZ)U
(C) X + [Y(X + Z)]U (D) X[Y(X + Z)]U
13. The simplified form of given function AB + BC + AC is
equal to
(A) AB + AC (B) AC + BC
(C) AC + BC (D) AB + AC
14. Simplify the following
YZ
WX
1 0
0
1
1
1
1 1 1
0 0 1
0
0 0 0
Time-bound Test provided at
end of each unit for assessment
of topics leaned in the unit.
17. Computer Science and Information Technology
Digital Logic: Boolean algebra. Combinational and sequential circuits. Minimization. Number representations and com-
puter arithmetic (fixed and floating point).
Computer Organization and Architecture: 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).
Programming and Data Structures: Programming in C. Recursion. Arrays, stacks, queues, linked lists, trees, binary
search trees, binary heaps, graphs.
Algorithms: Searching, sorting, hashing. Asymptotic worst case time and space complexity. Algorithm design tech-
niques: greedy, dynamic programming and divide-and-conquer. Graph search, minimum spanning trees, shortest paths.
Theory of Computation: Regular expressions and finite automata. Context-free grammars and push-down automata.
Regular and contex-free languages, pumping lemma. Turing machines and undecidability.
Compiler Design: Lexical analysis, parsing, syntax-directed translation. Runtime environments. Intermediate code
generation.
Operating System: Processes, threads, inter1process communication, concurrency and synchronization. Deadlock. CPU
scheduling. Memory management and virtual memory. File systems.
Databases: ER1model. Relational model: relational algebra, tuple calculus, SQL. Integrity constraints, normal forms.
File organization, indexing (e.g., B and B+ trees). Transactions and concurrency control.
Computer Networks: Concept of layering. LAN technologies (Ethernet). Flow and error control techniques, switch-
ing. 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 private key cryptography, digital signatures and certificates, firewalls.
Syllabus: Computer Science
and InformationTechnology
18. Chapter-wise Analysis of GATE
PreviousYears’ Papers
Subject 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017
General Aptitude
1 Marks Questions 5 5 5 5 5 5 5 5
2 Marks Questions 5 5 5 5 5 5 6 5
Total Marks 15 15 15 15 15 15 17 15
Engineering Mathematics
1 Marks 6 3 4 5 4 6 2 3 5 5 4 5 4
2 Marks 12 11 11 11 6 5 7 3 2 5 6 4 5
Total Marks 30 25 26 27 16 16 16 9 9 15 16 13 14
Theory of Computation
1 Marks 0 2 2 3 4 1 3 4 1 5 1 3 2
2 Marks 7 6 5 6 3 3 3 1 2 6 3 3 4
Total Marks 14 14 12 15 10 7 9 6 5 17 7 9 10
Digital Logic
1 Marks 4 1 3 4 2 3 3 2 3 3 1 2 2
2 Marks 5 5 5 1 0 2 3 2 1 5 2 1 2
Total Marks 14 11 13 6 2 7 9 6 5 13 5 4 6
Computer Organization and Architecture
1 Marks Questions 4 0 2 0 2 1 3 2 1 2 1 2 3
2 Marks Questions 9 7 6 12 4 4 2 4 7 2 2 2 4
Total Marks 22 14 14 24 10 9 7 10 15 6 5 6 11
Programming and Data Structures
1 Marks Questions 5 0 1 1 1 3 4 2 2 0 5 2 4
2 Marks Questions 3 6 3 3 3 5 7 6 5 2 3 5 4
Total Marks 11 12 7 7 7 13 18 14 12 4 11 12 12
Algorithm
1 Marks Questions 2 8 3 2 3 1 1 4 5 1 4 4 2
2 Marks Questions 10 7 12 15 6 3 0 2 3 2 4 5 2
Total Marks 22 22 27 32 15 7 1 8 11 5 12 14 6
Compiler Design
1 Marks Questions 1 1 1 2 1 2 1 1 2 1 2 1 2
2 Marks Questions 5 5 5 2 0 1 0 3 2 2 1 1 1
Total Marks 11 11 11 6 1 4 1 7 6 5 4 3 4
Operating System
1 Marks Questions 0 1 2 2 2 3 3 1 1 0 2 1 2
2 Marks Questions 2 8 6 5 5 2 2 3 1 2 2 4 2
Total Marks 4 17 14 12 12 7 7 7 3 4 6 9 6
Database
1 Marks Questions 3 1 0 1 0 3 0 3 1 3 1 3 2
2 Marks Questions 4 4 6 5 5 2 3 3 4 2 2 1 3
Total Mark 11 9 12 11 5 7 6 9 9 7 5 5 8
Computer Networks
1 Marks Questions 5 1 2 1 0 2 5 3 4 4 2 2 2
2 Marks Questions 2 5 6 4 5 3 2 3 2 2 3 4 3
Total Marks 9 11 14 9 5 8 9 9 8 8 8 10 8
Software Engineering
1 Marks Questions 1 0 1 0 0 1 1
2 Marks Questions 0 0 0 0 1 0 1
Total Marks 1 0 1 0 2 1 3
Web Technology
1 Marks Questions 1 0 1 0 0 0 1
2 Marks Questions 0 0 0 0 0 0 1
Total Marks 1 0 1 0 0 0 3
19. General Information about GATE
Structure of GATE
The GATE examination consists of a single online paper of 3-hour duration, in which there will be a total of 65 questions
carrying 100 marks out of which 10 questions carrying a total of 15 marks are in General Aptitude (GA).
Section Weightage and Marks
70% of the total marks is given to the technical section while 15% weightage is given to General Aptitude and Engineering
Mathematics each.
Weightage Questions (Total 65)
Respective
EngineeringBranch
70 Marks 25—1markques-
tions30—2mark
questions
EngineeringMaths 15 Marks
GeneralAptitude 15 Marks 5—1markques-
tions5—2mark
questions
Particulars
For 1-mark multiple-choice questions, 1/3 marks will be deducted for a wrong answer. Likewise, for 2-mark multiple-choice
questions, 2/3 marks will be deducted for a wrong answer.There is no negative marking for numerical answer type questions.
QuestionTypes
1. Multiple Choice Questions (MCQ) carrying 1 or 2 marks each in all papers and sections. These questions are
objective in nature, and each will have a choice of four answers, out of which the candidate has to mark the correct
answer.
2. Numerical Answer carrying 1 or 2 marks each in all papers and sections. For numerical answer questions, choices
will not be given. For these questions the answer is a real number, to be entered by the candidate using the virtual
keypad. No choices will be shown for this type of questions.
Design of Questions
The fill in the blank questions usually consist of 35%– 40% of the total weightage.
The questions in a paper may be designed to test the following abilities:
1. Recall: These are based on facts, principles, formulae or laws of the discipline of the paper.The candidate is expected
to be able to obtain the answer either from his/her memory of the subject or at most from a one-line computation.
2. Comprehension: These questions will test the candidate’s understanding of the basics of his/her field, by requiring
him/her to draw simple conclusions from fundamental ideas.
3. Application: In these questions, the candidate is expected to apply his/her knowledge either through computation or
by logical reasoning.
4. Analysis and Synthesis: In these questions, the candidate is presented with data, diagrams, images etc. that require
analysis before a question can be answered. A Synthesis question might require the candidate to compare two or
more pieces of information. Questions in this category could, for example, involve candidates in recognising unstated
assumptions, or separating useful information from irrelevant information.
About Online Pattern
The examination for all the papers will be carried out in an ONLINE Computer Based Test (CBT) mode where the candi-
dates will be shown the questions in a random sequence on a computer screen. The candidates are required to either select
the answer (for MCQ type) or enter the answer for numerical answer-type question using a mouse on a virtual keyboard
(keyboard of the computer will be disabled). The candidates will also be allowed to use a calculator with which the online
portal is equipped with.
20. Important Tips for GATE
The followings are some important tips which would be helpful for students to prepare for GATE exam
1. Go through the pattern (using previous year GATE paper) and syllabus of the exam and start preparing accordingly.
2. Preparation time for GATE depends on many factors, such as, individual’s aptitude, attitude, fundamentals,
concentration level etc., Generally rigorous preparation for 4 to 6 months is considered good but it may vary from
student to student.
3. Make a list of books which cover complete syllabus, contains solved previous year questions and mock tests for
practice based on latest GATE pattern. Purchase these books and start your preparation.
4. Make a list of topics which needs to be studied and make priority list for study of every topic based upon the marks
for which that particular topic is asked in GATE exam. Find out the topics which fetch more marks and give more
importance to those topics. Make a timetable for study of topics and follow the timetable strictly.
5. An effective way to brush up your knowledge about technical topics is group study with your friends. During group
study you can explore new techniques and procedures.
6. While preparing any subject highlight important points (key definitions, equations, derivations, theorems and laws)
which can be revised during last minute preparation.
7. Pay equal attention to both theory and numerical problems. Solve questions (numerical) based on latest exam pattern
as much as possible, keeping weightage of that topic in mind. Whatever topics you decide to study, make sure that
you know everything about it.
8. Try to use short-cut methods to solve problems instead of traditional lengthy and time consuming methods.
9. Go through previous year papers (say last ten years), to check your knowledge and note the distribution of different
topics. Also analyze the topics in which you are weak and concentrate more on those topics. Always try to solve
papers in given time, to obtain an idea how many questions you are able to solve in the given time limit.
10. Finish the detail study of topics one and a half month before your exam. During last month revise all the topics once
again and clear leftover doubts.
21. GATE 2017 Solved Paper
CS: Computer Science and Information Technology
Set – 1
Number of Questions: 65 Total Marks:100.0
Wrong answer for MCQ will result in negative marks, (-1/3) for 1 Mark Questions and (-2/3) for 2 Marks Question.
Computer Science Engineering
Number of Questions: 55 Section Marks: 85
Q.1 to Q.25 carry 1 mark each and Q.26 to Q.55 carry 2
marks each.
Question Number: 1 Question Type: MCQ
The statement (¬p) ⇒ (¬q) is logically equivalent to which
of the statements below?
I. p ⇒ q
II. q ⇒ p
III. (¬ q) ∨ p
IV. (¬ p) ∨ q
(A) I only (B) I and IV only
(C) II only (D) II and III only
Solution: We have (¬ p) ⇒ (¬ q)
≡ q ⇒ p
( An implication and its contra positive are equivalent)
∴II is equivalent to (¬ p) ⇒ (¬ q)
Also, (¬ p) ⇒ (¬ q) ≡ q ⇒ p
≡ (¬ q) ∨ p ( A ⇒ B ≡ ¬ A ∨ B)
∴ III is equivalent to (¬ p) ⇒ (¬ q)
Hence, the correct option is (D).
Question Number: 2 Question Type: MCQ
Consider the first-order logic sentence F:∀x(∃yR(x,y)).
Assuming non-empty logical domains, which of the sen-
tences below are implied by F?
I. ∃y(∃xR(x,y))
II. ∃y(∀xR(x,y))
III. ∀y(∃xR(x,y))
IV. ¬∃x(∀y ¬R(x,y))
(A) IV only (B) I and IV only
(C) II only (D) II and III only
Solution: Given F: ∀ x (∃ y R (x, y))
≡ [¬(¬(∀ x (∃ y R (x, y)))] ( p ≡ ¬ p)
≡ [¬ (∃ x (¬(∃ y R (x, y))))] ( ¬ ((∀ t) P (t)) ≡ ∃ t
(¬ P (t)))
≡ [¬ (∃ x (∀ y ¬ R (x, y)))] ( ¬ (∃ t P (t)) ≡ ∀ t ¬
P (t))
∴ IV is implied by F.
Also, F : ∀ x (∃ y R (x, y)) implies ∃ x (∃ y R (x, y)) (∀ x
(∃ y P (x, y) implies ∃ x (∃ y P (x, y))
Also, ∃ x (∃ y R (x, y)) implies ∃ y (∃ x R (x, y))
∴ F: ∀ x (∃ y R (x, y)) implies ∃ y (∃ x R (x, y))
∴ I is implied by F: ∀ x (∃ y R (x, y))
Hence, the correct option is (B).
Question Number: 3 Question Type: MCQ
Let c1
,…,cn
be scalers, not all zero, such that
1
0
n
i i
i
c a
=
=
∑
where ai
are column vectors in Rn
.
Consider the set of linear equations
Ax = b
Where A = [a1
,…,an
] and
1
n
i
i
b a
=
= ∑ . The set of equations
has
(A)
a unique solution at x = Jn
where Jn
denotes a
n-dimensional vector of all 1
(B) no solution
(C) infinitely many solutions
(D) finitely many solutions
Solution: As 1 2
, ,...., n
a a a are column vectors, such that
1
0
=
=
∑
n
i i
i
c a for some set of scalars 1 2
, ,...., n
c c c not all zero,
1 2
, ,...., n
a a a are linearly dependent.
∴ The rank of the matrix [ ]
1 2 3
, , ...., n
A a a a a
= is less
than n.
Also, given that
1
=
= ∑
n
i
i
b a
Consider the set of linear equations:
AX = b
i.e., [ ]
1
2
1 2
, ,...., .
.
=
n
n
x
x
a a a b
x
(1)
By taking 1 2..... 1,
= = =
n
x x x equation (1) is satisfied
As AX = b has a solution and rank of A is less than n (= The
number of unknowns), AX = b has infinitely many solutions.
Hence, the correct option is (C).
22. GATE 2017 Solved Paper CS: Set – 1 | xvii
Question Number: 4 Question Type: MCQ
Consider the following functions from positive integers to
real numbers:
10, n , n, log2
n,
100
n
.
The CORRECT arrangement of the above functions in
increasing order of asymptotic complexity is:
(A) 2
100
log , ,10, ,
n n n
n
(B) 2
100
,10, log , ,
n n n
n
(C) 2
100
10, , ,log ,
n n n
n
(D) 2
100
,log , 10, ,
n n n
n
Solution: 2
100
10, , , log ,
n
n n
n
According to dominance ranking, for large values of ‘n’ in-
creasing order of asymptotic complexity is
2
100
,10, log , ,
n n n
n
Hence, the correct option is (B).
Question Number: 5 Question Type: MCQ
Consider the following table:
Algorithms Design Paradigms
(P) Kruskal (i) Divide and Conquer
(Q) Quicksort (ii) Greedy
(R) Floyd-Warshall (iii) Dynamic Programming
Match the algorithms to the design paradigms they are
based on.
(A) (P) ↔ (ii), (Q) ↔ (iii), (R) ↔ (i)
(B) (P) ↔ (iii), (Q) ↔ (i), (R) ↔ (ii)
(C) (P) ↔ (ii), (Q) ↔ (i), (R) ↔ (iii)
(D) (P) ↔ (i), (Q) ↔ (ii), (R) ↔ (iii)
Solution: The design strategy for Kruskals algorithm is
greedy method.
Quick sort is implemented using Divide and Conquer strat-
egy.
Floyd-warshall algorithm is implemented using dynamic
programming.
Hence, the correct option is (C).
Question Number: 6 Question Type: MCQ
Let T be a binary search tree with 15 nodes. The minimum
and maximum possible heights of T are:
Note: The height of a tree with a single node is 0.
(A) 4 and 15 respectively
(B) 3 and 14 respectively
(C) 4 and 14 respectively
(D) 3 and 15 respectively
Solution: Binary Search Tree (BST) with 15 nodes, the
minimum height possible, when it is complete BST, which
is of height 3.
Maximum height is possible when BST is either left
skewed or right skewed, which is of height 14.
Hence, the correct option is (B).
Question Number: 7 Question Type: MCQ
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
)
Solution: Given fixed-point representation has the form.
integral fraction
f
i
n-bits
These numbers are in unsigned form.
The least number possible is 0.00 …. 0 (last bit of fraction
is 1). = 0
The largest number possible is 1111 ….. 1.1111 …. 1
(i 1’s in integral and f 1’s in fractional part).
The range of integral part is 2i
−1 (for unsigned).
The range of fraction part is 2
1 1 1
.....
2 2 2f
+ + + = 1 − 2−f
∴ The highest number possible is 2 1 1 2
i f
−
− + − = 2i
− 2-f
∴ Required range is 0 to 2i
− 2-f
Hence, the correct option is (D).
23. xviii | GATE 2017 Solved Paper CS: Set – 1
Question Number: 8 Question Type: MCQ
Consider the C code fragment given below.
typedef struct node {
int data;
node* next;
} node;
void join (node* m, node* n) {
node* p = n;
while (p − next != NULL) {
p = p − next;
}
p − next = m;
}
Assuming that m and n point to valid NULL-terminated
linked lists, invocation of join will
(A) append list m to the end of list n for all inputs.
(B)
either cause a null pointer dereference or append
list m to the end of list n.
(C) cause a null pointer dereference for all inputs.
(D) append list n to the end of list m for all inputs.
Solution: The above code appends list m to the end of list n
(or) it may cause null pointer dereference error which may
leads to segmentation fault, it happens when a page fault
handler fails.
Hence, the correct option is (B).
Question Number: 9 Question Type: MCQ
When two 8-bit numbers A7
… A0
and B7
… B0
in 2’s comple-
ment 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 over-
flow is said to have occurred if
(A) the carry bit C7
is 1
(B) all the carry bits (C7
,…,C0
) are 1
(C) 7 7 7 7 7 7
( )
A B S A B S
⋅ ⋅ + ⋅ ⋅ is 1
(D) 0 0 0 0 0 0
( )
A B S A B S
⋅ ⋅ + ⋅ ⋅ is 1
Solution: Overflow occurs only when
A7
:1 A7
:0
B7
:1 (or) B7
:0
S7
:0 S7
:1
∴ Overflow condition is given as
7 7
7
7 7 7.
A B S A B S
+
Hence, the correct option is (C).
Question Number: 10 Question Type: MCQ
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 represents the language gener-
ated by the above grammar?
(A) {(ab)n
(cb)n
| n ≥ 1}
(B) ( ) 1 2
1 2
{ | , , , , 1}
n
n m
m m
n
ab cb cb cb n m m m
… … ≥
(C) {(ab)n
(cbm
)n
| m, n ≥ 1}
(D) {(ab)n
(cbn
)m
| m, n ≥ 1}
Solution: Given grammar
S → abScT | abcT
T → bT | b
The strings of this grammar are,
1. S → abcT
→ abcb
2. S → abcT
→ abcbT
→ abcbb
3. S → ab ScT
→ ab abcTcT
→ ab ab cb cb
4. S → abScT
→ ab ab cTcT
→ ab abc bT cbT
→ ab ab cbbT cbb
→ ab ab cb bb cbb
Choice ( ) ( ) ( )
{ }
A : 1
n n
ab cb n ≥
This generates equal number of ‘ab’ and ‘cb’’s. So, this is
not equivalent to given grammar.
Choice ( ) ( )
{ }
1 2
1 2
B : ..... , , ,..., 1
n
n m
m m
n
ab cb cb cb n m m m ≥
This generates strings like
( ) ( )
1 1 2
1 1 2
1 , , 1
m m m
abcb m ababcb cb m m
≥ ≥ .
∴ This is equivalent to given grammar.
Choice ( ) ( ) ( )
{ }
C : , 1
n
n m
ab cb m n ≥ .
This generates strings like
( ) ( ) ( )
2
1 , 1
m m
abcb m abab cb m
≥ ≥ .
(This cannot generate the strings like ab ab cbb cb).
Choice (D): This generates strings of the form ab cb cb, ab
ab cbb.
Hence, the correct option is (B).
Question Number: 11 Question Type: MCQ
Consider the C struct defined below:
struct data {
int marks [100];
char grade;
24. GATE 2017 Solved Paper CS: Set – 1 | xix
int cnumber;
};
struct data student;
The base address of student is available in register R1.
The field student.grade can be accessed efficiently
using
(A) Post-increment addressing mode, (R1)+
(B) Pre-decrement addressing mode, − (R1)
(C) Register direct addressing mode, R1
(D)
Index addressing mode, X(R1), where X is an off-
set represented in 2’s complement 16-bit represen-
tation.
Solution: Student grade can be accessed efficiently using
index addressing mode.
X (R1
)
R1
is base address of student.
X is an offset.
The effective address of student grade is
R
X
1 100
+ ×
[( ) ( )]
size of int
Hence, the correct option is (D).
Question Number: 12 Question Type: MCQ
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 (B) p3
= a − b
q1
= p1
* c
q4
= p3
* c
p1
= u * v
p4
= u * v
q1
= p1
+ q1
q5
= p4
+ q4
(C) p1
= a − b (D) p1
= a − b
q1
= p2
* c
q1
= p * c
p3
= u * v
p2
= u * v
q2
= p4
+ q3
q2
= p + q
Solution: In static single assignment, each assignment to a
temporary variable is given a unique name and all the uses
reached by that assignment are renamed. Option (B) gives
the static single assignment form for the above code.
Hence, the correct option is (B).
Question Number: 13 Question Type: MCQ
Consider the following C code:
# include stdio.h
int *assignval (int *x, int val) {
*x = val;
return x;
}
void main ( ) {
int *x = malloc (sizeof (int));
if (NULL == x) return;
x = assignval (x, 0);
if (x) {
x = (int *) malloc (sizeof
(int));
if (NULL == x) return;
x = assignval (x, 10);
}
printf(“%dn”, *x);
free (x);
}
The code suffers from which one of the following problems:
(A)
compiler error as the return of malloc is not type-
cast appropriately
(B)
compiler error because the comparison should be
made as x == NULL and not as shown
(C)
compiles successfully but execution may result in
dangling pointer
(D)
compiles successfully but execution may result in
memory leak
Solution: The above program compiles successfully, but
the execution may result in the memory leak.
Hence, the correct option is (D).
Question Number: 14 Question Type: MCQ
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 seg-
ment is sent to the TCP server. Server-side TCP responds
by sending an 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
Solution: Fin-wait-1 state sends a segment, at which
close-wait state sends an ACK to the Fin-wait-2 state.
Hence, the correct option is (D).
Question Number: 15 Question Type: MCQ
A sender S sends a message m to receiver R, which is digi-
tally 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.
25. xx | GATE 2017 Solved Paper CS: Set – 1
Which of the following are possible security violations?
(A) (I) and (II) only
(B) (I) only
(C) (II) only
(D) (II) and (III) only
Solution: Sender can launch a birthday attack, which re-
places the message ‘m’ with fraud message.
Hence, the correct option is (B).
Question Number: 16 Question Type: MCQ
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 set of functional dependencies?
(A) V → W (B) V → W
V → X W → X
Y → V
Y → V
Y → Z Y → Z
(C) V → W (D) V → W
V → X
W → X
Y → V
Y → V
Y → X
Y → X
Y → Z Y → Z
Solution: Given FD’s :
V → W
VW → X
Y → VX
Y → Z
Using pseudotransitive rule, {V → W, VW → X} | = V → X.
Using projection rule, {Y → VX}| = Y → V, Y → X.
∴ Equivalent set of FD’s for given FD’s is
V → W
V → X
Y → V
Y → X
Y → Z
Irreducible equivalent set of FD’s is
V → W
V → X
Y → V
Y → Z
( X can be derived from either V or Y, so remove Y → X).
Hence, the correct option is (A).
Question Number: 17 Question Type: MCQ
Consider the following grammar:
→
→
→ ε
→
|
|
P xQRS
Q yz z
R w
S y
What is FOLLOW (Q)?
(A) {R} (B) {w}
(C) {w, y} (D) {w, $}
Solution: Consider the grammar given
P → x Q R S
Q → y z | z
R → w | ε
S → y
Follow (Q) = First (RS)
= First (R) – {ε} ∪ first (S)
= {w} ∪ {y}
= {w, y}
Hence, the correct option is (C).
Question Number: 18 Question Type: MCQ
Threads of a process share
(A) global variables but not heap.
(B) heap but not global variables.
(C) neither global variables nor heap.
(D) both heap and global variables.
Solution: Each program has 4 segments: Stack, Data,
Code, Heap.
All the threads of a process share all the segments except
the stack. Global variables are stored in heap. So, threads of
a process share both heap and global variable.
Hence, the correct option is (D).
Question Number: 19 Question Type: NAT
Let X be a Gaussian random variable with mean 0 and vari-
ance σ2
. Let Y = max (X, 0) where max (a, b) is the maxi-
mum of a and b. The median of Y is .
Solution: Given that X is a Gaussian random variable
Also given, mean of X = 0
Variance of X = s2
We know that in Gaussian distribution,
Mean = Median
Given Y = max. (X, 0)
0; 0
; 0
if X
X if X
=
Hence, the median of Y = Median of X = 0
Hence, the correct answer is (0).
26. GATE 2017 Solved Paper CS: Set – 1 | xxi
Question Number: 20 Question Type: NAT
Let T be a tree with 10 vertices. The sum of the degrees of
all the vertices in T is _______
Solution: Number of vertices (V) for given tree T is 10.
Numbers of regions (R) for a tree is 1.
we have
R = E – V + 2
For the above tree, numbers of vertices are 10,
1 = E – 10 + 2
E = 9
Sum of all degrees of all vertices are twice the number of
edges, i.e., 18
Hence, the correct answer is (18).
Question Number: 21 Question Type: NAT
Consider the Karnaugh map given below, where X repre-
sents “don’t care” and blank represents 0.
X X
X
1
X
X
1
1
00
00 01 11 10
01
10
11
ba
dc
Assume for all inputs (a, b, c, d), the respective comple-
ments ( , , , )
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 ________.
Solution:
00
ba
bc
11
01
00
10
10
11
01
X
1
1
X
X
X
X
1
1
Simplified expression is ca
a
c
c a
+
ca
=
Hence, we need one NOR gate.
Hence, the correct answer is (1).
Question Number: 22 Question Type: NAT
Consider the language L given by the regular expression (a
+ b)*b (a + b) over the alphabet {a, b}. The smallest num-
ber of states needed in a deterministic finite-state automaton
(DFA) accepting L is ________.
Solution: Given regular expression:
R = (a + b) * b (a + b)
The NFA for given R is
1 2
b a, b
a, b
3
The DFA equivalent to this NFA is
q δ a b
A{1} {1} {1, 2}
B{2} {3} {3}
C{3} φ φ
D{1, 2} {1, 3} {1, 2, 3}
E{1, 3} {1} {1, 2}
F{1, 2, 3} {1, 3} {1, 2, 3}
a
a
A D
F
E
a
a
b
b
b
b
(B, C states are not reachable from initial state).
Hence, the correct answer is (4).
Question Number: 23 Question Type: NAT
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.
27. xxii | GATE 2017 Solved Paper CS: Set – 1
EMP
( )
( )
( )
( )
SELECTIVE AVG EC.Num
FROM EC
WHERE DeptName, Num IN
(SELECT DeptName, COUNT EmpId AS
EC DeptName, Num
FROM EMP
GROUP BY DeptName)
EmpId EmpName DeptName
1 XYA AA
2 XYB AA
3 XYC AA
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 output of executing the SQL query is ______.
Solution: Based on given query EC table has Dept Name,
Count (EMPID) from EMP Table.
EC
Dept Name Num
AA 4
AB 3
AC 3
AD 2
AE 1
Average (EC. Num)
4 3 3 2 1
5
+ + + +
=
13
5
=
= 2.6
Hence, the correct answer is (2.6).
Question Number: 24 Question Type: NAT
Consider the following CPU processes with arrival times
(in milliseconds) and length of CPU bursts (in millisec-
onds) as given below :
Process Arrival time Burst time
P1 0 7
P2 3 3
P3 5 5
P4 6 2
If the pre-emptive shortest remaining time first scheduling
algorithm is used to schedule the processes, then the aver-
age waiting time across all processes is milliseconds.
Solution: For the given processes using preemptive SRTF,
the Gantt chart will be as below:
P1
P3 :5
P4 : 2
P1 : 4
P3 :5
P1 : 4
0 2 4 5 6 7 8 10 11 12 13
P1 P1 P1 P1 P1 P1 P3
P2 P2 P2 P4 P4
1 3 9
P1 :4
P2 : 3
P2 :1
P3 : 5
Waiting time of P1 = 5
Waiting time of P2 = 0
Waiting time of P3 = 12 − 5 = 7
Waiting time of P4 = 0
∴ Average waiting time 5 7
3
4
+
= =
Hence, the correct answer is (3).
Question Number: 25 Question Type: NAT
Consider a two-level cache hierarchy with L1 and L2 caches.
An application incurs 1.4 memory accesses per instruction
on average. For this application, the miss rate of L1 cache is
0.1; the L2 cache experiences on average 7 misses per 1000
instructions. The miss rate of L2 expressed correct to two
decimal places is .
Solution:
Number of misses
Miss rate
Total number of accesses
=
7
1000 1.4
=
×
= 0.05
Hence, the correct answer is (0.05).
Question Number: 26 Question Type: MCQ
Let G = (V,E) be any connected undirected edge-weighted
graph. The weights of the edges in E are positive and dis-
tinct. Consider the following statements:
28. GATE 2017 Solved Paper CS: Set – 1 | xxiii
(I) Minimum spanning Tree of G is always unique.
(II)
Shortest path between any two vertices of G is always
unique.
Which of the above statements is/are necessarily true?
(A) (I) only
(B) (II) only
(C) both (I) and (II)
(D) neither (I) nor (II)
Solution:
•
When the edge weights of a graph ‘G’ are unique, then
the minimum spanning tree for graph ‘G’ is unique.
•
Shortest path between any 2 vertices of graph may not
be always unique.
Consider the following graph with above scenario.
D C
B
A
4
3
1
2
5
The MST for the above graph ‘G’ is
D C
B
A
4
1
2
The shortest path from vertex A to C is given by two paths.
i.e.,
B
1 2
3
C
C
A
A
Hence, the correct option is (A).
Question Number: 27 Question Type: MCQ
A multithreaded program P executes with x number of
threads and uses y number of locks for ensuring mutual
exclusion while operating on shared memory locations. All
locks in the program are non-reentrant, i.e., if a thread holds
a lock l, then it cannot re-acquire lock l without releasing
it. If a thread is unable to acquire a lock, it blocks until the
lock becomes available. The minimum value of x and the
minimum value of y together for which execution of P can
result in a deadlock are:
(A) x = 1, y = 2 (B) x = 2, y = 1
(C) x = 2, y = 2 (D) x = 1, y = 1
Solution: As the non reentrant locks not allow a thread to
reacquire the lock, so only one thread and only one lock can
lead to deadlock, if it tries to reacquire the lock.
Hence, the correct option is (D).
Question Number: 28 Question Type: MCQ
The value of
7 5
3 2
1
2 1
lim
3 2
x
x x
x x
→
− +
− +
(A) is 0
(B) is −1
(C) is 1
(D) does not exist
Solution: We have
7 5
3 2
1
2 1
lim
3 2
→
− +
− +
x
x x
x x
6 4
2
1
7 10
lim
3 6
→
−
=
−
x
x x
x x
(By L’ Hospital’s Rule)
7 10
3 6
−
=
−
= 1
Hence, the correct option is (C).
Question Number: 29 Question Type: MCQ
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.
Solution: Given that (p → q) → r is a contradiction.
This is possible only when p → q is TRUE and r is FALSE.
p → q is TRUE only when p and q can have any combina-
tion of truth values except p is TRUE and q is FALSE.
Consider the expression, (r → p) → q
As r is FALSE, r → p is always TRUE.
∴ (r → p) → q is TRUE when q is TRUE and (r → p) → q
is FALSE when q is FALSE.
So, (r → p) → q is always TRUE when q is TRUE.
Hence, the correct option is (D).
Question Number: 30 Question Type: MCQ
Let u and v be two vectors in R2
whose Euclidean norms
satisfy ||u||= 2||v||. What is the value of α such that w = u +αv
bisects the angle between u and v?
(A) 2 (B) 1/2
(C) 1 (D) −1/2
29. xxiv | GATE 2017 Solved Paper CS: Set – 1
Solution: For two vectors u and v, || u || = 2 || v ||
⇒ u and 2v will have the same length.
We know that if two vectors v1
and v2
have the same length,
then v1
+ v2
bisects the angle between v1
and v2
.
As || u || = 2|| v ||, u + 2v bisects the angle between the vec-
tors u and 2v.
Also, we know that the angle between u and v is same as the
angle between u and 2v.
So, u + 2v bisects the angle between the vectors u and v.
∴ W = u + α v bisects the angle between u and v when α
= 2.
Hence, the correct option is (A).
Question Number: 31 Question Type: MCQ
Let A be n × n real valued square symmetric matrix of rank
2 with 2
1 1
50
n n
ij
i j
A
= =
=
∑∑ . 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)
Solution: Case (i):-
Let n 2.
∴ P(A) = 2 order of A.
⇒ A is a singular matrix.
⇒ O is an eigen value of A and 06[-5, 5]
∴ I is correct.
Also for A =
−
5 0 0
0 0 0
0 0 5
, none of the eigen values have
magnitude not greater than 5.
So, II is not correct.
Case (II):- Let n = 2
Consider the matrix B =
−
5 0
0 5
Clearly the eigen values of B lie in [-5, 5].
But none of its eigen values have magnitude greater than 5.
Hence, the correct option is (B).
Question Number: 32 Question Type: MCQ
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
Solution: Given polynomial generator as x3
+ x + 1, then
generator will be 1011.
Given data = 01011011
Message transmitted will be:
1011 01011011000
0000
1011
1011
00000
0000
0000
0000
0110
0000
1100
1110
1101
101
1011
0011
0001
01000011
The transmitted message is 01011011101.
Hence, the correct option is (C).
Question Number: 33 Question Type: MCQ
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.
Clock
Q1 Q0
T
Filp-
Flop
D
Filp-
Flop
Initially, both Q0
and Q1
are set to 1 (before the 1st
clock
cycle). The outputs
(A) Q1
Q0
after the 3rd
cycle are 11 and after the 4th
cycle are 00 respectively
(B) Q1
Q0
after the 3rd
cycle are 11 and after the 4th
cycle are 01 respectively
(C) Q1
Q0
after the 3rd
cycle are 00 and after the 4th
cycle are 11 respectively
(D) Q1
Q0
after the 3rd
cycle are 01 and after the 4th
cycle are 01 respectively
30. GATE 2017 Solved Paper CS: Set – 1 | xxv
Solution:
D
F F
T
F F
Q1 Q0
Clock
present state next state
Q1
Q0
Q1
+
Q0
+
1 1 0 1
0 1 1 0
1 0 1 1
1 1 0 0
Hence, the correct option is (B).
Question Number: 34 Question Type: MCQ
If G is a grammar with productions
S → SaS | aSb | bSa | SS |∈
Where S is the start variable, then which one of the follow-
ing strings is not generated by G?
(A) abab (B) aaab
(C) abbaa (D) babba
Solution: Given grammar
S → SaS | aSb | bSa | SS | E
abab:
S → aSb
→ abSab
→ abab
aaab:
S → aSb
→ aSaSb
→ aSaSaSb
→ aaab
abbaa:
S → SS
→ aSbSS
→ abbSaSaS
→ abbaa
babba:
C → bSa
→ baSba
→ ba ba
babba not derivable from S.
Hence, the correct option is (D).
Question Number: 35 Question Type: MCQ
Consider the following two functions.
void fun1 (int n) { void fun2 (int n) {
if (n == 0) return; if (n == 0) return;
printf (“%d”, n); printf (“%d”, n);
fun2 (n − 2) ; fun1(++n)
printf (“%d”, n); printf (“%d”, n);
} }
The output printed when fun1 (5) is called is
(A) 53423122233445 (B) 53423120112233
(C) 53423122132435 (D) 53423120213243
Solution:
fun 1(5)
Print (5) Print (5)
Print (3)
Print (4) Print (4)
Print (4)
Print (2)
Print (3) Print (3)
Print (3)
Print (1)
Print (2) Print (2)
Print (2)
fun 2(3)
fun 1(4)
fun 2(2)
fun 1(3)
fun 2(1)
fun 1(2)
fun 2(0)
It prints
5 3 4 2 3 1 2 2 2 3 3 4 4 5
Hence, the correct option is (A).
31. xxvi | GATE 2017 Solved Paper CS: Set – 1
Question Number: 36 Question Type: MCQ
Consider the C functions foo and bar given below:
int foo (int val) {
int x = 0;
while (val 0) {
x =x + foo (val−−);
}
return val;
}
int bar (int val) {
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 respec-
tively.
(D) Both terminating abnormally.
Solution: foo (3) terminates abnormally, while bar (3)
gets into infinite loop.
Hence, the correct option is (C).
Question Number: 37 Question Type: MCQ
Consider the context-free rammers 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.
Solution: The strings of L (G1
) are {ε, c, cc … c, ab, acb,
ac … cb, …}
The strings of L (G2
) are {ε, c, cc, … c, ba, bca, bc, ….
ca, …}
L (G1
) ∩ L (G2
) = {ε, c, cc, c, … c,}
The resultant grammar can have zero or more c’s.
This is regular and not finite.
Hence, the correct option is (B).
Question Number: 38 Question Type: MCQ
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}.
Which of the following are context-free languages?
I. L1
∪ L2
II. L1
∩ L2
(A) I only (B) II only
(C) I and II (D) Neither I nor II
Solution: Given :
{ }
1 , 0
n n m
L a b c m n
= ≥
{ }
2 , 0
m n n
L a b c m n
= ≥
Here both L1
and L2
are context-free languages.
CFL’s are under union but not under intersection.
L1
∪ L2
needs to check the equality of number of a’s and b’s
or equality of number of b’s and c’s.
∴ L1
∪ L2
is CFL.
L1
∩ L2
requires equal number of a’s, b’s and c’s. A PDA
cannot check this.
∴ L1
∩ L2
is not CFL.
Hence, the correct option is (A).
Question Number: 39 Question Type: MCQ
Let A and B be finite alphabets and let # be a symbol out-
side both A and B. Let f be a total function from A* to B*.
We say f is computable if there exists a turning 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 enu-
merable.
(C) If f is computable then Lf
is recursive, but not con-
versely.
(D) If f is computable then Lf
is recursively enumer-
able, but not conversely.
Solution: A computable function is same as recursive
function. Hence, choice (A) is correct.
Hence, the correct option is (A).
Question Number: 40 Question Type: MCQ
Recall that Belady’s anomaly is that the page-fault rate may
increase as the number of allocated frames increases. Now,
consider the following statements:
S1:
Random page replacement algorithm (where a page
chosen at random is replaced) suffers from Belady’s
anomaly
S2:
LRU page replacement algorithm suffers from Be-
lady’s anomaly
Which of the following is CORRECT?
(A) S1 is true, S2 is true (B) S1 is true, S2 is false
(C) S1 is false, S2 is true (D) S1 is false, S2 is false
Solution: Random page replacement algorithm simulates
FIFO. So, there is a possibility of Belady’s anomaly.
32. GATE 2017 Solved Paper CS: Set – 1 | xxvii
There is no possibility of Belady’s anomaly in LRU.
∴ S1
is true.
S2
is false.
Hence, the correct option is (B).
Question Number: 41 Question Type: MCQ
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.
(I) {t | ∃u ∈ EMP(t[EmpName] = u[EmpName] ∧ ∀ v ∈
DEPT(t[DeptId] ≠ v[DeptId]))}
(II) {t | ∃u ∈ EMP(t[EmpName] = u[EmpName] ∧ ∃ v ∈
DEPT(t[DeptId] ≠ v[DeptId]))}
(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)
Solution: All the queries are safe expressions.
( All giving finite tuples).
Hence, the correct option is (D).
Question Number: 42 Question Type: MCQ
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
T2
has requested a conflicting lock on the same resource
R. The following algorithm is used to prevent deadlocks 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 eventu-
ally. 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 star-
vation-free.
(C)
The database system is starvation-free, but not
deadlock-free.
(D)
The database system is neither deadlock-free nor
starvation-free.
Solution: Given Time Stamp algorithm is same as wound-
wait time stamp algorithm, which is free from deadlock and
starvation-free.
Hence, the correct option is (A).
Question Number: 43 Question Type: NAT
Consider the following grammar:
stmt − if expr then expr else expr; stmt | Ò
expr − term relop term | term
term − id | number
id − a | b | c
number − [0 − 9]
where relop is a relational operator (e.g., , ,…), Ò refers
to the empty statement, and if, then, else are terminals.
Consider a program P following the above grammar con-
taining 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.
Solution: The flow graph for the above grammar for ten if
terminals is given below:
The number of control flow paths will be 210
.
Hence, the correct answer is (1024).
33. xxviii | GATE 2017 Solved Paper CS: Set – 1
Question Number: 44 Question Type: NAT
In a RSA cryptosystem, a participant A uses two prime
numbers p = 13 and q = 17 to generate her public and pri-
vate keys. If the public key of A is 35, then the private key
of A is _________.
Solution: Given two prime numbers, p = 13, q = 17
RSA algorithm:-
(1) p = 13, q = 17
(2) n = p × q
= 13 × 17 ⇒221
z = (p − 1) × (q − 1)
= 12 × 16
= 192
Given public key as 35 (i.e. e = 35)
(3) (d * e) mod Z = 1
(d * 35) mod 192 = 1
d = 11
Hence, the correct answer is (11).
Question Number: 45 Question Type: NAT
The values of parameters for the Stop-and Wait ARQ proto-
col are as given below:
Bit rate of the transmission channel = 1Mbps.
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
stop-and-wait ARQ protocol for the above parameters is
________ (correct to 2 decimal places)
Solution: Transmission time =
length of data
band width
= 6
2000×8 bits
10 bps
= 16 m sec
Propagation time = 0.75 m sec
ACK transmission time = 6
40×8 bits
10 bps
= 0.32 m sec
Time to process a frame = 0.25 sec
Transmission efficiency (Stop an wait)
16
0.5 16 1.5 0.32
+ + +
200
100
229
87.3
= ×
=
Hence, the correct answer is (87.3).
Question Number: 46 Question Type: NAT
Consider a database that has the relation schema CR (stu-
dentName, CourseName). An instance of the schema CR is
as given below.
CR
StudentName CourseName
SA CA
SA CB
SA CC
SB CB
SB CC
SC CA
SC CB
SC CC
SD CA
SD CB
SD CC
SD CD
SE CD
SE CA
SE CB
SF CA
SF CB
SF CC
The following query is made on the database.
' '
1 ( (CR))
CouraseName StudentName SA
T p s =
←
2 1
T CR T
← ÷
The number of rows in T2 is .
Solution: The resultant of studentName = ‘SA’ (CR) is :
StudentName CourseName
SA CA
SA CB
SA CC
πCourseName
(studentName = ‘SA’ (CR)) resultant is T1
and is
equal to :
Course Name
CA
CB
CC
Now, T2
contains CR ÷ T1
.
T2
contains the StudentName’s who are enrolled for all the 3
courses CA, CB, CC. i.e.
34. GATE 2017 Solved Paper CS: Set – 1 | xxix
T2
Student Name
SA
SC
SD
SF
∴ T2
has 4 rows.
Hence, the correct answer is (4).
Question Number: 47 Question Type: NAT
The number of integers between 1 and 500 (both inclusive)
that are divisible by 3 or 5 or 7 is _______.
Solution: Let, A, B and C denote the sets of divisors of 3, 5
and 7 among the integers 1 to 500 respectively.
∴ The number of integers between 1 and 500 (both inclu-
sive) that are divisible by 3 or 5 or 7 = n (A ∪ B ∪ C)
We know that
n (A ∪ B ∪ C) = n (A) + n (B) + n (C) − n (A ∩ B) − n
(B ∩ C) − n (C ∩ A) + n (A ∩ B ∩ C) (1)
n (A) = The number of integers from 1 to 500 that are divis-
ible by 3 = 166
n (B) = The number of integers from 1 to 500 that are divis-
ible by 5 = 100
n (C) = The number of integers from 1 to 500 that are divis-
ible by 7 = 71
n (A ∩ B) = The number of integers from 1 to 500 that are
divisible by 3 and 5 = The number of integers from 1 to 500
that are divisible by 15 = 33
n (B ∩ C) = The number of integers from 1 to 500 that are
divisible by 5 and 7 = The number of integers from 1 to 500
that are divisible by 35 = 14
n (C ∩ A) = The number of integers from 1 to 500 that are
divisible by 7 and 3 = The number of integers from 1 to 500
that are divisible by 21 = 23
n (A ∩ B ∩ C) = The number of integers from 1 to 500 that
are divisible by 3, 5 and 7 = The number of integers from 1
to 500 that are divisible by 105 = 4
∴ Substituting these in (1), we get
n (A ∪ B ∪ C) = 166 + 100 + 71 − 33 − 14 − 23 + 4 = 271
Hence, the correct answer is (271).
Question Number: 48 Question Type: NAT
Let A be an array of 31 numbers consisting of a sequence of
0’s followed by a sequence of 1’s. The problem is to find the
smallest index i such that A[i] is 1 by probing the minimum
number of locations in A. The worst case number of probes
performed by an optimal algorithm is .
Solution: Using binary search, number of comparisions
required will be 2
logn
. Number of probes required is Èlog2
31
˘
= 5
Hence, the correct answer is (5).
Question Number: 49 Question Type: NAT
Consider a RISC machine where each instruction is exactly
4 bytes long. Conditional and unconditional branch instruc-
tions use PC-relative addressing mode Offset specified in
bytes to the target location of the branch instruction. Further
the Offset is always with respect to the address of the next
instruction in the program sequence. Consider the following
instruction sequence.
Instr.No. Instruction
i : add R2, R3, R4
i+1 : sub R5, R6, R7
i + 2 : cmp R1, R9, R10
i + 3 : beq R1, Offset
If the target of the branch instruction is i, then the decimal
value of the Offset is .
Solution: Given instruction sequence
i : add R2
, R3
, R4
i + 1: sub R5
, R6
, R7
i + 2 : cmp R1
, R9
, R10
i + 3 : beq R1
, offset.
In PC-relative addressing mode, effective address = PC +
offset.
PC always points to the address of next instruction.
∴ During execution of i + 3, the PC will point to address
of i + 4.
As each instruction requires 4 bytes, offset = − (4 × 4)
= − 16 bytes.
If ‘i’ is at address 1000, then i + 4 is at 1016.
EA = 1016 − 16 = 1000.
This gives address of ith
instruction.
Hence, the correct answer is (−16).
35. xxx | GATE 2017 Solved Paper CS: Set – 1
Question Number: 50 Question Type: NAT
Instruction execution in a processor is divided into 5 stages,
Instruction Fetch (IF), Instruction Decode (ID), Operand
Fetch (OF), Execute (EX), and Write Back (WB). These
stages take 5, 4, 20, 10, and 3 nanoseconds (ns) respec-
tive. A pipelined implement action of the processor requires
buffering between each pair of consecutive stages with a
delay of 2 ns. Two pipelined implementations of the proces-
sor are contemplated:
(i)
A navie pipeline implementation (NP) with 5 stages
and
(ii)
An efficient pipeline (EP) where the OF stage is divided
into stages OF1 and OF2 with execution times of 12 ns
and 8 ns respectively.
The speedup (correct to two decimal places) achieved by EP
over NP in executing 20 independent instructions with no
hazards is .
Solution: 5-stage pipeline:
Cycle time = 20 + 2
Execution time for 20 instructions = [5 + (20 − 1)] 22
6-stage pipeline:
Cycle time = 12 + 2 = 14
Execution time for 20 instructions = [6 + (20 − 1)] 14
Speed up of EP over NP
( )
( )
5 20 1 22
6 20 1 14
+ −
=
+ −
= 1.51
Hence, the correct answer is (1.51).
Question Number: 51 Question Type: NAT
Consider a 2-way set associative cache with 256 blocks and
uses LRU replacement. Initially the cache is empty. Conflict
misses are those misses which occur due to contention of
multiple blocks for the same cache set. Compulsory misses
occur due to first time access to the block. The following
sequence of accesses to memory blocks
(0, 128, 256, 128, 0, 128, 256, 128, 1, 129, 257, 129, 1, 129,
257, 129)
is repeated 10 times. The number of conflict misses experi-
enced by the cache is .
Solution: Cache has 256 blocks and is organized in a 2-way
set associative manner.
∴ The cache has 256
128
2
= sets.
set 0
set 0
set 127
In a 2-way set associative cache, a block is placed in the
location,
Block number % No. of sets in cache.
0 % 128 = 0 0
set
→ compulsory miss.
128 % 128 = 0 0
set
→ compulsory miss.
256 % 128 = 0 0
set
→ compulsory miss (1st
time access)
128 % 128 = 0 0
set
→ hit.
0 % 128 = 0 0
set
→ replace block 256, conflict miss.
128 % 128 = 0 0
set
→ hit.
256 % 128 = 0 0
set
→ replace block 0, conflict miss.
128 % 128 = 0 0
set
→ hit.
1 % 128 = 1 1
set
→ compulsory miss.
129 % 128 = 1 1
set
→ compulsory miss.
257 % 128 = 1 1
set
→ compulsory miss (1st
time access)
129 % 128 = 1 1
set
→ hit.
1 % 128 = 1 1
set
→ replace block 257, conflict miss.
129 % 128 = 1 1
set
→ hit.
257 % 128 = 1 1
set
→ replace block 1, conflict miss.
129 % 128 = 1 hit.
∴ For 1st
access, number of conflict misses = 4.
The contents of cache before starting 2nd
time access is
256
...... set 0
128
257
...... set 1
129
0 % 128 = 0 0
set
→ conflict miss, replace block 256.
128 % 128 = 0 0
set
→ Hit.
256 % 128 = 0 0
set
→ conflict miss, replace block 0.
128 % 128 = 0 0
set
→ Hit.
0 % 128 = 0 0
set
→ conflict miss, replace block 256.
128 % 128 = 0 0
set
→ Hit.
256 % 128 = 0 0
set
→ conflict miss, replace block 0.
128 % 128 = 0 0
set
→ Hit.
Similarly for next 8 accesses, we will get 4 conflict misses.
∴ Number of conflict misses for second access = 8.
Now, the cache state is same as before accessing the se-
quence for the second time.
36. GATE 2017 Solved Paper CS: Set – 1 | xxxi
So, for remaining accesses also there will be 8 conflict
misses.
∴ Total number of conflict misses to access the sequence
for 10 times = 4 + 9 × 8 = 76.
Hence, the correct answer is (76).
Question Number: 52 Question Type: NAT
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
instruction can have memory operands and (ii) arithmetic
instructions can have only register or immediate operands.
The value of X is .
Solution: Consider the expression
(a – 1) * ((b + c) / 3) + d)
Consider 2 registers R1 and R2.
R1
= b
R2
= c
R1
= R1
+ R2
R1
= R1
/3
R2
= d
R1
= R1
+ R2
R2
= a
R2
= R2
– 1
R1
+ R1
× R2
Only 2 registers are required
Hence, the correct answer is (2).
Question Number: 53 Question Type: NAT
Consider the following C program.
# include stdio.h
# include string.h
void printlength (char *s, char *t) {
unsigned int c = 0;
int len = ((strlen(s) − strlen (t))
c) ? strlen (s) : strlen (t);
printf (“%dn”, 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 _________.
Solution:
s
strlen (s) = 3
a b c
strlen (t) = 5
t
d e f g h
strlen( ) function return an unsigned value, computation
among unsigned variables will result in unsigned value i.e.,
positive value.
( )
strlen(s) strlen(t)
3 5
| 2 | 0 2 0
−
⇓
−
⇓
− ⇒
as condition is true, it stores strlen(s) into variable len.
It prints 3.
Hence, the correct answer is (3).
Question Number: 54 Question Type: NAT
A cache memory unit with capacity of N words and block
size of B words is to be designed. If it is designed as a direct
mapped cache, the length of the TAG field is 10 bits. If
the cache unit is now designed as a 16-way set-associative
cache, the length of the TAG filed is _________ bits.
Solution: Direct mapped cache:
Tag Line
n
10 l b
word
Where, block size 2b
B =
Number of Lines 2l
=
16-way set associative cache:
Tag Set
n
t l - 4 b
word
Number of sets 4
2
2
16
l
l−
= =
10 + l + b = t + l – 4 + b
t = 14.
∴ Required tag field is 14-bits.
Hence, the correct answer is (14).
37. xxxii | GATE 2017 Solved Paper CS: Set – 1
General Aptitude
Number of Questions: 10 Section Marks: 15
Question Number: 55 Question Type: NAT
The output of executing the following C program is______.
# include stdio.h
int total (int v) {
static int count = 0;
while (v) {
count + = v1;
v = 1;
}
return count;
}
void main ( ) {
static int x = 0;
int i = 5;
for (; i 0,i−−) {
x = x + total (i);
}
printf (“%dn”, x);
}
Solution: For the above code, the total( ) function calls
will be total(5), total(4), total(3), total(2) and total(1). As
the variables ‘count’ and ‘x’ are static, it restores the previ-
ous value. The values of count and x at each function call is
shown below.
Total (5)
V = 5 count 0 12
while (5)
Count = count + V 1 ; ⇒ 0 + (101) and (001) ⇒1
V = 1 ⇒ (101) 1 ⇒ 2
while (2)
Count = count + V 1 ; ⇒ 1 + (010) and (001) ⇒ 1
V = 1 ⇒ (010) 1 ⇒ 1
while (1)
Count = count + V 1 ; ⇒ 1 + (001) and (001) ⇒ 2
V = 1 ⇒ (001) 1 ⇒ 0
total (5) returns value 2 and x = 2
Similarly,
total (4) returns value 3 and x = 5
total (3) returns value 5 and x = 10
total (2) returns value 6 and x = 16
total (1) returns value 7 and x = 23
The value printed is 23.
Hence, the correct answer is (23).
Q.56 to Q.60 carry 1 mark each and Q.61 to Q.65 carry 2
marks each.
Question Number: 56 Question Type: MCQ
After Rajender Chola returned from his voyage to Indonesia,
he ________ to visit the temple in Thanjavur.
(A) was wishing (B) is wishing
(C) wished (D) had wished
Ans: (C)
Question Number: 57 Question Type: MCQ
Research in the workplace reveals that people work for
many reasons .
(A) money beside (B) beside money
(C) money besides (D) besides money
Ans: (D)
Question Number: 58 Question Type: MCQ
Rahul, Murali, srinivas and Arul are seated around a square
table. Rahul is sitting to the left of Murali. Srinivas is setting
to the right of Arul. Which of the following paris are seated
opposite each other?
(A) Rahul and Murali (B) Srinivas and Arul
(C) Srinivas and Murali (D) Srinivas and Rahul
Ans: (C)
Question Number: 59 Question Type: MCQ
Find the smallest number y such y × 162 is a perfect cube.
(A) 24 (B) 27
(C) 32 (D) 36
Ans: (D)
Question Number: 60 Question Type: MCQ
The probability that a k-digit number does NOT contain the
digits 0, 5, 0 or 9 is
(A) 0.3k
(B) 0.6k
(C) 0.7k
(D) 0.9k
Ans: (C)
Question Number: 61 Question Type: MCQ
“The hold of the nationalist imagination on our colonial past
is such that anything inadequately or improperly nationalist
is just not history.”
Which of the following statements best reflects the author’s
opinion?
(A) Nationalists are highly imaginative.
(B) History is viewed through the filter of nationalism.
(C) Our colonial past never happened.
(D)
Nationalism has to be both adequately and prop-
erly imagined.
Ans: (B)
38. GATE 2017 Solved Paper CS: Set – 1 | xxxiii
Question Number: 62 Question Type: MCQ
Six people are seated around a circular table. There are at
least two men and two women. There are at least three right-
handed persons. Every woman has a left-handed person to
her immediate right. None of the women are right- handed.
The number of women at the tables is
(A) 2
(B) 3
(C) 4
(D) Cannot be determined
Ans: (A)
Question Number: 63 Question Type: MCQ
The expression
( )
2
x y x y
− − −
is equal to
(A) the maximum of x and y
(B) the minimum of x and y
(C) 1
(D) none of the above
Ans: (B)
Question Number: 64 Question Type: MCQ
Arun, Gulab, Neel and Shweta must choose one shirt each
from a pile of four shirts coloured red, pink, blue and white
respectively. Arun dislikes the colour red and Shweta dis-
likes the colour white. Gulab and Neel like all the colours.
In how many different ways can they choose the shirts so
that no one has a shirt with a colour he or she dislikes?
(A) 21 (B) 18
(C) 16 (D) 14
Ans: (D)
Question Number: 65 Question Type: MCQ
A contour lines joins locations having the same height
above the mean sea level. The following is a contour plot
of a geographical region. Contour lines are shown at 25m
intervals in this plot. If in a flood, the water level rises to
525m, which of the villages P, Q, R, S, T get submerged ?
425
450
550
550
500
450
500
P
R
Q
T
S
(A) P, Q (B) P, Q, T
(C) R, S, T (D) Q, R, S
Ans: (C)
39. GATE 2017 Solved Paper
CS: Computer Science and Information Technology
Set – 2
Number of Questions: 65 Total Marks:100.0
Wrong answer for MCQ will result in negative marks, (-1/3) for 1 Mark Questions and (-2/3) for 2 Marks Question.
Computer Science Engineering
Number of Questions: 55 Section Marks: 85
Q.1 to Q.25 carry 1 mark each and Q.26 to Q.55 carry 2
marks each.
Question Number: 1 Question Type: MCQ
The representation of the value of a 16-bit unsigned integer
X in hexadecimal number system is BCA9. The representa-
tion of the value of X in octal number system is
(A) 571244 (B) 736251
(C) 571247 (D) 136251
Solution:
16 8
(BCA9) octal ( )
x
(BCA9)16
→ (x)2
16 2
(BCA9) (1011 1100 1010 1001)
→
⇓
(x)8
8
001 011 110 0 10 10 1 001
(136251)
1 3 6 2 5 1
→
Hence, the correct option is (D).
Question Number: 2 Question Type: MCQ
Match the following:
(P) static char var; (i)
Sequence of memory locations to
store addresses
(Q) m = malloc (10);
m = NULL;
(ii)
A variable located in data section of
memory
(R) char *
ptr [10]; (iii)
Request to allocate a CPU register
to store data
(S) register int var1; (iv)
A lost memory which cannot be
freed
(A) P → (ii), Q → (iv), R → (i), S → (iii)
(B) P → (ii), Q → (i), R → (iv), S → (iii)
(C) P → (ii), Q → (iv), R → (iii), S → (i)
(D) P → (iii), Q → (iv), R → (i), S → (ii)
Solution:
•
Static variables are stored in the program data segment.
• The statement m = malloc (10) is assigned with 10
memory units and when m is assigned with NULL val-
ue, then memory allocated is lost and it can’t be freed.
•
char *ptr [10]; declaration specifies a 10 pointers which
are used to store memory addresses.
•
register int var1; declaration request the CPU for al-
location of CPU registers for storing data.
Hence, the correct option is (A).
Question Number: 3 Question Type: MCQ
Match the algorithms with their time complexities:
Algorithm Time complexity
(P) Towers of Hanoi with n disks (i) Θ (n2
)
(Q)
Binary search given n sorted
numbers
(ii) Θ (n log n)
(R)
Heap sort given n numbers at the
worst case
(iii) Θ (2n
)
(S) Addition of two n × n matrices (iv) Θ (log n)
(A) P → (iii), Q → (iv), R → (i), S → (ii)
(B) P → (iv), Q → (iii), R → (i), S → (ii)
(C) P → (iii), Q → (iv), R → (ii), S → (i)
(D) P → (iv), Q → (iii), R → (ii), S → (i)
Solution: To solve Towers of Hanoi puzzle of ‘n’ disks, it
takes θ(2n
) time.
Binary search over ‘n’ sorted numbers takes θ(log n) time.
‘n’numbers can be sorted in θ(n log n) time using Heap sort
even in worst case.
Addition of two matrices of order n × n takes θ(n2
) time,
since it requires n2
computations.
Hence, the correct option is (C).
Question Number: 4 Question Type: MCQ
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 (B) I and III only
(C) II and IV only (D) I only
Solution: Given L1
, L2
are CFL. R is regular.
CFL’s are closed under union. CFL’s are not closed under
complement.
L1
− R = L1
∩ R
R is closed under complement. Intersection of regular and
CFL is CFL.
40. GATE 2017 Solved Paper CS: Set – 2 | xxxv
CFL’s are not closed under intersection.
∴ I and III are correct.
Hence, the correct option is (B).
Question Number: 5 Question Type: MCQ
Match the following according to input (from the left col-
umn) to the compiler phase (in the right column) that pro-
cesses it:
(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)
(B) P → (i), Q → (iv), R → (ii), S → (iii)
Solution: Phases of compiles with inputs
Source code
↓ Character stream
Lexical analysis (lexical analyzer)
↓ Token stream
Syntax analysis (syntax analyzer)
↓ Syntax tree
Semantic analysis (semantic analyzer)
↓ Intermediate representation
Code generator
↓
Output
Hence, the correct option is (C).
Question Number: 6 Question Type: MCQ
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 (B) II only
(C) III only (D) I and III only
Solution: Relation among parsers (with respect to accept-
ing languages) is shown with below Venn diagram:
CLR (1)
SLR (1)
LR (0)
LL (1)
LALR (1)
Hence, the correct option is (A).
Question Number: 7 Question Type: MCQ
Which of the following is/are shared by all the threads in a
process?
I. Program counter
II. Stack
III. Address space
IV. Registers
(A) I and II only (B) III only
(C) IV only (D) III and IV only
Solution: Each thread has its own program counter, stack,
Registers and state.
Address space is shared by all threads of a process
Hence, the correct option is (B).
Question Number: 8 Question Type: MCQ
In a file allocation system, which of the following alloca-
tion scheme(s) can be used if no external fragmentation is
allowed?
I. Contiguous
II. Linked
III. Indexed
(A) I and III only (B) II only
(C) III only (D) II and III only
Solution: In contiguous allocation, there is a possibility of
external fragmentation.
Hence, the correct option is (D).
Question Number: 9 Question Type: MCQ
Consider the following statements about the routing proto-
cols. 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
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
Solution:
• RIP uses distance vector routing.
•
RIP packets are sent using UDP as RIP uses UDP as
transport protocol.
•
OSPF packets are not sent using TCP and its operation
is based on link state routing.
Hence, the correct option is (C).
Question Number: 10 Question Type: MCQ
If f(x) = R sin ,
2
x
S
p
+
1
'
2
f
= 2 and
1
0
( )
f x dx
∫ =
2R
p
,
then the constants R and S are, respectively.
41. xxxvi | GATE 2017 Solved Paper CS: Set – 2
(A)
2
p
and
16
p
(B)
2
p
and 0
(C)
4
p
and 0 (D)
4
p
and
16
p
Solution: Given ( ) sin
2
π
= +
x
f x R S
1
2
2
f
′ =
and ( )
1
0
2
=
π
∫
R
f x dx
( )
1
cos
2 2
π π
=
f x R x
1 1 1
2 cos 2
2 2 2 2
π π
= ⇒ × =
f R
⇒ cos 2
2 4
π π
=
R
⇒
1
. 2
2 2
R
π
=
⇒
4
=
π
R
Also, ( )
1
0
2
=
π
∫
R
f x dx
⇒
1
0
4
2
sin
2
π
π
+ =
π
∫ R x S dx
⇒
1
2
0
4 8
sin
2
π
+ =
π π
∫ x S dx
⇒
1
2
0
cos
4 8
2
2
x
Sx
π
−
+ =
π
π
π
⇒ 2 2 2
8 8 8
cos cos0 0
2
S S
− π −
+ − + × =
π π π
⇒ 2 2
8 8
+ =
π π
S
⇒ S = 0
∴
4
=
π
R and S = 0
Hence, the correct option is (C).
Question Number: 11 Question Type: MCQ
Let p. q. 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)
(D) (¬ p ∧ r) ∨ ( r → (p ∧ q))
Solution: Given statements are
p: It is raining
q: It is cold
r: It is pleasant
Given compound statement is
“It is not raining and it is pleasant, and it is not pleasant,
only if it is raining and it is cold”.
is same as,
“It is not raining and it is pleasant, and if it is not pleasant
then it is raining and it is cold”.
Which can be written in symbolic form as (¬p ∧ r) ∧
(¬r → (p ∧ q))
Hence, the correct option is (A).
Question Number: 12 Question Type: MCQ
Given the following binary number in 32-bit (single preci-
sion) IEEE-754 format:
00111110011011010000000000000000
The decimal value closest to this floating-point number is
(A) 1.45 × 101
(B) 1.45 × 10−1
(C) 2.27 × 10−1
(D) 2.27 × 101
Solution: Given 32-bit IEEE 754 number is
0 0111110 0 11011010000000000000000
Sign-bit = 0 ⇒ number is positive
Biased exponent = 22
+ 23
+ 24
+25
+ 26
=124
∴ Exponent = 124−127 = −3
Mantissa = 1.1101101
∴ Number in binary
= 1.1101101 × 2−3
= 0.0011101101
= 0.2314453125
≃ 2.3 × 10−1
This is approximately equal to choice (C).
Hence, the correct option is (C).
Question Number: 13 Question Type: MCQ
A circular queue has been implemented using a singly
linked list where each node consists of a value and a single
pointer pointing to the next node. We maintain exactly two
external pointers FRONT and REAR pointing to the front
node and the rear node of the queue, respectively. Which of
the following statements is/are CORRECT for such a circu-
lar queue, so that insertion and deletion operations can be
performed in O (1) time?
42. GATE 2017 Solved Paper CS: Set – 2 | xxxvii
I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.
(A) I only (B) II only
(C) Both I and II (D) Neither I nor II
Solution: Circular Queue with Linked List:
a
F R O N T R E A R
b c
In above, implementation of circular queue using linked list,
Rear pointer always points Front as it is done always for
every new insertion.
FRONT node next pointer points to REAR only when they
are only 2 elements in a queue. Insertion and Deletion can
be done in O(1) time.
Hence, the correct option is (B).
Question Number: 14 Question Type: MCQ
Consider the following function implemented in C:
void printxy (int x, int y) {
int
ptr;
x = 0;
ptr = x;
y =
ptr;
ptr = 1;
printf (“%d, %d” x, y);
}
The output of invoking printxy (1, 1) is
(A) 0, 0 (B) 0, 1
(C) 1, 0 (D) 1, 1
Solution: 1 01 1 0
x y
ptr
y = *ptr ⇒ y = 0
when * ptr = 1 ⇒ only value of x will change, i.e., 1
when x and y are printed, it prints 1, 0.
Hence, the correct option is (C).
Question Number: 15 Question Type: MCQ
The Breadth First Search (BFS) algorithm has been imple-
mented using the queue data structure. Which one of the
following is a possible order of visiting the nodes in the
graph below?
M N O
P
Q
R
(A) MNOPQR
(B) NQMPOR
(C) QMNROP
(D) POQNMR
Solution: Given graph
M N
P
Q
R
O
In BFS traversal, it first traverse all the neighbours of start
node and traverse corresponding neighbours iteratively till
all the nodes are visited. Option (D) is the correct BFS tra-
versal of above graph ‘G’.
Hence, the correct option is (D).
Question Number: 16 Question Type: MCQ
Identify the language generated by the following grammar,
where S is the start variable.
S → XY
X → aX|a
Y → aYb|∈
(A) {am
bn
| m ≥ n, n 0} (B) {am
bn
| m ≥ n, n ≥ 0}
(C) {am
bn
| m n, n ≥ 0} (D) {am
bn
| m n, n 0}
Solution: Given grammar
S → XY
X →aX | a
Y → aYb | ε
For given grammar, there need to atleast one a. There can
be zero b’s.
n ≥ 0
Y generals equal number of a’s, and b’s.
X generates one or more a’s so S generates
{am
bn
| m n, n ≥ 0}
Hence, the correct option is (C).
Question Number: 17 Question Type: MCQ
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 participa-
tion of A in R is total.
(B)
Relationship R is one-to-many and the participa-
tion of A in R is partial.
43. xxxviii | GATE 2017 Solved Paper CS: Set – 2
(C)
Relationship R is many-to-one and the participa-
tion of A in R is total.
(D)
Relationship R is many-to-one and the participa-
tion of A in R is partial.
Solution:
I
m R B
A
The relationship R table can be merged with entity A’s table.
If R is many-to-one and A is total Participated in relation
R.
Hence, the correct option is (C).
Question Number: 18 Question Type: MCQ
Consider socket API on a Linux machine that supports con-
nected UDP sockets. A connected UDP socket is a UDP
socket on which connect function has already been called.
Winch 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
(B) II only
(C) Both I and II
(D) Neither I nor II
Solution: A process can use Connection function on a
UDP socket, if the communication is point to point.
Connected UDP simulates like TCP connection (like peer
to peer connection)
Hence, the correct option is (B).
Question Number: 19 Question Type: NAT
Consider the following tables T1 and T2.
T1 T2
P Q R S
2 2 2 2
3 8 8 3
7 3 3 2
5 8 9 7
6 9 5 7
8 5 7 2
9 8
In table T1, P is the primary key and Q is the foreign key
referencing R in table T2 with on-delete cascade and on-
update cascade. In table T2, R is the primary key and S is
the foreign key referencing P in table Tl 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 __________.
Solution: Based on given description, S is depend on P; Q
is depend on R.
After deleting row (3, 8) from T1
, set S = NULL at R = 8
in T2
.
∴ zero rows will get deleted in T1
, other than (3, 8).
Hence, the correct answer is (0).
Question Number: 20 Question Type: NAT
The maximum number of IPv4 router addresses that can be
listed in the record route (RR) option field of an IPv4 header
is__________.
Solution: In IPV4
, maximum number of router addresses
specified will be 9.
Hence, the correct answer is (9).
Question Number: 21 Question Type: NAT
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.
c
b
a
d
e
The minimum number of ordered pairs that need to be
added to R to make (X, R) a lattice is __________.
Solution: Given poset (X, R) is itself a lattice.
So, the minimum number of ordered pairs to be added = 0.
Hence, the correct answer is (0).
Question Number: 22 Question Type: NAT
Let P
1 1 1
2 3 4
3 2 3
−
= −
−
and Q
1 2 1
6 12 6
5 10 5
− − −
=
be two
matrices.
Then the rank of P + Q is __________.
44. GATE 2017 Solved Paper CS: Set – 2 | xxxix
Solution: Let
1 1 1
2 3 4
3 2 3
P
−
= −
−
and
1 2 1
6 12 6
5 10 5
− − −
=
Q
0 1 2
8 9 10
8 8 8
− −
∴ + =
P Q
( )
0 1 2
Det 8 9 10 0
8 8 8
P Q
− −
+ = =
and determinant of a 2 × 2 sub-matrix
0 1
8 9
−
of P + Q is
8 ≠ 0.
∴ Rank of P + Q = 2
Hence, the correct answer is (2).
Question Number: 23 Question Type: NAT
G is an undirected graph with n vertices and 25 edges such
that each vertex of G has degree at least 3. Then the maxi-
mum possible value of n is __________.
Solution: Number of edges of G = n (E) = 25
Given number of vertices of G = n (V) = n
As the degree of each vertex is atleast 3, we have sum of the
degrees of all the vertices will be of the form 3n + k, where
k is a positive integer.
We know that, sum of the degrees of all the vertices = 2 ×
Number of edges
⇒ 3 n + k = 2 × 25
⇒ 3 n + k = 50
For, n to be maximum, k should be minimum.
∴ 3 n + k = 50 and k is minimum only when n = 16.
Hence, the correct answer is (16).
Question Number: 24 Question Type: NAT
Consider a quadratic equation x2
− 13x + 36 = 0 with coeffi-
cients in a base b. The solutions of this equation in the same
base b are x = 5 and x = 6. Then b = __________.
Solution:
x2
− 13x +36 = 0
5.6 = (36)b
30 = 3b + 6
3b = 24
b = 8
∴ base = 8
Hence, the correct answer is (8.0 to 8.0).
Question Number: 25 Question Type: NAT
The minimum possible number of states of a deterministic
finite automaton that accepts the regular
language L = {w1
aw2
| w1
, w2
∈ {a, b}*, |w1
| = 2, |w2
| ≥ 3} is
__________.
Sulution: Given language
L = {w1
aw2
| w1
, w2
∈ {a, b}*,
|w1
| = 2
|w2
| ≥ 3}
The minimum DFA for L can be
a,b a b Dead
siale
a,b
a,b
a,b
a,b
a,b
∴ Minimal DFA which accepts L has 8 states. (Including
dead state)
Hence, the correct answer is (8).
Question Number: 26 Question Type: MCQ
P and Q are considering to apply for a job. The probability
that P applies for the job is
1
4
, the probability that P applies
for the job given that Q applies for the job is
1
2
and the
probability that Q applies for the job given that P applies for
the job is
1
3
. Then the probability that P does not apply for
the job given that Q does not apply for the job is
(A)
4
5
(B)
5
6
(C)
7
8
(D)
11
12
Solution: Let A and B denote the events of the persons P
and Q applying for a job respectively.
∴ ( )
1 1
,
4 2
= =
A
P A P
B
and
1
3
=
B
P
A
45. xl | GATE 2017 Solved Paper CS: Set – 2
We have
( )
( )
∩
=
P A B
B
P
A P A
⇒ P(A ∩ B) =
B
P
A
⋅ P (A)
1 1
3 4
= ×
⇒ ( )
1
12
∩ =
P A B
From the diagram, we have
A
A∩B
B
A∩B A∩B
( ) ( )
= ∩ ∪ ∩
A A B A B
⇒ ( ) ( ) ( )
= ∩ + ∩
P A P A B P A B
( ∩
A B and A ∩ B are mutually exclusive).
⇒ ( ) ( ) ( )
P A B P A P A B
∩ = − ∩
1 1
4 12
= −
∴ ( ) 1
6
∩ =
P A B
Also, we know that
( )
( )
∩
=
P A B
A
P
B P B
⇒ ( )
( )
∩
=
P A B
P B
A
P
B
1
12
1
2
=
∴ ( )
1
6
=
P B
∴ Probability that P does not apply for the job given that Q
does not apply for the job.
=
A
P
B
1
= −
A
P
B
( )
( )
( )
( )
1 1
1
∩ ∩
= − = −
−
P A B P A B
P B
P B
1
6
1
1
1
6
= −
−
1
6
1
5
6
= −
=
1
1
5
−
4
5
=
Hence, the correct option is (A).
Question Number: 27 Question Type: MCQ
If w, x, y, z are Boolean variables, then which one of the fol-
lowing is INCORRECT?
(A) wx + w(x + y) + x(x + y) = x + wy
(B) ( )
w x y z w x w x yz
+ + = + +
(C) ( )
( )
w x y x z w x y x y
+ + =
(D) (w + y) (wxy + wyz) = wxy + wyz
Solution: By observation, we can say that option (D) is
correct.
(C): ( )
( )
wx y xz w x y
+ +
( )
0
wxy w x y
+ +
wxy w xy x y x y
+ = ≠
Hence option (C) is wrong.
(B): ( )
wx y z wx
+ +
w x yz w x w x yz
+ + + = + +
Thus; option (B) is also correct.
(A): ( ) ( )
wx w x y x x y x wy
+ + + + = +
wx wx wy x xy
+ + + +
wx wy x x wy
+ + = +
Hence, the correct option is (C).
Question Number: 28 Question Type: MCQ
Given f(w, x, y, z) = ∑m(0,l,2,3,7,8,10) + ∑d(5,6,ll,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
= + +
46. GATE 2017 Solved Paper CS: Set – 2 | xli
Solution:
Given f (w, x, y, z) = ∑m (0, 1, 2, 3, 7, 8, 10) +
∑d(5, 6, 11, 15).
00
yz
wx
11
01
00
10
10
11
01
1
1
0
0
1
II
0
0
1
1
X
X
X
I
X
1
0
1
F = I ⋅ II
I = ( )
x z
+
II =( )
w z
+
F =( )
w z
+ ( )
x z
+
Hence, the correct option is (A).
Question Number: 29 Question Type: MCQ
In a two-level cache system, the access times of L1
and L2
caches are 1 and 8 clock cycles, respectively. The miss pen-
alty from the L2
cache to main memory is 18 clock cycles.
The miss rate of L1
cache is twice that of L2
. The average
memory access time (AMAT) of this cache system is 2
cycles. The miss rates of L1
and L2
respectively are:
(A) 0.111 and 0.056 (B) 0.056 and 0.111
(C) 0.0892 and 0.1784 (D) 0.1784 and 0.0892
Solution: Given,
Access time of L1
= 1 cc
Access time of L2
= 8 cc
Miss penalty of L2
= 18 cc
Miss rate of L1
= 2x
Miss rate of L2
= x
Miss penalty of L1
=
(L2
access time + miss rate of L2
× miss
penalty of L2
)
Miss penalty of L1
= (8 + 18x)
Average memory access time =
L1
access time + miss rate of
L1
× miss penalty of L1
2 = 1 + 2x × (8 +18x)
1 = 16x + 36x2
If x = 0.056, then 2
16 36
+
x x is approximately equal to 1.
Hence, the correct option is (A).
Question Number: 30 Question Type: MCQ
Consider the recurrence function
( )
( )
2 1 2
2, 0 2
T n n
T n
n
+
=
≤
Then T(n) in terms of Θ notation is
(A) Θ (log log n) (B) Θ (log n)
(C) ( )
n
Θ (D) Θ (n)
Solution: ( )
( )
2 1, 2
2 0 2
T n n
T n
n
+
=
≤
on 1st
iteration:
( ) ( )
2 1
= +
T n T n
on 2nd
iteration:
( ) ( )
2
2 1 1
= + +
T n T n
2
1
2 2
2 2 1
T n
= + ×
On kth
iteration
( )
1
2
2
k
k
T n T n k
= +
(1)
implies
1
2
2
k
n =
⇒ k = log2
log2
n
substituting k in (1)
( )
2 2
log log
2 2
2 2 log log
= +
n
T n
≅ 2 log2
n
≅ θ (log2
n)
T(n) is θ (log2
n).
Hence, the correct option is (B).
Question Number: 31 Question Type: MCQ
For any discrete random variable X, with probability mass
function
P(X = j) = pj
, pj
≥ 0, j ∈ {0,....., N}, and
0
1
N
j
j
p
=
=
∑ , define
the polynomial function ( )
0
N
j
x j
j
g z p z
=
= ∑ . For a certain
discrete random variable Y, there exists a scalar β ∈ [0,1]
such that gY
(z) = (1 − β + β z)N
. The expectation of Y is
(A) Nβ (l −β)
(B) Nβ
(C) N(l-β)
(D) Not expressible in terms of N and β alone
47. xlii | GATE 2017 Solved Paper CS: Set – 2
Solution: Given ( ) ( )
1
= −β+β
N
y
g z z
( )
1
= −β +β
N
z
It can be observed that by expanding ( ),
y
g z we will get
a binomial distribution with n = number of trials = N and,
p = Probability of success = β
∴ Expectation of Y = E (Y) = np
⇒ E (Y) = Nβ
Hence, the correct option is (B).
Question Number: 32 Question Type: MCQ
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 (B) E − TE
T − T + F | F E′ − −TE | ∈
F − (E) | id T − T + F | F
F − (E) | id
(C) E − TX (D) E − TX | (TX)
X − −TX | ∈ X − −TX | +TX | ∈
T − FY T − id
Y − + FY | ∈
F − (E) | id
Solution: The given grammar is :
E → E – T | T
T → T + F | F
F → (E) | id
Removal of left recursion of above grammar is:
E → TE1
E1
→ -TE1
|
T → FT1
T1
→ +FT1
/E
F → (E)|id
It is similar to option (C) in which E1
is replaced with X and
T1
is replaced with Y.
Hence, the correct option is (C).
Question Number: 33 Question Type: MCQ
A system shares 9 tape drives. The current allocation and
maximum requirement of tape drives for three processes are
shown below:
Process Current Allocation Maximum Requirement
P1 3 7
P2 1 6
P3 3 5
Which of the following best describes current state of the
system?
(A) Safe. Deadlocked
(B) Safe. Not Deadlocked
(C) Not Safe. Deadlocked
(D) Not Safe, Not Deadlocked
Solution: Total there are 9 tape drives
Max. Req. Allocated Required
P1 7 3 4
P2 6 1 5
P3 5 3 2
After allocating 3 + 1 + 3 = 7 tape drives, 9 − 7 = 2 tape
drives. With these 2 tape drives, the safe sequences possible
are P3
, P2
, P1
or P3
, P1
, P2
Hence, the system is in safe state and there is no deadlock.
Hence, the correct option is (B).
Question Number: 34 Question Type: MCQ
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 cor-
rected by the code be q. Then the values of p and q are
(A) p=3 and q=l
(B) p=3 and q=2
(C) p=4 and q=1
(D) p=4 and q=2
Solution: Given code words
00000, 01011, 10101, 11110
The hamming distance is
±
0 0 0 0 0
0 1 0 1 1
0 1 0 1 1
Hamming distance = 3
Similarly, the hamming distance with 00000 and other code
words 10101, 11110 is 3, 4.
The hamming distance between 01011 and 10101 is
±
0 1 0 1 1
1 0 1 0 1
1 1 1 1 0
Hamming distance = 4
Similarly, hamming distance 01011 and 11110 is 3.
Hamming distance between 10101 and 11110 is 3.
∴ p = 3.
48. GATE 2017 Solved Paper CS: Set – 2 | xliii
For correcting code, the condition is
2 d + 1 = 3
d = 1
Therefore, the value of q = 1.
Hence, the correct option is (A).
Question Number: 35 Question Type: MCQ
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
Solution:
10,000kms
2 × 108
m/s
106
bps
X Y
Transmission time =
length of packet
band width
6
50000 8
10
×
=
= 400 ms
propagation time =
distance
velocity
3
8
10000 10
2 10
×
=
×
= 50 msec
Hence, the correct option is (D).
Question Number: 36 Question Type: MCQ
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 tra-
versal 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
Solution: Given pre order transversal of binary search tree
is 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20
As the transversal is on binary search tree, it follows order-
ing property. From the given pre order transversal, 12 is the
root.
9
8, 6, 2, 7, 9, 10 16, 15, 19, 17, 20
fl
7
16
20
12
12
19
17
10
15
2
6
8
The post order transversal of above tree is 2, 7, 6, 10, 9, 8,
15, 17, 20, 19, 16, 12
Hence, the correct option is (B).
Question Number: 37 Question Type: MCQ
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)
Solution: Given code :
while (r = y)
{
r = r – y;
q = q + 1;
}
the pre-condition for x = = (y * q + r).
Should be r = x, as x ÷ y is computed as r ÷ y. Similarly, q =
0 as the ‘x’ should be equal to ‘r’, i.e., (q = = 0), ‘y’ should
be greater than 0 as it is unsigned variable (y 0 ⇒ r 0
⇒ x 0).
Hence, the correct option is (C).
49. xliv | GATE 2017 Solved Paper CS: Set – 2
Question Number: 38 Question Type: MCQ
Consider the following C function.
int fun (int n) {
int i, j;
for(i = 1; i = n; i++) {
for (j = l; j n; j += i) {
printf{“ %d %d”,i, j);
}
}
}
Time complexity of fun in terms of Θ notation is
(A) ( )
n n
Θ (B) Θ(n2
)
(C) Θ(n log n) (D) Θ(n2
log n)
Solution: Outer for loop in fun() iterates ‘n’ times.
For every ‘i’ value, the inner loop executes
( )
1
.
n i
n
+ −
i.e.,
1 1
...... 1
2 3
+ +
+ + + +
n n
n
1
1
=
+ −
=
∑
n
i
n i
i
1 1 1
1
1
n n n
i i i
n
i i
= = =
= + −
∑ ∑ ∑
≅ n (log n) + n – (log n)
≅ θ (n log n)
Hence, the correct option is (C).
Question Number: 39 Question Type: MCQ
Let δ denote the transition function and d̂ denote the
extended transition function of the ∈-NFA whose transition
table is given below:
δ ∈ a b
→q0
{q2
} (q1
} {q0
}
q1
{q2
} {q2
} {q3
}
q2
{q0
} Ø Ø
q3
Ø Ø (q2
}
Then d̂ (q2
, aba) is
(A) Ø (B) {q0
, q1
, q3
}
(C) {q0
, q1
, q2
} (D) {q0
, q2
, q3
}
Solution: Given transitions are
q0
b
a b
b
, a
q1
q2
q3
2
ˆ( , )
q aba
δ gives all states reachable from q2
, while reading
aba. So, it can reach q0
, q1
, q2
.
Hence, the correct option is (C).
Question Number: 40 Question Type: MCQ
Consider the following languages.
Lt
= {ap
| p is a prime number}
L2
= {an
bm
c2m
| n ≥ 0, m ≥ 0}
L3
= {an
bn
c2n
|n ≥ 0}
L4
= {an
bn
| n ≥ 1}
Winch 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 (B) II and III only
(C) I and IV only (D) III and IV only
Solution: L1
is not context-free.
(∵ PDA can not check whether a number is prime or not)
L2
is CFL.
The PDA pushes two b’s for every b and Pops a, b for every
‘c’.
L3
is not accepted by PDA.
L3
is accepted by TM and it halts for any input so it is re-
cursive.
L4
is accepted by DCFL.
(∵ Push a’s Pop ‘a’ for each ‘b’ in input).
∴ III and IV are correct.
Hence, the correct option is (D).
Question Number: 41 Question Type: MCQ
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 (B) II and III only
(C) II, III and IV only (D) III and IV only
Solution: I is Decidable.
II is Decidable
III is Undecidable
IV is Undecidable
Hence, the correct option is (D).
50. GATE 2017 Solved Paper CS: Set – 2 | xlv
Question Number: 42 Question Type: MCQ
The next state table of a 2-bit saturating up-counter is given
below.
1 0 1 0
0 0 0 1
0 1 1 0
1 0 1 1
1 1 1 1
Q Q Q Q
+ +
The counter is built as a synchronous sequential circuit
using T flip-flops. The expressions for T1
and T0
are
(A) 1 1 0, 0 1 0
T Q Q T Q Q
= =
(B) 1 0, 0
1 1 0
T Q Q T Q Q
= = +
(C) 1 1 0, 0 1 0
T Q Q T Q Q
= + = +
(D) 1 0, 0 1 0
1
T Q Q T Q Q
= = +
Solution:
1 0 1 0 1 0
0 0 0 1 0 1
0 1 1 0 1 1
1 0 1 1 0 1
1 1 1 1 0 0
Q Q Q Q T T
+ +
By observation, T1
= 1 0
Q Q
K’ map for T0
1
1
0
1
0 1
Q0
Q1
1
0
0 1 0
T Q Q
= +
T1
= 1 0
Q Q , T0
= 1 0
Q Q
+
Hence, the correct option is (B).
Question Number: 43 Question Type: NAT
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 =4; i++) {
if (array[i] array[i+1]) {
swap(array[i], array[i + 1]) ;
done = 0;
}
}
for (i=5; i =l; i--) {
if (array[i] array[i−l]) {
swap(array[i], array[i−1]);
done = 0;
}
}
}
printf{“%d”, array[3]);
}
The output of the program is ________.
Solution: The above code sorts the elements in the de-
creasing order. The output array after the code execution is
0 1 2 3 4 5
6 5 4 3 2 1
So, array [3] contains an element ‘3’, so, it outputs 3.
Hence, the correct answer is (3).
Question Number: 44 Question Type: NAT
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 wi
(V) denotes a write operation by transac-
tion Ti
on a variable V. The total number of conflict serializ-
able schedules that can be formed by T1
and T2
is _______.
Solution: Number of conflict serializable schedules pos-
sible such that T1
is depend on T2
is 1. Number of conflict
serislizable schedules possible such that T2
is depend on T1
is 53.
∴ Total possible conflict serializable schedules is 54
Hence, the correct answer is (54).
Question Number: 45 Question Type: NAT
The read access times and the hit ratios for different caches
in a memory hierarchy are as given below.
Cache Read access time
(in nanoseconds)
Hit ratio
I-cache 2 0.8
D-cache 2 0.9
L2-cache 8 0.9
The read access time of main memory is 90 nanoseconds.
Assume that the caches use the referred- word-first read pol-
icy and the write back policy. Assume that all the caches are
direct mapped caches. Assume that the dirty bit is always 0
for all the blocks in the caches. In execution of a program.
51. xlvi | GATE 2017 Solved Paper CS: Set – 2
60% of memory reads are for instruction fetch and 40% are
for memory operand fetch. The average read access time in
nanoseconds (up to 2 decimal places) is __________.
Solution: Given there are 60% instruction fetch, 40% op-
erand fetch.
For instruction fetch, average memory access time
= 0.6 [HI
* RI
+ (1 − HI
) HL2
(RI
+ RL2
) + (1 − HI
) (1 − HL2
)
(RI
+ RL2
+ Rm
)]
=
0.6[0.8 * 2 + (1−0.8) 0.9 (2 + 8) + (1 − 0.8) (1 − 0.9) (2
+ 8 + 90)]
= 0.6[1.6 + 1.8 + 2]
= 3.24 ns
For operand fetch,
Average memory access time
= 0.4[HD
* RD
+ (1 − HD
) HL2
(RD
+ RL2
) + (1 − HD
) (1 − HL2
)
(RD
+ RL2
+ Rm
)]
= 0.4[0.9 * 2 + 0.1 * 0.9 * (2 + 8) + 0.1 * 0.1 * (2 + 8 + 90)]
= 0.4 [1.8 + 0.9 + 1]
= 3.7 * 0.4 = 1.48 ns
∴ Average memory access time = 3.24 + 1.48 = 4.72
Hence, the correct answer is (4.72).
Question Number: 46 Question Type: NAT
Consider the following database table named top_scorer.
top_scorer
player country goals
Klose Germany 16
Ronaldo Brazil 15
G Miiller Germany 14
Fontaine France 13
Pelé Brazil 12
Klinsmann Germany 11
Kocsis Hungary 11
Batistuta Argentina 10
Cubillas Peru 10
Lato Poland 10
Lineker England 10
T Muller Germany 10
Rahn Germany 10
Consider the following SQL query:
SELECT ta.player FROM top_scorer AS ta
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 number of tuples returned by the above SQL query is
_________.
Solution: Select tb. goals FROM top-scorer AS tb where
tb. ‘country’ = Spain
This query returns zero tuples as no country has name
‘Spain’.
TC table has below rows:
tc
tc. goals
16
14
11
10
ta consists the player name whose goals is ANY (tc.goals)
ta
ta.player
Klose (∵ 16 15)
Ronaldo (∵ 15 14)
G muller (∵ 14 11)
Foundtaine (∵ 13 10)
Pele (∵ 12 10)
Klinsmann (∵ 11 10)
Kocsis (∵ 11 10)
∴ 7 rows returned by given query.
Hence, the correct answer is (7).
Question Number: 47 Question Type: NAT
If the ordinary generating function of a sequence
{ }
( )
3
0
1
is
1
n n
z
a
z
∞
=
+
−
then a3
−a0
is equal to __________.
Solution: Given, the generating function of a sequence
{ } 0
∞
=
n n
a is
( )
( )
( )
3 3
1 1
1
1 1
z
z
z z
+
= = +
− −
( ) ( )
0
1 3 1 , r
r
z C r r z
∞
=
= + − +
∑
( )
0
1
1 ,
(1 )
r
n
r
C n r r X
X
∞
=
= − +
−
∑
52. GATE 2017 Solved Paper CS: Set – 2 | xlvii
( ) ( )
0
1 2 , r
r
z C r r z
∞
=
= + +
∑
( ) ( ) ( ) ( ) ( )
0 2 3
1 2,0 3,1 4,2 5,3 ...
z C z C z C z C z
= + + + + +
( ) 2 3
1 1 3 6 10 ......
z z z z
= + + + + +
( ) ( )
2 3 2 3 4
1 3 6 10 ... 3 6 10 ...
z z z z z z z
= + + + + + + + + +
2 3
1 4 9 16 .......
z z z
= + + + +
∴ a0
= constant term of the generating function
⇒ a0
= 1
a3
= The coefficient of z3
in the generating function.
⇒ a3
= 16
∴ a3
−a0
= 16 −1 = 15
Hence, the correct answer is (15).
Question Number: 48 Question Type: NAT
If a random variable X has a Poisson distribution with mean
5. then the expectation E[(X + 2)2
] equals _________.
Solution: Given X is a Poisson random variable and mean
of X = E(X) = 5
∴ Variance of X = Var (X) = 5
Consider ( )
2 2
2 4 4
E X E X X
+ = + +
( ) ( )
2
4 4
E X E X
= + +
( ) ( )
( ) ( )
2
var 4 4
X E X E X
= + + +
2
5 5 4 5 4 54
= + + × + =
Hence, the correct answer is (54).
Question Number: 49 Question Type: NAT
In a B+ tree, if the search-key value 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 __________.
Solution: Given,
Search key value V = 8 B
Block Size B = 512 B
Block pointer size P = 2B
If the maximum order is m, then
(m × P) + ((m – 1) × V) ≤ B
⇒ m * 2 + ((m – 1) × 8) ≤ 512
⇒ 2 m + 8m – 8 ≤ 512
⇒ 10m ≤ 520
⇒ m ≤ 52
∴ maximum order is 52.
Hence, the correct answer is (52).
Question Number: 50 Question Type: NAT
A message is made up entirely of characters from the set X
= {P, Q, R, S,T}. The table of probabilities for each of the
characters is shown below:
Character Probability
P 0.22
Q 0.34
R 0.17
S 0.19
T 0.08
Total 1.00
If a message of 100 characters over X is encoded using
Huffman coding, then the expected length of the encoded
message in bits is _________.
Solution: Message of 100 characters contains letters P, Q,
R, S, T with their frequencies 22, 34, 17, 19, 8.
The Huffman tree for the above is:
1
1
(59)
1
0
(34)
Q
0
I3
I1
(25)
0
R T
1
I4
(41)
P
(22)
0
(19) (17) (8)
S
I2
Number of bits required for each character is
P – 00 – 2 bits × 22 ⇒ 44
Q – 10 – 2 bits × 34 ⇒ 68
R – 110 – 3 bits × 17 ⇒ 51
53. xlviii | GATE 2017 Solved Paper CS: Set – 2
S – 01 – 2 bits × 19 ⇒ 38
T – 111 – 3 bits x 8 ⇒ 24
Total bits required = 225
Hence, the correct answer is (225).
Question Number: 51 Question Type: NAT
Consider the set of processes with arrival time (in millisec-
onds). CPU burst time (in milliseconds). and priority (0 is
the highest priority) shown below. None of the processes
have I/O burst time.
Process Arrival Time Burst Time Priority
P1
0 11 2
P2
5 28 0
P3
12 2 3
P4
2 10 1
P5
9 16 4
The average waiting time (in milliseconds) of all the pro-
cesses using preemptive priority scheduling algorithm
is________.
Solution: Using preemptive priority scheduling algrithm,
the Gantt chart is as below:
P1
P2 (Priority 0)
P4 (Priority 1)
0 1 2 3 4 5 33 40 49 51 67
P1 P4 P3 P5
P4 P4 P2 P4 P1
At time 33
P2 completed, P4 Left with 7 units of burst time.
At time 40
P4 completed, P1 Left with 9 units of burst time
After completion of process execution:
waiting time of P1 = 40 – 2 = 38
waiting time of P2 = 0
waiting time of P3 = 49 – 12 = 37
Waiting time of P4 = 33 – 5 = 28
waiting time of P5 = 51 – 9 = 42
∴ Average waiting time
38 0 37 28 42
5
+ + + +
=
= 29 ms
Hence, the correct answer is (29).
Question Number: 52 Question Type: NAT
If the characteristic polynomial of a 3 × 3 matrix M over
(the set of real numbers) is λ3
− 4 λ2
+ aλ + 30, a ∈ , and
one eigenvalue of M is 2, then the largest among the abso-
lute values of the eigenvalues of M is__________.
Solution: Given the characteristic polynomial of a 3 × 3
matrix M is λ3
− 4λ2
+aλ + 30, a ∈
Also given one eigen value of M is 2.
Let λ1
and λ2
be the other two eigen values of M.
The characteristic equation of M is
λ3
− 4λ2
+ aλ + 30 = 0
We know that,
Sum of the eigen values of M = − (The coefficient of λ2
in its characteristic equation)
⇒ 2 × λ1
+λ2
= − (−4)
⇒ λ1
+ λ2
= 2 (1)
and product of the eigen values of M = −(constant term of
the characteristic equation of M).
⇒ 2 + λ1
× λ2
= −30
⇒ λ1
λ2
= −15(2)
We know that the quadratic equation with λ1
and λ2
as roots
is
λ2
− (λ1
+ λ2
) λ + λ1
λ2
= 0
⇒ λ2
− (2) λ − 15 = 0 (From (1) and (2))
⇒ λ2
− 2λ − 15 = 0
⇒ (λ − 5) (λ + 3) = 0
⇒ λ = 5; λ = −3
i.e., λ1
= 5 and λ2
= −3
∴ The eigen values of M are −3, 2 and 5.
∴ The largest among the absolute values of the eigen values
of M is 5.
Hence, the correct answer is (5).
Question Number: 53 Question Type: NAT
Consider a machine with a byte addressable main memory
of 232
bytes divided into blocks of size 32 bytes.Assume that
a direct mapped cache having 512 cache lines is used with
this machine. The size of the tag field in bits is_______.
Solution: Main memory capacity = 232
B
Block size = 32B = 25
B
Number of lines in cache = 512 = 29
32 bits
9 5
Tag Line offset
−
Tag = 32 − (9 + 5)
= 18
Hence, the correct answer is (18).
54. GATE 2017 Solved Paper CS: Set – 2 | xlix
Question Number: 54 Question Type: NAT
Consider the following C Program.
#includestdio.h
int main () {
int m = 10;
int n, nl ;
n = ++m;
nl = m++;
n−−;
−−nl;
n −= nl;
printf (“%d”
, n) ;
return 0;
}
The output of the program is _____________.
Solution:
10
m
n = ++m;
11
n 11
m
n 1= m ++;
111
n 11
m 12
n - -;
11
n 10
- - n1;
1 11
n 10
n− =n1;
⇓
n = n − n1; 11
n 0
⇓
n = 10 − 10;
n = 0;
The output will result in 0.
Hence, the correct answer is (0).
Question Number: 55 Question Type: NAT
Consider the following C Program.
#includestdio.h
#includestring,h
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 __________.
Solution: The expression
(c + 2[p] − 6 [p] − 1) will map to the sub string 17, i.e.
G A T E C S I T 2 0 1 7
expression maps
to above character
The string length for the expression will result in 2.
Hence, the correct answer is (2).
General Aptitude
Number of Questions: 10 Section Marks: 15
Q.56 to Q.60 carry 1 mark each and Q.61 to Q.65 carry 2
marks each.
Question Number: 56 Question Type: MCQ
Choose the option with words that are not synonyms.
(A) aversion, dislike (B) luminous, radiant
(C) Plunder, loot (D) yielding, resistant
Ans: (D)
Question Number: 57 Question Type: MCQ
Saturn is ________ to be seen on a clear night with the
naked eye.
(A) enough bright (B) bright enough
(C) as enough bright (D) bright as enough
Ans: (B)
Question Number: 58 Question Type: MCQ
There are five buildings called V
. W. X. Y and Z in a row
(not necessarily in that order). V is to the West of W. Z is to
the East of X and the West of V. W is to the West ofY. Which
is the building in the middle?
(A) V (B) W
(C) X (D) Y
Ans: (A)
Question Number: 59 Question Type: MCQ
A test has twenty questions worth 100 marks in total. There
are two types of questions. Multiple choice questions are
worth 3 marks each and essay questions are worth 11 marks
each. How many multiple choice questions does the exam
have?
(A) 12 (B) 15
(C) 18 (D) 19
Ans: (B)
Question Number: 60 Question Type: MCQ
There are 3 red socks. 4 green socks and 3 blue socks. You
choose 2 socks. The probability that they are of the same
colour is
56. that we utterly repudiated that damnable doctrine of Metellus
Numidicus.
My father, wholly unmoved, as soon as a sullen silence was
established, recommenced—Do not think, ladies, said he, that you
were without advocates at that day: there were many Romans
gallant enough to blame the Censor for a mode of expressing
himself which they held to be equally impolite and injudicious.
'Surely,' said they, with some plausibility, 'if Numidicus wished men
to marry, he need not have referred so peremptorily to the
disquietudes of the connection, and thus have made them more
inclined to turn away from matrimony than given them a relish for
it.' But against these critics one honest man (whose name of Titus
Castricius should not be forgotten by posterity) maintained that
Metellus Numidicus could not have spoken more properly; 'For
remark,' said he, 'that Metellus was a censor, not a rhetorician. It
becomes rhetoricians to adorn, and disguise, and make the best of
things; but Metellus, sanctus vir—a holy and blameless man, grave
and sincere to wit, and addressing the Roman people in the solemn
capacity of Censor—was bound to speak the plain truth, especially
as he was treating of a subject on which the observation of every
day, and the experience of every life, could not leave the least doubt
upon the mind of his audience.' Still Riccabocca, having decided to
marry, has no doubt prepared himself to bear all the concomitant
evils—as becomes a professed sage; and I own I admire the art with
which Pisistratus has drawn the precise woman likely to suit a
philosopher.
Pisistratus bows, and looks round complacently; but recoils from two
very peevish and discontented faces feminine.
Mr. Caxton (completing his sentence.)—Not only as regards
mildness of temper and other household qualifications, but as
regards the very person of the object of his choice. For you evidently
remembered, Pisistratus, the reply of Bias, when asked his opinion
57. on marriage: Ητοι καλην ἑξεις, η αισχραν· και ει καλην, ἑξεις κοινην·
ει δη αισχραν ἑξεις ποινην.
Pisistratus tries to look as if he had the opinion of Bias by heart, and
nods acquiescingly.
Mr. Caxton.—That is, my dears, 'The woman you would marry is
either handsome or ugly; if handsome, she is koiné, viz., you don't
have her to yourself; if ugly, she is poiné—that is, a fury.' But, as it is
observed in Aulus Gellius (whence I borrow this citation), there is a
wide interval between handsome and ugly. And thus Ennius, in his
tragedy of Menalippus, uses an admirable expression to designate
women of the proper degree of matrimonial comeliness, such as a
philosopher would select. He calls this degree stata forma—a
rational, mediocre sort of beauty, which is not liable to be either
koiné or poiné. And Favorinus, who was a remarkably sensible man,
and came from Provence—the male inhabitants of which district
have always valued themselves on their knowledge of love and
ladies—calls this said stata forma the beauty of wives—the uxorial
beauty. Ennius says that women of a stata forma are almost always
safe and modest. Now Jemima, you observe, is described as
possessing this stata forma; and it is the nicety of your observation
in this respect, which I like the most in the whole of your description
of a philosopher's matrimonial courtship, Pisistratus, (excepting only
the stroke of the spectacles) for it shows that you had properly
considered the opinion of Bias, and mastered all the counter logic
suggested in Book v. Chapter xi., of Aulus Gellius.
For all that, said Blanche, half-archly, half-demurely, with a smile in
the eye, and a pout of the lip, I don't remember that Pisistratus, in
the days when he wished to be most complimentary, ever assured
me that I had a stata forma—a rational, mediocre sort of beauty.
And I think, observed my uncle, that when he comes to his real
heroine, whoever that may be, he will not trouble his head much
about either Bias or Aulus Gellius.
58. CHAPTER II.
Matrimony is certainly a great change in life. One is astonished not
to find a notable alteration in one's friend, even if he or she have
been only wedded a week. In the instance of Dr. and Mrs.
Riccabocca the change was peculiarly visible. To speak first of the
lady, as in chivalry bound, Mrs. Riccabocca had entirely renounced
that melancholy which had characterized Miss Jemima: she became
even sprightly and gay, and looked all the better and prettier for the
alteration. She did not scruple to confess honestly to Mrs. Dale, that
she was now of opinion that the world was very far from
approaching its end. But, in the mean while, she did not neglect the
duty which the belief she had abandoned serves to inculculate—She
set her house in order. The cold and penurious elegance that had
characterized the Casino disappeared like enchantment—that is, the
elegance remained, but the cold and penury fled before the smile of
woman. Like Puss-in-Boots after the nuptials of his master,
Jackeymo only now caught minnows and sticklebacks for his own
amusement. Jackeymo looked much plumper, and so did Riccabocca.
In a word, the fair Jemima became an excellent wife. Riccabocca
secretly thought her extravagant, but, like a wise man, declined to
look at the house bills, and ate his joint in unreproachful silence.
Indeed, there was so much unaffected kindness in the nature of Mrs.
Riccabocca—beneath the quiet of her manner there beat so genially
the heart of the Hazeldeans—that she fairly justified the favorable
anticipations of Mrs. Dale. And though the Doctor did not noisily
boast of his felicity, nor, as some new married folks do, thrust it
insultingly under the nimis unctis naribus—the turned-up noses of
your surly old married folks, nor force it gaudily and glaringly on the
envious eyes of the single, you might still see that he was a more
cheerful and light-hearted man than before. His smile was less
ironical, his politeness less distant. He did not study Machiavelli so
intensely—and he did not return to the spectacles; which last was an
59. excellent sign. Moreover, the humanizing influence of the tidy English
wife might be seen in the improvement of his outward or artificial
man. His clothes seemed to fit him better; indeed, the clothes were
new. Mrs. Dale no longer remarked that the buttons were off the
wristbands, which was a great satisfaction to her. But the sage still
remained faithful to the pipe, the cloak, and the red silk umbrella.
Mrs. Riccabocca had (to her credit be it spoken) used all becoming
and wife-like arts against these three remnants of the old bachelor
Adam, but in vain, Anima mia—soul of mine, said the Doctor,
tenderly, I hold the cloak, the umbrella, and the pipe, as the sole
relics that remain to me of my native country. Respect and spare
them.
Mrs. Riccabocca was touched, and had the good sense to perceive
that man, let him be ever so much married, retains certain signs of
his ancient independence—certain tokens of his old identity, which a
wife, the most despotic, will do well to concede. She conceded the
cloak, she submitted to the umbrella, she concealed her abhorrence
of the pipe. After all, considering the natural villainy of our sex, she
confessed to herself that she might have been worse off. But,
through all the calm and cheerfulness of Riccabocca, a nervous
perturbation was sufficiently perceptible; it commenced after the
second week of marriage—it went on increasing, till one bright
sunny afternoon, as he was standing on his terrace gazing down
upon the road, at which Jackeymo was placed—lo, a stage-coach
stopped! The Doctor made a bound, and put both hands to his heart
as if he had been shot; he then leapt over the balustrade, and his
wife from her window beheld him flying down the hill, with his long
hair streaming in the wind, till the trees hid him from her sight.
Ah, thought she with a natural pang of conjugal jealousy,
henceforth I am only second in his home. He has gone to welcome
his child! And at that reflection Mrs. Riccabocca shed tears.
But so naturally amiable was she, that she hastened to curb her
emotion, and efface as well as she could the trace of a stepmother's
60. grief. When this was done, and a silent, self-rebuking prayer
murmured over, the good woman descended the stairs with alacrity,
and, summoning up her best smiles, emerged on the terrace.
She was repaid; for scarcely had she come into the open air, when
two little arms were thrown round her, and the sweetest voice that
ever came from a child's lips, sighed out in broken English, Good
mamma, love me a little.
Love you? with my whole heart! cried the stepmother, with all a
mother's honest passion. And she clasped the child to her breast.
God bless you, my wife! said Riccabocca, in a husky tone.
Please take this, too, added Jackeymo, in Italian, as well as his
sobs would let him—and broke off a great bough full of blossoms
from his favorite orange-tree, and thrust it into his mistress's hand.
She had not the slightest notion what he meant by it!
CHAPTER III.
Violante was indeed a bewitching child—a child to whom I defy Mrs.
Caudle herself (immortal Mrs. Caudle!) to have been a harsh
stepmother.
Look at her now, as, released from those kindly arms, she stands,
still clinging with one hand to her new mamma, and holding out the
other to Riccabocca—with those large dark eyes swimming in happy
tears. What a lovely smile!—what an ingenuous candid brow! She
looks delicate—she evidently requires care—she wants the mother.
And rare is the woman who would not love her the better for that!
Still, what an innocent infantine bloom in those clear smooth cheeks!
—and in that slight frame, what exquisite natural grace!
61. And this, I suppose, is your nurse, darling? said Mrs. Riccabocca,
observing a dark foreign-looking woman, dressed very strangely—
without cap or bonnet, but a great silver arrow stuck in her hair, and
a filagree chain or necklace resting upon her kerchief.
Ah, good Annetta, said Violante in Italian. Papa, she says she is to
go back; but she is not to go back—is she?
Riccabocca, who had scarcely before noticed the woman, started at
that question—exchanged a rapid glance with Jackeymo—and then,
muttering some inaudible excuse, approached the Nurse, and,
beckoning her to follow him, went away into the grounds. He did not
return for more than an hour, nor did the woman then accompany
him home. He said briefly to his wife that the Nurse was obliged to
return at once to Italy, and that she would stay in the village to
catch the mail; that indeed she would be of no use in their
establishment, as she could not speak a word of English; but that he
was sadly afraid Violante would pine for her. And Violante did pine at
first. But still, to a child it is so great a thing to find a parent—to be
at home—that, tender and grateful as Violante was, she could not be
inconsolable while her father was there to comfort.
For the first few days, Riccabocca scarcely permitted any one to be
with his daughter but himself. He would not even leave her alone
with his Jemima. They walked out together—sat together for hours
in the Belvidere. Then by degrees he began to resign her more and
more to Jemima's care and tuition, especially in English, of which
language at present she spoke only a few sentences (previously,
perhaps, learned by heart), so as to be clearly intelligible.
CHAPTER IV.
There was one person in the establishment of Dr. Riccabocca, who
was satisfied neither with the marriage of his master nor the arrival
62. of Violante—and that was our friend Lenny Fairfield. Previous to the
all-absorbing duties of courtship, the young peasant had secured a
very large share of Riccabocca's attention. The sage had felt interest
in the growth of this rude intelligence struggling up to light. But
what with the wooing, and what with the wedding, Lenny Fairfield
had sunk very much out of his artificial position as pupil, into his
natural station of under-gardener. And on the arrival of Violante, he
saw, with natural bitterness, that he was clean forgotten, not only by
Riccabocca, but almost by Jackeymo. It was true that the master still
lent him books, and the servant still gave him lectures on
horticulture. But Riccabocca had no time nor inclination now to
amuse himself with enlightening that tumult of conjecture which the
books created. And if Jackeymo had been covetous of those mines
of gold buried beneath the acres now fairly taken from the Squire
(and good-naturedly added rent-free, as an aid to Jemima's dower),
before the advent of the young lady whose future dowry the
produce was to swell—now that she was actually under the eyes of
the faithful servant, such a stimulus was given to his industry, that
he could think of nothing else but the land, and the revolution he
designed to effect in its natural English crops. The garden, save only
the orange-trees, was abandoned entirely to Lenny, and additional
laborers were called in for the field-work. Jackeymo had discovered
that one part of the soil was suited to lavender, that another would
grow chamomile. He had in his heart apportioned a beautiful field of
rich loam to flax; but against the growth of flax the Squire set his
face obstinately. That most lucrative, perhaps, of all crops, when soil
and skill suit, had, it would appear, been formerly attempted in
England much more commonly than it is now; since you will find few
old leases which do not contain a clause prohibitory of flax, as an
impoverishment of the land. And though Jackeymo learnedly
endeavored to prove to the Squire that the flax itself contained
particles which, if returned to the soil, repaid all that the crop took
away, Mr. Hazeldean had his old-fashioned prejudices on the matter,
which were insuperable. My forefathers, quoth he, did not put
that clause in their leases without good cause; and as the Casino
63. lands are entailed on Frank, I have no right to gratify your foreign
whims at his expense.
To make up for the loss of the flax, Jackeymo resolved to convert a
very nice bit of pasture into orchard ground, which he calculated
would bring in £10 net per acre by the time Miss Violante was
marriageable. At this, the Squire pished a little; but as it was quite
clear that the land would be all the more valuable hereafter for the
fruit trees, he consented to permit the grass land to be thus
partially broken up.
All these changes left poor Lenny Fairfield very much to himself—at
a time when the new and strange devices which the initiation into
book knowledge creates, made it most desirable that he should have
the constant guidance of a superior mind.
One evening after his work, as Lenny was returning to his mother's
cottage very sullen and very moody, he suddenly came in contact
with Sprott the tinker.
CHAPTER V.
The tinker was seated under a hedge, hammering away at an old
kettle—with a little fire burning in front of him—and the donkey hard
by, indulging in a placid doze. Mr. Sprott looked up as Lenny passed
—nodded kindly, and said:
Good evenin', Lenny: glad to hear you be so 'spectably sitivated
with Mounseer.
Ay, answered Lenny, with a leaven of rancor in his recollections,
You're not ashamed to speak to me now, that I am not in disgrace.
But it was in disgrace, when it wasn't my fault, that the real
gentleman was most kind to me.
64. Ar—r, Lenny, said the Tinker, with a prolonged rattle in that said Ar
—r, which was not without great significance. But you sees the real
gentleman who han't got his bread to get, can hafford to 'spise his
cracter in the world. A poor tinker must be timbersome and nice in
his 'sociations. But sit down here a bit, Lenny; I've summat to say to
ye!
To me—
To ye. Give the neddy a shove out i' the vay, and sit down, I say.
Lenny rather reluctantly, and somewhat superciliously, accepted this
invitation.
I hears, said the Tinker in a voice made rather indistinct by a
couple of nails which he had inserted between his teeth; I hears as
how you be unkimmon fond of reading. I ha' sum nice cheap books
in my bag yonder—sum as low as a penny.
I should like to see them, said Lenny, his eyes sparkling.
The Tinker rose, opened one of the panniers on the ass's back, took
out a bag which he placed before Lenny, and told him to suit himself.
The young peasant desired no better. He spread all the contents of
the bag on the sward, and a motley collection of food for the mind
was there—food and poison—serpentes avibus—good and evil. Here,
Milton's Paradise Lost, there The Age of Reason—here Methodist
tracts, there True Principles of Socialism—Treatises on Useful
Knowledge by sound learning actuated by pure benevolence—
Appeals to Operatives by the shallowest reasoners, instigated by the
same ambition that had moved Eratosthenes to the conflagration of
a temple; works of fiction admirable as Robinson Crusoe, or innocent
as the Old English Baron, beside coarse translations of such garbage
as had rotted away the youth of France under Louis Quinze. This
miscellany was an epitome, in short, of the mixed World of Books, of
that vast City of the Press, with its palaces and hovels, its aqueducts
and sewers—which opens all alike to the naked eye and the curious
65. mind of him to whom you say, in the Tinker's careless phrase, suit
yourself.
But it is not the first impulse of a nature, healthful and still pure, to
settle in the hovel and lose itself amid the sewers; and Lenny
Fairfield turned innocently over the bad books, and selecting two or
three of the best, brought them to the Tinker and asked the price.
Why, said Mr. Sprott, putting on his spectacles, you has taken the
werry dearest: them 'ere be much cheaper, and more hinterestin'.
But I don't fancy them, answered Lenny; I don't understand what
they are about, and this seems to tell one how the steam-engine is
made, and has nice plates; and this is Robinson Crusoe, which
Parson Dale once said he would give me—I'd rather buy it out of my
own money.
Well, please yourself, quoth the Tinker; you shall have the books
for four bob, and you can pay me next month.
Four bobs—four shillings? it is a great sum, said Lenny, but I will
lay by, as you are kind enough to trust me; good evening, Mr.
Sprott.
Stay a bit, said the Tinker; I'll just throw you these two little
tracks into the barging; they be only a shilling a dozen, so 'tis but
tuppence—and ven you has read those, vy, you'll be a reglar
customer.
The Tinker tossed to Lenny Nos. 1 and 2 of Appeals to Operatives,
and the peasant took them up gratefully.
The young knowledge-seeker went his way across the green fields,
and under the still autumn foliage of the hedgerows. He looked first
at one book, then at another; he did not know on which to settle.
66. The Tinker rose and made a fire with leaves and furze and sticks,
some dry and some green.
Lenny has now opened No. 1 of the tracts: they are the shortest to
read, and don't require so much effort of the mind as the
explanation of the steam-engine.
The Tinker has now set on his grimy glue-pot, and the glue simmers.
CHAPTER VI.
As Violante became more familiar with her new home, and those
around her became more familiar with Violante, she was remarked
for a certain stateliness of manner and bearing, which, had it been
less evidently natural and inborn, would have seemed misplaced in
the daughter of a forlorn exile, and would have been rare at so early
an age among children of the loftiest pretensions. It was with the air
of a little princess that she presented her tiny hand to a friendly
pressure, or submitted her calm clear cheek to a presuming kiss. Yet
withal she was so graceful, and her very stateliness was so pretty
and captivating, that she was not the less loved for all her grand
airs. And, indeed, she deserved to be loved; for though she was
certainly prouder than Mr. Dale could approve of, her pride was
devoid of egotism; and that is a pride by no means common. She
had an intuitive forethought for others; you could see that she was
capable of that grand woman-heroism, abnegation of self; and
though she was an original child, and often grave and musing, with
a tinge of melancholy, sweet, but deep in her character, still she was
not above the happy genial merriment of childhood—only her silver
laugh was more attuned, and her gestures more composed than
those of children, habituated to many playfellows, usually are. Mrs.
Hazeldean liked her best when she was grave, and said she would
become a very sensible woman. Mrs. Dale liked her best when she
was gay, and said, she was born to make many a heart ache; for
67. which Mrs. Dale was properly reproved by the Parson. Mrs.
Hazeldean gave her a little set of garden tools; Mrs. Dale a picture-
book and a beautiful doll. For a long time the book and the doll had
the preference. But Mrs. Hazeldean having observed to Riccabocca
that the poor child looked pale, and ought to be a good deal in the
open air, the wise father ingeniously pretended to Violante that Mrs.
Riccabocca had taken a great fancy to the picture book, and that he
should be very glad to have the doll, upon which Violante hastened
to give them both away, and was never so happy as when mamma
(as she called Mrs. Riccabocca) was admiring the picture-book, and
Riccabocca with austere gravity dandled the doll. Then Riccabocca
assured her that she could be of great use to him in the garden; and
Violante instantly put into movement her spade, hoe, and
wheelbarrow.
This last occupation brought her into immediate contact with Mr.
Leonard Fairfield; and that personage one morning, to his great
horror, found Miss Violante had nearly exterminated a whole celery-
bed, which she had ignorantly conceived to be a crop of weeds.
Lenny was extremely angry. He snatched away the hoe, and said,
angrily, You must not do that, Miss. I'll tell your papa if you—
Violante drew herself up, and never having been so spoken to
before, at least since her arrival in England, there was something
comic in the surprise of her large eyes, as well as something tragic
in the dignity of her offended mien. It is very naughty of you, Miss,
continued Leonard, in a milder tone, for he was both softened by the
eyes and awed by the mien, and I trust you will not do it again.
Non capisco (I don't understand), murmured Violante, and the
dark eyes filled with tears. At that moment up came Jackeymo; and
Violante, pointing to Leonard, said, with an effort not to betray her
emotion, Il fanciullo e molto grossolano (he is a very rude boy).
68. Jackeymo turned to Leonard with the look of an enraged tiger. How
you dare, scum of de earth that you are, cried he,[13] how you
dare make cry the signorina? And his English not supplying familiar
vituperatives sufficiently, he poured out upon Lenny such a profusion
of Italian abuse, that the boy turned red and white in a breath with
rage and perplexity.
Violante took instant compassion upon the victim she had made,
and, with true feminine caprice, now began to scold Jackeymo for
his anger, and, finally approaching Leonard, laid her hand on his
arm, and said with a kindness at once childlike and queenly, and in
the prettiest imaginable mixture of imperfect English and soft Italian,
to which I can not pretend to do justice, and shall therefore
translate: Don't mind him. I dare say it was all my fault, only I did
not understand you: are not these things weeds?
No, my darling signorina, said Jackeymo, in Italian, looking ruefully
at the celery-bed, they are not weeds, and they sell very well at this
time of the year. But still, if it amuses you to pluck them up, I should
like to see who's to prevent it.
Lenny walked away. He had been called the scum of the earth, by
a foreigner, too! He had again been ill-treated for doing what he
conceived his duty. He was again feeling the distinction between rich
and poor, and he now fancied that that distinction involved deadly
warfare, for he had read from beginning to end those two damnable
tracts which the Tinker had presented to him. But in the midst of all
the angry disturbance of his mind, he felt the soft touch of the
infant's hand, the soothing influence of her conciliating words, and
he was half ashamed that he had spoken so roughly to a child.
Still, not trusting himself to speak, he walked away, and sat down at
a distance. I don't see, thought he, why there should be rich and
poor, master and servant. Lenny, be it remembered, had not heard
the Parson's Political Sermon.
69. An hour after, having composed himself, Lenny returned to his work.
Jackeymo was no longer in the garden; he had gone to the fields;
but Riccabocca was standing by the celery-bed, and holding the red
silk umbrella over Violante as she sat on the ground, looking up at
her father with those eyes already so full of intelligence, and love,
and soul.
Lenny, said Riccabocca, my young lady has been telling me that
she has been very naughty, and Giacomo very unjust to you. Forgive
them both.
Lenny's sullenness melted in an instant; the reminiscences of tracts
Nos. 1 and 2,
Like the baseless fabrics of a vision,
Left not a wreck behind.
He raised eyes, swimming with all his native goodness, toward the
wise man, and dropped them gratefully on the face of the infant
peacemaker. Then he turned away his head and fairly wept. The
Parson was right: O ye poor, have charity for the rich; O ye rich,
respect the poor.
CHAPTER VII.
Now from that day the humble Lenny and the regal Violante became
great friends. With what pride he taught her to distinguish between
celery and weeds—and how proud too, was she when she learned
that she was useful! There is not a greater pleasure you can give to
children, especially female children, than to make them feel they are
already of value in the world, and serviceable as well as protected.
Weeks and months rolled away, and Lenny still read, not only the
books lent him by the Doctor, but those he bought of Mr. Sprott. As
for the bombs and shells against religion which the Tinker carried in
70. his bag, Lenny was not induced to blow himself up with them. He
had been reared from his cradle in simple love and reverence for the
Divine Father, and the tender Saviour, whose life beyond all records
of human goodness, whose death beyond all epics of mortal
heroism, no being whose infancy has been taught to supplicate the
Merciful and adore the Holy, yea, even though his later life may be
entangled amidst the thorns of some desolate Pyrrhonism, can ever
hear reviled and scoffed without a shock to the conscience and a
revolt of the heart. As the deer recoils by instinct from the tiger, as
the very look of the scorpion deters you from handling it, though
you never saw a scorpion before, so the very first line in some ribald
profanity on which the Tinker put his slack finger, made Lenny's
blood run cold. Safe, too, was the peasant boy from any temptation
in works of a gross and licentious nature, not only because of the
happy ignorance of his rural life, not because of a more enduring
safeguard—genius! Genius, that, manly, robust, healthful as it be, is
long before it lose its instinctive Dorian modesty: shame-faced,
because so susceptible to glory—genius, that loves indeed to dream,
but on the violet bank, not the dunghill. Wherefore, even in the error
of the senses, it seeks to escape from the sensual into worlds of
fancy, subtle and refined. But apart from the passions, true genius is
the most practical of all human gifts. Like the Apollo, whom the
Greek worshiped as its type, even Arcady is its exile, not its home.
Soon weary of the dalliance of Tempé, its ascends to its mission—the
Archer of the silver bow, the guide of the car of light. Speaking more
plainly, genius is the enthusiasm for self-improvement; it ceases or
sleeps the moment it desists from seeking some object which it
believes of value, and by that object it insensibly connects its self-
improvement with the positive advance of the world. At present
Lenny's genius had no bias that was not to the Positive and Useful.
It took the direction natural to his sphere, and the wants therein,
viz., to the arts which we call mechanical. He wanted to know about
steam-engines and Artesian wells; and to know about them it was
necessary to know something of mechanics and hydrostatics; so he
bought popular elementary works on those mystic sciences, and set
all the powers of his mind at work on experiments.
71. Noble and generous spirits are ye, who with small care for fame, and
little reward from pelf, have opened to the intellects of the poor the
portals of wisdom! I honor and revere ye; only do not think ye have
done all that is needful. Consider, I pray ye, whether so good a
choice from the Tinker's bag would have been made by a boy whom
religion had not scared from the Pestilent, and genius had not led to
the Self-improving. And Lenny did not wholly escape from the
mephitic portions of the motley elements from which his awakening
mind drew its nurture. Think not it was all pure oxygen that the
panting lip drew in. No; there were still those inflammatory tracts.
Political I do not like to call them, for politics mean the art of
government, and the tracts I speak of assailed all government which
mankind has hitherto recognized. Sad rubbish, perhaps, were such
tracts to you, O sound thinker, in your easy-chair! Or to you,
practiced statesman, at your post on the Treasury Bench—to you,
calm dignitary of a learned Church—or to you, my lord judge, who
may often have sent from your bar to the dire Orcus of Norfolk's Isle
the ghosts of men whom that rubbish, falling simultaneously on the
bumps of acquisitiveness and combativeness, hath untimely slain.
Sad rubbish to you! But seems it such rubbish to the poor man, to
whom it promises a paradise on the easy terms of upsetting a
world? For ye see, these Appeals to Operatives represent that
same world-upsetting as the simplest thing imaginable—a sort of
two-and-two-make-four proposition. The poor have only got to set
their strong hands to the axle, and heave-a-hoy! and hurrah for the
topsy-turvy! Then, just to put a little wholesome rage into the
heave-a-hoy! it is so facile to accompany the eloquence of Appeals
with a kind of stir-the-bile-up statistics—Abuses of the
Aristocracy—Jobs of the Priesthood—Expenses of Army kept up
for Peers' younger sons—Wars contracted for the villainous
purpose of raising the rents of the landowners—all arithmetically
dished up, and seasoned with tales of every gentleman who has
committed a misdeed, every clergyman who has dishonored his
cloth; as if such instances were fair specimens of average gentlemen
and ministers of religion! All this passionately advanced, (and
observe, never answered, for that literature admits no
72. controversialists, and the writer has it all his own way), may be
rubbish; but it is out of such rubbish that operatives build barricades
for attack, and legislators prisons for defense.
Our poor friend Lenny drew plenty of this stuff from the Tinker's
bag. He thought it very clever and very eloquent; and he supposed
the statistics were as true as mathematical demonstrations.
A famous knowledge-diffuser is looking over my shoulder, and tells
me, Increase education, and cheapen good books, and all this
rubbish will disappear! Sir, I don't believe a word of it. If you
printed Ricardo and Adam Smith at a farthing a volume, I still
believe they would be as little read by the operatives as they are
nowadays by a very large proportion of highly-cultivated men. I still
believe that while the press works, attacks on the rich, and
propositions for heave-a-hoys, will always form a popular portion of
the Literature of Labor. There's Lenny Fairfield reading a treatise on
hydraulics, and constructing a model for a fountain into the bargain;
but that does not prevent his acquiescence in any proposition for
getting rid of a National Debt, which he certainly never agreed to
pay, and which he is told makes sugar and tea so shamefully dear.
No. I tell you what does a little counteract those eloquent incentives
to break his own head against the strong walls of the Social System
—it is, that he has two eyes in that head, which are not always
employed in reading. And, having been told in print that masters are
tyrants, parsons hypocrites or drones in the hive, and landowners
vampires and bloodsuckers, he looks out into the little world around
him, and, first he is compelled to acknowledge that his master is not
a tyrant (perhaps because he is a foreigner and a philosopher, and,
for what I and Lenny know, a republican). But then Parson Dale,
though High Church to the marrow, is neither hypocrite nor drone.
He has a very good living, it is true—much better than he ought to
have, according to the political opinions of those tracts; but Lenny
is obliged to confess that, if Parson Dale were a penny the poorer, he
would do a pennyworth's less good; and, comparing one parish with
another, such as Rood Hall and Hazeldean, he is dimly aware that
73. there is no greater CIVILIZER than a parson tolerably well off. Then,
too, Squire Hazeldean, though as arrant a Tory as ever stood upon
shoe-leather, is certainly not a vampire nor bloodsucker. He does not
feed on the public; a great many of the public feed upon him: and,
therefore, his practical experience a little staggers and perplexes
Lenny Fairfield as to the gospel accuracy of his theoretical dogmas.
Masters, parsons, landowners! having, at the risk of all popularity,
just given a coup de patte to certain sages extremely the fashion at
present, I am not going to let you off without an admonitory flea in
the ear. Don't suppose that any mere scribbling and typework will
suffice to answer scribbling and typework set at work to demolish
you—write down that rubbish you can't—live it down you may. If you
are rich, like Squire Hazeldean, do good with your money; if you are
poor, like Signor Riccabocca, do good with your kindness.
See! there is Lenny now receiving his week's wages; and though
Lenny knows that he can get higher wages in the very next parish,
his blue eyes are sparkling with gratitude, not at the chink of the
money, but at the poor exile's friendly talk on things apart from all
service; while Violante is descending the steps from the terrace,
charged by her mother-in-law with a little basket of sago, and
suchlike delicacies, for Mrs. Fairfield, who has been ailing the last
few days.
Lenny will see the Tinker as he goes home, and he will buy a most
Demosthenean Appeal—a tract of tracts, upon the Propriety of
Strikes, and the Avarice of Masters. But, somehow or other, I think
a few words from Signor Riccabocca, that did not cost the Signor a
farthing, and the sight of his mother's smile at the contents of the
basket, which cost very little, will serve to neutralize the effects of
that Appeal, much more efficaciously than the best article a
Brougham or a Mill could write on the subject.
74. CHAPTER VIII.
Spring had come again; and one beautiful May-day, Leonard Fairfield
sate beside the little fountain which he had now actually constructed
in the garden. The butterflies were hovering over the belt of flowers
which he had placed around his fountain, and the birds were singing
overhead. Leonard Fairfield was resting from his day's work, to enjoy
his abstemious dinner, beside the cool play of the sparkling waters,
and, with the yet keener appetite of knowledge, he devoured his
book as he munched his crusts.
A penny tract is the shoeing-horn of literature: it draws on a great
many books, and some too tight to be very useful in walking. The
penny tract quotes a celebrated writer, you long to read him; it props
a startling assertion by a grave authority, you long to refer to it.
During the nights of the past winter, Leonard's intelligence had made
vast progress: he had taught himself more than the elements of
mechanics, and put to practice the principles he had acquired, not
only in the hydraulical achievement of the fountain, nor in the still
more notable application of science, commenced on the stream in
which Jackeymo had fished for minnows, and which Lenny had
diverted to the purpose of irrigating two fields, but in various
ingenious contrivances for the facilitation or abridgment of labor,
which had excited great wonder and praise in the neighborhood. On
the other hand, those rabid little tracts, which dealt so summarily
with the destinies of the human race, even when his growing
reason, and the perusal of works more classical or more logical, had
led him to perceive that they were illiterate, and to suspect that they
jumped from premises to conclusions with a celerity very different
from the careful ratiocination of mechanical science, had still, in the
citations and references wherewith they abounded, lured him on to
philosophers more specious and more perilous. Out of the Tinker's
bag he had drawn a translation of Condorcet's Progress of Man, and
another of Rousseau's Social Contract. These had induced him to
select from the tracts in the Tinker's miscellany those which
abounded most in professions of philanthropy, and predictions of
75. some coming Golden Age, to which old Saturn's was a joke—tracts
so mild and mother-like in their language, that it required a much
more practical experience than Lenny's to perceive that you would
have to pass a river of blood before you had the slightest chance of
setting foot on the flowery banks on which they invited you to
repose—tracts which rouged poor Christianity on the cheeks,
clapped a crown of innocent daffodillies on her head, and set her to
dancing a pas de zephyr in the pastoral ballet in which St. Simon
pipes to the flock he shears; or having first laid it down as a
preliminary axiom, that
The cloud-capt towers, the gorgeous palaces,
The solemn temples, the great globe itself—
Yea, all which it inherit, shall dissolve,
substituted in place thereof Monsieur Fourier's symmetrical
phalanstere, or Mr. Owen's architectural parallelogram. It was with
some such tract that Lenny was seasoning his crusts and his
radishes, when Riccabocca, bending his long dark face over the
student's shoulder, said abruptly—
Diavolo, my friend! What on earth have you got there? Just let me
look at it, will you?
Leonard rose respectfully, and colored deeply as he surrendered the
tract to Riccabocca.
The wise man read the first page attentively, the second more
cursorily, and only ran his eye over the rest. He had gone through
too vast a range of problems political, not to have passed over that
venerable Pons Asinorum of Socialism, on which Fouriers and St.
Simons sit straddling and cry aloud that they have arrived at the last
boundary of knowledge!
All this is as old as the hills, quoth Riccabocca irreverently; but the
hills stand still, and this—there it goes! and the sage pointed to a
cloud emitted from his pipe. Did you ever read Sir David Brewster
76. on Optical Delusions? No! Well, I'll lend it to you. You will find
therein a story of a lady who always saw a black cat on her hearth-
rug. The black cat existed only in her fancy, but the hallucination
was natural and reasonable—eh—what do you think?
Why, sir, said Leonard, not catching the Italian's meaning, I don't
exactly see that it was natural and reasonable.
Foolish boy, yes! because black cats are things possible and known.
But who ever saw upon earth a community of men such as sit on the
hearth-rugs of Messrs. Owen and Fourier? If the lady's hallucination
was not reasonable, what is his, who believes in such visions as
these?
Leonard bit his lip.
My dear boy, cried Riccabocca kindly, the only thing sure and
tangible to which these writers would lead you, lies at the first step,
and that is what is commonly called a Revolution. Now, I know what
that is. I have gone, not indeed through a revolution, but an attempt
at one.
Leonard raised his eyes toward his master with a look of profound
respect, and great curiosity.
Yes, added Riccabocca, and the face on which the boy gazed
exchanged its usual grotesque and sardonic expression for one
animated, noble, and heroic. Yes, not a revolution for chimeras, but
for that cause which the coldest allow to be good, and which, when
successful, all time approves as divine—the redemption of our native
soil from the rule of the foreigner! I have shared in such an attempt.
And, continued the Italian mournfully, recalling now all the evil
passions it arouses, all the ties it dissolves, all the blood that it
commands to flow, all the healthful industry it arrests, all the
madmen that it arms, all the victims that it dupes, I question
whether one man really honest, pure, and humane, who has once
gone through such an ordeal, would ever hazard it again, unless he
77. was assured that the victory was certain—ay, and the object for
which he fights not to be wrested from his hands amidst the uproar
of the elements that the battle has released.
The Italian paused, shaded his brow with his hand, and remained
long silent. Then, gradually resuming his ordinary tone, he continued
—
Revolutions that have no definite objects made clear by the positive
experience of history; revolutions, in a word, that aim less at
substituting one law or one dynasty for another, than at changing
the whole scheme of society, have been little attempted by real
statesmen. Even Lycurgus is proved to be a myth who never existed.
They are the suggestions of philosophers who lived apart from the
actual world, and whose opinions (though generally they were very
benevolent, good sort of men, and wrote in an elegant poetical
style) one would no more take on a plain matter of life, than one
would look upon Virgil's Eclogues as a faithful picture of the ordinary
pains and pleasures of the peasants who tend our sheep. Read them
as you would read poets, and they are delightful. But attempt to
shape the world according to the poetry—and fit yourself for a
madhouse. The farther off the age is from the realization of such
projects, the more these poor philosophers have indulged them.
Thus, it was amidst the saddest corruption of court manners that it
became the fashion in Paris to sit for one's picture with a crook in
one's hand, as Alexis or Daphne. Just as liberty was fast dying out of
Greece, and the successors of Alexander were founding their
monarchies, and Rome was growing up to crush, in its iron grasp, all
states save its own, Plato withdraws his eyes from the world, to
open them in his dreamy Atlantis. Just in the grimmest period of
English history, with the ax hanging over his head, Sir Thomas More
gives you his Utopia. Just when the world is to be the theatre of a
new Sesostris, the dreamers of France tell you that the age is too
enlightened for war, that man is henceforth to be governed by pure
reason and live in a paradise. Very pretty reading all this to a man
like me, Lenny, who can admire and smile at it. But to you, to the
78. man who has to work for his living, to the man who thinks it would
be so much more pleasant to live at his ease in a phalanstere than
to work eight or ten hours a day; to the man of talent, and action,
and industry, whose future is invested in that tranquillity, and order
of a state, in which talent, and action and industry are a certain
capital; why, Messrs. Coutts, the great bankers, had better
encourage a theory to upset the system of banking! Whatever
disturbs society, yea, even by a causeless panic, much more by an
actual struggle, falls first upon the market of labor, and thence
affects, prejudicially, every department of intelligence. In such times
the arts are arrested; literature is neglected; people are too busy to
read any thing save appeals to their passions. And capital, shaken in
its sense of security, no longer ventures boldly through the land,
calling forth all the energies of toil and enterprise, and extending to
every workman his reward. Now, Lenny, take this piece of advice.
You are young, clever, and aspiring: men rarely succeed in changing
the world; but a man seldom fails of success if he lets the world
alone, and resolves to make the best of it. You are in the midst of
the great crisis of your life; it is the struggle between the new
desires knowledge excites, and that sense of poverty, which those
desires convert either into hope and emulation, or into envy and
despair. I grant that it is an up-hill work that lies before you; but
don't you think it is always easier to climb a mountain than it is to
level it? These books call on you to level the mountain; and that
mountain is the property of other people, subdivided among a great
many proprietors, and protected by law. At the first stroke of the
pick-ax, it is ten to one but what you are taken up for a trespass. But
the path up the mountain is a right of way uncontested. You may be
safe at the summit, before (even if the owners are fools enough to
let you) you could have leveled a yard. Cospetto! quoth the Doctor,
it is more than two thousand years ago since poor Plato began to
level it, and the mountain is as high as ever!
Thus saying, Riccabocca came to the end of his pipe, and, stalking
thoughtfully away, he left Leonard Fairfield trying to extract light
from the smoke.
79. CHAPTER IX.
Shortly after this discourse of Riccabocca's, an incident occurred to
Leonard that served to carry his mind into new directions. One
evening, when his mother was out, he was at work on a new
mechanical contrivance, and had the misfortune to break one of the
instruments which he employed. Now it will be remembered that his
father had been the Squire's head-carpenter; the widow had
carefully hoarded the tools of his craft, which had belonged to her
poor Mark; and though she occasionally lent them to Leonard, she
would not give them up to his service. Among these, Leonard knew
that he should find the one that he wanted; and being much
interested in his contrivance, he could not wait till his mother's
return. The tools, with other little relics of the lost, were kept in a
large trunk in Mrs. Fairfield's sleeping room; the trunk was not
locked, and Leonard went to it without ceremony or scruple. In
rummaging for the instrument, his eye fell upon a bundle of MSS.;
and he suddenly recollected that when he was a mere child, and
before he much knew the difference between verse and prose, his
mother had pointed to these MSS. and said, One day or other, when
you can read nicely, I'll let you look at these Lenny. My poor Mark
wrote such verses—ah, he was a scollard! Leonard, reasonably
enough, thought that the time had now arrived when he was worthy
the privilege of reading the paternal effusions, and he took forth the
MSS. with a keen but melancholy interest. He recognized his father's
handwriting, which he had often seen before in account-books and
memoranda, and read eagerly some trifling poems, which did not
show much genius, nor much mastery of language and rhythm—
such poems, in short as a self-educated man, with poetic taste and
feeling, rather than poetic inspiration or artistic culture, might
compose with credit, but not for fame. But suddenly, as he turned
over these Occasional Pieces, Leonard came to others in a different
handwriting—a woman's handwriting—small, and fine, and
exquisitely formed. He had scarcely read six lines of these last,
80. before his attention was irresistibly chained. They were of a different
order of merit from poor Mark's; they bore the unmistakable stamp
of genius. Like the poetry of women in general, they were devoted
to personal feeling—they were not the mirror of a world, but
reflections of a solitary heart. Yet this is the kind of poetry most
pleasing to the young. And the verses in question had another
attraction for Leonard: they seemed to express some struggle akin
to his own—some complaint against the actual condition of the
writer's life, some sweet melodious murmurs at fortune. For the rest,
they were characterized by a vein of sentiment so elevated that, if
written by a man, it would have run into exaggeration; written by a
woman, the romance was carried off by so many genuine revelations
of sincere, deep, pathetic feeling, that it was always natural, though
true to a nature from which you would not augur happiness.
Leonard was still absorbed in the perusal of these poems, when Mrs.
Fairfield entered the room.
What have you been about, Lenny? searching in my box?
I came to look for my father's bag of tools, mother, and I found
these papers, which you said I might read some day.
I doesn't wonder you did not hear me when I came in, said the
widow sighing. I used to sit still for the hour together, when my
poor Mark read his poems to me. There was such a pretty one about
the 'Peasant's Fireside,' Lenny—have you got hold of that?
Yes, dear mother; and I remarked the allusion to you: it brought
tears to my eyes. But these verses are not my father's—whose are
they? They seem a woman's hand.
Mrs. Fairfield looked—changed color—grew faint—and seated herself.
Poor, poor Nora! said she, faltering. I did not know as they were
there; Mark kep 'em; they got among his—
81. Leonard.—Who was Nora!
Mrs. Fairfield.—Who?—child—who? Nora was—was my own—own
sister.
Leonard (in great amaze, contrasting his ideal of the writer of these
musical lines, in that graceful hand, with his homely uneducated
mother, who can neither read nor write).—Your sister—is it
possible? My aunt, then. How comes it you never spoke of her
before? Oh! you should be so proud of her, mother.
Mrs. Fairfield (clasping her hands).—We were proud of her, all of us
—father, mother—all! She was so beautiful and so good, and not
proud she! though she looked like the first lady in the land. Oh!
Nora, Nora!
Leonard (after a pause).—But she must have been highly educated?
Mrs. Fairfield.—'Deed she was!
Leonard.—How was that?
Mrs. Fairfield (rocking herself to and fro in her chair.)—Oh! my Lady
was her godmother—Lady Lansmere I mean—and took a fancy to
her when she was that high! and had her to stay at the Park, and
wait on her ladyship; and then she put her to school, and Nora was
so clever that nothing would do but she must go to London as a
governess. But don't talk of it, boy! don't talk of it!
Leonard.—Why not, mother? what has become of her? where is
she?
Mrs. Fairfield (bursting into a paroxysm of tears.)—In her grave—in
her cold grave! Dead, dead!
Leonard was inexpressibly grieved and shocked. It is the attribute of
the poet to seem always living, always a friend. Leonard felt as if
82. some one very dear had been suddenly torn from his heart. He tried
to console his mother; but her emotion was contagious, and he wept
with her.
And how long has she been dead? he asked at last, in mournful
accents.
Many's the long year, many; but, added Mrs. Fairfield, rising, and
putting her tremulous hand on Leonard's shoulder, you'll just never
talk to me about her—I can't bear it—it breaks my heart. I can bear
better to talk of Mark—come down stairs—come.
May I not keep these verses, mother? Do let me.
Well, well, those bits o' paper be all she left behind her—yes, keep
them, but put back Mark's. Are they all here?—sure? And the
widow, though she could not read her husband's verses, looked
jealously at the MSS. written in his irregular large scrawl, and,
smoothing them carefully, replaced them in the trunk, and resettled
over them some sprigs of lavender, which Leonard had unwittingly
disturbed.
But, said Leonard, as his eye again rested on the beautiful
handwriting of his lost aunt—but you call her Nora—I see she signs
herself L.
Leonora was her name. I said she was my Lady's god-child. We
called her Nora for short—
Leonora—and I am Leonard—is that how I came by the name?
Yes, yes—do hold your tongue, boy, sobbed poor Mrs. Fairfield;
and she could not be soothed nor coaxed into continuing or
renewing a subject which was evidently associated with
insupportable pain.
83. CHAPTER X.
It is difficult to exaggerate the effect that this discovery produced on
Leonard's train of thought. Some one belonging to his own humble
race had, then, preceded him in his struggling flight toward the
loftier regions of Intelligence and Desire. It was like the mariner
amidst unknown seas, who finds carved upon some desert isle a
familiar household name. And this creature of genius and of sorrow
—whose existence he had only learned by her song, and whose
death created, in the simple heart of her sister, so passionate a grief,
after the lapse of so many years—supplied to the romance awaking
in his young heart the ideal which it unconsciously sought. He was
pleased to hear that she had been beautiful and good. He paused
from his books to muse on her, and picture her image to his fancy.
That there was some mystery in her fate was evident to him; and
while that conviction deepened his interest, the mystery itself, by
degrees, took a charm which he was not anxious to dispel. He
resigned himself to Mrs. Fairfield's obstinate silence. He was
contented to rank the dead among those holy and ineffable images
which we do not seek to unvail. Youth and Fancy have many secret
hoards of idea which they do not desire to impart, even to those
most in their confidence. I doubt the depth of feeling in any man
who has not certain recesses in his soul into which none may enter.
Hitherto, as I have said, the talents of Leonard Fairfield had been
more turned to things positive than to the ideal; to science and
investigation of fact than to poetry, and that airier truth in which
poetry has its element. He had read our greater poets, indeed, but
without thought of imitating; and rather from the general curiosity to
inspect all celebrated monuments of the human mind, than from
that especial predilection for verse which is too common in childhood
and youth to be any sure sign of a poet. But now these melodies,
unknown to all the world beside, rang in his ear, mingled with his
thoughts—set, as it were, his whole life to music. He read poetry
with a different sentiment—it seemed to him that he had discovered
84. its secret. And so reading, the passion seized him, and the numbers
came.
To many minds, at the commencement of our grave and earnest
pilgrimage, I am Vandal enough to think that the indulgence of
poetic taste and reverie does great and lasting harm; that it serves
to enervate the character, give false ideas of life, impart the
semblance of drudgery to the noble toils and duties of the active
man. All poetry would not do this—not, for instance, the Classical, in
its diviner masters—not the poetry of Homer, of Virgil, of Sophocles
—not, perhaps, even that of the indolent Horace. But the poetry
which youth usually loves and appreciates the best—the poetry of
mere sentiment—does so in minds already over predisposed to the
sentimental, and which require bracing to grow into healthful
manhood.
On the other hand, even this latter kind of poetry, which is peculiarly
modern, does suit many minds of another mould—minds which our
modern life, with its hard positive forms, tends to produce. And as in
certain climates plants and herbs, peculiarly adapted as antidotes to
those diseases most prevalent in the atmosphere, are profusely
sown, as it were, by the benignant providence of nature—so it may
be that the softer and more romantic species of poetry, which comes
forth in harsh, money-making, unromantic times, is intended as
curatives and counter-poisons. The world is so much with us,
nowadays, that we need have something that prates to us, albeit
even in too fine an euphuism, of the moon and stars.
Certes, to Leonard Fairfield, at that period of his intellectual life, the
softness of our Helicon descended as healing dews. In his turbulent
and unsettled ambition, in his vague grapple with the giant forms of
political truths, in his bias toward the application of science to
immediate practical purposes, this lovely vision of the Muse came in
the white robe of the Peacemaker; and with upraised hand, pointing
to serene skies, she opened to him fair glimpses of the Beautiful,
which is given to Peasant as to Prince—showed to him that on the
85. surface of earth there is something nobler than fortune—that he
who can view the world as a poet is always at soul a king; while to
practical purpose itself, that larger and more profound invention,
which poetry stimulates, supplied the grand design and the subtle
view—leading him beyond the mere ingenuity of the mechanic, and
habituating him to regard the inert force of the matter at his
command with the ambition of the Discoverer. But, above all, the
discontent that was within him finding a vent, not in deliberate war
upon this actual world, but through the purifying channels of song—
in the vent itself it evaporated, it was lost. By accustoming ourselves
to survey all things with the spirit that retains and reproduces them
only in their lovelier or grander aspects, a vast philosophy of
toleration for what we before gazed on with scorn or hate insensibly
grows upon us. Leonard looked into his heart after the enchantress
had breathed upon it; and through the mists of the fleeting and
tender melancholy which betrayed where she had been, he beheld a
new sun of delight and joy dawning over the landscape of human
life.
Thus, though she was dead and gone from his actual knowledge,
this mysterious kinswoman—a voice and nothing more—had
spoken to him, soothed, elevated, cheered, attuned each discord
into harmony; and, if now permitted from some serener sphere to
behold the life that her soul thus strangely influenced, verily, with
yet holier joy, the saving and lovely spirit might have glided onward
in the Eternal Progress.
We call the large majority of human lives obscure. Presumptuous
that we are! How know we what lives a single thought retained from
the dust of nameless graves may have lighted to renown?
CHAPTER XI.
86. Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com