## GATE-CS-2007

 Question 1
Consider the following two statements about the function f(x)=|x|
P. f(x) is continuous for all real values of x
Q. f(x) is differentiable for all real values of x 
Which of the following is TRUE?
 A P is true and Q is false. B P is false and Qis true. C Both P and Q are true D Both P and Q are false.
Numerical Methods and Calculus    GATE-CS-2007
Discuss it

Question 1 Explanation:
A function is continuous if for every value of 'x', we have a corresponding f(x). Here, for every x, we have f(x) which is actually the value of x itself, without the negative sign for x < 0.

But, the given function is not differentiable for x = 0 because for x < 0, the derivative is negative and for x > 0, the derivative is positive. So, the left hand derivative and right hand derivative do not match.

Hence, P is correct and Q is incorrect. Thus, A is the correct option.

Please comment below if you find anything wrong in the above post.
 Question 2
Let S be a set of nelements. The number of ordered pairs in the largest and the smallest equivalence relations on S are:
 A n and n B n2 and n C n2 and 0 D n and 1
Set Theory & Algebra    GATE-CS-2007
Discuss it

Question 2 Explanation:
Consider an example set, S = (1,2,3)

Equivalence property follows, reflexive, symmetric
and transitive

Largest ordered set are s x s =
{ (1,1) (1,2) (1,3) (2,1) (2,2) (2,3) (3,1) (3,2)
(3,3) } which are 9 which equal to 3^2 = n^2

Smallest ordered set are { (1,1) (2,2) ( 3,3)}
which are 3 and equals to n. number of elements.
 Question 3
What is the maximum number of different Boolean functions involving n Boolean variables?
 A n2 B 2n C 22n D 2n2
Combinatorics    GATE-CS-2007
Discuss it

Question 3 Explanation:
No of inputs sequences possible for a n variable Boolean function = 2n

Each input sequence can give either T or F as output ( 2 possible values )

So, Total no of Boolean functions are -

2X2X2X2X2X2X.............X2X2X2X2X2X2

<-------------------- 2n Times -------------->

22n

 Question 4
Let G be the non-planar graph with the minimum possible number of edges. Then G has
 A 9 edges and 5 vertices B 9 edges and 6 vertices C 10 edges and 5 vertices D 10 edges and 6 vertices
Graph Theory    GATE-CS-2007
Discuss it

Question 4 Explanation:
For a simple, connected, planar graph with v vertices and e edges, the following simple conditions hold: If v ≥ 3 then e ≤ 3v − 6; Note that the question is about non-planar graph G. Only option C doesn't follow above.   Alternate Explanation: We know that K5K5 (which has 10 edges and 5 vertices) and K3,3K3,3 (which has 9 edges and 6 vertices) are non-planar graphs. Since we are asked about minimum number of edges, answer should be k3,3k3,3 i.e. option (B) is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2007.html
 Question 5
Consider the DAG with Consider V = {1, 2, 3, 4, 5, 6}, shown below. Which of the following is NOT a topological ordering?
 A 1 2 3 4 5 6 B 1 3 2 4 5 6 C 1 3 2 4 6 5 D 3 2 4 1 6 5
Graph Traversals    GATE-CS-2007
Discuss it

Question 5 Explanation:
In option D, 1 appears after 2 and 3 which is not possible in Topological Sorting. In the given DAG it is directly visible that there is an outgoing edge from vertex 1 to vertex 2 and 3 hence 2 and 3 cannot come before vertex 1 so clearly option D is incorrect topological sort. But for questions in which it is not directly visible we should know how to find topological sort of a DAG. This solution is contributed by Parul sharma.
 Question 6
Which of the following problems is undecidable? [2007]
 A Membership problem for CFGs B Ambiguity problem for CFGs. C Finiteness problem for FSAs. D Equivalence problem for FSAs.
Undecidability    GATE-CS-2007
Discuss it

Question 6 Explanation:

A set is closed under an operation means when we operate an element of that set with that operator we get an element from that set.
Here, CFG generates a CFL and set of all CFLs is the set. But ambiguity is not an operation and hence we can never say that CFG is closed under such operation.
Only ambiguity problem for CFGs are undecidable.

Thus, option (B) is correct.

Please comment below if you find anything wrong in the above post.
 Question 7
Which of the following is TRUE?
 A Every subset of a regular set is regular. B Every finite subset of a non-regular set is regular. C The union of two non-regular sets is not regular. D Infinite union of finite sets is regular
Regular languages and finite automata    GATE-CS-2007
Discuss it

 Question 8
How many 3-to-8 line decoders with an enable input are needed to construct a 6-to-64 line decoder without using any other logic gates?
 A 7 B 8 C 9 D 10
Digital Logic & Number representation    GATE-CS-2007
Discuss it

Question 8 Explanation:
So total signals in=a, b, c, x, y, z  i.e. 6 And total output =8*8=64 hence required decoders (from fig.)=9  so ans is ( C) part.
 Question 9
Consider the following Boolean function of four variables: f(w,x,y,z) = ∑(1,3,4,6,9,11,12,14) The function is:
 A independent of one variables. B independent of two variables. C independent of three variables. D dependent on all the variables.
Digital Logic & Number representation    GATE-CS-2007
Discuss it

Question 9 Explanation:
On solving K-MAP we get ZX’+XZ’ so  it is independent of w,y Ans (B) part.
 Question 10
Consider a 4-way set associative cache consisting of 128 lines with a line size of 64 words. The CPU generates a 20-bit address of a word in main memory. The number of bits in the TAG, LINE and WORD fields arerespectively:
 A 9,6,5 B 7, 7, 6 C 7, 5, 8 D 9, 5, 6
Computer Organization and Architecture    GATE-CS-2007
Discuss it

Question 10 Explanation:
Here the number of sets = 128/4 = 32 (as it is 4 say set associative)

We have total 64 words then we need 6 bits to identify the word

So the line offset is 5 bits and the word offset is 6 bits

and the TAG = 20-(5+6) =9 bits

so it should be 9,5,6
 Question 11
Consider a disk pack with 16 surfaces, 128 tracks per surface and 256 sectors per track. 512 bytes of data are stored in a bit serial manner in a sector. The capacity of the disk pack and the number of bits required to specify a particular sector in the disk are respectively:
 A 256 Mbyte, 19 bits B 256 Mbyte, 28 bits C 512 Mbyte, 20 bits D 64 Gbyte, 28 bit
Input Output Systems    GATE-CS-2007
Discuss it

Question 11 Explanation:
 Question 12
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height h is:
 A 2h−1 B 2h−1 -1 C 2h+1-1 D 2h+1
Binary Trees    GATE-CS-2007
Discuss it

Question 12 Explanation:
 Question 13
The maximum number of binary trees that can be formed with three unlabeled nodes is:
 A 1 B 5 C 4 D 3
GATE-CS-2007
Discuss it

Question 13 Explanation:
 Question 14
Which of the following sorting algorithms has the lowest worst-case complexity?
 A Merge sort B Bubble Sort C Quick Sort D Selection Sort
GATE-CS-2007
Discuss it

Question 14 Explanation:
 Question 15
Consider the following segment of C-code:
  int j, n;
j = 1;
while (j <= n)
j = j*2; 
The number of comparisons made in the execution of the loop for any n > 0 is: Base of Log is 2 in all options.
 A CEIL(logn) + 2 B n C CEIL(logn) D FLOOR(logn) + 2
Analysis of Algorithms    GATE-CS-2007
Discuss it

Question 15 Explanation:
We can see it by taking few examples like n = 1, n = 3, etc.

