GATE-CS-2015 (Set 1)

Question 1
Didn’t you buy _________ when you went shopping?
A
any paper
B
much paper
C
no paper
D
a few paper
English    GATE-CS-2015 (Set 1)    
Discuss it


Question 1 Explanation: 
In general, any is used in negative sentences and questions.
Question 2
Which of the following options is the closest in meaning to the sentence below?
She enjoyed herself immensely at the party.
A
She had a terrible time at the party
B
She had a horrible time at the party
C
She had a terrific time at the party
D
She had a terrifying time at the party
English    GATE-CS-2015 (Set 1)    
Discuss it


Question 2 Explanation: 
Except C, all other options indicate that she didn't enjoy. Horrible and terrible means fearful . Terrific means wonderful. 
Question 3
Given Set A = {2, 3, 4, 5} and Set B = {11, 12, 13, 14, 15}, two numbers are randomly selected, one from each set. What is the probability that the sum of the two numbers equals 16?
A
0.20
B
0.25
C
0.30
D
0.33
Probability    GATE-CS-2015 (Set 1)    
Discuss it


Question 3 Explanation: 
There are 20 possible pairs from {2, 3, 4, 5} and {11, 12, 13, 14, 15} i.e 5*4=20 Out of which following pairs have sum 16.
(2, 14)
(3, 13)
(4, 12)
(5, 11) 

Probability = Favorable Outcomes/Total Outcomes
Probability = 4/20 = 0.20

Therefore option A is correct
Question 4
Based on the given statements, select the most appropriate option to solve the given question. If two floors in a certain building are 9 feet apart, how many steps are there in a set of stairs that extends from the first floor to the second floor of the building?  
Statements:
1. Each step is 3/4 foot high.
2. Each step is 1 foot wide.
A
Statement 1 alone is sufficient, but statement 2 alone is not sufficient
B
Statement 2 alone is sufficient, but statement 1 alone is not sufficient
C
Both statement together are sufficient, but neither statement alone is sufficient
D
Statement 1 and 2 together are not sufficient
General Aptitude    GATE-CS-2015 (Set 1)    
Discuss it


Question 4 Explanation: 
When we climb from one floor to other, it is the height that matters and not the width of the staircase.Therefore, From statement 1 only, we can figure out that 9 / (3/4) or 12 steps are required.
Question 5
Which one of the following combinations is incorrect?
A
Acquiescence - Submission
B
Wheedle - Roundabout
C
Flippancy - Lightness
D
Profligate - Extravagant
English    GATE-CS-2015 (Set 1)    
Discuss it


Question 5 Explanation: 
Flippancy     ---> lack of respect or seriousness.
Acquiescence  ---> the reluctant acceptance of 
                   something without protest.
Wheedle      --->  use endearments or flattery to 
                   persuade someone to do something or 
Profligate   ---> recklessly extravagant 
Question 6
The number of students in a class who have answered correctly, wrongly, or not attempted each question in an exam, are listed in the table below. The marks for each question are also listed. There is no negative or partial marking.
Q.No. Marks Answered-Correctly Answered-Wrongly Not-Attempted
 1      2         21                17               6 
 2      3         15                27               2    
 3      1         11                29               4
 4      2         23                18               3
 5      5         31                12               1 
What is the average of the marks obtained by the class in the examination?
A
2.290
B
2.970
C
6.795
D
8.795
General Aptitude    GATE-CS-2015 (Set 1)    
Discuss it


Question 6 Explanation: 
There are total 44 students. This count can be obtained by adding last 3 entries of any row of given total.
Total marks = 2*21 + 3*15 + 1*11 + 2*23  + 5*31
            = 299
Average marks =  299/44 = 6.795 
Question 7
Select the alternative meaning of the underlined part of the sentence. The chain snatchers took to their heels when the police party arrived.
A
took shelter in a thick jungle
B
open indiscriminate fire
C
took to flight
D
unconditionally surrendered
English    GATE-CS-2015 (Set 1)    
Discuss it


Question 7 Explanation: 
Both took to flight and took to their heels mean run away.
Question 8
The given statement is following by some courses of action. Assuming the statement to be true, decide the correct option.
Statement: 
There has been a significant drop in the water level 
in the lakes supplying water to the city.

Course of action:
1. The water supply authority should impose a partial 
   cut in supply to tackle the situation.
2. The government should appeal to all the residents 
   through mass media for minimal use of water.
3. The government should ban the water supply in lower 
   areas
A
Statement 1 and 2 follow
B
Statement 1 and 3 follow
C
Statement 2 and 3 follow
D
All statements follow
General Aptitude    GATE-CS-2015 (Set 1)    
Discuss it


Question 8 Explanation: 
3rd course of action is not correct. Banning water supply can not solve the problem.
Question 9
The pie chart below has the breakup of the number of students, from different departments in an engineering college for the year 2012. The proportion of male to female students in each department is 5 : 4. There are 40 males in Electrical Engineering. What is the different between the numbers of female students in the Civil department and the female students in the Mechanical department? Q9
A
32
B
16
C
48
D
8
General Aptitude    GATE-CS-2015 (Set 1)    
Discuss it


Question 9 Explanation: 
Total male students in Electrical = 40 Total female in Electrical = (40 * 4)/5 = 32 Total female in Mechanical = 32/2 = 16 Total female in Civil = [(30 + 42)*3/2]*4/9 = = 72 * 2/3 = 48 The difference is 32.
Question 10
The probabilities that a student passes in Mathematics, Physics and Chemistry are m, p and c respectively. Of these subjects, the student has 75% chance of passing in at least one, a 50% chance of passing in at least two and a 40% chance of passing in exactly two. Following relations are drawn in m, p and c:
1. p + m + c = 27/20 
2. p + m + c = 13/20
3. (p) × (m) × (c) = 1/10 
A
Only relation 1 is true
B
Only relation 2 is true
C
Relations 2 and 3 are true
D
Relations 1 and 3 are true
Probability    GATE-CS-2015 (Set 1)    
Discuss it


Question 10 Explanation: 
1 - (1 - m) (1 - p) (1 - c) = 0.75               -------(1)
(1 - m)pc +  (1 - p)mc + (1 - c)mp + mpc = 0.5   -------(2)
(1 - m)pc +  (1 - p)mc + (1 - c)mp  = 0.4        -------(3)

From last 2 equations, we can derive mpc = 0.1

After simplifying equation 1, we get.
p + c + m - (mp + mc + pc) + mpc = 0.75        
p + c + m - (mp + mc + pc) = 0.65         -------(4)

After simplifying equation 3, we get
pc + mc + mp - 3mpc = 0.4

Putting value of mpc, we get
pc + mc + mp = 0.7

After putting above value in equation 4, we get
 p + c + m - 0.7 = 0.65
 p + c + m = 1.35 = 27/20 
Question 11
Match the following
       List-I                            List-II
A. Condition coverage                 1. Black-box testing
B. Equivalence class partitioning     2. System testing
C. Volume testing                     3. White-box testing
D. Alpha testing                      4. Performance testing

Codes:
   A B C D
(a) 2 3 1 4
(b) 3 4 2 1
(c) 3 1 4 2
(d) 3 1 2 4
A
a
B
b
C
c
D
d
Software Engineering    GATE-CS-2015 (Set 1)    
Discuss it


