# GATE-CS-2015 (Mock Test)

• Last Updated : 02 Dec, 2021

 Question 1
The output of following C program is
#include <stdio.h>
char str1;

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;
}
 A GATE CS 2015 Mock Test B tseT kcoM 5102 SC ETAG C Nothing is printed on screen D Segmentation Fault
GATE-CS-2015 (Mock Test)     C String
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.
 A Problem 1 belongs NP Complete set and 2 belongs to P B Problem 1 belongs to P set and 2 belongs to NP Complete set C Both problems belong to P set D Both problems belong to NP complete set
GATE-CS-2015 (Mock Test)    NP Complete    50 Algorithms MCQs with Answers
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?
 A Forward it the router whose entry matches with the longest prefix of incoming packet B Forward the packet to all routers whose network addresses match. C Discard the packet. D Forward it the router whose entry matches with the longest suffix of incoming packet
GATE-CS-2015 (Mock Test)    Network Layer
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?
 A 1->D, 2->B, 3->B B 1->D, 2->B, 3->D C 1->B, 2->D, 3->D D 1->D, 2->D, 3->D
GATE-CS-2015 (Mock Test)    Network Layer
Discuss it

Question 4 Explanation:
 Question 5
Which of the following is NOT true about User Datagram Protocol in transport layer?
 A Works well in unidirectional communication, suitable for broadcast information. B It does three way handshake before sending datagrams C It provides datagrams, suitable for modeling other protocols such as in IP tunneling or Remote Procedure Call and the Network File System D The lack of retransmission delays makes it suitable for real-time applications
GATE-CS-2015 (Mock Test)    Transport Layer
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.
 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) 
 A Θ(nLogn) B Θ(n2) C Θ(n) D Θ(n2Logn)
GATE-CS-2015 (Mock Test)    Analysis of Algorithms (Recurrences)
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: A f1(n); f4(n); f2(n); f3(n) B f1(n); f2(n); f3(n); f4(n); C f2(n); f1(n); f4(n); f3(n) D f1(n); f2(n); f4(n); f3(n)
GATE-CS-2015 (Mock Test)    Analysis of Algorithms
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).
 A 1/32 B 5/16 C 1/2 D 7/64
GATE-CS-2015 (Mock Test)    Probability
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)

 A 1 and 2 B 2, 3, and 4 C 1, 2 and 3 D 2, 3 and 4
GATE-CS-2015 (Mock Test)    Sorting    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:
 A Θ(n) B Θ(nLogn) C Θ(Logn) D Θ(1)
GATE-CS-2015 (Mock Test)    Algorithm Misc    50 Algorithms MCQs with Answers
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.
My Personal Notes arrow_drop_up

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.