• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE CS 2008

Question 71

Consider the program given in above question, f1(8) and f2(8) return the values
  • 1661 and 1640
  • 59 and 59
  • 1640 and 1640
  • 1640 and 1661

Question 72

Delayed branching can help in the handling of control hazards. For all delayed conditional branch instructions, irrespective of whether the condition evaluates to true or false,
  • the instruction following the conditional branch instruction in memory is executed
  • the first instruction in the fall through path is executed
  • the first instruction in the taken path is executed
  • the branch takes longer to execute than any other instruction

Question 73

Delayed branching can help in the handling of control hazards The following code is to run on a pipelined processor with one branch delay slot:
I1: ADD R2R7+R8
I2 : SUB R4 R5-R6
I3 : ADD R1 R2+R3
I4 : STORE Memory [R4][R1]
BRANCH to Label if R1== 0
Which of the instructions I1, I2, I3 or I4 can legitimately occupy the delay slot without any other program modification?
  • I1
  • I2
  • I3
  • I4

Question 74

Let xn denote the number of binary strings of length n that contain noconsecutive 0s. Which of the following recurrences does Xn satisfy? Q79
  • A
  • B
  • C
  • D

Question 75

The value of X5 is
  • 5
  • 7
  • 8
  • 16

Question 76

The subset-sum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,...,an} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2-dimensional Boolean array X, with n rows and W+1 columns. X[i, j],1 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,...,ai} whose elements sum to j. Which of the following is valid for 2 <= i <= n and ai <= j <= W?

  • X[i, j] = X[i - 1, j] V X[i, j -ai]

  • X[i, j] = X[i - 1, j] V X[i - 1, j - ai]

  • X[i, j] = X[i - 1, j] V X[i, j - ai]

  • X[i, j] = X[i - 1, j] V X[i -1, j - ai]

Question 77

The subset-sum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,...,an} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2-dimensional Boolean array X, with n rows and W+1 columns. X[i, j],1 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,...,ai} whose elements sum to j. Which of the following is valid for 2 <= i <= n and ai <= j <= W? Which entry of the array X, if TRUE, implies that there is a subset whose elements sum to W?
  • X[1, W]
  • X[n, 0]
  • X[n, W]
  • X[n-1, n]

Question 78

Consider the following ER diagram. The minimum number of tables needed to represent M, N, P, R1, R2 is
  • 2
  • 3
  • 4
  • 5

Question 79

Consider the data given in above question. Which of the following is a correct attribute set for one of the tables for the correct answer to the above question?
  • {M1, M2, M3, P1}
  • {M1, P1, N1, N2}
  • {M1, P1, N1}
  • {M1, P1}

Question 80

Consider the following C program that attempts to locate an element x in an array Y[] using binary search. The program is erroneous. C
1.   f(int Y[10], int x) {
2.     int i, j, k;
3.     i = 0; j = 9;
4.     do {
5.             k =  (i + j) /2;
6.             if( Y[k] < x)  i = k; else j = k;
7.         } while(Y[k] != x && i < j);
8.     if(Y[k] == x) printf (\"x is in the array \") ;
9.     else printf (\" x is not in the array \") ;
10. }
On which of the following contents of Y and x does the program fail?
  • Y is [1 2 3 4 5 6 7 8 9 10] and x < 10
  • Y is [1 3 5 7 9 11 13 15 17 19] and x < 1
  • Y is [2 2 2 2 2 2 2 2 2 2] and x > 2
  • Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even

There are 85 questions to complete.

Last Updated :
Take a part in the ongoing discussion