GATE 2014 (Session 2)
65 questions
MCQ 42 · NAT 231-mark 30 · 2-mark 35
Questions 51–55 of 65
Suppose a stack implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?
Answer: (C)
Put the front of the queue at the top of the stack.
- ENQUEUE(x): do REVERSE, then PUSH x, then REVERSE again. This is 3 instructions.
- DEQUEUE: do POP. This is 1 instruction.
Answer: ENQUEUE takes three instructions and DEQUEUE takes one
- ENQUEUE(x): do REVERSE, then PUSH x, then REVERSE again. This is 3 instructions.
- DEQUEUE: do POP. This is 1 instruction.
Answer: ENQUEUE takes three instructions and DEQUEUE takes one
Consider the C function given below
int f(int j)
{
static int i = 50;
int k;
if (i == j)
{
printf("something");
k = f(i);
return 0;
}
else return 0;
} Which one of the following is TRUE?Answer: (D)
The variable i is static, so it keeps the value 50. Take j = 50. Then the check i == j is true, and the function calls f(i), which is f(50), once more. In that call i == j is true again, so the same thing repeats. The recursion never stops, and the stack overflows.
For any other value of j, the function just returns 0.
Answer: The function will exhaust the runtime stack or run into an infinite loop when j = 50
For any other value of j, the function just returns 0.
Answer: The function will exhaust the runtime stack or run into an infinite loop when j = 50
In designing a computer's cache system, the cache block (or cache line) size is an important Parameter. Which one of the following statements is correct in this context?
Answer: (D)
Check each statement:
(A) False. A smaller block brings in fewer neighbouring words, so it uses spatial locality less, not better.
(B) False. A smaller block gives more blocks, so there are more tags in total, and the tag does not get smaller. So tag overhead is higher, not lower.
(C) False. More or larger tags mean more bits to store and compare. This does not make a hit faster.
(D) True. On a miss only a small block is moved from memory, so the miss penalty is lower.
Answer: (D)
(A) False. A smaller block brings in fewer neighbouring words, so it uses spatial locality less, not better.
(B) False. A smaller block gives more blocks, so there are more tags in total, and the tag does not get smaller. So tag overhead is higher, not lower.
(C) False. More or larger tags mean more bits to store and compare. This does not make a hit faster.
(D) True. On a miss only a small block is moved from memory, so the miss penalty is lower.
Answer: (D)
If the associativity of a processor cache is doubled while keeping the capacity and block size unchanged, which one of the following is guaranteed to be NOT affected?
Answer: (D)
When associativity is doubled, the cache has half as many sets. The index becomes 1 bit smaller, the tag becomes 1 bit larger, and the way multiplexer needs twice as many inputs.
The width of the data bus between the processor and main memory does not depend on how the cache is organised.
Answer: Width of processor to main memory data bus
The width of the data bus between the processor and main memory does not depend on how the cache is organised.
Answer: Width of processor to main memory data bus
The value of a float type variable is represented using the single-precision 32-bit floating point format of IEEE-754 standard that uses 1 bit for sign, 8 bits for biased exponent and 23 bits for mantissa. A float type variable x is assigned the decimal value of -14.25. The representation of x in hexadecimal notation is
Answer: (A)
Binary form and normalised form:
- Sign bit = 1
- Biased exponent = 3 + 127 = 130 = 10000010
- Mantissa = 1100100...0
Joining the fields, 1 10000010 11001000... = 1100 0001 0110 0100 0000... = C1640000H
Answer: C1640000H
- Sign bit = 1
- Biased exponent = 3 + 127 = 130 = 10000010
- Mantissa = 1100100...0
Joining the fields, 1 10000010 11001000... = 1100 0001 0110 0100 0000... = C1640000H
Answer: C1640000H