Question 1
Let G = (V,E) be a graph. Define ξ(G) = Σd id x d, where id is the number of vertices of degree d in G. If S and T are two different trees with ξ(S) = ξ(T),then
 A |S| = 2|T| B |S| = |T|-1 C |S| = |T| D |S| = |T|+1
GATE CS 2010    Graph Theory
Discuss it

Question 1 Explanation:
The expression ξ(G) is basically sum of all degrees in a tree.   For example, in the following tree, the sum is 3 + 1 + 1 + 1.
    a
/ | \
b  c  d
Now the questions is, if sum of degrees in trees are same, then what is the relationship between number of vertices present in both trees? The answer is, ξ(G) and ξ(T) is same for two trees, then the trees have same number of vertices. It can be proved by induction. Let it be true for n vertices. If we add a vertex, then the new vertex (if it is not the first node) increases degree by 2, it doesn't matter where we add it. For example, try to add a new vertex say 'e' at different places in above example tee.
 Question 2
Newton-Raphson method is used to compute a root of the equation x2-13=0 with 3.5 as the initial value. The approximation after one iteration is
 A 3.575 B 3.676 C 3.667 D 3.607
GATE CS 2010    Numerical Methods and Calculus
Discuss it

Question 2 Explanation:
In Newton-Raphson's method, We use the following formula to get the next value of f(x). f'(x) is derivative of f(x).
f(x)  =  x2-13
f'(x) =  2x

Applying the above formula, we get
Next x = 3.5 - (3.5*3.5 - 13)/2*3.5
Next x = 3.607

 Question 3
What is the possible number of reflexive relations on a set of 5 elements?
 A 210 B 215 C 220 D 225
GATE CS 2010    Combinatorics
Discuss it

Question 3 Explanation:
Number of reflexive relations is 2n2-n which is 220 for n = 5
 Question 4
Consider the set S = {1, ω, ω2}, where ω and w2 are cube roots of unity. If * denotes the multiplication operation, the structure (S, *) forms
 A A group B A ring C An integral domain D A field
GATE CS 2010    Set Theory & Algebra
Discuss it

Question 4 Explanation:
A group is a set of elements together with an operation that combines any two of its elements to form a third element also in the set while satisfying four conditions called the group axioms, namely closureassociativityidentity and invertibility. (Source: http://en.wikipedia.org/wiki/Group_(mathematics) (S, *)  is a group with identity as 1
 Question 5
What is the value of Limn->∞(1-1/n)2n ?
 A 0 B e-2 C e-1/2 D 1
GATE CS 2010    Numerical Methods and Calculus
Discuss it

Question 5 Explanation:
The value of e (mathematical constant) can be written as following   And the value of 1/e can be written as following. Limn-> ∞( 1-1/n)2n  =  (Limn-> ∞(1-1/n)n)2  =  e-2
 Question 6
The minterm expansion of f(P, Q, R) = PQ + QR' + PR' is
 A m2 + m4 + m6 + m7 B m0 + m1 + m3 + m5 C m0 + m1 + m6 + m7 D m2 + m3 + m4 + m5
GATE CS 2010    Digital Logic & Number representation
Discuss it

Question 6 Explanation:
 Question 7
A main memory unit with a capacity of 4 megabytes is built using 1M x 1-bit DRAM chips. Each DRAM chip has 1K rows of cells with 1K cells in each row. The time taken for a single refresh operation is 100 nanoseconds.The time required to perform one refresh operation on all the cells in the memory unit is
 A 100*210 nanoseconds B 100*220 nanoseconds C 3200*220 nanoseconds
GATE CS 2010    Computer Organization and Architecture
Discuss it

Question 7 Explanation:
Number of chips required for 4MB MM =
(4 * 2^20 * 8) / (1 * 2^20) = 32

Time required to refresh one chip = 2^20 * 100 ns.

Hence, time required to refresh MM = 32 * 2^20 * 100 ns
= 3200 * 2^20 ns 
 Question 8
P is a 16-bit signed integer. The 2's complement representation of P is (F87B)16.The 2's complement representation of 8*P
 A (C3D8)16 B (187B)16 C (F878)16 D (987B)16
GATE CS 2010    Number Representation
Discuss it

Question 8 Explanation:
P = (F87B)16 is -1111 1000 0111 1011 in bianry Note that most significant bit in the binary representation is 1, which implies that the number is negative. To get the value of the number perform the 2's complement of the number. We get P as -1925 and 8P as -15400 Since 8P is also negative, we need to find 2's complement of it (-15400) Binary of 15400 = 0011 1100 0010 1000 2's Complement = 1100 0011 1101 1000 = (C3D8)16
 Question 9
The Boolean expression for the output 'f' of the multiplexer shown below is
 A (P(XOR)Q(XOR)R)' B P(XOR)Q(XOR)R C (P+Q+R)' D P+Q+R
GATE CS 2010    Digital Logic & Number representation
Discuss it

Question 9 Explanation:
For 4 to 1 mux truth table SEL                  INPUT                 O/P
 Q P R R’ R’ R F 0 0 X X X 1 1 0 1 X X 1 X 1 1 0 X 1 X X 1 1 1 1 X X X 1
p’q’r+p’qr’+pq’r’+pqr pXORqXORr
 Question 10
What does the following program print?
#include
void f(int *p, int *q)
{
p = q;
*p = 2;
}
int i = 0, j = 1;
int main()
{
f(&i, &j);
printf("%d %d \n", i, j);
getchar();
return 0;
}

 A 2 2 B 2 1 C 0 1 D 0 2
Pointer Basics    GATE CS 2010
Discuss it

Question 10 Explanation:
/* p points to i and q points to j */
void f(int *p, int *q)
{
p = q;    /* p also points to j now */
*p = 2;   /* Value of j is changed to 2 now */
}

 Question 11
Two alternative packages A and B are available for processing a database having 10k records.Package A requires 0.0001n2 time units and package B requires 10nlog10n time units to process n records.What is the smallest value of k for which package B will be preferred over A?
 A 12 B 10 C 6 D 5
GATE CS 2010    Numerical Methods and Calculus
Discuss it

Question 11 Explanation:
B must be preferred on A when the time taken taken by B is more than A, i.e.,
0.0001 n2 < 10 n log10n
10-5n  < log10n
 Question 12
In a binary tree with n nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child?
 A 0 B 1 C (n-1)/2 D n-1
Binary Trees    GATE CS 2010
Discuss it

Question 12 Explanation:
It is mentioned that each node has odd number of descendants including node itself, so all nodes must have even number of descendants 0, 2, 4 so on. Which means each node should have either 0 or 2 children. So there will be no node with 1 child. Hence 0 is answer. Following are few examples.
       a
/    \
b      c

a
/   \
b     c
/  \
d    e
Such a binary tree is full binary tree (a binary tree where every node has 0 or 2 children).
 Question 13
Which data structure in a compiler is used for managing information about variables and their attributes?
 A Abstract syntax tree B Symbol table C Semantic stack D Parse Table
Misc    GATE CS 2010
Discuss it

Question 13 Explanation:
Symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is associated with information relating to its declaration or appearance in the source, such as its type, scope level and sometimes its location (Source: http://en.wikipedia.org/wiki/Symbol_table)
 Question 14
Which languages necessarily need heap allocation in the runtime environment?
 A Those that support recursion B Those that use dynamic scoping C Those that allow dynamic data structures D Those that use global variables
GATE CS 2010    Principles of Programming Languages
Discuss it

Question 14 Explanation:
Heap allocation is needed for dynamic data structures like tree, linked list, etc.
 Question 15
One of the header fields in an IP datagram is the Time to Live(TTL)field.Which of the following statements best explains the need for this field?
 A It can be used to prioritize packets B It can be used to reduce delays C It can be used to optimize throughput D It can be used to prevent packet looping
GATE CS 2010    Network Layer
Discuss it

Question 15 Explanation:
Time to Live can be thought as an upper bound on the time that an IP datagram can exist in the network. The purpose of the TTL field is to avoid a situation in which an undeliverable datagram keeps circulating.
 Question 16
Which one of the following is not a client server application?
 A Internet chat B Web browsing C E-mail D ping
GATE CS 2010    Misc Topics in Computer Networks
Discuss it

Question 16 Explanation:
Ping is not a client server application. Ping is a computer network administration utility used to test the reachability of a host on an Internet Protocol (IP). In ping, there is no server that provides a service.
 Question 17
Let L1 be a recursive language. Let L2 and L3 be languages that are recursively enumerable but not recursive. Which of the following statements is not necessarily true? (A) L2 – L1 is recursively enumerable. (B) L1 – L3 is recursively enumerable (C) L2 ∩ L1 is recursively enumerable (D) L2 ∪ L1 is recursively enumerable
 A A B B C C D D
GATE CS 2010    Recursively enumerable sets and Turing machines
Discuss it

Question 17 Explanation:
A) Always True
(Recursively enumerable - Recursive ) is
Recursively enumerable

B) Not always true
L1 - L3 = L1 intersection ( Complement L3 )
L1 is recursive , L3 is recursively enumerable
but not recursive Recursively enumerable languages
are NOT closed under complement.

C) and D) Always true Recursively enumerable languages
are closed under intersection and union. 
 Question 18
Consider a B+-tree in which the maximum number of keys in a node is 5. What is the minimum number of keys in any non-root node?
 A 1 B 2 C 3 D 4
GATE CS 2010     File structures (sequential files, indexing, B and B+ trees)
Discuss it

Question 18 Explanation:
This solution is contributed by Anil Saikrishna Devarasetty Another one: Since the maximum number of keys is 5, maximum number of children a node can have is 6. By definition of B Tree, minimum children that a node can have would be 6/2 = 3. Therefore, minimum number of keys that a node can have becomes 2 (3-1).
 Question 19
A relational schema for a train reservation database is given below. Passenger (pid, pname, age) Reservation (pid, class, tid)
Table: Passenger
pid   pname   age
-----------------
0    Sachin   65
1    Rahul    66
2    Sourav   67
3    Anil     69

Table : Reservation
pid  class  tid
---------------
0    AC   8200
1    AC   8201
2    SC   8201
5    AC   8203
1    SC   8204
3    AC   8202
What pids are returned by the following SQL query for the above instance of the tables?
SLECT pid
FROM Reservation ,
WHERE class ‘AC’ AND
EXISTS (SELECT *
FROM Passenger
WHERE age > 65 AND
Passenger. pid = Reservation.pid)
 A 1, 0 B 1, 2 C 1, 3 D 1, 5
GATE CS 2010    SQL
Discuss it

Question 19 Explanation:
When a subquery uses values from outer query, the subquery is called correlated subquery. The correlated subquery is evaluated once for each row processed by the outer query. The outer query selects 4 entries (with pids as 0, 1, 5, 3) from Reservation table. Out of these selected entries, the subquery returns Non-Null values only for 1 and 3.
 Question 20
Which of the following concurrency control protocols ensure both conflict serialzability and freedom from deadlock? I. 2-phase locking II. Time-stamp ordering
 A I only B II only C Both I and II D Neither I nor II
GATE CS 2010    Transactions and concurrency control
Discuss it

Question 20 Explanation:

2 Phase Locking (2PL) is a concurrency control method that guarantees serializability. The protocol utilizes locks, applied by a transaction to data, which may block (interpreted as signals to stop) other transactions from accessing the same data during the transaction’s life. 2PL may be lead to deadlocks that result from the mutual blocking of two or more transactions. See the following situation, neither T3 nor T4 can make progress.

Timestamp-based concurrency control algorithm is a non-lock concurrency control method. In Timestamp based method, deadlock cannot occur as no transaction ever waits.

 Question 21
The cyclomatic complexity of each of the modules A and B shown below is 10. What is the cyclomatic complexity of the sequential integration shown on the right hand side?
 A 19 B 21 C 20 D 10
GATE CS 2010    Software Engineering
Discuss it

Question 21 Explanation:
Cyclomatic Complexity of module = Number of decision points + 1

Number of decision points in A = 10 - 1 = 9
Number of decision points in B = 10 - 1 = 9
Cyclomatic Complexity of the integration = Number of decision points + 1
= (9 + 9) + 1
= 19

 Question 22
What is the appropriate pairing of items in the two columns listing various activities encountered in a software life cycle?
P. Requirements Capture	 1.Module Development and Integration
Q. Design	         2.Domain Analysis
R. Implementation	 3.Structural and Behavioral Modeling
S. Maintenance	         4.Performance Tuning
 A P-3, Q-2, R-4, S-1 B P-2, Q-3, R-1, S-4 C P-3, Q-2, R-1, S-4 D P-2, Q-3, R-4, S-1
GATE CS 2010    Software Engineering
Discuss it

Question 22 Explanation:
Module Development and Integration is clearly implementation work Performance Tuning is clearly maintenance work Domain Analysis is clearly Requirements Capture
 Question 23
Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.
Method Used by P1
while (S1 == S2) ;
Critica1 Section
S1 = S2;

Method Used by P2
while (S1 != S2) ;
Critica1 Section
S2 = not (S1);
Which one of the following statements describes the properties achieved?
 A Mutual exclusion but not progress B Progress but not mutual exclusion C Neither mutual exclusion nor progress D Both mutual exclusion and progress
Process Management    GATE CS 2010
Discuss it

Question 23 Explanation:
Mutual Exclusion: A way of making sure that if one process is using a shared modifiable data, the other processes will be excluded from doing the same thing. while one process executes the shared variable, all other processes desiring to do so at the same time moment should be kept waiting; when that process has finished executing the shared variable, one of the processes waiting; while that process has finished executing the shared variable, one of the processes waiting to do so should be allowed to proceed. In this fashion, each process executing the shared data (variables) excludes all others from doing so simultaneously. This is called Mutual Exclusion. Progress Requirement: If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then the selection of the processes that will enter the critical section next cannot be postponed indefinitely. Solution: It can be easily observed that the Mutual Exclusion requirement is satisfied by the above solution, P1 can enter critical section only if S1 is not equal to S2, and P2 can enter critical section only if S1 is equal to S2. But here Progress Requirement is not satisfied. Suppose when s1=1 and s2=0 and process p1 is not interested to enter into critical section but p2 want to enter critical section. P2 is not able to enter critical section in this as only when p1 finishes execution, then only p2 can enter (then only s1 = s2 condition be satisfied). Progress will not be satisfied when any process which is not interested to enter into the critical section will not allow other interested process to enter into the critical section. Reference : http://www.personal.kent.edu/~rmuhamma/OpSystems/Myos/mutualExclu.htm See http://www.geeksforgeeks.org/operating-systems-set-7/ This solution is contributed by Nitika Bansal
 Question 24
A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded to begin with. The system first accesses 100 distinct pages in some order and then accesses the same 100 pages but now in the reverse order. How many page faults will occur?
 A 196 B 192 C 197 D 195
Memory Management    GATE CS 2010
Discuss it

Question 24 Explanation:
 Question 25
Which of the following statements are true?
I. Shortest remaining time first scheduling may cause starvation
II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
 A I only B I and III only C II and III only D I, II and III
GATE CS 2010    CPU Scheduling
Discuss it

Question 25 Explanation:
I) Shortest remaining time first scheduling is a pre-emptive version of shortest job scheduling. In SRTF, job with the shortest CPU burst will be scheduled first. Because of this process, It may cause starvation as shorter processes may keep coming and a long CPU burst process never gets CPU. II) Pre-emptive just means a process before completing its execution is stopped and other process can start execution. The stopped process can later come back and continue from where it was stopped. In pre-emptive scheduling, suppose process P1 is executing in CPU and after some time process P2 with high priority then P1 will arrive in ready queue then p1 is pre-empted and p2 will brought into CPU for execution. In this way if process which is arriving in ready queue is of higher priority then p1, then p1 is always pre-empted and it may possible that it suffer from starvation. III) round robin will give better response time then FCFS ,in FCFS when process is executing ,it executed up to its complete burst time, but in round robin it will execute up to time quantum. So Round Robin Scheduling improves response time as all processes get CPU after a specified time. So, I,II,III are true which is option (D). Option (D) is correct answer. Reference: https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/5_CPU_Scheduling.html http://www.geeksforgeeks.org/operating-systems-set-7/ This solution is contributed by Nitika Bansal
 Question 26
Consider a company that assembles computers. The probability of a faulty assembly of any computer is p. The company therefore subjects each computer to a testing process.This testing process gives the correct result for any computer with a probability of q. What is the probability of a computer being declared faulty?
 A pq + (1 - p)(1 - q) B (1 - q) p C (1 - p) q D pq
GATE CS 2010    Probability
Discuss it

Question 26 Explanation:
A computer can be declared faulty in two cases
1) It is actually faulty and correctly declared so (p*q)
2) Not faulty and incorrectly declared (1-p)*(1-q). 
 Question 27
What is the probability that divisor of 1099 is a multiple of 1096?
 A 1/625 B 4/625 C 12/625 D 16/625
GATE CS 2010    Probability
Discuss it

