# AMCAT Placment Paper 3

50) Akshit has a large list of fixed length numbers. He needs to sort this list using an efficient technique. Which of the following techniques can he use?
(a)Selection Sort (b)Radix Sort (c)Shell Sort (d)Quick Sort

Ans. D

51) A characteristic of data that binary search uses but linear search ignores is ANS:(A)
(a)order of the list (b)length of the list (c)maximum value of the list (d)None of these

Ans. A

52) Passage: integer MyVar1=5 function main()
{
integer MyVar1=9 print MyVar1
print //missing code
}
Assuming that main() is the starting point of execution of program, which of the following options should replace the
//missing code so as to print the value of global MyVar1 (value = ANS:(C) 5)?
(a)MyVar1.MyVar1 (b)MyVar1[0] (c) ::MyVar1 (d)No local variable should have the same name as the global variable

53) Which of the following options refers to the best case complexity of a Binary Search algorithm while searching a list of n elements?
(a) O(n*n) (b) O(log n) (c) O(n) (d)O (1)

Ans. D
54) Passage:
function Fibonacci(num)
1.if ( num equals 0 )
2.then return 1
3.else if ( n equals 1 )
4.then return 1
5.else return Fibonacci(n-1) + Fibonacci(n-2)
Maya wrote the given algorithm to calculate Fibonacci series.
What is the complexity of this algorithm?
(a) O(n ) (b) O(n ) (c) O(n) (d) O(2^n )

Ans. D O(2^n)

55) CPoansssiadgeer :the following pseudo-code class entity
{
private: integer a, b public: integer c
function entity( ) { a = 0; b=0} function compare ( )
{ if (a>b) return 1; return 0
}
}
function main ( )
{
entity black
int value, value2 = 5
value = black.compare( ) // Statement 1 black.c = value2 //Statement 2
print black.a //Statement 3
}
Choose the correct answer. A pseudo-code which is similar to that of C++ and self-explanatory. An accessible member function or data member for an object are accessed by the statement objectname.functionname or objectname.datamembername respectively.
(a)Statement 1 (b)Statement 2 (c)Statement 3 (d)None of these

56) What will be the input to the second pass, if the list before starting the Radix Sort is: 729, 150, 123, 931, 348, 517?
(a)150, 123, 348, 517, 729, 931 (b)150, 931, 123, 517, 348, 729 (c)517, 729, 123, 931, 348, 150 (d)123, 150, 348, 517, 729, 931

Ans.B

56) In the following sorting procedures, which one will be the slowest for any given array? (a)Quick sort (b)Heap sort (c)Merge Sort (d)Bubble sort

Ans. D

47) What is the term given to the memory allocation that takes place during run time rendering the resizing of an Array?
(a)Static Allocation (b)Dynamic Allocation (c)Automatic Allocation (d)Executive Allocation

Ans. B

48) Ritika was asked to include concrete objects in her project. Which of the following statements clearly states about the concrete objects?
(a)All the objects created as the instance of a class
(b)Objects created using the new keyword
(c)Variables and objects that follow the concrete keyword
(d)Objects created under conditional statements

Ans.A

49) What are the maximum number of edges in a n-vertex undirected graph?
(a) n*(n-1)/2 (b) n*(n+1)/2 (c) n*n (d) 2*n

Ans.A

40) Passage:
Srujan writes a sorting algorithm. The algorithm takes different amount of time to sort two different lists of equal size. What is the possible difference between the two lists?
(a) All numbers in one list are more than 100, while in the other are less than 100.
(b)The ordering of numbers with respect to magnitude in the two list has different properties.
(c)One list has all negative numbers, while the other has all positive numbers.
(d)One list contains 0 as an element, while the other does not

Ans. B

41) Passage:
function Display( string MyStr ) //Statement 1
{
print "Hello My name is" print MyStr //Statement 2
}
function main() // Statement 3
{
string str = " Mr.Beans"
integer num = Display( str ) // Statement 4
}
Consider the given code to print a name on the screen. Which statement will generate an error?
(a)Statement 1 (b)Statement 2 (c)Statement 3 (d)Statement 4 (e)This code will run without any error

