GATE-CS-2005

Question 1
What does the following C-statement declare? [1 mark]
int ( * f) (int * ) ;
A
A function that takes an integer pointer as argument and returns an integer.
B
A function that takes an integer as argument and returns an integer pointer.
C
A pointer to a function that takes an integer pointer as argument and returns an integer.
D
A function that takes an integer pointer as argument and returns a function pointer
Pointer Basics    GATE-CS-2005    
Discuss it


Question 1 Explanation: 
The steps to read complicated declarations : 1)Convert C declaration to postfix format and read from left to right. 2)To convert expression to postfix, start from innermost parenthesis, If innermost parenthesis is not present then start from declarations name and go right first. When first ending parenthesis encounters then go left. Once the whole parenthesis is parsed then come out from parenthesis. 3)Continue until complete declaration has been parsed. At First, we convert the following given declaration into postfix:
int ( * f) (int * )
Since there is no innermost bracket, so first we take declaration name f, so print “f” and then go to the right, since there is nothing to parse, so go to the left. There is * at the left side, so print “*”.Come out of parenthesis. Hence postfix notation of given declaration can be written as follows:
f * (int * ) int
Meaning: f is a pointer to function (which takes one argument of int pointer type) returning int . Refer http://www.geeksforgeeks.org/complicated-declarations-in-c/ This solution is contributed by Nirmal Bharadwaj.
Question 2
An Abstract Data Type (ADT) is:
A
Same as an abstract class
B
A data type that cannot be instantiated
C
A data type type for which only the operations defined on it can be used, but none else
D
All of the above
Misc    GATE-CS-2005    
Discuss it


Question 3
A common property of logic programming languages and functional languages is:
A
both are procedural languages
B
both are based on λ-calculus
C
both are declarative
D
both use Horn-clauses
Principles of Programming Languages    GATE-CS-2005    
Discuss it


Question 4
Which one of the following are essential features of an object-oriented programming language? (GATE CS 2005) (i) Abstraction and encapsulation (ii) Strictly-typedness (iii) Type-safe property coupled with sub-type rule (iv) Polymorphism in the presence of inheritance Answer (b) Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language (See the Wiki page for OOP).
A
(i) and (ii) only
B
(i) and (iv) only
C
(i), (ii) and (iv) only
D
(i), (iii) and (iv) only
GATE-CS-2005    OOP Concepts    
Discuss it


Question 4 Explanation: 
Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language (See the Wiki page for OOP).
Question 5
A program P reads in 500 integers in the range [0..100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?
A
An array of 50 numbers
B
An array of 100 numbers
C
An array of 500 numbers
D
A dynamically allocated array of 550 numbers
GATE-CS-2005    
Discuss it


Question 6
An undirected graph C has n nodes. Its adjacency matrix is given by an n × n square matrix whose (i) diagonal elements are 0's, and (ii) non-diagonal elements are l's. Which one of the following is TRUE?
A
Graph G has no minimum spanning tree (MST)
B
Graph G has a unique MST of cost n-1
C
Graph G has multiple distinct MSTs, each of cost n-1
D
Graph G has multiple spanning trees of different costs
GATE-CS-2005    
Discuss it


Question 7
The time complexity of computing the transitive closure of a binary relation on a set of n elements is known to be
A
O (n)
B
O (n log n)
C
O(n3/2)
D
O(n3)
GATE-CS-2005    
Discuss it


Question 8
Let A, B and C be non-empty sets and let X = (A - B) - C and Y = (A - C) - (B - C). Which one of the following is TRUE?
A
X = Y
B
X ⊂ Y
C
Y ⊂ X
D
none of these
Set Theory & Algebra    GATE-CS-2005    
Discuss it


Question 8 Explanation: 
We can solve it by making Venn diagram
Question 9
The following is the Hasse diagram of the poset [{a, b, c, d, e}, ≤] GATECS2005Q9 The poset is
A
not a lattice
B
a lattice but not a distributive lattice
C
a distributive lattice but not a Boolean algebra
D
a Boolean algebra
Set Theory & Algebra    GATE-CS-2005    
Discuss it


Question 9 Explanation: 
It is a lattice but not a distributive lattice.

Table for Join Operation of above Hesse diagram

V |a b c d e
________________
a |a a a a a
b |a b a a b
c |a a c a c
d |a a a d d
e |a b c d e

Table for Meet Operation of above Hesse diagram

^ |a b c d e
_______________
a |a b c d e
b |b b e e e
c |c e c e e
d |d e e d e
e |e e e e e

Therefore for any two element p, q in the lattice (A,<=)

p <= p V q ; p^q <= p

This satisfies for all element (a,b,c,d,e).

which has 'a' as unique least upper bound and 'e' as unique 
greatest lower bound.

The given lattice doesn't obey distributive law, so it is 
not distributive lattice,

Note that for b,c,d we have distributive law

b^(cVd) = (b^c) V (b^d). From the diagram / tables given above 
we can verify as follows,

(i) L.H.S. = b ^ (c V d) = b ^ a = b

(ii) R.H.S. = (b^c) V (b^d) = e v e = e

b != e which contradict the distributive law. 
Hence it is not distributive lattice.

so, option (B) is correct. 
Question 10
Let G be a simple connected planar graph with 13 vertices and 19 edges. Then, the number of faces in the planar embedding of the graph is
A
6
B
8
C
9
D
13
Graph Theory    GATE-CS-2005    
Discuss it


Question 10 Explanation: 
An undirected graph is called a planar graph if it can be drawn on a paper without having two edges cross and such a drawing is called Planar Embedding. We say that a graph can be embedded in the plane, if it planar. A planar graph divides the plane into regions (bounded by the edges), called faces. Graph K4 is palanar graph, because it has a planar embedding as shown in figure below. P_graph Euler's Formula : For any polyhedron that doesn't intersect itself (Connected Planar Graph),the • Number of Faces(F) • plus the Number of Vertices (corner points) (V) • minus the Number of Edges(E) , always equals 2. This can be written: F + V − E = 2. Solution : Here as given, F=?,V=13 and E=19 -> F+13-19=2 -> F=8 So Answer is (B). This solution is contributed by Nirmal Bharadwaj We can apply Euler's Formula of planar graphs. The formula is v − e + f = 2.
Question 11
Let G be a simple graph with 20 vertices and 100 edges. The size of the minimum vertex cover of G is 8. Then, the size of the maximum indepen­dent set of G is
A
12
B
8
C
Less than 8
D
More than 12
Graph Theory    GATE-CS-2005    
Discuss it


Question 11 Explanation: 
Background Explanation: Vertex cover is a set S of vertices of a graph such that each edge of the graph is incident to at least one vertex of S. Independent set of a graph is a set of vertices such that none of the vertices in this set have an edge connecting them i.e. no two are adjacent. A single vertex is an independent set, but we are interested in maximum independent set, that is largest set which is independent set. Relation between Independent Set and Vertex Cover : An interesting fact is, the number of vertices of a graph is equal to its minimum vertex cover number plus the size of a maximum independent set. How? removing all vertices of minimum vertex cover leads to maximum independent set. So if S is the size of minimum vertex cover of G(V,E) then the size of maximum independent set of G is |V| - S. Solution: size of minimum vertex cover = 8 size of maximum independent set = 20 - 8 =12 Therefore, correct answer is (A). References : vertex cover maximum independent set. This solution is contributed by Nitika Bansal.
Question 12
Let f(x) be the continuous probability density func­tion of a random variable X. The probability that a < X ≤ b, is
		 
A) f(b - a)
B) f(b) - f(a)
C)  GATECS2005Q12A
D) GATECS2005Q12B
A
A
B
B
C
C
D
D
Probability    GATE-CS-2005    
Discuss it


Question 12 Explanation: 
  anil_1   This solution is contributed by Anil Saikrishna Devarasetty.
Question 13
The set {1, 2, 4, 7, 8, 11, 13, 14} is a group under multiplication modulo 15. The inverses of 4 and 7 are respectively
A
3 and 13
B
2 and 11
C
4 and 13
D
8 and 14
Set Theory & Algebra    GATE-CS-2005    
Discuss it