Question 27 Explanation:
Following are multiples of 1096 which are also divisor of 1099 1096, 2x1096, 4x1096, 5x1096, 8x1096, 10x1096, 20x1096, 25x1096, 40x1096, 50x1096, 10x1096, 125x1096, 200x1096, 250x1096, 500x1096, 1000x1096 The total number of divisors of 1099 = 10000  (See http://www.math.cmu.edu/~mlavrov/arml/13-14/number-theory-09-29-13.pdf) So the probability = 16/10000=1/625
 Question 28
The degree sequence of a simple graph is the sequence of the degrees of the nodes in the graph in decreasing order. Which of the following sequences can not be the degree sequence of any graph?
I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III. 7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1 
 A I and II B III and IV C IV only D II and IV
GATE CS 2010    Graph Theory
Discuss it

Question 28 Explanation:
A generic algorithm or method to solve this question is 1: procedure isV alidDegreeSequence(L) 2: for n in list L do 3: if L doesn’t have n elements next to the current one then return false 4: decrement next n elements of the list by 1 5: arrange it back as a degree sequence, i.e. in descending order 6: if any element of the list becomes negative then return false 7: return true Rationale behind this method comes from the properties of simple graph. Enumerating the f alse returns, 1) if L doesn’t have enough elements after the current one or 2) if any element of the list becomes negative, then it means that there aren’t enough nodes to accommodate edges in a simple graph fashion, which will lead to violation of either of the two conditions of the simple graph (no self-loops and no multiple-edges between two nodes), if not others. See http://www.geeksforgeeks.org/data-structures-and-algorithms-set-25/ This solution is contributed by Vineet Purswani. Another one: A degree sequence d1,d2,d2. . . dn of non negative integer is graphical if it is a degree sequence of a graph. We now introduce a powerful tool to determine whether a particular sequence is graphical due to Havel and Hakimi Havel–Hakimi Theorem : → According to this theorem, Let D be sequence the d1,d2,d2. . . dn with d1 ≥ d2 ≥ d2 ≥ . . . dn for n≥ 2 and di ≥ 0. → Then D0 be the sequence obtained by: → Discarding d1, and → Subtracting 1 from each of the next d1 entries of D. → That is Degree sequence D0 would be : d2-1, d2-1, d3-1 . . . , dd1+1 -1 . . . , dn → Then, D is graphical if and only if D0 is graphical. Now, we apply this theorem to given sequences: option I) 7,6,5,4,4,3,2,1 → 5,4,3,3,2,1,0 → 3,2,2,1,0,0 → 1,1,0,0,0 → 0,0,0,0 so its graphical. Option II) 6,6,6,6,3,3,2,2 → 5,5,5,2,2,1,2 ( arrange in ascending order) → 5,5,5,2,2,2,1 → 4,4,1,1,1,0 → 3,0,0,0,0 → 2,-1,-1,-1,0 but d (degree of a vertex) is non negative so its not a graphical. Option III) 7,6,6,4,4,3,2,2 → 5,5,3,3,2,1,1 → 4,2,2,1,1,0 → 1,1,0,0,0 → 0,0,0,0 so its graphical. Option IV) 8,7,7,6,4,2,1,1 , here degree of a vertex is 8 and total number of vertices are 8 , so it’s impossible, hence it’s not graphical. Hence only option I) and III) are graphic sequence and answer is option-D This solution is contributed by Nirmal Bharadwaj.
 Question 29
Consider the following matrix A = If the eigenvalues of A are 4 and 8, then
 A x=4, y=10 B x=5, y=8 C x=-3, y=9 D x=-4, y=10
GATE CS 2010    Linear Algebra
Discuss it

Question 29 Explanation:
 Question 30
Suppose the predicate F(x, y, t) is used to represent the statement that person x can fool person y at time t. which one of the statements below expresses best the meaning of the formula ∀x∃y∃t(¬F(x, y, t))?
 A Everyone can fool some person at some time B No one can fool everyone all the time C Everyone cannot fool some person all the time D No one can fool some person at some time
GATE CS 2010    Propositional and First Order Logic.
Discuss it

Question 30 Explanation:
∀ x ∃ y ∃ t(¬ F(x,y,t)) => ∀ x ¬(∀ y ∀ t F(x,y,t))
 Question 31
What is the Boolean expression for the output f of the combinational logic circuit of NOR gates given below?
 A (Q+R)' B (P+Q)' C (P+R) D (P+Q+R)'
GATE CS 2010    Digital Logic & Number representation
Discuss it

Question 31 Explanation:
Answer is Option A. The above question contains the NOR gates. Let's see what NOR gate does. If A and B are the two inputs to the NOR gate, the NOR gate gives (A+B)' as the output. Let's assign numbers to the Gates for the easy understanding.
In the 1st column there are 4 NOR Gates,
number them as 1 to 4 ( top to down).

In the 2nd column there are 2 NOR Gates,
number them as 5 and 6 ( top to down).

In the 3rd column there is only 1 NOR Gate,
number it as 7.

1st numbered Gate gives output as : ( P + Q )'
2nd numbered Gate gives output as : ( Q + R )'
3rd numbered Gate gives output as : ( P + R )'
4th numbered Gate gives output as : ( R + Q )'
5th numbered Gate gives output as :
(( P + Q )' + ( Q + R )')'
= ((P + Q)'' . ( Q + R )'') ( De Morgan's law)
= (P + Q ) . ( Q + R ) ( Idempotent Law, A'' = A)
= (PQ + PR + Q + QR )
= (Q(1 + P + R) + PR) = Q + PR ( as, 1 + " any
boolean expression" = 1 )

Similarly 6th numbered Gate gives output as : R + PQ
(as this time R is common here)

Now 7th numbered Gate gives output as :
((Q + PR) + (R + PQ))'
= (Q( 1+P) + R(1+P))'
= (Q+R)' 
 Question 32
In the sequential circuit shown below,if the initial value of the output Q1Q0 is 00,what are the next four values of Q1Q0?
 A 11, 10, 01, 00 B 10, 11, 01, 00 C 10, 00, 01, 11 D 11, 10, 00, 01
GATE CS 2010    Digital Logic & Number representation
Discuss it

Question 32 Explanation:
We have t flip flop Truth table of t flip flop
 t q 0 q 1 q’
So q0 always inverted as t=1 always So 1)q10=1 2)q0 =0 3)q0 =1 4)q0 =1 For q1 also t=1 always but clock is so we have to observe positive edge of clock I.e. when is q0 going from 0 -> 1 1)q1 =1 2)q1 =1 3)q1 =0 4)q1 =0 So final combination q0q1->(11,10,01,00) Ans (A)
 Question 33
A 5-stage pipelined processor has Instruction Fetch(IF),Instruction Decode(ID),Operand Fetch(OF),Perform Operation(PO)and Write Operand(WO)stages.The IF,ID,OF and WO stages take 1 clock cycle each for any instruction.The PO stage takes 1 clock cycle for ADD and SUB instructions,3 clock cycles for MUL instruction,and 6 clock cycles for DIV instruction respectively.Operand forwarding is used in the pipeline.What is the number of clock cycles needed to execute the following sequence of instructions?
     Instruction           Meaning of instruction
