Capgemini Pseudo Code MCQ | Set 2

Capgemini Pseudo Code | Set 2


Capgemini Psuedo Code MCQ




Ques. 1 To which of the following domain problem does the knapsack problem belong?


A)   NP-complete

B)   Sorting

C)   Optimization

D)   Linear Solution


Correct Answer: Option C


Explanation: knapsack algorithm is used to find the maximum profit out of the least weight combination possible, therefore it definitely belongs to an optimization domain.


Ques. 2 Which of the following data types represents many to many relations?


A)   Both plex and graph

B)   Graph

C)   Plex

D)   Tree

 

Correct Answer: Option A


Explanation: A many-to-many relationship occurs when multiple records in a table are associated with multiple records in another table. This is possible only with the help of Both plex and graph.


Ques. 3 Find the output of the following pseudo-code:


 Integer value, n

 Set value = 1, n = 45

 while(value less than equal to n)

 value = value << 1

 end loop

 Print value
 


Options:

A) 64

B) 32

C) 45

D) None of the above


Correct Answer: Option A


Explanation:  Here, the left shift operation pushes the values towards the left once; when 1 is left-shifted the value that we will be obtaining will always be 2 to the power something. When one is converted in the beginning and not shifted the value will be 2^0 which is 1. The next iteration will be pushed one place towards the left, therefore the value now will be 2^1 which is 2; this will go on happening until the value stored is greater than 45. The value which is greater than 45 in 2 powers is 64. Now the loop terminates and the last value stored in the variable is 64 and the same will be printed.


Ques. 4 What will be the output if the following pseudocode  


if a=10 and b=6:

   Integer func (Integer a, Integer b)

   Integer temp

   while(b)

     temp = a MOD b

     a = b

     b = temp

   end while

 return a

 End function func()

Options:

A) 2

B) 4

C) 3

D) 1


Correct Answer: Option A


Explanation:  The while loop will only terminate when the value of b becomes zero, this will happen only after the 4th iteration when the last value of the b will be zero and the value of a is 2


Ques. 5 What will be the output of the following pseudocode?

Integer a=5, b=4, c=3
a = b + c
c = ab
c = c + a
c = b + c
b = b + c
Print a, b, c

Options:


A) 7 14 7

B) 7 14 10

C) 7 8 14

D) 7 18 14


Correct answer: Option D


Explanation:  The intial values of a=5, b=4, c=3

           a = 4 +3 = 7

           c = 7 – 4 = 3

           c = 3 + 7 = 10

           c = 4 + 10 = 14

           b = 4 + 14 = 18

           Print 7, 18, 14


Ques. 6 What will be the output of the following pseudocode?


Integer a, b, c, d
Set b = 18, c = 12
a = b c
for (each c from 1 to a 1)
		 b = b + c + 12
		 b = b/5
		 d = b + a
end for
c = a + b + c
Print a b c


Options:


A) 5 3 9

B) 6 14 17

C) 6 4 14

D) 6 4 16


Correct Answer: Option D


Explanation:  The loop runs for 5 times; after the 5th iteration the value of a=6; b=4; c=10.

So the final answers are 6, 4, 16 


Ques. 7 An abstract data type is defined to be a mathematical model of a user-defined type along with the collection of all ________ operations on that model.


Options:

A) Union

B) Assignment

C) Primitive

D) None of the above


Correct Answer: Option A


Explanation:  In computer science, an abstract data type (ADT) is a mathematical model for data types. An abstract data type is defined by its behaviour (semantics) from the point of view of a user, of the data, specifically in terms of possible values, possible operations on data of this type, and the behaviour of these operations. These are not possible in union and assignment operations. 


Ques. 8 What do we call the highest element of an array’s index?


A)   Upper bound

B)   Lower bound

C)   Range

D)   Extraction


Correct Answer: Option A


Explanation: The upper bound is always the highest element of an array index.


Ques. 9 Find the output of the following pseudo-code:

Integer x,y,z;
x=0
y=1
x = y = z = 8
Print x

Options:

A) 0

B) 8 

C) 1

D) None of the above


Correct Answer: Option B


Explanation:   In the above question, the value of x is initialized as 0 and y as 1 in the beginning. Later the value 8 is assigned to the variable z and the value of z is assigned to the variable y and the value of y is assigned to the variable x. Finally, the value of x is updated as 8.


Ques. 10 Find the output of the following pseudo-code 


if x= 4 and y=5:

 Integer fun(int x, int y)
   if(x > 1)
     fun(x – 2, y + 2)
   end if
   print y
 End function fun()


Options:


A) 4 5 6

B) 7 6 5

C) 9 7 5

D) None of the above


Correct Answer: Option C


Explanation:  the first reverse recursion would print 9 and returns to a previous function call, next it prints 7 and returns to the very first function call finally it prints a 5 and completes the execution.


This Blog is Hard work !

Can you give me a treat 😌


Capgemini Pseudo Code MCQ - Set 1

Capgemini Pseudo Code MCQ - Set 2

Capgemini Pseudo Code MCQ - Set 3

Capgemini Pseudo Code MCQ - Set 4

Capgemini Pseudo Code MCQ - Set 5

Post a Comment

0 Comments