Question 13 Explanation: 
We know that,
For a number 'n', (n) x (n') = I, where
n' = inverse of 'n' I = Identity element Now, the identity element for multiplication is 1. So, we need to find two numbers 'm' and 'n' such that (4 x m) % 15 = 1 and (7 x n) % 15 = 1,
where 'm' is the inverse of 4 and 'n' is the inverse of 7, and both 'm' and 'n' belong to the given set. Thus, from the given set, it can be easily identified by putting values that m = 4 and n = 13. So, C is the correct choice.
  Please comment below if you find anything wrong in the above post.
Question 14
The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar is
A
ambiguous
B
left-recursive
C
right-recursive
D
an operator-grammar
Parsing and Syntax directed translation    GATE-CS-2005    
Discuss it


Question 14 Explanation: 
Answer (B) is correct because grammar is left recursive, hence the parser may fall into a loop. Answer A is not correct because ambiguity can occur from both left or right recursion. Refer https://lambda.uta.edu/cse5317/notes/node13.html
Question 15
Consider the following circuit. GATECS2005Q14 Which one of the following is TRUE?
A
f is independent of X
B
f is independent of Y
C
f is independent of Z
D
None of X, Y, Z is redundant
Digital Logic & Number representation    GATE-CS-2005    
Discuss it


Question 15 Explanation: 
[(XY’)’ NAND (YZ)’]= [(XY’)’ .(YZ)’]’ =XY’+YZ SO NONE OF X,Y,Z IS REDUNDANT Ans (D)
Question 16
The range of integers that can be represented by an n bit 2's complement number system is
A
- 2n - 1 to (2n - 1 - 1)
B
- (2n - 1 - 1) to (2n - 1 - 1)
C
- 2n - 1 to 2n - 1
D
- (2n - 1 + 1) to (2n - 1 + 1)
GATE-CS-2005    Number Representation    
Discuss it


Question 16 Explanation: 
For example, signed char is 8 bits, we can store from -128 to 127 using sign char. Refer http://en.wikipedia.org/wiki/Two%27s_complement for more details.
Question 17
The hexadecimal representation of 6578 is
A
1AF
B
D78
C
D71
D
32F
Digital Logic & Number representation    GATE-CS-2005    
Discuss it


Question 17 Explanation: 
We can first convert to Binary, we get 110 101 111. Then convert binary to base 16, we get 1AF (0001 1010 1111). (657)base 8= Writing binary of each digit=>  110=6 => 101=5 => 111=7 Adding extra 0’s I beginning to make groups of 4 binary digits each 000110101111= 0001 1010 1111 In octal
  • 0001 =1
  • 1010 =A
  • 1111 =F
So Ans is (A) part.
Question 18
The switching expression corresponding to f(A, B, C, D) = Σ (1, 4, 5, 9, 11, 12) is
A
BC'D' + A'C'D + AB'D
B
ABC' + ACD + B'C'D
C
ACD' + A'BC' + AC'D'
D
A'BD + ACD' + BCD'
Digital Logic & Number representation    GATE-CS-2005    
Discuss it


Question 18 Explanation: 
42   On solving above k-map we get AB’D+C’D+BC’D’ So Ans is (A) part.
Question 19
Which one of the following is true for a CPU having a single interrupt request line and a single interrupt grant line?
A
Neither vectored interrupt nor multiple interrupting devices are possible.
B
Vectored interrupts are not possible but multiple interrupting devices are possible.
C
Vectored interrupts and multiple interrupting devices are both possible.
D
Vectored interrupt is possible but multiple in­terrupting devices are not possible.
Computer Organization and Architecture    GATE-CS-2005    
Discuss it


Question 19 Explanation: 
CPU has single interrupt request and grant line Multiple request can be given to CPU but CPU interrupts only for highest priority interrupt so option A and D are wrong But in case of single interrupts line vectored interrupts are definitely not possible So (B) is correct option
Question 20
Normally user programs are prevented from handling I/O directly by I/O instructions in them. For CPUs having explicit I/O instructions, such I/O protection is ensured by having the I/O instructions privileged. In a CPU with memory mapped I/O, there is no explicit I/O instruction. Which one of the following is true for a CPU with memory mapped I/O?
A
I/O protection is ensured by operating system routine (s)
B
I/O protection is ensured by a hardware trap
C
I/O protection is ensured during system configuration
D
I/O protection is not possible
Input and Output    GATE-CS-2005    
Discuss it


Question 20 Explanation: 
User applications are not allowed to perform I/O in user mode - All I/O requests are handled through system calls that must be performed in kernel mode.
Question 21
What is the swap space in the disk used for?
A
Saving temporary html pages
B
Saving process data
C
Storing the super-block
D
Storing device drivers
GATE-CS-2005    
Discuss it


Question 21 Explanation: 
Swap space in Linux is used to increase the amount of apparent memory available on the system or when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory. At any rate, Linux supports swap space in two forms: as a separate disk partition or a file somewhere on your existing Linux file systems. If the system is thrashing because of lack of physical RAM and swap. Swap files are a good way to add swap on demand. See question 2 of http://www.geeksforgeeks.org/operating-systems-set-16/ Reference: https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-swap-what-is.html This solution is contributed by Nitika Bansal
Question 22
Increasing the RAM of a computer typically improves performance because:
A
Virtual memory increases
B
Larger RAMs are faster
C
Fewer page faults occur
D
Fewer segmentation faults occur
GATE-CS-2005    
Discuss it


Question 22 Explanation: 
When RAM size is bigger, the page table would have more entries of pages, hence less number of page faults.
Question 23
Packets of the same session may be routed through different paths in
A
TCP, but not UDP
B
TCP and UDP
C
UDP, but not TCP
D
Neither TCP, nor UDP
Transport Layer    GATE-CS-2005    
Discuss it


Question 23 Explanation: 
Question 24
The address resolution protocol (ARP) is used for
A
Finding the IP address from the DNS
B
Finding the IP address of the default gateway
C
Finding the IP address that corresponds to a MAC address
D
Finding the MAC address that corresponds to an IP address
Network Layer    GATE-CS-2005    
Discuss it


Question 24 Explanation: 
When a packet is passed to the data link layer from network layer IP address of the sender , MAC address of the sender and the gateway of the network is attached. The MAC address of the sender is known to the sender but not the MAC address of the gateway .So ARP (Address Resolution Protocol) request is generated with the IP address of the gateway and is broadcasted ,everyone except the gateway discards it and gateway sends it’s MAC address. sh_24 Reference: http://www.louiewong.com/archives/196?LMCL=pchYgb&LMCL=U7nEDo&LMCL=An2_DF&LMCL=pchYgb&LMCL=An2_DF Address Resolution Protocol (ARP) is a request and reply protocol used to find MAC address from IP address. This solution is contributed by Shashank Shanker khare.
Question 25
The maximum window size for data transmission using the selective reject protocol with n-bit frame sequence numbers is:
A
2^n
B
2^(n-1)
C
2^n – 1
D
2^(n-2)
Transport Layer    GATE-CS-2005    
Discuss it


Question 25 Explanation: 
In Selective Reject (or Selective Repeat), maximum size of window must be half of the maximum sequence number.
Question 26
In a network of LANs connected by bridges, packets are sent from one LAN to another through intermediate bridges. Since more than one path may exist between two LANs, packets may have to be routed through multiple bridges. Why is the spanning tree algorithm used for bridge-routing?
A
For shortest path routing between LANs
B
For avoiding loops in the routing paths
C
For fault tolerance
D
For minimizing collisions
GATE-CS-2005    
Discuss it


Question 26 Explanation: 
The main idea for using Spanning Trees is to avoid loops. See Spanning Tree Protocol for more details.
Question 27
An organization has a class B network and wishes to form subnets for 64 departments. The subnet mask would be
A
255.255.0.0
B
255.255.64.0
C
255.255.128.0
D
255.255.252.0
GATE-CS-2005    
Discuss it


Question 27 Explanation: 
Question 28
Which one of the following is a key factor for preferring B+ -trees to binary search trees for indexing database relations?
A
Database relations have a large number of records
B
Database relations are sorted on the primary key
C
B+ -trees require less memory than binary search trees
D
Data transfer from disks is in blocks
GATE-CS-2005    
Discuss it


Question 28 Explanation: 
Database queries can be executed faster when disk reads and writes whole blocks of data at once.But, nodes of binary search tree store a single key. So, in case of binary search tree, data transfer can not be done in blocks. B+ tree is a balanced tree and multiple keys are stored in each node of a B+ tree. Thus, disk can transfer data in blocks when B+ tree is used for indexing database relations. Hence, option (D) is correct. Please comment below if you find anything wrong in the above post.
Question 29
Which one of the following statements about normal forms is FALSE?
A
BCNF is stricter than 3NF
B
Lossless, dependency-preserving decomposi­tion into 3NF is always possible
C
Lossless, dependency-preserving decomposi­tion into BCNF is always possible
D
Any relation with two attributes is in BCNF
Database Design(Normal Forms)    GATE-CS-2005    
Discuss it


Question 29 Explanation: 
Question 30
Let r be a relation instance with schema R = (A, B, C, D). We define r1 = ΠA, B, C (r) and r2 = ΠA.D (r). Let s = r1 * r2 where * denotes natural join. Given that the decomposition of r into r1 and r2 is lossy, which one of the following is TRUE?
A
s ⊂ r
B
r ∪ s
C
r ⊂ s
D
r * s = s
Database Design(Normal Forms)    GATE-CS-2005    
Discuss it


Question 30 Explanation: 
Question 31
Consider the following C-program:
void foo(int n, int sum)
{
  int k = 0, j = 0;
  if (n == 0) return;
    k = n % 10; 
  j = n / 10;
  sum = sum + k;
  foo (j, sum);
  printf ("%d,", k);
}
 
int main ()
{
  int a = 2048, sum = 0;
  foo (a, sum);
  printf ("%d\n", sum);
   
  getchar();
}
What does the above program print?
A
8, 4, 0, 2, 14
B
8, 4, 0, 2, 0
C
2, 0, 4, 8, 14
D
2, 0, 4, 8, 0
Functions    GATE-CS-2005    
Discuss it


Question 31 Explanation: 
Question 32
Consider the following C-program:
double foo (double); /* Line 1 */

int main()
{

    double da, db;

    // input da

    db = foo(da);

}

double foo(double a)
{
    return a;
}
The above code compiled without any error or warning. If Line 1 is deleted, the above code will show:
A
no compile warning or error
B
some compiler-warnings not leading to unintended results
C
some compiler-warnings due to type-mismatch eventually leading to unintended results
D
compiler errors
Functions    GATE-CS-2005    
Discuss it


Question 33
Postorder traversal of a given binary search tree T produces the following sequence of keys 10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29 Which one of the following sequences of keys can be the result of an inorder traversal of the tree T?
A
9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
B
9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
C
29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
D
95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29
GATE-CS-2005    
Discuss it


Question 33 Explanation: 
Inorder traversal of a BST always gives elements in increasing order. Among all four options, a) is the only increasing order sequence.
Question 34
A Priority-Queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is given below: 10, 8, 5, 3, 2 Two new elements ”1‘ and ”7‘ are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the elements is:
A
10, 8, 7, 5, 3, 2, 1
B
10, 8, 7, 2, 3, 1, 5
C
10, 8, 7, 1, 2, 3, 5
D
10, 8, 7, 3, 2, 1, 5
GATE-CS-2005    
Discuss it


Question 35
How many distinct binary search trees can be created out of 4 distinct keys?
A
5
B
14
C
24
D
42
GATE-CS-2005    
Discuss it


Question 35 Explanation: 
Question 36
In a complete k-ary tree, every internal node has exactly k children. The number of leaves in such a tree with n internal nodes is
A
nk
B
(n - 1)k + 1
C
n(k - 1) + 1
D
n(k - 1)
GATE-CS-2005    
Discuss it


Question 36 Explanation: 
  Background required - Trees and Recurrence Relation We have to tackle this problem by forming a recurrence relation. Let T(n) be number of leaves in a tree having n internal nodes. We have to somehow relate T(n) to T(n-1). Consider a tree with n = 1. This tree will be having exactly k Leaves. Try creating a tree with 2 internal nodes from the above tree. We have to make one leaf node an internal node and while doing this, we are getting more k leaves. Therefore, number of leaf nodes in the newly constructed tree will be one less than original tree as we have changed one leaf to internal node plus k (Newly converted node has now spawn k more leaves). tree

Thus, T(n)   = T(n-1) - 1 + k = T(n-1) + k -1
             = T(n-2) + 2*(k-1)		 Solving By Substitution Method
	     = T(n-3) + 3*(k-1)
	     .
	     .
	     .
	     = T(n-(n-1)) + (n-1)*(k-1)	 
	     = T(1) + (n-1)*(k-1)
	     = k + (n-1)*(k-1)             Forming Base Case : T(1) = k
             = n(k – 1) + 1
In Gate, we will suggest you to solve this question by taking 2-3 examples and eliminating the options. But in the interviews later, you might have to show them how you form and solve the recurrence relation. This explanation has been contributed by Pranjul Ahuja. Visit the following link to learn more on recurrence relation: MIT Video Lecture on Asymptotic Notation | Recurrences | Substitution, Master Method
Question 37
Suppose T(n) = 2T (n/2) + n, T(0) = T(1) = 1 Which one of the following is FALSE?
A
T(n) = O(n2)
B
T(n) = θ(n log n)
C
T(n) = Ω(n2)
D
T(n) = O(n log n)
GATE-CS-2005    
Discuss it


Question 37 Explanation: 
anil_d_1 See question 4 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-23/ This solution is contributed by Anil Saikrishna Devarasetty
Question 38
Let G(V, E) an undirected graph with positive edge weights. Dijkstra's single-source shortest path algorithm can be implemented using the binary heap data structure with time complexity:
A
O(| V |2)
B
O (| E | + | V | log | V |)
C
O (| V | log | V |)
D
O ((| E | + | V |) log | V |)
Graph Shortest Paths    GATE-CS-2005    
Discuss it


Question 39
Suppose there are ⌈ log n ⌉ sorted lists of ⌊ n/log n ⌋ elements each. The time complexity of producing a sorted list of all these elements is : (Hint : Use a heap data structure)
A
O(n log log n)
B
θ(n log n)
C
Ω(n log n)
D
Ω(n3/2)
Misc    GATE-CS-2005    
Discuss it


Question 39 Explanation: 
We can merge x arrays of each size y in in O(xy*Logy) time using Min Heap. x = n/Logn y = Logn We get O(n/Logn * Logn * Log Log n) which is O(nLogLogn)
Question 40
Let P, Q and R be three atomic prepositional assertions. Let X denote (P v Q) → R and Y denote (P → R) v (Q → R). Which one of the following is a tautology?
A
X ≡ Y
B
X → Y
C
Y → X
D
¬ Y → X
Propositional and First Order Logic.    GATE-CS-2005    
Discuss it


Question 40 Explanation: 
Answer : [ B ]
X = (P ⋁ Q) → R
  = ~(P ⋁ Q) ⋁ R

  = (~P ⋀ ~Q) ⋁ R

  = (~P ⋁ R) ⋀ (~Q ⋁ R)

  = (P → R) ⋀ (Q → R)

X → Y is true as (A ⋀ B) → (A ⋁ B) is always TRUE
but reverse implication is not always true. 
Question 41
What is the first order predicate calculus statement equivalent to the following? Every teacher is liked by some student
A
∀(x) [teacher (x) → ∃ (y) [student (y) → likes (y, x)]]
B
∀ (x) [teacher (x) → ∃ (y) [student (y) ^ likes (y, x)]]
C
∃ (y) ∀ (x) [teacher (x) → [student (y) ^ likes (y, x)]]
D
∀ (x) [teacher (x) ^ ∃ (y) [student (y) → likes (y, x)]]
Propositional and First Order Logic.    GATE-CS-2005    
Discuss it


Question 41 Explanation: 
Answer is B] Statement : If X is a teacher then there exists some Y who is a student and likes X. A] Statement : If X is a teacher, then there exists a Y such that if Y is a student, then Y likes X. C] Statement : There exist a student who likes all teachers. D] Statement : Everyone is a teacher and there exists a Y such that if Y is student then y likes X.
Question 42
Let R and S be any two equivalence relations on a non-empty set A. Which one of the following statements is TRUE?
A
R ∪ S, R ∩ S are both equivalence relations
B
R ∪ S is an equivalence relation
C
R ∩ S is an equivalence relation
D
Neither R ∪ S nor R ∩ S is an equivalence relation
Set Theory & Algebra    GATE-CS-2005    
Discuss it


Question 43
Let f: B → C and g: A → B be two functions and let h = f o g. Given that h is an onto function. Which one of the following is TRUE?
A
f and g should both be onto functions.
B
f should be onto but g need not be onto
C
g should be onto but f need not be onto
D
both f and g need not be onto
Set Theory & Algebra    GATE-CS-2005    
Discuss it


Question 43 Explanation: 
A function f: X → Y is called on-to function if for every value in set Y, there is a value in set X.
Given that, f: B → C and g: A → B and h = f o g.  

Note that the sign o represents composition. 

h is basically f(g(x)). So h is a function from set A
to set C.

It is also given that h is an onto function which means
for every value in C there is a value in A. 
We map from C to A using B. So for every value in C, there must be a value in B. It means f must be onto. But g may or may not be onto as there may be some values in B which don't map to A. Example :
Let us consider following sets
A : {a1, a2, a3}
B : {b1, b2}
C : {c1}

And following function values
f(b1) = c1
g(a1) = b1, g(a2) = b1, g(a3) = b1

