# GATE CS 2012

 Question 1
Consider the following logical inferences.
I1: If it rains then the cricket match will not be played.
The cricket match was played.
Inference: There was no rain.
I2: If it rains then the cricket match will not be played.
It did not rain.
Inference: The cricket match was played.
Which of the following is TRUE?
 A Both I1 and I2 are correct inferences B I1 is correct but I2 is not a correct inference C I1 is not correct but I2 is a correct inference D Both I1 and I2 are not correct inferences
GATE CS 2012    General Aptitude
Discuss it

Question 1 Explanation:
The cricket match may not be played even if doesn't rain.
 Question 2
Which of the following is TRUE?
 A Every relation in 3NF is also in BCNF B A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every key of R C Every relation in BCNF is also in 3NF D No relation can be in both BCNF and 3NF
GATE CS 2012    Database Design(Normal Forms)
Discuss it

Question 2 Explanation:

BCNF is a stronger version 3NF. So every relation in BCNF will also be in 3NF.

 Question 3
What will be the output of the following C program segment?
```char inchar = 'A';
switch (inchar)
{
case 'A' :
printf ("choice A n") ;
case 'B' :
printf ("choice B ") ;
case 'C' :
case 'D' :
case 'E' :
default:
printf ("No Choice") ;
}
```
 A `No choice` B `Choice A` C ```Choice A Choice B No choice``` D `Program gives no output as it is erroneous`
GATE CS 2012
Discuss it

Question 3 Explanation:
There is no break statement in case ‘A’. If a case is executed and it doesn’t contain break, then all the subsequent cases are executed until a break statement is found. That is why everything inside the switch is printed. Try following program as an exercise.
```int main()
{
char inchar = 'A';
switch (inchar)
{
case 'A' :
printf ("choice A \n") ;
case 'B' :
{
printf ("choice B") ;
break;
}
case 'C' :
case 'D' :
case 'E' :
default:
printf ("No Choice") ;
}
}```
 Question 4
```Assuming P != NP, which of the following is true ?
(A) NP-complete = NP
(B) NP-complete P = (C) NP-hard = NP
(D) P = NP-complete
```
 A A B B C C D D
GATE CS 2012
Discuss it

Question 4 Explanation:

The answer is B (no NP-Complete problem can be solved in polynomial time). Because, if one NP-Complete problem can be solved in polynomial time, then all NP problems can solved in polynomial time. If that is the case, then NP and P set become same which contradicts the given condition.

Related Article: NP-Completeness | Set 1 (Introduction) P versus NP problem (Wikipedia)
 Question 5
The worst case running time to search for an element in a balanced in a binary search tree with n2^n elements is
```(A) (B) (C) (D) ```
 A A B B C C D D
GATE CS 2012
Discuss it

Question 5 Explanation:
-> The search time in a binary search tree depends on the form of the tree, that is on the order in which its nodes were inserted. A pathological case: The n nodes were inserted by increasing order of the keys, yielding something like a linear list (but with a worse space consumption), with O(n) search time(in the case of skew tree). -> A balanced tree is a tree where every leaf is “not more than a certain distance” away from the root than any other leaf.So in balanced tree, the height of the tree is balanced to make distance between root and leafs nodes a low as possible. In a balanced tree, the height of tree is log2(n). -> So , if a Balanced Binary Search Tree contains n2n elements then Time complexity to search an item: Time Complexity = log(n2n) = log (n) + log(2n) = log (n) +n = O(n) So Answer is C. See http://www.geeksforgeeks.org/data-structures-and-algorithms-set-28/ This solution is contributed by Nirmal Bharadwaj
 Question 6
 A X B X+Y C X xor Y D Y
GATE CS 2012    Digital Logic & Number representation
Discuss it

Question 6 Explanation:
The value of f(X, Y) is same as X for all input pairs. We see from truth table – Column x= f(x,y) So , f(x,y)=x Ans is (A) part.
 Question 7
T he decimal value 0.5 in IEEE single precision floating point representation has
 A fraction bits of 000…000 and exponent value of 0 B fraction bits of 000…000 and exponent value of −1 C fraction bits of 100…000 and exponent value of 0 D no exact representation
GATE CS 2012    Number Representation
Discuss it

Question 7 Explanation:
The IEEE 754 standard specifies following distribution of bits: Sign bit: 1 bit Exponent width: 8 bits Significand or Fraction: 24 (23 explicitly stored) 0.5 in base 10 means 1 X 2-1 in base 2. So exponent bits have value -1 and all fraction bits are 0
 Question 8
A process executes the code
```fork();
fork();
fork(); ```
The total number of child processes created is
 A 3 B 4 C 7 D 8
GATE CS 2012    OS Process Management
Discuss it

Question 8 Explanation:
Let us put some label names for the three lines
```  fork ();    // Line 1
fork ();   // Line 2
fork ();   // Line 3

L1       // There will be 1 child process created by line 1
/     \
L2      L2    // There will be 2 child processes created by line 2
/  \    /  \
L3  L3  L3  L3  // There will be 4 child processes created by line 3```
We can also use direct formula to get the number of child processes. With n fork statements, there are always 2^n – 1 child processes. Also see this post for more details.
 Question 9
Consider the function f(x) = sin(x) in the interval [π/4, 7π/4]. The number and location(s) of the local minima of this function are
 A One, at π/2 B One, at 3π/2 C Two, at π/2 and 3π/2 D Two, at π/4 and 3π/2
GATE CS 2012    Numerical Methods and Calculus
Discuss it

Question 9 Explanation:
 Question 10
Let A be the 2 × 2 matrix with elements a11 = a12 = a21 = +1 and a22 = −1. Then the eigenvalues of the matrix A19 are A A B B C C D D
GATE CS 2012    Linear Algebra
Discuss it

Question 10 Explanation:
```A =  1    1
1   -1

A2 = 2   0
0   2

A4 = A2 X A2
A4 = 4   0
0   4

A8 = 16   0
0    16

A16 = 256   0
0    256

A18 = A16 X A2
A18 = 512   0
0    512

A19 = 512   512
512  -512

Applying Characteristic polynomial

512-lamda   512
512       -(512+lamda)  =   0

-(512-lamda)(512+lamda) - 512 x 512 = 0

lamda2 = 2 x 5122 ```
Alternative solution:
```det(A) = -2.
det(A^19) = (det(A))^19 = -2^19 = lambda1*lambda2.
The only viable option is D. ```
Thanks to Matan Mandelbrod for suggesting this solution.
There are 59 questions to complete.

My Personal Notes arrow_drop_up