Question 1
Which one of the following in NOT necessarily a property of a Group?
 A Commutativity B Associativity C Existence of inverse for every element D Existence of identity
GATE-CS-2009    Set Theory & Algebra
Discuss it

Question 1 Explanation:
A group is a set, G, together with an operation • (called the group law of G) that combines any two elements a and b to form another element, denoted a • b or ab. To qualify as a group, the set and operation, (G, •), must satisfy four requirements known as the group axioms: Closure For all a, b in G, the result of the operation, a • b, is also in G.b Associativity For all a, b and c in G, (a • b) • c = a • (b • c). Identity element There exists an element e in G, such that for every element a in G, the equation e • a = a • e = a holds. Such an element is unique (see below), and thus one speaks of the identity element. Inverse element For each a in G, there exists an element b in G such that a • b = b • a = e, where e is the identity element. The result of an operation may depend on the order of the operands. In other words, the result of combining element a with element b need not yield the same result as combining element b with element a; the equation a • b = b • a may not always be true. This equation always holds in the group of integers under addition, because a + b = b + a for any two integers (commutativity of addition). Groups for which the commutativity equation a • b = b • a always holds are called abelian groups (in honor of Niels Abel) Source: http://en.wikipedia.org/wiki/Group_(mathematics)
 Question 2
What is the chromatic number of an n-vertex simple connected graph which does not contain any odd length cycle? Assume n >= 2.
 A 2 B 3 C n-1 D n
GATE-CS-2009    Graph Theory
Discuss it

Question 2 Explanation:
The chromatic number of a graph is the smallest number of colours needed to colour the vertices of so that no two adjacent vertices share the same colour. These types of questions can be solved by substitution with different values of n. 1) n = 2 This simple graph can be coloured with 2 colours. 2) n = 3 Here, in this graph let us suppose vertex A is coloured with C1 and vertices B, C can be coloured with colour C2 => chromatic number is 2 In the same way, you can check with other values, Chromatic number is equals to 2 This solution contributed by Anil Saikrishna Devarasetty //A simple graph with no odd cycles is bipartite graph and a Bipartite graph can be colored using 2 colors (See this)
 Question 3
Which one of the following is TRUE for any simple connected undirected graph with more than 2 vertices?
 A No two vertices have the same degree. B At least two vertices have the same degree. C At least three vertices have the same degree. D All vertices have the same degree.
GATE-CS-2009    Graph Theory
Discuss it

Question 3 Explanation:
Since the graph is simple, there must not be any self loop and parallel edges. Since the graph is connected, the degree of any vertex cannot be 0. Therefore, degree of all vertices should be be from 1 to n-1. So the degree of at least two vertices must be same.
 Question 4
Consider the binary relation R = {(x, y), (x, z), (z, x), (z, y)} on the set {x, y, z}. Which one of the following is TRUE?
 A R is symmetric but NOT antisymmetric B R is NOT symmetric but antisymmetric C R is both symmetric and antisymmetric D R is neither symmetric nor antisymmetric
GATE-CS-2009    Set Theory & Algebra
Discuss it

Question 4 Explanation:
R is not symmetric as (x, y) is present, but (y, x) is not present in R. R is also not antisymmetric as both (x, z) and (z, x) are present in R.
 Question 5
(1217)8 is equivalent to
 A (1217)16 B (028F)16 C (2297)10 D (0B17)16
GATE-CS-2009    Number Representation
Discuss it

Question 5 Explanation:
(1217)8 = (001 010 001 111)= (0010 1000 1111) = (28F)16
 Question 6
What is the minimum number of gates required to implement the Boolean function (AB+C)if we have to use only 2-input NOR gates?
 A 2 B 3 C 4 D 5
GATE-CS-2009    Digital Logic & Number representation
Discuss it

Question 6 Explanation:
AB+C = (A+C)(B+C) = ((A+C)' + (B+C)')' So, '3' 2-input NOR gates are required.
 Question 7
A CPU generally handles an interrupt by executing an interrupt service routine
 A As soon as an interrupt is raised B By checking the interrupt register at the end of fetch cycle. C By checking the interrupt register after finishing the execution of the current instruction. D By checking the interrupt register at fixed time intervals.
Input Output Systems    GATE-CS-2009
Discuss it

Question 7 Explanation:
Hardware detects interrupt immediately, but CPU acts only after its current instruction. This is followed to ensure integrity of instructions.
 Question 8
In which one of the following page replacement policies, Belady’s anomaly may occur?
 A FIFO B Optimal C LRU D MRU
Memory Management    GATE-CS-2009
Discuss it

Question 8 Explanation:
Belady’s anomaly proves that it is possible to have more page faults when increasing the number of page frames while using the First in First Out (FIFO) page replacement algorithm. See the wiki page for an example of increasing page faults with number of page frames.
 Question 9
The essential content(s) in each entry of a page table is / are
 A Virtual page number B Page frame number C Both virtual page number and page frame number D Access right information
Memory Management    GATE-CS-2009
Discuss it

Question 9 Explanation:

A page table entry must contain Page frame number. Virtual page number is typically used as index in page table to get the corresponding page frame number. See this for details.

 Question 10
What is the number of swaps required to sort n elements using selection sort, in the worst case? (A) (n) (B) (n log n) (C) (n^2 ) (D) (n^2 log n)
 A Theta(n) B Theta(nLogn) C Theta(n*n) D Theta(n*nLogn)
GATE-CS-2009
Discuss it

Question 10 Explanation:
Here is Selection Sort algorithm for sorting in ascending order.
   1. Find the minimum value in the list
2. Swap it with the value in the first position
3. Repeat the steps above for the remainder of the list (starting at
the second position and advancing each time)
As we can see from the algorithm, selection sort performs swap only after finding the appropriate position of the current picked element. So there are O(n) swaps performed in selection sort. Because swaps require writing to the array, selection sort is preferable if writing to memory is significantly more expensive than reading. This is generally the case if the items are huge but the keys are small. Another example where writing times are crucial is an array stored in EEPROM or Flash. There is no other algorithm with less data movement. References: http://en.wikipedia.org/wiki/Selection_sort
 Question 11