Ans. D

36) In a ______________ , there is no beginning and no end.
(a) Queue (b) Deque (c) Doubly Linked List (d) Circular Linked List

Ans. D

35) Passage:
Consider a binary tree implementation. The root address is stored in the variable root. Given the address of a node in variable node, its value, right and root child node address can be accessed using the following statements respectively: node-> value, node -> right, node-> left. Srikanth writes the following function to do a preorder traversal of the tree.
function preordertraverse(node)
{
print node -> value if (Condition X)
{preordertraverse(node->left) } if (Condition Y)
{preordertraverse(node->right) } return
}
What is condition X and Condition Y?
(a)Condition X: node -> left isnotequal null Condition Y: node -> right isnotequal null
(b)Condition X: node -> right isnotequal null Condition Y: node -> left isnotequal null
(c)Condition X: node -> left isequal null
Condition Y: node -> right isequal null
(d) Condition X: node -> right isequal null Condition Y: node -> left isequal null

Ans.A

26) Which of the following sorting techniques has the worst case functioning time less than O(n*n)?
(a)Heap Sort (b)Quick Sort (c)Insertion Sort (d)Selection Sort

Ans.A

25) There is a class which contains two integers as private members. There are two member functions (public) defined on it, one to add the two integers and another to subtract the two integers. Ravi wants to add a new functionality, which enables multiplication of the two numbers. Which one of the following options he should adopt?
(a)He should define a third member function (public) which multiplies the two numbers.
(b)He should define member functions (public) to return value of both the integers and then multiply them in his code. By returning the values, he can in future do any operation on them giving extensibility to the code.
(c)He should define a third member function (private) which multiplies the two numbers.
(d)He should define member functions (private) to return value of both the integers and then multiply them in his code. By returning the values, he can in future do any operation on them giving extensibility to the code.

Ans.B

20) What is the minimum number of division checks required to check whether a number is prime or not?
(a) (number-1) divisions (b) (number) divisions (c) (integer(number/2)-1) divisions
(d) sqrt(number) divisions

Ans.D

21) Suppose that a graph is represented as adjacency matrix and a BFS(Breadth First search) algorithm is modified to handle such input graphs. Which of the following options refers to the running time of such an algorithm given that the number of vertices in the graph is V and number of edges is E?
(a) O(V*V) (b)O(V*V+E) (c)O(E*E+V) (d)O(E*E)

Ans.A

22) Parthiv has included several classes and their objects in his project. Now he wants to use something that will hold all these objects(of different classes). Which of the following options provides him with the best alternate?
(a)Store them in database (b)Final Class (c)Generic Class (d)Anonymous Class

Ans.C

Which of the following options is true with regard to private and protected members of a class?
(a)Both have the same properties with regard to an object of the class.
(b)Private members cannot be directly accessed, while protected members can be directly accessed.
(c)Protected members cannot be accessed by member functions, while
private members can be accessed by member functions.
(d) Private and protected members are same in all regards

Ans.A

Mary is making a database of animals in a zoo and their properties. The possible
animals are dog, lion and zebra. Each one has as attributes isHerbivorous, colour and
isNocturnal. She uses the object oriented programming paradigm for this. How will she
conceptualize the system?
(a) class: Animal; objects: dog, lion and zebra; data members: is Herbivorous, colour and is
Nocturnal
(b)class: Animal; objects: is Herbivorous, colour and is Nocturnal; data
members: dog, lion and zebra
(c)classes: dog, lion and zebra; objects: Animal; data members: is Herbivorous, colour and is
Nocturnal
d)None of these

Ans a)class: Animal; objects: dog, lion and zebra; data members: is Herbivorous, colour and is
Nocturnal
class is a template(logical entity) , objects are instances of class(real entity).