Join Regular Classroom : Visit ClassroomTech

Capgemini Sample Question Paper II | Codewindow.in

Q1. What will be the output of the following pseudocode for a=6, b=3, c=4?

Integer funn(Integer a, Integer b, Integer c)
        for(each c from 5 to 6)
		b=(b+a)^a
	End for
	return a+b

a) 37
b) 23
c) 29
d) 25

Answer: d) 25

Explanation:
for c = 5
a = 6, b = 3
(b + a) ^ a = 9 ^ 6 = 15
b = 15

for c = 6
a = 6, b = 15
(b + a) ^ a = 21 ^ 6 = 19
b = 19

a + b = 6 + 19 = 25

Q2. What will be the output of the following pseudocode?

Integer a,b,c
set a=5, b=3, c=5
if((c+b+a)<(a+c))
	a=(a+b)+a
End if
if((7+a-b)<(b+c))
	c=(3+8)+c
End if
print a+b+c

a) 4
b) 23
c) 15
d) 13

Answer: d) 13

Explanation:
First if condition is false, so the block will not execute.
Second if condition is also false, so that block will also not execute.
a + b + c = 5 + 3 + 5 = 13

Q3. What will be the output of the following pseudocode?

Integer a,b,c
set a=5, b=7, c=8
if((c-9)<(9-c))
	a=c^b
	a=b+c
else
	a=a+b
	b=(b+5)+a
	if(5>b)
		c=(b+a)+c
		a=c+a
	End if
	a=(b&5)+a
End if
print a+b+c

a) 32
b) 25
c) 30
d) 42

Answer: c) 30

Explanation:
First if condition is true.
a = c ^ b = 8 ^ 7 = 15
a = b + c = 7 + 8 = 15
a + b + c = 15 + 7 + 8 = 30

Q4. What will be the output of the following pseudocode?

Integer p,q,r
set p=2, q=8, r=9
for(each r from 5 to 9)
	q=q+r
	if((9&q)<r)
		q=3^pa
		q=5+q
	Else
		jump out of the loop
	End if
	p=5+r
End for
print p+q

a) 24
b) 20
c) 15
d) 10

Answer: c) 15

Explanation:
for r = 5
q = q + r = 8 + 5 = 13
if condition is false and jump out of the loop
p + q = 2 + 13 = 15

Also Read: Capgemini Sample Question Paper I

Q5. Post-order traversal of a BST, produces the following sequence of keys
28, 33, 47, 61, 55, 99, 82, 75, 41
Which one of the following sequences of keys can be the result of an in-order traversal of the same BST?

a) 28, 33, 41, 47, 55, 61, 75, 82, 99
b) 28, 33, 41, 55, 47, 61, 75, 82, 99
c) 28, 33, 47, 41, 55, 61, 75, 82, 99
d) 28, 33, 41, 47, 61, 55, 75, 82, 99

Answer: a) 28, 33, 41, 47, 55, 61, 75, 82, 99

Explanation:
POT is 28, 33, 47, 61, 55, 99, 82, 75, 41
So 41 is the root. 75 is the right children of 41, and as it is a BST 33 will the left children. 28 will be the only left children of 33.
47 has to be the left most child of 75. 61 or 55 has to be its parent but as 61 comes before 55, 55 is parent of 61. Same goes for 82 and 99.

                        41
		      /	  \
		    33	   75
		   /	  /  \
		 28	55    82
		       /  \	\
		     47	   61	 99

Q6. Which of the following data structure is used to convert the infix expression into prefix/postfix?

a) Stack
b) Queue
d) Tree
d) List

Answer: a) Stack

Q7. Which of the following data structure cannot be used to create a circular queue?

a) Stack
b) Array
c) Single linked list
d) Double linked list

Answer: a) Stack

Q8. If the base address of a two dimensional array A[100][300] is 10000, then find out the address of an element A[2][2] in the array.
**assume 4 words per memory cell and elements are arranged in column major order.

a) 10050
b) 10808
c) 18007
d) 17009

Answer: b) 10808

Explanation:
The address of A[2][2] = 10000 + (2 * 100 + 2) * 4 = 10808

Also Read: Infosys Sample Question Paper

Q9. If the base address of a two dimensional array A[200][300] is 20, then find out the address of an element A[2][4] in the array.
**assume 2 words per memory cell and elements are arranged in column major order.

a) 1258
b) 1828
c) 1228

d) 1624

Answer: d) 1624

Explanation:
The address of A[2][4] = 20 + (4 * 200 + 2) * 2 = 1624

Q10. Find out the sum of the degree of vertices in the pseudograph as shown in the image.

a) 26
b) 24
c) 12
d) 22

Answer: b) 24

Q11. Find out the pre order traversal sequence of the given BTS.

a) 30, 20, 10, 15, 23, 25, 39, 35, 42
b) 30, 20, 10, 15, 25, 23, 35, 39, 42
c) 30, 20, 10, 25, 15, 23, 39, 35, 42
d) 30, 20, 10, 15, 25, 23, 39, 35, 42

Answer: d) 30, 20, 10, 15, 25, 23, 39, 35, 42


 


Recent Posts