GATE-CS-2015 (Mock Test)

Last Updated :
Discuss
Comments

Question 1

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 2

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 3

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 4

Consider the situation in which the disk read/write head is currently located at track 45 (of tracks 0-255) and moving in the positive direction. Assume that the following track requests have been made in this order: 40, 67, 11, 240, 87. What is the order in which optimised C-SCAN would service these requests and what is the total seek distance?
  • 600
  • 810
  • 505
  • 550

Question 5

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}

Question 6

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)

Question 7

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

Question 8

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 9

Consider the following three table to store student enrollements in different courses.

Student(EnrollNo, Name)
Course(CourseID, Name)
EnrollMents(EnrollNo, CourseID) 

What does the following query do?

SELECT S.Name
FROM Student S, Course C, Enrollments E
WHERE S.EnrollNo = E.EnrollNo AND 
      C.Name = "DBMS" AND
      E.CourseID = C.CourseID AND
      S.EnrollNo IN 
        (SELECT S2.EnrollNo
         FROM Student S2, Course C2, Enrollments E2
         WHERE S2.EnrollNo = E2.EnrollNo AND
               E2.CourseID = C2.CourseID
               C2.Name = "OS")
  • Name of all students who are either enrolled in "DBMS" or "OS" courses

  • Name of all students who are enrolled in "DBMS" and "OS"

  • Name of all students who are either enrolled in "DBMS" or "OS" or both.

  • None of the above

Question 10

Consider the following Employee table 
 

ID   salary   DeptName
1    10000      EC
2    40000      EC
3    30000      CS
4    40000      ME
5    50000      ME
6    60000      ME 
7    70000      CS 


How many rows are there in the result of following query? 
 

SELECT E.ID
FROM  Employee E
WHERE  EXISTS  (SELECT E2.salary
               FROM Employee E2
               WHERE E2.DeptName = 'CS'
               AND   E.salary > E2.salary)


 

  • 6
     

  • 5
     

  • 4
     

  • 0
     

Tags:

There are 18 questions to complete.

Take a part in the ongoing discussion