GATE 2017 (Session 2)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 11–15 of 65
The representation of the value of a 16-bit unsigned integer X in hexadecimal number system is BCA9. The representation of the value of X in octal number system is
Answer: (D)
Write BCA9 in binary: 1011 1100 1010 1001. Now make groups of 3 bits, starting from the right: 1 011 110 010 101 001. Each group gives one octal digit: 1 3 6 2 5 1.
Answer: 136251
Answer: 136251
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 |
Answer: (A)
P: a static variable lives for the whole run of the program, so it is kept in the data section, not on the stack → (ii).
Q: malloc(10) returns the only pointer to a new 10-byte block, and m = NULL overwrites it. The block stays allocated but can no longer be reached or freed: lost memory (a memory leak) → (iv).
R: char *ptr[10] is an array of 10 pointers, that is, 10 consecutive memory locations that hold addresses → (i).
S: register asks the compiler to keep var1 in a CPU register (the compiler may ignore the request) → (iii).
Answer: (A)
Q: malloc(10) returns the only pointer to a new 10-byte block, and m = NULL overwrites it. The block stays allocated but can no longer be reached or freed: lost memory (a memory leak) → (iv).
R: char *ptr[10] is an array of 10 pointers, that is, 10 consecutive memory locations that hold addresses → (i).
S: register asks the compiler to keep var1 in a CPU register (the compiler may ignore the request) → (iii).
Answer: (A)
Match the algorithms with their time complexities:
Answer: (C)
Let us go through each item:
- Towers of Hanoi: , which matches (iii)
- Binary search: , which matches (iv)
- Heap sort in the worst case: , which matches (ii)
- Adding two n n matrices takes additions, so , which matches (i)
Answer: P-(iii), Q-(iv), R-(ii), S-(i)
- Towers of Hanoi: , which matches (iii)
- Binary search: , which matches (iv)
- Heap sort in the worst case: , which matches (ii)
- Adding two n n matrices takes additions, so , which matches (i)
Answer: P-(iii), Q-(iv), R-(ii), S-(i)
Let be any two context free languages and R be any regular language. Then which of the following is/are CORRECT ?
I. is context - free
II. is context - free
III. is context - free
IV. is context - free
I. is context - free
II. is context - free
III. is context - free
IV. is context - free
Answer: (B)
Check each statement:
- I: CFLs are closed under union. True
- II: CFLs are not closed under complement. False
- III: , and CFL regular gives a CFL. True
- IV: CFLs are not closed under intersection. False
Answer: I and III only
- I: CFLs are closed under union. True
- II: CFLs are not closed under complement. False
- III: , and CFL regular gives a CFL. True
- IV: CFLs are not closed under intersection. False
Answer: I and III only
Match the following according to input (from the left column) to the complier phase (in the right column) that processes it.
Answer: (C)
Phase that takes each input:
- Syntax tree is processed by the semantic analyzer (iii)
- Character stream is processed by the lexical analyzer (iv)
- Intermediate representation is processed by the code generator (i)
- Token stream is processed by the syntax analyzer (ii)
Answer: P-(iii), Q-(iv), R-(i), S-(ii)
- Syntax tree is processed by the semantic analyzer (iii)
- Character stream is processed by the lexical analyzer (iv)
- Intermediate representation is processed by the code generator (i)
- Token stream is processed by the syntax analyzer (ii)
Answer: P-(iii), Q-(iv), R-(i), S-(ii)