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
The truth table represents the Boolean function
 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    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
The protocol data unit (PDU) for the application layer in the Internet stack is
 A Segment B Datagram C Message D Frame
GATE CS 2012    Application Layer
Discuss it

Question 10 Explanation:
The Protocol Data Unit  is the unit of communication at a particular layer.
 The Layer 1 (Physical Layer) PDU is the bit or, more generally, symbol
The Layer 2 (Data Link Layer) PDU is the frame.
The Layer 3 (Network Layer) PDU is the packet.
The Layer 4 (Transport Layer) PDU is the segment
for TCP or the datagram for UDP.
The Layer 5 (Application Layer) PDU is the data or message.

 Question 11
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 11 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 
 Question 12
W hat is the complement of the language accepted by the NFA shown below?
 A A B B C C D D
GATE CS 2012    Regular languages and finite automata
Discuss it

Question 12 Explanation:
The given alphabet contains only one symbol {a} and the given NFA accepts all strings with any number of occurrences of ‘a’. In other words, the NFA accepts a+. Therefore complement of the language accepted by automata is empty string.
 Question 13
What is the correct translation of the following statement into mathematical logic? “Some real numbers are rational”
 A A B B C C D D
GATE CS 2012    Propositional and First Order Logic.
Discuss it

Question 13 Explanation:
(A) "There exist some numbers which are either real OR rational"

(B) "All real numbers are rational"

(C) "There exist some numbers which are both real AND rational"

(D) "There exist some numbers for which rational implies real"
(See Propositional Logic for details)

Clearly answer C is correct among all
 Question 14
Given the basic ER and relational models, which of the following is INCORRECT?
 A An attribute of an entity can have more than one value B An attribute of an entity can be composite C In a row of a relational table, an attribute can have more than one value D In a row of a relational table, an attribute can have exactly one value or a NULL value
GATE CS 2012    ER and Relational Models
Discuss it

Question 14 Explanation:
The term ‘entity’ belongs to ER model and the term ‘relational table’ belongs to relational model. A and B both are true. ER model supports both multivalued and composite attributes See this for more details. (C) is false and (D) is true. In Relation model, an entry in relational table can can have exactly one value or a NULL.
 Question 15
Which of the following statements are TRUE about an SQL query?
P : An SQL query can contain a HAVING clause even
if it does not have a GROUP BY clause
Q : An SQL query can contain a HAVING clause only
if it has a GROUP BY clause
R : All attributes used in the GROUP BY clause must
appear in the SELECT clause
S : Not all attributes used in the GROUP BY clause
need to appear in the SELECT clause 
 A P and R B P and S C Q and R D Q and S
GATE CS 2012    SQL
Discuss it

Question 15 Explanation:
According to standard SQL answer should be C. Refer If we talk about different SQL implementations like MySQL, then option B is also right. But in question they seem to be talking about standard SQL not about implementation. For example below is a P is correct in most of the implementations. HAVING clause can also be used with aggregate function. If we use a HAVING clause without a GROUP BY clause, the HAVING condition applies to all rows that satisfy the search condition. In other words, all rows that satisfy the search condition make up a single group. See this for more details. S is correct . To verify S, try following queries in SQL.
CREATE TABLE temp
(
id   INT,
name VARCHAR(100)
);

INSERT INTO temp VALUES (1, "abc");
INSERT INTO temp VALUES (2, "abc");
INSERT INTO temp VALUES (3, "bcd");
INSERT INTO temp VALUES (4, "cde");

SELECT Count(*)
FROM   temp
GROUP  BY name;

Output:
count(*)
--------
2
1
1

 Question 16
The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is
 A T(n) = 2T(n − 2) + 2 B T(n) = 2T(n − 1) + n C T(n) = 2T(n/2) + 1 D T(n) = 2T(n − 1) + 1
GATE CS 2012
Discuss it

Question 16 Explanation:
 Question 17
Let G be a simple undirected planar graph on 10 vertices with 15 edges. If G is a connected graph, then the number of bounded faces in any embedding of G on the plane is equal to
 A 3 B 4 C 5 D 6
GATE CS 2012    Graph Theory
Discuss it

Question 17 Explanation:
If the graph is planar, then it must follow below Euler's Formula for planar graphs
v - e + f = 2
v is number of vertices
e is number of edges
f is number of faces including bounded and unbounded

10 - 15 + f = 2
f = 7
There is always one unbounded face, so the number of bounded faces =  6
 Question 18