For example, for n=5 we have the following (4) comparisons:
------------------------
1 <= 5 (T)
2 <= 5 (T)
4 <= 5 (T)
8 <= 5 (F)

------------------------
CEIL(log_2 n)+2 = CEIL(log_2 5) + 2 = CEIL(2.3) + 2 = 3 + 2 = 5
 Question 16
Group 1 contains some CPU scheduling algorithms and Group 2 contains some applications. Match entries in Group 1 to entries in Group 2.
     Group I                          Group II
(P) Gang Scheduling              (1) Guaranteed Scheduling
(Q) Rate Monotonic Scheduling    (2) Real-time Scheduling
(R) Fair Share Scheduling        (3) Thread Scheduling
 A P – 3 Q – 2 R – 1 B P – 1 Q – 2 R – 3 C P – 2 Q – 3 R – 1 D P – 1 Q – 3 R – 2
GATE-CS-2007    CPU Scheduling
Discuss it

Question 16 Explanation:
 Question 17
Consider the following statements about user level threads and kernel level threads. Which one of the following statement is FALSE?
 A Context switch time is longer for kernel level threads than for user level threads. B User level threads do not need any hardware support. C Related kernel level threads can be scheduled on different processors in a multi-processor system. D Blocking one kernel level thread blocks all related threads.
Process Management    GATE-CS-2007
Discuss it

Question 17 Explanation:
 Question 18
Which one of the following is a top-down parser?
 A Recursive descent parser. B Operator precedence parser. C An LR(k) parser. D An LALR(k) parser
Parsing and Syntax directed translation    GATE-CS-2007
Discuss it

Question 18 Explanation:
Recursive Descent parsing is LL(1) parsing which is top down parsing.
 Question 19
In Ethernet when Manchester encoding is used, the bit rate is:
 A Half the baud rate. B Twice the baud rate. C Same as the baud rate. D None of the above
Discuss it

Question 19 Explanation:
In Manchester encoding, the bitrate is half of the baud rate.
 Question 20
Which one of the following uses UDP as the transport protocol?
 A HTTP B Telnet C DNS D SMTP
Transport Layer    GATE-CS-2007
Discuss it

Question 20 Explanation:
UDP is a stateless ,connectionless and unreliable protocol. HTTP needs connection to be established and thus,uses TCP. Telnet is a byte stream protocol which again needs connection establishment ,thus uses TCP. DNS needs request and response ,it needs a protocol in which a server can answer the small queries of large number of users. As UDP is fast and stateless it is the most suitable protocol and thus,it is used in DNS querying . SMTP needs reliability and thus,uses TCP. This solution is contributed by Shashank Shanker khare //.............// DNS uses UDP. HTTP, Telnet and SMTP uses TCP. Thus, C is the correct choice.

Please comment below if you find anything wrong in the above post.
 Question 21
How many different non-isomorphic Abelian groups of order 4 are there
 A 2 B 3 C 4 D 5
Set Theory & Algebra    GATE-CS-2007
Discuss it

Question 21 Explanation:
2 can be written as 2 power 2.
Number of partitioning of 2 = no. of non isomorphic
abelian groups
2 can be partitioned as {(2),(1,1)}
 Question 22
Let Graph(x) be a predicate which denotes that x is a graph. Let Connected(x) be a predicate which denotes that x is connected. Which of the following first order logic sentences DOES NOT represent the statement: “Not every graph is connected”?
 A A B B C C D D
Propositional and First Order Logic.    GATE-CS-2007
Discuss it

Question 22 Explanation:
We need to find out first order logic sentence that DOES NOT
represent the statement: “Not every graph is connected”

Option B says "There exist some x such that x is a graph AND
not connected"
So B is right option.

Option A and option C are same G(x)-->C(x) can also be written
as ~G(x) or C(x), and they are the correct representation.
Option C says: There exists a graph and graph is not connected,
which is equivalent to given sentence.

Option D: Every x which is graph is not connected. 
 Question 23
Which of the following graphs has an Eulerian circuit?
 A Any k-regular graph where kis an even number. B A complete graph on 90 vertices C The complement of a cycle on 25 vertices D None of the above
Graph Theory    GATE-CS-2007
Discuss it

Question 23 Explanation:
A graph has Eulerian Circuit if following conditions are true. ….a) All vertices with non-zero degree are connected. We don’t care about vertices with zero degree because they don’t belong to Eulerian Cycle or Path (we only consider all edges). ….b) All vertices have even degree. Let us analyze all options. A) Any k-regular graph where k is an even number. is not Eulerian as a k regular graph may not be connected (property b is true, but a may not) B) A complete graph on 90 vertices is not Eulerian because all vertices have degree as 89 (property b is false) C) The complement of a cycle on 25 vertices is Eulerian. In a cycle of 25 vertices, all vertices have degree as 2. In complement graph, all vertices would have degree as 22 and graph would be connected.
 Question 24
Suppose we uniformly and randomly select a permutation from the 20! Permutations of 1, 2, 3 ,…..,20. What is the probability that 2 appears at an earlier position than any other even number in the selected permutation?
 A 1/2 B 1/10 C 9!/10! D Node of the above
Probability    GATE-CS-2007
Discuss it

Question 24 Explanation:
 Question 25
Let A be a 4 x 4 matrix with eigenvalues -5, -2, 1, 4. Which of the following is an eigenvalue of
[A  I]
[I  A] 
where I is the 4 x 4 identity matrix?
 A -5 B -7 C 2 D 1
GATE-CS-2007
Discuss it

Question 25 Explanation:

We find the eigenvalues of given matrix by solving its characteristic equation :

|(A – x I)2 – I2| = 0 |(A – (x – 1) I) * (A – (x + 1) I)| = 0 |(A – (x – 1) I)| * |(A – (x + 1) I)| = 0 So, |(A – (x – 1) I)| = 0 or |(A – (x + 1) I)| = 0
Let y be eigenvalues of A, then |(A – y I)| = 0 .
So, by comparing equations we get, either x – 1 = y or x + 1 = y
Therefore , x = y + 1 or x = y – 1
y = -5, -4, 1, 4 (given)
So, x = −4, −1, 2, 5, −6, −3, 0, 3

Thus, option (C) is the answer.

Please comment below if you find anything wrong in the above post.
 Question 26
 A A B B C C D D
Set Theory & Algebra    GATE-CS-2007
Discuss it

 Question 27
 A A B B C C D D
Set Theory & Algebra    GATE-CS-2007
Discuss it

Question 27 Explanation:
To be basis of subspace x, 2 conditions are to be fulfilled 1) They must span x 2) The vectors have to be linearly independent 1)the general solution of x1+x2+x3=0 is [-x2-x3 , x2 , x3]^T (Transpose) Which gives two linearly independent solutions by by assuming x2 = 1 and x3 = 0 and next x3 = 1 and x2 = 0 gives [-1,1,0]^T and [-1,0,1]^T respectively. Since both of these can be generated by linear combinations of [1,-1,0]^T & [-1,0,1]^T given in question, it span x. 2) Above set of column vector is linearly independent because one cannot be obtained from another by scalar multiplication (second method rank is 2..that is why linearly independent)
 Question 28
Consider the series Xn+1 = Xn/2 + 9/(8 Xn), X0 = 0.5 obtained from the Newton-Raphson method. The series converges to
 A 1.5 B sqrt(2) C 1.6 D 1.4
Numerical Methods and Calculus    GATE-CS-2007
Discuss it

Question 28 Explanation:
As per Newton Rapson's Method,

Xn+1  = Xn − f(Xn)/f′(Xn)

Here above equation is given in the below form

Xn+1 = Xn/2 + 9/(8 Xn)

