GATE 2022
65 questions
MCQ 32 · MSQ 15 · NAT 181-mark 30 · 2-mark 35
Questions 41–45 of 65
Consider three floating point numbers A, B and C stored in registers , and , respectively as per IEEE-754 single precision floating point format. The 32-bit content stored in these registers (in hexadecimal form) are as follows.
Which one of the following is FALSE?
Which one of the following is FALSE?
Answer: (B)
Decode each register (sign | exponent | mantissa):
- C1400000: sign 1, exponent , mantissa 1.1 = 1.5
- 42100000: sign 0, exponent , mantissa 1.001 = 1.125
- 41400000: like A, but positive
- True
- FALSE
- True
- True
Answer: C = A + B
- C1400000: sign 1, exponent , mantissa 1.1 = 1.5
- 42100000: sign 0, exponent , mantissa 1.001 = 1.125
- 41400000: like A, but positive
- True
- FALSE
- True
- True
Answer: C = A + B
Consider four processes P, Q, R, and S scheduled on a CPU as per round robin algorithm with a time quantum of 4 units. The processes arrive in the order P, Q, R, S, all at time t = 0. There is exactly one context switch from S to Q, exactly one context switch from R to Q, and exactly two context switches from Q to R. There is no context switch from S to P. Switching to a ready process after the termination of another process is also considered a context switch. Which one of the following is NOT possible as CPU burst time (in time units) of these processes?
Answer: (D)
Let us run round robin (quantum 4, order P, Q, R, S) on the burst times P = 3, Q = 7, R = 7, S = 3.
- P runs for 3 units and finishes Q runs for 4 units (3 left) R runs for 4 units (3 left) S runs for 3 units and finishes
- Q runs for 3 units and finishes R runs for 3 units and finishes
The context switches are: PQ, QR, RS, SQ, QR. There is no R Q switch, but exactly one is needed. So these burst times cannot work.
(If we run the other three sets of burst times, we get exactly one SQ, one RQ, two QR and no SP.)
Answer: P = 3, Q = 7, R = 7, S = 3
- P runs for 3 units and finishes Q runs for 4 units (3 left) R runs for 4 units (3 left) S runs for 3 units and finishes
- Q runs for 3 units and finishes R runs for 3 units and finishes
The context switches are: PQ, QR, RS, SQ, QR. There is no R Q switch, but exactly one is needed. So these burst times cannot work.
(If we run the other three sets of burst times, we get exactly one SQ, one RQ, two QR and no SP.)
Answer: P = 3, Q = 7, R = 7, S = 3
What is printed by the following ANSI C program?
#include <stdio.h>
int main(int argc, char *argv[])
{
int a[3][3][3] =
{{1, 2, 3, 4, 5, 6, 7, 8, 9},
{10, 11, 12, 13, 14, 15, 16, 17, 18},
{19, 20, 21, 22, 23, 24, 25, 26, 27}};
int i = 0, j = 0, k = 0;
for( i = 0; i < 3; i++ ){
for(k = 0; k < 3; k++ )
printf("%d ", a[i][j][k]);
printf(" \n");
}
return 0;
}
Answer: (A)
Each inner brace holds 9 values for , and they are stored one after another in order:
a[0][0] = {1, 2, 3}, a[1][0] = {10, 11, 12}, a[2][0] = {19, 20, 21},
The value of j remains 0, and the loops print for k = 0, 1, 2:
1 2 3
10 11 12
19 20 21
Answer: 1 2 3 / 10 11 12 / 19 20 21
a[0][0] = {1, 2, 3}, a[1][0] = {10, 11, 12}, a[2][0] = {19, 20, 21},
The value of j remains 0, and the loops print for k = 0, 1, 2:
1 2 3
10 11 12
19 20 21
Answer: 1 2 3 / 10 11 12 / 19 20 21
What is printed by the following ANSI C program?
ASCII encoding for relevant characters is given below
#include <stdio.h>
int main(int argc, char *argv[]){
char a = 'P';
char b = 'x';
char c = (a & b) + '*';
char d = (a | b) - '-';
char e = (a ^ b) + '+';
printf("%c %c %c \n", c, d, e);
return 0;
}
ASCII encoding for relevant characters is given below
Answer: (A)
The ASCII codes are 'P' = 80 = 0101 0000 and 'x' = 120 = 0111 1000.
- AND: = 0101 0000 = 80. Then 80 + '*'(42) = 122, which is 'z'
- OR: = 0111 1000 = 120. Then 120 '-'(45) = 75, which is 'K'
- XOR: = 0010 1000 = 40. Then 40 + '+'(43) = 83, which is 'S'
The printf call uses %c, so it prints characters: z K S
Answer: z K S
- AND: = 0101 0000 = 80. Then 80 + '*'(42) = 122, which is 'z'
- OR: = 0111 1000 = 120. Then 120 '-'(45) = 75, which is 'K'
- XOR: = 0010 1000 = 40. Then 40 + '+'(43) = 83, which is 'S'
The printf call uses %c, so it prints characters: z K S
Answer: z K S
Consider solving the following system of simultaneous equations using LU decomposition.
where L and U are denoted as
Which one of the following is the correct combination of values for and ?
where L and U are denoted as
Which one of the following is the correct combination of values for and ?
Answer: (D)
Use the Doolittle LU method, where L has a unit diagonal:
- The first row of U is [1, 1, 2]. Then
- Next:
- Then:
- Last:
Now solve the system. Take eq2 eq1, which gives . Take eq3 2eq1, which gives . So .
Answer:
- The first row of U is [1, 1, 2]. Then
- Next:
- Then:
- Last:
Now solve the system. Take eq2 eq1, which gives . Take eq3 2eq1, which gives . So .
Answer: