GATECS2006
Question 1 
3  
4  
6  
9 
Discuss it
p = a3 X x  (1) q = (a2 + p) X x (2) r = (a1 + q) X x (3) result = a0 + rReference : http://www.geeksforgeeks.org/hornersmethodpolynomialevaluation/ This solution is contributed by Nitika Bansal.
Question 2 
z^{2xy}  
z x 2 ^{xy}  
z^{2x + y}  
2^{xyz} 
Discuss it
So number of functions from Z to E =
Question 3 
It is not closed  
2 does not have an inverse  
3 does not have an inverse  
8 does not have an inverse 
Discuss it
Question 4 
Neither a Partial Order nor an Equivalence Relation  
A Partial Order but not a Total Order  
A Total Order  
An Equivalence Relation 
Discuss it
Solution:
An equivalence relation on a set x is a subset of x*x, i.e., a collection R of ordered pairs of elements of x, satisfying certain properties. Write “x R y" to mean (x,y) is an element of R, and we say "x is related to y," then the properties are 1. Reflexive: a R a for all a Є R, 2. Symmetric: a R b implies that b R a for all a,b Є R 3. Transitive: a R b and b R c imply a R c for all a,b,c Є R.
An partial order relation on a set x is a subset of x*x, i.e., a collection R of ordered pairs of elements of x, satisfying certain properties. Write “x R y" to mean (x,y) is an element of R, and we say "x is related to y," then the properties are
1. Reflexive: a R a for all a Є R, 2. AntiSymmetric: a R b and b R a implies that for all a,b Є R 3. Transitive: a R b and b R c imply a R c for all a,b,c Є R.
An total order relation a set x is a subset of x*x, i.e., a collection R of ordered pairs of elements of x, satisfying certain properties. Write “x R y" to mean (x,y) is an element of R, and we say "x is related to y," then the properties are
1. Reflexive: a R a for all a Є R, 2. Symmetric: a R b implies that b R a for all a,b Є R 3. Transitive: a R b and b R c imply a R c for all a,b,c Є R. 4. Comparability : either a R b or b R a for all a,b Є R.
As given in question, a relation R is defined on ordered pairs of integers as follows: (x,y) R(u,v) if x < u and y > v , reflexive property is not satisfied here , because there is > or < relationship between (x ,y) pair set and (u,v) pair set . Other way , if there would have been x <= u and y>= v (or x=u and y=v) kind of relation amongs elements of sets then reflexive property could have been satisfied. Since reflexive property in not satisfied here , so given realtion can not be equivalence ,partial order or total order relation.So ,Answer (A) is true .
This solution is contributed by Nirmal Bharadwaj.
Question 5 
Ensure packets reach destination within that time  
Discard packets that reach later than that time  
Prevent packets from looping indefinitely  
Limit the time for which a packet gets queued in intermediate routers. 
Discuss it
Question 6 
1  
2  
3  
4 
Discuss it
Question 7 
S > S * E S > E E > F + E E > F F > idConsider the following LR(0) items corresponding to the grammar above.
(i) S > S * .E (ii) E > F. + E (iii) E > F + .EGiven the items above, which two of them will appear in the same set in the canonical setsofitems for the grammar?
(i) and (ii)  
(ii) and (iii)  
(i) and (iii)  
None of the above 
Discuss it
Question 8 
A  
B  
C  
D 
Discuss it
In option (A), during the negative edge of the clock, first flipflop inverts complement of ‘f’. But, the output of first flipflop has the same phase as ‘f’. Now, we give this output as input to the second flipflop, which is enabled by ‘clk’. Thus, we get a double inverted output having same phase as the input. So, A is not the correct option.
In option (B) and (D), the output is inverted ‘f’. But, we want ‘f’ as the output. So, (B) and (D) can’t be the answer.
In option (C), the first flipflop is activated by ‘clk’. So, the output of first flipflop has the same phase as ‘f’. But, the second flipflop is enabled by complement of ‘clk’. Since the clock ‘clk’ has a duty cycle of 50% , we get the output having phase delay of 180 degrees.
Therefore, (C) is the correct answer.
Please comment below if you find anything wrong in the above post.
Question 9 
400  
500  
600  
700 
Discuss it
Here, size of instruction = 24/8 = 3 bytes. Program Counter can shift 3 bytes at a time to jump to next instruction. So the given options must be divisible by 3. only 600 is satisfied.
Question 10 
O(n)  
O(Logn)  
O(LogLogn)  
O(1) 
Discuss it
Question 11 
n — 1  
2n — 2  
nC2  
2 
Discuss it
Question 12 
Queue  
Stack  
Heap  
BTree 
Discuss it
Question 13 
log2n  
n  
2n + 1  
2^n — 1 
Discuss it
Question 14 
Quick sort  
Insertion sort  
Selection sort  
Heap sort 
Discuss it
Question 15 
for (i = n, j = 0; i >0; i /= 2, j += i);Let val(j) denote the value stored in the variable j after termination of the for loop. Which one of the following is true? (A) val(j) = (logn) (B) vaI(j) = (sqrt(n)) (C) val(j) = (n) (D) val(j) = (nlogn)
A  
B  
C  
D 
Discuss it
Question 16 
R is NPcomplete  
R is NPhard  
Q is NPcomplete  
Q is NPhard 
Discuss it
Question 17 
Solves it in linear time using a left to right pass of the array  
Solves it in linear time using a right to left pass of the array  
Solves it using divide and conquer in time Theta(nlogn)  
Solves it in time Theta(n^2) 
Discuss it
Question 18 
1/n  
2  
sqrt(n)  
n 
Discuss it
Question 19 
L1 only  
L3 Only  
L1 and L2  
L2 and L3 
Discuss it
Question 20 
1. T1 start 2. T1 B old=12000 new=10000 3. T1 M old=0 new=2000 4. T1 commit 5. T2 start 6. T2 B old=10000 new=10500 7. T2 commitSuppose the database system cra shes just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure?
We must redo log record 6 to set B to 10500  
We must undo log record 6 to set B to 10000 and then redo log records 2 and 3.  
We need not redo log records 2 and 3 because transaction T1 has committed.  
We can apply redo and undo operations in arbitrary order because they are idempotent 
Discuss it
Question 21 
(2nCn) / (4^n)
 
(2nCn) / (2^n)  
1 / (2nCn)  
1/2 
Discuss it
Question 22 
X ⊂ Y  
X ⊃ Y  
X = Y  
X  Y ≠ φ and Y  X ≠ φ 
Discuss it
Question 23 
Determinant of F is zero.  
There are an infinite number of solutions to Fx = b  
There is an x≠0 such that Fx = 0  
F must have two identical rows 
Discuss it
Question 24 
(n  A ∪ B) A B  
(A^{2}+B^{2})n^{2}  
n! A∩B / A∪B  
A∩B^{2}nCA∪B 
Discuss it
Question 25 
3m  
3n  
2m + 1  
2n + 1 
Discuss it
Question 26 
Tigers and lions attack if they are hungry or threatened.
A  
B  
C  
D 
Discuss it
Question 27 
P1 is a tautology, but not P2  
P2 is a tautology, but not P1  
P1 and P2 are both tautologies  
Both P1 and P2 are not tautologies 
Discuss it
A  B  C  ((A ∧ B) → C))  ((A → C) ∧ (B → C))  ((A ∨ B) → C))  ((A → C) ∨ (B → C)) 

0  0  0  T  T  T  T 
0  0  1  T  T  T  T 
0  1  0  T  F  F  T 
0  1  1  T  T  T  T 
1  0  0  T  F  F  T 
1  0  1  T  T  T  T 
1  1  0  F  F  F  F 
1  1  1  T  T  T  T 
Question 28 
(A) (~A □ B) (B) ~(A □ ~B) (C) ~(~A □ ~B) (D) ~(~A □ B)
A  
B  
C  
D 
Discuss it
Question 29 
A  
B  
C  
D 
Discuss it
Question 30 
L is recursively enumerable, but not recursive  
L is recursive, but not contextfree  
L is contextfree, but not regular  
L is regular 
Discuss it
Question 31 
Both DHAM_{3} and SHAM_{3} are NPhard  
SHAM_{3} is NPhard, but DHAM_{3} is not  
DHAM_{3} is NPhard, but SHAM_{3} is not  
Neither DHAM_{3} nor SHAM_{3} is NPhard 
Discuss it
Question 32 
G = {S → SS, S → ab, S → ba, S → Ε} I. G is ambiguous II. G produces all strings with equal number of a’s and b’s III. G can be accepted by a deterministic PDA.Which combination below expresses all the true statements about G?
I only  
I and III only  
II and III only  
I, II and III 
Discuss it
Question 33 
L1 ∩ L2 is a deterministic CFL  
L3 ∩ L1 is recursive  
L1 ∪ L2 is context free  
L1 ∩ L2 ∩ L3 is recursively enumerable 
Discuss it
(A) This statement is true because deterministic context free languages are closed under intersection with regular languages.
(B) This statement is false because L1 is recursive and every recursive language is decidable. L3 is recursively enumerable but not recursive. So, L3 is undecidable. Intersection of recursive language and recursive enumerable language is recursively enumerable .
(C) This statement is true because L1 is regular. Every regular language is also a context free languages. L2 is a deterministic context free language and every DCFL is also a context free languages. Every context free language is closed under Union.
(D) This statement is true beacuse L1 is regular hence it is also recursively enumerable. L2 is deterministic context free language so, it is also recursively enumerable . Recursively enumerable languages are closed under intersection.
Thus, problem mentioned in option (A) is undecidable.
Please comment below if you find anything wrong in the above post.
Question 34 
3  
5  
8  
9 
Discuss it
Question 35 
xz' + xy + y'z  
xz' + xy + (yz)'  
xz + xy + (yz)'  
xz + xy' + y'z 
Discuss it
Question 36 
A  
B  
C  
D 
Discuss it
Question 37 
000  
001  
010  
101 
Discuss it
The D flipflops are initialized to zeroes. This implies q0 = 0, q1 = 0 and q2 = 0 initially.
Clock cycle 1 : q0 = data = 1 , q1 = q0_{before} XOR q2_{before} = 0 XOR 0 = 0 , q2 = q1_{before} = 0
Clock cycle 2 : q0 = data = 0 , q1 = q0_{before} XOR q2_{before} = 1 XOR 0 = 1 , q2 = q1_{before} = 0
Clock cycle 3 : q0 = data = 0 , q1 = q0_{before} XOR q2_{before} = 0 XOR 0 = 0 , q2 = q1_{before} = 1
Clock cycle 4 : q0 = data = 1 , q1 = q0_{before} XOR q2_{before} = 0 XOR 1 = 1 , q2 = q1_{before} = 0
Clock cycle 5 : q0 = data = 1 , q1 = q0_{before} XOR q2_{before} = 1 XOR 0 = 1 , q2 = q1_{before} = 1
Clock cycle 6 : q0 = data = 0 , q1 = q0_{before} XOR q2_{before} = 1 XOR 1 = 0 , q2 = q1_{before} = 1
Clock cycle 7 : q0 = data = 0 , q1 = q0_{before} XOR q2_{before} = 0 XOR 1 = 1 , q2 = q1_{before} = 0
Clock cycle 8 : q0 = data = 0 , q1 = q0_{before} XOR q2_{before} = 0 XOR 0 = 0 , q2 = q1_{before} = 1
Clock cycle 9 : q0 = data = 0 , q1 = q0_{before} XOR q2_{before} = 0 XOR 1 = 1 , q2 = q1_{before} = 0
Thus, option (C) is correct.
Please comment below if you find anything wrong in the above post.
Question 38 
w'xz, wxy', xy'z, xyz,wyz  
wxy,w'xz,wyz  
wx(yz)', xz, wx'yz  
wzy, wyz, wxz, w'xz, xy'z, xyz 
Discuss it
Question 39 
A  
B  
C  
D 
Discuss it
 both operands are positive and the result is negative, or
 both operands are negative and the result is positive.

Question 40 
A  
B  
C  
D 
Discuss it
Question 41 
92 ns  
104 ns  
172 ns  
184 ns 
Discuss it
Question 42 
1.0 second  
1.2 seconds  
1.4 seconds  
1.6 seconds 
Discuss it
Total number of instructions = 10^{9}
20% out of 10^{9} are conditional branches.
Therefore, Cycle penalty = 0.2 * 2 * 10^{9} = 4 * 10^{9}
Clock speed is 1 GHz and each instruction on average takes 1 cycle.
Total execution time = (10^{9} / 10^{9}) + 4 * (10^{8} / 10^{9}) = 1.4 seconds
Thus, total execution time of the program is 1.4 seconds.
Please comment below if you find anything wrong in the above post.
Question 43 
mask ← 0 x 1 ο pos  
mask ← 0 x ffffffff ο pos  
mask ← pos  
mask ← 0 × f 
Discuss it
Question 44 
20  
40  
160  
320 
Discuss it
Round Trip propagation delay = 80ms Frame size = 32*8 bits Bandwidth = 128kbps Transmission Time = 32*8/(128) ms = 2 ms Let n be the window size. UtiliZation = n/(1+2a) where a = Propagation time / transmission time = n/(1+80/2) For maximum utilization: n = 41 which is close to option (B)Source : Question 1 of http://www.geeksforgeeks.org/computernetworksset11/
Question 45 
C1 and C2 both assume they are on the same network  
C2 assumes C1 is on same network, but C1 assumes C2 is on a different network  
C1 assumes C2 is on same network, but C2 assumes C1 is on a different network  
C1 and C2 both assume they are on different networks. 
Discuss it
Question 46 
12  
14  
16  
18 
Discuss it
Question 47 
(a—b),(d—f),(b—f),(d—c),(d—e)  
(a—b),(d—f),(d—c),(b—f),(d—e)  
(d—f),(a—b),(d—c),(b—f),(d—e)  
(d—f),(a—b),(b—f),(d—e),(d—c) 
Discuss it
Question 48 
There must exist a vertex w adjacent to both u and n in G  
There must exist a vertex w whose removal disconnects u and n in G  
There must exist a cycle in G containing u and n  
There must exist a cycle in G containing u and all its neighbours in G. 
Discuss it
Question 49 
void insert(Q, x) { push (S1, x); } void delete(Q){ if(stackempty(S2)) then if(stackempty(S1)) then { print(“Q is empty”); return; } else while (!(stackempty(S1))){ x=pop(S1); push(S2,x); } x=pop(S2); }Let n insert and m (<=n) delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n?
n+m <= x < 2n and 2m <= y <= n+m  
n+m <= x < 2n and 2m<= y <= 2n  
2m <= x < 2n and 2m <= y <= n+m  
2m <= x <2n and 2m <= y <= 2n 
Discuss it
Question 50 
Consider the following algorithm in which x,y and z are Boolean arrays of size n:
algorithm zzz(x[] , y[], z []) { int i; for (i=O; i<n; ++i) z[i] = (x[i] ^ ~y[i]) V (~x[i] ^ y[i]) }The set Z computed by the algorithm is:
(X ∩ Y)  
(X ∪ Y)  
(XY) ∩ (YX)  
(XY) ∪ (YX) 
Discuss it
Question 51 
A  
B  
C  
D 
Discuss it
Question 52 
O(n^2 Logn)  
O(n^2)  
O(n Logn Logn)  
O(nLogn) 
Discuss it
Question 53 
void xyz(int a[], int b [], int c[]) { int i, j, k; i = j = k = O; while ((i<n) && (j<m)) if (a[i] < b[j]) c[k++] = a[i++]; else c[k++] = b[j++]; }Which of the following condition(s) hold(s) after the termination of the while loop? (GATE CS 2006) (i) j < m, k = n+j1, and a[n1] < b[j] if i = n (ii) i < n, k = m+i1, and b[m1] <= a[i] if j = m
only (i)  
only (ii)  
either (i) or (ii) but not both  
neither (i) nor (ii) 
Discuss it
Question 54 
Takes O(n^{3}) and Ω(2^{n}) time if hashing is permitted  
Takes O(n^{3}) and Ω(n^{2.5}) time in the key comparison model  
Takes θ(n) time and space  
Takes O(√n) time only if the sum of the 2n elements is an even number 
Discuss it
 Since there are total n elements, maximum sum is n for both arrays.
 Difference between two sums varies from n to n. So there are total 2n + 1 possible values of difference.
 If differences between prefix sums of two arrays become same at two points, then subarrays between these two points have same sum.
 Create an auxiliary array of size 2n+1 to store starting points of all possible values of differences (Note that possible values of differences vary from n to n, i.e., there are total 2n+1 possible values)
 Initialize starting points of all differences as 1.
 Initialize maxLen as 0 and prefix sums of both arrays as 0, preSum1 = 0, preSum2 = 0
 Travers both arrays from i = 0 to n1.
 Update prefix sums: preSum1 += arr1[i], preSum2 += arr2[i]
 Compute difference of current prefix sums: curr_diff = preSum1 – preSum2
 Find index in diff array: diffIndex = n + curr_diff // curr_diff can be negative and can go till n
 If curr_diff is 0, then i+1 is maxLen so far
 Else If curr_diff is seen first time, i.e., starting point of current diff is 1, then update starting point as i
 Else (curr_diff is NOT seen first time), then consider i as ending point and find length of current same sum span. If this length is more, then update maxLen
 Return maxLen
Question 55 
int work1(int *a, int i, int j) { int x = a[i+2]; a[j] = x+1; return a[i+2] – 3; } int work2(int *a, int i, int j) { int t1 = i+2; int t2 = a[t1]; a[j] = t2+1; return t2 – 3; }S1: The transformation form work1 to work2 is valid, i.e., for any program state and input arguments, work2 will compute the same output and have the same effect on program state as work1 S2: All the transformations applied to work1 to get work2 will always improve the performance (i.e reduce CPU time) of work2 compared to work1
S1 is false and S2 is false
 
S1 is false and S2 is true  
S1 is true and S2 is false  
S1 is true and S2 is true 
Discuss it
Question 56 
subroutine swap(ix,iy) it = ix L1 : ix = iy L2 : iy = it end ia = 3 ib = 8 call swap (ia, 1b+5) print *, ia, ib endS1: The compiler will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the cell swap S2: On execution the code will generate a runtime error on line L1 S3: On execution the code will generate a runtime error on line L2 S4: The program will print 13 and 8 S5: The program will print 13 and 2 Exactly the following set of statement(s) is correct:
S1 and S2  
S1 and S4  
S3  
S1 and S5 
Discuss it
 to bound cells to its subroutines, if they are already present
 to unnamed temporary cells later to be bound, if they are not there