Let us try to convert in Newton Rapson's form by putting Xn as
first part.
Xn+1  = Xn - Xn/2 + 9/(8 Xn)
= Xn - (4*Xn2 - 9)/(8*Xn)

So    f(X)  =  (4*Xn2 - 9)
and  f'(X) =  8*Xn 
So clearly f(X) = 4X2 − 9. We know its roots are ±3/2 = ±1.5, but if we start from X0 = 0.5, according to equation, we cannot get negative value at any time, so answer is 1.5 i.e. option (A) is correct.
 Question 29
A minimum state deterministic finite automaton accepting the language L={w | w ε {0,1} *, number of 0s and 1s in w are divisible by 3 and 5, respectively} has
 A 15 states B 11 states C 10 states D 9 states
Regular languages and finite automata    GATE-CS-2007
Discuss it

Question 29 Explanation:
Here a string w of 0's and 1's should have the property that, the no of 0's in the string w should be divisible by 3 ( N(0) % 3 =0 ), and the number of 1's the string w should be divisible by 5 (N(1) % 5 =0). Having said that, the Language will contain the strings such as : { ε , 000, 11111, 00011111, 00111101 , 11111000, 10101011 , 00000011111,....and so on } So, strings accepted by the automaton have to be of length 0, 3, 5, 8, 11, 13, 14, 16....and so on, i.e. equation for length will be 3x + 5y (where x,y>=0 ) Modulo 3 gives remainder as ( 0, 1, 2 ) , and Modulo 5 gives remainder as ( 0, 1, 2, 3, 4 ).  Hence 3 * 5 sates, i.e. there will be 15 states in the automaton to represent this. Please comment below if you find anything wrong in the above post.
 Question 30
The language L= {0i21i | i≥0 } over the alphabet {0,1, 2} is:
 A not recursive B is recursive and is a deterministic CFL. C is a regular language. D is not a deterministic CFL but a CFL.
Context free languages and Push-down automata    GATE-CS-2007
Discuss it

Question 30 Explanation:
Let us first design a deterministic pushdown automata for the given language.
• For each occurrence of ‘0’ , we PUSH X in the stack.
• When ‘2’ appears, no stack operation is performed. But, state of the automata is changed.
• For each occurrence of ‘1’ , we POP X from the stack.
• If at the end Z0 is on the stack top then input string is accepted
We also design a Turing machine for the given language.
• When ‘0’ appears in the input string , we replace it with X .Then, traverse to the rightmost corner and replace ‘1’ with Y.
• We go back to the leftmost ‘0’ and repeat the above process.
• While traversing rightwards from the beginning of the input string, if after X, ‘2’ appears and after ‘2’, Y appears then we reach the HALT state. Thus, the given language is recursive. Every recursive language is a CFL. Thus, option (B) is the answer. Please comment below if you find anything wrong in the above post.
 Question 31
Which of the following languages is regular?
 A A B B C C D D
Regular languages and finite automata    GATE-CS-2007
Discuss it

Question 31 Explanation:

(C) Strings which are the part of this language are either 0w0 or 1w1 where w is any string in {0, 1}* . Thus, language given in option (C) is regular.

All other languages accept strings which have a palindrome as their substring.
(A) Strings intersect with 0*110* .
(B) Strings intersect with 0*110*1 .
(D) Strings intersect with 10*110* .
According to pumping lemma, languages given option (A), (B) and (D) are irregular.

Thus, option (C) is the answer.

Please comment below if you find anything wrong in the above post.
 Question 32
Let f(w, x, y, z) = ∑(0, 4, 5, 7, 8, 9, 13, 15). Which of the following expressions are NOT equivalent to f?
 A x'y'z' + w'xy' + wy'z + xz B w'y'z' + wx'y' + xz C w'y'z' + wx'y' + xyz + xy'z D x'y'z' + wx'y' + w'y
Digital Logic & Number representation    GATE-CS-2007
Discuss it

Question 32 Explanation:
Solving this k-map we get x'y'z' + w'xy' + wy'z + xz which is (A) part Solving this k-map we get w'y'z' + wx'y' + xz which is (B) part. Solving this k-map we get w'y'z' + wx'y' + xyz + xy'z which is ( C) part . But we can’t get (D) part from any combination so Ans is (D) part.
 Question 33
Define the connective * for the Boolean variables X and Y as: X * Y = XY + X' Y'. Let Z = X * Y.
Consider the following expressions P, Q and R.
P: X = Y⋆Z
Q: Y = X⋆Z
R: X⋆Y⋆Z=1
Which of the following is TRUE?
 A Only P and Q are valid B Only Q and R are valid. C Only P and R are valid. D All P, Q, R are valid.
Digital Logic & Number representation    GATE-CS-2007
Discuss it

Question 33 Explanation:
* is nothing but working as EX NOR here.Explanation: P:

X= Y * Z

=(Y XOR Z)’

=YZ + Y’Z’

=Y(XY + X’Y’)+Y’(XY+X’Y’)’

=XY+Y’((Y XOR X)’)’

=XY+Y’(Y XOR X)

=XY+Y’(Y’X+X’Y)

=XY+Y’X

=X(Y+Y’)

=X 
Q:

Y=X*Z

=(X XOR Z)’

=X(XY + X’Y’) + X’(XY + X’Y’)’

=XY+X’(X’Y+XY’)

=XY+X’Y

=Y 
R:

X * Y *Z

WE HAVE SEEN FROM P Y*Z =X

SO X * X

NOT(X XOR X)=X’X’+XX
1

SO ALL P,Q,R ARE CORRECT ANS IS (D)
 Question 34
Suppose only one multiplexer and one inverter are allowed to be used to implement any Boolean function of n variables. What is the minimum size of the multiplexer needed?
 A 2n line to 1 line B 2n+1 line to 1 line C 2n-1 line to 1 line D 2n-2 line to 1 line
Digital Logic & Number representation    GATE-CS-2007
Discuss it

Question 34 Explanation:
We can use n-1 selection lines , and using 0,1 and nth variable and its compliment to realize the function So ans is 2^(n-1):1  Part-(C )
 Question 35
In a look-ahead carry generator, the carry generate function Gi and the carry propagate function Pi for inputs Ai and Bi are given by:
Pi = Ai ⨁ Bi and Gi = AiBi
The expressions for the sum bit Si and the carry bit Ci+1 of the look-ahead carry adder are given by:
Si = Pi ⨁ Ci and Ci+1 = Gi + PiCi , where C0 is the input carry.
Consider a two-level logic implementation of the look-ahead carry generator. Assume that all Pi and Gi are available for the carry generator circuit and that the AND and OR gates can have any number of inputs. The number of AND gates and OR gates needed to implement the look-ahead carry generator for a 4-bit adder with S3, S2, S1, S0 and C4 as its outputs are respectively:
 A 6, 3 B 10, 4 C 6, 4 D 10, 5
Digital Logic & Number representation    GATE-CS-2007
Discuss it

Question 35 Explanation:
let the carry input be c0 Now,
c1 = g0 + p0c0 = 1 AND, 1 OR
c2 = g1 + p1g0 + p1p0c0
= 2 AND, 1 OR

c3 = g2 + p2g1 + p2p1go + p2p1p0c0
= 3 AND, 1 OR
c4 = g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0
= 4 AND, 1 OR
So, total AND gates = 1+2+3+4 = 10 , OR gates = 1+1+1+1 = 4 So as a general formula we can observe that we need a total of " n(n+1)/2 " AND gates and "n" OR gates for a n-bit carry look ahead circuit used for addition of two binary numbers.
 Question 36