S -> aSa|bSb|a|b; The language generated by the above grammar over the alphabet {a,b} is the set of
 A All palindromes B All odd length palindromes. C Strings that begin and end with the same symbol D All even length palindromes
GATE-CS-2009    Context free languages and Push-down automata
Discuss it

Question 11 Explanation:
The possible palindrome generated by above grammar can be of odd length only as there is no rule for S -> [Tex]\epsilon[/Tex] For example generated palindromes are aba, aaa, bab, ababa, aaaaa, ..
 Question 12
Which of the following statement(s)is / are correct regarding Bellman-Ford shortest path algorithm?
P: Always finds a negative weighted cycle, if one exist s.
Q: Finds whether any negative weighted cycle is reachable
from the source. 
 A P Only B Q Only C Both P and Q D Neither P nor Q
Graph Shortest Paths    GATE-CS-2009
Discuss it

Question 12 Explanation:
Bellman-Ford shortest path algorithm is a single source shortest path algorithm. So it can only find cycles which are reachable from a given source, not any negative weight cycle. Consider a disconnected where a negative weight cycle is not reachable from the source at all. If there is a negative weight cycle, then it will appear in shortest path as the negative weight cycle will always form a shorter path when iterated through the cycle again and again.
 Question 13
Let pA be a problem that belongs to the class NP. Then which one of the following is TRUE?
 A There is no polynomial time algorithm for pA B If pA can be solved deterministically in polynomial time,then P = NP C If pA is NP-hard, then it is NP-complete. D pA may be undecidable.
GATE-CS-2009
Discuss it

Question 13 Explanation:

If a problem is both NP hard and NP, then it is NP Complete.  See http://www.geeksforgeeks.org/np-completeness-set-1/ for details.

 Question 14
Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*?
 A The set of all strings containing the substring 00. B The set of all strings containing at most two 0’s. C The set of all strings containing at least two 0’s. D The set of all strings that begin and end with either 0 or 1.
GATE-CS-2009    Regular languages and finite automata
Discuss it

Question 14 Explanation:
The regular expression has two 0′s surrounded by (0+1)* which means accepted strings must have at least 2 0′s.
 Question 15
Which one of the following is FALSE?
 A There is unique minimal DFA for every regular language B Every NFA can be converted to an equivalent PDA. C Complement of every context-free language is recursive. D Every nondeterministic PDA can be converted to an equivalent deterministic PDA.
GATE-CS-2009    Regular languages and finite automata
Discuss it

Question 15 Explanation:
Deterministic PDA cannot handle languages or grammars with ambiguity, but NDPDA can handle languages with ambiguity and any context-free grammar. So every nondeterministic PDA can not be converted to an equivalent deterministic PDA.
 Question 16
How many 32K x 1 RAM chips are needed to provide a memory capacity of 256K-bytes?
 A 8 B 32 C 64 D 128
GATE-CS-2009    Computer Organization and Architecture
Discuss it

Question 16 Explanation:
We need 256 Kbytes, i.e., 256 x 1024 x 8 bits. We have RAM chips of capacity 32 Kbits = 32 x 1024 bits. (256 * 1024 * 8)/(32 * 1024) = 64
 Question 17
Match all items in Group 1 with correct options from those given in Group 2.
Group 1                          Group 2
P. Regular expression        1. Syntax analysis
Q. Pushdown automata         2. Code generation
R. Dataflow analysis         3. Lexical analysis
S. Register allocation       4. Code optimization

 A P-4. Q-1, R-2, S-3 B P-3, Q-1, R-4, S-2 C P-3, Q-4, R-1, S-2 D P-2, Q-1, R-4, S-3
GATE-CS-2009    Parsing and Syntax directed translation
Discuss it

Question 17 Explanation:
Regular expressions are used in syntax analysis. Pushdown automata is related to context free grammar which is related to syntax analysis. Dataflow analysis is done in code optimization. Register allocation is done in code generation.
 Question 18
Output of following program?
#include <stdio.h>
int fun(int n, int *f_p)
{
int t, f;
if (n <= 1)
{
*f_p = 1;
return 1;
}
t = fun(n- 1,f_p);
f = t+ * f_p;
*f_p = t;
return f;
}

int main()
{
int x = 15;
printf (" %d \n", fun(5, &x));
return 0;
}

 A 6 B 8 C 14 D 15
Recursion    GATE-CS-2009
Discuss it

Question 18 Explanation:
Let x is stored at location 2468 i.e. &x = 2468

(dots are use just to ensure alignment)
x = 15
fun(5, 2468)
...{t = fun(4, 2468)
.......{t = fun(3, 2468)
...........{t = fun(2,2468)
...............{t = fun(1, 2468)
...................{// x=1
........................return 1}
................t = 1
................f = 2 //1+1 //since *f_p is x
................x = t = 1
................return 2}
...........t = 2
...........f = 2+1
...........x = t = 2
...........return 3}
........t = 3
........f = 3+2
........x = t = 3
........return 5}
....t = 5
....f = 5+3
....x = t = 5
....return 8}

which implies fun (5,2468) is 8.
 Question 19
The coupling between different modules of a software is categorized as follows:
   I.   Content coupling
II.  Common coupling
III. Control coupling
IV.  Stamp coupling
V.   Data coupling 
Coupling between modules can be ranked in the order of strongest (least desirable) to weakest (most desirable) as follows:
 A I-II-III-IV-V B V-IV-III-II-I C I-III-V -II-IV D IV-II-V-III-I
GATE-CS-2009    Software Engineering
Discuss it

Question 19 Explanation:
See http://en.wikipedia.org/wiki/Coupling_(computer_programming)
 Question 20
