GATE 2017 (Session 1)
64 questions
MCQ 44 · NAT 201-mark 30 · 2-mark 34
Questions 56–60 of 64
The number of integers between 1 and 500 (both inclusive) that are divisible by 3 or 5 or 7 is ______________.
Answer: 271
Use the inclusion-exclusion method for numbers 1 to 500:
Count formula:
Putting in the values: 166 + 100 + 71 33 23 14 + 4 = 271
Answer: 271
Count formula:
Putting in the values: 166 + 100 + 71 33 23 14 + 4 = 271
Answer: 271
Let A be an array of 31 numbers consisting of sequence of 0's followed by a sequence of 1's. The problem is to find the smallest index i that A[i] is 1 by probing the minimum numbers of locations in A. The worst case number of probes performed by an optimal algorithm is _____________.
Answer: 5
The array is sorted, with all 0s first and then all 1s. So binary search can find the first 1.
There are 31 numbers. The first 1 can be at any of the 31 positions, or there may be no 1 at all. This gives 32 possible answers. The number of probes needed is .
Answer: 5
There are 31 numbers. The first 1 can be at any of the 31 positions, or there may be no 1 at all. This gives 32 possible answers. The number of probes needed is .
Answer: 5
Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC- relative addressing mode with 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.
If the target of the branch instruction is i, then the decimal value of the Offset is __________
If the target of the branch instruction is i, then the decimal value of the Offset is __________
Answer: -16
The beq is instruction . The offset is counted from the next instruction, .
Each instruction is 4 bytes, so:
The target is instruction , so
Answer: -16
Each instruction is 4 bytes, so:
The target is instruction , so
Answer: -16
Instructions 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) respectively. A pipelined implementation of the processor requires buffering between each pair of consecutive stages with a delay of 2ns.
Two pipelined implementations of the processor are contemplated.
(i) a naive pipeline implementation (NP) with 5 stages and
(ii) an efficient pipeline (EP) where the OF stage id divided into stages OF1 and OF2 with execution times of 12 ns and 8 ns respectively.
The speedup (correct to two decimals places) achieved by EP over NP in executing 20 independent instructions with no hazards is ________________.
Two pipelined implementations of the processor are contemplated.
(i) a naive pipeline implementation (NP) with 5 stages and
(ii) an efficient pipeline (EP) where the OF stage id divided into stages OF1 and OF2 with execution times of 12 ns and 8 ns respectively.
The speedup (correct to two decimals places) achieved by EP over NP in executing 20 independent instructions with no hazards is ________________.
Answer: 1.49 to 1.52
Check each case:
- NP: slowest stage 20 + 2 (buffer) = 22 ns; 5 stages, 20 instructions (5 + 19) 22 = 528 ns
- EP: stages 5, 4, 12, 8, 10, 3 slowest 12 + 2 = 14 ns; (6 + 19) 14 = 350 ns
Speedup = 528 / 350 1.51
Answer: 1.51
- NP: slowest stage 20 + 2 (buffer) = 22 ns; 5 stages, 20 instructions (5 + 19) 22 = 528 ns
- EP: stages 5, 4, 12, 8, 10, 3 slowest 12 + 2 = 14 ns; (6 + 19) 14 = 350 ns
Speedup = 528 / 350 1.51
Answer: 1.51
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 the 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 experienced by the cache is ___________.
(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 experienced by the cache is ___________.
Answer: 76
The cache has 128 sets (2-way). Blocks 0, 128 and 256 map to set 0. Blocks 1, 129 and 257 map to set 1. In each round, set 0 sees this sequence: 0, 128, 256, 128, 0, 128, 256, 128.
- Round 1: 0, 128 and 256 are compulsory misses. After that, 0 and 256 miss again (conflict) 2 conflict misses.
- Every later round: 0 and 256 keep evicting each other, and 128 stays in the cache 4 conflict misses.
Set 0: 2 + 9 4 = 38. Set 1 behaves in the same way, so it also gives 38. Total = 76
Answer: 76
- Round 1: 0, 128 and 256 are compulsory misses. After that, 0 and 256 miss again (conflict) 2 conflict misses.
- Every later round: 0 and 256 keep evicting each other, and 128 stays in the cache 4 conflict misses.
Set 0: 2 + 9 4 = 38. Set 1 behaves in the same way, so it also gives 38. Total = 76
Answer: 76