Question 11 Explanation: 
White Box Testing tests internal structures or workings of an application. It covers following Control flow testing Data flow testing Branch testing Statement coverage Decision coverage Modified condition/decision coverage Prime path testing Path testing So conditional coverage must be in White-Box Testing. Black-box testing is a method of software testing that examines the functionality of an application without peering into its internal structures or workings. Typical black-box test design techniques include: Decision table testing All-pairs testing Equivalence partitioning Boundary value analysis Cause–effect graph Error guessing Volume Testing Does performance testing for specific size. Alpha testing is system testing by potential users/customers or an independent test team at the developers' site.
Question 12
Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n(≥ 2) numbers? In the recurrence equations given in the options below, c is a constant.
A
T(n) = 2T (n/2) + cn
B
T(n) = T(n – 1) + T(0) + cn
C
T(n) = 2T (n – 2) + cn
D
T(n) = T(n/2) + cn
Analysis of Algorithms    Sorting    GATE-CS-2015 (Set 1)    QuickSort    
Discuss it


Question 12 Explanation: 
In worst case, the chosen pivot is always placed at a corner position and recursive call is made for following. a) for subarray on left of pivot which is of size n-1 in worst case. b) for subarray on right of pivot which is of size 0 in worst case.
Question 13
For any two languages L1 and L2 such that L1 is context free and L2 is recursively enumerable but not recursive, which of the following is/are necessarily true?
1. L1' (complement of L1) is recursive 
2. L2' (complement of L2) is recursive
3. L1' is context-free 
4. L1' ∪ L2 is recursively enumerable 
A
1 only
B
3 only
C
3 and 4 only
D
1 and 4 only
Recursively enumerable sets and Turing machines    GATE-CS-2015 (Set 1)    
Discuss it


Question 13 Explanation: 
1. L1' (complement of L1) is recursive is true L1 is context free. Every context free language is also recursive and recursive languages are closed under complement. 4. L1' ∪ L2 is recursively enumerable is true Since L1' is recursive, it is also recursively enumerable and recursively enumerable languages are closed under union. 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: Wiki) 3. L1' is context-free: Context-free languages are not closed under complement, intersection, or difference. 2. L2' (complement of L2) is recursive is false: Recursively enumerable languages are not closed under set difference or complementation
Question 14
Q14
A
B
0
C
1
D
Not Defined
Numerical Methods and Calculus    GATE-CS-2015 (Set 1)    
Discuss it


Question 14 Explanation: 
[Tex]\lim_{x\to\infty} 1/x[/Tex] = 0. and [Tex]\lim_{x\to\infty} x^0[/Tex] = 1.
  Alternate method : Using log lnm=lim x->infinity 1/x*lnx lim x->infinity lnx/x  (numerator = finite value,denominator = infinity and finite/infinite=0   ) ln(m)=0 m=e0=1    
Question 15
Q15
A
a
B
b
C
c
D
d
Numerical Methods and Calculus    GATE-CS-2015 (Set 1)    
Discuss it


Question 15 Explanation: 
g(h(x)) = g(x/(x-1)) = 1 - x/(x-1) = -1/(x-1)

h(g(x)) = h(1-x) = (1-x)/((1-x) - 1) = -(1-x)/x


g(h(x)) / h(g(x))  = [-1/(x-1)] / [-(1-x)/x]
                   = -x/(x-1)2

-x/(x-1)2 is same as h(x) / g(x) 
Question 16
Match the following
List-I
A. Prim’s algorithm for minimum spanning tree
B. Floyd-Warshall algorithm for all pairs shortest paths
C. Mergesort
D. Hamiltonian circuit
List-II
1. Backtracking
2. Greed method
3. Dynamic programming
4. Divide and conquer
Codes:
    A B C D
(a) 3 2 4 1
(b) 1 2 4 3
(c) 2 3 4 1
(d) 2 1 3 4 
A
a
B
b
C
c
D
d
Misc    GATE-CS-2015 (Set 1)    
Discuss it


Question 16 Explanation: 
Prim's Algorithm is a greedy algorithm where greedy choice is to pick minimum weight edge from cut that divides already picked vertices and vertices yet to be picked. Floyd-Warshall algorithm for all pairs shortest paths is a Dynamic Programming algorithm where we keep updating the distance matrix in bottom up manner. Merge Sort is clearly divide and conquer which follows all steps of divide and conquer. It first divides the array in two halves, then conquer the two halves and finally combines the conquered results. Hamiltonian circuit is a NP complete problem, that can be solved using Backtracking
Question 17
Select operation in SQL is equivalent to
A
the selection operation in relational algebra
B
the selection operation in relational algebra, except that select in SQL retains duplicates
C
the projection operation in relational algebra
D
the projection operation in relational algebra, except that select in SQL retains duplicates
SQL    GATE-CS-2015 (Set 1)    
Discuss it


Question 17 Explanation: 
Select operation is equivalent to the projection operation in relational algebra, except that select in SQL retains duplicates and on the contrary projection removes the duplicates.
Question 18
For computers based on three-address instruction formats, each address field can be used to specify which of the following:
S1: A memory operand
S2: A processor register
S3: An implied accumulator register
A
Either S1 or S2
B
Either S2 or S3
C
Only S2 and S3
D
All of S1, S2 and S3
Computer Organization and Architecture    GATE-CS-2015 (Set 1)    
Discuss it


Question 18 Explanation: 
In Three address instruction format, each operand specifies either a memory address or a register. See http://homepage.cs.uiowa.edu/~ghosh/1-19-06.pdf
Question 19
The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
P1() 
{ 
   C = B – 1; 
   B = 2*C;  
}

P2()
{
   D = 2 * B;
   B = D - 1; 
}
The number of distinct values that B can possibly take after the execution is
A
3
B
2
C
5
D
4
Process Management    GATE-CS-2015 (Set 1)    
Discuss it


Question 19 Explanation: 
There are following ways that concurrent processes can follow.
 C = B – 1;   // C = 1
 B = 2*C;    // B = 2
 D = 2 * B;   // D  = 4
 B = D - 1;   // B  = 3


 C = B – 1;   // C = 1
 D = 2 * B;   // D = 4
 B = D - 1;   // B = 3
 B = 2*C;    // B = 2

 C = B – 1;  // C = 1
 D = 2 * B; // D =  4
 B = 2*C;  // B = 2
 B = D - 1;  // B = 3

 D = 2 * B; // D =  4
 C = B – 1;  // C = 1
 B = 2*C;  // B = 2
 B = D - 1;  // B = 3

 D = 2 * B; // D =  4
 B = D - 1;  // B = 3
 C = B – 1;  // C = 2
 B = 2*C;  // B = 4 
There are 3 different possible values of B: 2, 3 and 4.
Question 20
Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)?
1. 3, 5, 7, 8, 15, 19, 25
2. 5, 8, 9, 12, 10, 15, 25
3. 2, 7, 10, 8, 14, 16, 20
4. 4, 6, 7, 9, 18, 20, 25 
A
1 and 4 only
B
2 and 3 only
C
2 and 4 only
D
2 only
GATE-CS-2015 (Set 1)    
Discuss it


Question 20 Explanation: 
An Inorder traversal of a Binary Search Tree must be in increasing order.
Question 21
The output of the following C program is __________.
void f1 (int a, int b)
{
  int c;
  c=a; a=b; b=c;
}
void f2 (int *a, int *b)
{
  int c;
  c=*a; *a=*b;*b=c;
}
int main()
{
  int a=4, b=5, c=6;
  f1(a, b);
  f2(&b, &c);
  printf (“%d”, c-a-b);
  return 0;
}
A
-5
B
-4
C
5
D
3
Functions    GATE-CS-2015 (Set 1)    
Discuss it


