Capgemini Pseudo Code MCQ | Set 3

Capgemini Pseudo Code | Set 3


Capgemini Psuedo Code MCQ


Ques. 1 How many times will the print statement be executed:

Integer a, b, c
 Set a = 8, b = 10, c = 6
 If(a > c AND (b + c) > a)
   Print a
 end if
 if(c > b OR (a + c) > b)
   Print b
 end if
 if((b+c) MOD a EQUALS 0)
   Print c
 end if


Options:


A) 2

B) 3

C) 1

D) 0

Correct Answer: Option B


Explanation:  All the conditions are true when checked with the condition so the print statement will be executed 3 times.


Ques. 2 What will be the output of the following pseudo-code?


Integer x, y, z
Set x=24, y=8
x = x/y
z = y<<x
Print z

[Note: << is left shift operator, it takes two numbers, left shifts the bits of the first operand, the second operand decodes the number of …]

 

Options:


A) 1

B) 8

C) 0

D) 64


Correct Answer: Option D


Explanation:  When the x is reinitialized in line 3 the value stored will be 3. Therefore 8 has to be left-shifted thrice. The shifted value is the 3rd next power of 2 that is 2^6 and the value is 64.


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


Integer x, y, z, a
Set x = 2, y = 1, z = 5
a = (x AND y) OR (z + 1)
Print a

Options:


A) 5

B) 3

C) 2

D) 1


Correct Answer: Option D


Explanation:  AND gate works when both the conditions are true so the first (x and y) condition will be taken as true as both the inputs are true. OR gate works when any of the conditions are true, where it has already got one of its input as true so without checking the other input it will directly assign the value as 1.


Ques. 4 What do we call the binary tree nodes with no successor?

Options:

A) End nodes

B) Terminal nodes

C) Last nodes

D) Final nodes


Correct Answer: Option B


Explanation:  The official terminology is Terminal node or leaf node



Ques. 5 Recursion uses more memory space than iteration. Which of the following is/are the valid reason for the same?


A.   It uses the stack instead of a queue


B.   Every recursion call has to be stored


Choose the correct answer from the options given below.


A)   Only A

B)   Both A and B

C)   Neither A nor B

D)   Only B



Correct Answer: Option A


Explanation: Recursive functions use the stack as the memory space technique. And also as rightly pointed out the call has to be present to store the returned values.


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


Ques. 7 Which of the following operations is possible on an array?


Options:


A) All of the mentioned options

B) Insertion

C) Searching

D) Sorting


Correct Answer: Option A


Explanation:  It is trickier when it comes to arrays to do the operation in comparison with the linked lists. But they are definitely possible


Ques. 8 Which of the following is NOT a type of linked list?


A)   Double ended linked list

B)   Double linked list

C)   Simple linked list

D)   Circular linked list



Correct Answer: Option A


Explanation: We just have 3 types of linked list among the given options b, c, and d. A double-ended linked list does not exist.


Ques. 9 Each node of the graph is represented as a _______?


A)  Vertex

B)  Root

C)  Path

D)  Edge


Correct Answer: Option A


Explanation: Every node cannot be a root node and path, the edge is related to the directions of the graph.


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


 

Integer c, d
 Set c = 15, d = 12
 d = c 1
 Print c //line
 c = d + (c 2)
 if(c < 40)
   Goto line
 end if 

 

Options:


A) 14 26 38

B) 27 39

C) 15 27 39

D) None of the above


Correct Answer: Option C


Explanation:  c and a is initialized, and d as well; line 5 we are re-initializing c in every iteration of goto; the goto loop terminates only when the value of c is greater than 40 the last value stored in c which breaks the if the condition is 51 and all the numbers 15 27 and 39 will be printed according to the algebraic expression in line number 5.




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