Values of h() would be,
h(a1) = c1, h(a2) = c1, h(a3) = c1

Here h is onto, therefore f is onto, but g is 
onto as b2 is not mapped to any value in A.
Given that, f: B → C and g: A → B and h = f o g.
Question 44
What is the minimum number of ordered pairs of non-negative numbers that should be chosen to ensure that there are two pairs (a, b) and (c, d) in the chosen set such that "a ≡ c mod 3" and "b ≡ d mod 5"
A
4
B
6
C
16
D
24
Set Theory & Algebra    GATE-CS-2005    
Discuss it


Question 44 Explanation: 

a = c mod 3 (given) Thus, ‘a’ can be any one of these values : 0, 1, 2
b = d mod 5 (given) Thus, ‘b’ can be any one of these values : 0, 1, 2, 3, 4
Thus, ordered pair for (a, b) are : (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)
Therefore, ordered pair (a, b) has 15 combinations and ordered pair (c, d) has 1 combination. Total combinations = 15 + 1 = 16
 
Hence, option (C) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 45
Consider three decision problems P1, P2 and P3. It is known that P1 is decidable and P2 is undecidable. Which one of the following is TRUE?
A
P3 is decidable if P1 is reducible to P3
B
P3 is undecidable if P3 is reducible to P2
C
P3 is undecidable if P2 is reducible to P3
D
P3 is decidable if P3 is reducible to P2's complement
Undecidability    GATE-CS-2005    
Discuss it


Question 45 Explanation: 
  Background: In computational complexity theory, a decision problem has only two possible outputs yes or no. A decision problem is said to be decidable if there exists an effective method or algorithm that returns a correct yes/no answer to that problem. A decision problem is said to be undecidable if there does not exist a single algorithm that always lead to a correct yes/no solution. In terms of reducibility: A ≤p B denotes A is a decision problem that is reducible to B in polynomial time p. This simply means that A’s instance can be transformed into B’s instance and following the solution of B we can get a solution for the problem A. So here we can draw some conclusions:
1. If A ≤p B and B is decidable then A is also decidable.
This is because if there exists a specific algorithm for solving B and we can 
also reduce A to B then we can have a solution of A as well. Hence A is decidable.

However the reverse is not true i.e. if A ≤p B and A is decidable 
then B is also decidable because A can have an algorithm existing for its correct 
solution but might be the case that B does not.

2. If A ≤p B and A is undecidable then B is also undecidable.
This is because if A is undecidable even when it can be reduced to B that simply 
reflects even B cannot provide an algorithm by which we can solve B and hence A. 
So decision problem B is also undecidable.

However the reverse is not true here as well i.e. if A ≤p B and B is undecidable then A is also undecidable because there might exist an algorithm for A that can provide a solution to A. Using the above stated conclusions we can say that option 1, 2 and 4 are false and option 3 is true.
Option 1: P1 ≤p P3 and given P1 is decidable gives no conclusion for P3.
Option 2: P3 ≤p P2 and given P2 is undecidable gives no conclusion for P3.
Option 3: P2 ≤p P3 and given P2 is undecidable gives conclusion for P3 to be 
          undecidable.
Option 4: P3 ≤p P2’s complement and given P2 is undecidable therefore P2’s 
           complement is also undecidable gives no conclusion for P3.
This explanation is contributed by Yashika Arora. Visit the following articles to learn more: undecidability-and-reducibility Wikipedia: Reduction_(Complexity)
Question 46
Consider the set H of all 3 × 3 matrices of the type GATECS2005Q46 where a, b, c, d, e and f are real numbers and abc ≠ 0. Under the matrix multiplication operation, the set H is
A
a group
B
a monoid but not a group
C
a semigroup but not a monoid
D
neither a group nor a semigroup
Linear Algebra    GATE-CS-2005    
Discuss it


Question 46 Explanation: 
Because identity matrix is identity & as they define abc != 0, then it is non-singular so inverse is also defined
Question 47
Which one of the following graphs is NOT planar? GATECS2005Q47
A
G1
B
G2
C
G3
D
G4
Graph Theory    GATE-CS-2005    
Discuss it


Question 47 Explanation: 
A graph is planar if it can be redrawn in a plane without any crossing edges. G1 is a typical example of nonplanar graphs.
Question 48
Consider the following system of equations in three real variables xl, x2 and x3 2x1 - x2 + 3x3 = 1 3x1- 2x2 + 5x3 = 2 -x1 + 4x2 + x3 = 3 This system of equations has
A
no solution
B
a unique solution
C
more than one but a finite number of solutions
D
an infinite number of solutions
Linear Algebra    GATE-CS-2005    
Discuss it


Question 48 Explanation: 
The determinant value of following matrix is non-zero, therefore we have a unique solution.
 2   -1   3
 3   -2   5
-1    4   1  
Question 49
What are the eigenvalues of the following 2 × 2 matrix? GATECS2005Q49
A
-1 and 1
B
1 and 6
C
2 and 5
D
4 and -1
Linear Algebra    GATE-CS-2005    
Discuss it


Question 49 Explanation: 
The eigenvalues of A are precisely the real numbers λ that satisfy the equation det(A - &lambda I) = 0. Let us find determinant value of A - &lambda I;
2-λ     -1
   -4       5-λ   
We get the equation as λ2 -7 λ + 6 = 0 which gives us eigenvalues as 6 and 1.
Question 50
Let G(x) = 1/(1 - x)2 = GATECS2005Q50, where | x | < 1. What is g(i) ?
A
i
B
i+1
C
2i
D
2i
Numerical Methods and Calculus    GATE-CS-2005    
Discuss it


Question 50 Explanation: 
B is the correct option. Let us put values

S = 1 + 2x + 3x2 + 4x3 + ..........
Sx =    x  + 2x2 + 3x3 + ..........  
S - Sx = 1 + x + x2 + x3 + ....
S - Sx = 1/(1 - x) [sum of infinite GP series with ratio < 1 is a/(1-r)]
S = 1/(1 - x)2 
Question 51
Box P has 2 red balls and 3 blue balls and box Q has 3 red balls and 1 blue ball. A ball is selected as follows:
(i)  Select a box
(ii) Choose a ball from the selected box such that each ball in
     the box is equally likely to be chosen. The probabilities of
     selecting boxes P and Q are (1/3) and (2/3), respectively.  
Given that a ball selected in the above process is a red ball, the probability that it came from the box P is
A
4/19
B
5/19
C
2/9
D
19/30
Probability    GATE-CS-2005    
Discuss it


Question 51 Explanation: 
The probability of selecting a red ball  = 
              (1/3) * (2/5) + (2/3) * (3/4) = 2/15 + 1/2 
              = 19/30  [Let it be P1]

Probability of selecting a red ball from box P =
             (1/3) * (2/5) = 2/15 [Let it be P2]

Given that a ball selected in the above process is 
a red ball, the probability that it came from the 
box P is = P1/P2 = (2/15) / (19/30) = 4/19 
Question 52
A random bit string of length n is constructed by tossing a fair coin n times and setting a bit to 0 or 1 depending on outcomes head and tail, respectively. The probability that two such randomly generated strings are not identical is
A
1/2n
B
1 - (1/n)
C
(1/n!)
D
1 - (1/2n)
Probability    GATE-CS-2005    
Discuss it