Consider the HTML t able definition given below:


< table border=1>
<tr>
<td rowspan=2> ab </td>
<td colspan=2> cd </td>
</tr>
<tr>
<td> ef </td>
<td rowspan=2> gh </td>
</tr>
<tr> <td colspan=2> ik </td>
</tr>
</table>


The number of rows in each column and the number of columns in each row are:
 A (2, 2, 3) and (2, 3, 2) B (2, 2, 3) and (2, 2, 3) C (2, 3, 2) and (2, 3, 2) D (2, 3, 2) and (2, 2, 3)
GATE-CS-2009    HTML and XML
Discuss it

Question 20 Explanation:
cd ab ef ij gh ab -> rowspan "2" cd -> colspan "2" 1st row closed <tr> is row <td> is data ef placed in 2nd row. gh is in same row but rowspan "2" 2nd row also closed. Move to 3rd row. Insert ij . its colspan "2". More information: [1]www.w3schools.com [2]http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_td
 Question 21
An unbalanced dice (with 6 faces, numbered from 1 to 6) is thrown. The probability that the face value is odd is 90% of the probability that the face value is even. The probability of getting any even numbered face is the same. If the probability that the face is even given that it is greater than 3 is 0.75, which one of the following options is closest to the probability that the face value exceeds 3?
 A 0.453 B 0.468 C 0.485 D 0.492
GATE-CS-2009    Probability
Discuss it

Question 21 Explanation:
Let Xi be the probability that the face value is i.

We can say that X1 + X2 + X3 + X4 + X5 + X6 = 1

It is given that  (X1 + X3 + X5) = 0.9*(X2 + X4 + X6)

It is also given that X2 = X4 = X6

Also given that (X4 + X6)/(X4 + X5 + X6) = 0.75

Solving the above equations, we can get X3 as 0.468 
 Question 22
For the composition table of a cyclic group shown below
 * a b c d a a b c d b b a d c c c d b a d d c a b
Which one of the following choices is correct?
 A a, b are generators B b, c are generators C c, d are generators D d, a are generators
GATE-CS-2009    Set Theory & Algebra
Discuss it

Question 22 Explanation:
Check for all:-
a1 = a ,
a2 = a * a = a
a3 = a2 * a = a * a = a
a is not the generator since we are not able to express
other members of the group in powers of a

Check for c -
c1 = c
c2 = c * c = b
c3 = c2 * c = b * c = d
c4 = c2 * c2 = b * b = a
We are able to generate all the members of the group from c ,
Hence c is the generator

Similarly check for d

 Question 23
Which one of the following is the most appropriate logical formula to represent the statement? "Gold and silver ornaments are precious". The following notations are used: G(x): x is a gold ornament S(x): x is a silver ornament P(x): x is precious
 A ∀x(P(x)→(G(x)∧S(x))) B ∀x((G(x)∧S(x))→P(x)) C ∃x((G(x)∧S(x))→P(x) D ∀x((G(x)∨S(x))→P(x))
GATE-CS-2009    Propositional and First Order Logic.
Discuss it

Question 23 Explanation:

=> This statement can be expressed as => For all X, x can be either gold or silver then the ornament X is precious => For all X, (G(X) v S(x)) => P(X).

This solution is contributed by Anil Saikrishna Devarasetty .

 Question 24
The binary operation c is defined as follows
 P Q PcQ T T T T F T F T F F F T
Which one of the following is equivalent to P∨Q?
A)

B)

C)

D) 
 A A B B C C D D
GATE-CS-2009    Propositional and First Order Logic.
Discuss it

Question 24 Explanation:
This solution is contributed by Anil Saikrishna Devarasetty.
 Question 25
is equivalent to
 A 0 B 1 C ln 2 D 1/2 ln 2
GATE-CS-2009    Numerical Methods and Calculus
Discuss it

Question 25 Explanation:
(1-tanx)/(1+tanx) = (cosx - sinx)/(cosx + sinx) Let cosx + sinx = t (-sinx + cosx)dx = dt (1/t)dt = ln t => ln(sinx + cosx) => ln(sin Π/4 + cos Π/4) => ln(1/√2 + 1/√2) => 1/2 ln 2
 Question 26
Which of the above two are equivalent?
 A I and III B I and IV C II and III D II and IV
GATE-CS-2009    Propositional and First Order Logic.
Discuss it

Question 26 Explanation:
 Question 27
Given the following state table of an FSM with two states A and B, one input and one output:
 Present State A Present State B Input Next State A Next State B Output 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 1
If the initial state is A=0, B=0, what is the minimum length of an input string which will take the machine to the state A=0, B=1 with Output = 1?
 A 3 B 4 C 5 D 6
GATE-CS-2009    Regular languages and finite automata
Discuss it

Question 27 Explanation:
//(0, 0) --1--> (0, 1) --0-->(1, 0) --1--> (0, 1) and output 1 According to the question we have to reach the states A=0, B=1 and output=1. This state is shown by green color. Thus to reach final states as A=0, B=1 and output=1 we have to reach previous states of A=1, B=0. Since initial states are A=0,B=0 (red); we provide input=1 (to reach A=0,B=1) Now this will give present states as A=0, B=1 and output=0. Now we provide (blue) input=0 (to reach A=1,B=0) with present states as A=0, B=1. The present states will become A=1, B=0 and output=0. This is what is required. On providing input=1 we get final states as A=0, B=1 and output=1. Hence an input string of 3 i.e. 101 leads to the desired output and states. This solution is contributed by Kriti Kushwaha
 Question 28
Consider a 4 stage pipeline processor.   The number of cycles needed by the four instructions I1, I2, I3, I4 in stages S1, S2, S3, S4 is shown below:
 S1 S2 S3 S4 I1 2 1 1 1 I2 1 3 2 2 I3 1 1 1 3 I4 1 2 2 2
What is the number of cycles needed to execute the following loop? For (i=1 to 2) {I1; I2; I3; I4;}
 A 16 B 23 C 28 D 30
