![]() |
VOOZH | about |
Question 1
Consider the following ANSI C function:
int SomeFunction (int x, int y)
{
if ((x==1) || (y==1)) return 1;
if (x==y) return x;
if (x > y) return SomeFunction(x-y, y);
if (y > x) return SomeFunction (x, y-x);
}
The value returned by SomeFunction (15, 255) is __________ .
15
1275
30
255
Question 2
Consider the following ANSI C function:
int SimpleFunction(int Y[], int n, int x)
{
int total = Y[0], loopIndex;
for (loopIndex=1; loopIndex<=n-1; loopIndex++)
total=x*total +Y[loopIndex];
return total;
}
Let Z be an array of 10 elements with Z[i]=1, for all i such that 0 <= i <= 9. The value returned by SimpleFunction(Z,10,2) is __________ .
1023
1024
2047
511
Question 3
Consider the following C code. Assume that unsigned long int type length is 64 bits.
The value returned when we call fun with the input [Tex]2^{40}[/Tex] is
4
5
6
40
Question 4
Consider the following C functions.
The value returned by pp(3,4) is ________ .
Note -
This question was Numerical Type.
81
64
100
49
Question 5
Consider the following C-function:
Suppose we modify the above function foo() and store the values of foo (i), 0 < = i < n, as and when they are computed. With this modification, the time complexity for function foo() is significantly reduced. The space complexity of the modified function would be:
O(1)
O(n)
O(n!)
O(nn)
Question 6
Consider the following C-function:
The space complexity of the above function is:
O(1)
O(n)
O(n!)
O(nn)
Question 7
Consider the following C program.
The output of the program _____________ Note : This question was asked as Numerical Answer Type.
2016
0
4
8
Question 8
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 9
The value printed by the following program is
10
20
30
40
Question 10
Consider the following C-program:
What does the above program print?
8, 4, 0, 2, 14
8, 4, 0, 2, 0
2, 0, 4, 8, 14
2, 0, 4, 8, 0
There are 34 questions to complete.