GATE 2019
65 questions
MCQ 41 · NAT 241-mark 30 · 2-mark 35
Questions 26–30 of 65
Which of the following protocol pairs can be used to send and retrieve e-mails (in that order)?
Answer: (B)
SMTP is the protocol that sends (pushes) mail. To get mail from the mailbox, POP3 (or IMAP) is used. MIME is just a format for attachments.
Answer: SMTP, POP3
Answer: SMTP, POP3
The following C program is executed on a Unix / Linux system:
#include <unistd.h>
int main() {
int i;
for (i = 0; i < 10; i++)
if (i % 2 == 0) fork();
return 0;
} The total number of child process created is __________ .Answer: 31
fork() runs only when i is even, that is for i = 0, 2, 4, 6, 8 so 5 times. Each time, every process that exists at that point forks.
Total processes . One of them is the original process, so the number of children .
Answer: 31
Total processes . One of them is the original process, so the number of children .
Answer: 31
Consider the following C program:
#include <stdio.h>
int jumble(int x, int y) {
x = 2 * x + y;
return x;
}
int main() {
int x = 2, y = 5;
y = jumble(y, x);
x = jumble(y, x);
printf("%d\n", x);
return 0;
} The value printed by program is __________ .Answer: 26
The function jumble(x, y) gives back 2x + y.
- First call, y = jumble(5, 2) = 25 + 2 = 12
- Second call, x = jumble(12, 2) = 212 + 2 = 26
Answer: 26
- First call, y = jumble(5, 2) = 25 + 2 = 12
- Second call, x = jumble(12, 2) = 212 + 2 = 26
Answer: 26
Consider the following given grammar:
Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210).
Answer:_____
S -> Aa
A -> BD
B -> b| ε
D -> d| ε Let a, b, d and $ be indexed as follows: Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, $}, then the answer should be 3210).
Answer:_____
Answer: 31
We have A BD, so D comes right after B. This means FOLLOW(B) gets FIRST(D) {} = {d}.
D can also become , so FOLLOW(B) gets FOLLOW(A) = {a} as well (from S Aa).
FOLLOW(B) = {a, d}. The indices are a = 3 and d = 1 written in descending order, this gives 31.
Answer: 31
D can also become , so FOLLOW(B) gets FOLLOW(A) = {a} as well (from S Aa).
FOLLOW(B) = {a, d}. The indices are a = 3 and d = 1 written in descending order, this gives 31.
Answer: 31
An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) is _________.
Answer: 0.08
The pivot lands in the worst place when it ends up at either end of the array. This happens when the pivot is the smallest or the largest element. So there are 2 favourable choices out of 25.
Answer: 0.08
Answer: 0.08