The control signal functions of a 4-bit binary counter are given below (where X is “don’t care”) The counter is connected as follows: Assume that the counter and gate delays are negligible. If the counter starts at 0, then it cycles through the following sequence:
 A 0, 3, 4 B 0, 3, 4, 5 C 0, 1, 2, 3, 4 D 0, 1, 2, 3, 4, 5
Digital Logic & Number representation    GATE-CS-2007
Discuss it

Question 36 Explanation:
Initially A1 A2 A3 A4 =0000 Clr=A1 and A3 So when A1 and A3 both are 1 it again goes to 0000 Hence 0000(init.) -> 0001(A1 and A3=0)->0010 (A1 and A3=0) -> 0011(A1 and A3=0) -> 0100 (A1 and A3=1)[ clear condition satisfied] ->0000(init.) so it goes through 0->1->2->3->4 Ans is ( C) part.
 Question 37
Consider a pipelined processor with the following four stages:
IF: Instruction Fetch
ID: Instruction Decode and Operand Fetch
EX: Execute
WB: Write Back
The IF, ID and WB stages take one clock cycle each to complete the operation. The number of clock cycles for the EX stage dependson the instruction. The ADD and SUB instructions need 1 clock cycle and the MUL instruction needs 3 clock cycles in the EX stage. Operand forwarding is used in the pipelined processor. What is the number of clock cycles taken to complete the following sequence of instructions?
ADD R2, R1, R0       R2 <- R0 + R1
MUL R4, R3, R2       R4 <- R3 * R2
SUB R6, R5, R4       R6 <- R5 - R4

 A 7 B 8 C 10 D 14
Computer Organization and Architecture    GATE-CS-2007
Discuss it

Question 37 Explanation:
Explanation: Order of instruction cycle phases IF”  ID”  EX”  WB” We  have 3 instructions. which represents wait in pipeline due to result dependently.
 1 2 3 4 5 6 7 8 R2!R1!R0 IF ID EX WB R4!R3!R2 IF ID EX EX EX WB R6!R5!R4 IF ID - - EX WB
This is the table shows the cycle phases and number of cycles require for given instruction. No. of cycles required=8 So (B) is correct option.
 Question 38
The following postfix expression with single digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
 A 6, 1 B 5, 7 C 3, 2 D 1, 5
GATE-CS-2007
Discuss it

Question 38 Explanation:
 Question 39
The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e c f g, respectively. The postorder traversal of the binary tree is:
 A d e b f g c a B e d b g f c a C e d b f g c a D d e f g b c a
GATE-CS-2007
Discuss it

Question 39 Explanation:
 Question 40
Consider a hash table of size seven, with starting index zero, and a hash function (3x + 4)mod7. Assuming the hash table is initially empty, which of the following is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the table using closed hashing? Note that ‘_’ denotes an empty location in the table.
 A 8, _, _, _, _, _, 10 B 1, 8, 10, _, _, _, 3 C 1, _, _, _, _, _,3 D 1, 10, 8, _, _, _, 3
GATE-CS-2007
Discuss it

Question 40 Explanation:
 Question 41
In an unweighted, undirected connected graph, the shortest path from a node S to every other node is computed most efficiently, in terms of time complexity by
 A Dijkstra’s algorithm starting from S. B Warshall’s algorithm C Performing a DFS starting from S. D Performing a BFS starting from S.
GATE-CS-2007
Discuss it

Question 41 Explanation:
 Question 42
Consider the following C function, what is the output?
#include <stdio.h>
int f(int n)
{
static int r = 0;
if (n <= 0) return 1;
if (n > 3)
{
r = n;
return f(n-2)+2;
}
return f(n-1)+r;
}

int main()
{
printf("%d", f(5));
}

 A 5 B 7 C 9 D 18
Storage Classes and Type Qualifiers    GATE-CS-2007
Discuss it

Question 42 Explanation:
f(5) = f(3)+2
The line "r = n" changes value of r to 5.  Since r
is static, its value is shared be all subsequence
calls.  Also, all subsequent calls don't change r
because the statement "r = n" is in a if condition
with n > 3.

f(3) = f(2)+5
f(2) = f(1)+5
f(1) = f(0)+5
f(0) = 1

So f(5) = 1+5+5+5+2 = 18 
 Question 43
A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41, and I = 10, what is the value of n?
 A 3 B 4 C 5 D 6
GATE-CS-2007
Discuss it

Question 43 Explanation:
 Question 44
In the following C function, let n >= m.
int gcd(n,m)
{
if (n%m ==0) return m;
n = n%m;
return gcd(m,n);
}

How many recursive calls are made by this function? (A) (logn)? (B) (n) (C) (loglogn) (D) (sqrt(n))
 A A B B C C D D
GATE-CS-2007
Discuss it

Question 44 Explanation:
 Question 45
What is the time complexity of the following recursive function:
int DoSomething (int n)
{
if (n <= 2)
return 1;
else
return (DoSomething (floor(sqrt(n))) + n);
}

(A) (n) (B) (nlogn) (C) (logn) (D) (loglogn)
 A A B B C C D D
GATE-CS-2007
Discuss it

 Question 46
Consider the following C program segment where CellNode represents a node in a binary tree:
struct CellNode
{
struct CellNOde *leftChild;
int element;
struct CellNode *rightChild;
};

int GetValue(struct CellNode *ptr)
{
int value = 0;
if (ptr != NULL)
{
if ((ptr->leftChild == NULL) &&
(ptr->rightChild == NULL))
value = 1;
else
value = value + GetValue(ptr->leftChild)
+ GetValue(ptr->rightChild);
}
return(value);
}

The value returned by GetValue() when a pointer to the root of a binary tree is passed as its argument is:
 A the number of nodes in the tree B the number of internal nodes in the tree C the number of leaf nodes in the tree D the height of the tree
GATE-CS-2007
Discuss it

Question 46 Explanation:
 Question 47
Consider the process of inserting an element into a Max Heap, where the Max Heap is represented by an array. Suppose we perform a binary search on the path from the new leaf to the root to find the position for the newly inserted element, the number of comparisons performed is: (A) (logn) (B) (LogLogn ) (C) (n) (D) (nLogn)
 A A B B C C D D
GATE-CS-2007
Discuss it

Question 47 Explanation:
 Question 48
Which of the following is TRUE about formulae in Conjunctive Normal Form?
 A For any formula, there is a truth assignment for which at least half the clauses evaluate to true. B For any formula, there is a truth assignment for which all the clauses evaluate to true C There is a formula such that for each truth assignment, at most one-fourth of the clauses evaluate to true. D None of the above
Propositional and First Order Logic.    GATE-CS-2007
Discuss it

Question 48 Explanation:
We can easily prove that for any formula, there is a truth assignment for which at least half the clauses evaluate to true . Proof : Consider an arbitrary truth assignment. For each of its clause ‘j’ , introduce a random variable. Xj = 1 if clause ‘j’ is satisfied Xj = 0 otherwise Then, X = summation of (j * Xj) is the number of satisfied clauses. Given any clause ’c’ , it is unsatisfied only if all of its ‘k’ constituent literals evaluates to false as they are joined by OR operator. Now, because each literal within a clause has a 1/2 chance of evaluating to true independently of any of the truth value of any of the other literals, the probability that they are all false is (1 / 2)k . Thus, the probability that ‘c’ is satisfied = 1 − (1 / 2)k So, E(Xj) = 1 * (1 / 2)k = (1 / 2)k Therefore, E(Xj) >= 1/2 Summation on both sides to get E(X). Therefore, we have E(X) = summation of (j * Xj) >= m/2 where ‘m’ is the number of clauses. E(X) represents expected number of satisfied clauses. Thus, there must exist an assignment that satisfies at least half of the clauses. Please comment below if you find anything wrong in the above post.
 Question 49