Question 21 Explanation: 
The function call to to f1(a, b) won't have any effect as the values are passed by value. The function call f2(&b, &c) swaps values of b and c. So b becomes 6 and c becomes 5. Value of c-a-b becomes 5-4-6 which is -5.
Question 22
Consider a system with byte-addressable memory, 32 bit logical addresses, 4 kilobyte page size and page table entries of 4 bytes each. The size of the page table in the system in megabytes is ___________
A
2
B
4
C
8
D
16
Memory Management    GATE-CS-2015 (Set 1)    
Discuss it


Question 22 Explanation: 
Number of entries in page table = 232 / 4Kbyte  
                                = 232 / 212 
                                        = 220

Size of page table = (No. page table entries)*(Size of an entry) 
                   = 220 * 4 bytes 
                   = 222 
                   = 4 Megabytes
Question 23
Which one of the following is True at any valid state in shift-reduce parsing?
A
Viable prefixes appear only at the bottom of the stack and not inside
B
Viable prefixes appear only at the top of the stack and not inside
C
The stack contains only a set of viable prefixes
D
The stack never contains viable prefixes
Parsing and Syntax directed translation    GATE-CS-2015 (Set 1)    
Discuss it


Question 23 Explanation: 
The prefixes of right sentential forms that can appear on the stack of a shift-reduce parser are called viable prefixes. By definition, a viable prefix is a prefix of a right sentential form that does not continue past the right end of the rightmost handle of that sentential form. Source http://cse.iitkgp.ac.in/~bivasm/notes/scribe/11CS30001.pdf
Question 24
Which one of the following is not equivalent to p←→q Q81
A
A
B
B
C
C
D
D
Propositional and First Order Logic.    GATE-CS-2015 (Set 1)    
Discuss it


Question 24 Explanation: 
This question is the revision of basics of propositional logic. Conjunction Conjunction of p and q, denoted by p ∨q, is the proposition ‘p or q’.The Conjunction p ∨q is when anyone of p or q is TRUE. Disjunction Disjunction of p and q, denoted by p ∧q, is the proposition ‘p and q’. The Disjunction p ∧q is TRUE when both p and q is TRUE. Logical Implication It is a type of relationship between two statements or sentence. Denoted by ‘p → q’. The conditional statement p → q is false when p is true and q is false, and true otherwise. i.e. p→ q = ¬p ∨q Bi-Condition A bi-conditional statement is a compound statement formed by combining two conditionals under “and.” Bi-conditionals are true when both statements have the exact same truth value. Solution : p←→q means both p→q and q→p p→q is equivalent to ⌉p ∨ q So A and B are fine. D is a different way of writing A p ↔ q = (p→ q) ∧ (q→p) (⌉p ∨ q) ∧ (q → p)         ( As p→ q = ⌉p ∨ q ) (⌉p ∨ q) ∧ (⌉q ∨ p) = (¬p ∧ p )∨ (¬p ∧¬q )∨ (q ∧p ) ∨(q ∧¬q ) (Distributive law) As ((¬p∧ p )=0,(q ∧¬q )=0) (Complementation) (⌉p ∧ ⌉q) ∨ (p ∧ q) So, answer C
Question 25
Which of following statements is/are False?
1. XML overcomes the limitations in HTML 
   to support a structured way of organizing content.

2. XML specification is not case sensitive while 
   HTML specification is case sensitive.

3. XML supports user defined tags while HTML
   uses pre-defined tags.

4. XML tags need not be closed while HTML 
   tags must be closed.
A
2 only
B
1 only
C
2 and 4 only
D
3 and 4 only
HTML and XML    GATE-CS-2015 (Set 1)    
Discuss it


Question 25 Explanation: 
1.TRUE- XML is a structured way of 
         organizing content.
2.FALSE- XML is CASE SENSITIVE whereas 
          HTML is NOT case sensitive. 
3.TRUE- XML facilitates User Defined tags
        whereas HTML has only Pre-Defined
        tags 
4.FALSE- XML tags MUST be closed while HTML 
         tags may NOT be closed.
Question 26
For a set A, the power set of A is denoted by 2A. If A = {5, {6}, {7}}, which of the following options are True. Q12
A
I and III only
B
II and III only
C
I, II and III only
D
I, II and IV only
Combinatorics    GATE-CS-2015 (Set 1)    
Discuss it


Question 26 Explanation: 
A = {5, {6}, {7}}

Below is Powerset of A
{  φ, 
   5, 
   {6}, 
   {7}, 
   {5, {6}}, 
   {5, {7}}, 
   {{6}, {7}}, 
   {5, {6}, {7}} 
}
I is true, as φ belongs to Powerset. II is true, as an empty set is a subset of every set. III is true as {5, {6}} belongs to Powerset. IV is false, {5, {6}} is not a subset, but {{5, {6}}} is.
Question 27
In one of the pairs of protocols given below, both the protocols can use multiple TCP connections between the same client and the server. Which one is that?
A
HTTP, FTP
B
HTTP, TELNET
C
FTP, SMTP
D
HTTP, SMTP
Application Layer    GATE-CS-2015 (Set 1)    
Discuss it


Question 27 Explanation: 
HTTP may use different TCP connection for different objects of a webpage if non-persistent connections are used. FTP uses two TCP connections, one for data and another control. TELNET and FTP can only use ONE connection at a time.
Question 28
In the LU decomposition of the matrix
| 2  2 |
| 4  9 |
, if the diagonal elements of U are both 1, then the lower diagonal entry l22 of L is
A
4
B
5
C
6
D
7
Linear Algebra    GATE-CS-2015 (Set 1)    
Discuss it


Question 28 Explanation: 
LU decomposition (where 'LU' stands for 'lower upper', and also called LU factorization) factors a matrix as the product of a lower triangular matrix and an upper triangular matrix.
| 2  2 | =  | l11   0   |  * | 1   u12 |
| 4  9 |    | l21   l22 |    | 0    1  |

 l21 *  u12 + l22 * 1  = 9  ------ (1)
 
 We need to find l21 and u12 
 l21 *  1 + l22 * 0  = 4
 l21 = 4

 l11 * U12 + 0 * 1 = 2
 l11 = 2
 U12 = 1

 Putting value of l21 and u12 in (1), we get
 4 * 1 + l22 * 1 = 9
 l22 = 5  
Question 29
Suppose two hosts use a TCP connection to transfer a large file. Which of the following statements is/are False with respect to the TCP connection?
1. If the sequence number of a segment is m, then the sequence 
   number of the subsequent segment is always m+1.
2. If the estimated round trip time at any given point of time
   is t sec, the value of the retransmission timeout is always
   set to greater than or equal to t sec.
3. The size of the advertised window never changes during the 
   course of the TCP connection.
4. The number of unacknowledged bytes at the sender is always 
   less than or equal to the advertised window 
A
3 only
B
1 and 3 only
C
1 and 4 only
D
2 and 4 only
Transport Layer    GATE-CS-2015 (Set 1)    
Discuss it


Question 29 Explanation: 
TCP sequence number of a segment is the byte number of the first byte in the segment. For example, if the segment contains 500 bytes which are from 1000 to 1499, then sequence number of the segment would be 1000 and sequence number of next segment would be 1500. Receiver window changes when TCP data is processed by application layer of receiver side.
Question 30
Consider a 4 bit Johnson counter with an initial value of 0000. The counting sequence of this counter is:
A
0, 1, 3, 7, 15, 14, 12, 8, 0
B
0, 1, 3, 5, 7, 9, 11, 13, 15, 0
C
0, 2, 4, 6, 8, 10, 12, 14, 0
D
0, 8, 12, 14, 15, 7, 3, 1, 0
Digital Logic & Number representation    GATE-CS-2015 (Set 1)    
Discuss it