GATE-CS-2009    Computer Organization and Architecture
Discuss it

Question 28 Explanation:
This question is different from other questions on pipeline with respect to the no of cycles taken by each instruction in each stage, i.e. an instruction here may take different no of cycles in different stages, and also that two instructions may take different no of cycles in the same stage as well. Therefore, here we have to consider two things : 1) Eligibility 2) Availability i.e. an instruction i should be eligible to be given to stage j, and a stage j should be available(free) to handle/process instruction i. Now, let's see how both the above things can be achieved. An instruction i will be eligible to be given to stage j, if and only if, the instruction i has completed stage j-1. Similarly, a Stage j will be available for instruction i, if and only if, the Stage j has completed instruction i-1. So, by following and fulfilling above two criteria we have to determine the total no of cycles taken by these instructions in a loop of 2 iterations. Note: An instruction i will be eligible for processing in iteration 2, if and only if, it has completed its processing in iteration 1.
 Question 29
Consider a 4-way set associative cache (initially empty) with total 16 cache blocks. The main memory consists of 256 blocks and the request for memory blocks is in the following order: 0, 255, 1, 4, 3, 8, 133, 159, 216, 129, 63, 8, 48, 32, 73, 92, 155. Which one of the following memory block will NOT be in cache if LRU replacement policy is used?
 A 3 B 8 C 129 D 216
GATE-CS-2009    Computer Organization and Architecture
Discuss it

Question 29 Explanation:
4 way set associative so 16 block will be divided in 4 sets of 4 blocks each. We apply(Address mod  4) function to decide set.
 Set 0 0 48 0 mod4=0 * 4 32 255 mod4=3 * 8 8 1 mod4=1 * 216 92 4 mod4=0 * Set 1 1 1 3 mod4=3 * 133 133 8 mod4=0 * 129 129 133 mod4=1 * 73 73 159 mod4=3 * Set 2 216 mod4=0 * 129 mod4=1 * 63 mod4=3 * 8 mod4=0 * Set 3 255 155 98 mod4=0 * 3 3 32 mod4=0 * 159 159 73 mod4=1 * 63 63 92 mod4=0 * 155 Mod4=3 *
All  * are misses S1 in the first stage ans S2 in the second. In the second stage 216 is not present in the cache. So (D) is correct option.
 Question 30
Consider a system with 4 types of resources R1 (3 units), R2 (2 units), R3 (3 units), R4 (2 units). A non-preemptive resource allocation policy is used. At any given instance, a request is not entertained if it cannot be completely satisfied. Three processes P1, P2, P3 request the sources as follows if executed independently.
Process P1:
t=0: requests 2 units of R2
t=1: requests 1 unit of R3
t=3: requests 2 units of R1
t=5: releases 1 unit of R2
and 1 unit of R1.
t=7: releases 1 unit of R3
t=8: requests 2 units of R4
t=10: Finishes

Process P2:
t=0: requests 2 units of R3
t=2: requests 1 unit of R4
t=4: requests 1 unit of R1
t=6: releases 1 unit of R3
t=8: Finishes

Process P3:
t=0: requests 1 unit of R4
t=2: requests 2 units of R1
t=5: releases 2 units of R1
t=7: requests 1 unit of R2
t=8: requests 1 unit of R3
t=9: Finishes
Which one of the following statements is TRUE if all three processes run concurrently starting at time t=0?
 A All processes will finish without any deadlock B Only P1 and P2 will be in deadlock. C Only P1 and P3 will be in a deadlock. D All three processes will be in deadlock
Discuss it

Question 30 Explanation:

We can apply the following Deadlock Detection algorithm and see that there is no process waiting indefinitely for a resource. See this for deadlock detection algorithm.

 Question 31
Consider a disk system with 100 cylinders. The requests to access the cylinders occur in following sequence: 4, 34, 10, 7, 19, 73, 2, 15, 6, 20 Assuming that the head is currently at cylinder 50, what is the time taken to satisfy all requests if it takes 1ms to move from one cylinder to adjacent one and shortest seek time first policy is used?
 A 95 ms B 119 ms C 233 ms D 276 ms
GATE-CS-2009
Discuss it

Question 31 Explanation:
4, 34, 10, 7, 19, 73, 2, 15, 6, 20 Since shortest seek time first policy is used, head will first move to 34. This move will cause 16*1 ms. After 34, head will move to 20 which will cause 14*1 ms. And so on. So cylinders are accessed in following order 34, 20, 19, 15, 10, 7, 6, 4, 2, 73 and total time will be (16 + 14 + 1 + 4 + 5 + 3 + 1 + 2 + 2 + 71)*1 = 119 ms.
 Question 32
In the following process state transition diagram for a uniprocessor system, assume that there are always some processes in the ready state: Now consider the following statements:
I. If a process makes a transition D, it would result in
another process making transition A immediately.
II. A process P2 in blocked state can make transition E
while another process P1 is in running state.
III. The OS uses preemptive scheduling.
IV. The OS uses non-preemptive scheduling.
Which of the above statements are TRUE?
 A I and II B I and III C II and III D II and IV
GATE-CS-2009    CPU Scheduling
Discuss it

Question 32 Explanation:
I is false. If a process makes a transition D, it would result in another process making transition B, not A. II is true. A process can move to ready state when I/O completes irrespective of other process being in running state or not. III is true because there is a transition from running to ready state. IV is false as the OS uses preemptive scheduling.
 Question 33
The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:
void enter_CS(X)
{
while test-and-set(X) ;
}
void leave_CS(X)
{
X = 0;
}
In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider the following statements: I. The above solution to CS problem is deadlock-free II. The solution is starvation free. III. The processes enter CS in FIFO order. IV More than one process can enter CS at the same time. Which of the above statements is TRUE?
 A I only B I and II C II and III D IV only
Process Management    GATE-CS-2009
Discuss it

