GATE 2017 Mock

Last Updated :
Discuss
Comments

Question 1

Consider the following C code for process P1 and P2. a=4, b=0, c=0 (initialization)
     P1                      P2
  if (a < 0)                b = 10;    
    c = b-a;                a = -3;
  else
    c = b+a;
If the processes P1 and P2 executes concurrently (shared variables a, b and c), which of the following cannot be the value of ‘c’ after both processes complete?
  • 4
  • 7
  • 10
  • 13

Question 2

Suppose a stack is to be implemented with a linked list instead of an array. What would be the effect on the time complexity of the push and pop operations of the stack implemented using linked list (Assuming stack is implemented efficiently)?
  • O(1) for insertion and O(n) for deletion
  • O(1) for insertion and O(1) for deletion
  • O(n) for insertion and O(1) for deletion
  • O(n) for insertion and O(n) for deletion

Question 3

Consider n elements that are equally distributed in k stacks. In each stack, elements of it are arranged in ascending order (min is at the top in each of the stack and then increasing downwards). Given a queue of size n in which we have to put all n elements in increasing order. What will be the time complexity of the best known algorithm?
  • O(n logk)
  • O(nk)
  • O(n2)

  • O(k2)

Question 4

Which of the below given sorting techniques has highest best-case runtime complexity.
  • Quick sort
  • Selection sort
  • Insertion sort
  • Bubble sort

Question 5

Consider the problem of computing min-max in an unsorted array where min and max are minimum and maximum elements of array. Algorithm A1 can compute min-max in a1 comparisons without divide and conquer. Algorithm A2 can compute min-max in a2 comparisons by scanning the array linearly. What could be the relation between a1 and a2 considering the worst case scenarios?
  • a1 < a2
  • a1 > a2
  • a1 = a2
  • Depends on the input

Question 6

You are given an array A[] having n random bits and a function OR(i,j) which will take two indexes from an array as parameters and will return the result of ( A[i] OR A[j] ) i.e bitwise OR. What is the minimum no of OR calls required so as to determine all the bits inside the array i.e. to determine every index of A[] whether it has 0 or 1 ?
  • N-1
  • N*(N-1)/2
  • N
  • Not possible to determine the bit array

Question 7

What will be the output produced by the following C code:
int main()
{
    int array[5][5];
    printf("%d",( (array == *array) && (*array == array[0]) ));
    return 0;    
}
  • 1
  • 0
  • 2
  • -1

Question 8

Consider the following C code
int main()
{
   int a = 300;    
   char *b = (char *)&a;
   *++b = 2;
   printf("%d ",a);
   return 0;
}

Consider the size of int as two bytes and size of char as one byte. Predict the output of the following code . Assume that the machine is little-endian.
  • 556
  • 300
  • Runtime Error
  • Compile Time Error

Question 9

If LRU and Geek page replacement are compared (in terms of page faults) only for above reference string then find the correct statement from the following:
  • LRU and Geek are same
  • LRU is better than Geek
  • Geek is better than LRU
  • None

Question 10

Linked Questions 58-59
Assume GeeksforGeeks implemented the new page replacement algorithm in virtual memory and given its name as ‘Geek’. Consider the working strategy of Geek as following-
  • Each page in memory maintains a count which is incremented if the page is referred and no page fault occurs.
  • If a page fault occurs, the physical page with zero count or smallest count is replaced by new page and if more than one page with zero count or smallest count then it uses FIFO strategy to replace the page.
Find the number of page faults using Geeks algorithm for the following reference string (assume three physical frames are available which are initially free)
Reference String : “A B C D A B E A B C D E B A D”
  • 7
  • 9
  • 11
  • 13
Tags:

There are 65 questions to complete.

Take a part in the ongoing discussion