Question 30 Explanation: 
Refer http://en.wikipedia.org/wiki/Ring_counter#Johnson_Counter_.284-bits.29 The four bit Johnson's counter connects the complement of the output of the last shift register to the input of the first register with shift distance=1 i.e 1 bit will shift/cycle It will work as follows: 0000 //Last 0 complemented and fed as input to first register 1000 1100 1110 1111 //Last 1 complemented and fed as input to first register 0111 0011 0001 0000
Question 31
Suppose that everyone in a group of N people wants to communicate secretly with the N–1 others using symmetric key cryptographic system. The communication between any two persons should not be decodable by the others in the group. The number of keys required in the system as a whole to satisfy the confidentiality requirement is
A
2N
B
N(N – 1)
C
N(N – 1)/2
D
(N – 1)2
Network Security    GATE-CS-2015 (Set 1)    
Discuss it


Question 31 Explanation: 
In Symmetric Key Cryptography, access of key is with both the parties. It implies every person needs to communicate N-1 other users using different keys i.e 1+2+3...N-2+N-1 This is like number of edges needed in a complete graph with N vertices is N(N-1)/2. Answer is therefore C
Question 32
Which one of the following fields of an IP header is NOT modified by a typical IP router?
A
Checksum
B
Source address
C
Time to Live (TTL)
D
Length
Network Layer    GATE-CS-2015 (Set 1)    
Discuss it


Question 32 Explanation: 
Length and checksum can be modified when IP fragmentation happens. Time To Live is reduced by every router on the route to destination. Only Source Address is what IP address can not change SO B is the answer.
Question 33
What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
A
Θ(logn) for both insertion and deletion
B
Θ(n) for both insertion and deletion
C
Θ(n) for insertion and Θ(logn) for deletion
D
Θ(logn) for insertion and Θ(n) for deletion
Binary Search Trees    GATE-CS-2015 (Set 1)    
Discuss it


Question 33 Explanation: 
The time taken by search, insert and delete on a BST is always proportional to height of BST. Height may become O(n) in worst case.
Question 34
A file is organized so that the ordering of data records is the same as or close to the ordering of data entries in some index. Then that index is called
A
Dense
B
Sparse
C
Clustered
D
Unclustered
File structures (sequential files, indexing, B and B+ trees)    GATE-CS-2015 (Set 1)    
Discuss it


Question 34 Explanation: 
In Clustered Index, data blocks are stored in a way to match the index. Therefore, only one clustered index can be created on a given database table. Refer https://msdn.microsoft.com/en-IN/library/ms190457.aspx for more details.
Question 35
The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are
A
63 and 6, respectively
B
64 and 5, respectively
C
32 and 6, respectively
D
31 and 5, respectively
Binary Trees    GATE-CS-2015 (Set 1)    
Discuss it


Question 35 Explanation: 
Number of nodes is maximum for a perfect binary tree.
A perfect binary tree of height h has 2h+1 - 1 nodes

Number of nodes is minimum for a skewed binary tree.
A perfect binary tree of height h has h+1 nodes.
Question 36
Q90
A
0.99
B
1
C
99
D
0.9
Numerical Methods and Calculus    GATE-CS-2015 (Set 1)    
Discuss it


Question 36 Explanation: 
S  = 1/1*2 + 1/2*3 + 1/3*4 + ..... + 1/99*100
   = (1 - 1/2) + (1/2 - 1/3) + (1/3 - 1/4) + .... + (1/99 - 1/100)
   = (1 + 1/2 + 1/3 .... 1/99) - (1/2 + 1/3 + 1/4 ... 1/100)
   = 1 - 1/100
   = 99/100
   = 0.99
Question 37
Consider the following relations: Q45
SELECT S. Student_Name, sum(P.Marks)
     FROM Student S, Performance P
     WHERE S.Roll_No = P.Roll_No
     GROUP BY S.Student_Name 
The number of rows that will be returned by the SQL query is _________
A
0
B
1
C
2
D
3
SQL    GATE-CS-2015 (Set 1)    
Discuss it


Question 37 Explanation: 
Below is result of given query. Note that there are only two student names and query prints sum(P.Marks) for every student.
  Student_Name     Marks
      Raj           310
     Rohit          140 
Question 38
The binary operator ≠ is defined by the following truth table Q46 Which one of the following is true about the binary operator ≠?
A
Both commutative and associative
B
Commutative but not associative
C
Not commutative but associative
D
Neither commutative nor associative
Set Theory & Algebra    GATE-CS-2015 (Set 1)    
Discuss it


Question 38 Explanation: 
The operation is basically XOR which is both commutative and associative.
Question 39
Consider a LAN with four nodes S1, S2, S3 and S4. Time is divided into fixed-size slots, and a node can begin its transmission only at the beginning of a slot. A collision is said to have occurred if more than one node transmit in the same slot. The probabilities of generation of a frame in a time slot by S1, S2, S3 and S4 are 0.1, 0.2, 0.3 and 0.4, respectively. The probability of sending a frame in the first slot without any collision by any of these four stations is _________.
A
0.462
B
0.711
C
0.5
D
0.652
Data Link Layer    GATE-CS-2015 (Set 1)    
Discuss it


Question 39 Explanation: 
The probability of sending a frame in the first slot 
without any collision by any of these four stations is
sum of following 4 probabilities

Probability that S1 sends a frame and no one else does + 
Probability thatS2 sends a frame and no one else does +
Probability thatS3 sends a frame and no one else does +
Probability thatS4 sends a frame and no one else does

= 0.1 * (1 - 0.2) * (1 - 0.3) *(1 - 0.4) + 
  (1 -0.1) * 0.2 * (1 - 0.3) *(1 - 0.4) + 
  (1 -0.1) * (1 - 0.2) * 0.3 *(1 - 0.4) + 
  (1 -0.1) * (1 - 0.2) * (1 - 0.3) * 0.4

= 0.4404 
Question 40
Suppose the following disk request sequence (track numbers) for a disk with 100 tracks is given: 45, 20, 90, 10, 50, 60, 80, 25, 70. Assume that the initial position of the R/W head is on track 50. The additional distance that will be traversed by the R/W head when the Shortest Seek Time First (SSTF) algorithm is used compared to the SCAN (Elevator) algorithm (assuming that SCAN algorithm moves towards 100 when it starts execution) is _________ tracks
A
8
B
9
C
10
D
11
Input Output Systems    GATE-CS-2015 (Set 1)    
Discuss it


Question 40 Explanation: 
In Shortest seek first (SSTF), closest request to the current position of the head, and then services that request next. In SCAN (or Elevator) algorithm, requests are serviced only in the current direction of arm movement until the arm reaches the edge of the disk. When this happens, the direction of the arm reverses, and the requests that were remaining in the opposite direction are serviced, and so on.
Given a disk with 100 tracks 

And Sequence 45, 20, 90, 10, 50, 60, 80, 25, 70.

Initial position of the R/W head is on track 50.

In SSTF, requests are served as following

Next Served     Distance Traveled
  50                   0
  45                   5
  60                  15   
  70                  10   
  80                  10   
  90                  10
  25                  65   
  20                   5   
  10                  10
-----------------------------------     
Total Dist         =  130


If Simple SCAN is used, requests are served as following