Let w be the minimum weight among all edge weights in an undirected connected graph. Let e be a specific edge of weight w . Which of the following is FALSE?
 A There is a minimum spanning tree containing e. B If e is not in a minimum spanning tree T, then in the cycle formed by adding e to T, all edges have the same weight. C Every minimum spanning tree has an edge of weight w . D e is present in every minimum spanning tree.
GATE-CS-2007
Discuss it

Question 49 Explanation:
 Question 50
An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is TRUE about the number of comparisons needed?
 A At least 2n - c comparisons, for some constant c, are needed. B At most 1.5n - 2 comparisons are needed. C At least nLog2n comparisons are needed. D None of the above.
GATE-CS-2007
Discuss it

Question 50 Explanation:
 Question 51
Consider the following C code segment:
int IsPrime(n)
{
int i,n;
for(i=2;i<=sqrt(n);i++)
if(n%i == 0)
{printf(“Not Prime\n”); return 0;}
return 1;
}

Let T(n) denotes the number of times the for loop is executed by the program on input n. Which of the following is TRUE? (A) T(n) = O(sqrt(n)) and T(n) = (sqrt(n)) (B) T(n) = O(sqrt(n)) and T(n) = (1) (C) T(n) = O(n) and T(n) = (sqrt(n)) (D) None of the above
 A A B B C C D D
GATE-CS-2007
Discuss it

 Question 52
Consider the grammar with non-terminals N = {S,C,S1 },terminals T={a,b,i,t,e}, with S as the start symbol, and the following set of rules:
S --> iCtSS1|a
S1 --> eS|ϵ
C --> b
The grammar is NOT LL(1) because:
 A it is left recursive B it is right recursive C it is ambiguous D It is not context-free.
Parsing and Syntax directed translation    GATE-CS-2007
Discuss it

Question 52 Explanation:

A  LL(1) grammar doesn't give to multiple entries in a single cell of its parsing table. It has only single entry in a single cell, hence it should be unambiguous.

Option A is wrong. Grammar is not left recursive. For a grammar to be left recursive a production should be of form A->Ab, where A is a single Non-Terminal and b is any string of grammar symbols.

Option B is wrong. Because a right recursive grammar has nothing to do with LL(1).

Option D is wrong. Because the given grammar is clearly a Context Free Grammar. A grammar is CFG if it has productions of the form A->(V∪ T)* , where A is a single non-terminal and V is a set of Non-terminals and T is a set of Terminals.

Hence Option C should be the correct one. i.e. the grammar is ambiguous.

But let's see how the grammar is ambiguous.

If the grammar is ambiguous then it should give multiple entry in a cell while making its parsing table. And Parse table is made with the aid of two functions : FIRST and FOLLOW.

A parsing table of a grammar will not have multiple entries in a cell( i.e. will be a LL(1) grammar) if and only if the following conditions hold for each production of the form A->α|β 1) FIRST(α)  ∩ FIRST(β) =   Φ 2) if FIRST(α) contains ' ε ' then FIRST(α) ∩ FOLLOW (A) =  Φ and vice-versa.

Now,

• For the production , S->iCtSS1|a, rule 1 is satisfied, because FIRST(iCtSS1) ∩ FIRST(a) = {i} ∩ {a} = Φ
• For the production, S1->eS|ε, rule 1 is satisfied, as FIRST(eS) ∩ FIRST(ε) = {e} ∩ {ε} = Φ   .  But here due to 'ε' in FIRST, we have to check for rule 2. FIRST(eS)  ∩ FOLLOW(S1) = {e} ∩ {e, \$} ≠ Φ .  Hence rule 2 fails in this production rule. Therefore there will be multiple entries in the parsing table, hence the grammar is ambiguous and not LL(1).
Please refer these link to learn how to find FIRST and FOLLOW:  http://geeksquiz.com/compiler-design-first-in-syntax-analysis/ http://geeksquiz.com/compiler-design-follow-set-in-syntax-analysis/
 Question 53
Consider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?
 A Both P and Q are true B P is true and Q is false C P is false and Q is true D Both P and Q are false
Parsing and Syntax directed translation    GATE-CS-2007
Discuss it

Question 53 Explanation:
A regular grammar can also be ambiguous also
For example, consider the following grammar,
S → aA/a
A → aA/ε
In above grammar, string 'a' has two leftmost
derivations.
(1)   S → aA                      (2)   S → a
S->a (using A->ε)
And LL(1) parses only unambiguous grammar,
so statement P is False.
Statement Q is true is for every regular set, we can have a regular
grammar which is unambiguous so it can be parse by LR parser.

So option C is correct choice 
 Question 54
In a simplified computer the instructions are: The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block: Assume that all operands are initially in memory. The final value of the computation should be in memory. What is the minimum number of MOV instructions in the code generated for this basic block?
 A 2 B 3 C 5 D 6
Code Generation and Optimization    GATE-CS-2007
Discuss it

Question 54 Explanation:
For Instructions of t2 and t3 1. MOV c, t2 2. OP d, t2(OP=ADD) 3. OP e, t2(OP=SUB) For Instructions of t1 and t4 4. MOV a, t1 5. OP b, t1(OP=ADD) 6. OP t1, t2(OP=SUB) 7. MOV t2, a(AS END Value has To be in the MEMORY) Step 6 should have been enough, if the question hadn't asked for final value in memory and rather be in register. The final step require another MOV, thus a total of 3.
 Question 55
An operating system uses Shortest Remaining Time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following processes:
Process  Execution time  Arrival time
P1             20            0
P2             25            15
P3             10            30
P4             15            45
What is the total waiting time for process P2?
 A 5 B 15 C 40 D 55
GATE-CS-2007    CPU Scheduling
Discuss it

Question 55 Explanation:
Shortest remaining time, also known as shortest remaining time first (SRTF), is a scheduling method that is a pre-emptive version of shortest job next scheduling. In this scheduling algorithm, the process with the smallest amount of time remaining until completion is selected to execute. Since the currently executing process is the one with the shortest amount of time remaining by definition, and since that time should only reduce as execution progresses, processes will always run until they complete or a new process is added that requires a smaller amount of time. The Gantt chart of execution of processes: At time 0, P1 is the only process, P1 runs for 15 time units. At time 15, P2 arrives, but P1 has the shortest remaining time. So P1 continues for 5 more time units. At time 20, P2 is the only process. So it runs for 10 time units. at time 30, P3 is the shortest remaining time process. So it runs for 10 time units. at time 40, P2 runs as it is the only process. P2 runs for 5 time units. At time 45, P3 arrives, but P2 has the shortest remaining time. So P2 continues for 10 more time units. P2 completes its execution at time 55. As we know, turn around time is total time between submission of the process and its completion. Waiting time is the time The amount of time that is taken by a process in ready queue and waiting time is the difference between Turn around time and burst time. Total turnaround time for P2 = Completion time - Arrival time = 55 - 15 = 40 Total Waiting Time for P2= turn around time - Burst time = 40 – 25 = 15 See question 3 of http://www.geeksforgeeks.org/operating-systems-set-12/ This solution is contributed by Nitika Bansal
 Question 56
A virtual memory system uses First In First Out (FIFO) page replacement policy and allocates a fixed number of frames to a process. Consider the following statements:

P: Increasing the number of page frames allocated to a
process sometimes increases the page fault rate.
Q: Some programs do not exhibit locality of reference. 
Which one of the following is TRUE?
 A Both P and Q are true, and Q is the reason for P B Both P and Q are true, but Q is not the reason for P. C P is false, but Q is true D Both P and Q are false
