Q: 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()Solution: 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
Q: What will be the output of the following pseudo-code? Integer x, y, z Set x=24, y=8 x = x/y z = y<
Solution: 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.
Q: 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
Solution: 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.
Q: What will be the output of the following pseudocode? Integer a=5, b=4, c=3 a = b + c c = a – b c = c + a c = b + c b = b + c Print a, b, c
Solution: 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, 14Q: 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 cSolution: 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
Q: Which of the following operations is possible on an array?
Solution: It is trickier when it comes to arrays to do the operation in comparison with the linked lists. But they are definitely possible
Q: 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.
Solution: 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.
Q: What do we call the binary tree nodes with no successor?
Solution: The official terminology is Terminal node or leaf node;
Q: What do we call the highest element of an array’s index?
Solution: The upper bound is always the highest element of an array index.
Q: Which of the following data types represents many to many relations?
Solution: 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.
| You Have Score    | /10 |