A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

61. The value of j at the end of the execution of the following C program.

int incr(int i)
{
static int count = 0;
count = count + i;
return (count);
}
main()
{
int i,j;
for (i = 0; i <=4; i++)
j = incr(i);
}
a. 10
b. 4
c. 6
d. 7
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).10

62. Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort?
a. O(n)
b. O(n Log n)
c. O(n^2)
d. O(n!)
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).O(n^2)

63. Consider any array representation of an n element binary heap where the elements are stored from index 1 to index n of the array. For the element stored at index i of the array (i <= n), the index of the parent is
a. i - 1
b. floor(i/2)
c. ceiling(i/2)
d. (i+1)/2
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).floor(i/2)

64. What is the minimum number of stacks of size n required to implement a queue of size n?
a. One
b. Two
c. Three
d. Four
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).Two

65. What is printed by the print statements in the program P1 assuming call by reference parameter passing?

Program P1()
{
x = 10;
y = 3;
func1(y,x,x);
print x;
print y;
}
func1(x,y,z)
{
y = y+4;
z = x+y+z;
}
a. 10, 3
b. 31, 3
c. 27, 7
d. None of the above
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).31, 3

66. Consider the following three C functions :

[PI] int * g (void)
{
int x= 10;
return (&x);
}

[P2] int * g (void)
{
int * px;
*px= 10;
return px;
}

[P3] int *g (void)
{
int *px;
px = (int *) malloc (sizeof(int));
*px= 10;
return px;
}

Which of the above three functions are likely to cause problems with pointers?
a. Only P3
b. Only P1 and P3
c. Only P1 and P2
d. P1, P2 and P3
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).Only P1 and P2

67. Consider the following program

Program P2
var n: int:
procedure W(var x: int)
begin
x=x+1;
print x;
end

procedure D
begin
var n: int;
n=3;
W(n);
end
begin //beginP2
n=10;
D;
end

If the language has dynamic scoping and parameters are passed by reference, what will be printed by the program?
a. 10
b. 11
c. 3
d. None of the above
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).None of the above

68. In the C language
a. At most one activation record exists between the current activation record and the activation record for the main
b. The number of activation records between the current activation record and the activation record for the main depends on the actual function calling sequence
c. The visibility of global variables depends on the actual function calling sequence
d. Recursion requires the activation record for the recursive function to be saved on a different stack before the recursive function can be called
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).The number of activation records between the current activation record and the activation record for the main depends on the actual function calling sequence

69. The results returned by functions under value-result and reference parameter passing conventions
a. Do not differ
b. Differ in the presence of loops
c. Differ in all cases
d. May differ in the presence of exceptions
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).May differ in the presence of exceptions

70. Consider the following declaration of a two dimensional array in C:

char a[100][100];

Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 0, the address of a [40][50] is :
a. 4040
b. 4050
c. 5040
d. 5050
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).4050

Page 7 of 12