• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Gate IT 2008

Question 41

The following three are known to be the preorder, inorder and postorder sequences of a binary tree. But it is not known which is which.
MBCAFHPYK
KAMCBYPFH
MABCKYFPH
Pick the true statement from the following.
  • I and II are preorder and inorder sequences, respectively
  • I and III are preorder and postorder sequences, respectively
  • II is the inorder sequence, but nothing more can be said about the other two sequences
  • II and III are the preorder and inorder sequences, respectively

Question 42

Consider the following sequence of nodes for the undirected graph given below.
a b e f d g c
a b e f c g d
a d g e b c f
a d b c g e f
A Depth First Search (DFS) is started at node a. The nodes are listed in the order they are first visited. Which all of the above is (are) possible output(s)?
2008_46
  • 1 and 3 only
  • 2 and 3 only
  • 2, 3 and 4 only
  • 1, 2, and 3

Question 43

Consider a hash table of size 11 that uses open addressing with linear probing. Let h(k) = k mod 11 be the hash function used. A sequence of records with keys
43 36 92 87 11 4 71 13 14
is inserted into an initially empty hash table, the bins of which are indexed from zero to ten. What is the index of the bin into which the last record is inserted?
  • 2
  • 4
  • 6
  • 7

Question 44

What is the output printed by the following C code? C
# include <stdio.h>
int main ()
{
    char a [6] = \"world\";
    int i, j;
    for (i = 0, j = 5; i < j; a [i++] = a [j--]);
    printf (\"%s\\n\", a);
}
 /* Add code here. Remove these lines if not writing code */ 
  • dlrow
  • Null String
  • dlrld
  • worow

Question 45

Consider the C program below. What does it print? C
# include <stdio.h>
# define swapl (a, b) tmp = a; a = b; b = tmp
void swap2 ( int a, int b)
{
        int tmp;
        tmp = a; a = b; b = tmp;
 }
void swap3 (int*a, int*b)
{
        int tmp;
        tmp = *a; *a = *b; *b = tmp;
}
int main ()
{
        int num1 = 5, num2 = 4, tmp;
        if (num1 < num2) {swap1 (num1, num2);}
        if (num1 < num2) {swap2 (num1 + 1, num2);}
        if (num1 >= num2) {swap3 (&num1, &num2);}
        printf (\"%d, %d\", num1, num2);
}
 /* Add code here. Remove these lines if not writing code */ 
  • 5, 5
  • 5, 4
  • 4, 5
  • 4, 4

Question 46

Consider the C program given below. What does it print? C
#include <stdio.h>
int main ()
{
        int i, j;
        int a [8] = {1, 2, 3, 4, 5, 6, 7, 8};
        for(i = 0; i < 3; i++) {
             a[i] = a[i] + 1;
             i++;
        }
        i--;
        for (j = 7; j > 4; j--) {
              int i = j/2;
              a[i] = a[i] - 1;
        }
        printf (\"%d, %d\", i, a[i]);
}
 /* Add code here. Remove these lines if not writing code */ 
  • 2, 3
  • 2, 4
  • 3, 2
  • 3, 3

Question 47

C program is given below: C
# include <stdio.h>
int main ()
{
        int i, j;
        char a [2] [3] = {{\'a\', \'b\', \'c\'}, {\'d\', \'e\', \'f\'}};
        char b [3] [2];
        char *p = *b;
        for (i = 0; i < 2; i++) {
              for (j = 0; j < 3; j++) {
              *(p + 2*j + i) = a [i] [j];
              }
        }
}
 /* Add code here. Remove these lines if not writing code */ 
What should be the contents of the array b at the end of the program?
  • a b
    c d
    e f
  • a d
    b e
    c f
  • a c
    e b
    d f
  • a e
    d c
    b f

Question 48

The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores equipped with the standard P and V operations. semaphore S = 1, Q = 0; integer x; producer:                            consumer: while (true) do                    while (true) do P(S);                                      P(Q); x = produce ();                    consume (x); V(Q);                                     V(S); done                                       done Which of the following is TRUE about the program above?
  • The process can deadlock
  • One of the threads can starve
  • Some of the items produced by the producer may be lost
  • Values generated and stored in \'x\' by the producer will always be consumed before the producer can generate a new value

Question 49

An operating system implements a policy that requires a process to release all resources before making a request for another resource. Select the TRUE statement from the following:

  • Both starvation and deadlock can occur

  • Starvation can occur but deadlock cannot occur

  • Starvation cannot occur but deadlock can occur

  • Neither starvation nor deadlock can occur

Question 50

If the time-slice used in the round-robin scheduling policy is more than the maximum time required to execute any process, then the policy will
  • degenerate to shortest job first
  • degenerate to priority scheduling
  • degenerate to first come first serve
  • none of the above

There are 82 questions to complete.

Last Updated :
Take a part in the ongoing discussion