Question 1
Consider the following function implemented in C:
void printxy(int x, int y)
{
int *ptr;
x = 0;
ptr = &x;
y = *ptr;
*ptr = 1;
printf("%d,%d", x, y);
}
The output of the printxy(1,1) is
0,0
0,1
1,0
1,1
Question 2
Consider the following snippet of a C program. Assume that swap(&x, &y) exchanges the contents of x and y.
int main()
{
int array[] = {3, 5, 1, 4, 6, 2};
int done = 0;
int i;
while (done == 0)
{
done = 1;
for (i = 0; i <= 4; i++)
{
if (array[i] < array[i+1])
{
swap(&array[i], &array[i+1]);
done = 0;
}
}
for (i = 5; i >= 1; i--)
{
if (array[i] > array[i-1])
{
swap(&array[i], &array[i-1]);
done = 0;
}
}
}
printf("%d", array[3]);
}
The output of the program is _____. Note: This question appeared as Numerical Answer Type.
1
2
3
4
Question 3
In a two-level cache system, the access times of L1 and L2 1 and 8 clock cycles, respectively. The miss penalty from the L2 cache to main memory is 18 clock cycles. The miss rate of L1 cache is twice that of L2. The average memory access time(AMAT) of this cache system is 2 cycles. The miss rates of L1 and L2 respectively are:
0.111 and 0.056
0.056 and 0.111
0.0892 and 0.1784
0.1784 and 0.0892
Question 4
Consider the following C function.
int fun(int n)
{
int i, j;
for (i = 1; i <= n ; i++)
{
for (j = 1; j < n; j += i)
{
printf("%d %d", i, j);
}
}
}
Time complexity of fun in terms of θ notation is:
θ(n √n)
θ(n2)
θ(n log n)
θ(n 2 log n)
Question 5
Consider the following languages.
L1 = {ap | p is a prime number}
L2 = {anbmc2m | n >= 0, m >= 0}
L3 = {anbnc2n | n >= 0}
L4 = {anbn | n >= 1}
Which of the following are CORRECT ?
I. L1 is context free but not regular.
II. L2 is not context free.
III. L3 is not context free but recursive.
IV. L4 is deterministic context free.
I, II and IV only
II and III only
I and IV only
III and IV only
Question 6
Consider the set of processes with arrival time(in milliseconds), CPU burst time (in milliseconds), and priority(0 is the highest priority) shown below. None of the processes have I/O burst time.
The average waiting time (in milliseconds) of all the processes using preemptive priority scheduling algorithm is ____.
Note: This question appeared as Numerical Answer Type.
29
30
31
32
Question 7
The pre-order traversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20. Then the post-order traversal of this tree is:
2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12
7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12
Question 8
If w, x, y, z are boolean variables, then which of the following in INCORRECT?
wx + w(x+y) + x(x+y) = x + wy
(wx'(y + z'))' + w'x = w' + x + y'z
(wx'(y + xz') + w'x')y = xy'
(w + y)(wxy + wyz) = wxy + wyz
Question 9
Consider two hosts X and Y, connected by a single direct link of rate 106 bits/sec. The distance between the two hosts is 10,000 km and the propagation speed along the link is 2 x 108 m/s. Hosts X send a file of 50,000 bytes as one large message to hosts Y continuously. Let the transmission and propagation delays be p milliseconds and q milliseconds, respectively. Then the vales of p and q are:
p = 50 and q = 100
p = 50 and q = 400
p = 100 and q = 50
p = 400 and q = 50
Question 10
Consider the following C program:
#include
int main()
{
int m = 10;
int n, n1;
n = ++m;
n1 = m++;
n--;
--n1;
n -= n1;
printf("%d",n);
return 0;
}
The output of the program is ______.
Note:
This questions appeared as Numerical Answer Type.
0
1
2
3
There are 65 questions to complete.