• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE-CS-2015 (Mock Test)

Question 1

Consider a 3 game tournament between two teams. Assume that every game results in either a win or loss. The team that wins two or more games wins the series. The probability for wining the first game for both teams is 1/2. The probability for a team to win a game after a win is 2/3. The probability of wining a game after a loss is 1/3. Note that the effect of only previous game is considered. What is the probability for a team to win the series after loosing first game.
  • 1/9
  • 1/6
  • 2/9
  • 1/3

Question 2

The output of following C program is C
#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

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 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 router whose entry matches with the longest suffix of incoming packet

Question 4

Consider the following routing table of a router.

PrefixNext Hop
192.24.0.0/18D
192.24.12.0/22B

Consider the following three IP addresses.

Prefix
192.24.0.0/18
192.24.12.0/22
192.24.54.0

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

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

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)
  • Θ(n2)
  • Θ(n)
  • Θ(n2Logn)

Question 7

The increasing order of following functions in terms of asymptotic complexity is: [Tex]\\\\ f_{1}(n) = n^{0.999999}log (n)\\\\ f_{2}(n) = 10000000n\\\\ f_{3}(n) = 1.000001^{n} f_{4}(n) = n^{2} [/Tex]
  • 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)

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

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

Question 10

Let swap() be a function that swaps two elements using their addresses. Consider the following C function. C
void fun(int arr[], int n)
{
    for (int i = 0; i < n; i+=2)
    {
        if (i>0 && arr[i-1] > arr[i] )
            swap(&arr[i], &arr[i-1]); 
        if (i<n-1 && arr[i] < arr[i+1] )
            swap(&arr[i], &arr[i + 1]);
    }
}
If an array {10, 20, 30, 40, 50, 60, 70, 80} is passed to the function, the array is changed to
  • {20, 10, 40, 30, 60, 50, 80, 70}
  • {10, 30, 20, 40, 60, 50, 80, 70}
  • {10, 20, 30, 40, 50, 60, 70, 80}
  • {80, 70, 60, 50, 40, 30, 20, 10}

There are 18 questions to complete.

Last Updated :
Take a part in the ongoing discussion