Next Served     Distance Traveled
  50                   0
  60                  10   
  70                  10   
  80                  10   
  90                  10
  45                  65 [disk arm goes to 100, then to 45]
  25                  20   
  20                   5   
  10                  10
-----------------------------------     
Total Dist         =  140


Extra Distance traveled in SSTF = 140 - 120 = -10
If SCAN with LOOK is used, requests are served as following

Next Served     Distance Traveled
  50                   0
  60                  10   
  70                  10   
  80                  10   
  90                  10
  45                  45 [disk arm comes back from 90]
  25                  20   
  20                   5   
  10                  10
-----------------------------------     
Total Dist         =  120


Extra Distance traveled in SSTF = 130 - 120 = 10
Question 41
Consider the following C function.
int fun1 (int n)
{
   int i, j, k, p, q = 0;
   for (i = 1; i<n; ++i)
   {
      p = 0;
      for (j=n; j>1; j=j/2)
         ++p;
      for (k=1; k<p; k=k*2)
         ++q;
   }
   return q;
}
Which one of the following most closely approximates the return value of the function fun1?
A
n3
B
n (logn)2
C
nlogn
D
nlog(logn)
Analysis of Algorithms    GATE-CS-2015 (Set 1)    
Discuss it


Question 41 Explanation: 
int fun1 (int n)
{
   int i, j, k, p, q = 0;

   // This loop runs Θ(n) time
   for (i = 1; i < n; ++i)
   {
      p = 0;

      // This loop runs Θ(Log n) times. Refer this 
      for (j=n; j > 1; j=j/2)
         ++p;
     
      // Since above loop runs Θ(Log n) times, p = Θ(Log n)
      // This loop runs Θ(Log p) times which loglogn
      for (k=1; k < p; k=k*2)
         ++q;
   
   }
   return q;
}
T(n) = n(logn + loglogn) T(n) = n(logn) dominant But please note here we are return q which lies in loglogn so ans should be T(n) = nloglogn Refer this for details.
Question 42
Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap is
A
40, 30, 20, 10, 15, 16, 17, 8, 4, 35
B
40, 35, 20, 10, 30, 16, 17, 8, 4, 15
C
40, 30, 20, 10, 35, 16, 17, 8, 4, 15
D
40, 35, 20, 10, 15, 16, 17, 8, 4, 30
Heap    GATE-CS-2015 (Set 1)    
Discuss it


Question 42 Explanation: 
The array 40, 30, 20, 10, 15, 16, 17, 8, 4 represents following heap

         40
       /    \
     30      20
    / \      / \
   10  15  16   17
  / \
 8   4
After insertion of 35, we get
         40
       /    \
     30      20
    / \       / \
   10  15  16   17
  / \  /
 8   4 35  
After swapping 35 with 15 and swapping 35 again with 30, we get
         40
       /    \
     35      20
    / \       / \
   10  30  16   17
  / \  /
 8   4 15  
Question 43
Consider the following pseudo code, where x and y are positive integers.
begin
   q := 0
   r := x
while r >= y do
   begin
      r := r – y
      q := q + 1
   end
end 
The post condition that needs to be satisfied after the program terminates is
A
{r = qx + y ∧ r < y}
B
{x = qy + r ∧ r < y}
C
{y = qx + r ∧ 0 < r < y}
D
{ q + 1 < r–y ∧ y > 0}
Misc    GATE-CS-2015 (Set 1)    
Discuss it


Question 43 Explanation: 
The given pseudo code does following for given x and y which positive integers.
1) It initializes r as x.
2) It repeatedly subtracts y from r until r becomes
   smaller than y.  For every subtraction, it 
   increments count q.
3) Finally r contains remainder, i.e., x%y and q contains
   ⌊x/y⌋
See below pseudo code with comments.
begin
   q := 0  // q is going to contain floor(x/y)
   r := x  // r is going to contain x % y

// Repeatedly subtract y from x.
while r >= y do
   begin
      r := r – y
      q := q + 1
   end
end
Question 44
Suppose L = {p, q, r, s, t} is a lattice represented by the following Hasse diagram: Q48 For any x, y ∈ L, not necessarily distinct, x ∨ y and x ∧ y are join and meet of x, y respectively. Let L3 = {(x,y,z): x, y, z ∈ L} be the set of all ordered triplets of the elements of L. Let pr be the probability that an element (x,y,z) ∈ L3 chosen equiprobably satisfies x ∨ (y ∧ z) = (x ∨ y) ∧ (x ∨ z). Then
A
Pr = 0
B
Pr = 1
C
0 < Pr ≤ 1/5
D
1/5 < Pr < 1
Set Theory & Algebra    GATE-CS-2015 (Set 1)    
Discuss it


Question 44 Explanation: 
Number of triplets in L3 = Number of ways in which 
                             we can choose 3 elements 
                             from 5 with repetition 

                              = 5 * 5 * 5 
                              = 125.

Now, when we take x = t, then the given condition for L is
satisfied for any y and z. Here, y and z can be taken in 
5 * 5 = 25 ways.

Take x = r, y = p, z = p. Here also, the given condition is
satisfied. So, pr > 25 / 125 > 1/5.

For x = q, y = r, z = s, the given condition is not satisfied
as q ⋁ (r ⋀ s) = q ⋁ p = q, while (q ⋁ r) ⋀ (q ⋁ s) = t ⋀ t = t.

So, pr ≠ 1.

Hence  D choice.
Question 45
What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory.
#include <stdio.h>
int main()
{ 
   unsigned int x[4][3] = {{1, 2, 3}, {4, 5, 6}, 
                           {7, 8, 9}, {10, 11, 12}};
   printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3);
}
A
2036, 2036, 2036
B
2012, 4, 2204
C
2036, 10, 10
D
2012, 4, 6
Advanced Pointer    GATE-CS-2015 (Set 1)    
Discuss it


Question 45 Explanation: 
x = 2000

Since x is considered as a pointer to an 
array of 3 integers and an integer takes 4
bytes, value of x + 3 = 2000 + 3*3*4 = 2036

The expression, *(x + 3) also prints same 
address as x is 2D array.


The expression *(x + 2) + 3 = 2000 + 2*3*4 + 3*4
                            = 2036
Question 46
Consider the following 2 × 2 matrix A where two elements are unknown and are marked by a and b. The eigenvalues of this matrix are –1 and 7. What are the values of a and b?
A = | 1  4 |
    | b  a |
A
a = 6, b = 4
B
a = 4, b = 6
C
a = 3, b = 5
D
a = 5, b = 3
Linear Algebra    GATE-CS-2015 (Set 1)    
Discuss it


Question 46 Explanation: 
The character equation for given matrix is

| 1-λ    4 | = 0
|  b    a-λ|

(1-λ)*(a-λ) - 4b = 0

Putting λ = -1,
=> (1 - (-1)) * (a - (-1)) - 4b = 0
=> 2a + 2 - 4b = 0
=> 2b - a = 1


Putting λ = 7,
=> (1 - 7) * (a - 7) - 4b = 0
=> -6a + 42 - 4b = 0
=> 2b + 3a = 21

Solving the above two equations, we get
a = 5, b = 3

Question 47
A positive edge-triggered D flip-flop is connected to a positive edge-triggered JK flipflop as follows. The Q output of the D flip-flop is connected to both the J and K inputs of the JK flip-flop, while the Q output of the JK flip-flop is connected to the input of the D flip-flop. Initially, the output of the D flip-flop is set to logic one and the output of the JK flip-flop is cleared. Which one of the following is the bit sequence (including the initial state) generated at the Q output of the JK flip-flop when the flip-flops are connected to a free-running common clock? Assume that J = K = 1 is the toggle mode and J = K = 0 is the state-holding mode of the JK flip-flop. Both the flip-flops have non-zero propagation delays.
A
0110110...
B
0100100...
C
011101110...
D
011001100...
Digital Logic & Number representation    GATE-CS-2015 (Set 1)    
Discuss it


