Placement Written test paper for MNC  Computer questions and answers Part – 2
Ques 33 : Choose the correct answer  
Rohit writes the following program which inputs a number and prints “Double digit” if the number is composed of two digits and “Not a double digit” if it is not. int number; if (number>10 AND number < 100) print “Double digit” else print “Not a double digit” end if Rohit tries the following inputs: 5 and 66. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn’t work correctly. What did Ravi enter? 

Option 1 : 8  Option 2 : 100  Option 3 : 99  Option 4 : 10  


Ques 34 : Choose the correct answer 

Rohan writes the following program which inputs a number and prints “Triple digit” if the number is composed of three digits and “Not triple digit” if it is not. int number; if (number>99) print “Triple digit” else print “Not triple digit” end if Rohan tries the following inputs: 25 and 566. The program works fine. He asks his brother Ravi to try the program. When Ravi enters a number, the program doesn’t work correctly. What did Ravi enter? 

Option 1 : 99  Option 2 : 100  Option 3 : 0  Option 4 : 1000  


Ques 35 : Choose the correct answer 

Abhinav wants to find the largest number in a given list of 20 numbers. Which of the following is an efficient approach to do this?  
Option 1 : Use bubble sort to sort the list in descending order and then print the first number of the series.  Option 2 : Use selection sort to sort the list in descending order and then print the first number of the series.  Option 3 : Implement one iteration of selection sort for descending order and print the first number in the series.  Option 4 : None of these  


Ques 36 : Choose the correct answer  
Lavanya wants to find the smallest number out of 26 inputted numbers. How many minimum comparisons he has to make?  
Option 1 : 25  Option 2 : 13  Option 3 : 26  Option 4 : 52  


Ques 37 : Choose the correct answer 

A company offers commission for selling it products to its salesperson. The commission rate is Rs. 5 per product. However if the salesperson sells more than 200 items, he gets a commission of Rs. 10 on all items he sold after the first 200. Kanu writes a program to calculate the commission for the salesperson: integer numberProducts, commission input numberProducts if ( numberProducts > 200 ) — MISSING STATEMENT — else commission = numberProducts * 5 end if print commission Fill in the missing statement. 

Option 1 : commission = (numberProducts – 200) * 10  Option 2 : commission = 200 * 5 + (numberProducts – 200) * 10  Option 3 : commission = numberProducts * 10  Option 4 : None of these  


Ques 38 : Choose the correct answer  
Vikram wants to write a program which checks whether the inputted number is divisible by any of the first 6 natural numbers (excluding 1). He writes the following efficient code for it. int number, n = 2, isdivisible=0 Vikram takes the program to Hari. Hari tells Vikram that though the code is correct, it can be made more efficient. Hari modifies a single statement and makes the code more efficient. Which statement does he modify and how? 

Option 1 : Statement 1 is changed to: while (n <=6 AND isdivisible=0) 
Option 2 : Statement 1 is changed to: while (n <=6 OR isdivisible=0) 
Option 3 : Statement 1 is changed to: while (isdivisible=0) 
Option 4 : Statement 2 is changed to: n = n + 2 



Ques 39 : Choose the correct answer 

Rajiv wants to make a program which inputs two numbers: a and b (a>b) and computes the number of terms between a and b (including a and b). What will be code statement to do this:  
Option 1 : a – b  Option 2 : a – b + 1  Option 3 : a + b  Option 4 : a – b – 1  


Ques 40 : Choose the correct answer  
I have a problem to solve which takes as input a number n. The problem has a property that given the solution for (n1), I can easily solve the problem for n. Which programming technique will I use to solve such a problem?  
Option 1 : Iteration  Option 2 : Decisionmaking  Option 3 : Object Oriented Programming  Option 4 : Recursion  


Ques 41 : Choose the correct answer: A pseudocode is used with the following meaning. “pointer” is a datatype which contains memory address (or pointers) Statement “a = *b” puts the value at the memory address referenced by b into a. Statement “a = &b” puts the memory address of b into a. Statement “*b = a” puts the value a at the memory address referenced by b. 

What is the output of the following code statements? The compiler saves the first integer at the memory location 4062. Integer is one byte long.
integer a 

Option 1 : 4062  Option 2 : 4063  Option 3 : 20  Option 4 : 10  