I0 :MUL R2 ,R0 ,R1	      R2 ¬ R0 *R1
I1 :DIV R5 ,R3 ,R4  	      R5 ¬ R3/R4
I2 :ADD R2 ,R5 ,R2	      R2 ¬ R5+R2
I3 :SUB R5 ,R2 ,R6	      R5 ¬ R2-R6
 A 13 B 15 C 17 D 19
GATE CS 2010    Computer Organization and Architecture
Discuss it

Question 33 Explanation:
Operand Forwarding : In this technique the value of operand is given to the concerned stage of dependent instruction before it is stored. In the above question, I2 is dependent on I0 and I1, and I3 is dependent on I2. Let's see this question with a time-space diagram. The above is a space-time diagram representing the pipeline in which the instructions gets executed. Instruction 0 is a MUL operation which take 3 clock cycles of CPU in the PO stage, and at any other stage it takes only 1 cycle. Instruction 1 is a DIV operation which take 6 clock cycles of CPU in the PO stage, and at any other stage it takes only 1 cycle. It can be noticed here that even when the OF stage was free in the 4th clock cycle, then also the instruction 1 was not given to it. This is a design issue. The operands should be fetched only if they are going to get operated or executed in the next cycle, else there is a possibility of data corruption. As PO stage was not free in the next cycle hence OF was delayed and was done for instruction 1 only just before 1 cycle of going to PO stage. Instruction 2 is an ADD operation which take 1 clock cycles of CPU in all stages. But it is a dependent operation. it needs the operands which are provided by Instruction 0 and 1. Instruction 2 needs R5 and R2 to add, it gets R2 on time, because till the time Instruction 2 reaches its PO stage R2 would have been stored in memory. Now R5 is also needed, but Instruction 2's PO and Instruction 1's WO are in parallel. That means Instruction 2 can't take the value of R5 before it is stored by Instruction 1. So here comes the concept of Operand Forwarding. Before Instruction 1 store it's result/value which is R5, it can first forward it to instruction 2's Fetch-Execute Buffer, so that Instruction 2 can also use it in parallel to Instruction's WO stage. This will save extra clock cycles required( if Operand forwarding is not used, and R5 need to be taken from memory). In Instruction 3, same operand forwarding concept is applied for the value of R2 which is computed by Instruction 2. Hence operand forwarding saved 2 extra clock cycles here. ( 1 cycle in Instruction 2 and 1 cycle in Instruction 3). So the total no of cycles are 15, which can be seen from the diagram, each instance of the stage represents 1 clock cycle. So total 15.
 Question 34
The weight of a sequence a0, a1, ..., an-1 of real numbers is defined as a0+a1/2+...+ aa-1/2n-1. A subsequence of a sequence is obtained by deleting some elements from the sequence, keeping the order of the remaining elements the same. Let X denote the maximum possible weight of a subsequence of a0, a1, ...,an-1 and Y the maximum possible weight of a subsequence of a1, a2, ...,an-1. Then X is equal to
 A max(Y, a0+Y) B max(Y, a0+Y/2) C max(Y, a0+2Y) D a0+Y/2
GATE CS 2010    General Aptitude
Discuss it

Question 34 Explanation:
Using concepts of Dynamic Programming, to find the maximum possible weight of a subsequence of X, we will have two alternatives: 1. Do not include a0 in the subsequence: then the maximum possible weight will be equal to maximum possible weight of a subsequence of {a1, a2,....an} which is represented by Y 2. Include a0: then maximum possible weight will be equal to a0 + (each number picked in Y will get divided by 2) <=> a0 + Y/2. Here you can note that Y will itself pick optimal subsequence to maximize the weight. Final answer will be Max(Case1, Case2) i.e. Max(Y, a0 + Y/2). Hence B).
 Question 35
#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};
printf("%d", f(a, 6));
getchar();
return 0;
}
 A -9 B 5 C 15 D 19
Recursion    GATE CS 2010
Discuss it

Question 35 Explanation:
f() is a recursive function which adds f(a+1, n-1) to *a if *a is even. If *a is odd then f() subtracts f(a+1, n-1) from *a. See below recursion tree for execution of f(a, 6). .
 f(add(12), 6) /*Since 12 is first element. a contains address of 12 */
|
|
12 + f(add(7), 5) /* Since 7 is the next element, a+1 contains address of 7 */
|
|
|
|
|
|
|
|
|
|
6 + 0
So, the final returned value is 12 + (7 – (13 – (4 + (11 – (6 + 0))))) = 15
 Question 36
The following C function takes a simply-linked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank.
typedef struct node
{
int value;
struct node *next;
}Node;

{
Node *p, *q;
q = NULL; p = head;
while (p-> next !=NULL)
{
q = p;
p = p->next;
}
_______________________________
}

Choose the correct alternative to replace the blank line.
 A q = NULL; p->next = head; head = p; B q->next = NULL; head = p; p->next = head; C head = p; p->next = q; q->next = NULL; D q->next = NULL; p->next = head; head = p;
GATE CS 2010
Discuss it

Question 36 Explanation:
When the while loop ends, q contains address of second last node and p contains address of last node. So we need to do following things after while loop. i) Set next of q as NULL (q->next = NULL). ii) Set next of p as head (p->next = head). iii) Make head as p ( head = p) Step (ii) must be performed before step (iii). If we change head first, then we lose track of head node in the original linked list. See http://www.geeksforgeeks.org/move-last-element-to-front-of-a-given-linked-list/ for more details.
 Question 37
The program below uses six temporary variables a, b, c, d, e, f.

a = 1
b = 10
c = 20
d = a+b
e = c+d
f = c+e
b = c+e
e = b+f
d = 5+e
return d+f
Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling?
 A 2 B 3 C 4 D 6
GATE CS 2010    Computer Organization and Architecture
Discuss it