Question 33 Explanation:
The above solution is a simple test-and-set solution that makes sure that deadlock doesn’t occur, but it doesn’t use any queue to avoid starvation or to have FIFO order.
 Question 34
A multilevel page table is preferred in comparison to a single level page table for translating virtual address to physical address because
 A It reduces the memory access time to read or write a memory location. B It helps to reduce the size of page table needed to implement the virtual address space of a process. C It is required by the translation lookaside buffer. D It helps to reduce the number of page faults in page replacement algorithms.
Memory Management    GATE-CS-2009
Discuss it

Question 34 Explanation:
The size of page table may become too big (See this) to fit in contiguous space. That is why page tables are typically divided in levels.
 Question 35
The running time of an algorithm is represented by the following recurrence relation:
    if  n <= 3  then   T(n) = n
else T(n) = T(n/3) + cn

Which one of the following represents the time complexity of the algorithm? <pre> (A) (n) (B) (n log n) (C) (n^2) (D) (n^2log n) </pre>
 A A B B C C D D
GATE-CS-2009
Discuss it

Question 35 Explanation:

T(n) = cn + T(n/3)
= cn + cn/3 + T(n/9)
= cn + cn/3 + cn/9 + T(n/27)
Taking the sum of infinite GP series. The value of T(n) will
be less than this sum.
T(n) <= cn(1/(1-1/3))
<= 3cn/2

or we can say
cn <= T(n) <= 3cn/2
Therefore T(n) = (n)

This can also be solved using Master Theorem for solving recurrences. The given expression lies in Case 3 of the theorem.

 Question 36
The keys 12, 18, 13, 2, 3, 23, 5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k) = k mod 10 and linear probing. What is the resultant hash table?
 A A B B C C D D
GATE-CS-2009
Discuss it

Question 36 Explanation:

To get the idea of open addressing concept, you can go through below lines from Wikipedia.

Open addressing, or closed hashing, is a method of collision resolution in hash tables. With this method a hash collision is resolved by probing, or searching through alternate locations in the array (the probe sequence) until either the target record is found, or an unused array slot is found, which indicates that there is no such key in the table. Well known probe sequences include:

linear probing in which the interval between probes is fixed–often at 1.
quadratic probing in which the interval between probes increases linearly (hence, the indices are described by a quadratic function).
double hashing in which the interval between probes is fixed for each record but is computed by another hash function.

 Question 37
What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a tree with a single node is 0.
 A 2 B 3 C 4 D 5
GATE-CS-2009
Discuss it

Question 37 Explanation:
AVL trees are binary trees with the following restrictions. 1) the height difference of the children is at most 1. 2) both children are AVL trees
                 a
/   \
/      \
b        c
/  \      /
/    \    /
d     e   g
/
/
h
References: http://en.wikipedia.org/wiki/AVL_tree
 Question 38
Consider the following graph: Which one of the following is NOT the sequence of edges added to the minimum spanning tree using Kruskal's algorithm?
 A (b,e)(e,f)(a,c)(b,c)(f,g)(c,d) B (b,e)(e,f)(a,c)(f,g)(b,c)(c,d) C (b,e)(a,c)(e,f)(b,c)(f,g)(c,d) D (b,e)(e,f)(b,c)(a,c)(f,g)(c,d)
Graph Minimum Spanning Tree    GATE-CS-2009
Discuss it

Question 38 Explanation:
In the sequence (b, e) (e, f) (b, c) (a, c) (f, g) (c, d) given option D, the edge (a, c) of weight 4 comes after (b, c) of weight 3. In Kruskal's Minimum Spanning Tree Algorithm, we first sort all edges, then consider edges in sorted order, so a higher weight edge cannot come before a lower weight edge.
 Question 39
In quick sort, for sorting n elements, the (n/4)th smallest element is selected as pivot using an O(n) time algorithm. What is the worst case time complexity of the quick sort? <pre> (A) (n) (B) (nLogn) (C) (n^2) (D) (n^2 log n) </pre>
 A A B B C C D D
Analysis of Algorithms    Sorting    GATE-CS-2009    QuickSort
Discuss it

Question 39 Explanation:
Answer(B) The recursion expression becomes: T(n) = T(n/4) + T(3n/4) + cn After solving the above recursion, we get \theta(nLogn).
 Question 40
Let L = L1  L2, where L1 and L2 are languages as defined below:
L1 = { | m, n >= 0 }
L2 = { | i, j, k >= 0 }
Then L is
 A Not recursive B Regular C Context free but not regular D Recursively enumerable but not context free.
GATE-CS-2009    Context free languages and Push-down automata
Discuss it

Question 40 Explanation:
The language L1 accept strings {c, abc, abcab, aabbcab, aabbcaabb, …} and L2 accept strings {a, b, c, ab, abc, aabc, aabbc, … }. Intersection of these two languages is L1 \cap L2 = {a^{k}b^{k}c | k >= 0} which is context free, but not regular.
 Question 41
The below DFA accepts the set of all strings over {0,1} that
 A begin either with 0 or 1 B end with 0 C end with 00 D contain the substring 00.
GATE-CS-2009
Discuss it

Question 41 Explanation:
If the strings beginning with 0 and 1 are 01 and 11 respectively, then the DFA doesn't accept these( because it doesn't reach to the final terminating/accepting state). Hence not option A. If the string ending with 0 is 10, then the DFA doesn't accept this also. Hence not option B. If the string which contains substring 00 is 1001, then the DFA doesn't accept this also. Hence not option D. Now, take any string which ends with 00, like 00, 100, 1100, 10100, 0100 all are accepted by the given DFA. Hence option C. Intuitively we can also observe here by looking at the DFA that there is only one direct path to reach the final terminating state C ( lets say given 3 states(circles) are A, B and C from left to right in the diagram ), then the path is A-->B-->C , and this path requires 00 in the current substring of the input to reach from A to C. Now after reaching C, either the string should terminate to be accepted by the given DFA, or it can also have any number of 0's following it, for the string to be accepted. In either of the case the string would be ending with 00.
 Question 42