Ques 42 : Choose the correct answer: A pseudocode is used with the following meaning. “pointer” is a datatype which contains memory address (or pointers) Statement “a = *b” puts the value at the memory address referenced by b into a. Statement “a = &b” puts the memory address of b into a. Statement “*b = a” puts the value a at the memory address referenced by b. 

What is the output of the following code statements? The compiler saves the first integer at the memory location 4165 and the rest at consecutive memory spaces in order of declaration. Integer is one byte long. integer a, b 

Option 1 : 30  Option 2 : 4165  Option 3 : 40  Option 4 : 4166  


Ques 43 : Choose the correct answer: 

What is the output of the following code statements? The compiler saves the first integer at the memory location 4165 and the rest at consecutive memory spaces in order of declaration. Integer is one byte long. integer a 

Option 1 : 30  Option 2 : 4165  Option 3 : 40  Option 4 : 4166  


Ques 44 : Choose the correct answer 

What is space complexity of a program?  
Option 1 : Amount of harddisk space required to store the program  Option 2 : Amount of harddisk space required to compile the program  Option 3 : Amount of memory required by the program to run  Option 4 : Amount of memory required for the program to compile  


Ques 45 : Choose the correct answer 

The memory space needed by an algorithm has a fixed part independent of the problem instance solved and a variable part which changes according to the problem instance solved. In general, which of these two is of prime concern to an algorithm designer?  
Option 1 : Fixed part  Option 2 : Variable Part  Option 3 : Product of fixed part and variable part  Option 4 : None of these  


Ques 46 : Choose the correct answer 

While calculating time complexity of an algorithm, the designer concerns himself/herself primarily with the run time and not the compile time. Why?  
Option 1 : Run time is always more than compile time.  Option 2 : Compile time is always more than run time.  Option 3 : Compile time is a function of run time.  Option 4 : A program needs to be compiled once but can be run several times.  


Ques 47 : Choose the correct answer 

Pankaj and Mythili were both asked to write the code to evaluate the following expression: a – b + c/(ab) + (ab)^{2} Pankaj writes the following code statements (Code A): print (ab) + c/(ab) + (ab)*(ab) Mythili writes the following code statements (Code B): d = (ab) print d + c/d + d*d If the time taken to load a value in a variable, for addition, multiplication or division between two operands is same, which of the following is true? 

Option 1 : Code A uses lesser memory and is slower than Code B  Option 2 : Code A uses lesser memory and is faster than Code B  Option 3 : Code A uses more memory and is faster than Code B  Option 4 : Code A uses more memory and is slower than Code B  


Ques 48 : Choose the correct answer 

Vrinda writes an efficient program to sum two square diagonal matrices (matrices with elements only on diagonal). The size of each matrix is nXn. What is the time complexity of Vrinda’s algorithm?  
Option 1 : θ(n^2)  Option 2 : θ(n)  Option 3 : θ(n*log(n))  Option 4 : None of these  


Ques 49 : Choose the correct answer 

Tarang writes an efficient program to add two upper triangular 10X10 matrices (elements on diagonal retained). How many total additions will his program make?  
Option 1 : 100  Option 2 : 55  Option 3 : 25  Option 4 : 10  


Ques 50 : Choose the correct answer 

Ravi and Rupali are asked to write a program to sum the rows of a 2X2 matrices stored in the array A. Ravi writes the following code (Code A): for n = 0 to 1 sumRow1[n] = A[n][1] + A[n][2] endRupali writes the following code (Code B): sumRow1[0] = A[0][1] + A[0][2] sumRow1[1] = A[1][1] + A[1][2]Comment upon these codes (Assume no loopunrolling done by compiler): 

Option 1 : Code A will execute faster than Code B.  Option 2 : Code B will execute faster than Code A  Option 3 : Code A is logically incorrect.  Option 4 : Code B is logically incorrect.  


Ques 51 : Choose the correct answer 

There is an array of size n initialized with 0. Akanksha has to write a code which inserts the value 3^{k} at position 3^{k} in the array, where k=0,1…(till possible). Akanksha writes an efficient code to do so. What is the time complexity of her code?  
Option 1 : θ(n^2)  Option 2 : θ(n)  Option 3 : θ(log_{3}(n))  Option 4 : θ(3^{n})  


