GATE 2015 (Session 3)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 56–60 of 65
Two hosts are connected via a packet switch with bits per second links. Each link has a propagation delay of 20 microseconds. The switch begins forwarding a packet 35 microseconds after it receives the same. If 10000 bits of data are to be transmitted between the two hosts using a packet size of 5000 bits, the time elapsed between the transmission of the first bit of data and the reception of the last bit of the data in microseconds is____________.
Answer: 1575
For each packet, transmission time is , propagation delay is 20 , and switch delay is 35 .
- Packet 1: sent from 0 to 500, reaches switch at 520, forwarded from 555 to 1055, received at 1075
- Packet 2: sent from 500 to 1000, reaches switch at 1020, forwarded from 1055 to 1555, received at 1575
Answer: 1575
- Packet 1: sent from 0 to 500, reaches switch at 520, forwarded from 555 to 1055, received at 1075
- Packet 2: sent from 500 to 1000, reaches switch at 1020, forwarded from 1055 to 1555, received at 1575
Answer: 1575
For the processes listed in the following table, which of the following scheduling schemes will give the lowest average turnaround time?
Answer: (C)
Turnaround time = completion time arrival time. Arrivals of A, B, C, D are 0, 1, 4, 6 and processing times are 3, 6, 4, 2.
- FCFS: A runs 0-3, B 3-9, C 9-13, D 13-15 (3 + 8 + 9 + 9)/4 = 7.25
- Non-preemptive SJF: A runs 0-3. At 3 only B is waiting, so B runs 3-9. At 9, D (2) is shorter than C (4), so the order is A, B, D, C, completing at 3, 9, 11, 15 (3 + 8 + 5 + 11)/4 = 6.75
- SRT: A runs 0-3 and B 3-4. At 4, C (4) arrives and is shorter than B's remaining 5, so C preempts B and runs 4-8. At 6, D (2) arrives, but C also has 2 left, so C keeps running. Then D runs 8-10 and B 10-15 (3 + 14 + 4 + 4)/4 = 6.25
- RR (q = 2): A 0-2, B 2-4, A 4-5, C 5-7, B 7-9, D 9-11, C 11-13, B 13-15. Here a process that arrives just as a quantum ends is queued before the preempted one. Turnaround times are A 5, B 14, C 9, D 5 (5 + 14 + 9 + 5)/4 = 8.25
SRT has the lowest average (6.25), because it always runs the process with the least work left, so short processes do not wait behind long ones.
Answer: (C)
- FCFS: A runs 0-3, B 3-9, C 9-13, D 13-15 (3 + 8 + 9 + 9)/4 = 7.25
- Non-preemptive SJF: A runs 0-3. At 3 only B is waiting, so B runs 3-9. At 9, D (2) is shorter than C (4), so the order is A, B, D, C, completing at 3, 9, 11, 15 (3 + 8 + 5 + 11)/4 = 6.75
- SRT: A runs 0-3 and B 3-4. At 4, C (4) arrives and is shorter than B's remaining 5, so C preempts B and runs 4-8. At 6, D (2) arrives, but C also has 2 left, so C keeps running. Then D runs 8-10 and B 10-15 (3 + 14 + 4 + 4)/4 = 6.25
- RR (q = 2): A 0-2, B 2-4, A 4-5, C 5-7, B 7-9, D 9-11, C 11-13, B 13-15. Here a process that arrives just as a quantum ends is queued before the preempted one. Turnaround times are A 5, B 14, C 9, D 5 (5 + 14 + 9 + 5)/4 = 8.25
SRT has the lowest average (6.25), because it always runs the process with the least work left, so short processes do not wait behind long ones.
Answer: (C)
Consider three software items: Program-, Control Flow Diagram of Program- and Control Flow Diagram of Program- as shown below
Program-:

Control Flow Diagram of Program-:

The values of McCabe’s Cyclomatic complexity of Program-, Program-, and Program- respectively are
Program-:
sumcal(int maxint, int value)
{
int result=0, i=0;
if (value <0)
{
value = -value;
}
while((i<value) AND (result <= maxint))
{
i=i+1;
result = result + 1;
}
if(result <= maxint)
{
printf(result);
}
else
{
printf("large");
}
printf("end of program");
}Control Flow Diagram of Program-:
Control Flow Diagram of Program-:

The values of McCabe’s Cyclomatic complexity of Program-, Program-, and Program- respectively are
Answer: (A)
McCabe's cyclomatic complexity of a connected flow graph with E edges and N nodes is . For structured code it equals the number of decisions + 1.
Program-X: the decisions are if (value < 0), the while test and if (result <= maxint). The while condition is one test node in the flow graph. So .
Program-Y: the graph has N = 8 nodes. It has 7 edges down the chain and 3 back edges, so E = 10, and .
Program-Z: the graph of X followed by the graph of Y, joined by one extra edge. So and :
Answer: (A)
Program-X: the decisions are if (value < 0), the while test and if (result <= maxint). The while condition is one test node in the flow graph. So .
Program-Y: the graph has N = 8 nodes. It has 7 edges down the chain and 3 back edges, so E = 10, and .
Program-Z: the graph of X followed by the graph of Y, joined by one extra edge. So and :
Answer: (A)
Consider the equation where x and y are unknown. The number of possible solutions is ______________
Answer: 5
and . Equating them gives , so .
The digit is used in base , so . That means , so (for , is not allowed). Also must be a valid octal digit, so .
So , which gives . That is 5 solutions.
Answer: 5
The digit is used in base , so . That means , so (for , is not allowed). Also must be a valid octal digit, so .
So , which gives . That is 5 solutions.
Answer: 5
Let R be a relation on the set of ordered pairs of positive integers such that if and only if . Which one of the following is true about R?
Answer: (C)
The condition can be written as .
Reflexive: for the condition is , so . For it gives . So and R is not reflexive.
Symmetric: if then . The condition for is , which is the same equation. So R is symmetric.
Answer: (C)
Reflexive: for the condition is , so . For it gives . So and R is not reflexive.
Symmetric: if then . The condition for is , which is the same equation. So R is symmetric.
Answer: (C)