Question 37 Explanation:
All of the given expressions use at-most 3 variables, so we never nee more than 3 registers. See  http://en.wikipedia.org/wiki/Register_allocation It requires minimum 3 registers. Principle of Register Allocation : If a variable needs to be allocated to a register, the system checks for any free register available, if it finds one, it allocates. If there is no free register, then it checks for a register that contains a dead variable ( a variable whose value is not going to be used in future ), and if it finds one then it allocates. Otherwise it goes for Spilling ( it checks for a register whose value is needed after the longest time, saves its value into the memory, and then use that register for current allocation, later when the old value of the register is needed, the system gets it from the memory where it was saved and allocate it in any register which is available ). But here we should not apply spilling as directed in the question. Let's allocate the registers for the variables. a = 1 ( let's say register R1 is allocated for variable 'a' )   b = 10 ( R2 for 'b' , because value of 'a' is going to be used in the future, hence can not replace variable of 'a' by that of 'b' in R1)   c = 20 ( R3 for 'c', because values of 'a' and 'b' are going to be used in the future, hence can not replace variable 'a' or 'b' by 'c' in R1 or R2 respectively)   d = a+b ( now, 'd' can be assigned to R1 because R1 contains dead variable which is 'a' and it is so called because it is not going to be used in future, i.e. no subsequent expression uses the value of variable 'a')   e = c+d ( 'e' can be assigned to R1, because currently R1 contains value of varibale 'd' which is not going to be used in the subsequent expression.) Note: an already calculated value of a variable is used only by READ operation ( not WRITE), hence we have to see only on the RHS side of the subsequent expressions that whether the variable is going to be used or not.   f = c+e ( ' f ' can be assigned to R2, because vaule of 'b' in register R2 is not going to be used in subsequent expressions, hence R2 can be used to allocate for ' f ' replacing 'b' )   b = c+e ( ' b ' can be assigned to R3, because value of 'c' in R3 is not being used later )   e = b+f ( here 'e' is already in R1, so no allocation here, direct assignment )   d = 5+e ( 'd' can be assigned to either R1 or R3, because values in both are not used further, let's assign in R1 )   return d+f ( no allocation here, simply contents of registers R1 and R2 are added and returned)   hence we need only 3 registers, R1 R2 and R3.
 Question 38
The grammar S → aSa | bS | c is
 A LL(1) but not LR(1) B LR(1)but not LR(1) C Both LL(1)and LR(1) D Neither LL(1)nor LR(1)
GATE CS 2010    Parsing and Syntax directed translation
Discuss it

Question 38 Explanation:
First(aSa) = a
First(bS) = b
First(c) = c
All are mutually disjoint i.e no common terminal
between them, the given grammar is LL(1).

As the grammar is LL(1) so it will also be LR(1) as LR parsers are
more powerful then LL(1) parsers. and all LL(1) grammar are also LR(1)
So option C is correct. 
Below are more details. A grammar is LL(1) if it is possible to choose the next production by looking at only the next token in the input string.
Formally, grammar G is LL(1) if and only if
For all productions  A → α1 |  α2 | ... | αn,
First(αi) ∩ First(αj) =  ∅, 1 ≤ i,j  ≤ n,  i ≠ j.
For every non-terminal A such that First(A) contains ε,
First(A) ∩ Follow(A) = ∅ 
Source: https://s3-ap-southeast-1.amazonaws.com/erbuc/files/4147_870334aa-9922-4f78-9c2c-713e7a7f0d53.pdf
 Question 39
Let L={w \in (0 + 1)*|w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expression below represents L?
 A (0*10*1)* B 0*(10*10*)* C 0*(10*1*)*0* D 0*1(10*1)*10*
GATE CS 2010
Discuss it

Question 39 Explanation:
Option (A) is incorrect because it cannot accept “110″ Option (C) is incorrect because it accept a string with single 1. Option (D) is incorrect because it cannot accept 11101
 Question 40
Consider the languages L1 = {0i1j | i != j}. L2 = {0i1j | i = j}. L3 = {0i1j | i = 2j+1}. L4 = {0i1j | i != 2j}.
 A Only L2 is context free B Only L2 and L3 are context free C Only L1 and L2 are context free D All are context free
GATE CS 2010    Context free languages and Push-down automata
Discuss it

Question 40 Explanation:
All these languages have valid CFGs that can derive them. Hence, all of them are CFLs. Intuitively, (A) & (B) are well known CFLs and CFGs for (C) & (D) could be made by little modifications in A & B’s CFGs.     This solution is contributed by vineet purswani.
 Question 41
Let w be any string of length n is {0,1}*. Let L be the set of all substrings of w. What is the minimum number of states in a non-deterministic finite automaton that accepts L?
 A n-1 B n C n+1 D 2n-1
GATE CS 2010    Regular languages and finite automata
Discuss it

Question 41 Explanation:
We need minimum n+1 states to build NFA that accepts all substrings of a binary string. For example, following NFA accepts all substrings of “010″ and it has 4 states.
 Question 42
Consider the following schedule for transactions T1, T2 and T3: Which one of the schedules below is the correct serialization of the above?
 A T1->>T3->>T2 B T2->>T1->>T3 C T2->>T3->>T1 D T3->>T1->>T2
GATE CS 2010    Transactions and concurrency control
Discuss it

Question 42 Explanation:

T1 can complete before T2 and T3 as there is no conflict between Write(X) of T1 and the operations in T2 and T3 which occur before Write(X) of T1 in the above diagram.
T3 should can complete before T2 as the Read(Y) of T3 doesn’t conflict with Read(Y) of T2. Similarly, Write(X) of T3 doesn’t conflict with Read(Y) and Write(Y) operations of T2.
Another way to solve this question is to create a dependency graph and topologically sort the dependency graph. After topologically sorting, we can see the sequence T1, T3, T2.

 Question 43
Which of the following functional dependencies hold for relations R(A, B, C) and S(B, D, E):
B -> A
A -> C
The relation R contains 200 tuples and the rel ation S contains 100 tuples. What is the maximum number of tuples possible in the natural join of R and S (R natural join S)
 A 100 B 200 C 300 D 2000
GATE CS 2010
Discuss it

Question 43 Explanation:

From the given set of functional dependencies, it can be observed that B is a candidate key of R. So all 200 values of B must be unique in R. There is no functional dependency given for S. To get the maximum number of tuples in output, there can be two possibilities for S.
1) All 100 values of B in S are same and there is an entry in R that matches with this value. In this case, we get 100 tuples in output.
2) All 100 values of B in S are different and these values are present in R also. In this case also, we get 100 tuples.

 Question 44