Question 52 Explanation: 
let us suppose if outcome is head =>0, tail => 1 Since the coin is fare, P(H) = P(T) = 1⁄2 Length of the string is => n P(X) = both the strings should not be identical P(-X) = both are not identical = 1 – P(X) If both the strings are equal, every character should be same w.r.t its positions i.e P(X) = 1/2*1/2*.......(n times) = (1/2)^n P(-X) = 1 – (1/2)^n This solution is contributed by Anil Saikrishna Devarasetty
Question 53
Consider the machine M: GATECS2005Q53 The language recognized by M is :
A
{w ∈ {a, b}* / every a in w is followed by ex­actly two b's}
B
{w ∈ {a, b}* every a in w is followed by at least two b’}
C
{w ∈ {a, b}* w contains the substring 'abb'}
D
{w ∈ {a, b}* w does not contain 'aa' as a substring}
Regular languages and finite automata    GATE-CS-2005    
Discuss it


Question 53 Explanation: 
 

Here w ∈ {a, b}* means w can be any string from the set of {a, b}* and {a, b}* is set of all strings composed of a and b (any string of a and b that you can think of) like null, a, b, aaa, abbaaa, bbbbb, aaaaa, aaaabbbbaabbababab etc.

These type of questions are frequently asked in GATE, where it is asked to choose best fit language among the options. To slove the question like this, there is a better way, we try to eliminate wrong options by choosing testing strings intelligently until we are left with one right option.As given in question, let’s we try to eliminate option (A), it recognizes only those string (composed of a and b) in which every a in w is followed by exactly two b’s , so if we take string abbb(three b’s), then it is accepted by machine , so this options is wrong. Now we try to eliminate option (C), it recognizes only those strings(composed of a and b) in which w contains the substring ‘abb’, so if we take string abbaa (has substring abb), then it is not accepted by machine, so this options is also wrong. Now we try to eliminate option (D), it recognizes only those string(composed of a and b) in which w does not contains ‘aa’ as a substring , so if we take string abbaba(‘aa’ not as a substring), then it is not accepted by machine ,so this options is also wrong. Only option with which we are left, is option (b) in which every a in w is followed by at least two b’ ,is correct.So answer is option (B).

This solution is contributed by Nirmal Bharadwaj.

Question 54
Let Nf and Np denote the classes of languages accepted by non-deterministic finite automata and non-deterministic push-down automata, respectively. Let Df and Dp denote the classes of languages accepted by deterministic finite automata and deterministic push-down automata, respectively. Which one of the following is TRUE?
A
Df ⊂ Nf and Dp ⊂ Np
B
Df ⊂ Nf and Dp = Np
C
Df = Nf and Dp = Np
D
Df = Nf and Dp ⊂ Np
Regular languages and finite automata    GATE-CS-2005    
Discuss it


Question 54 Explanation: 
Deterministic pushdown automata can recognize all deterministic context-free languages while nondeterministic ones can recognize all context-free languages. Mainly the former are used in parser design (Source: http://en.wikipedia.org/wiki/Pushdown_automaton ). Deterministic context-free languages (DCFL) are a proper subset of context-free languages. Non-deterministic finite automata and Deterministic finite automata, both accept same set of languages as NFAs can be translated to equivalent DFAs using the subset construction algorithm.
Question 55
Consider the languages:
L1 = {anbncm | n, m > 0} 
L2 = {anbmcm | n, m > 0} 
Which one of the following statements is FALSE?
A
L1 ∩ L2 is a context-free language
B
L1 U L2 is a context-free language
C
L1 and L2 are context-free language
D
L1 ∩ L2 is a context sensitive language
Context free languages and Push-down automata    GATE-CS-2005    
Discuss it


Question 55 Explanation: 
L1 and L2 are context free languages. See this for closure properties.
Question 56
Let L1 be a recursive language, and let L2 be a recursively enumerable but not a recursive language. Which one of the following is TRUE?
L1' --> Complement of L1
L2' --> Complement of L2 
A
L1' is recursive and L2' is recursively enumer­able
B
L1' is recursive and L2' is not recursively enumerable
C
L1' and L2' are recursively enumerable
D
L1' is recursively enumerable and L2' is recursive
Recursively enumerable sets and Turing machines    GATE-CS-2005    
Discuss it


Question 56 Explanation: 
Recursively enumerable languages are known as type-0 languages in the Chomsky hierarchy of formal languages. All regular, context-free, context-sensitive and recursive languages are recursively enumerable (Source: http://en.wikipedia.org/wiki/Recursively_enumerable_language ) Recursive Languages are closed under complementation, but recursively enumerable are not closed under complementation.  If a languages L is recursively enumerable, then the complement of it is recursively enumerable if and only if  L is also recursive.  Since L2 is recursively enumerable, but not recursive, L2' is not recursively enumerable.
Question 57
Consider the languages:
L1 = {wwR |w ∈ {0, 1}*}
L2 = {w#wR | w ∈ {0, 1}*}, where # is a special symbol
L3 = {ww |  w ∈  (0, 1}*)
Which one of the following is TRUE?
A
L1 is a deterministic CFL
B
L2 is a deterministic CFL
C
L3 is a CFL, but not a deterministic CFL
D
L3 is a deterministic CFL
Context free languages and Push-down automata    GATE-CS-2005    
Discuss it


Question 57 Explanation: 
  L1: {ww^R | w belongs {0,1}*} This is a CFL but not a DCFL. It can be derived from the following grammar S -> aSa | bSb | epsilon But it can't be derived from any deterministic pushdown automaton, because there is no way to figure out where a word w ends and its reverse starts. L2: {w#w^R | w belongs {0,1}*} This is a CFL, due to the same reason as described above. This is a deterministic CFL because we have a marker to help us find out the end of the word w and start of its reverse. Thus a PDA where all the alphabets are pushed until we get # and afterwards pop only if the top of the stack matches the current alphabet and reject otherwise - will derive L2. L3: {ww | w belongs {0,1}*} This is not even a CFL. Above claim could be proved using pumping lemma - Consider a string z of the form (0^n 1^n 0^n 1^n). Assuming L3 is a CFL, and z obviously satisfies L3 - thus z should also satisfy pumping lemma. We will take n such that n = p, where p is the pumping length of L3, hence forcing our string to be of length greater than pumping length. Now, according to pumping lemma, there must exist u,v,w,x,y such that z = uvwxy, |vwx| <= p, |vx| > 0 and u{v^i}x{y^i}z belongs L3 for all i>=0. There doesn't exist any such configuration of u,v,w,x,y such that u{v^0}x{y^0}z belongs L3. Hence z doesn't satisfy pumping lemma. Hence L3 is not a CFL. Considering all the above conclusions, only correct option comes out to be (B) L2 is a deterministic CFL. Reference ; https://courses.engr.illinois.edu/cs373/sp2013/Lectures/lec17.pdf This solution is contributed by Vineet Purswani.
Question 58
Consider the following two problems on undirected graphs
α : Given G(V, E), does G have an independent set of size | V | - 4?
β : Given G(V, E), does G have an independent set of size 5? 
Which one of the following is TRUE?
A
α is in P and β is NP-complete
B
α is NP-complete and β is in P
C
Both α and β are NP-complete
D
Both α and β are in P
NP Complete    GATE-CS-2005    
Discuss it


Question 58 Explanation: 
Graph independent set decision problem is NP Complete.
Question 59
Consider the grammar
E → E + n | E × n | n 
For a sentence n + n × n, the handles in the right-sentential form of the reduction are
A
n, E + n and E + n × n
B
n, E + n and E + E × n
C
n, n + n and n + n × n
D
n, E + n and E × n
Parsing and Syntax directed translation    GATE-CS-2005    
Discuss it


Question 59 Explanation: 
E → E + n       {Applying E → E + n } 
  → E + E * n   {Applying E → E * n } 
  → E + n * n   {Applying E → n } 
  → n + n * n   {Applying E → n } 
Question 60
Consider the grammar
S → (S) | a
Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good
A
n1 < n2 < n3
B
n1 = n3 < n2
C
n1 = n2 = n3
D
n1 ≥ n3 ≥ n2
Parsing and Syntax directed translation    GATE-CS-2005    
Discuss it


Question 60 Explanation: 
LALR(1) is formed by merging states of LR(1) ( also called CLR(1)), hence no of states in LALR(1) is less than no of states in LR(1), therefore n3 < n2. And SLR(1) and LALR(1) have same no of states, i.e ( n1 = n3).
Hence n1 = n3 < n2
Question 61
Consider line number 3 of the following C- program.
int main ( ) {                   /* Line 1 */
  int I, N;                      /* Line 2 */
  fro (I = 0, I < N, I++);       /* Line 3 */
}
Identify the compiler's response about this line while creating the object-module
A
No compilation error
B
Only a lexical error
C
Only syntactic errors
D
Both lexical and syntactic errors
Misc    GATE-CS-2005    
Discuss it


Question 61 Explanation: 
Note that there is 'fro' instead of 'for'. This is not a lexical error as lexical analysis typically involves Tokenization.
Question 62
Consider the following circuit involving a positive edge triggered D FF. gatecs20051 Consider the following timing diagram. Let Ai represent the logic level on the line A in the i-th clock period. gatecs2005 Let A' represent the complement of A. The correct output sequence on Y over the clock periods 1 through 5 is
A
A0 Al A1' A3 A4
B
A0 Al A2' A3 A4
C
Al A2 A2' A3 A4
D
Al A2' A3 A4 A5'
Digital Logic & Number representation    GATE-CS-2005    
Discuss it


Question 62 Explanation: 
The Flip Flop used here is a Positive edge triggered D Flip Flop, which means that only at the "rising edge of the clock" flip flop will capture the input provided at D and accordingly give the output at Q. And at other times of the clock the output doesn't change. The output of D flip flop is same as input, i.e. Y=Q=D ( at the rising edge ). Now, in the question above, 5 clock periods are given, and we have to find the output Q or Y in those clock periods. First, let's derive the boolean expression for the Logic gate. which is : D = AX + X' Q' Now, In the 1st clock period, (i.e. when t = 0 to 1 ) here the clock has rising edge at t= 0, hence at this moment only, D flip flop will change its state. In the 1st clock,  X = 1, So,  D = A. Now A logic line may have different levels at different clock periods, i.e. may be high or low, therefore we have to answer with respect to the ith clock period where Ai is the logic level ( high or low ) of logic line A in the ith clock. So in the 1st clock period, A logic value should be A1 ( i.e. value of A in 1st clock period), but due to the delay provided by the Logic Gates ( Propagation Delay) the value of A used by Flip Flop is previous value of A only, i.e.it will capture the value of D resulted by using the logic line A in the 0th clock period, which is A0. Same happens with the value of X, i.e. instead of Xi, previous value of X  is used in the in the ith clock period, which is Xi-1. Now, In the 1st clock period value of X is same as in the 0th clock, i.e. logic 1. So, X = 1 ,and A = A0, therefore, D = A0, and hence Q = Y = A0 Similarly we have to do for other clock periods, i.e. instead of taking Ai and Xi,  Ai-1 and Xi-1 need to be taken for getting the output in the ith clock period. In the 2nd clock period, (i.e. when t = 1 to 2 ) X = 1 ( value in the previous clock), So, D = A1 ( value of A in the previous clock)  , therefore Q = Y = A1 In the 3rd clock period, (i.e. when t = 2 to 3 ) X = 0 ( value in the previous clock,see the timing diagram), So, D = Q' = A1' , therefore Q = Y = A1'   ( because of the feedback line ) In the 4th clock period, (i.e. when t = 3 to 4 ) X = 1 ( value in the previous clock,  ), So, D = A3 , therefore Q =  Y = A3 In the 5th clock period, (i.e. when t = 4 to 5 ) X = 1 ( value in the previous clock ), so, D = A4 , therefore Q = Y = A4 Hence the output sequence is : A0 A1 A1' A3 A4
Question 63
The following diagram represents a finite state machine which takes as input a binary number from the least significant bit. GATECS2005Q63 Which one of the following is TRUE?
A
It computes 1's complement of the input number
B
It computes 2's complement of the input number
C
It increments the input number
D
It decrements the input number
Regular languages and finite automata    GATE-CS-2005    
Discuss it


Question 63 Explanation: 
The given finite state machine takes a binary number from LSB as input.
The given FSM remains unchanged till first ‘1’ . After that it takes 1’s complement of rest of the input string.
We assume the input string to be ‘110010’ . Thus, according to the FSM, output is ‘001110’ .
2’s complement of ‘110010’ = 1’s complement of ‘110010’ + 1 = 001101 + 1 = 001110 Thus, the FSM computes 2’s complement of the input string.
 
Hence, option (B) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 64
Consider the following circuit gatecs2005 The flip-flops are positive edge triggered D FFs. Each state is designated as a two bit string Q0Q1. Let the initial state be 00. The state transition sequence is:
 A) digi64A 
B) digi64B
C)digi64
D)digi64D
A
A
B
B
C
C
D
D
Digital Logic & Number representation    GATE-CS-2005    
Discuss it