Which of the following statements are TRUE?
I.  There exist parsing algorithms for some programming languages
whose complexities are less than O(n3).
II.  A programming language which allows recursion can be implemented
with static storage allocation.
III. No L-attributed definition can be evaluated in The framework
of bottom-up parsing.
IV. Code improving transformations can be performed at both source
language and intermediate code level.
 A I and II B I and IV C III and IV D I, III and IV
GATE-CS-2009    Parsing and Syntax directed translation
Discuss it

Question 42 Explanation:
II is false, in recursion, compiler cannot determine the space needed for recursive calls. III is false.  See http://www.cs.sunysb.edu/~cse304/Fall09/Lectures/attributes-handout.pdf
 Question 43
Consider two transactions T1 and T2, and four schedules S1, S2, S3, S4 of T1 and T2 as given below:
T1 = R1[X] W1[X] W1[Y]
T2 = R2[X] R2[Y] W2[Y]
S1 = R1[X] R2[X] R2[Y] W1[X] W1[Y] W2[Y]
S2 = R1[X] R2[X] R2[Y] W1[X] W2[Y] W1[Y]
S3 = R1[X] W1[X] R2[X] W1[Y] R2[Y] W2[Y]
S1 = R1[X] R2[Y]R2[X]W1[X] W1[Y] W2[Y]
Which of the above schedules are conflict-serializable?
 A S1 and S2 B S2 and S3 C S3 only D S4 only
GATE-CS-2009
Discuss it

Question 43 Explanation:
There can be two possible serial schedules T1 T2 and T2 T1. The serial schedule T1 T2 has the following sequence of operations R1[X] W1[X] W1[Y] R2[X] R2[Y] W2[Y] And the schedule T2 T1 has the following sequence of operations. R2[X] R2[Y] W2[Y] R1[X] W1[X] W1[Y] The Schedule S2 is conflict-equivalent to T2 T1 and S3 is conflict-equivalent to T1 T2
 Question 44
The following key values are inserted into a B+-tree in which order of the internal nodes is 3, and that of the leaf nodes is 2, in the sequence given below. The order of internal nodes is the maximum number of tree pointers in each node, and the order of leaf nodes is the maximum number of data items that can be stored in it. The B+-tree is initially empty. 10, 3, 6, 8, 4, 2, 1. The maximum number of times leaf nodes would get split up as a result of these insertions is
 A 2 B 3 C 4 D 5
GATE-CS-2009
Discuss it

Question 44 Explanation:
Please see the below image to see how many times a leaf node is splitted. We have marked all the leaf and root  nodes splits by *. I have used left biasing in B+ Tree construction as biasing is important in B+ tree because all the keys have to present at the leaf nodes. In a B+ tree, insertion always happens at the leaf level, because that is where all the data resides. The nodes above the leaf level contain only keys that serve to guide the search, which may be copies of actual keys. The leaf layer is often called a 'sequence set' whereas the internal nodes make up the 'index'. When a leaf splits, a suitable separator key(which is the middle one) is copied up into the index layer. In case you are not familiar with the insertion algorithm, check out the following link. www.cs.sjsu.edu/~lee/cs157b/Brian_Lee_B__Trees.ppt https://en.wikipedia.org/wiki/B%2B_tree In the image given below, there are total 5 splits out which 4 are leaf node splits. This solution is contributed by Pranjul Ahuja.
 Question 45
Let R and S be relational schemes such that R={a,b,c} and S={c}. Now consider the following queries on the database:
IV) SELECT R.a, R.b
FROM R,S
WHERE R.c=S.c
Which of the above queries are equivalent?
 A I and II B I and III C II and IV D III and IV
GATE-CS-2009    SQL
Discuss it

Question 45 Explanation:
I and II describe the division operator in Relational Algebra and Tuple Relational Calculus respectively. See Page 3 of this and slide numbers 9,10 of this for more details.
 Question 46
In the RSA public key cryptosystem, the private and public keys are (e, n) and (d, n) respectively, where n = p*q and p and q are large primes. Besides, n is public and p and q are private. Let M be an integer such that 0 < M < n and f(n) = (p- 1)(q-1). Now consider the following equations.

I.  M’= Me mod n
M = (M’)d mod n

II.  ed ≡ 1 mod n

III. ed ≡ 1 mod f(n)

IV. M’= Me mod f(n)
M = (M’)d mod f(n) 
Which of the above equations correctly represent RSA cryptosystem?
 A I and II B I and III C II and IV D III and IV
GATE-CS-2009    Network Security
Discuss it

Question 46 Explanation:
I is true because below is true in RSA-Cryptosystem.
Encrypted-Text = (Plain-Text)e mod n
Plain-Text = (Encrypted-Text)d mod n 
III is true because below is true
   d-1 = e mod ϕ(n)
OR ed = 1 mod ϕ(n) 
 Question 47
While opening a TCP connection, the initial sequence number is to be derived using a time-of-day(ToD) clock that keeps running even when the host is down. The low order 32 bits of the counter of the ToD clock is to be used for the initial sequence numbers. The clock counter increments once per millisecond. The maximum packet lifetime is given to be 64s. Which one of the choices given below is closest to the minimum permissible rate at which sequence numbers used for packets of a connection can increase?
 A 0.015/s B 0.064/s C 0.135/s D 0.327/s
GATE-CS-2009    Transport Layer
Discuss it

Question 47 Explanation:
The maximum packet lifetime is given to be 64 seconds in the question. Thus, a sequence number increments after every 64 seconds.
So, minimum permissible rate = 1 / 64 = 0.015 per second

Thus, option (A) is the answer.

Please comment below if you find anything wrong in the above post.
 Question 48