Let w(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. which of the following is ALWAYS TRUE?
(A)
(B)
(C)
(D)

 A A B B C C D D
GATE CS 2012
Discuss it

Question 18 Explanation:
The worst case time complexity is always greater than or same as the average case time complexity. The term written in Big O notation can always asymptotically same or greater than the term on the other side.
 Question 19
The amount of ROM needed to implement a 4 bit multiplier is
 A 64 bits B 128 bits C 1 Kbits D 2 Kbits
GATE CS 2012    Computer Organization and Architecture
Discuss it

Question 19 Explanation:
For a 4 bit multiplier, there are 24 * 24 combinations, i.e., 28 combinations. Also, Output of a 4 bit multiplier is 8 bits. Thus, the amount of ROM needed = 28 * 8 = 211 = 2048 bits = 2Kbits
 Question 20
Which of the following transport layer protocols is used to support electronic mail?
 A SMTP B IP C TCP D UDP
GATE CS 2012    Transport Layer
Discuss it

Question 20 Explanation:
E-mail uses SMTP as application layer protocol. TCP and UDP are two transport layer protocols. SMTP uses TCP as transport layer protocol as TCP is reliable.
 Question 21
In the IPv4 addressing format, the number of networks allowed under Class C addresses is
 A 2 14 B 2 7 C 2 21 D 2 24
Discuss it

Question 21 Explanation:
In class C, 8 bits are reserved for Host Id and 24 bits are reserved for Network Id. Out of these 24 Network Id bits, the leading 3 bits are fixed as 110. So remaining 21 bits can be used for different networks. See this for more details.
 Question 22
Which of the following problems are decidable?
 A 1, 2, 3, 4 B 1, 2 C 2, 3, 4 D 3, 4
GATE CS 2012    Undecidability
Discuss it

Question 22 Explanation:
 Question 23
Given the language L = {ab, aa, baa}, which of the following strings are in L*?
1) abaabaaabaa
2) aaaabaaaa
3) baaaaabaaaab
4) baaaaabaa 
 A 1, 2 and 3 B 2, 3 and 4 C 1, 2 and 4 D 1, 3 and 4
GATE CS 2012    Regular languages and finite automata
Discuss it

Question 23 Explanation:
 Question 24
Which of the following graphs is isomorphic to
 A A B B C C D D
GATE CS 2012    Graph Theory
Discuss it

Question 24 Explanation:
 Question 25
Consider the following transactions with data items P and Q initialized to zero:
T1: read (P) ;
if P = 0 then Q : = Q + 1 ;
write (Q) ;
if Q = 0 then P : = P + 1 ;
write (P) ;
Any non-serial interleaving of T1 and T2 for concurrent execution leads to
 A A serializable schedule B A schedule that is not conflict serializable C A conflict serializable schedule D A schedule for which a precedence graph cannot be drawn
GATE CS 2012    Transactions and concurrency control
Discuss it

Question 25 Explanation:
 Question 26
The bisection method is applied to compute a zero of the function f(x) = x4 – x3 – x2 – 4 in the interval [1,9]. The method converges to a solution after ––––– iterations
 A 1 B 3 C 5 D 7
GATE CS 2012    Numerical Methods and Calculus
Discuss it

Question 26 Explanation:
In bisection method, we calculate the values at extreme points of given interval, if signs of values are opposite, then we find the middle point. Whatever sign we get at middle point, we take the corner point of opposite sign and repeat the process till we get 0. f(1) < 0 and f(9) > 0 mid = (1 + 9)/2 = 5 f(5) > 0, so zero value lies in [1, 5] mid = (1+5)/2 = 3 f(3) > 0, so zero value lies in [1, 3] mid = (1+3)/2 = 2 f(2) = 0
 Question 27
Let G be a weighted graph with edge weights greater than one and G'be the graph constructed by squaring the weights of edges in G. Let T and T' be the minimum spanning trees of G and G', respectively, with total weights t and t'. Which of the following statements is TRUE?
 A T' = T with total weight t' = t2 B T' = T with total weight t' < t2 C T' != T but total weight t' = t2 D None of the above
GATE CS 2012    Graph Minimum Spanning Tree
Discuss it

Question 27 Explanation:
Squaring the weights of the edges in a weighted graph will not change the minimum spanning tree. Assume the opposite to obtain a contradiction. If the minimum spanning tree changes then at least one edge from the old graph G in the old minimum spanning tree T must be replaced by a new edge in tree T' from the graph G' with squared edge weights. The new edge from G' must have a lower weight than the edge from G. This implies that there exists some weights C1 and C2 such that C1 < C2 and C12 >= C22. This is a contradiction. Source: http://www.cs.nyu.edu/courses/spring06/V22.0310-001/hw3.htm Sums of squares of two or more numbers is always smaller than square of sum. Example: 2^2 + 2^2 < (4)^2 But
there is one counter example when the graph has only one edge.
In that case, the two values are same. 
 Question 28