Question 64 Explanation: 
Q0 will toggle in every cycle because Q0' (Q0 complement) is fed as input to the D0 flip flop. For the D1 flip flop, D1 = Q0 ⊕ Q1' , i.e., Q0 XOR Q1'. So, the bit pattern Q0 Q1 will be :
Q0     Q1

0      0

1      1

0      1

1      0

0      0

.      .

.      .

.      .
Thus, the transition sequence will be GATECS2005Q64D So, D would be the correct choice.   Please comment below if you find anything wrong in the above post.
Question 65
Consider a three word machine instruction
ADD A[R0], @ B 
The first operand (destination) "A [R0]" uses indexed addressing mode with R0 as the index register. The second operand (source) "@ B" uses indirect addressing mode. A and B are memory addresses residing at the second and the third words, respectively. The first word of the instruction specifies the opcode, the index register designation and the source and destination addressing modes. During execution of ADD instruction, the two operands are added and stored in the destination (first operand). The number of memory cycles needed during the execution cycle of the instruction is
A
3
B
4
C
5
D
6
Computer Organization and Architecture    GATE-CS-2005    
Discuss it


Question 65 Explanation: 
In Indexed addressing mode, the base address is already in the instruction i.e A and to fetch the index data from R0 no memory access is required because it's a register So to fetch the operand only 1 memory cycle is required. Indirect Addressing mode requires 2 memory cycles only
Question 66
Match each of the high level language statements given on the left hand side with the most natural addressing mode from those listed on the right hand side.
 1 A[1] = B[J];	     a Indirect addressing
 2 while [*A++];     b Indexed, addressing
 3 int temp = *x;    c Autoincrement 
A
(1, c), (2, b), (3, a)
B
(1, a), (2, c), (3, b)
C
(1, b), (2, c), (3, a)
D
(1, a), (2, b), (3, c)
Computer Organization and Architecture    GATE-CS-2005    
Discuss it


Question 66 Explanation: 
List 1                           List 2
1) A[1] = B[J];      b) Indirect addressing 
Here indexing is used

2) while [*A++];     c) auto increment
The memory locations are automatically incremented

3) int temp = *x;    a) Indirect addressing
Here temp is assigned the value of int type stored
at the address contained in X

Hence (C) is correct solution. See Addressing Modes for more information.

Question 67
Consider a direct mapped cache of size 32 KB with block size 32 bytes. The CPU generates 32 bit addresses. The number of bits needed for cache indexing and the number of tag bits are respectively
A
10, 17
B
10, 22
C
15, 17
D
5, 17
Computer Organization and Architecture    GATE-CS-2005    
Discuss it


Question 67 Explanation: 
Cache is direct mapped size of cache=32 KB  =2 5* 2 10 Bytes=2 15 Bytes. Require 15 bits for cache addressing  so CPU address has tag and index  No. of tag bits=32-15=17 From 15 cache addressing bits consist of blocks and words. Each block has 32 words(bytes) So require 5 bit.Index=block +word  Block=15-5=10  So 10,17 Hence (A)  is correct option.
Question 68
A 5 stage pipelined CPU has the following sequence of stages:
IF — Instruction fetch from instruction memory,
RD — Instruction decode and register read,
EX — Execute: ALU operation for data and address computation,
MA — Data memory access - for write access, the register read
     at RD stage is used,
WB — Register write back.
Consider the following sequence of instructions:
I1 : L R0, 1oc1;        R0 <= M[1oc1]
I2 : A R0, R0;           R0 <= R0 + R0
I3 : S R2, R0;           R2 <= R2 - R0
Let each stage take one clock cycle.
What is the number of clock cycles taken to complete the above sequence of instructions starting from the fetch of I1 ?
A
8
B
10
C
12
D
15
Computer Organization and Architecture    GATE-CS-2005    
Discuss it


Question 68 Explanation: 

If we use operand forwarding from memory stage :
2005-68-1
If we don’t use operand forwarding :
2008-68-2
Thus, clock cycles = 8 / 11 Since, 11 is not in the option. So, clock cycles = 8.
 
Thus, option (A) is correct.
 
Please comment below if you find anything wrong in the above post.
Question 69
A device with data transfer rate 10 KB/sec is connected to a CPU. Data is transferred byte-wise. Let the interrupt overhead be 4 msec. The byte transfer time between the device interface register and CPU or memory is negligible. What is the minimum performance gain of operating the device under interrupt mode over operating it under program controlled mode?
A
15
B
25
C
35
D
45
Input Output Systems    GATE-CS-2005    
Discuss it


Question 69 Explanation: 
In programmed I/O, CPU does continuous polling,
To transfer 10KB CPU polls for 1 sec = 10^6 micro-sec of processing
In interrupt mode CPU is interrupted on completion of i\o ,
To transfer 10 KB CPU does 4 micro-sec of processing.
Gain = 10^6 / 4 = 25000
250000 for 10000 bytes and 25 for 1 bytes.
Question 70
Consider a disk drive with the following specifications: 16 surfaces, 512 tracks/surface, 512 sectors/track, 1 KB/sector, rotation speed 3000 rpm. The disk is operated in cycle stealing mode whereby whenever one byte word is ready it is sent to memory; similarly, for writing, the disk interface reads a 4 byte word from the memory in each DMA cycle. Memory cycle time is 40 nsec. The maximum percentage of time that the CPU gets blocked during DMA operation is:
A
10
B
25
C
40
D
50
Input Output Systems    GATE-CS-2005    
Discuss it