The following program is to be tested for statement coverage:
begin
if (a== b) {S1; exit;}
else if (c== d) {S2;]
else {S3; exit;}
S4;
end 
The test cases T1, T2, T3 and T4 given below are expressed in terms of the properties satisfied by the values of variables a, b, c and d. The exact values are not given. T1 : a, b, c and d are all equal T2 : a, b, c and d are all distinct T3 : a = b and c != d T4 : a != b and c = d Which of the test suites given below ensures coverage of statements S1, S2, S3 and S4?
 A T1, T2, T3 B T2, T4 C T3, T4 D T1, T2, T4
GATE CS 2010    Software Engineering
Discuss it

Question 44 Explanation:
T1 checks S1

T2 checks S3

T4 checks S2 and S4
 Question 45
The following program consists of 3 concurrent processes and 3 binary semaphores.The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0. How many times will process P0 print '0'?
 A At least twice B Exactly twice C Exactly thrice D Exactly once
Process Management    GATE CS 2010
Discuss it

Question 45 Explanation:
Initially only P0 can go inside the while loop as S0 = 1, S1 = 0, S2 = 0. P0 first prints '0' then, after releasing S1 and S2, either P1 or P2 will execute and release S0. So 0 is printed again.
 Question 46
A system has n resources R0,...,Rn-1,and k processes P0,....Pk-1.The implementation of the resource request logic of each process Pi is as follows:
 if (i % 2 == 0) {
if (i < n) request Ri
if (i+2 < n) request Ri+2
}
else {
if (i < n) request Rn-i
if (i+2 < n) request Rn-i-2
}
In which one of the following situations is a deadlock possible?
 A n=40, k=26 B n=21, k=12 C n=20, k=10 D n=41, k=19
Discuss it

Question 46 Explanation:
Option B is answer

No. of resources, n = 21
No. of processes, k = 12

Processes {P0, P1....P11}  make the following Resource requests:
{R0, R20, R2, R18, R4, R16, R6, R14, R8, R12, R10, R10}

For example P0 will request R0 (0%2 is = 0 and 0< n=21).

Similarly, P10 will request R10.

P11 will request R10 as n - i = 21 - 11 = 10.

As different processes are requesting the same resource, deadlock
may occur. 
 Question 47
Suppose computers A and B have IP addresses 10.105.1.113 and 10.105.1.91 respectively and they both use the same netmask N. Which of the values of N given below should not be used if A and B should belong to the same network?
 A 255.255.255.0 B 255.255.255.128 C 255.255.255.192 D 255.255.255.224
Discuss it

Question 47 Explanation:
 Question 48
A computer system has an L1 cache, an L2 cache, and a main memory unit connected as shown below. The block size in L1 cache is 4 words. The block size in L2 cache is 16 words. The memory access times are 2 nanoseconds. 20 nanoseconds and 200 nanoseconds for L1 cache, L2 cache and main memory unit respectively. When there is a miss in L1 cache and a hit in L2 cache, a block is transferred from L2 cache to L1 cache. What is the time taken for this transfer?
 A 2 nanoseconds B 20 nanoseconds C 22 nanoseconds D 88 nanoseconds
GATE CS 2010    Computer Organization and Architecture
Discuss it

Question 48 Explanation:
A block to access in L2 cache requires 20 nanoseconds, and 2 seconds to place in L1-cache. The block size in L1 cache is 4 words and there are total 16 words, so total time is 4*(20+2) = 88.
 Question 49
Consider the data from above question. When there is a miss in both L1 cache and L2 cache, first a block is transferred from main memory to L2 cache, and then a block is transferred from L2 cache to L1 cache. What is the total time taken for these transfers?
 A 222 nanoseconds B 888 nanoseconds C 902 nanoseconds D 968 nanoseconds
GATE CS 2010    Computer Organization and Architecture
Discuss it

Question 49 Explanation:
Access time from main memory is 200. So total time to access is is 200+20 nanoseconds Similarly for L1 cache to access from L2 cache is 20+2 nanoseconds So total time is 4*(220 + 22) = 968 nanoseconds.
 Question 50
Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in the matrix W below is the weight of the edge {i, j}. What is the minimum possible weight of a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T?
 A 7 B 8 C 9 D 10
GATE CS 2010
Discuss it

Question 50 Explanation:
 Question 51
In the graph given in above question, what is the minimum possible weight of a path P from vertex 1 to vertex 2 in this graph such that P contains at most 3 edges?
 A 7 B 8 C 9 D 10
GATE CS 2010
Discuss it

Question 51 Explanation:
 Question 52
A hash table of length 10 uses open addressing with hash function h(k)=k mod 10, and linear probing. After inserting 6 values into an empty hash table, the table is as shown below. Which one of the following choices gives a possible order in which the key values could have been inserted in the table?
 A 46, 42, 34, 52, 23, 33 B 34, 42, 23, 52, 33, 46 C 46, 34, 42, 23, 52, 33 D 42, 46, 33, 23, 34, 52
GATE CS 2010
Discuss it

Question 52 Explanation:
 Question 53
Consider the data given in above question. How many different insertion sequences of the key values using the same hash function and linear probing will result in the hash table shown above?
 A 10 B 20 C 30 D 40
GATE CS 2010
Discuss it

Question 53 Explanation:
 Question 54
Consider a network with 6 routers R1 to R6 connected with links having weights as shown in the following diagram All the routers use the distance vector based routing algorithm to update their routing tables. Each router starts with its routing table initialized to contain an entry for each neighbour with the weight of the respective connecting link. After all the routing tables stabilize, how many links in the network will never be used for carrying any data?
 A 4 B 3 C 2 D 1
GATE CS 2010    Network Layer
Discuss it

Question 54 Explanation:
 Question 55