W hat is the minimal form of the Karnaugh map shown below? Assume that X denotes a don’t care term.
 A b'd' B b'd' + b'c' C b'd' + a'b'c'd' D b'd' + b'c' + c'd'
GATE CS 2012    Digital Logic & Number representation
Discuss it

Question 28 Explanation:
 Question 29
Consider the 3 processes, P1, P2 and P3 shown in the table.
Process           Arrival time         Time Units Required
P1                0                         5
P2                1                         7
P3                3                         4
The completion order of the 3 processes under the policies FCFS and RR2 (round robin scheduling with CPU quantum of 2 time units) are
 A FCFS: P1, P2, P3 RR2: P1, P2, P3 B  FCFS: P1, P3, P2 RR2: P1, P3, P2 C FCFS: P1, P2, P3 RR2: P1, P3, P2 D FCFS: P1, P3, P2 RR2: P1, P2, P3
GATE CS 2012    CPU Scheduling
Discuss it

Question 29 Explanation:
FCFS is clear.

In RR, time slot is of 2 units.

Processes are assigned in following order
p1, p2, p1, p3, p2, p1, p3, p2, p2

This question involves the concept of ready queue. At t=2, p2 starts and p1 is sent to the ready queue and at t=3 p3 arrives so then the job p3 is queued in ready queue after p1. So at t=4, again p1 is executed then p3 is executed for first time at t=6.
 Question 30