Memory Management    GATE-CS-2007
Discuss it

Question 56 Explanation:
First In First Out Page Replacement Algorithms: This is the simplest page replacement algorithm. In this algorithm, operating system keeps track of all pages in the memory in a queue, oldest page is in the front of the queue. When a page needs to be replaced page in the front of the queue is selected for removal. FIFO Page replacement algorithms suffers from Belady’s anomaly : Belady’s anomaly states that it is possible to have more page faults when increasing the number of page frames. Solution: Statement P: Increasing the number of page frames allocated to a process sometimes increases the page fault rate. Correct, as FIFO page replacement algorithm suffers from belady’s anomaly which states above statement. Statement Q: Some programs do not exhibit locality of reference. Correct, Locality often occurs because code contains loops that tend to reference arrays or other data structures by indices. So we can write a program does not contain loop and do not exhibit locality of reference. So, both statement P and Q are correct but Q is not the reason for P as Belady’s Anomaly occurs for some specific patterns of page references. See Question 1 of http://www.geeksforgeeks.org/operating-systems-set-13/ Reference : http://quiz.geeksforgeeks.org/operating-system-page-replacement-algorithm/ This solution is contributed by Nitika Bansal
 Question 57
A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. Consider the following scenario, where the column alloc denotes the number of units of each resource type allocated to each process, and the column request denotes the number of units of each resource type requested by a process in order to complete execution. Which of these processes will finish LAST?

alloc           request
X Y Z            X Y Z
P0  1 2 1            1 0 3
P1  2 0 1            0 1 2
P2  2 2 1            1 2 0 
 A P0 B P! C P2 D None of the above, since the system is in a deadlock
GATE-CS-2007
Discuss it

Question 57 Explanation:
A single processor system has three resource types X, Y and Z, which are shared by three processes. There are 5 units of each resource type. So, the resource instances which are left being unallocated = <0,1,2> { unallocated resources= total resources-allocated resources } now, from the request table, you can say that only request of P1 can be satisfied. So P1 can finish its execution first. Once P1 is done, it releases 2, 0 and 1 units of X, Y and Z respectively which were allocated to P1.So, Now unallocated resource instance are = <0,1,2> +<2,0,1> = <2,1,3> Now Among P0 and P2, needs of P0 can only be satisfied. So P0 finishes its execution. Once P2 is done, It releases 2,2,and 1 units of X,Y and Z respectively which were allocated to P2.SO, Now unallocated resource instance are= <2,1,3> + <2,2,1> = <4,3,4>. Finally, P2 finishes its execution. So, P2 is the process which finishes in end. Option (C) is the correct answer. See question 2 of http://www.geeksforgeeks.org/operating-systems-set-13/ Reference: http://quiz.geeksforgeeks.org/operating-system-bankers-algorithm/ This solution is contributed by Nitika Bansal
 Question 58
Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v
  /* P1 */
while (true) {
wants1 = true;
while (wants2 == true);
/* Critical
Section */
wants1=false;
}
/* Remainder section */

/* P2 */
while (true) {
wants2 = true;
while (wants1==true);
/* Critical
Section */
wants2 = false;
}
/* Remainder section */
 A It does not ensure mutual exclusion. B It does not ensure bounded waiting. C It requires that processes enter the critical section in strict alternation. D It does not prevent deadlocks, but ensures mutual exclusion.
Process Management    GATE-CS-2007
Discuss it

Question 58 Explanation:
Bounded waiting :There exists a bound, or limit, on the number of times other processes are allowed to enter their critical sections after a process has made request to enter its critical section and before that request is granted. mutual exclusion prevents simultaneous access to a shared resource. This concept is used in concurrent programming with a critical section, a piece of code in which processes or threads access a shared resource. Solution: Two processes, P1 and P2, need to access a critical section of code. Here, wants1 and wants2 are shared variables, which are initialized to false. Now, when both wants1 and wants2 become true, both process p1 and p2 enter in while loop and waiting for each other to finish. This while loop run indefinitely which leads to deadlock. Now, Assume P1 is in critical section (it means wants1=true, wants2 can be anything, true or false). So this ensures that p2 won’t enter in critical section and vice versa. This satisfies the property of mutual exclusion. Here bounded waiting condition is also satisfied as there is a bound on the number of process which gets access to critical section after a process request access to it. See question 3 of http://www.geeksforgeeks.org/operating-systems-set-13/ This solution is contributed by Nitika Bansal
 Question 59
Information about a collection of students is given by the relation studinfo(studId, name, sex). The relation enroll(studId, courseId) gives which student has enrolled for (or taken) that course(s). Assume that every course is taken by at least one male and at least one female student. What does the following relational algebra expression represent?
 A Courses in which all the female students are enrolled. B Courses in which a proper subset of female students are enrolled. C Courses in which only male students are enrolled. D None of the above
ER and Relational Models    GATE-CS-2007
Discuss it

Question 59 Explanation:
 Question 60
Consider the relation employee(name, sex, supervisorName) with name as the key. supervisorName gives the name of the supervisor of the employee under consideration. What does the following Tuple Relational Calculus query produce?
 A Names of employees with a male supervisor. B Names of employees with no immediate male subordinates. C Names of employees with no immediate female subordinates. D Names of employees with a female supervisor.
ER and Relational Models    GATE-CS-2007
Discuss it

Question 60 Explanation:
 Question 61
Consider the table employee(empId, name, department, salary) and the two queries Q1 ,Q2 below. Assuming that department 5 has more than one employee, and we want to find the employees who get higher salary than anyone in the department 5, which one of the statements is TRUE for any arbitrary employee table?
Q1 : Select e.empId
From employee e
Where not exists
(Select * From employee s where s.department = “5” and
s.salary >=e.salary)
Q2 : Select e.empId
From employee e
Where e.salary > Any
(Select distinct salary From employee s Where s.department = “5”)

 A Q1 is the correct query B Q2 is the correct query C Both Q1 and Q2 produce the same answer. D Neither Q1 nor Q2 is the correct query
SQL    GATE-CS-2007
Discuss it

Question 61 Explanation:
 Question 62
Which one of the following statements if FALSE?
 A Any relation with two attributes is in BCNF B A relation in which every key has only one attribute is in 2NF C A prime attribute can be transitively dependent on a key in a 3 NF relation. D A prime attribute can be transitively dependent on a key in a BCNF relation.
GATE-CS-2007
Discuss it

Question 62 Explanation:

If a relational schema is in BCNF then all redundancy based on functional dependency has been removed, although other types of redundancy may still exist.
A relational schema R is in BCNF form if and only if for every one of its dependencies X → Y, at least one of the following conditions hold : 1. X → Y is a trivial functional dependency i.e. Y is a subset of X . 2. X is a super key for schema R
So, we check transitive dependency for only non-prime attributes in case of BCNF.
Thus, the statement 'A prime attribute can be transitively dependent on a key in a BCNF relation' is false.

Thus, option (D) is the answer.

Please comment below if you find anything wrong in the above post.
 Question 63
The order of a leaf node in a tree B+ ? is the maximum number of (value, data record pointer) pairs it can hold. Given that the block size is 1K bytes, data record pointer is 7 bytes long, the value field is 9 bytes long and a block pointer is 6 bytes long, what is the order of the leaf node?
 A 63 B 64 C 67 D 68
B and B+ Trees    GATE-CS-2007
Discuss it

Question 63 Explanation:
  Disk Block size = 1024 bytes

Data Record Pointer size, r = 7 bytes
Value size, V = 9 bytes
Disk Block ptr, P = 6 bytes 
Let order of leaf be m. A leaf node in B+ tree contains at most m record pointers, at most m values, and one disk block pointer. r*m + V*m + p <= 1024 16m <= 1018 m =< 63
 Question 64
