GATE 2021 (Session 2)
64 questions
MCQ 33 · MSQ 13 · NAT 181-mark 29 · 2-mark 35
Questions 16–20 of 64
Consider the three-way handshake mechanism followed during TCP connection establishment between hosts P and Q. Let X and Y be two random 32-bit starting sequence numbers chosen by P and Q respectively. Suppose P sends a TCP connection request message to Q with a TCP segment having SYN bit =1, SEQ number =X, and ACK bit =0. Suppose Q accepts the connection request. Which one of the following choices represents the information present in the TCP segment header that is sent by Q to P?
Answer: (C)
Q replies with a SYN-ACK segment:
- SYN = 1, and the SEQ field holds Q's own starting sequence number, SEQ = Y
- ACK = 1, because Q acknowledges the SYN from P (the SYN takes up one sequence number) ACK number = X + 1
- FIN = 0
Answer: SYN = 1, SEQ = Y, ACK = 1, ACK number = X+1, FIN = 0
- SYN = 1, and the SEQ field holds Q's own starting sequence number, SEQ = Y
- ACK = 1, because Q acknowledges the SYN from P (the SYN takes up one sequence number) ACK number = X + 1
- FIN = 0
Answer: SYN = 1, SEQ = Y, ACK = 1, ACK number = X+1, FIN = 0
What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size n?
Answer: (B)
In every recursive call, a fixed number of arithmetic operations is done (finding mid), and the range becomes half. So the recursion goes down to a depth of , and the total work is .
Answer:
Answer:
Let be an arbitrary regular language accepted by a minimal DFA with k states. Which one of the following languages must necessarily be accepted by a minimal DFA with k states?
Answer: (C)
(C) Take a minimal DFA for (complete, states) and swap its final and non-final states. It accepts and still has states. It stays minimal, because two states that some string tells apart for are told apart by the same string for the complement.
The others can change the number of states. Take , which needs 1 state.
(A) is neither empty nor all strings, so it needs at least 2 states.
(B) Take , which needs 1 state. Then needs 4 states (three for the prefixes and a dead state).
(D) Take , which needs 3 states (start, accept, dead). Then needs 4 states.
Answer: (C)
The others can change the number of states. Take , which needs 1 state.
(A) is neither empty nor all strings, so it needs at least 2 states.
(B) Take , which needs 1 state. Then needs 4 states (three for the prefixes and a dead state).
(D) Take , which needs 3 states (start, accept, dead). Then needs 4 states.
Answer: (C)
Consider the following ANSI C program.
#include <stdio.h>
int main( )
{
int arr[4][5];
int i, j;
for (i=0; i < 4; i++)
{
for (j=0; j < 5; j++)
{
arr[i][j] = 10 * i + j;
}
}
printf("%d", *(arr[1]+9));
return 0;
} What is the output of the above program?Answer: (C)
arr[1] gives the address of arr[1][0]. Adding 9 moves the pointer 9 ints forward in row-major order. The position is 5 + 9 = 14, which is row 2, column 4.
So arr[2][4] = 10 2 + 4 = 24
Answer: 24
So arr[2][4] = 10 2 + 4 = 24
Answer: 24
Consider the following sets, where :
S1: Set of all nxn matrices with entries from the set
S2: Set of all functions from the set to the set
Which of the following choice(s) is/are correct?
S1: Set of all nxn matrices with entries from the set
S2: Set of all functions from the set to the set
Which of the following choice(s) is/are correct?
One or more options are correct.
Answer: (B), (C)
Let us check each statement:
- Size of S1: (each of the entries can be chosen in 3 ways).
- Size of S2: (each of the inputs can be mapped in 3 ways).
Both sets are finite and have the same size so a bijection exists (take the matrix entries in order as the function values). A bijection is also a surjection and an injection.
Answer: A surjection exists; a bijection exists
- Size of S1: (each of the entries can be chosen in 3 ways).
- Size of S2: (each of the inputs can be mapped in 3 ways).
Both sets are finite and have the same size so a bijection exists (take the matrix entries in order as the function values). A bijection is also a surjection and an injection.
Answer: A surjection exists; a bijection exists