Ques 52 : Choose the correct answer 

There are two matrices A and B of size nXn. The data in both these matrices resides only at positions where both the indices are a perfect square. Rest all positions have 0 as the data. Manuj has available a third matrix initialized with 0’s at all positions. He writes an efficient code to put the sum of A and B in C. What is the time complexity of Manuj’s program?  
Option 1 : θ(n^2)  Option 2 : θ(n)  Option 3 : θ(n^{1/2})  Option 4 : θ(log(n))  


Ques 53 : Choose the correct answer 

Ravi has to add an strictly upper triangular (no elements at diagonal) and a strictly lower triangular square matrix (no elements at diagonal) and put the result in a third matrix. What is the time complexity of Ravi’s algorithm? Assume that storing a value in a memory space takes negligible time, while each addition between values takes the dominating amount of time.  
Option 1 : θ(n^2)  Option 2 : θ(n)  Option 3 : θ(1)  Option 4 : None of these  


Ques 54 : Choose the correct answer 

We have two 100X3 (rowsXcolumn) matrices containing midterm exam marks and endterm exam marks of 100 students. Each row refers to a particular student, while columns refer to marks in English, Social Sciences and Maths. The endterm and midterm marks of each student in each subject have to be added to get his total score in each subject, to be put in a third matrix (100X3). Parinidhi writes a code (Code A), where the outer loop iterates over the rows, while the inner loop iterates over the columns. Shashi writes a code (Code B), where the outer loop iterates over the columns, while the inner loop iterates over rows. Which of the following is true with regard to their code ignoring any caching or memory storage effects?  
Option 1 : Code A is faster than Code B  Option 2 : Code B is faster than Code A  Option 3 : Code A and Code B will run in the same amount of time  Option 4 : The comparison between the speed of the codes cannot be made.  


Ques 55 : Choose the correct answer 

A code takes the following code steps (equivalently time unit) to execute: 5*n^{3} + 6*n^{2} + 1. Which of the following is not true about the time complexity of the program?  
Option 1 : It has a time complexity of O(n^{3})  Option 2 : It has a time complexity of O(n^{4})  Option 3 : It has a time complexity of O(n^{2})  Option 4 : It has a time complexity of θ(n^{3})  


Ques 56 : Choose the correct answer 

We have two programs. We know that the first has a time complexity O(n^{2}), while the second has a complexity ω(n^{2}). For sufficiently large n, which of the following cannot be true?  
Option 1 : Both codes have same complexity  Option 2 : The first code has higher time complexity than the second  Option 3 : The second code has lower time complexity than the first code.  Option 4 : Both codes are the same.  


Ques 57 : Choose the correct answer 

The time complexity of code A is θ(n), while for Code B it is θ(log(n)). Which of the following is true for sufficiently large n?  
Option 1 : Both code have the same time complexity  Option 2 : Code A has higher time complexity  Option 3 : Code B has higher time complexity  Option 4 : No comparison can be made between the time complexity of the two codes.  


Ques 58 : Choose the correct answer 

Rajini is given an efficient code for summing two nXn matrices and putting the result in a third matrix. She is asked to find it’s time complexity. She realizes that the number of iterations required is more than n. What can she claim with regard to the complexity of the code?  
Option 1 : It is O(n)  Option 2 : It is O(n^{2})  Option 3 : It is θ(n)  Option 4 : It is ω(n)  


Ques 59 : Choose the correct answer 

Gautam is given two codes, A and B, to solve a problem, which have complexity θ(n) and θ(n^{2}) respectively. His client wants to solve a problem of size k, which Gautam does not know. Which code will Gautam deliver to the client, so that the execution is faster?  
Option 1 : Code A  Option 2 : Code B  Option 3 : Gautam cannot determine  Option 4 : Both codes have the same execution time, so deliver any.  


Ques 60 : Choose the correct answer 

Surbhi is given two codes, A and B, to solve a problem, which have complexity O(n^{3}) and ω(n^{4}) respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code will Surbhi deliver to the client, so that the execution is faster?  
Option 1 : Code A  Option 2 : Code B  Option 3 : Surbhi cannot determine  Option 4 : Both codes have the same execution time, so deliver any. 