Consider the following schedules involving two transactions. Which one of the following statements is TRUE?
 A Both S1 and S2 are conflict serializable. B S1 is conflict serializable and S2 is not conflict serializable. C S1 is not conflict serializable and S2 is conflict serializable. D Both S1 and S2 are not conflict serializable.
GATE-CS-2007
Discuss it

Question 64 Explanation:
S1 is not conflict serializable, but S2 is conflict serializable

Schedule S1
T1            T2
---------------------
r1(X)
r1(Y)
r2(X)
r2(Y)
w2(Y)
w1(X)
The schedule is neither conflict equivalent to T1T2, nor T2T1.

Schedule S2
T1            T2
---------------------
r1(X)
r2(X)
r2(Y)
w2(Y)
r1(Y)
w1(X)
The schedule is conflict equivalent to T2T1.

 Question 65
There are n stations in a slotted LAN. Each station attempts to transmit with a probability p in each time slot. What is the probability that ONLY one station transmits in a given time slot?
 A (1-p)(n-1) B np(1-p)(n-1) C p(1-p)(n-1) D 1-(1-p)(n-1)
Discuss it

Question 65 Explanation:

P(X) = Probability that station X attempts to transmit = P P (-X) = Probability that station X does not transmit = 1-P Required is: Probability that only one station transmits = y

