Question 1
Consider the following C code segment:
#include
main()
{
int i, j , x ;
scanf("%d", &x);
i = 1 ; j = 1;
while ( i< 10 ) {
j = j * i;
i = i + 1;
if (i == x) break ;
}
}
For the program fragment above, which of the following statements about the variables i and j must be true after execution of this program? [!(exclamation) sign denotes factorial in the answer]
( j = (x - 1 )! ) ? (i >= x)
( j = 9!) ? (i =10)
(( j = 10!) ? (i = 10 )) V (( j = (x - 1)!) ? (i = x ))
(( j = 9!) ? (i = 10)) V (( j = (x - 1)!) ? (i = x ))
Question 2
Consider the following declaration :
struct addr {
char city[10];
char street[30];
int pin ;
};
struct {
char name[30];
int gender;
struct addr locate;
} person , *kd = &person ;
Then *(kd -> name +2) can be used instead of
person.name +2
kd -> (name +2 )
*((*kd).name + 2 )
either (A) or (B), but not (C)
Question 3
The following C program
main()
{
fork() ; fork() ; printf ("yes");
}
If we execute this core segment, how many times the string yes will be printed ?
Only once
2 times
4 times
8 times
Question 4
_______ can detect burst error of length less than or equal to degree of the polynomial and detects burst errors that affect odd number of bits.
Hamming Code
CRC
VRC
None of the above
Question 5
Station A uses 32 byte packets to transmit messages to Station B using a sliding window protocol. The round trip delay between A and B is 80 ms and the bottleneck bandwidth on the path between A and B is 128 kbps. What is the optimal window size that A should use?
20
40
160
320
Question 6
Assume A and B are non-zero positive integers. The following code segment:
while ( A != B){
if ( A > B ) A - = B ;
else B - = A ;
}
cout << A; // printing the value of A
Computes the LCM of two numbers
Divides the larger number by the smaller number
Computes the GCD of two numbers
Finds the smaller of two numbers
Question 7
The time complexity of computing the transitive closure of binary relation on a set of n elements is known to be
O(n)
O(n log n)
O(n 3/2)
O(n 3)
Question 8
The following paradigm can be used to find the solution of the problem in minimum time: Given a set of non-negative integer, and a value K, determine if there is a subset of the given set with sum equal to K:
Divide and Conquer
Dynamic Programming
Greedy Algorithm
Branch and Bound
Question 9
Determine the number of page faults when references to pages occur in order - 1, 2, 4, 5, 2, 1, 2, 4. Assume that the main memory can accommodate 3 pages and the main memory already has the pages 1 and 2, with page 1 having brought earlier than page 2.(assume LRU algorithm is used)
3
4
5
None of these
Question 10
Processes P1 and P2 have a producer-consumer relationship, communicating by the use of a set of shared buffers.
P1: repeat
Obtain an empty buffer
Fill it
Return a full buffer
forever
P2: repeat
Obtain a full buffer
Empty it
Return an empty buffer
forever
Increasing the number of buffers is likely to do which of the following?
I. Increase the rate at which requests are satisfied (throughput)
II. Decrease the likelihood of deadlock
III. Increase the ease of achieving a correct implementation
Ill only
II only
I only
II and III only
There are 81 questions to complete.