Question 70 Explanation: 
Time takes for 1 rotation = 60/3000 It reads 512*1024 Bytes in one rotation. Time taken to read 4 bytes = 153 ns 153 is approximately 4 cycles (160ns) Percentage of time CPU gets blocked = 40*100/160 = 25
Question 71
Suppose n processes, P1, …. Pn share m identical resource units, which can be reserved and released one at a time. The maximum resource requirement of process Pi is Si, where Si > 0. Which one of the following is a sufficient condition for ensuring that deadlock does not occur?
A
A
B
B
C
C
D
D
GATE-CS-2005    Deadlock    
Discuss it


Question 71 Explanation: 
Question 72
Consider the following code fragment:
  if (fork() == 0)
  { a = a + 5; printf(“%d,%d\n”, a, &a); }
  else { a = a –5; printf(“%d, %d\n”, a, &a); } 
Let u, v be the values printed by the parent process, and x, y be the values printed by the child process. Which one of the following is TRUE?
A
u = x + 10 and v = y
B
u = x + 10 and v != y
C
u + 10 = x and v = y
D
u + 10 = x and v != y
GATE-CS-2005    
Discuss it


Question 72 Explanation: 
When a fork() system call is issued, a copy of all the pages corresponding to the parent process is created, loaded into a separate memory location by the OS for the child process. But this is not needed in certain cases. When the child is needed just to execute a command for the parent process, there is no need for copying the parent process' pages, since exec replaces the address space of the process which invoked it with the command to be executed. In such cases, a technique called copy-on-write (COW) is used. With this technique, when a fork occurs, the parent process's pages are not copied for the child process. Instead, the pages are shared between the child and the parent process. Whenever a process (parent or child) modifies a page, a separate copy of that particular page alone is made for that process (parent or child) which performed the modification. This process will then use the newly copied page rather than the shared one in all future references. fork() returns 0 in child process and process ID of child process in parent process. In Child (x), a = a + 5 In Parent (u), a = a – 5; Child process will execute the if part and parent process will execute the else part. Assume that the initial value of a = 6. Then the value of a printed by the child process will be 11, and the value of a printed by the parent process in 1. Therefore u+10=x Now the second part. The answer is v = y. We know that, the fork operation creates a separate address space for the child. But the child process has an exact copy of all the memory segments of the parent process. Hence the virtual addresses and the mapping (initially) will be the same for both parent process as well as child process. PS: the virtual address is same but virtual addresses exist in different processes' virtual address space and when we print &a, it’s actually printing the virtual address. Hence the answer is v = y. Reference: http://www.csl.mtu.edu/cs4411.ck/www/NOTES/process/fork/create.html See question 5 of http://www.geeksforgeeks.org/operating-systems-set-16/ This solution is contributed by Nitika Bansal
Question 73
In a packet switching network, packets are routed from source to destination along a single path having two intermediate nodes. If the message size is 24 bytes and each packet contains a header of 3 bytes, then the optimum packet size is:
A
4
B
6
C
7
D
9
Network Layer    GATE-CS-2005    
Discuss it


Question 73 Explanation: 
Dividing a message into packets may decrease the transmission time due to parallelism as shown in the following figure. But after a certain limit reducing the packet size may increase the transmission time also. Following figure shows the situation given in question. Let transmission time to transfer 1 byte for all nodes be t. The first packet will take time = (packet size)*3*t. After the first packet reaches the destination, remaining packets will take time equal to (packet size)*t due to parallelism.
If we use 4 bytes as packet size, there will be 24 packets
Total Transmission time = Time taken by first packet + 
                          Time taken by remaining packets 
                       = 3*4*t + 23*4*t = 104t

If we use 6 bytes as packet size, there will be 8 packets
Total Transmission time = 3*6*t + 7*6*t = 60t

If we use 7 bytes as packet size, there will be 6 packets
Total Transmission time = 3*7*t + 5*7*t = 56t

If we use 9 bytes as packet size, there will be 4 packets
Total Transmission time = 3*9*t + 3*9*t = 54t
Source: question 2 of http://www.geeksforgeeks.org/computer-networks-set-6/ Related Articles: Circuit Switching Vs Packet Switching
Question 74
Suppose the round trip propagation delay for a 10 Mbps Ethernet having 48-bit jamming signal is 46.4 ms. The minimum frame size is
A
94
B
416
C
464
D
512
Data Link Layer    GATE-CS-2005    
Discuss it


Question 74 Explanation: 
Question 75
Let E1 and E2 be two entities in an E/R diagram with simple single-valued attributes. R1 and R2 are two relationships between E1 and E2, where R1 is one-to-many and R2 is many-to-many. R1 and R2 do not have any attributes of their own. What is the minimum number of tables required to represent this situation in the relational model?
A
2
B
3
C
4
D
5
ER and Relational Models    GATE-CS-2005    
Discuss it


Question 75 Explanation: 
The answer is B, i.e minimum 3 tables. Strong entities E1 and E2 are represented as separate tables. In addition to that many-to-many relationships(R2) must be converted as seperate table by having primary keys of E1 and E2 as foreign keys. One-to-many relaionship (R1) must be transferred to 'many' side table(i.e. E2) by having primary key of one side(E1) as foreign key( this way we need not to make a seperate table for R1). Let relation schema be E1(a1,a2) and E2( b1,b2). Relation E1( a1 is the key)
a1 a2
-------
1 3
2 4
3 4
Relation E2( b1 is the key, a1 is the foreign key, hence R1(one-many) relationship set satisfy here )
b1 b2 a1
-----------
7 4 2
8 7 2
9 7 3
Relation R2 ( {a1, b1} combined is the key here , representing many-many relationship R2 )
a1 b1
--------
1 7
1 8
2 9
3 9
Hence we will have minimum of 3 tables.
Question 76
The following table has two attributes A and C where A is the primary key and C is the foreign key referencing A with on-delete cascade.
A   C
-----
2   4
3   4
4   3
5   2
7   2
9   5
6   4 
The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (2,4) is deleted is:
A
(3,4) and (6,4)
B
(5,2) and (7,2)
C
(5,2), (7,2) and (9,5)
D
(3,4), (4,3) and (6,4)
SQL    GATE-CS-2005    
Discuss it


Question 76 Explanation: 
Question 77
The relation book (title, price) contains the titles and prices of different books. Assuming that no two books have the same price, what does the following SQL query list?
  select title
  from book as B
  where (select count(*)
     from book as T
     where T.price > B.price) < 5 
A
Titles of the four most expensive books
B
Title of the fifth most inexpensive book
C
Title of the fifth most expensive bookTitles of the five most expensive books
D
Titles of the five most expensive books
SQL    GATE-CS-2005    
Discuss it


Question 77 Explanation: 
Question 78
Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional dependencies hold: {A–>B, BC–>D, E–>C, D–>A}. What are the candidate keys of R?
A
AE, BE
B
AE, BE, DE
C
AEH, BEH, BCH
D
AEH, BEH, DEH
Database Design(Normal Forms)    GATE-CS-2005    
Discuss it


Question 78 Explanation: 
Question 79
Consider the following data path of a CPU. GATECS2005Q78 The, ALU, the bus and all the registers in the data path are of identical size. All operations including incrementation of the PC and the GPRs are to be carried out in the ALU. Two clock cycles are needed for memory read operation - the first one for loading address in the MAR and the next one for loading data from the memory bus into the MDR The instruction "add R0, R1" has the register transfer interpretation R0 < = R0 + R1. The minimum number of clock cycles needed for execution cycle of this instruction is.
A
2
B
3
C
4
D
5
Computer Organization and Architecture    GATE-CS-2005    
Discuss it


Question 79 Explanation: 
Minimum number of clock cycles (execution only) = 3 1) load Y 2) input R1, add 3) output to R1
Question 80
Consider the following data path of a CPU. GATECS2005Q78 The, ALU, the bus and all the registers in the data path are of identical size. All operations including incrementation of the PC and the GPRs are to be carried out in the ALU. Two clock cycles are needed for memory read operation - the first one for loading address in the MAR and the next one for loading data from the memory bus into the MDR 79. The instruction "call Rn, sub" is a two word instruction. Assuming that PC is incremented during the fetch cycle of the first word of the instruction, its register transfer interpretation is
Rn < = PC + 1;
PC < = M[PC]; 
The minimum number of CPU clock cycles needed during the execution cycle of this instruction is:
A
2
B
3
C
4
D
5
GATE-CS-2005    
Discuss it