(S1) Because the second argument is an expression, which could be evaluated easily by compiler SDT rules to a value 13, compiler itself will generate code to define and declare an unnamed temporary cell with value 13 and pass it to swap subroutine. [CORRECT] (S2) 'ix' and 'iy' are variables bound to valid mutable cells, thus there is no reason to get a run time error on line L1. [INCORRECT] (S3) Incorrect due to same reason as of S2 [INCORRECT] (S4) Due to the passbyreference nature of the language, the cell bound to variable 'ia' will get value 13 and the temporary unnamed cell which was allocated and passed to the swap subroutine will get value 3. Seemingly, cell bound to variable 'ib' is unchanged, thus printing 13 and 8 at the end of this routine. [CORRECT] (S5) Incorrect due to same reason as of S4 [INCORRECT]Hence, answer should be (B) S1 and S4 This explanation has been contributed by Vineet Purswani.
Question 57 
void swap(int *px, int *py) { *px = *px  *py; *py = *px + *py; *px = *py  *px; }S1: will generate a compilation error S2: may generate a segmentation fault at runtime depending on the arguments passed S3: correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the process S4: implements the swap procedure correctly for some but not all valid input pointers S5: may add or subtract integers and pointers.
S1  
S2 and S3  
S2 and S4  
S2 and S5 
Discuss it
Question 58 
S → FR R → S  ε F → idIn the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $] respectively.
{S → FR} and {R → ε }  
{S → FR} and { }  
{S → FR} and {R → *S}  
{F → id} and {R → ε} 
Discuss it
Question 59 
2 * 3 + 4  
2 * +3 4  
2 3 * 4 +  
2 3 4+* 
Discuss it
Explanation : We are given LAttributed Syntax Directed Translation as semantic actions like printf statements are inserted anywhere on the RHS of production (R → *E{print(“*”);}R). After constructing the parse tree as shown below from the given grammar, we will follow depth first order left to right evaluation in order to generate the final output.Parse Tree:
Just follow the arrows in the picture (This is actually Depth first left to right evaluation ) and the moment we take exit from any child which is printf statement in this question, we print that symbol which can be a integer value or ‘*’ or ‘+’.Evaluation : This explanation has been contributed by Pranjul Ahuja.
Question 60 
for (i = 0, i<n; i++) { for (j=0; j<n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } } }Which one of the following is false?
The code contains loop invariant computation  
There is scope of common subexpression elimination in this code  
There is scope of strength reduction in this code  
There is scope of dead code elimination in this code 
Discuss it
4*j is common subexpression elimination so B is true. 5*i can be moved out of inner loop so can be i%2. Means, A is true as we have loop invariant computation. Next, 4*j as well as 5*i can be replaced with a =  4; before j loop then a = a + 4; where 4*j is computed, likewise for 5*i. C is true as there is scope of strength reduction. By choice elimination, we have D.
Question 61 
void P (binary_semaphore *s) { unsigned y; unsigned *x = &(s>value); do { fetchandset x, y; } while (y); } void V (binary_semaphore *s) { S>value = 0; }Which one of the following is true?
The implementation may not work if context switching is disabled in P  
Instead of using fetchand –set, a pair of normal load/store can be used  
The implementation of V is wrong  
The code does not implement a binary semaphore 
Discuss it
Question 62 
11 bits  
13 bits  
15 bits  
20 bits 
Discuss it
Question 63 
Efficient implementation of multiuser support is no longer possible  
The processor cache organization can be made more efficient now  
Hardware support for memory management is no longer needed  
CPU scheduling can be made more efficient now 
Discuss it
Question 64 
13 units  
14 units  
15 units  
16 units 
Discuss it
p2 p1 p2 p1 p2 p0 p1 p2 p0 p1 p2 0 4 5 6 7 8 9 10 11 12 13 14First 4 sec, p2 will run, then remaining time p2=4, p1=4, p0=2. Now P1 will get chance to run for 1 sec, then remaining time. p2=4,p1=3,p0=2. Now p2 will get chance to run for 1 sec, then remaining time. p2=3,p1=3,p0=2. By doing this way, you will get above gantt chart. Scheduling table: AT=Arrival Time, BT=Burst Time, CT=Completion Time, TAT=Turn Around Time As we know, turn around time is total time between submission of the process and its completion. i.e turn around time=completion timearrival time. i.e. TAT=CTAT Turn around time of p0 = 12 (120) Turn around time of p1 = 13 (130) Turn around time of p2 = 14 (140) Average turn around time is (12+13+14)/3 = 13. Option (A) is the correct answer. See question 1 of http://www.geeksforgeeks.org/operatingsystemsset15/ This solution is contributed by Nitika Bansal
Question 65 
0%  
10.6%  
30.0%  
89.4% 
Discuss it
idle p0 p1 p2 idle 0 2 9 23 44 47 Total time spent = 47 Idle time = 2 + 3 = 5 Percentage of idle time = (5/47)*100 = 10.6 %See Question 2 of http://www.geeksforgeeks.org/operatingsystemsset15/ This solution is contributed by Nitika Bansal
Question 66 
min (Xp, Xq) < max (Yk) where k != p and k != q  
Xp + Xq >= min (Yk) where k != p and k != q  
max (Xp, Xq) > 1  
min (Xp, Xq) > 1 
Discuss it
Question 67 
Query1: select A.customer, count(B.customer) from account A, account B where A.balance <=B.balance group by A.customer Query2: select A.customer, 1+count(B.customer) from account A, account B where A.balance < B.balance group by A.customerConsider these statements about Query1 and Query2.
1. Query1 will produce the same row set as Query2 for some but not all databases. 2. Both Query1 and Query2 are correct implementation of the specification 3. Query1 is a correct implementation of the specification but Query2 is not 4. Neither Query1 nor Query2 is a correct implementation of the specification 5. Assigning rank with a pure relational query takes less time than scanning in decreasing balance order assigning ranks using ODBC.Which two of the above statements are correct?
2 and 5  
1 and 3  
1 and 4  
3 and 5 
Discuss it
Now, let us consider a fact that all the entries in the database have the same value for balance. Ideally, all the customers should have rank 1, but both the queries will give all the customers a rank equal to the number of customers in the database. So, both the queries do not give us the required output.
Thus, C is the correct choice.
Please comment below if you find anything wrong in the above post.
Question 68 
Query1: select student from enrolled where student in (select student from paid) Query2: select student from paid where student in (select student from enrolled) Query3: select E.student from enrolled E, paid P where E.student = P.student Query4: select student from paid where exists (select * from enrolled where enrolled.student = paid.student)Which one of the following statements is correct?
All queries return identical row sets for any database  
Query2 and Query4 return identical row sets for all databases but there exist databases for which Query1 and Query2 return different row sets.  
There exist databases for which Query3 returns strictly fewer rows than Query2  
There exist databases for which Query4 will encounter an integrity violation at runtime. 
Discuss it
Question 69 
Plan 1 and Plan 2 will not output identical row sets for all databases.  
A course may be listed more than once in the output of Plan 1 for some databases  
For x = 5000, Plan 1 executes faster than Plan 2 for all databases.  
For x = 9000, Plan I executes slower than Plan 2 for all databases. 
Discuss it
Question 70 
AB CD, AF D, DE F, C G , F E, G AWhich one of the following options is false?
CF+ = {ACDEFG}  
BG+ = {ABCDG}  
AF+ = {ACDEFG}  
AB+ = {ABCDFG} 
Discuss it
Question 71 
1  
n  
n+1  
2^{n} 
Discuss it
Question 72 
(n/2)C2 x 2^{n/2}  
2^{n2}  
2^{n3} x 3  
2^{n1} 
Discuss it
Question 73 
n  
n+2  
2^{n/2}  
2^{n} / n 
Discuss it
Question 74 
2.4 ns  
2.3 ns  
1.8 ns  
1.7 ns 
Discuss it
Total combinations are : = cache size / (Number of blocks * block size) = 32 * 2^{10} / (2 * 32) = 512 = 2^{9}
Therefore, number of index bits = 9
Since, cache block size is 32 bytes i.e. 2^{5} bytes. Number of offset bits = 5
So, number of tag bits = 32 – 9 – 5 = 18
Hit latency (h1) = 0.6 + (18 / 10) ns = 2.4 ns
Thus, option (A) is correct.
Please comment below if you find anything wrong in the above post.
Question 75 
2.4 ns  
2.3  
1.8  
1.7 
Discuss it
Total combinations are : = cache size / (Number of blocks * block size) = 32 * 2^{10} / (1 * 32) = 1024 = 2^{10}
Therefore, number of index bits = 10
Since, cache block size is 32 bytes i.e. 2^{5} bytes. Number of offset bits = 5
So, number of tag bits = 32 – 10 – 5 = 17
Hit latency (h2) = (17 / 10) ns = 1.7 ns
Thus, option (D) is correct.
Please comment below if you find anything wrong in the above post.
Question 76 
1, 3, 5, 6, 8, 9  
9, 6, 3, 1, 8, 5  
9, 3, 6, 8, 5, 1  
9, 5, 6, 8, 3, 1 
Discuss it
9 /  \ /  \ 5 6 8 /  /  3 1
Question 77 
10, 7, 9, 8, 3, 1, 5, 2, 6, 4  
10, 9, 8, 7, 6, 5, 4, 3, 2, 1  
10, 9, 4, 5, 7, 6, 8, 2, 1, 3  
10, 8, 6, 9, 7, 2, 3, 4, 1, 5 
Discuss it
9 /  \ /  \ 7 6 8 /  \ /  \ 3 1 5After insertion of 2
9 /  \ /  \ 7 6 8 /  \ / /  \ / 3 1 5 2After insertion of 10
10 /  \ /  \ 7 9 8 /  \ /  /  \ /  3 1 5 2 6After insertion of 4
10 /  \ /  \ 7 9 8 /  \ /  \ /  \ /  \ 3 1 5 2 6 4
Question 78 
void barrier (void) { 1: P(S); 2: process_arrived++; 3. V(S); 4: while (process_arrived !=3); 5: P(S); 6: process_left++; 7: if (process_left==3) { 8: process_arrived = 0; 9: process_left = 0; 10: } 11: V(S); }The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. The above implementation of barrier is incorrect. Which one of the following is true?
The barrier implementation is wrong due to the use of binary semaphore S  
The barrier implementation may lead to a deadlock if two barrier in
invocations are used in immediate succession.  
Lines 6 to 10 need not be inside a critical section  
The barrier implementation is correct if there are only two processes instead of three. 
Discuss it
Question 79 
void barrier (void) { 1: P(S); 2: process_arrived++; 3. V(S); 4: while (process_arrived !=3); 5: P(S); 6: process_left++; 7: if (process_left==3) { 8: process_arrived = 0; 9: process_left = 0; 10: } 11: V(S); }The variables process_arrived and process_left are shared among all processes and are initialized to zero. In a concurrent program all the three processes call the barrier function when they need to synchronize globally. Which one of the following rectifies the problem in the implementation?
Lines 6 to 10 are simply replaced by process_arrived  
At the beginning of the barrier the first process to enter the barrier waits
until process_arrived becomes zero before proceeding to execute P(S).  
Context switch is disabled at the beginning of the barrier and reenabled at the end.  
The variable process_left is made private instead of shared 
Discuss it
Step ‘2’ should not be executed when the process enters the barrier second time till other two processes have not completed their 7th step. This is to prevent variable process_arrived becoming greater than 3.
So, when variable process_arrived becomes zero and variable process_left also becomes zero then the problem of deadlock will be resolved.
Thus, at the beginning of the barrier the first process to enter the barrier waits until process_arrived becomes zero before proceeding to execute P(S).
Thus, option (B) is correct.
Please comment below if you find anything wrong in the above post.
Question 80 
for (i=0; i<512; i++) { for (j=0; j<512; j++) { x += A[i][j]; } }P2:
for (i=0; i<512; i++) { for (j=0; j<512; j++) { x += A[j][i]; } }P1 and P2 are executed independently with the same initial state, namely, the array A is not in the cache and i, j, x are in registers. Let the number of cache misses experienced by P1 be M1 and that for P2 be M2 . The value of M1 is:
0  
2048  
16384  
262144 
Discuss it
Question 81 
for (i=0; i<512; i++) { for (j=0; j<512; j++) { x += A[i][j]; } }P2:
for (i=0; i<512; i++) { for (j=0; j<512; j++) { x += A[j][i]; } }P1 and P2 are executed independently with the same initial state, namely, the array A is not in the cache and i, j, x are in registers. Let the number of cache misses experienced by P1 be M1 and that for P2 be M2 . The value of the ratio M1/M2 is:
0  
1/16  
1/8  
16 
Discuss it
Question 82 
B1, B5, B3, B4, B2  
B1, B3, B5, B2, B4  
B1, B5, B2, B3, B4  
B1, B3, B4, B5, B2 
Discuss it
B1 / \ / \ B5 B3 / \ / \ B4 B2Note that B4 and B2 are connected through B3 (Not B5) because B3 has lower serial number than B5. One DFS traversal of tree is B1 B5 B3 B4 B2 Hence Option A is the Answer
Question 83 
Hosts  Port 
H1, H2, H3, H4  3 
H5, H6, H9, H10  1 
H7, H8, H11, H12  2 
Hosts  Port 
H1, H2  4 
H3, H4  3 
H5, H6  1 
H7, H8, H9, H10,H11,H12  2 
Hosts  Port 
H3, H4  3 
H5, H6, H9, H10  1 
H1, H2  4 
H7, H8, H11, H12  2 
Hosts  Port 
H1, H2, H3, H4  3 
H5, H7, H9, H10  1 
H7, H8, H11, H12  4 
A  
B  
C  
D 
Discuss it
Question 84 
A  
B  
C  
D 
Discuss it
Question 85 
max(l,m) + 2  
l + m + 2  
l + m + 3  
max(l, m) + 3 
Discuss it
S > ACCB C > aCbepsilon A > aAa B > BbbNow, the most optimal and intuitive way to generate a string of the form a^{l}b^{m} would be to first use "C > aCbepsilon" production rule to get as many a and b as we can, which would be min(l,m). To get the rest of the string, we could just use latter two production rules accordingly. Formally deriving the string of the general format a^{l}b^{m} from the above grammar 
1. S > AC 2. > A(aCb) 3. > .... 4. > .... 5. > A(a^{m} C b^{m}) 6. > A(a^{m} b^{m}) 7. > aA(a^{m} b^{m}) 8. > .... 9. > .... 10. > a^{(lm1)}A(a^{m} b^{m}) 11. > a^{l} b^{m}From above set of derivation steps we can count the total steps as follows:
Production 1 took 1 step : 1 [using S>AC] Production 25 took steps : min(l,m) [using C>aCb] Production 6 took 1 step : 1 [using C>epsilon] Production 711 took steps : max(l,m)min(l,m) [using A > aAa or B > Bbb] Total steps : max(l,m) + 2Hence, answer should be (A): max(l,m) + 2 This explanation is contributed by Vineet Purswani.