Let G(x) be the generator polynomial used for CRC checking. What is the condition that should be satisfied by G(x) to detect odd number of bits in error?
 A G(x) contains more than two terms B G(x) does not divide 1+x^k, for any k not exceeding the frame length C 1+x is a factor of G(x) D G(x) has an odd number of terms.
Discuss it

Question 48 Explanation:
Odd number of bit errors can be detected if G(x) contains (x+1) as a factor. See this for proof.
 Question 49
Which of the following statements are TRUE?
I. The context diagram should depict The system as
a single bubble.
II. External entities should be identified clearly
at all levels of DFDs.
III. Control information should not be represented
in a DFD.
IV. A data store can be connected either to another
data store or to an external entity.
 A II and III B II and III C I and III D I, II and III
GATE-CS-2009    Software Engineering
Discuss it

Question 49 Explanation:
The context diagram depict the system as a single bubble. Control information should not represent in DFD.
 Question 50
Consider the following statements about the cyclomatic complexity of the control flow graph of a program module. Which of these are TRUE?
I. The cyclomatic complexity of a module is equal to the maximum number of
linearly independent circuits in the graph.
II. The cyclomatic complexity of a module is the number of decisions in the
module plus one,where a decision is effectively any conditional statement
in the module.
III.The cyclomatic complexity can also be used as a number of linearly
independent paths that should be tested during path coverage testing. 
 A I and II B II and III C I and III D I, II and III
GATE-CS-2009    Software Engineering
Discuss it

Question 50 Explanation:
TRUE: The cyclomatic complexity of a module is the number of decisions in the
module plus one,where a decision is effectively any conditional statement
in the module.
TRUE: The cyclomatic complexity can also be used as a number of linearly
independent paths that should be tested during path coverage testing. 
 Question 51
A hard disk has 63 sectors per track, 10 platters each with 2 recording surfaces and 1000 cylinders. The address of a sector is given as a triple (c, h, s), where c is the cylinder number, h is the surface number and s is the sector number. Thus, the 0th sector is addressed as (0, 0, 0), the 1st sector as (0, 0, 1), and so on The address <400,16,29> corresponds to sector number:
 A 505035 B 505036 C 505037 D 505038
Input Output Systems    GATE-CS-2009
Discuss it

Question 51 Explanation:
Overview The data in hard disk is arranged in the shown manner. The smallest division is sector. Sectors are then combined to make a track. Cylinder is formed by combining the tracks which lie on same dimension of the platters. Read write head access the disk. Head has to reach at a particular track and then wait for the rotation of the platter so that the required sector comes under it. Here, each platter has two surfaces, which is the r/w head can access the platter from the two sides, upper and lower. So,<400,16,29> will represent 400 cylinders are passed(0-399) and thus, for each cylinder 20 surfaces (10 platters * 2 surface each) and each cylinder has 63 sectors per surface. Hence we have passed 0-399 =  400 * 20 * 63 sectors + In 400th cylinder we have passed 16 surfaces(0-15) each of which again contains 63 sectors per cylinder so 16 * 63 sectors. + Now on the 16th surface we are on 29th sector. So, sector no = 400x20x63 + 16×63 + 29 = 505037. Reference : https://www.ilbe.com/1144674842 This solution is contributed by Shashank Shanker khare.
 Question 52
Consider the data given in previous question. The address of the 1039th sector is
 A (0, 15, 31) B (0, 16, 30) C (0, 16, 31) D (0, 17, 31)
Input Output Systems    GATE-CS-2009
Discuss it

Question 52 Explanation:
You can also see the  image uploaded in previous question. (a) <0,15,31> 0th cylinder 15th surface and 31st sector So, 0 cylinders passed 0*20*63 As each cylinder has 20 surfaces and each surface has 63 sectors. + 15 surfaces passed (0-14) 15*63 As each surface has 63 sectors + We are on 31st sector So, sector no. =0*20*63+15*63+31=976 sector. Which is not equal to 1039. (b) <0,16,30> Similarly this represents, 0*20*63 + 16*63 (0-15 sectors and each sector has 63 sectors) + 30 sectors on 16th sector Sector no = 0*20*63+16*63+30=1038 sector which is not equal to 1039. (c) <0,16,31> Similarly this represents, 0*20*63 + 16*63 (0-15 sectors and each sector has 63 sectors) + 31 sectors on 16th sector Sector no = 0*20*63+16*63+31=1039 sector which is equal to 1039. Hence,option c is correct. (d) <0,17,31> Similarly this represents, 0*20*63 + 17*63 (0-16 sectors and each sector has 63 sectors) + 31 sectors on 17th sector Sector no = 0*20*63+17*63+31=1102 sector which is not equal to 1039.   This solution is contributed by Shashank Shanker khare.
 Question 53
A sub-sequence of a given sequence is just the given sequence with some elements (possibly none or all) left out. We are given two sequences X[m] and Y[n] of lengths m and n respectively, with indexes of X and Y starting from 0. We wish to find the length of the longest common sub-sequence(LCS) of X[m] and Y[n] as l(m,n), where an incomplete recursive definition for the function l(i,j) to compute the length of The LCS of X[m] and Y[n] is given below:
l(i,j) = 0, if either i=0 or j=0
= expr1, if i,j > 0 and X[i-1] = Y[j-1]
= expr2, if i,j > 0 and X[i-1] != Y[j-1] 
 A expr1 ≡ l(i-1, j) + 1 B expr1 ≡ l(i, j-1) C expr2 ≡ max(l(i-1, j), l(i, j-1)) D expr2 ≡ max(l(i-1,j-1),l(i,j))
Dynamic Programming    GATE-CS-2009
Discuss it

Question 53 Explanation:
In Longest common subsequence problem, there are two cases for X[0..i] and Y[0..j]
1) The last characters of two strings match.
The length of lcs is length of lcs of X[0..i-1] and Y[0..j-1]
2) The last characters don't match.
The length of lcs is max of following two lcs values
a) LCS of X[0..i-1] and Y[0..j]
b) LCS of X[0..i] and Y[0..j-1]

 Question 54