Question 80 Explanation: 
One cycle to increment PC, one cycle to load PC into MAR, one cycle to fetch memory content and load into PC.
Question 81
Consider the following C-function:
double foo (int n)
{
    int i;
    double sum;
    if (n = = 0) return 1.0;
    else
    {
        sum = 0.0;
        for (i = 0; i < n; i++)
            sum += foo (i);
        return sum;
    }
}
The space complexity of the above function is:
A
O(1)
B
O(n)
C
O(n!)
D
O(nn)
Analysis of Algorithms    GATE-CS-2005    
Discuss it


Question 81 Explanation: 
Note that the function foo() is recursive. Space complexity is O(n) as there can be at most O(n) active functions (function call frames) at a time.
Question 82
Consider the following C-function:
double foo (int n)
{
    int i;
    double sum;
    if (n = = 0) return 1.0;
    else
    {
        sum = 0.0;
        for (i = 0; i < n; i++)
            sum += foo (i);
        return sum;
    }
}
Suppose we modify the above function foo() and store the values of foo (i), 0 < = i < n, as and when they are computed. With this modification, the time complexity for function foo() is significantly reduced. The space complexity of the modified function would be:
A
O(1)
B
O(n)
C
O(n!)
D
O(nn)
Analysis of Algorithms    GATE-CS-2005    
Discuss it


Question 82 Explanation: 
Space complexity now is also O(n). We would need an array of size O(n). The space required for recursive calls would be O(1) as the values would be taken from stored array rather than making function calls again and again.
Question 83
Let s and t be two vertices in a undirected graph G + (V, E) having distinct positive edge weights. Let [X, Y] be a partition of V such that s ∈ X and t ∈ Y. Consider the edge e having the minimum weight amongst all those edges that have one vertex in X and one vertex in Y The edge e must definitely belong to:
A
the minimum weighted spanning tree of G
B
the weighted shortest path from s to t
C
each path from s to t
D
the weighted longest path from s to t
Graph Minimum Spanning Tree    GATE-CS-2005    
Discuss it


Question 83 Explanation: 
The minimum weight edge on any s-t cut is always part of MST. This is called Cut Property. This is the idea used in Prim's algorithm. The minimum weight cut edge is always a minimum spanning tree edge. Why B (the weighted shortest path from s to t) is not an answer? See below example, edge 4 (lightest in highlighted red cut from s to t) is not part of shortest path. ShortestPathCut
Question 84
Let s and t be two vertices in a undirected graph G + (V, E) having distinct positive edge weights. Let [X, Y] be a partition of V such that s ∈ X and t ∈ Y. Consider the edge e having the minimum weight amongst all those edges that have one vertex in X and one vertex in Y. Let the weight of an edge e denote the congestion on that edge. The congestion on a path is defined to be the maximum of the congestions on the edges of the path. We wish to find the path from s to t having minimum congestion. Which one of the following paths is always such a path of minimum congestion?
A
a path from s to t in the minimum weighted spanning tree
B
a weighted shortest path from s to t
C
an Euler walk from s to t
D
a Hamiltonian path from s to t
Graph Theory    GATE-CS-2005    
Discuss it


Question 84 Explanation: 
Suppose shortest path from A->B is 6, but in MST, we have A->C->B (A->C = 4, C->B = 3), then along the path in MST, we have minimum congestion, i.e 4
Question 85
Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.
 E → number 	 E.val = number. val
    | E '+' E 	 E(1).val = E(2).val + E(3).val
    | E '×' E	 E(1).val = E(2).val × E(3).val
The above grammar and the semantic rules are fed to a yacc tool (which is an LALR (1) parser generator) for parsing and evaluating arithmetic expressions. Which one of the following is true about the action of yacc for the given grammar?
A
It detects recursion and eliminates recursion
B
It detects reduce-reduce conflict, and resolves
C
It detects shift-reduce conflict, and resolves the conflict in favor of a shift over a reduce action
D
It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action
Parsing and Syntax directed translation    GATE-CS-2005    
Discuss it


Question 85 Explanation: 
  Background yacc conflict resolution is done using following rules: shift is preferred over reduce while shift/reduce conflict. first reduce is preferred over others while reduce/reduce conflict.   You can answer to this question straightforward by constructing LALR(1) parse table, though its a time taking process. To answer it faster, one can see intuitively that this grammar will have a shift-reduce conflict for sure. In that case, given this is a single choice question, (C) option will be the right answer. Fool-proof explanation would be to generate LALR(1) parse table, which is a lengthy process. Once we have the parse table with us, we can clearly see that i. reduce/reduce conflict will not arise in the above given grammar ii. shift/reduce conflict will be resolved by giving preference to shift, hence making the expression calculator right associative. According to the above conclusions, only correct option seems to be (C). Referance: http://dinosaur.compilertools.net/yacc/ This solution is contributed by Vineet Purswani.
Question 86
Consider the following expression grammar. The seman­tic rules for expression calculation are stated next to each grammar production.
 E → number 	 E.val = number. val
    | E '+' E 	 E(1).val = E(2).val + E(3).val
    | E '×' E	 E(1).val = E(2).val × E(3).val 
Assume the conflicts in Part (a) of this question are resolved and an LALR(1) parser is generated for parsing arithmetic expressions as per the given grammar. Consider an expression 3 × 2 + 1. What precedence and associativity properties does the generated parser realize?
A
Equal precedence and left associativity; ex­pression is evaluated to 7
B
Equal precedence and right associativity; ex­pression is evaluated to 9
C
Precedence of '×' is higher than that of '+', and both operators are left associative; expression is evaluated to 7
D
Precedence of '+' is higher than that of '×', and both operators are left associative; expression is evaluated to 9
Parsing and Syntax directed translation    GATE-CS-2005    
Discuss it


Question 86 Explanation: 
The Operator which is closer to the starting symbol is having the least precedence. So (c) should be the correct one.
Question 87
We are given 9 tasks T1, T2.... T9. The execution of each task requires one unit of time. We can execute one task at a time. Each task Ti has a profit Pi and a deadline di Profit Pi is earned if the task is completed before the end of the dith unit of time.
Task     T1  T2	 T3  T4  T5  T6	 T7 T8  T9
Profit   15  20	 30  18  18  10	 23 16  25
Deadline 7   2 	 5   3 	 4   5 	 2  7   3 
Are all tasks completed in the schedule that gives maximum profit?
A
All tasks are completed
B
T1 and T6 are left out
C
T1 and T8 are left out
D
T4 and T6 are left out
Misc    GATE-CS-2005    
Discuss it


Question 87 Explanation: 
Task     T1  T2	 T3  T4  T5  T6	 T7 T8  T9
Profit   15  20	 30  18  18  10	 23 16  25
Deadline 7   2 	 5   3 	 4   5 	 2  7   3 
To maximize profit, we can finish tasks in following order T7, T2, T9, T5, T3, T8, T1
Question 88
We are given 9 tasks T1, T2.... T9. The execution of each task requires one unit of time. We can execute one task at a time. Each task Ti has a profit Pi and a deadline di Profit Pi is earned if the task is completed before the end of the dith unit of time.
Task     T1  T2	 T3  T4  T5  T6	 T7 T8  T9
Profit   15  20	 30  18  18  10	 23 16  25
Deadline 7   2 	 5   3 	 4   5 	 2  7   3 
What is the maximum profit earned?
A
147
B
165
C
167
D
175
Misc    GATE-CS-2005    
Discuss it


Question 88 Explanation: 
Task     T1  T2	 T3  T4  T5  T6	 T7 T8  T9
Profit   15  20	 30  18  18  10	 23 16  25
Deadline 7   2 	 5   3 	 4   5 	 2  7   3 
To maximize profit, we can finish tasks in following order T7, T2, T9, T5, T3, T8, T1. We get the maximum profit as 23 + 20 + 25 + 18 + 30 + 16 + 15 = 147
Question 89
Consider the following floating point format GATECS2005Q84A Mantissa is a pure fraction in sign-magnitude form. The decimal number 0.239 × 213 has the following hexadecimal representation (without normalization and rounding off :
A
0D 24
B
0D 4D
C
4D 0D
D
4D 3D
Digital Logic & Number representation    GATE-CS-2005    
Discuss it


Question 89 Explanation: 
ans_45
Question 90
Consider the following floating point format GATECS2005Q84A Mantissa is a pure fraction in sign-magnitude form. The normalized representation for the above format is specified as follows. The mantissa has an implicit 1 preceding the binary (radix) point. Assume that only 0's are padded in while shifting a field. The normalized representation of the above number (0.239 × 213) is:
A
0A 20
B
11 34
C
4D D0
D
4A E8
Digital Logic & Number representation    GATE-CS-2005    
Discuss it


Question 90 Explanation: 
ans_46
There are 90 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.