Time: 00:00:00

Question #1

Consider the following piece of code. What will be the space required for this code?

int sum(int A[], int n)
{
int sum = 0, i;
for(i = 0; i < n; i++)
sum = sum + A[i];
return sum;
}
// sizeof(int) = 2 bytes
A
2n + 8
2n + 8
B
2n + 4
2n + 4
C
2n + 2
2n + 2
D
2n
2n
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

2n+4

Start

Time: 00:00:00

Question #2

What will be the output of the following pseudo code?

For input a=8 & b=9.
Function(input a,input b)
If(a<b)
return function(b,a)
elseif(b!=0)
return (a+function(a,b-1))
else
return 0
A
56
56
B
88
88
C
72
72
D
65
65
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Time: 00:00:00

Question #3

What will be the output of the following pseudo code?

Input m=9,n=6
m=m+1
N=n-1
m=m+n
if (m>n)
print m
else
print n
A
6
6
B
5
5
C
10
10
D
15
15
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

m=9, n=6 m=9+1 =10 N=6-1 =5 m=10+5 =15 if(15>6) print 15 else print 6 so the answer is 15

Start

Time: 00:00:00

Question #4





What will be the output of the following pseudo code?








Input f=6,g=9 and set sum=0
Integer n
if(g>f)
for(n=f;n<g;n=n+1)
sum=sum+n
End for loop
else
print error message
print sum



A
21
21
B
15
15
C
9
9
D
6
6
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Time: 00:00:00

Question #5

Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions are resolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33, 12, 17, 10. The maximum, minimum, and average chain lengths in the hash table, respectively, are
A
3, 0, and 1
3, 0, and 1
B
3, 3, and 3
3, 3, and 3
C
4, 0, and 1
4, 0, and 1
D
3, 0, and 2
3, 0, and 2
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Time: 00:00:00

Question #6

You have an array of n elements. Suppose you implement a quick sort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is:
A
O(n2)
O(n2)
B
O(nLogn)
O(nLogn)
C
Θ(nLog2)
Θ(nLog2)
D
O(n3)
O(n3)
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Time: 00:00:00

Question #7

Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time on Depth First Search of G? Assume that the graph is represented using adjacency matrix.
A
O(n)
O(n)
B
O(m+n)
O(m+n)
C
O(n2)
O(n2)
D
O(mn)
O(mn)
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Time: 00:00:00

Question #8

Let P be a Quick Sort Program to sort numbers in ascending order using the first element as a pivot. Let t1 and t2 be the number of comparisons made by P for the inputs {1, 2, 3, 4, 5} and {4, 1, 5, 3, 2} respectively. Which one of the following holds?
A
t1 = 5
t1 = 5
B
t1 < t2
t1 < t2
C
t1 > t2
t1 > t2
D
t1 = t2
t1 = t2
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Time: 00:00:00

Question #9

What does the following piece of code do?

public void func(Tree root)
{
func(root.left());
func(root.right());
System.out.println(root.data());
}
A
Preorder traversal
Preorder traversal
B
Inorder traversal
Inorder traversal
C
Postorder traversal
Postorder traversal
D
Level order traversal
Level order traversal
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Post order Traversal : LEFT> RIGHT >ROOT

Start

Time: 00:00:00

Question #10

How will you find the minimum element in a binary search tree?

a) public void min(Tree root)
{
while(root.left() != null)
{
root = root.left();
}
System.out.println(root.data());
}

b) public void min(Tree root)
{
while(root != null)
{
root = root.left();
}
System.out.println(root.data());
}

c) public void min(Tree root)
{
while(root.right() != null)
{
root = root.right();
}
System.out.println(root.data());
}

d) public void min(Tree root)
{
while(root != null)
{
root = root.right();
}
System.out.println(root.data());
}
A
a
a
B
b
b
C
c
c
D
d
d
Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Buy Capgemini Pseudo Code Paid Materials

Join Capgemini Online Classes

Your Quiz-1 Percentile Percentile (0%)

You can check your score after Login/Signup

Your global Capgemini Ranking

-

Your Capgemini- Pseudo Code Ranking

-

Your Quiz-1 Percentile Ranking

-

The percentile data will be refreshed at 11:59 PM everyday

Result

Result

Completed - 0/10

Average time Per Question - 0