Question 51
Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n + m] be another integer array.
void xyz(int a[], int b [], int c[])
{
int i, j, k;
i = j = k = O;
while ((i<n) && (j<m))
if (a[i] < b[j]) c[k++] = a[i++];
else c[k++] = b[j++];
}
Which of the following condition(s) hold(s) after the termination of the while loop? (GATE CS 2006) (i) j < m, k = n+j-1, and a[n-1] < b[j] if i = n (ii) i < n, k = m+i-1, and b[m-1] <= a[i] if j = m
Question 52
int work1(int *a, int i, int j)
{
int x = a[i+2];
a[j] = x+1;
return a[i+2] – 3;
}
int work2(int *a, int i, int j)
{
int t1 = i+2;
int t2 = a[t1];
a[j] = t2+1;
return t2 – 3;
}
Question 53
subroutine swap(ix,iy) it = ix L1 : ix = iy L2 : iy = it end ia = 3 ib = 8 call swap (ia, 1b+5) print *, ia, ib endS1: The compiler will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the cell swap S2: On execution the code will generate a runtime error on line L1 S3: On execution the code will generate a runtime error on line L2 S4: The program will print 13 and 8 S5: The program will print 13 and -2 Exactly the following set of statement(s) is correct:
Question 54
void swap(int *px, int *py)
{
*px = *px - *py;
*py = *px + *py;
*px = *py - *px;
}
Question 55
S → FR R → S | ε F → idIn the predictive parser table, M, of the grammar the entries M[S, id] and M[R, $] respectively.
Question 56
Question 57
Consider the following C code segment.
for (i = 0, i<n; i++) { for (j=0; j<n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } } }
Which one of the following is false?
Question 58
void P (binary_semaphore *s) { unsigned y; unsigned *x = &(s->value); do { fetch-and-set x, y; } while (y); } void V (binary_semaphore *s) { S->value = 0; }Which one of the following is true?
Question 59
Question 60
There are 84 questions to complete.