Consider the data given in the previous question. The values of l(i, j) could be obtained by dynamic programming based on the correct recursive definition of l(i, j) of the form given above, using an array L[M, N], where M = m+1 and N =n+1, such that L[i, j] = l(i, j). Which one of the following statements would be TRUE regarding the dynamic programming solution for the recursive definition of l(i, j)?
 A All elements L should be initialized to 0 for the values of l(i,j) to be properly computed B The values of l(i,j) may be computed in a row major order or column major order of L(M,N) C The values of l(i,j) cannot be computed in either row major order or column major order of L(M,N) D L[p,q] needs to be computed before L[r,s] if either p < r or q < s.
GATE-CS-2009
Discuss it

Question 54 Explanation:
The value can be computed either in row major or column major order, see http://www.geeksforgeeks.org/dynamic-programming-set-4-longest-common-subsequence/. We can swap the two loops without effecting the output.
 Question 55
Consider the following relational schema:
Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Consider the following relational query on the above database:
SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
WHERE C.pid NOT IN (SELECT P.pid
FROM Parts P
WHERE P.color<> 'blue'))
Assume that relations corresponding to the above schema are not empty. Which one of the following is the correct interpretation of the above query?
 A Find the names of all suppliers who have supplied a non-blue part. B Find the names of all suppliers who have not supplied a non-blue part. C Find the names of all suppliers who have supplied only blue parts. D Find the names of all suppliers who have not supplied only blue parts.
GATE-CS-2009    SQL
Discuss it

Question 55 Explanation:

The subquery “SELECT P.pid FROM Parts P WHERE P.color<> ‘blue’” gives pids of parts which are not blue. The bigger subquery “SELECT C.sid FROM Catalog C WHERE C.pid NOT IN (SELECT P.pid FROM Parts P WHERE P.color<> ‘blue’)” gives sids of all those suppliers who have supplied blue parts. The complete query gives the names of all suppliers who have supplied a non-blue part

 Question 56
Consider the following relational schema:
Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Assume that, in the suppliers relation above, each supplier and each street within a city has a unique name, and (sname, city) forms a candidate key. No other functional dependencies are implied other than those implied by primary and candidate keys. Which one of the following is TRUE about the above schema?
 A The schema is in BCNF B The schema is in 3NF but not in BCNF C The schema is in 2NF but not in 3NF D The schema is not in 2NF
GATE-CS-2009    Database Design(Normal Forms)
Discuss it

Question 56 Explanation:
A relation is in BCNF if for every one of its dependencies X → Y, at least one of the following conditions hold:
    X → Y is a trivial functional dependency (Y ⊆ X)
X is a superkey for schema R 
Since (sname, city) forms a candidate key, there is no non-tirvial dependency X → Y where X is not a superkey
 Question 57
Frames of 1000 bits are sent over a 10^6 bps duplex link between two hosts. The propagation time is 25ms. Frames are to be transmitted into this link to maximally pack them in transit (within the link). What is the minimum number of bits (i) that will be required to represent the sequence numbers distinctly? Assume that no time gap needs to be given between transmission of two frames.
 A i = 2 B i = 3 C i = 4 D i = 5
Discuss it

Question 57 Explanation:
Transmission delay for 1 frame = 1000/(10^6) = 1 ms Propagation time = 25 ms The sender can atmost transfer 25 frames before the first frame reaches the destination. The number of bits needed for representing 25 different frames = 5
 Question 58
Consider the data of previous question. Suppose that the sliding window protocol is used with the sender window size of 2^i where is the number of bits identified in the previous question and acknowledgments are always piggybacked. After sending 2^i frames, what is the minimum time the sender will have to wait before starting transmission of the next frame? (Identify the closest choice ignoring the frame processing time.)
 A 16ms B 18ms C 20ms D 22ms
Discuss it

Question 58 Explanation:
Size of sliding window = 2^5 = 32 Transmission time for a frame = 1ms Total time taken for 32 frames = 32ms The sender cannot receive acknoledgement before round trip time which is 50ms After sending 32 frames, the minimum time the sender will have to wait before starting transmission of the next frame = 50 – 32 = 18
 Question 59
Consider a binary max-heap implemented using an array. Which one of the following array represents a binary max-heap?
 A 25,12,16,13,10,8,14 B 25,14,13,16,10,8,12 C 25,14,16,13,10,8,12 D 25,14,12,13,10,8,16
GATE-CS-2009
Discuss it

Question 59 Explanation:
A tree is max-heap if data at every node in the tree is greater than or equal to it’s children’ s data. In array representation of heap tree, a node at index i has its left child at index 2i + 1 and right child at index 2i + 2.
           25
/      \
/          \
14            16
/  \           /  \
/      \       /     \
13     10      8       12
 Question 60
Consider the data given in above question. What is the content of the array after two delete operations on the correct answer to the previous question?
 A 14,13,12,10,8 B 14,12,13,8,10 C 14,13,8,12,10 D 14,13,12,8,10
GATE-CS-2009
Discuss it

Question 60 Explanation:
For Heap trees, deletion of a node includes following two operations. 1) Replace the root with last element on the last level. 2) Starting from root, heapify the complete tree from top to bottom..
Let us delete the two nodes one by one:
1) Deletion of 25:
Replace 25 with 12

12
/    \
/       \
14        16
/ \         /
/     \      /
13     10    8
Since heap property is violated for root (16 is greater than 12),
make 16 as root of the tree.

16
/     \
/        \
14         12
/ \         /
/   \       /
13     10    8
2) Deletion of 16:
Replace 16 with 8

8
/    \
/      \
14         12
/ \
/   \
13     10
Heapify from root to bottom.

14
/    \
/       \
8         12
/ \
/   \
13     10
14
/     \
/       \
13         12
/ \
/   \
8    10
There are 60 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.