Computer Science Engineering - Online Test

Q1. Which of the given options provides the increasing order of asymptotic complexityoffunctions f1,f2,fand f4?

Answer : Option A
Explaination / Solution:



Q2. Consider the languages L1, L2 and L3 as given below

Which of the following statements is NOT TRUE? 
Answer : Option C
Explaination / Solution:

L1: regular language L2: context free language L3: context sensitive language

Q3. Which of the following is TRUE?
Answer : Option C
Explaination / Solution:

Option A is false since BCNF is stricter than 3NF (it needs LHS of all FDs should be candidate key for 3NF condition) Option B is false since the definition given here is of 2NF Option C is true, since for a relation to be in BCNF it needs to be in 3NF, every relation in BCNF satisfies all the properties of 3NF. Option D is false, since if a relation is in BCNF it will always be in 3NF.

Q4. What is the minimal form of the Karnaugh map shown below? Assume that X denotes a don’t care term.


Answer : Option B
Explaination / Solution:



Q5. Consider the following C code segment: 
int a, b, c = 0; 
void prtFun(void); 
main( )
{ static int a = 1;            /* Line 1 */
 prtFun( );
a + = 1;
 prtFun( )
printf(“\n %d %d “, a, b);
}
void prtFun(void)
{ static int a=2;               /* Line 2 */
int b=1;
a+=++b;
printf(“\n %d %d “, a, b);
What output will be generated by the given code segment?
Answer : Option C
Explaination / Solution:



Q6. In a k-way set associative cache, the cache is divided into v sets, each of which consists of k lines. The lines of a set are placed in sequence one after another. The lines in set s are sequenced before the lines in set (s+1). The main memory blocks are numbered 0 onwards. The main memory block numbered j must be mapped to any one of the cache lines from
Answer : Option A
Explaination / Solution:

Position of main memory block in the cache (set) = (main memory block number) MOD (number of sets in the cache). As the lines in the set are placed in sequence, we can have the lines from 0 to (K – 1) in each set. Number of sets = v, main memory block number = j First line of cache = (j mod v)*k; last line of cache = (j mod v)*k + (k – 1)

Q7. In an IPv4 datagram, the M bit is 0, the value of HLEN is 10, the value of total length is 400 and the fragment offset value is 300. The position of the datagram, the sequence numbers of the first and the last bytes of the payload, respectively are
Answer : Option C
Explaination / Solution:

M= 0 – Means there is no fragment after this, i.e. Last fragment
HLEN=10 - So header length is 4×10=40, as 4 is constant scale factor 
Total Length = 400(40 Byte Header + 360 Byte Payload)
Fragment Offset = 300, that means 300×8 Byte = 2400 bytes are before this last fragment 
So the position of datagram is last fragment 
Sequence number of First Byte of Payload = 2400 (as 0 to 2399 Sequence no are used) 
Sequence number of Last Byte of Payload = 2400+360-1=2759

Q8.
The following is comment written for a C function
/* This function computes the roots of a quadratic equation
a.x^2+b.x+c=0. The function stores two real roots
in *root1 and *root2 and returns the status of validity of
roots. It handles four different kinds of cases.
(i) When coefficient a is zero irrespective of discriminant
(ii) When discriminant is positive
(iii) When discrimanant is zero
(iv) When discrimanant is negative
Only in cases (ii) and (iii), the stored roots are valid.
Otherwise 0 is stored in the roots. the function returns 0 when 
the roots are valid and -1 otherwise. 
The functin also ensures root1>=root2.
int get_QuadRoots (float a, float b, float c, float *root1, float *root2) ; 
*/
A software test engineer is assigned the job of doing black box testing. He comes up with the following test cases, many of which are redundant. 

Which one of the following options provide the set of non-redundant tests using equivalence class partitioning approach from input perspective for black box testing? 
Answer : Option C
Explaination / Solution:

T1 and T2 checking same condition a = 0 hence, any one of T1 and T2 is redundant.
T3T4: in both case discriminant (D)= b2 − 4ac = 0 . Hence any one of it is redundant.
T5 : D>0 
T6 : D<0 

Q9. Which one of the following options is CORRECT given three positive integers x, y and z, and a predicate P (x) = ¬ (x = 1) ∧ ∀y (∃z (x = y * z) ⇒ (y = x) ∨ (y = 1))
Answer : Option A
Explaination / Solution:
No Explaination.


Q10. Consider the following table of arrival time and burst time for three processes P0, P1 and P2. 
Process   Arrival time       Burst Time 
  P0             0 ms                 9 ms 
  P1             1 ms                 4ms 
  P2             2 ms                 9ms 
The pre-emptive shortest job first scheduling algorithm is used. Scheduling is carried out only at arrival or completion of processes. What is the average waiting time for the three processes?
Answer : Option A
Explaination / Solution:


Average waiting time = (4+11)/3 = 5 ms