GATE 2019
65 questions
MCQ 41 · NAT 241-mark 30 · 2-mark 35
Questions 31–35 of 65
The value of is _____
Answer: 2
Reduce the power step by step:
Two numbers are chosen independently and uniformly at random from the set {1, 2, ..., 13}. The probability (rounded off to 3 decimal places) that their 4-bit (unsigned) binary representations have the same most significant bit is ___________
Answer: 0.502 to 0.504
Look at the MSB of each number in 4 bits. It is 1 for the numbers 8 to 13 (6 numbers). It is 0 for the numbers 1 to 7 (7 numbers).
Probability that both MSBs match:
Answer: 0.503
Probability that both MSBs match:
Answer: 0.503
Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.
The process are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y-X is __________.
The process are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y-X is __________.
Answer: 80
Each update is really three steps: load D, change it, store D. So one process can overwrite the results of the others.
- Maximum: the update of P2 is lost. P1 reads 100. Then P2 runs fully (D = 50). P1 then writes 120, and P3 makes it 130. So .
- Minimum: both additions are lost. P2 reads 100. P1 and P3 then run fully (D = 130). P2 then writes 100 50 = 50. So .
Answer: 80
- Maximum: the update of P2 is lost. P1 reads 100. Then P2 runs fully (D = 50). P1 then writes 120, and P3 makes it 130. So .
- Minimum: both additions are lost. P2 reads 100. P1 and P3 then run fully (D = 130). P2 then writes 100 50 = 50. So .
Answer: 80
Consider the following C program:
#include <stdio.h>
int main(){
int arr[] = {1,2,3,4,5,6,7,8,9,0,1,2,5}, *ip = arr + 4;
printf("%d\n", ip[1]);
return 0;
} The number that will be displayed on execution of the program is _________ .Answer: 6
Here ip = arr + 4 is the address of arr[4]. So ip[1] = *(ip + 1) = arr[5] = 6.
Answer: 6
Answer: 6
Consider a sequence of 14 elements: A = [-5, -10, 6, 3, -1, -2, 13, 4, -9, -1, 4, 12, -3, 0]. The sequence sum . Determine the maximum of S(i,j), where . (Divide and conquer approach may be used). Answer:______
Answer: 29
Apply Kadane's method: keep a running sum and start again when it becomes negative.
5 and 10 are left out. Start from 6. The running sums are 6, 9, 8, 6, 19, 23, 14, 13, 17, 29, 26, 26.
The maximum subarray is 6 + 3 1 2 + 13 + 4 9 1 + 4 + 12 = 29.
Answer: 29
5 and 10 are left out. Start from 6. The running sums are 6, 9, 8, 6, 19, 23, 14, 13, 17, 29, 26, 26.
The maximum subarray is 6 + 3 1 2 + 13 + 4 9 1 + 4 + 12 = 29.
Answer: 29