Y = (A1, -A2, -A3...... -An) + (-A1, A2, A3......-An) + (-A1, -A2, A3.....-An) + ........... + (-A1, -A2, -A3......An) = (p*(1-p)*(1-p)*...... (1-p) + (1-p)*p*(1-p)........(1-p) + ............. = p*(1-p)^(n-1) + p*(1-p)^n-1 + .................................................... + p*(1-p)^(n-1) = n*p*(1-p)^(n-1)

This solution is contributed Anil Saikrishna Devarasetty .

See question 3 of http://www.geeksforgeeks.org/computer-networks-set-9/
 Question 66
In a token ring network the transmission speed is 10^7 bps and the propagation speed is 200 metres/micro second. The 1-bit delay in this network is equivalent to:
 A 500 metres of cable. B 200 metres of cable. C 20 metres of cable. D 50 metres of cable.
Discuss it

Question 66 Explanation:
 Question 67
The address of a class B host is to be split into subnets with a 6-bit subnet number. What is the maximum number of subnets and the maximum number of hosts in each subnet?
 A 62 subnets and 262142 hosts. B 64 subnets and 262142 hosts. C 62 subnets and 1022 hosts. D 64 subnets and 1024 hosts.
Discuss it

Question 67 Explanation:
 Question 68
The message 11001001 is to be transmitted using the CRC polynomial x^3 + 1 to protect it from errors. The message that should be transmitted is:
 A 11001001000 B 11001001011 C 11001010 D 110010010011
Discuss it

Question 68 Explanation:
 Question 69
The distance between two stations M and N is L kilometers. All frames are K bits long. The propagation delay per kilometer is t seconds. Let R bits/second be the channel capacity. Assuming that processing delay is negligible, the minimum number of bits for the sequence number field in a frame for maximum utilization, when the sliding window protocolis used, is:
 A A B B C C D D
Discuss it

Question 69 Explanation:
 Question 70
Match the following:

(P) SMTP     (1) Application layer
(Q) BGP      (2) Transport layer
(R) TCP      (3) Data link layer
(S) PPP      (4) Network layer
(5) Physical layer 
 A P – 2 Q – 1 R – 3 S – 5 B P – 1 Q – 4 R – 2 S – 3 C P – 1 Q – 4 R – 2 S – 5 D P – 2 Q – 4 R – 1 S – 3
Misc Topics in Computer Networks    GATE-CS-2007
Discuss it

Question 70 Explanation:
 Question 71
Consider the following program segment. Here R1, R2 and R3 are the general purpose registers. Assume that the content of memory location 3000 is 10 and the content of the register R3 is 2000. The content of each of the memory locations from 2000 to 2010 is 100. The program is loaded from the memory location 1000. All the numbers are in decimal. Assume that the memory is word addressable. The number of memory references for accessing the data in executing the program completely is:
 A 10 B 11 C 20 D 21
Computer Organization and Architecture    GATE-CS-2007
Discuss it

Question 71 Explanation:
Explanation: Ist memory reference R1←M[3000] and then in the loop which runs for 10 times, because the content of memory location 3000 is 10 given in question and loop will run 10 times as R2← M[R3] M[R3] ←R2 There are two memory reference every iteration 10*2=20 Total=20+1=21 So  (D) is correct option.
 Question 72
Consider the data given in above question. Assume that the memory is word addressable. After the execution of this program, the content of memory location 2010 is:
 A 100 B 101 C 102 D 110
Computer Organization and Architecture    GATE-CS-2007
Discuss it

Question 72 Explanation:
Explanation: Program stores results from 2000 to 2010. It stores 110,109,108…..100 at  2010 location. So at 2010 it stores 100 Because DEC R1 is instruction which decrements register value by 1. So (A) is correct option.
 Question 73
Consider the data given in above questions. Assume that the memory is byte addressable and the word size is 32 bits. If an interrupt occurs during the execution of the instruction “INC R3”, what return address will be pushed on to the stack?
 A 1005 B 1020 C 1024 D 1040
Computer Organization and Architecture    GATE-CS-2007
Discuss it

Question 73 Explanation:
Explanation: If memory is byte addressable so for each instruction it requires 1 word that is equal to 4 bytes which require 4 addresses
 Instruction Word location MOV R1,3000 2 1000-1007 MOV R2,R1 1 1008-1011 ADD R2,R1 1 1012-1015 MOV(R3),R2 1 1016-1019 INC R3 1 1020-1023 DEC R1 1 1024-1027
Interrupt occur during execution of instruction INC R3. So CPU will complete the execution of this instruction and push the next address 1024 in the stack. So after interrupt service program can be resumed for next instruction. So (C) is correct option.
 Question 74
Consider the following Finite State Automaton. The language accepted by this automaton is given by the regular expression
 A A B B C C D D
Regular languages and finite automata    GATE-CS-2007
Discuss it

Question 74 Explanation:
In this case, we would at least have to reach q1 so that our string gets accepted. So, b* a is the smallest accepted string. Now, at q1, any string with any number of a's and b's would be accepted. So, we append (a + b)* to the smallest accepted string.

Thus, the string accepted by the FSA is b* a (a + b)*.

Thus, C is the correct choice.

Please comment below if you find anything wrong in the above post.
 Question 75
Consider the automata given in previous question. The minimum state automaton equivalent to the above FSA has the following number of states
 A 1 B 2 C 3 D 4
Regular languages and finite automata    GATE-CS-2007
Discuss it

Question 75 Explanation:
Following is equivalent FSA with 2 states.
 Question 76
Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a, b, c, d, e, f?
 A 0, 10, 110, 1110, 11110, 11111 B 11, 10, 011, 010, 001, 000 C 11, 10, 01, 001, 0001, 0000 D 110, 100, 010, 000, 001, 111
Greedy Algorithms    GATE-CS-2007
Discuss it

Question 76 Explanation:
We get the following Huffman Tree after applying Huffman Coding Algorithm. The idea is to keep the least probable characters as low as possible by picking them first.
The letters a, b, c, d, e, f have probabilities
1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively.

1
/   \
/     \
1/2    a(1/2)
/  \
/    \
1/4  b(1/4)
/   \
/     \
1/8   c(1/8)
/  \
/    \
1/16  d(1/16)
/  \
e    f
 Question 77
Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. What is the average length of Huffman codes?
 A 3 B 2.1875 C 2.25 D 1.9375
Greedy Algorithms    GATE-CS-2007
Discuss it

Question 77 Explanation:
We get the following Huffman Tree after applying Huffman Coding Algorithm. The idea is to keep the least probable characters as low as possible by picking them first.
The letters a, b, c, d, e, f have probabilities
1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively.

1
/   \
/     \
1/2    a(1/2)
/  \
/    \
1/4  b(1/4)
/   \
/     \
1/8   c(1/8)
/  \
/    \
1/16  d(1/16)
/  \
e    f
The average length = (1*1/2 + 2*1/4 + 3*1/8 + 4*1/16 + 5*1/32 + 5*1/32)
= 1.9375

 Question 78
Consider the CFG with {S,A,B) as the non-terminal alphabet, {a,b) as the terminal alphabet, S as the start symbol and the following set of production rules
S --> aB        S --> bA
B --> b         A --> a
B --> bS        A --> aS
B --> aBB       A --> bAA
Which of the following strings is generated by the grammar?
 A aaaabb B aabbbb C aabbab D abbbba
Context free languages and Push-down automata    GATE-CS-2007
Discuss it

Question 78 Explanation:
Given below production rules.
S --> aB        S --> bA
B --> b         A --> a
B --> bS        A --> aS
B --> aBB       A --> bAA
We can derive aabbab using below sequence
S  -> aB      [Using S --> aB]
-> aaBB    [Using B --> aBB]
-> aabB    [Using B --> b]
-> aabbS   [Using B --> bS]
-> aabbaB  [Using S --> aB]
-> aabbab  [Using B --> b]
 Question 79
For the correct answer strings to above question, how many derivation trees are there?
 A 1 B 2 C 3 D 4
Context free languages and Push-down automata    GATE-CS-2007
Discuss it

Question 79 Explanation:
When it asks about the no of derivations tree, we should consider either left most derivation(LMD) or right most derivations(RMD), but not both. Here two left most derivations are possible for the correct string of the previous question "aabbab" from the given grammar. LMD-1 S -> aB [Using S --> aB] -> aaBB [Using B --> aBB] -> aabB [Using B --> b] -> aabbS [Using B --> bS] -> aabbaB [Using S --> aB] -> aabbab [Using B --> b] LMD-2 S -> aB [Using S --> aB] -> aaBB [Using B --> aBB] -> aabSB [Using B --> bS] -> aabbAB [Using S --> bA] -> aabbaB [Using A --> a] -> aabbab [Using B --> b] The Derivation tress are shown below :
 Question 80
Consider a machine with a byte addressable main memory of 216 bytes. Assume that a direct mapped data cache consisting of 32 lines of 64 bytes each is used in the system. A 50 × 50 two-dimensional array of bytes is stored in the main memory starting from memory location 1100H. Assume that the data cache is initially empty. The complete array is accessed twice. Assume that the contents of the data cache do not change in between the two accesses. How many data cache misses will occur in total?
 A 40 B 50 C 56 D 59
Computer Organization and Architecture    GATE-CS-2007
Discuss it

Question 80 Explanation:
Size of main memory=216 bytes Size of cache=32*64 Bytes =2 11 Bytes Size of array=2500 Bytes Array is stored in main memory but cache will be empty Size of cache=2048 Bytes So number of page faults=2500-2048=452 Complete array will be access twice So for second access no. of total page faults=452*2=904 So total page faults=452+904=1356 So data cache misses will be 56 So (C) is correct option
 Question 81
Consider the data given in above question. Which of the following lines of the data cache will be replaced by new blocks in accessing the array for the second time?
 A line 4 to line 11 B line 4 to line 12 C line 0 to line 7 D line 0 to line 8
Computer Organization and Architecture    GATE-CS-2007
Discuss it

Question 81 Explanation:
Size of Main Memory = 2^16 bytes No. of lines = 32 = 2^5 Size of each line = 64 = 2^6 bytes => Word Offset = 6 2 way set is present Hence, No.of sets = No. of lines / 2 = 2^5 / 2 = 2^4 Now, Main memory format= ////// Sir 1st image here //////// Starting memory location : 1100 H => 0001 0001 0000 0000 Offset : 00 0000 Line   : 01 00 (4)   This solution is contributed by Mohit Gupta.
 Question 82
A process has been allocated 3 page frames. Assume that none of the pages of the process are available in the memory initially. The process makes the following sequence of page references (reference string): 1, 2, 1, 3, 7, 4, 5, 6, 3, 1 If optimal page replacement policy is used, how many page faults occur for the above reference string?
 A 7 B 8 C 9 D 10
Memory Management    GATE-CS-2007
Discuss it

Question 82 Explanation:
Optimal replacement policy looks forward in time to see which frame to replace on a page fault. 1 23    -> 1,2,3 //page faults 173      ->7 143  ->4 153 -> 5 163  -> 6 Total=7 So Answer is A
 Question 83
Consider the data given in above question. Least Recently Used (LRU) page replacement policy is a practical approximation to optimal page replacement. For the above reference string, how many more page faults occur with LRU than with the optimal page replacement policy?
 A 0 B 1 C 2 D 3
Memory Management    GATE-CS-2007
Discuss it

Question 83 Explanation:
LRU replacement policy: The page that is least recently used is being Replaced. Given String:   1, 2, 1, 3, 7, 4, 5, 6, 3, 1 123  // 1 ,2, 3 //page faults 173 ->7 473 ->4 453 ->5 456 ->6 356 ->3 316 ->1 Total 9 In http://geeksquiz.com/gate-gate-cs-2007-question-82/, In optimal Replacement total page faults=7 Therefore 2 more page faults  Answer is C
 Question 84
Suppose that a robot is placed on the Cartesian plane. At each step it is allowed to move either one unit up or one unit right, i.e., if it is at (i,j) then it can move to either (i+1,j) or (i,j+1). How many distinct paths are there for the robot to reach the point (10,10) starting from the initial position (0, 0)
 A A B B C C D D
Combinatorics    GATE-CS-2007
Discuss it

Question 84 Explanation:
At each move, robot can move either 1 unit right, or 1 unit up, and there will be 20 such moves required to reach (10,10) from (0,0). So we have to divide these 20 moves, numbered from 1 to 20, into 2 groups: right group and up group. Right group contains those moves in which we move right, and up group contains those moves in which we move up. Each group contains 10 elements each. So basically, we have to divide 20 things into 2 groups of 10 10 things each, i.e., we need to find all possible arrangements of {r, r, r, r, r, r, r, r, r, r, u, u, u, u, u, u, u, u, u, u} where r represents right move and u represents up move. The arrangements can can be done in 20! / (10!∗10!) = 20C10 ways. So option (A) is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2007.html
 Question 85
Consider the data given in above question. Suppose that the robot is not allowed to traverse the line segment from (4,4) to (5,4). With this constraint, how many distinct paths are there for the robot to reach (10,10) starting from (0,0)?
 A A B B C C D D
Combinatorics    GATE-CS-2007
Discuss it

Question 85 Explanation:
Since we are not allowed to traverse from (4,4) to (5,4), we subtract all those paths which were passing through (4,4) to (5,4). To count number of paths passing through (4,4) to (5,4), we find number of paths from (0,0) to (4,4), and then from (5,4) to (10,10).
From (0,0) to (4,4), number of paths = 8C4
[found in same way as in previous question].

From (5,4) to (10,10), number of paths = 11C5.
So total number of paths required : 20C10 − 8C4 ∗ 11C5.

So option (D) is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2007.html
There are 85 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.