Javatpoint Logo
Javatpoint Logo

GATE 2017 CS Set 2

1) The representation of the value of a 16-bit unsigned integer X in a hexadecimal number system is BCA9. The representation of the value of X in octal number system is:

  1. 571244
  2. 736251
  3. 571247
  4. 136251

Answer: D

Explanation:

Given, Hexadecimal number = BCA9

        Binary conversion = 001011110010101001

To convert in Octal number, take 3 bits from LSB of the binary conversion and convert to decimal.

i.e. 001 011 110 010 101 001

= 1 3 6 2 5 1

Therefore option (D) is the right answer.


2) 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
  1. P-->(ii), Q-->(iv), R-->(i), S-->(iii)
  2. P-->(ii), Q-->(i), R-->(iv), S-->(iii)
  3. P-->(ii), Q-->(iv), R-->(iii), S-->(i)
  4. P-->(iii), Q-->(iv), R-->(i), S-->(ii)

Answer: B

Explanation:

(P) -> (ii) static char var; As we can see that the given variable is static in nature, so it is located in a data section of memory.

(Q) -> (i) m = malloc (10); m = NULL; 10 contiguous bytes of memory is allocated, and address of the first byte is stored in variable 'm'. Later it is updated with NULL, that lost the memory completely which cannot be freed.

(R) -> (iv) char *ptr[10]; Sequence of memory locations to store addresses of type char.

(S) -> (iii) register int var1; Request to allocate a cpu register to store data.

Therefore option (B) is the right answer.


3) 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)
  1. P-> (iii), Q -> (iv), R -> (i), S -> (ii)
  2. P-> (iv), Q -> (iii), R -> (i), S -> (ii)
  3. P-> (iii), Q -> (iv), R -> (ii), S -> (i)
  4. P-> (iv), Q -> (iii), R -> (ii), S -> (i)

Answer: C

Explanation:

Tower of Hanoi -> θ(2n)

Heap sort (worst case) -> θ(n log n)

Binary Search -> θ(log n)

Addition of Two n * n Matrices -> θ(n2)

Therefore option (C) is the right answer.


4) Let L1 and L2 be any context-free language and R be any regular language. Then, which of the following is correct?

I. L1 ∪ L2 is context-free.
II. L1' is context-free.
III. L1-R is context-free.
IV. L1 ∩ L2

  1. I, II and IV only
  2. I and III only
  3. II and IV only
  4. I only

Answer: B

Explanation:

Given, L1 and L2 are context-free languages, and R is a regular language.
Statement I is TRUE as context-free language are closed under union operation.
Statement II is FALSE as context-free languages are not closed under complementation operation.
Statement III is TRUE as L1 - R = L1 ∩ R', the intersection of context-free languages and regular is always context-free.
Statement IV is FALSE as context-free languages are not closed under intersection operation.

Therefore option (B) is the right answer.


5) Match the following according to input(from the left column) to the compiler phase(in the right column) that process it:

(P) Syntax tree (i) Code generator
(Q) Character stream (ii) Syntax analyzer
(R) Intermediate representation (iii) Symantic analyzer
(S) Token stream (iv) Lexical analyzer
  1. P -> (ii), Q -> (iii), R -> (iv), S -> (i)
  2. P -> (ii), Q -> (i), R -> (iii), S -> (iv)
  3. P -> (iii), Q -> (iv), R -> (i), S -> (ii)
  4. P -> (i), Q -> (iv), R -> (ii), S -> (iii)

Answer: C

Explanation:

P - iii. The syntax tree is processed as input to a semantic analyzer.

Q - iv. Character stream is given as input to the lexical analyzer.

R - i. Intermediate code is used for the code generation process.

S - ii. The token stream is input to syntax analyzer.

Therefore option (C) is the right answer.


6) Which of the following statements about the 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.

  1. I only
  2. II only
  3. III only
  4. II and III only

Answer: A

Explanation:

Bottom-up parsers in decreasing order in term of their power: CLR > LALR > SLR > LR (0)

The given statements:

I. Canonical LR is more powerful than SLR is CORRECT.

II. SLR is more powerful than LALR is INCORRECT

III. SLR is more powerful than Canonical LR is INCORRECT.

Therefore option (A) is the right answer.


7) Which of the following is/are shared by all the threads in a process?

Program Counter
Stack
Address space
Registers

  1. I and II only
  2. III only
  3. IV only
  4. III and IV only

Answer: B

Explanation:

The thread is a light-weight process. There can be many threads in a single process. Every thread must have its own stack, register and program counter (PC). Address space is generally used in the context of a process, not threads. But all threads of the same process reside in same address space as the parent process so we can say that all threads share the address space. Therefore option (B) is the right answer.


8) In a file allocation system, which of the following allocation scheme(s) can be used if no external fragmentation is allowed?

I. Contiguous
II. Linked
III. Indexed

  1. I and III only
  2. II only
  3. III only
  4. II and III only

Answer: D

Explanation:

The contiguous allocation always suffers from external fragmentation. But linked and indexed allocation schemes free from external fragmentation. Therefore option (D) is the right answer.


GATE 2017 CS Set 2-2
GATE 2017 CS Set 2-3
GATE 2017 CS Set 2-4
GATE 2017 CS Set 2-5
GATE 2017 CS Set 2-6
GATE 2017 CS Set 2-7
GATE 2017 CS Set 2-8






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA