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 Question Number: 3 Question Type: MCQ
marks each. Match the algorithms with their time complexities:
Question Number: 1 Question Type: MCQ
Algorithm Time complexity
The representation of the value of a 16-bit unsigned integer
X in hexadecimal number system is BCA9. The representa- (P) Towers of Hanoi with n disks (i) Θ (n2)
tion of the value of X in octal number system is (Q) B inary search given n sorted (ii) Θ (n log n)
(A) 571244 (B) 736251 numbers
(C) 571247 (D) 136251 (R) Heap sort given n numbers at the (iii) Θ (2n)
Solution: worst case
(BCA9)16 octal
( x )8 (S) Addition of two n × n matrices (iv) Θ (log n)
(BCA9)16 → (x)2
(BCA9)16 → (1011 1100 1010 1001) 2 (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)
(x)8 (D) P → (iv), Q → (iii), R → (ii), S → (i)
001 011 110 0 10 10 1 001 Solution: To solve Towers of Hanoi puzzle of ‘n’ disks, it
→ (136251)8
1 3 6 2 5 1 takes θ(2n) time.
Hence, the correct option is (D). Binary search over ‘n’ sorted numbers takes θ(log n) time.
Question Number: 2 Question Type: MCQ ‘n’ numbers can be sorted in θ(n log n) time using Heap sort
Match the following: even in worst case.
Addition of two matrices of order n × n takes θ(n2) time,
(P) static char var; (i)
Sequence of memory locations to
store addresses since it requires n2 computations.
(Q) m = malloc (10); (ii) A variable located in data section of Hence, the correct option is (C).
m = NULL; memory
Question Number: 4 Question Type: MCQ
(R) char *ptr [10]; (iii) Request to allocate a CPU register
to store data Let L1 L2 be any two context-free languages and R be
(S) register int var1; (iv)
A lost memory which cannot be
any regular language. Then which of the following is/are
freed CORRECT?
(A) P → (ii), Q → (iv), R → (i), S → (iii) I. L1 ∪ L2 is context-free.
(B) P → (ii), Q → (i), R → (iv), S → (iii) II. L1 is context-free.
(C) P → (ii), Q → (iv), R → (iii), S → (i) III. L1 − R is context-free.
(D) P → (iii), Q → (iv), R → (i), S → (ii) IV. L1 ∩ L2 is context-free.
(A) I, II and IV only (B) I and III only
Solution: (C) II and IV only (D) I only
• Static variables are stored in the program data segment.
• The statement m = malloc (10) is assigned with 10 Solution: Given L1, L2 are CFL. R is regular.
memory units and when m is assigned with NULL val- CFL’s are closed under union. CFL’s are not closed under
ue, then memory allocated is lost and it can’t be freed. complement.
• char *ptr [10]; declaration specifies a 10 pointers which
L1 − R = L1 ∩ R
are used to store memory addresses.
• register int var1; declaration request the CPU for al- R is closed under complement. Intersection of regular and
location of CPU registers for storing data. CFL is CFL.
Hence, the correct option is (A).
GATE 2017 Solved Paper CS: Set – 2 | xxxv
CFL’s are not closed under intersection. Question Number: 7 Question Type: MCQ
∴ I and III are correct. Which of the following is/are shared by all the threads in a
Hence, the correct option is (B). process?
I. Program counter
Question Number: 5 Question Type: MCQ II. Stack
Match the following according to input (from the left col- III. Address space
umn) to the compiler phase (in the right column) that pro- IV. Registers
cesses it: (A) I and II only (B) III only
(C) IV only (D) III and IV only
(P) Syntax tree (i) Code generator
Solution: Each thread has its own program counter, stack,
(Q) Character stream (ii) Syntax analyzer
Registers and state.
(R) Intermediate representation (iii) Semantic analyzer
(S) Token stream (iv) Lexical analyzer
Address space is shared by all threads of a process
Hence, the correct option is (B).
(A) P → (ii), Q → (iii), R → (iv), S → (i)
(B) P → (ii), Q → (i), R → (iii), S → (iv) Question Number: 8 Question Type: MCQ
(C) P → (iii), Q → (iv), R → (i), S → (ii) In a file allocation system, which of the following alloca-
(B) P → (i), Q → (iv), R → (ii), S → (iii) tion scheme(s) can be used if no external fragmentation is
allowed?
Solution: Phases of compiles with inputs I. Contiguous
Source code II. Linked
↓ Character stream III. Indexed
Lexical analysis (lexical analyzer) (A) I and III only (B) II only
↓ Token stream (C) III only (D) II and III only
Syntax analysis (syntax analyzer)
↓ Syntax tree Solution: In contiguous allocation, there is a possibility of
Semantic analysis (semantic analyzer) external fragmentation.
↓ Intermediate representation Hence, the correct option is (D).
Code generator Question Number: 9 Question Type: MCQ
↓
Consider the following statements about the routing proto-
Output
cols. Routing Information Protocol (RIP) and Open Shortest
Hence, the correct option is (C).
Path First (OSPF) in an IPv4 network.
Question Number: 6 Question Type: MCQ I: RIP uses distance vector routing
II: RIP packets are sent using UDP
Which of the following statements about parser is/are
III: OSPF packets are sent using TCP
CORRECT?
IV: OSPF operation is based on link-state routing
I. Canonical LR is more powerful than SLR.
II. SLR is more powerful than LALR. Which of the statements above are CORRECT?
III. SLR is more powerful than Canonical LR. (A) I and IV only
(A) I only (B) II only (B) I, II and III only
(C) III only (D) I and III only (C) I, II and IV only
(D) II, III and IV only
Solution: Relation among parsers (with respect to accept-
Solution:
ing languages) is shown with below Venn diagram:
• RIP uses distance vector routing.
CLR (1)
LALR (1) • RIP packets are sent using UDP as RIP uses UDP as
SLR (1) transport protocol.
• OSPF packets are not sent using TCP and its operation
LR (0) is based on link state routing.
LL (1) Hence, the correct option is (C).
Question Number: 10 Question Type: MCQ
p x 1 1 2R
If f(x) = R sin + S , f ' = 2 and ∫ f ( x) dx = ,
Hence, the correct option is (A). 2 2 0 p
then the constants R and S are, respectively.