Sample Questions
Computer Programming
Directions: Choose the correct option.
Q1. A programmer is given an efficient code to sum two nXn matrices and store the result in a
third matrix. She is asked to find its time complexity. She realizes that the number of iterations
required is more than n. What can she claim regarding the complexity of the code?
A. It is O(n)
B. It is O(n2)
C. It is Θ(n)
D. It is ω(n)
Directions: Choose the correct option.
Q2. What is the output of the program given below?
integer i = 0, j
while (i<2)
{
j = 0;
while (j<= 3*i)
{
print j
print blank space
j=j+3
}
print end-of-line //takes the cursor to the next line
i=i+1
}
© Aspiring Minds Assessment Pvt. Ltd.
A. 0
03
B. 0 3
036
C. 0
036
0369
D. 0 3 6
0369
0 3 6 9 12
Directions: Choose the correct option.
Q3. A programmer writes a program to find an element in the array A[5] with the elements: 8
30 40 45 70. The program is run to find a number "X", that is found in the first iteration of
binary search. What is the value of "X"?
A. 40
B. 8
C. 70
D. 30
Directions: Choose the correct option.
Q4. Refer to the given pseudocode. The code is similar to that in C++ and is self-explanatory. An
accessible member function and a data member for an object are accessed by the statements
objectname.functionname and objectname.datamembername, respectively. Which statement
should be deleted from the code to rectify the error in it?
© Aspiring Minds Assessment Pvt. Ltd.
class brush
{
private:
integer size, c
rcode
function getdata( ) { ... }// Statement 1
public:
integer name // Statement 2
function putdata( ) { ... }
}
function main
{
brush b1, b2
print b1.name // Statement 3
b2.getdata( ) //Statement 4
}
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
© Aspiring Minds Assessment Pvt. Ltd.