0% found this document useful (0 votes)
126 views5 pages

Sample Question Paper For Placement

The document contains 20 multiple choice questions related to programming concepts like functions, loops, arrays, linked lists, trees, sorting algorithms, complexity analysis etc. It also contains few questions on prime numbers and their storage in memory.

Uploaded by

tamizhanps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views5 pages

Sample Question Paper For Placement

The document contains 20 multiple choice questions related to programming concepts like functions, loops, arrays, linked lists, trees, sorting algorithms, complexity analysis etc. It also contains few questions on prime numbers and their storage in memory.

Uploaded by

tamizhanps
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

{

1. function modify(b,a)

return a - b
}
function calculate( )
{
integer a = 5, b = 12, c
c = modify(a, b);
print c
}
Assume that a and b were passed by reference. What will be the
output of the program on executing function calculate( ) ?
A: 7

Op 2: -7

Op 3: Error

Op 4: 8

2. Afzal writes a piece of code, where a set of three lines occur


around 10 times in different parts of the program. What
programming concept can he use to shorten his program code
length?
A: Use for loops Op 2: Use functions Op 3: Use arrays Op 4: Use
classes
3. What does the following function do?
function operation (int a, int b)
{
if (a > b)
{
return operation(b, a)
}
else
{
return a;
}
}
Op 1: Always returns the first parameter Op 2: Returns the min
of (a,b) Op 3: Returns the max of (a,b) Op 4: Loops forever
4. How will 47 be stored as an unsigned 8-bit binary number?
Op 1: 10111101 Op 2: 00101111 Op 3: 10111000 Op 4:
00101101
5. Tarun wants to write a code to divide two numbers. He wants to
warn the user and terminate the program if he or she enters 0

as the divisor. Which programming construct can he use to do


this?
Op 1: Iteration Op 2: Decision-making Op 3: Recursion Op 4:
None of these
6. The time complexity of linear search algorithm over an array of
n elements is
a) O(log2n)
b) O (n2) c) O(n log2n)
d) O(n)
7. Pankaj stores n data elements in a hash table. He is able to get
the best efficiency achievable by a hash table. What is the time
complexity of accessing any element from this hash table?
O(1)
b) O (n2) c) O(log2n)
d) O(n)
8. Shalini writes a program in C++ and passes it on to Pankaj.
Pankaj does some indentation in some statements of the code.
What will this lead to?
Op 1: Faster Execution Op 2: Lower memory requirement Op 3:
Correction of errors Op 4: Better readability
9. Linked lists are not suitable for
Op
1: Insertion sort Op 2: Binary search Op 3: Queue
implementation Op 4: None of these
10.
Two lists, A and B are implemented as singly linked linklists. The address of the first and last node are stored in
variables firstA and lastA for list A and firstB and lastB for list B.
Given the address of a node is given in the variable
node, the element stored in the node can be accessed by the
statement node->data
and the address to the next node can be accessed by node->next.
Pankaj wants to append list B at end of list A. Which of the following
statements should he use?
Op 1: lastB -> next = firstA
Op 2: lastA = firstB
Op 3: lastA>next = firstB Op 4: lastB = firstA
11.
A complete binary tree with 5 levels has how many nodes?
(Root is Level 1)
Op 1: 15
Op 2: 25
Op 3: 63
Op 4: 31
12.
Consider an array on which bubble sort is used. The bubble
sort would compare the element A[x] to which of the following
elements in a single iteration.
Op 1: A [x+1] Op 2: A [x+2] Op 3: A [x+2x] Op 4: All of
these.

13.
An array of 5 numbers has the following entries in order:
7 4 5 10 8. Prashant uses selection sort to sort this array in
descending order. What will the array contain after two
iterations of selection sort?
Op 1: 10 8 7 5 4
Op 2: 10 8 5 7 4
Op 3: 8 10 5 7 4
Op 4: None of these
14.
A queue is implemented as a (singly linked) linked-list for easy addition
and deletion of elements. Each node has an element and pointer to another
node. Which node will point to empty/no location?
Op 3: Both

Op 1: Front Op 2: Rear

Op 4: None of these

15.
Shalini wants to program to print the largest number out of
three inputted numbers. She writes the following program:
int number1, number 2, number3, temp;
input number1, number2, number3;
if (number1>number2)
temp = number1
else
temp = number2
end if
if (??) // Statement 1
temp = number3
end if
print temp
Fill in the ?? in Statement 1
Op 1: number3 > number2 Op 2: number3 > temp Op 3:
number3 < temp
Op 4: number3 > number1
16. A bus started from bustand at 8.00am, and after staying for 30 minutes at a destination, it
returned back to the busstand. The destination is 27 miles from the busstand. The speed of the bus
is 18mph. During the return journey bus travels with 50% faster speed.At what time does it return
to the busstand?
17. Hansie made the following amounts in seven games of cricket in India : Rs.10, Rs.15, Rs.21,
Rs.12, Rs.18, Rs.19 and Rs.17(all figures in crores of course).Find his average earnings.
18. What is the largest prime number that can be stored in an 6-bit memory?
19. What is the largest prime number that can be stored in an 7-bit memory?

20. What is the largest prime number that can be stored in an 8-bit memory?

You might also like