GATE 2024 (Session 2)
65 questions
MCQ 32 · MSQ 18 · NAT 151-mark 30 · 2-mark 35
Questions 31–35 of 65
An instruction format has the following structure:
Instruction Number:
Consider the following sequence of instructions to be executed in a pipelined processor:
I1: DIV R3, R1, R2
I2: SUB R5, R3, R4
I3: ADD R3, R5, R6
I4: MUL R7, R3, R8
Which of the following statements is/are TRUE
Instruction Number:
Consider the following sequence of instructions to be executed in a pipelined processor:
I1: DIV R3, R1, R2
I2: SUB R5, R3, R4
I3: ADD R3, R5, R6
I4: MUL R7, R3, R8
Which of the following statements is/are TRUE
One or more options are correct.
Answer: (A)
Check each statement:
- I1 writes R3 and I2 reads R3 RAW TRUE.
- I1 and I3 both write R3 this is WAW, not WAR FALSE.
- I2 reads R3 and I3 writes R3 this is WAR, not RAW FALSE.
- I3 writes R3 and I4 reads R3 this is RAW, not WAW FALSE.
Answer: There is a RAW dependency on R3 between I1 and I2
- I1 writes R3 and I2 reads R3 RAW TRUE.
- I1 and I3 both write R3 this is WAW, not WAR FALSE.
- I2 reads R3 and I3 writes R3 this is WAR, not RAW FALSE.
- I3 writes R3 and I4 reads R3 this is RAW, not WAW FALSE.
Answer: There is a RAW dependency on R3 between I1 and I2
Which of the following fields of an IP header is/are always modified by any router before it forwards the IP packet?
One or more options are correct.
Answer: (C), (D)
Each router lowers the TTL by one. A header field has changed, so the header checksum has to be calculated again.
An ordinary router does not change the source IP or the protocol field. The source IP changes only with NAT, and NAT is not what "any router" does.
Answer: TTL, Header Checksum
An ordinary router does not change the source IP or the protocol field. The source IP changes only with NAT, and NAT is not what "any router" does.
Answer: TTL, Header Checksum
Consider the following C function definition.
int fX(char *a){
char *b = a;
while(*b)
b++;
return b - a;} Which of the following statements is/are TRUE?One or more options are correct.
Answer: (A), (B), (D)
The function fX increases pointer until it finds '\0'. Then it returns , which is the string length.
- fX("abcd"): a string literal ends with a null character so it returns 4.
- char c[] = "abcd": the array holds 5 chars, including '\0' so it returns 4.
- char *c = "abcd": the pointer points to a literal that ends with a null character so it returns 4.
- The code is valid C (the pointer difference is converted to int) so it compiles.
Answer: Options 1, 2 and 4
- fX("abcd"): a string literal ends with a null character so it returns 4.
- char c[] = "abcd": the array holds 5 chars, including '\0' so it returns 4.
- char *c = "abcd": the pointer points to a literal that ends with a null character so it returns 4.
- The code is valid C (the pointer difference is converted to int) so it compiles.
Answer: Options 1, 2 and 4
Let be the partial order defined on the set as follows
The number of total orders on that contain is ______
The number of total orders on that contain is ______
Answer: 5
A total order that contains P must respect . So we count the possible orderings (linear extensions).
The first element can only be 1 or 3, because nothing has to come before them.
- If we start with 1: the next one must be 3, since both 2 and 4 need 3 before them. Then 2 and 4 can come in either order 1324, 1342 (2 orders).
- If we start with 3: we arrange 1, 2, 4 so that 1 comes before 2 3124, 3142, 3412 (3 orders).
Total = 5
Answer: 5
The first element can only be 1 or 3, because nothing has to come before them.
- If we start with 1: the next one must be 3, since both 2 and 4 need 3 before them. Then 2 and 4 can come in either order 1324, 1342 (2 orders).
- If we start with 3: we arrange 1, 2, 4 so that 1 comes before 2 3124, 3142, 3412 (3 orders).
Total = 5
Answer: 5
Let be an array containing integer values. The distance of is defined as the minimum number of elements in that must be replaced with another integer so that the resulting array is sorted in non-decreasing order. The distance of the array is _____
Answer: 3
The elements we keep must already be in non-decreasing order. All the other elements can be replaced with suitable values. So
distance = (length of the longest non-decreasing subsequence).
In [2, 5, 3, 1, 4, 2, 6], the longest non-decreasing subsequence is 2, 3, 4, 6. Its length is 4.
So the distance (for example [2, 2, 3, 3, 4, 4, 6]).
Answer: 3
distance = (length of the longest non-decreasing subsequence).
In [2, 5, 3, 1, 4, 2, 6], the longest non-decreasing subsequence is 2, 3, 4, 6. Its length is 4.
So the distance (for example [2, 2, 3, 3, 4, 4, 6]).
Answer: 3