GATE CS Mock 2018

Last Updated :
Discuss
Comments

Question 1

Predict the output?

C
int fun(char *str1)
{
    char *str2 = str1;
    while (*++str1)
        ;
    return (str1 - str2);
}
int main()
{
    char *str = "GeeksQuiz";
    printf("%d", fun(str));
    return 0;
}


  • 10

  • 9

  • 8

  • Random Number

Question 2

What will be the output of the following program?

C
#include <stdio.h>
int main() {
    int a = 10, b = 20, c;
    c = scanf("%d %d", &a, &b);
    printf("%d %d %d\n", a, b, c);
    return 0;
}

User Input: 30 40

  • 30 40 2

  • 10 20 2

  • 30 40 1

  • Compilation error

Question 3

Which of the following option is False?
  • An executing instance of a program is called a process while a thread is a subset of the process.
  • Threads have considerable overhead while processes have almost no overhead.
  • Execution of processes are independent while execution of threads are dependent.
  • New processes require duplication of the parent process while new threads are easily created.

Question 4

Suppose that the one-way propagation delay for a 100 Mbps Ethernet having 48-bit jamming signal is 1.04 micro-seconds. The minimum frame size in bits is:
  • 112
  • 160
  • 208
  • 256

Question 5

What is the time complexity of following function fun()? Assume that log(x) returns log value in base 2.

void fun(int n)
{
   int i, j;
   for (i=1; i<=n; i++)
      for (j=1; j<=log(i); j++)
         printf("GeeksforGeeks");
}
  • Θ(n)

  • Θ(nLogn)

  • Θ(n^2)

  • Θ(n^2(Logn))

Question 6

Given A, an array of size n, comprised of an increasing sequence of numbers followed immediately by a decreasing one. What is worst case time complexity of optimal algorithm to determine if a given number x is in the array?
  • Θ(log n)
  • Θ(n)
  • Θ(n^2)
  • Θ(log n)^2

Question 7

Recall that Belady’s anomaly is that the pages-fault rate may increase as the number of allocated frames increases and also recall convey effect where first process can increase waiting time for all processes. Now consider the following statements:
S1 : Random page replacement algorithm (where
    a page chosen at random is replaced) 
    suffers from Belady’s anomaly.

S2 : Random CPU scheduling algorithm 
    suffers from convoy effect.
Which of the following is CORRECT?
  • S1 is true, S2 is true
  • S1 is true, S2 is false
  • S1 is false , S2 is true
  • S1 is false, S2 is false

Question 8

Consider 4-way set-associative cache memory has the following properties:
  • Data words are 32 bits each
  • A cache block will contain 2048 bits of data
  • The address supplied from the CPU is 32 bits long
  • There are 2048 blocks in the cache
  • Addresses are to the word
Number of bits in tag?
  • 17
  • 15
  • 16
  • None of the above

Question 9

Consider the following C-program : C
int fun()
{
  static int num = 16;
  return num--;
}

int main()
{
  for(fun(); fun(); fun())
    printf("%d ", fun());
  return 0;
}
What is output of above program?
  • Infinite loop

  • 13 10 7 4 1

  • 15 12 8 5 2

  • 14 11 8 5 2

Question 10

Consider the following table
       Algorithms                   Design Paradigms
(P) Dijkastra’s Algorithm              (i) Divide and Conquer
(Q) Strassen’s Matrix Multiplication   (ii) Greedy
(R) Fibonacci numbers                  (iii) Dynamic Programming 
Match the algorithm to design paradigms they are based on:
  • P-(ii), Q-(iii), R-(i)
  • P-(iii), Q-(i), R-(ii)
  • P-(ii), Q-(i), R-(iii)
  • P-(i), Q-(ii), R-(iii)
Tags:

There are 62 questions to complete.

Take a part in the ongoing discussion