Question 47 Explanation: 
jk Initially Q output of D - FF  = 1 Initially Q output of JK - FF  = 0 Now with the help of present state and next state table we can see what is happening in circuit.
  • Toggle: J = K = 1
  • Hold : J = K = 0
jk1 We see from table Q output of D-FF is going to next state input of JK-FF and the bits sequence produced is like 110110….. Including initial condition (0) we get output as 0110110110…. Hence answer is (A) part. Another Explanation: Here, it is given that JK flip flop will toggle when J = K = 1 and it will retain the output if J = K = 0. Also, the output of the D flip flop would remain the same as the input. So, we have Initial output : D = 1

JK = 0

After clock 1 : D = 0 (D gets 0 as input 
from initial output of JK, so output = 0)

JK = 1 (J = K = 1 from initial output of D, so output would be toggled from 0 to 1)

After clock 2 : D = 1 (D gets 1 as input 
from previous output of JK, so output = 1)

JK = 1 (J = K = 0 from previous output of D, so output would be retained to 1)

After clock 3 : D = 1 (D gets 1 as input
from previous output of JK, so output = 1)

JK = 0 (J = K = 1 from previous output of D, so output would be toggled from 1 to 0)

After clock 4 : D = 0 (D gets 0 as input
from previous output of JK, so output = 0)

JK = 1 (J = K = 1 from previous output of D, so output would be toggled from 0 to 1)

After clock 5 : D = 1 (D gets 1 as input
from previous output of JK, so output = 1)

JK = 1 (J = K = 0 from previous output of D, so output would be retained to 1)


Thus, the bit sequence generated at the Q output of the JK flip flop will be 0110110...

 
Question 48
Consider a non-pipelined processor with a clock rate of 2.5 gigahertz and average cycles per instruction of four. The same processor is upgraded to a pipelined processor with five stages; but due to the internal pipeline delay, the clock speed is reduced to 2 gigahertz. Assume that there are no stalls in the pipeline. The speed up achieved in this pipelined processor is __________.
A
3.2
B
3.0
C
2.2
D
2.0
Computer Organization and Architecture    GATE-CS-2015 (Set 1)    
Discuss it


Question 48 Explanation: 
Speedup = ExecutionTimeOld / ExecutionTimeNew

ExecutionTimeOld = CPIOld * CycleTimeOld
                  [Here CPI is Cycles Per Instruction]
                 = CPIOld * CycleTimeOld
                 = 4 * 1/2.5 Nanoseconds
                 = 1.6 ns

Since there are no stalls, CPUnew can be assumed 1 on average.
ExecutionTimeNew = CPInew * CycleTimenew
                 = 1 * 1/2
                 = 0.5

Speedup = 1.6 / 0.5 = 3.2
Refer http://www.cs.berkeley.edu/~pattrsn/252F96/Lecture2a.pdf for more information on this topic.
Question 49
Consider the operations f(X, Y, Z) = X'YZ + XY' + Y'Z'  and  g(X′, Y, Z) = X′YZ + X′YZ′ + XY Which one of the following is correct?
A
Both {f} and {g} are functionally complete
B
Only {f} is functionally complete
C
Only {g} is functionally complete
D
Neither {f} nor {g} is functionally complete
Digital Logic & Number representation    GATE-CS-2015 (Set 1)    
Discuss it


Question 49 Explanation: 
A function is considered as functionally complete if it does not belong to T0,T1,L,M,S which are Property 1: We say that boolean function f preserves zero, if on the 0-input it produces 0. By the 0-input we mean such an input, where every input variable is 0 (this input usually corresponds to the first row of the truth table). We denote the class of zero-preserving boolean functions as T0 and write f ∈ T0. Property 2: Similarly to T0, we say that boolean function f preserves one, if on 1-input, it produces 1. The 1-input is the input where all the input variables are 1 (this input usually corresponds to the last row of the truth table). We denote the class of one-preserving boolean functions as T1 and write f ∈ T1. Property 3: We say that boolean function f is linear if one of the following two statements holds for f:
  • For every 1-value of f, the number of 1’s in the corresponding input is odd, and for every 0-value of f, the number of 1’s in the corresponding input is even.
or
  • For every 1-value of f, the number of 1’s in the corresponding input is even, and for every 0-value of f, the number of 1’s in the corresponding input is odd.
If one of these statements holds for f, we say that f is linear1. We denote the class of linear boolean functions with L and write f ∈ L. Property 4: We say that boolean function f is monotone if for every input, switching any input variable from 0 to 1 can only result in the function’s switching its value from 0 to 1, and never from 1 to 0. We denote the class of monotone boolean functions with M and write f ∈ M. Property 5: We say that boolean function f(x1,...,xn) is self-dual if f(x1,...,xn) = ¬f(¬x1,...,¬xn). The function on the right in the equality above (the one with negations) is called the dual of f. We will call the class of self-dual boolean functions S and write f ∈ S. As in our case we can see  on giving all i/p to 0 (g )produce 0 so it preserving 0 and can’t be functionally complete. But f is neither preserving 0 nor 1.
  • F is not linear(see defn. of linear above)
  • F is not monotone(see defn. of monotone above)
  • F is not self dual as f(x,y,z) is not equal to –f(-x,-y,-z)
So f is functionally complete. Hence ans is (B) part
Question 50
An algorithm performs (logN)1/2 find operations, N insert operations, (logN)1/2 operations, and (logN)1/2 decrease-key operations on a set of data items with keys drawn from a linearly ordered set. For a delete operation, a pointer is provided to the record that must be deleted. For the decrease-key operation, a pointer is provided to the record that has its key decreased. Which one of the following data structures is the most suited for the algorithm to use, if the goal is to achieve the best total asymptotic complexity considering all the operations?
A
Unsorted array
B
Min-heap
C
Sorted array
D
Sorted doubly linked list
Array    GATE-CS-2015 (Set 1)    
Discuss it


Question 50 Explanation: 
The time complexity of insert in unsorted array is O(1), O(Logn) in Min-Heap, O(n) in sorted array and sorted DLL.
  1. For unsorted array, we can always insert an element at end and do insert in O(1) time
  2. For Min Heap, insertion takes O(Log n) time. Refer Binary Heap operations for details.
  3. For sorted array, insert takes O(n) time as we may have to move all elements worst case.
  4. For sorted doubly linked list, insert takes O(n) time to find position of element to be inserted.
Since number of insertion operations is asymptotically higher, unsorted array is preferred.
Question 51
Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an m : n relationship R12, E1 and E3 are connected by a 1 : n (1 on the side of E1 and n on the side of E3) relationship R13. E1 has two single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-valued attributes a21 and a22 is the key attribute. E3 has two single-valued attributes a31 and a32 of which a31 is the key attribute. The relationships do not have any attributes. If a relational model is derived from the above ER model, then the minimum number of relations that would be generated if all the relations are in 3NF is ___________.
A
2
B
3
C
4
D
5
Database Design(Normal Forms)    GATE-CS-2015 (Set 1)    
Discuss it


Question 51 Explanation: 
Entity E1.
a1  a12
--------
a11 is key

Entity E2
a21  a22
--------
a22 is key

Entity E3
a31  a32
--------
a31 is key

