# GATE-CS-2015 (Mock Test)

Please wait while the activity loads.

If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled.

If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled.

Question 1 |

The output of following C program is

#include <stdio.h> char str1[100]; char *fun(char str[]) { static int i = 0; if (*str) { fun(str+1); str1[i] = *str; i++; } return str1; } int main() { char str[] = "GATE CS 2015 Mock Test"; printf("%s", fun(str)); return 0; }

GATE CS 2015 Mock Test | |

tseT kcoM 5102 SC ETAG
| |

Nothing is printed on screen | |

Segmentation Fault |

**C String**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 1 Explanation:

The function basically reverses the given string.

Question 2 |

Consider the following two problems of graph.

**1)**Given a graph, find if the graph has a cycle that visits every vertex exactly once except the first visited vertex which must be visited again to complete the cycle.**2)**Given a graph, find if the graph has a cycle that visits every edge exactly once. Which of the following is true about above two problems.Problem 1 belongs NP Complete set and 2 belongs to P | |

Problem 1 belongs to P set and 2 belongs to NP Complete set | |

Both problems belong to P set | |

Both problems belong to NP complete set |

**NP Complete**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 2 Explanation:

Problem 1 is Hamiltonian Cycle problem which is a famous NP Complete problem.
Problem 2 is Euler Circuit problem which is solvable in Polynomial time.

Question 3 |

Routers forward a packet using forwarding table entries. The network address of incoming packet may match multiple entries. How routers resolve this?

Forward it the the router whose entry matches with the longest prefix of incoming packet | |

Forward the packet to all routers whose network addresses match. | |

Discard the packet. | |

Forward it the the router whose entry matches with the longest suffix of incoming packet |

**Network Layer**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 3 Explanation:

The network addresses of different entries may overlap in forwarding table. Routers forward the incoming packet to the router which hash the longest prefix matching with the incoming packet.

Question 4 |

Consider the following routing table of a router.

Consider the following three IP addresses.

How are the packets with above three destination IP addresses are forwarded?

1->D, 2->B, 3->B | |

1->D, 2->B, 3->D | |

1->B, 2->D, 3->D | |

1->D, 2->D, 3->D |

**Network Layer**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 4 Explanation:

Refer following source of this question for explanation.
https://www.youtube.com/watch?v=PSC5omE3pX8&list=PLkHsKoi6eZnzJl1qTzmvBwTxrSJW4D2Jj&index=32

Question 5 |

Which of the following is not true about User Datagram Protocol in transport layer?

Works well in unidirectional communication, suitable for broadcast information. | |

It does three way handshake before sending datagrams | |

It provides datagrams, suitable for modeling other protocols such as in IP tunneling or Remote Procedure Call and the Network File System | |

The lack of retransmission delays makes it suitable for real-time applications |

**Transport Layer**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 5 Explanation:

// UDP is a connectioness protocol, so it doesn't establish connection. Three way handshake is done by transport layer.
A- UDP is a stateless protocol thus, useful in servers which answer small queries of large number of clients as it doesn’t need to store the state for each client. Thus, UDP is suitable for broadcast and unidirectional communication.
B- Three way handshake is performed by TCP before establishing the connection in which it first sends SYN packet then SYN-ACK is received,then ACK packet is sent. UDP is a connectionless protocol and thus,doesn’t to perform 3-way handshake.
C- IP tunneling is a communication channel between two different kind of networks .It is used to connect islands of IPv6 across the IPV internet by encapsulating the packets in the frame format of IPV4 . Remote procedure call is when a program causes a subroutine to run in another address space .This address space can be on server.It is a request response protocol and thus,UDP is suitable for it. Datagrams are also useful as UDP is a packet stream protocol.
D- TCP retransmits the errorneous packets from source to destination while UDP discards them.
This solution is contributed by

**Shashank Shanker khare**Question 6 |

Select the correct asymptotic complexity of an algorithm with runtime T(n, n) where

T(x, c) = Θ(x) for c <= 2, T(c, y) = Θ(y) for c <= 2, and T(x, y) = Θ(x+y) + T(x/2, y/2)

Θ(nLogn) | |

Θ(n ^{2}) | |

Θ(n) | |

Θ(n ^{2}Logn) |

**Analysis of Algorithms (Recurrences)**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 6 Explanation:

The recurrence is

T(x, y) = Θ(x+y) + T(x/2, y/2)It can be written as below.

T(x, y) = Θ(x+y) + Θ((x+y)/2) + Θ((x+y)/4) + Θ((x+y)/8) ..... T(x, y) = Θ((x+y) + (x+y)/2 + (x+y)/4 + (x+y)/8 ..... )The above expression forms a geometric series with ratio as 2 and starting element as (x+y)/2 T(x, y) is upper bounded by Θ(x+y) as sum of infinite series is 2(x+y). It is lower bounded by (x+y) Source: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/assignments/MIT6_006F11_ps1.pdf

Question 7 |

The increasing order of following functions in terms of asymptotic complexity is:

f1(n); f4(n); f2(n); f3(n) | |

f1(n); f2(n); f3(n); f4(n); | |

f2(n); f1(n); f4(n); f3(n) | |

f1(n); f2(n); f4(n); f3(n) |

**Analysis of Algorithms**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 8 |

An ISP has a link of 100Mbps which is shared by its subscribers. Considering the fact that all of its subscribers are active 50% of the time and the probabilities of being active are independent, the ISP has promised 25 Mbps to its 6 subscribers. What is the probability that any subscriber gets degraded service (less than promised speed).

1/32 | |

5/16 | |

1/2 | |

7/64 |

**Probability**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 8 Explanation:

The above question is an example of Binomial Experiment.
Any user can be either Online(O) or Offline(F)
Let be the Random Variable denoting the number of users online. The users get degraded service when or ,

Question 9 |

Which of the following changes to typical QuickSort improves its performance on average and are generally done in practice.

1) Randomly picking up to make worst case less likely to occur. 2) Calling insertion sort for small sized arrays to reduce recursive calls. 3) QuickSort is tail recursive, so tail call optimizations can be done. 4) A linear time median searching algorithm is used to pick the median, so that the worst case time reduces to O(nLogn)

1 and 2 | |

2, 3, and 4 | |

1, 2 and 3 | |

2, 3 and 4 |

**Sorting**

**GATE-CS-2015 (Mock Test)**

**QuickSort**

**Discuss it**

Question 9 Explanation:

The 4th optimization is generally not used, it reduces the worst case time complexity to O(nLogn), but the hidden constants are very high.

Question 10 |

Given an array that represents elements of arithmetic progression in order. It is also given that one element is missing in the progression, the worst case time complexity to find the missing element efficiently is:

Θ(n) | |

Θ(nLogn) | |

Θ(Logn) | |

Θ(1) |

**Algorithm Misc**

**GATE-CS-2015 (Mock Test)**

**Discuss it**

Question 10 Explanation:

We can use Binary Search to find the missing element. See following link for details.
http://www.geeksforgeeks.org/find-missing-number-arithmetic-progression/

There are 18 questions to complete.