Capgemini Pseudo Code MCQs | Capgemini Pseudo Code Test

Capgemini pseudo code MCQs  with answers are given here. These are the questions which were asked in most recent Capgemini pseudo code test.

Capgemini Pseudo Code MCQs –  Pattern

capgemini pseudo code questions

The pattern for Capgemini pseudo code MCQs is given below. Capgemini pseudo code Mcqs section consists of  25 questions to be answered in 25 minutes. This means approximately 1 minute is the maximum amount you can take to answer each question.

In Capgemini, this is a very crucial round. Though Capgemini has never announced sectional cutoff, yet the overall test cutoff is high. Hence you need to answer the maximum number of questions to clear the test. Generally, a minimum of 70% questions needs to be answered rightly in each section.

SectionNumber of questionsTime duration
Pseudo Code MCQ’s20 20 mins

To know the pattern and syllabus of other rounds in Capgemini recruitment process, click on the below button.

Capgemini Pseudo Code MCQs –  Syllabus

The syllabus for Capgemini pseudo code MCQs section is as given below. Questions will be mostly on these topics only.

  • C
  • C++
  • Data Structures
  • OOPS

Capgemini Pseudo Code MCQs (previously asked)

1) What will be the value of s if n=127?

Read n
i=0,s=0
Function Sample(int n)
while(n>0)
r=n%l0
p=8^i
s=s+p*r
i++
n=n/10
End While
Return s;
End Function

a) 27
b) 187
c) 87
d) 120

Ans: Option C

2) What will be the value of s if N=20?

Read N
Function sample(N)
s = 0, f = 1, i=1;
Do Until i <= N
f = f * i;
s = s +(i / f);
i=i+1
End Do
return(s);
End Function

a) 666667
b) 718282
c) 708333
d) 716667

Ans: Option B

3) What will be the output if limit = 6?

Read limit
n1 = 0, n2= 1, n3=1, count = 1;
while  count <= limit
count=count+1
print n3
n3 = n1 + n2
n1 = n2
n2 = n3
End While

a) 1235813
b) 12358
c) 123581321
d) 12358132

Ans: Option A

4) What will be the value of even_counter if number = 2630?

Read number
Function divisible(number)
even_counter = 0, num_remainder = number;
while (num_remainder)
digit = num_remainder % 10;
if digit != 0 AND number % digit == 0
even_counter= even_counter+1
End If
num_remainder= num_remainder / 10;
End While
return even_counter;

a) 3
b) 4
c) 2
d) 1

Answer: Option D

5) What will be the value of t if a = 56 , b = 876?

Read a,b
Function mul(a, b)
t = 0
while (b != 0)
t = t + a
b=b-1
End While
return t;
End Function

a) 490563
b) 49056
c) 490561
d) None of the mentioned

Ans: Option B

6) Code to sort given array in ascending order:

Read size
Read a[1],a[2],…a[size]
i=0
While(i<size)
j=i+1
      While(j<size)       
            If a[i] < a[j] then           
t= a[i];
a[i] = a[j];
a[j] = t;

End If
j=j+1
End While
i=i+1
End While
i=0
While (i<size)
print a[i]
i=i+1
End While

wrong statement?
a) Line 4
b) Line 6
c) Line 7
d) No Error

Ans: Option C

7) What is the time complexity of searching for an element in a circular linked list?
a) O(n)
b) O(nlogn)
c) O(1)
d) None of the mentioned

Ans: Option A

8) In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is
a) log 2 n
b) n2
c) log 2 n – 1
d) n

Ans: Option D

9) Which of the following will give the best performance?
a) O(n)
b) O(n!)
c) O(n log n)
d) O(n^C)

Ans: Option A

10) How many times the following loop be executed?

{

ch = ‘b’;
while(ch >= ‘a’ && ch <= ‘z’)
ch++;
}

a) 0
b) 25
c) 26
d) 1

Ans: B

11) 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
b) 2n + 4
c) 2n + 2
d) 2n

Ans: A

12) 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
b) 88
c) 72
d) 65

Ans: C

13) 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
b) 5
c) 10
d) 15

Ans: D
 

14) 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
b) 15
c) 9
d) 6

Ans: A

15) 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
b) 3, 3, and 3
c) 4, 0, and 1
d) 3, 0, and 2

Ans: A
 
16) 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)
b) O(nLogn)
c) Θ(nLogn)
d) O(n3)


Ans: A
 
17) 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)
b) O(m+n)
c) O(n2)
d) O(mn)

Ans: C

18) 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
b) t1 < t2
c) t1 > t2
d) t1 = t2

Ans: C

19) 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
b) Inorder traversal
c) Postorder traversal
d) Level order traversal

Ans: C

20) 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());
}

Ans: a

Leave a Reply