R12 is m:n Relationship between E1 and E2
R12
a11     a22
-------------
(a11, a22) is key.


R13 is 1:n Relationship between E1 and E3
R13
a11   a31
-----------
(a11, a31) is key.


We need minimum no. of tables. 
Can we remove any of the above tables without 
loosing information and keeping the relations in 3NF?


We can combine R13 and R12 into one.  
a11   a31   a22
------------------
(a11, a31, a22) is key.


The relation is still in 3NF as for every functional 
dependency X -> A, one of the following holds
1) X is a superkey or
2) A-X is prime attribute 
Question 52
Consider the following C program segment.
while (first <= last)
{
   if (array [middle] < search)
      first = middle +1;
   else if (array [middle] == search)
      found = True;
   else last = middle – 1;
   middle = (first + last)/2;
}
if (first < last) not Present = True;
The cyclomatic complexity of the program segment is __________.
A
3
B
4
C
5
D
6
Software Engineering    GATE-CS-2015 (Set 1)    
Discuss it


Question 52 Explanation: 
the cyclomatic complexity of a structured program[a] is defined with reference to the control flow graph of the program, a directed graph containing the basic blocks of the program, with an edge between two basic blocks if control may pass from the first to the second. The complexity M is then defined as

    M = E − N + 2P,
where
    E = the number of edges of the graph.
    N = the number of nodes of the graph.
    P = the number of connected components.  
Source: http://en.wikipedia.org/wiki/Cyclomatic_complexity For a single program (or subroutine or method), P is always equal to 1. So a simpler formula for a single subroutine is
    M = E − N + 2 
For the given program, the control flow graph is: q100
 E = 13, N = 10.

Therefore, E - N + 2 = 5. 
Question 53
The graph shown below 8 edges with distinct integer edge weights. The minimum spanning tree (MST) is of weight 36 and contains the edges: {(A, C), (B, C), (B, E), (E, F), (D, F)}. The edge weights of only those edges which are in the MST are given in the figure shown below. The minimum possible sum of weights of all 8 edges of this graph is ______________. Q49
A
66
B
69
C
68
D
70
Graph Minimum Spanning Tree    GATE-CS-2015 (Set 1)    
Discuss it


Question 53 Explanation: 
In every cycle, the weight of an edge that is not part of MST must by greater than or equal to weights of other edges which are part of MST. Since all edge weights are distinct, the weight must be greater. So the minimum possible weight of ED is 7, minimum possible weight of CD is 16 and minimum possible weight of AB is 10. Therefore minimum possible sum of weights is 69.
Question 54
Q50
A
0
B
-1
C
1
D
infinite
Numerical Methods and Calculus    GATE-CS-2015 (Set 1)    
Discuss it


Question 54 Explanation: 
Let f(x) be the given function. We assume that \[\frac{1}{x} = z\] Differentiating both sides, we get [Tex] \[\frac{-1}{x^2} dx = dz\] Now, accordingly, the lower limit of the integral is \[ z = \frac{1}{\frac{1}{\pi}} = \pi\] and the upper limit for the integral is \[ z = \frac{1}{\frac{2}{\pi}} = \frac{\pi}{2}\] So, the given function now becomes \[ f(x)= - \int_\pi^{\frac{\pi}{2}} cos(z) dz \] \[ f(x)= \int_\frac{\pi}{2}^{\pi} cos(z) dz \] \[f(x) = sin(z) ,\] and the upper limit is π and the lower limit is π/2 So, \[f(x) = sin(\pi) - sin(\frac{\pi}{2})\] \[f(x) = 0 - 1\] \[f(x) = -1\] So, the required answer is -1. [/Tex]
Question 55
Let G = (V, E) be a simple undirected graph, and s be a particular vertex in it called the source. For x ∈ V, let d(x) denote the shortest distance in G from s to x. A breadth first search (BFS) is performed starting at s. Let T be the resultant BFS tree. If (u, v) is an edge of G that is not in T, then which one of the following CANNOT be the value of d(u) – d(v)?
A
-1
B
0
C
1
D
2
Graph Shortest Paths    GATE-CS-2015 (Set 1)    
Discuss it


Question 55 Explanation: 
Note that the given graph is undirected, so an edge (u, v) also means (v, u) is also an edge. Since a shorter path can always be obtained by using edge (u, v) or (v, u), the difference between d(u) and d(v) can not be more than 1.
Question 56
Consider a main memory with five page frames and the following sequence of page references: 3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3. Which one of the following is true with respect to page replacement policies First-In-First Out (FIFO) and Least Recently Used (LRU)?
A
Both incur the same number of page faults
B
FIFO incurs 2 more page faults than LRU
C
LRU incurs 2 more page faults than FIFO
D
FIFO incurs 1 more page faults than LRU
GATE-CS-2015 (Set 1)    
Discuss it


Question 56 Explanation: 
3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3

In both FIFO and LRU, we get following after 
considering 3, 8, 2, 3, 9, 1, 3 8 2 9 1

FIFO
6 replaces 3
8 2 9 1 6

3 replaces 8
2 9 1 6 3

8 replaces 2
9 1 6 3 8

2 replaces 9
1 6 3 8 2

No more page faults

LRU
6 replaces 8
3 2 9 1 6
 
8 replaces 2
3 9 1 6 8

2 replaces 1
3 9 6 8 2

1 replaces 8
3 9 6 2 1 
Question 57
Consider a disk pack with a seek time of 4 milliseconds and rotational speed of 10000 rotations per minute (RPM). It has 600 sectors per track and each sector can store 512 bytes of data. Consider a file stored in the disk. The file contains 2000 sectors. Assume that every sector access necessitates a seek, and the average rotational latency for accessing each sector is half of the time for one complete rotation. The total time (in milliseconds) needed to read the entire file is _________.
A
14020
B
14000
C
25030
D
15000
Input Output Systems    GATE-CS-2015 (Set 1)    
Discuss it


Question 57 Explanation: 
Seek time (given) = 4ms

RPM = 10000 rotation in 1 min [60 sec]
So, 1 rotation will be =60/10000 =6ms [rotation speed]
Rotation latency= 1/2 * 6ms=3ms
# To access a file, 
  total time includes =seek time + rot. latency +transfer time
TO calc. transfer time, find transfer rate

Transfer rate = bytes on track /rotation speed
so, transfer rate = 600*512/6ms =51200 B/ms

transfer time= total bytes to be transferred/ transfer rate
so, Transfer time =2000*512/51200 = 20ms

Given as each sector requires seek tim + rot. latency
= 4ms+3ms =7ms

Total 2000 sector takes = 2000*7 ms =14000 ms
To read entire file ,total time = 14000 + 20(transfer time)
                                = 14020 ms
Question 58
Let an represent the number of bit strings of length n containing two consecutive 1s. What is the recurrence relation for an?
A
an–2 + an–1 + 2n–2
B
an–2 + 2an–1 + 2n–2
C
2an–2 + an–1 + 2n–2
D
2an–2 + 2an–1 + 2n–2
Misc    GATE-CS-2015 (Set 1)    
Discuss it


Question 58 Explanation: 
Simple Solution One way to solve this is to try for small values and rule out options.
a0 = 0  
a1 = 0  
a2 = 1  ["11"]
a3 = 3  ["011", "110", "111"] 
a4 = 8  ["0011", "0110", "0111", "1101",
                    "1011", "1100", "1110", "1111"]
If we check for a3, we can see that only A and C satisfy the value. Among (A) and (C), only (A) satisfies for a4. Another Solution (With Proof)
A string of length n (n >= 2) can be formed by 
following 4 prefixes

