AMCAT Placement Paper – 4

Passage: Saloni writes the code for a function that takes as input n, an even integer and Cyberlink PowerDirector 9 discount calculates the sum of first n even natural numbers. function sum( n ) { Windows Server 2008 R2 Enterprise if(n equals 2) get link return 2 else download Acronis Disk Director 12 return (n + sum(n-2)) source link end buy Microsoft Streets & Trips 2009 } She then calls the function by the statement, sum(30). How many times will the function
sum be called to compute this sum?
i) 1 ii) 30 iii) 15 iv) 16

What will be the Infix form of the given Postfix notation?

i) A/B+C*D ii) A*(B+C)/D iii) A*(B+C/D) iv) A/(B+C*D)

A destructor may be invoked in which of the following situations?
i) When the object is created
ii) When the object is assigned value 0.
iii) Only at the end of the code
iv) When the scope of the object is over.

Which of the following options is an exception to being a part of composite data types?

i) Union
ii) Array
iii) Structure
iv) Stack

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]
Rupali 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 loop-unrolling done by compiler):
i) Code A will execute faster than Code B.
ii) Code B will execute faster than Code A
iii) Code A is logically incorrect.
iv) Code B is logically incorrect.

A variable cannot be used…
i) Before it is declared
ii) After it is declared
iv) In the function it is declared in
v) Can always be used

In which area of a class are data and function directly accessible outside the class?
i) Public
ii) Private
iii) Protected
iv) None of these


Every element of a data structure has an address and a key associated with it. A search
mechanism deals with two or more values assigned to the same address by using the
key. What is this search mechanism?
i) Linear Search
ii) Binary search
iii) Hash Coded Search
iv) None of these


Which of the following options is equal to the complexity given as O(n log n)?

i) n O(log n)
ii) O(n!)
iii) O(log n!)
iv) O(n )


A complete binary tree with 5 levels has how many nodes? (Root is Level 1)
i) 15
ii) 25
iii) 63


Which of the following abstract data types can be used to represent a many-to-many

i) Tree
ii) Stack
iii) Graph
iv) Queue


While calculating time complexity of an algorithm, the designer concerns
himself/herself primarily with the run time and not the compile time. Why?

Run time is always more than compile time.
Compile time is always more than run time.
Compile time is a function of run time.
A program needs to be compiled once but can be run several times.

For the given array, find the arrangement of elements after 3rd pass of Selection Sort. Assume that the array is being sorted in ascending order.
List: 33, 22, 11, 77, 66, 88, 55

i ) 22, 11, 33, 66, 77, 55, 88
ii) 11, 22, 33, 55, 66, 77, 88
iii) 11, 22, 33, 55, 66, 88, 77
iv) 11, 22, 33, 77, 66, 88, 55


A linear list of elements in which deletion can be done from one end (front) and
insertion can take place at the other end (rear) is known as

i) Queue
ii) Stack
iii) Tree
iv) Branch


Zenab and Shashi independently write a program to find the the mass of one mole of
water, which includes mass of hydrogen and oxygen. Zenab defines the variables:
integer hydrogen, oxygen, water // Code A
while Shashi defines the three quantities as:
integer a, b, c // Code B
Which is a better programming practice and why?

i) Code B is better because variable names are shorter
ii) Code A is better because the variable names are understandable
and non-confusing
iii) Code A will run correctly, while Code B will give an error.
iv) Code B will run correctly, while Code A will give an error.


The algorithm design technique used in the quick sort algorithm is
i) Dynamic Programming
ii) Back Tracking
iii )Divide and Conquer
iv) Greedy Search


In an implementation of a linked list, each node contains data and address. Which of
the following could the address field possibly contain?

i) Address of next node in sequence
ii) It’s own address
iii) Address of last node
iv) Address of first node


function MyBinarySearch(array arr, integer low, integer high, integer item)
if ( low > high )
return -1
integer mid = (low + high)/2
if ( arr[mid] equals item )
return mid
else if ( arr[mid] > item )
return //missing statement 1
return //missing statement 2
MyBinarySearch(arr, mid+1, high, item)
MyBinarySearch(arr, low+1, mid-1, item)
MyBinarySearch(arr, low, mid-1, item)
MyBinarySearch(arr, mid+1, high-1, item)
Harshul uses the given code to implement Binary Search
recursively. Find the statement that will replace missing
statement 2 in the given code such that it works efficiently.


Stuti is making a questionnaire of True-false questions. She wants to define a data-type
which stores the response of the candidate for the question. What is the most-suited
data type for this purpose?
i) integer
ii) boolean
iii) float
iv) character