Share this Article
Question 1
Answer
Explanation
Question 1
What will be the output of the following pseudocode?
Integer i
Set i = 3
do
print i + 3
i = i – 1
while(i not equals 0)
end while
A) 6 6 6
B) 6 5 6
C) 5 5 5
D) 6 5 4
Answer
Answer: Option D
Explanation
EXPLANATION:
Step 1:
It will print i+3, here i value is 3. So i+3 is 6. On the next line, i will be decremented by 1. Then checking
the conditions in do-while() i!=0. Here updated i value is 2 (2!=0),so condition is true. The loop
continues.
Step 2:
It will print i+3, here updated i value is 2. So i+3 is 5. On the next line i will be decremented by 1. Then
checking the conditions in do-while() i!=0. Here updated i value is 1 (1!=0),so condition gets true. The
loop continues
Step 3:
It will print i+3, here updated i value is 1. So i+3 is 4. On the next line i will be decremented by 1. Then
checking the condition in do while() i!=0. Here updated i value is 0 (0!=0),so condition gets false. Thus
the loop gets terminated!
Question 2
Answer
Explanation
Question 2
What would be the output of the following pseudocode?
Integer a
String str1
Set str1 = “goose”
a = stringLength(str1)
Print (a ^ 1)
A) 0
B) 4
C) 5
D) 3
Answer
Answer: Option B
Explanation
EXPLANATION:
There are two variables a and str1. Value initialized for str1 is “goose”. On the next line, we are finding
the length of str1 that is 5. Finally, printing the output of a bitwise exclusive OR operator with 1. And
the answer is 4
Question 3
Answer
Explanation
Question 3
What would be the output of the following pseudocode?
Integer a, b, c
Set a = 8, b = 51, c = 2
c = (a ^ c)^ (a)
b = b mod 4
Print a + b + c
A) 13
B) 17
C) 26
D) 16
Answer
Answer: Option A
Explanation
EXPLANATION:
There are three variables a, b and c declared. Value initialized for a is 8, b is 51 and c is 2.
When we do a bitwise exclusive OR of (8^2), the answer is 10. Again 10 bitwise exclusive OR of a i.e
(10 ^ 8) is 2, which will be stored in variable c.
Then taking modulo operation for b by 4 (b%4) the answer is 3
Finally adding all the updated values of a,b, and c (8+2+3 ) and the output of Pseudocode is 13.
Question 4
Answer
Explanation
Question 4
Consider an array A = {1, 2, 4, 5, 6, 11, 12} and a key which is equal to 10. How many comparisons
would be done to find the key element in the array using the binary search?
A) 5
B) 1
C) 2
D) 3
Answer
Answer: Option D
Explanation
EXPLANATION:
There are three variables a, b and c declared. Value initialized for a is 8, b is 51 and c is 2.
When we do a bitwise exclusive OR of (8^2), the answer is 10. Again 10 bitwise exclusive OR of a i.e.
(10 ^ 8) is 2, which will be stored in variable c.
Then taking modulo operation for b by 4 (b%4) the answer is 3.
Finally adding all the updated values of a, b, and c (8+2+3 ) and the output of Pseudocode is 13.
Question 5
Answer
Explanation
Question 5
What would be the output of the following pseudocode?
Integer i, j, k
Set k = 8
for(each i from 1 to 1)
for(each j from the value of i to 1)
print k+1
end for
end for
Answer
Answer: Option B
Explanation
EXPLANATION:
There are three variables i, j and k declared. Value initialized for k is 8, In this code, we are moving with
nested for loop.
Here i value is 1, for loop will check the condition i<=1 condition gets true. Now, moving with inner for
loop j value will be 1 condition gets true j<=1.so, it prints K+1. Then j value will be incremented by
1(2<+1) inner for loop condition gets false.
On the next iteration i value will be incremented by 1, here updated i value is 2 (2<=1) condition get
false. So the answer is 9.
Question 6
Answer
Explanation
Question 6
What will be the output of the following pseudocode?
Integer a, b
Set a = 15, b = 7
a = a mod (a – 3)
b = b mod (b – 3)
a = a mod 1
b = b mod 1
Print a + b
A) 15
B) 7
C) 2
D) 0
Answer
Answer: Option D
Explanation
EXPLANATION:
There are two variables a and b declared. Value initialized for a is 15 and b is 7. Taking mod operation for a by 12(a%12) and the answer is 3 will stored in a.
The next mod operation for b is 7 mod (7%4). The answer is 3 will be stored in b. The next line takes the updated value of a and mods it by 1(3%1). Then the answer becomes 0 will be stored in a.
Next line takes the updated value of b mod by 1 (3%1) then the answer is 0. Finally adding all the updated values of a and b (0+0 ) and the output of Pseudocode is 0.
Question 7
Answer
Explanation
Question 7
What will be the output of the following pseudocode?
Integer a, b, c
Set b = 5, a = 2, c = 2
if(b>a && a>c && c>b)
b = a + 1
Else
a = b + 1
End if
Print a + b + c
A) 2
B) 13
C) 26
D) 5
Answer
Answer: Option B
Explanation
EXPLANATION:
There are three variables a, b and c declared. Value initialized for a is 2, b is 5 and c is 2. Checking the condition using if, b >a and a>c and c>b here if conditions get false.
Now else part will be executed. b value will be incremented by 1 and stored in a.
Finally adding all the updated values of a, b and c (6+5+2 ) and the output of Pseudocode is 13.
Question 8
Answer
Explanation
Question 8
For which of the following applications can you use hashing?
1. To construct a message authentication code.
2. For Timestamping
3. For detecting a cycle in a graph
Choose the correct answer from the options given below:
A) Only 1 and 3
B) Only 2 and 3
C) Only 1
D) Only 1 and 2
Answer
Answer: Option D
Explanation
EXPLANATION:
Constructing a message authentication code and Timestamping are the real-time applications for hashing.
Question 9
Answer
Explanation
Question 9
What is the second part of a node in a linked list that contains the address of the next node called?
A) Data
B) Pointer
C) Element
D) Link
Answer
Answer: Option D
Explanation
EXPLANATION:
The field of each node that contains the address of the next node is usually called the Link.
FOLLOW US
You Missed
Also Checkout
Pages: 1 2