Consider the data given in above question. Suppose the weights of all unused links in the previous question are changed to 2 and the distance vector algorithm is used again until all routing tables stabilize. How many links will now remain unused?
 A 0 B 1 C 2 D 3
GATE CS 2010    Network Layer
Discuss it

Question 55 Explanation:
 Question 56
Choose the most appropriate word from the options given below to the complete the following sentence: His rather casual remarks on politics ___________ his lack of seriousness about the subject.
 A masked B belied C betrayed D suppressed
GATE CS 2010    English
Discuss it

Question 56 Explanation:
There should be word like showed or revealed or betrayed.
 Question 57
Which of the following options is closest in meaning to the word Circuitous.
 A cyclic B indirect C confusing D crooked
GATE CS 2010    English
Discuss it

Question 57 Explanation:
 Question 58
Choose the most appropriate word from the options given below to complete the following sentence: If we manage to ____________ our natural resources, we would leave a better planet for our children.
 A uphold B restrain C cherish D conserve
GATE CS 2010    English
Discuss it

Question 58 Explanation:
 Question 59
25 persons are in a room. 15 of them play hockey, 17 of them play football and 10 of them play both hockey and football. Then the number of persons playing neither hockey nor football is:
 A 2 B 17 C 13 D 3
GATE CS 2010    General Aptitude
Discuss it

Question 59 Explanation:
25 - (15+ 17-10)
 Question 60
The question below consists of a pair of related words followed by four pairs of words. Select the pair that best expresses the relation in the original pair. Unemployed: Worker
 A fallow: land B unaware: sleeper C wit: jester D renovated: house
GATE CS 2010    English
Discuss it

Question 60 Explanation:
A worker who is not working is called unemployed, similarly a land which is not used is called fallow.
 Question 61
Hari(H), Gita(G), Irfan(I) and Saira(S) are siblings (i.e., brothers and sisters). All were born on 1st January. The age difference between any two successive siblings (that is born one after another) is less than 3 years. Given the following facts:
i.  Hari's age + Gita's age > Irfan's age + Saira's age
ii. The age difference between Gita and Saira is 1 year. However Gita is not
the oldest and Saira is not the youngest.
iii. There are no twins. 
In what order were they born (oldest first)?
 A HSIG B SGHI C IGSH D IHSG
GATE CS 2010    General Aptitude
Discuss it

Question 61 Explanation:
H + G > I + S G - S = 1 OR S - G = 1 G is not the oldest and S is not the youngest. We need to try all options one by one.
 Question 62
Modern warfare has changed from large scale clashes of armies to suppression of civilian populations. Chemical agents that do their work silently appear to be suited to such warfare; and regretfully, there exist people in military establishments who think that chemical agents are useful tools for their cause. Which of the following statements best sums up the meaning of the above passage:
 A Modern warfare has resulted in civil strife. B Chemical agents are useful in modern warfare. C Use of chemical agents in warfare would be undesirable D People in military establishments like to use chemical agents in war.
GATE CS 2010    English
Discuss it

Question 62 Explanation:
Civil Strife means civil disorder, a term used to describe unrest caused by a group of people, which is not true in the light of the given passage. So, A is not the correct option. B is incorrect because there is no fact in the data justifying the usefulness of chemical agents for warfare. C is also incorrect because it is mentioned in the second line that chemical agents appear to be suited for such warfare, which implies that they are desirable. It is mentioned in the last line that there exist people in military establishments who think that chemical agents are useful for warfare, which makes D correct.
 Question 63
If 137 + 276 = 435 how much is 731 + 672?
 A 534 B 1403 C 1623 D 1513
GATE CS 2010    General Aptitude
Discuss it

Question 63 Explanation:
If we try adding the numbers directly (i.e. considering decimal)

1
137
+276
---
3

Since 7+6=13 and the given answer 435 has 5 in the one's place therefore the numbers are in base 8; Because 13 will correspond to 15 (7+8) in base 8 system. As shown: Now converting 731 and 672 in decimal 7x8^2 + 3x8^1 + 1x8^0 = 473 6x8^2 + 7x8^1 + 2x8^0 = 442 Adding 473 + 442 = 915 Converting 915 into base 8 = 1623 This explanation has been contributed by Kriti Kushwaha. More questions at: number-representation
 Question 64
5 skilled workers can build a wall in 20 days: 8 semi-skilled workers can build a wall in 25 days; 10 unskilled workers can build a wall in 30 days. If a team has 2 skilled, 6 semi-skilled and 5 unskilled workers, how long will it take to build the wall?
 A 20 B 10 C 16 D 15
GATE CS 2010    General Aptitude
Discuss it

Question 64 Explanation:
5 skilled workers can build a wall in 20 days 1 skilled worker can build the same wall in 100 days Capacity of each skilled worker is 1/100 8 semi-skilled workers can build a wall in 25 days 1 semi-skilled worker can build the same wall in 200 days Capacity of each semi-skilled worker is 1/200 Capacity of 1 unskilled worker is 1/300 Capacity of 2 skilled + 6 semi-skilled + 5 unskilled workers is 2(1/100) + 6(1/200) + 5/300 = 1/15
 Question 65
Given digits 2, 2, 3, 3, 3, 4, 4, 4, 4 how many distinct 4 digit numbers greater than 3000 can be formed?
 A 50 B 51 C 52 D 54
GATE CS 2010    General Aptitude
Discuss it

Question 65 Explanation:
First digit is either 3 or 4. We'll consider each case separately: (1) First digit is 3: Then the rest of the numbers must come from the list: 2, 2, 3, 3, 4, 4, 4, 4 Therefore we may choose any 3-digit sequence except 222 and 333 for the rest of the digits. This shows there are 3*3*3 - 2 = 25 numbers in this case. (2) First digit is 4: Then the rest of the numbers must come from the list 2, 2, 3, 3, 3, 4, 4, 4 Therefore we may choose any 3-digit sequence except 222 for the rest of the digits. This shows there are 3*3*3 - 1 = 26 numbers in this case. Now, the total number is just 25 + 26 = 51. Source: http://in.answers.yahoo.com/question/index?qid=20100216113008AANZGwP
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.