Fetch_And_Add(X,i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.
  AcquireLock(L){
L = 1;
}
ReleaseLock(L){
L = 0;
}
This implementation
 A fails as L can overflow B fails as L can take on a non-zero value when the lock is actually available C works correctly but may starve some processes D works correctly without starvation
GATE CS 2012    Process Management
Discuss it

Question 30 Explanation:
Take closer look the below while loop.
     while (Fetch_And_Add(L,1))
L = 1;  // A waiting process can be here just after
// the lock is released, and can make L = 1.

Consider a situation where a process has just released the lock and made L = 0. Let there be one more process waiting for the lock, means executing the AcquireLock() function. Just after the L was made 0, let the waiting processes executed the line L = 1. Now, the lock is available and L = 1. Since L is 1, the waiting process (and any other future coming processes) can not come out of the while loop. The above problem can be resolved by changing the AcuireLock() to following.
  AcquireLock(L){
{ // Do Nothing }
}

 Question 31
Suppose a fair six-sided die is rolled once. If the value on the die is 1, 2, or 3, the die is rolled a second time. What is the probability that the sum total of values that turn up is at least 6?
 A 10/21 B 5/12 C 2/3 D 1/6
GATE CS 2012    Probability
Discuss it

Question 31 Explanation:
The following are different possibilities (1,5) (1,6) (2,4) (2,5) (2,6) (3,3) (3,4) (3,5) (3,6) Plus 1/6 probability that first time 6 is rolled So total probability is 9/36 + 1/6 = 15/36 = 5/12.
 Question 32
A n Internet Service Provider (ISP) has the following chunk of CIDR-based IP addresses available with it: 245.248.128.0/20. The ISP wants to give half of this chunk of addresses to Organization A, and a quarter to Organization B, while retaining the remaining with itself. Which of the following is a valid allocation of addresses to A and B?
 A 245.248.136.0/21 and 245.248.128.0/22 B 245.248.128.0/21 and 245.248.128.0/22 C 245.248.132.0/22 and 245.248.132.0/21 D 245.248.136.0/24 and 245.248.132.0/21
Discuss it

Question 32 Explanation:
 Question 33
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
 A Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT B Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR C Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT D Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT
GATE CS 2012
Discuss it

Question 33 Explanation:
Implementation of Circular Queue : Head - It always points to the location from where next deletion takes place from the queue. Tail - It always points to the next empty location in which next insertion will take place in the queue. We will be using wrap around feature since it is a circular queue which is when the tail or head is at the index n-1, next operation will bring them to index 0. In Spite of having capacity of n inside array, we will reserve one empty spot in order to detect the overflow(Queue Full) and underflow(Queue Empty) conditions. The elements in the queue reside in locations Q.head, Q.head + 1, . . . , Q.tail + 1, where we “wrap around” in the sense that location 0 immediately follows location n-1 in a circular order. Algorithm :
ENQUEUE(Q, x)
{

if Q.head == Q.tail + 1
error "Queue overflow"

Q[Q.tail] = x

if Q.tail == Q.length    - 1
Q.tail = 0
else
Q.tail = Q.tail + 1
}

DEQUEUE(Q)
{
error "Queue underflow"

if Q.head == Q.length - 1
else

return x
}


This solution is contributed by Pranjul Ahuja
 Question 34
Consider the program given below, in a block-structured pseudo-language with lexical scoping and nesting of procedures permitted.
 A A B B C C D D
GATE CS 2012    Principles of Programming Languages
Discuss it

Question 34 Explanation:
Access link is defined as link to activation record of closest lexically enclosing block in program text, so the closest enclosing blocks respectively for A1 ,A2 and A21 are main , main and A2 Since, Activation records are created at procedure entry time and destroyed at procedure exit time. Solution: Link to activation record of closest lexically enclosing block in program text. It depends on the static program text. Here Calling sequence is given as, Main->A1->A2->A21->A1 Now A1,A2 are defined under Main...So A1,A2 Access link are pointed to main A21 is defined under A2 hence its Access link will point to A2 . Reference: http://www.cs.nyu.edu/courses/spring08/G22.2130-001/lectures/lecture-13.html
This solution is contributed by Nitika Bansal
 Question 35
How many onto (or surjective) functions are there from an n-element (n >= 2) set to a 2-element set?
 A 2n B 2n - 1 C 2n - 2 D 2(2n - 2)
GATE CS 2012    Combinatorics
Discuss it

Question 35 Explanation:
Total possible number of functions is 2n. In mathematics, a function f from a set X to a set Y is surjective (or onto), or a surjection, if every element y in Y has a corresponding element x in X such that f(x) = y (Source: http://en.wikipedia.org/wiki/Surjective_function) There are total 2 functions out of 2n that are NOT onto: one that maps to all 1s and other that maps to all 2s. Therefore total number of onto functions is 2n - 2.
 Question 36
Let G be a complete undirected graph on 6 vertices. If vertices of G are labeled, then the number of distinct cycles of length 4 in G is equal to
 A 15 B 30 C 45 D 360
GATE CS 2012    Graph Theory
Discuss it

Question 36 Explanation:
There can be total 6C4 ways to pick 4 vertices from 6. The value of 6C4 is 15. Note that the given graph is complete so any 4 vertices can form a cycle. There can be 6 different cycle with 4 vertices. For example, consider 4 vertices as a, b, c and d. The three distinct cycles are cycles should be like this (a, b, c, d,a) (a, b, d, c,a) (a, c, b, d,a) (a, c, d, b,a) (a, d, b, c,a) (a, d, c, b,a) and (a, b, c, d,a) and (a, d, c, b,a) (a, b, d, c,a) and (a, c, d, b,a) (a, c, b, d,a) and (a, d, b, c,a) are same cycles. So total number of distinct cycles is (15*3) = 45. **NOTE**: In original GATE question paper 45 was not an option. In place of 45, there was 90.
 Question 37
A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is
 A O(n log n) B O(n2 log n) C O(n2 + log n) D O(n2)
GATE CS 2012
Discuss it

Question 37 Explanation:
When we are sorting an array of n integers, Recurrence relation for Total number of comparisons involved will be, T(n) = 2T(n/2) + (n) where (n) is the number of comparisons in order to merge 2 sorted subarrays of size n/2. = (nlog2n) Instead of integers whose comparison take O(1) time, we are given n strings. We can compare 2 strings in O(n) worst case. Therefore, Total number of comparisons now will be (n2log2n) where each comparison takes O(n) time now. In general, merge sort makes (nlog2n) comparisons, and runs in (nlog2n) time if each comparison can be done in O(1) time. See question 5 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-28/ This solution is contributed by Pranjul Ahuja
 Question 38
Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijstra?s shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is updated only when a strictly shorter path to v is discovered.
 A SDT B SBDT C SACDT D SACET
GATE CS 2012
Discuss it

Question 38 Explanation:
Background Required -  Dijkstra's Single Source Shortest Path Algorithm Explanation - Applying  Dijkstra's algorithm to compute the shortest distances from S and finally generating the Tree as given below in the diagram.   This solution is contributed by Pranjul Ahuja.
 Question 39
A file system with 300 GByte disk uses a file descriptor with 8 direct block addresses, 1 indirect block address and 1 doubly indirect block address. The size of each disk block is 128 Bytes and the size of each disk block address is 8 Bytes. The maximum possible file size in this file system is
 A 3 Kbytes B 35 Kbytes C 280 Bytes D Dependent on the size of the disk
GATE CS 2012    Input Output Systems
Discuss it

Question 39 Explanation:
 Question 40
Consider the virtual page reference string 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 On a demand paged virtual memory system running on a computer system that main memory size of 3 pages frames which are initially empty. Let LRU, FIFO and OPTIMAL denote the number of page faults under the corresponding page replacements policy. Then
 A OPTIMAL < LRU < FIFO B OPTIMAL < FIFO < LRU C OPTIMAL = LRU D OPTIMAL = FIFO
GATE CS 2012    Memory Management
Discuss it

Question 40 Explanation:
First In First Out (FIFO) This is the simplest page replacement algorithm. In this algorithm, operating system keeps track of all pages in the memory in a queue; oldest page is in the front of the queue. When a page needs to be replaced page in the front of the queue is selected for removal. Optimal Page replacement: in this algorithm, pages are replaced which are not used for the longest duration of time in the future. Least Recently Used (LRU) In this algorithm page will be replaced which is least recently used. Solution: the virtual page reference string is 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 size of main memory pages frames is 3. For FIFO: total no of page faults are 6 (depicted in bold and italic) For optimal: total no of page faults are 5 (depicted in bold and italic) For LRU: total no of page faults are 9 (depicted in bold and italic) The Optimal will be 5, FIFO 6 and LRU 9. so, OPTIMAL < FIFO < LRU option (B) is correct answer. See http://www.geeksforgeeks.org/operating-systems-set-5/ This solution is contributed by Nitika Bansal
 Question 41
Suppose (A, B) and (C,D) are two relation schemas. Let r1 and r2 be the corresponding relation instances. B is a foreign key that refers to C in r2. If data in r1 and r2 satisfy referential integrity constraints, which of the following is ALWAYS TRUE?
 A A B B C C D D
GATE CS 2012    ER and Relational Models
Discuss it

Question 41 Explanation:
 Question 42
Consider a source computer(S) transmitting a file of size 106 bits to a destination computer(D)over a network of two routers (R1 and R2) and three links(L1, L2, and L3). L1connects S to R1; L2 connects R1 to R2; and L3 connects R2 to D.Let each link be of length 100 km. Assume signals travel over each link at a speed of 108 meters per second.Assume that the link bandwidth on each link is 1Mbps. Let the file be broken down into 1000 packets each of size 1000 bits. Find the total sum of transmission and propagation delays in transmitting the file from S to D?
 A 1005 ms B 1010 ms C 3000 ms D 3003 ms
GATE CS 2012    Network Layer
Discuss it

Question 42 Explanation:
 Question 43
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.
 A 8 MSS B 14 MSS C 7 MSS D 12 MSS
GATE CS 2012    Transport Layer
Discuss it

Question 43 Explanation:
 Question 44
Consider the set of strings on {0,1} in which, every substring of 3 symbols has at most two zeros. For example, 001110 and 011001 are in the language, but 100010 is not. All strings of length less than 3 are also in the language. A partially completed DFA that accepts this language is shown below. The missing arcs in the DFA are
 A A B B C C D D
GATE CS 2012    Regular languages and finite automata
Discuss it

Question 44 Explanation:
 Question 45
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudocode below is invoked as height (root) to compute the height of a binary tree rooted at the tree pointer root. The appropriate expression for the two boxes B1 and B2 are
 A B1 : (1 + height(n->right)), B2 : (1 + max(h1,h2)) B B1 : (height(n->right)), B2 : (1 + max(h1,h2)) C B1 : height(n->right), B2 : max(h1,h2) D B1 : (1 + height(n->right)), B2 : max(h1,h2)
GATE CS 2012
Discuss it

Question 45 Explanation:
The box B1 gets exected when left subtree of n is NULL and right sbtree is not NULL. In this case, height of n will be height of right subtree plus one. The box B2 gets executed when both left and right sbtrees of n are not NULL. In this case, height of n will be max of heights of left and right sbtrees of n plus 1.
 Question 46
Register renaming is done in pipelined processors
 A as an alternative to register allocation at compile time B for efficient access to function parameters and local variables C to handle certain kinds of hazards D as part of address translation
GATE CS 2012    Computer Organization and Architecture
Discuss it

Question 46 Explanation:
Register renaming is done to avoid data hazards
 Question 47
Consider a random variable X that takes values +1 and −1 with probability 0.5 each. The values of the cumulative distribution function F(x) at x = −1 and +1 are
 A 0 and 0.5 B 0 and 1 C 0.5 and 1 D 0.25 and 0.75
GATE CS 2012    Probability
Discuss it

Question 47 Explanation:
The Cumulative Distribution Function F(x) = P(X≤x) F(-1) = P(X≤-1) = P(X=-1) = 0.5 F(+1) = P(X≤+1) = P(X=-1) + (P=+1) = 0.5+0.5 = 1
 Question 48
Consider the following C program
int a, b, c = 0;
void prtFun (void);
int 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?
 A 3 1 4 1 4 2 B 4 2 6 1 6 1 C 4 2 6 2 2 0 D 3 1 5 2 5 2
GATE CS 2012
Discuss it

Question 48 Explanation:
 Question 49
Consider the above question. What output will be generated by the given code d\segment if: Line 1 is replaced by “auto int a = 1;” Line 2 is replaced by “register int a = 2;
 A 3 1 4 1 4 2 B  4 2 6 1 6 1 C 4 2 6 2 2 0 D 4 2 4 2 2 0
GATE CS 2012
Discuss it

Question 49 Explanation:
 Question 50
Consider the following relations A, B, C. How many tuples does the result of the following relational algebra expression contain? Assume that the schema of A U B is the same as that of A.
Table A
Id   Name    Age
----------------
12   Arun    60
15   Shreya  24
99   Rohit   11

Table B
Id   Name   Age
----------------
15   Shreya  24
25   Hari    40
98   Rohit   20
99   Rohit   11

Table C
Id   Phone  Area
-----------------
10   2200   02
99   2100   01

 A 7 B 4 C 5 D 9
GATE CS 2012    ER and Relational Models
Discuss it

Question 50 Explanation:
 Question 51
Table A
Id   Name    Age
----------------
12   Arun    60
15   Shreya  24
99   Rohit   11

Table B
Id   Name   Age
----------------
15   Shreya  24
25   Hari    40
98   Rohit   20
99   Rohit   11

Table C
Id   Phone  Area
-----------------
10   2200   02
99   2100   01
Consider the above tables A, B and C. How many tuples does the result of the following SQL query contains?
SELECT A.id
FROM   A
WHERE  A.age > ALL (SELECT B.age
FROM   B
WHERE  B. name = "arun")

 A 4 B 3 C 0 D 1
GATE CS 2012    SQL
Discuss it

Question 51 Explanation:
The meaning of “ALL” is the A.Age should be greater than all the values returned by the subquery. There is no entry with name “arun” in table B. So the subquery will return NULL. If a subquery returns NULL, then the condition becomes true for all rows of A (See this for details). So all rows of table A are selected. Source: http://www.geeksforgeeks.org/database-management-system-set-3/
 Question 52
For the grammar below, a partial LL(1) parsing table is also presented along with the grammar. Entries that need to be filled are indicated as E1, E2, and E3. is the empty string, $indicates end of input, and, | separates alternate right hand sides of productions.  A A B B C C D D GATE CS 2012 Parsing and Syntax directed translation Discuss it Question 52 Explanation: First(X) - It is the set of terminals that begin the strings derivable from X. Follow(X) - It is the set of terminals that can appear immediately to the right of X in some sentential form. Now in the above question, FIRST(S) = { a, b, epsilon} FIRST(A) = FIRST(S) = { a, b, epsilon} FIRST(B) = FIRST(S) = { a, b, epsilon} FOLLOW (A) = { b , a } FOLLOW (S) = {$ } U FOLLOW (A) = { b , a , $} FOLLOW (B) = FOLLOW (S) = { b ,a ,$ }

epsilon corresponds to empty string.
 Question 53
Consider the date same as above question. The appropriate entries for E1, E2, and E3 are
 A A B B C C D D
GATE CS 2012    Parsing and Syntax directed translation
Discuss it

Question 53 Explanation:
As we need to find entries E1, E2 and E3 which are against Non terminals S and B, so we will deal with only those productions which have S and B on LHS. Here representing the parsing table as M[ X , Y ], where X represents rows( Non terminals) and Y represents columns(terminals).

Rule 1: if P --> Q is a production, for each terminal
't' in FIRST(Q) add P-->Q to M [ P , t ]

Rule 2 : if epsilon is in FIRST(Q), add P --> Q to
M [ P , f ] for each f in FOLLOW(P). 
For the production rule S--> aAbB, it will be added to parsing table at the position M[ S , FIRST( aAbB ) ], Now FIRST(aAbB) = {a}, hence add S--> aAbB to M[ S , a ] which is E1. For the production rule S--> bAaB, it will be added to parsing table at the position M[ S , FIRST( bAaB ) ], Now FIRST(bAaB) = {b}, hence add S--> bAaB to M[ S , b ] which is E2 For the production rule S--> epsilon , it will be added to parsing table at the position M[ S , FOLLOW(S) ], Now FOLLOW(S) = { a , b , $}, hence add S --> epsilon to M[ S , a ] and M[ S , b ] which are again E1 and E2 respectively. For the production rule B --> S, it will be added to parsing table at the position M[ B , FIRST( S ) ], Now FIRST(S) also contains epsilon, hence add B --> S to M[ S , FOLLOW(B) ], and FOLLOW(B) contains {$}, i.e. M[ S , \$ ] which is E3. epsilon corresponds to empty string.
 Question 54
A computer has a 256 KByte, 4-way set associative, write back data cache with block size of 32 Bytes. The processor sends 32 bit addresses to the cache controller. Each cache tag directory entry contains, in addition to address tag, 2 valid bits, 1 modified bit and 1 replacement bit. The number of bits in the tag field of an address is
 A 11 B 14 C 16 D 27
GATE CS 2012    Computer Organization and Architecture
Discuss it

Question 54 Explanation:
A set-associative scheme is a hybrid between a fully associative cache, and direct mapped cache. It's considered a reasonable compromise between the complex hardware needed for fully associative caches (which requires parallel searches of all slots), and the simplistic direct-mapped scheme, which may cause collisions of addresses to the same slot (similar to collisions in a hash table). (source: http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/Memory/set.html). Also see http://csillustrated.berkeley.edu/PDFs/handouts/cache-3-associativity-handout.pdf   Number of blocks = Cache-Size/Block-Size = 256 KB / 32 Bytes = 213 Number of Sets = 213 / 4 = 211 Tag + Set offset + Byte offset = 32 Tag + 11 + 5 = 32 Tag = 16
 Question 55
Consider the data given in previous question. The size of the cache tag directory is
 A 160 Kbits B 136 bits C 40 Kbits D 32 bits
GATE CS 2012    Computer Organization and Architecture
Discuss it

Question 55 Explanation:
16 bit address 2 bit valid 1 modified 1 replace Total bits = 20 20 × no. of blocks = 160 K bits.
 Question 56
The cost function for a product in a firm is given by 5q2, where q is the amount of production. The firm can sell the product at a market price of Rs 50 per unit. The number of units to be produced by the firm such that the profit is maximized is
 A 5 B 10 C 15 D 25
GATE CS 2012    General Aptitude
Discuss it

Question 56 Explanation:
Profit = Price - Cost
= 50q - 5q2
The value of above expression is maximum at q = 5. 
 Question 57
Choose the most appropriate alternative from the options given below to complete the following sentence: Despite several ––––––––– the mission succeeded in its attempt to resolve the conflict.
 A attempts B setbacks C meetings D delegations
GATE CS 2012    English
Discuss it

Question 57 Explanation:
 Question 58
Which one of the following options is the closest in meaning to the word given below? Mitigate
 A Diminish B Divulge C Dedicate D Denote
GATE CS 2012    English
Discuss it

Question 58 Explanation:
 Question 59
Choose the grammatically INCORRECT sentence:
 A They gave us the money back less the service charges of Three Hundred rupees. B This country’s expenditure is not less than that of Bangladesh. C The committee initially asked for a funding of Fifty Lakh rupees, but later settled for a lesser sum. D This country’s expenditure on educational reforms is very less.
GATE CS 2012    English
Discuss it

Question 59 Explanation:
 Question 60
Choose the most appropriate alternative from the options given below to complete the following sentence: Suresh’s dog is the one ––––––––– was hurt in the stampede.
 A that B which C who D whom
GATE CS 2012    English
Discuss it

Question 60 Explanation:
 Question 61
Wanted Temporary, Part-time persons for the post of Field Interviewer to conduct personal interviews to collect and collate economic data. Requirements: High School-pass, must be available for Day, Evening and Saturday work. Transportation paid, expenses reimbursed. Which one of the following is the best inference from the above advertisement?
 A Gender-discriminatory B Xenophobic C Not designed to make the post attractive D Not gender-discriminatory
GATE CS 2012    English
Discuss it

Question 61 Explanation:
There is no mention of gender. Xenophobia also doesn't fit.
 Question 62
A political party orders an arch for the entrance to the ground in which the annual convention is being held. The profile of the arch follows the equation y = 2x – 0.1x2 where y is the height of the arch in meters. The maximum possible height of the arch is
 A 8 meters B 10 meters C 12 meters D 14 meters
GATE CS 2012    General Aptitude
Discuss it

Question 62 Explanation:
y = 2x – 0.1x2 dy/dx = 2 - 0.2x So the value maximizes at 2 - 0.2x = 0 => x = 10 => y = 20 - 10 = 10 meters
 Question 63
An automobile plant contracted to buy shock absorbers from two suppliers X and Y. X supplies 60% and Y supplies 40% of the shock absorbers. All shock absorbers are subjected to a quality test. The ones that pass the quality test are considered reliable. Of X’s shock absorbers, 96% are reliable. Of Y’s shock absorbers, 72% are reliable. The probability that a randomly chosen shock absorber, which is found to be reliable, is made by Y is
 A 0.288 B 0.334 C 0.667 D 0.72
GATE CS 2012    General Aptitude
Discuss it

Question 63 Explanation:
Probability that the absorber is reliable = 0.96*0.6 + 0.72*0.4
= 0.576 + 0.288

Probability that  the absorber is from y and reliable =
(Probability that is made by Y)  X (Probability that it is reliable)
= 0.4 * 0.72
= 0.288

The probability that randomly picked reliable absorber is from y =
(Probability that  the absorber is from y and reliable) / (>Probability that the absorber is reliable )
= (0.288)/ (0.576 + 0.288)
=  0.334 
 Question 64
Which of the following assertions are CORRECT? P: Adding 7 to each entry in a list adds 7 to the mean of the list Q: Adding 7 to each entry in a list adds 7 to the standard deviation of the list R: Doubling each entry in a list doubles the mean of the list S: Doubling each entry in a list leaves the standard deviation of the list unchanged
 A P, Q B Q, R C P, R D R, S
GATE CS 2012    General Aptitude
Discuss it

Question 64 Explanation:
Mean is average.
Let us consider below example
[Tex] 2,\ 4,\ 4,\ 4,\ 5,\ 5,\ 7,\ 9 [/Tex]

These eight data points have the mean (average) of 5:
[Tex] \frac{2 + 4 + 4 + 4 + 5 + 5 + 7 + 9}{8} = 5. [/Tex]

When we add 7 to all numbers, mean becomes 12 so P is TRUE.

If we double all numbers mean becomes double, so R is also
TRUE.

Standard Deviation is square root of variance.
Variance is sum of squares of differences between all numbers
and means.

Deviation for above example
First, calculate the deviations of each data point from the mean,
and square the result of each:

[Tex] \begin{array}{lll} (2-5)^2 = (-3)^2 = 9 && (5-5)^2 = 0^2 = 0 \\ (4-5)^2 = (-1)^2 = 1 && (5-5)^2 = 0^2 = 0 \\ (4-5)^2 = (-1)^2 = 1 && (7-5)^2 = 2^2 = 4 \\ (4-5)^2 = (-1)^2 = 1 && (9-5)^2 = 4^2 = 16. \\ \end{array} [/Tex]

[Tex]variance = \frac{9 + 1 + 1 + 1 + 0 + 0 + 4 + 16}{8} = 4. [/Tex]

[Tex]standard deviation = \sqrt{ 4 } = 2 [/Tex]

If we add 7 to all numbers, standard deviation won't change
as 7 is added to mean also. So Q is FALSE.

If we double all entries, standard deviation also becomes
double.  So S is false. 
References: https://en.wikipedia.org/wiki/Standard_deviation http://staff.argyll.epsb.ca/jreed/math30p/statistics/standardDeviation.htm
 Question 65
Given the sequence of terms, AD CG FK JP, the next term is
 A OV B OW C PV D PW
GATE CS 2012    General Aptitude
Discuss it

Question 65 Explanation:
Here 1st letter of each term in order are: A C F J Now In alphabets, A and C have a difference of 1 alphabet, C and F have a difference of 2, and F and J have a difference of 3. Hence next term here should contain its 1st letter as an alphabet with a difference of 4 after J, i.e O. Similarly, 2nd letter of each term in order are: D G K P Now In alphabets, D and G have a difference of 2 alphabets, G and K have a difference of 3, and K and P have a difference of 4. Hence next term here should contain its 2nd letter as an alphabet with a difference of 5 after P, i.e V.
There are 65 questions to complete.

## GATE CS Corner

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.