Computer Science Engineering - Online Test

Q1. Consider the following two functions. 
void funl (int n) {                        void fun2 (int n) {
if (n = =0 ) return;                            if (n = = 0) return ;
printf (“%d” , n);                               printf (“%d” , n);
fun2 (n - 2);                                     fun1(++n) ;
printf (“%d” , n);                               printf (“%d” , n);
}                                                       }
The output printed when fun1 (5) is called is  
Answer : Option A
Explaination / Solution:

In this the fun1() is calling fun2() after printing value and after returning from fun2(),it prints the same value. In the fun2() also the same thing happens So by looking options we can judge the correct sequence of output.

Q2. In the sequential circuit shown below, if the initial value of the output Q1Q0 is 00, what are the next four values of Q1Q0

Answer : Option D
Explaination / Solution:
No Explaination.


Q3. Consider the following two sets of LR(1) items of an LR(1) grammar
X → c.X, c / d    X → c.X, $
X → .cX, c / d    X → .cX, $
X → .d, c / d      X → .d, $
Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE? 
1. Cannot be merged since look aheads are different
2. Can be merged but will result in S–R conflict
3. Can be merged but will result in R–R conflict
4. Cannot be merged since goto on c will lead to two different sets

Answer : Option D
Explaination / Solution:


1. Merging of two states depends on core part (production rule with dot operator), not on look aheads.
2. The two states are not containing Reduce item ,So after merging, the merged state can not contain any S-R conflict
3. As there is no Reduce item in any of the state, so can’t have R-R conflict.
4. Merging of stats does not depend on further goto on any terminal. So all statements are false.

Q4. Consider the transactions T1, T2, and T3 and the schedules S1 and S2 given below.
T1 : r1 (X) ; r1 (z) ; w1 (X) ; w1 (z) 
T2 : r2 (X) ; r2 (z) ; w2 (z) 
T3 : r3 (X) ; r3 (X) ; w3 (Y) 
S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z); w3(Y); w2(Z); r1(Z); w1(X); w1(Z) 
S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z); r2(Z); w3(Y); w1(X); w2(Z); w1(Z) 
Which one of the following statements about the schedules is TRUE?
Answer : Option A
Explaination / Solution:

Precedence graph for S1 & S2 are as follows 

∴Only S1 is conflict serializable.

Q5. Identify the correct order in which a server process must invoke the function calls accept, bind, listen, and recv according to UNIX socket APL
Answer : Option B
Explaination / Solution:

The correct order in which a server process must invoke the function calls is bind, listen, accept and recv. First three are used in connection establishment phase and recv is used in data transfer phase.

Q6. Consider a carry look ahead adder for adding two n-bit integers, built using gates of fan-in at most two. The time to perform addition using this adder is
Answer : Option B
Explaination / Solution:
No Explaination.


Q7. Consider that B wants to send a message m that is digitally signed to A. Let the pair of private and public keys for A and B be denoted by  for x = A, B, respectively. Let Kx(m) represent the operation of encrypting m with a key Kx and H (m) represent the message digest. Which one of the following indicates the CORRECT way of sending the message m along with the digital signature to A?
Answer : Option B
Explaination / Solution:



Q8. Consider an instance of TCP’s Additive Increase Multiplicative decrease (AIMD) algorithm where the window size at the start of the slow start phase is 2 MSS and the threshold at the start of the first transmission is 8 MSS. Assume that a timeout occurs during the fifth transmission. Find the congestion window size at the end of the tenth transmission.
Answer : Option C
Explaination / Solution:


Given, initial threshold = 8
Time = 1, during 1st transmission,Congestion window size = 2 (slow start phase)
Time = 2, congestion window size = 4 (double the no. of acknowledgments)
Time = 3, congestion window size = 8 (Threshold meet)
Time = 4, congestion window size = 9, after threshold (increase by one Additive increase)
Time = 5, transmits 10 MSS, but time out occurs congestion window size = 10
Hence threshold = (Congestion window size)/2 = 10/2 = 5 
Time = 6, transmits 2
Time = 7, transmits 4
Time = 8, transmits 5 (threshold is 5)
Time = 9, transmits 6, after threshold (increase by one Additive increase)
Time = 10, transmits 7
∴ During 10th transmission, it transmits 7 segments hence at the end of the tenth transmission the size of congestion window is 7 MSS.

Q9. What is the value printed by the following C program?
#include <stdio.h> 
int f(int * a, int n)
{
if (n <= 0)return 0;
else if(*a % 2 == 0) return * a + f(a + 1,n - 1);
else return * a - f(a + 1, n - 1);
}
int main ( )
{
int a[ ] = {12, 7, 13, 4, 11, 6};
print f ("%d", f(a, 6));
return 0;
}
Answer : Option A
Explaination / Solution:
No Explaination.


Q10.  Consider the DFA given below.

Which of the following are FALSE? 
1. Complement of L(A) is context–free
2. L(A) = L ((11*0+0)(0+1)*0*1*)
3. For the language accepted by A, A is the minimal DFA
4. A accepts all strings over {0, 1} of length at least 2 
Answer : Option D
Explaination / Solution:


(1) L(A) is regular, its complement is also regular and if it is regular it is also context free.
(2) L(A) = (11*0+0)(0+1)*0*1* = 1*0(0+1)* Language has all strings where each string contains ‘0’.
(3) A is not minimal, it can be constructed with 2 states
(4) Language has all strings, where each string contains ‘0’. (atleast length one)