1) 11 followed by a string of length n-2
2) 00 followed by a string of length n-2
3) 01 followed by a string of length n-2
4) 10 followed by a string of length n-2

Number 1 has already two consecutive 1's so number 
of binary strings beginning with number 3 is 2n-2
as remaining n-2 bits can have any value.

Number 2 has two 0's so remaining n-2 bits must have
two consecutive 1's. Therefore number of binary strings
that can be formed by number 2 is an-2.

Number 3 and Number 4 together form all strings of length
n-1 and two consecutive 1's.
Question 59
A variable x is said to be live at a statement Si in a program if the following three conditions hold simultaneously:
1. There exists a statement Sj that uses x
2. There is a path from Si to Sj in the flow
   graph corresponding to the program
3. The path has no intervening assignment to x 
   including at Si and Sj
Q59New The variables which are live both at the statement in basic block 2 and at the statement in basic block 3 of the above control flow graph are
A
p, s, u
B
r, s, u
C
r, u
D
q, v
Software Engineering    GATE-CS-2015 (Set 1)    
Discuss it


Question 59 Explanation: 
Live variable analysis is useful in compilers to find variables in each program that may be needed in future. As per the definition given in question, a variable is live if it holds a value that may be needed in the future. In other words,  it is used in future before any new assignment.
Question 60
Consider the NPDA 〈Q = {q0, q1, q2}, Σ = {0, 1}, Γ = {0, 1, ⊥}, δ, q0, ⊥, F = {q2}〉, where (as per usual convention) Q is the set of states, Σ is the input alphabet, Γ is stack alphabet, δ is the state transition function, q0 is the initial state, ⊥ is the initial stack symbol, and F is the set of accepting states, The state transition is as follows: Q60 Which one of the following sequences must follow the string 101100 so that the overall string is accepted by the automaton?
A
10110
B
10010
C
01010
D
01001
Context free languages and Push-down automata    GATE-CS-2015 (Set 1)    
Discuss it


Question 60 Explanation: 
In q0 state for '1', a '1' is pushed and for a '0' a '0' is pushed. In q1 state, for a '0' a '1' is popped and for a '1' a '0' is popped. So, the given PDA is accepting all strings of of the form x0x'r or x1x'r or xx'r, where x'r is the reverse of the 1's complement of x. The given string 101100 has 6 letters and we are given 5 letter strings. So, x0 is done, with x = 10110. So, x'r = (01001)r = 10010. Hence option B is correct.
Question 61
Consider the DFAs M and N given above. The number of states in a minimal DFA that accepts the language L(M) ∩ L(N) is __________. question2015
A
0
B
1
C
2
D
3
Regular languages and finite automata    GATE-CS-2015 (Set 1)    
Discuss it


Question 61 Explanation: 
In DFA M: all strings must end with 'a'. In DFA N: all strings must end with 'b'. So the intersection is empty. For an empty language, only one state is required in DFA. The state is non-accepting and remains on itself for all characters of alphabet. Q61
Question 62
Suppose that the stop-and-wait protocol is used on a link with a bit rate of 64 kilobits per second and 20 milliseconds propagation delay. Assume that the transmission time for the acknowledgment and the processing time at nodes are negligible. Then the minimum frame size in bytes to achieve a link utilization of at least 50% is _________.
A
160
B
320
C
640
D
220
Data Link Layer    GATE-CS-2015 (Set 1)    
Discuss it


Question 62 Explanation: 
Transmission or Link speed = 64 kb per sec
Propagation Delay = 20 milisec

Since stop and wait is used, a packet is sent only
when previous one is acknowledged.

Let x be size of packet, transmission time = x / 64 milisec

Since utilization is at least 50%, minimum possible total time
for one packet is twice of transmission delay, which means 
x/64 * 2 = x/32

x/32 > x/64 + 2*20
x/64 > 40
x > 2560 bits = 320 bytes
Answer in GATE keys says 160 bytes, but the answer keys seem incorrect. See question 36 here.
Question 63
Let G be a connected planar graph with 10 vertices. If the number of edges on each face is three, then the number of edges in G is _______________.
A
24
B
20
C
32
D
64
Graph Theory    GATE-CS-2015 (Set 1)    
Discuss it


Question 63 Explanation: 
Euler's formula states that if a finite, connected, planar graph is drawn in the plane without any edge intersections, then
    v − e + f = 2.  
    v -> Number of vertices
    e -> Number of edges
    f -> Number of faces

As per the question 
v = 10
And number of edges on each face is three
Therefore, 2e = 3f  [Note that every edge is
                    shared by 2 faces]

Putting above values in v − e + f = 2
10 - e + 2e/3 = 2
e = 3*10 - 6 = 24
Question 64
The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r/3 + s – t * 5 + u * v/w is
A
4
B
8
C
7
D
9
Computer Organization and Architecture    GATE-CS-2015 (Set 1)    
Discuss it


Question 64 Explanation: 

The correct answer is 8. This question was asked as a fill in the blank type question in the exam.

 

Three address code is an intermediate code generated by compilers while optimizing the code. Each three address code instruction can have atmost three operands (constants and variables) combined with an assignment and a binary operator. The point to be noted in three address code is that the variables used on the left hand side (LHS) of the assignment cannot be repeated again in the LHS side. Static single assignment (SSA) is nothing but a refinement of the three address code.

So, in this question, we have
t1 = r / 3;

t2 = t * 5;

t3 = u * v;

t4 = t3 / w;

t5 = q + t1;

t6 = t5 + s;

t7 = t6 - t2; 

t8 = t7 + t4;
Therefore, we require 8 temporary variables (t1 to t8) to create the three address code in static single assignment form.
Question 65
Consider a uniprocessor system executing three tasks T1, T2 and T3, each of which is composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 3, 7 and 20 milliseconds, respectively. The priority of each task is the inverse of its period and the available tasks are scheduled in order of priority, with the highest priority task scheduled first. Each instance of T1, T2 and T3 requires an execution time of 1, 2 and 4 milliseconds, respectively. Given that all tasks initially arrive at the beginning of the 1st milliseconds and task preemptions are allowed, the first instance of T3 completes its execution at the end of ______________ milliseconds.
A
5
B
10
C
12
D
15
GATE-CS-2015 (Set 1)    CPU Scheduling    
Discuss it


Question 65 Explanation: 
Periods of T1, T2 and T3 are 3ms, 7ms and 20ms

Since priority is inverse of period, T1 is the highest 
priority task, then T2 and finally T3

Every instance of T1 requires 1ms, that of T2 requires 
2ms and that of T3 requires 4ms

Initially all T1, T2 and T3 are ready to get processor, 
T1 is preferred

Second instances of T1, T2, and T3 shall arrive at 3, 7, 
and 20 respectively.

Third instance of T1, T2 and T3 shall arrive at 6, 14, 
and 49 respectively.

Time-Interval  Tasks   
 0-1            T1     
 1-2            T2      
 2-3            T2     
 3-4            T1  [Second Instance of T1 arrives] 
 4-5            T3     
 5-6            T3     
 6-7            T1  [Third Instance of T1 arrives]                        
                    [Therefore T3 is preempted] 
 7-8            T2  [Second instance of T2 arrives]                            
 8-9            T2
 9-10           T1  [Fourth Instance of T1 arrives]                          
10-11           T3
11-12           T3 [First Instance of T3 completed]
There are 65 questions to complete.

See GATE Corner for all papers, notes and other important information.


GATE CS Corner


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