Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
5K views

AMCAT Computer Programming1 - Part2

This document contains 97 multiple choice questions about programming concepts such as functions, loops, conditional statements, and parameter passing. Each question has 5 possible answers and identifies the correct answer. The questions cover a wide range of topics including function definitions and calls, conditional logic, loops, and parameter passing modes.

Uploaded by

tanuj kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
5K views

AMCAT Computer Programming1 - Part2

This document contains 97 multiple choice questions about programming concepts such as functions, loops, conditional statements, and parameter passing. Each question has 5 possible answers and identifies the correct answer. The questions cover a wide range of topics including function definitions and calls, conditional logic, loops, and parameter passing modes.

Uploaded by

tanuj kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

 

  41 

Op 2: 13 -8 
Op 3: 12 8 
Op 4: 13 8 
Op 5: 
Correct Op : 2 
 
Ques79. 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? 
Op 1: Use for loops 
Op 2: Use functions 
Op 3: Use arrays 
Op 4: Use classes 
Op 5: 
Correct Op : 2 
 
Ques80. Geetika writes a piece of code, where a set of eight lines occur around 10  
times in different parts of the program (Code A). She passes on the code to Deva. 
Deva puts the set of eight lines in a function definition and calls them at the 10 
points in the program (Code B). Which code will run faster using an interpreter? 
Op 1: Code A 
Op 2: Code B 
Op 3: Code A and Code B will run with the same speed 
Op 4: None of these 
Op 5: 
Correct Op : 1 
 
Ques81. Consider the following code: 
function modify(a,b) 

integer c, d = 2 
c = a*d + b 
return c 

function calculate( ) 

integer a = 5, b = 20, c 
integer d = 10 
c = modify(a, b); 
c = c + d 
print c 

 

  42 

Assume that a and b were passed by value. What will be the output of the function 
calculate( ) ? 
Op 1: 80 
Op 2: 40 
Op 3: 32 
Op 4: 72 
Op 5: 
Correct Op : 2 
 
Ques82. Consider the following code: 
function modify(w,u) 

w = w + 2 
u = u - 3 
return (w - u) 

function calculate( ) 

integer a = 10, b = 20, c 
c = modify(a, b); 
print a 
print space 
print b 

Assume that a was passed by value and b was passed by reference. What will be the 
output of the program on executing function calculate( ) ? 
Op 1: 12 17 
Op 2: 10 17 
Op 3: 12 20 
Op 4: 10 20 
Op 5: 
Correct Op : 2 
 
Ques83. Consider the following function: 
function run( ) 

integer a = 0 // Statement 1 
while (a < 5) 

 integer c = 0 // Statement 2 
 c = c + 1 // Statement 3 
 a = a + 1 
 

  43 


print c // Statement 4 

At which statement in this program will the compiler detect an error? 
Op 1: Statement 1 
Op 2: Statement 2 
Op 3: Statement 3 
Op 4: Statement 4 
Op 5: 
Correct Op : 4 
 
Ques85. Which one of the following is the lowest level format to which the computer 
converts a higher language program before execution? 
Op 1: English code 
Op 2: Machine Code 
Op 3: Assembly Language 
Op 4: System Language 
Op 5: 
Correct Op : 2 
 
Ques86. If you want to write a function that swaps the values of two variables, you 
must pass them by: 
Op 1: Value only 
Op 2: Reference only 
Op 3: Either A or B 
Op 4: Neither A nor B 
Op 5: 
Correct Op : 2 
 
Ques87. Consider the following code: 
if (condition 1) { 
if (condition 2) 
{ // Statement A } 
else 
 if (condition 3) 
 { // Statement B } 
 else 
 { // Statement C } 
else 
if (condition 4) 
{ // Statement D } 
else 
 

  44 

{ // Statement E} 

Which of the following conditions will allow execution of statement C? 
Op 1: condition1 AND condition3 
Op 2: condition1 AND condition4 AND !condition2 
Op 3: NOT(condition2) AND NOT(condition3) 
Op 4: condition1 AND NOT(condition2) AND NOT(condition3) 
Op 5: 
Correct Op : 4 
 
Ques88. Consider the following code: 
if (condition 1) { 
if (condition 2) 
{ // Statement A } 
else 
 if (condition 3) 
 { // Statement B} 
 else 
 {// Statement C } 
else 
if (condition 4) 
{// Statement D} 
else 
{// Statement E} 

Which of the following conditions will allow execution of statement E? 
Op 1: condition1 AND condition3 
Op 2: NOT(condition1) AND condition2 AND NOT(condition4) 
Op 3: NOT(condition2) AND NOT(condition3) 
Op 4: condition1 AND condition4 AND NOT(condition2) AND NOT(condition3) 
Op 5: 
Correct Op : 2 
 
Ques89. Consider the following code: 
if (condition 1) { 
if (condition 2) 
{ // Statement A } 
else 
 if (condition 3) 
 { // Statement B} 
 else 
 {// Statement C } 
 

  45 

else 
if (condition 4) 
{// Statement D} 
else 
{// Statement E} 

Which of the following condition will allow execution of statement A? 
Op 1: NOT(condition2) AND NOT(condition3) 
Op 2: condition1 AND condition4 AND NOT(condition2) AND NOT(condition3) 
Op 3: condition1 AND condition2 AND condition4 
Op 4: NOT(condition1) AND condition2 AND NOT(condition4) 
Op 5: 
Correct Op : 3 
 
Ques90. What does the following function do? 
function operation (int a, int b) 

if (a < b) 
{ return operation(b, a) } 
else 
{ return a } 

Op 1: Returns the max of (a,b) 
Op 2: Returns the min of (a,b) 
Op 3: Loops forever 
Op 4: Always returns the second parameter 
Op 5: 
Correct Op : 1 
 
Ques91. 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 
Op 5: 
 

  46 

Correct Op : 2 
 
Ques92. function g(int n) 

if (n > 0) return 1; 
else return -1; 

function f(int a, int b) 

if (a > b) return g(b-a); 
if (a < b) return g(a-b); 
return 0; 

If f(a,b) is called, what is returned? 
Op 1: Always -1 
Op 2: 1 if a > b, -1 if a < b, 0 otherwise 
Op 3: -1 if a > b, 1 if a < b, 0 otherwise 
Op 4: 0 if a equals b, -1 otherwise 
Op 5: 
Correct Op : 4 
 
Ques93. function g(int n) 

if (n > 0) return 1; 
else return -1; 

function f(int a, int b) 

if (a > b) return g(a-b); 
if (a < b) return g(b-a); 
return 0; 

If f(a,b) is called, what is returned? 
Op 1: 1 if a > b, -1 if a < b, 0 otherwise 
Op 2: Always +1 
Op 3: 0 if a equals b, +1 otherwise 
Op 4: -1 if a > b, 1 if a < b, 0 otherwise 
Op 5: 
Correct Op : 3 
 
Ques94. function g(int n) 

 

  47 

if (n > 0) return 1; 
else return -1; 

function f(int a, int b) 

if (a > b) return g(a-b); 
if (a < b) return g(-b+a); 
return 0; 

If f(a,b) is called, what is returned? 
Op 1: Always +1 
Op 2: 1 if a > b, -1 if a < b, 0 otherwise 
Op 3: -1 if a > b, 1 if a < b, 0 otherwise 
Op 4: 0 if a equals b, -1 otherwise 
Op 5: 
Correct Op : 2 
 
Ques95. function g(int n) 

if (n > 0) return 1; 
else return -1; 

function f(int a, int b) 

if (a > b) return g(b-a); 
if (a < b) return g(-a+b); 
return 0; 

If f(a,b) is called, what is returned? 
Op 1: Always +1 
Op 2: -1 if a > b, 1 if a < b, 0 otherwise 
Op 3: 1 if a > b, -1 if a < b, 0 otherwise 
Op 4: 0 if a equals b, -1 otherwise 
Op 5: 
Correct Op : 2 
 
Ques96. Consider the following code: 
for i= m to n increment 2 
{ print "Hello!" } 
Assuming m < n and exactly one of (m,n) is even, how many times will Hello be 
printed? 
Op 1: (n - m + 1)/2 
 

  48 

Op 2: 1 + (n - m)/2 
Op 3: 1 + (n - m)/2 if m is even, (n - m + 1)/2 if m is odd 
Op 4: (n - m + 1)/2 if m is even, 1 + (n - m)/2 if m is odd 
Op 5: 
Correct Op : 1 
 
Ques97. Consider the following code: 
for i= m to n increment 2 
{ print "Hello!" } 
Assuming m < n and (m,n) are either both even or both odd, How many times will 
Hello be printed? 
Op 1: (n - m + 1)/2 
Op 2: 1 + (n - m)/2 
Op 3: 1 + (n - m)/2 if m is even, (n - m + 1)/2 if m is odd 
Op 4: (n - m + 1)/2 if m is even, 1 + (n - m)/2 if m is odd 
Op 5: 
Correct Op : 2 
 
Ques98. Assuming n > 2, What value does the following function compute for odd n? 
function f (int n) 

if (n equals 1) { return 1 } 
if (n equals 2) { return f(n-1) + n/2 } 
return f(n-2) + n; 

Op 1: 1 + 2 + 3 + 4 + ... + n 
Op 2: 1 + 3 + 5 + 7 + ... + n 
Op 3: n/2 + (1 + 3 + 5 + 7 + ... + n) 
Op 4: 1 + (1 + 3 + 5 + 7 + ... + n) 
Op 5: 
Correct Op : 2 
 
Ques99. Assuming n > 2, What value does the following function compute for even n? 
int f (int n) 

if (n equals 1) { return 1 } 
if (n equals 2) { return f(n-1) + n/2 } 
return f(n-2) + n 

Op 1: 1 + 2 + 3 + 4 + ... + n 
Op 2: 1 + (2 + 4 + 6 + 8 + ... + n) 
Op 3: 1 + n/2 + (4 + 6 + 8 + ... + n) 
 

  49 

Op 4: 2 + 4 + 6 + 8 + ... + n 
Op 5: 
Correct Op : 4 
 
Ques100. The for loop is equivalent to a while loop when 
Op 1: There is no initialization expression 
Op 2: There is no increment expression 
Op 3: A and B combined are true 
Op 4: It is never equivalent 
Op 5: 
Correct Op : 3 
 
Ques101. Consider the statement 
while (a < 10.0) { a = a*a } 
Assuming a is positive, for what value of a will this code statement result in an 
infinite loop? 
Op 1: a < 1.0 
Op 2: a < sqrt(10) 
Op 3: a > sqrt(10) 
Op 4: a = 0 
Op 5: 
Correct Op : 1 
 
Ques102. int area(double radius) 

return PI*radius*radius; 

Which of the following is always true about the function area? 
Op 1: It returns the area of a circle within the limits of double precision. 
Op 2: It returns the area of a circle within the limits of the constant PI. 
Op 3: It returns the area of a circle within the limits of precision of double, or the 
constant PI, whichever is lower. 
Op 4: None of the above. 
Op 5: 
Correct Op : 4 
 
Ques103. What does this function compute for positive n? 
function f(int n) 

if (n equals 1) 
{ return 1 } 
else 
 

  50 

{ return f(n-1)/f(n-1) + n } 

Op 1: 1 + n 
Op 2: 1 + 2 + 3 + ... + n 
Op 3: 1 + n, if n > 1, 1 otherwise 
Op 4: None of the above 
Op 5: 
Correct Op : 3 
 
Ques104. Which of these is not a data type? 
Op 1: integer 
Op 2: character 
Op 3: boolean 
Op 4: array 
Op 5: 
Correct Op : 4 
 
Ques105. The construct "if (condition) then A else B" is for which of the following 
purposes? 
Op 1: Decision-Making 
Op 2: Iteration 
Op 3: Recursion 
Op 4: Object Oriented Programming 
Op 5: 
Correct Op : 1 
 
Ques106. In a sequential programming language, code statements are executed in which 
order? 
Op 1: All are executed simultaneously 
Op 2: From top to bottom 
Op 3: From bottom to top 
Op 4: None of these 
Op 5: 
Correct Op : 2 
 
Ques107. A for-loop is used for which of the following purposes? 
Op 1: Decision-Making 
Op 2: Iteration 
Op 3: Recursion 
Op 4: None of these 
Op 5: 
Correct Op : 2 
 

  51 

 
Ques108. There are two loops which are nested. This implies which one of the following? 
Op 1: Two loop, one after the other 
Op 2: Two loops, one inside the others 
Op 3: One loop with two different iteration counts 
Op 4: Two loops with the same iteration count 
Op 5: 
Correct Op : 2 
 
Ques109. How will 47 be stored as an unsigned 8-bit binary number? 
Op 1: 10111101 
Op 2: 00101111 
Op 3: 10111000 
Op 4: 00101101 
Op 5: 
Correct Op : 2 
 
Ques110. An integer X is saved as an unsigned 8-bit number, 00001011.What is X? 
Op 1: 22 
Op 2: 11 
Op 3: 10 
Op 4: None of these 
Op 5: 
Correct Op : 2 
 
Ques111. A variable cannot be used… 
Op 1: Before it is declared 
Op 2: After it is declared 
Op 3: In the function it is declared in 
Op 4: Can always be used 
Op 5: 
Correct Op : 1 
 
Ques112. What is implied by the argument of a function? 
Op 1: The variables passed to it when it is called 
Op 2: The value it returns on execution 
Op 3: The execution code inside it 
Op 4: Its return type 
Op 5: 
Correct Op : 1 
 
Ques113. Which of the following is true about comments? 
 

  52 

Op 1: They are executed only once. 
Op 2: They are not executed 
Op 3: A good program does not contain them 
Op 4: They increase program execution time. 
Op 5: 
Correct Op : 2 
 
Ques114. Neelam wants to share her code with a colleague, who may modify it. Thus 
she wants to include the date of the program creation, the author and other 
information with the program. What component should she use? 
Op 1: Header files 
Op 2: Iteration 
Op 3: Comments 
Op 4: Preprocessor directive 
Op 5: 
Correct Op : 3 
 
Ques115. Shashi 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 
Op 5: 
Correct Op : 4 
 
Ques116. 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? 
Op 1: Code B is better because variable names are shorter 
Op 2: Code A is better because the variable names are understandable and nonconfusing 
Op 3: Code A will run correctly, while Code B will give an error. 
Op 4: Code B will run correctly, while Code A will give an error. 
Op 5: 
Correct Op : 2 
 
Ques117. For solving a problem, which of these is the first step in developing a working 
program for it? 
 

  53 

Op 1: Writing the program in the programming language 
Op 2: Writing a step-by-step algorithm to solve the problem. 
Op 3: Compiling the libraries required. 
Op 4: Code debugging 
Op 5: 
Correct Op : 2 
 
Ques118. A robust program has which one of the following features? 
Op 1: It runs correctly on some inputs 
Op 2: It is robust to hardware damage 
Op 3: It can handle incorrect input data or data types. 
Op 4: None of these 
Op 5: 
Correct Op : 3 
 
Ques119. 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 
Op 5: 
Correct Op : 2 
 
Ques120. To solve a problem, it is broken in to a sequence of smaller sub-problems, till a 
stage that the sub-problem can be easily solved. What is this design approach called? 
Op 1: Top-down Approach 
Op 2: Bottom-Up Approach 
Op 3: Procedural Programming 
Op 4: None of these 
Op 5: 
Correct Op : 1 
 
Ques121. The time complexity of linear search algorithm over an array of n elements is 
Op 1: O (log2 n) 
Op 2: O (n) 
Op 3: O (n log2 n ) 
Op 4: O (n2 

Op 5: 
Correct Op : 2 
 

  54 

 
Ques122. Rajesh implements queue as a singly-linked linked list. The queue has n 
elements. The time complexity to ADD a new element to the queue: 
Op 1: O (1) 
Op 2: O (log2 n) 
Op 3: O (n) 
Op 4: O (n log2 n ) 
Op 5: 
Correct Op : 1 
 
Ques123. The time required to insert an element in a stack with linked list 
implementation is 
Op 1: O (1) 
Op 2: O (log2 n) 
Op 3: O (n) 
Op 4: O (n log2 n ) 
Op 5: 
Correct Op : 1 
 
Ques124. In the following sorting procedures, which one will be the slowest for any 
given array? 
Op 1: Quick sort 
Op 2: Heap sort 
Op 3: Merge Sort 
Op 4: Bubble sort 
Op 5: 
Correct Op : 4 
 
Ques125. 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? 
Op 1: O(1) 
Op 2: O(n2 

Op 3: O(log n) 
Op 4: O(n) 
Op 5: 
Correct Op : 1 
 
Ques126. 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? 
 

  55 

Op 1: Linear Search 
Op 2: Binary search 
Op 3: Hash Coded Search 
Op 4: None of these 
Op 5: 
Correct Op : 3 
 
Ques127. The order of magnitude of the worst case performance of a hash coded search 
(over N elements) is 
Op 1: N 
Op 2: N log2 N 
Op 3: log2 N 
Op 4: not dependent upon N 
Op 5: 
Correct Op : 1 
 
Ques128. A sorting algorithm traverses through a list, comparing adjacent elements and 
switching them under certain conditions. What is this sorting algorithm called? 
Op 1: insertion sort 
Op 2: heap sort 
Op 3: quick sort 
Op 4: bubble sort 
Op 5: 
Correct Op : 4 
 
Ques129. A sorting algorithm iteratively traverses through a list to exchange the first 
element with any element less than it. It then repeats with a new first element. What 
is this sorting algorithm called? 
Op 1: insertion sort 
Op 2: selection sort 
Op 3: heap sort 
Op 4: quick sort 
Op 5: 
Correct Op : 2 
 
Ques130. A sort which uses the binary tree concept such that any number in the tree is 
larger than all the numbers in the subtree below it is called 
Op 1: selection sort 
Op 2: insertion sort 
Op 3: heap sort 
Op 4: quick sort 
Op 5: 
 

  56 

Correct Op : 3 
 
Ques131. The average time required to perform a successful sequential search for an 
element in an array A(1 : n) is given by 
Op 1: (n+1) / 2 
Op 2: log2n 
Op 3: n(n+1) / 2 
Op 4: n2 
Op 5: 
Correct Op : 1 
 
Ques132. How many comparisons are needed to sort an array of length 5 if a straight 
selection sort is used and array is already in the opposite order? 
Op 1: 1 
Op 2: 10 
Op 3: 50 
Op 4: 20 
Op 5: 
Correct Op : 2 
 
Ques133. Queues serve a major role in 
Op 1: simulation of recursion 
Op 2: simulation of arbitrary linked list 
Op 3: simulation of limited resource allocation 
Op 4: expression evaluation 
Op 5: 
Correct Op : 3 
 
Ques134. The average search time of hashing with linear probing will be less if the load  
factor 
Op 1: is far less than one 
Op 2: equals one 
Op 3: is far greater than one 
Op 4: none of these 
Op 5: 
Correct Op : 1 
 
Ques135. Number of vertices of odd degree in a graph is 
Op 1: is always even 
Op 2: always odd 
Op 3: either even or odd 
Op 4: always zero 
 

  57 

Op 5: 
Correct Op : 1 
 
Ques136. The algorithm design technique used in the quick sort algorithm is 
Op 1: Dynamic programming 
Op 2: Back tracking 
Op 3: Divide and conquer 
Op 4: Greedy Search 
Op 5: 
Correct Op : 3 
 
Ques137. Linked lists are not suitable for 
Op 1: Insertion sort 
Op 2: Binary search 
Op 3: Queue implementation 
Op 4: None of these 
Op 5: 
Correct Op : 2 
 
Ques138. A connected graph is the one which 
Op 1: Cannot be partitioned without removing an edge 
Op 2: Can be partitioned without removing an edge 
Op 3: does not contain a cycle 
Op 4: Has even number of vertices 
Op 5: 
Correct Op : 1 
 
Ques140. Stack is useful for implementing 
Op 1: radix search 
Op 2: breadth first search 
Op 3: recursion 
Op 4: none of these 
Op 5: 
Correct Op : 3 
 
Ques141. Which of the following is useful in traversing a given graph by breadth first 
search? 
Op 1: stack 
Op 2: set 
Op 3: list 
Op 4: queue 
Op 5: 
 

  58 

Correct Op : 4 
 
Ques142. Which of the following is useful in implementing quick sort? 
Op 1: stack 
Op 2: set 
Op 3: list 
Op 4: queue 
Op 5: 
Correct Op : 1 
 
Ques143. Which of the following abstract data types can be used to represent a manyto-many 
relation? 
Op 1: Tree 
Op 2: Stack 
Op 3: Graph 
Op 4: Queue 
Op 5: 
Correct Op : 3 
 
Ques144. Two lists, A and B are implemented as singly linked link-lists. 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 
Op 5: 
Correct Op : 3 
 
Ques145. Which of the following sorting algorithms yield approximately the same worstcase 
and average-case running time behaviour in O (n log n)? 
Op 1: Bubble sort and Selection sort 
Op 2: Heap sort and Merge sort 
Op 3: Quick sort and Radix sort 
Op 4: Tree sort and Median-of-3 Quick sort 
Op 5: 
Correct Op : 2 
 
 

  59 

Ques146. 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 
Op 5: 
Correct Op : 4 
 
Ques147. The maximum number of nodes on level I of a binary tree is which of the 
following? (Root is Level 1) 
Op 1: 2l-1 
Op 2: 3l-1 
Op 3: 2l 
Op 4: 2l - 1 
Op 5: 
Correct Op : 1 
 
Ques148. 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. 
Op 5: 
Correct Op : 1 
 
Ques149. In an implementation of a linked list, each node contains data and address. 
Which of the following could the address field possibly contain? 
Op 1: Address of next node in sequence 
Op 2: It's own address 
Op 3: Address of last node 
Op 4: Address of first node 
Op 5: 
Correct Op : 1 
 
Ques150. Surbhi wants to implement a particular data structure using a static array. She 
uses the concept of circular list to implement the data structure, because this allows 
her to efficiently use all fields of the array. Which data structure is Surbhi 
implementing? 
Op 1: a stack 
Op 2: a queue 
Op 3: Binary Tree 
 

  60 

Op 4: None of these 
Op 5: 
Correct Op : 2 
 
Ques151. Which of the following is a bad implementation for a queue? 
Op 1: Circular List 
Op 2: Doubly linked list 
Op 3: Singly linked List 
Op 4: Linear Static Array 
Op 5: 
Correct Op : 4 
 
Ques152. Which of the following statements are true about a doubly-linked list? 
Op 1: it may be either linear or circular 
Op 2: it must contain a header node 
Op 3: it will occupy same memory space as that of linear linked list, both having 
same number of nodes 
Op 4: None of these 
Op 5: 
Correct Op : 1 
 
Ques153. Which of the following data structure may give overflow error, even though 
the current number of element in it is less than its size ? 
Op 1: Queue implemented in a linear array 
Op 2: Queue implemented in a circularly connected array 
Op 3: Stack implemented in a linear array 
Op 4: none of these 
Op 5: 
Correct Op : 1 
 
Ques154. Number of possible ordered trees with 3 nodes A, B, C is 
Op 1: 16 
Op 2: 12 
Op 3: 13 
Op 4: 14 
Op 5: 
Correct Op : 2 
 
Ques155. The best sorting methods if number of swapping done is the only measure of 
efficiency is 
Op 1: Bubble sort 
Op 2: Selection sort 
 

  61 

Op 3: Insertion sort 
Op 4: Quick sort 
Op 5: 
Correct Op : 3 
 
Ques156. As part of the maintenance work, you are entrusted with the work of 
rearranging the library books in a shelf in proper order, at the end of each day. The 
ideal choice will be 
Op 1: bubble sort 
Op 2: insertion sort 
Op 3: selection sort 
Op 4: heap sort 
Op 5: 
Correct Op : 2 
 
Ques157. A hash table can store a maximum of 10 records. Currently there are records 
in locations 1, 3, 4, 7, 8, 9, 10. The probability of a new record going into location 2, 
with a hash function resolving collisions by linear probing is 
Op 1: 0.6 
Op 2: 0.1 
Op 3: 0.2 
Op 4: 0.5 
Op 5: 
Correct Op : 1 
 
Ques158. A full binary tree with n leaves contains 
Op 1: 2n + 1 nodes 
Op 2: log2 n nodes 
Op 3: 2n - 1 nodes 
Op 4: 2n nodes 
Op 5: 
Correct Op : 3 
 
Ques159. An array contains the following elements in order: 7 6 12 30 18. Insertion sort 
is used to sort the array in ascending order. How many times will an insertion be 
made? 
Op 1: 2 
Op 2: 3 
Op 3: 4 
Op 4: 5 
Op 5: 
Correct Op : 1 
 

  62 

 
Ques160. 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 
Op 5: 
Correct Op : 2 
 
Ques161. Srishti writes a program to find an element in the array A[5] with the following 
elements in order: 8 30 40 45 70. She runs the program to find a number X. X is  
found in the first iteration of binary search. What is the value of X? 
Op 1: 40 
Op 2: 8 
Op 3: 70 
Op 4: 30 
Op 5: 
Correct Op : 1 
 
Ques162. The array A has n elements. We want to determine the position of X in the 
array. We know that X is present in the array A and X can be present at any location 
in the array with equal probability. How many comparisons will be required on 
average to find the element X using linear search? 
Op 1: n 
Op 2: (n+1)/2 
Op 3: 2*n 
Op 4: n^2 
Op 5: 
Correct Op : 2 
 
Ques163. A is an empty stack. The following operations are done on it. 
PUSH(1) 
PUSH(2) 
POP 
PUSH(5) 
PUSH(6) 
POP 
What will the stack contain after these operations. (Top of the stack is underlined) 
Op 1: 5 6 
Op 2: 1 5 
 

  63 

Op 3: 5 6 
Op 4: 1 5 
Op 5: 
Correct Op : 2 
 
Ques164. A stack is implemented as a linear array A[0…N-1]. Farhan writes the following 
functions for pushing an element E in to the stack. 
function PUSH( top, E, N ) 

if(X) 

 top= top+1 
 A[top] = E 

else 

 print "Overflow" 

return top 

Fill in the condition X 
Op 1: top< N 
Op 2: top <n-1 
Op 3: top > 0 
Op 4: top > 1 
Op 5: 
Correct Op : 2 
 
Ques165. A stack is implemented as a linear array A[0…N-1]. Noor writes the following 
functions for popping 
an element from the stack. 
function POP( top, N ) 

if(X) 

 top = top - 1 

else 

 print "Underflow" 

return top 
 

  64 


Fill in the condition X 
Op 1: top< N-1 
Op 2: top<n 
Op 3: top>1 
Op 4: top >= 0 
Op 5: 
Correct Op : 4 
 
Ques166. Q is an empty queue. The following operations are done on it: 
ADD 5 
ADD 7 
ADD 46 
DELETE 
ADD 13 
DELETE 
DELETE 
ADD 10 
What will be the content of Q after these operations. Front is marked by (F) and Rear is marked 
by (R). 
Op 1: 10(R) 13(F) 
Op 2: 5(R) 10(F) 
Op 3: 13(R) 10(F) 
Op 4: 10(R) 5(F) 
Op 5: 
Correct Op : 1 
 
Ques167. 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 1: Front 
Op 2: Rear 
Op 3: Both 
Op 4: None of these 
Op 5: 
Correct Op : 2 
 
Ques168. A stack is implemented as a (singly-linked) linked-list, where each node contains data 
and address of another node. The top node will contain the address of which node? 
Op 1: No node. It will be empty 
Op 2: The node containing the first element pushed into the stack. 
 

  65 

Op 3: The node containing the element which was pushed just before the top element. 
Op 4: None of these 
Op 5: 
Correct Op : 3 
 
Ques169. A queue is implemented by a linear array of size 10 (and not as a circularly connected 
array). Front 
and Rear are represented as an index in the array. To add an element, the rear index is 
incremented and 
the element is added. To delete an element, the front index is incremented. The following 
operations 
are done on an empty queue. 
ADD 1; DELETE; ADD 2; ADD 3; ADD 4; DELETE, DELETE 
After this set of operations, what is the maximum capacity of the queue? 
Op 1: 6 
Op 2: 7 
Op 3: 10 
Op 4: None of these 
Op 5: 
Correct Op : 2 
 
Ques170. A queue is implemented as a (singly linked) linked-list. Each node has an element and 
pointer to 
another node. Rear and Front contain the addresses of the rear and front node respectively. If 
the 
condition (rear isequal front) is true and neither is NULL, what do we infer about the linked 
list? 
Op 1: It has no elements 
Op 2: It has one element 
Op 3: There is an error 
Op 4: None of these 
Op 5: 
Correct Op : 2 
 
Ques171. Jaswinder has a book of tickets and wants to store ticket numbers in a data structure. 
New tickets 
are added to the end of the booklet. Ticket at the top of the stack is issued to the customer. 
Which data 
structure should Jaswinder use to represent the ticket booklet? 
Op 1: Queue 
Op 2: Stack 
Op 3: Array 
 

  66 

Op 4: Graph 
Op 5: 
Correct Op : 1 
</n 
</n-1 
 
 
 
 
 
 
 

SET 2 
 

 
 

  67 

1.  Null function is also known as 

a.   Anonymous Function 

b. Generic Function 

c. Void Function 

d. Null operator 

Ans.D 

2.  There are two loops which are nested. This implies which of the following 

a.   Two loops, one after the other   

b. Two loops, one inside the other 

c. One loop two different iteration counts 

d. Two loops with same iteration count 

Ans.B 

3.       Shravanti writes the following program.  

integer i=0,j 

                                while( i < 2  ) 

                                { 

                                                j = 0; 
 

  68 

                                                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 

                                } 

 What will be the output of the program? 

a.       0                      b. 0 3                     c.  0                        d. 0 3 6 

                       0 3                        0 3 6                       0 3 6                       0 3 6 9 

                                                                                     0 3 6 9                    0 3 6 9 12 

Ans. C 

4.        What is the term used to describe the situation,when a function in the base class is 
redefined in inherited class? 

a.       Inheritance         b. Overriding      c. Overloading   d. Encapsulation 

Ans.B 

5.  Consider the given statements regarding Arrays- 

1.Arrays provide a linear medium to store data. 
 

  69 

2.Arrays provide a non indexed structure. 

3.All the elements in Array depend on the location of the other elements of the Array. 

Which of the above statements is/are true? 

a.       Only 1     b. Both 1 and 2                  c. Both 1 and 3                   d. 1, 2 and 3 

Ans.D 

6.       Consider a binary tree implementation. The root address is stored in variable root. Given 
the address of a node is variable node, its value, right and root could 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(n0de) 

                                                print node -> value 

                                                if(Conditon X) 

                                                { 

preordertraverse(node ->left) 

                                                if(Condition Y) 

                                                { 

preordertraverse(node ->right) 

                                                return 

                                } 
 

  70 

What is the Condition X and Condition Y ? 

a.       Condition X: node -> left is not equal null 

b. Condition X: node -> right is not equal null,Condition Y:node -> right is not equal 
null,Condition Y:node -> left is not equal null 

c.  Condition X: node -> left is equal null 

d.   Condition X: node -> right is equal null, Condition Y:node -> right is equal null, Condition 
Y:node -> left is equal null. 

Ans.A 

7.       In breadth-first search,which of the following options is true? 

a.       Beginning from a node,first all its adjacent nodes are traversed. 

b.      Beginning from a node,each adjacent node is fully explored before 

c.       Traversing the next adjacent node. 

d.      Beginning from a node , nodes are traversed in cyclic order. 

e.      None of these. 

Ans.A 

8.       Sruti is making a questionnaire of True-False question. 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? 

a.       Integer   B. Boolean        c. float   d. character 

 
 

  71 

Ans.B 

9.       Which of these is not a data type? 

a.       Integer   B. character   C. Boolean    D. array 

Ans.D 

10.   A full binary tree with n leaves contains 

a.       2n+1 nodes        b. log2n nodes                  C. 2n-1 nodes                    D. 2n nodes 

Ans.A 

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

A. Address of next node in sequence   B. It’s own address  

C. Address of the last node            D. Address of the first node 

Ans. A 

12.​  ​Parthiv has included several classes and their subjects 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 iterative? 

A. Store them in database   B. Final class         C. Generic class       D. Anonymous class 

Ans.C 
 

  72 

13.​ ​Shristhi writes the code for a function that computes the factorial of the inputted number  ​n​. 

function factorial(n) 

  if( n equals 1) 

    return 1 

  else 

   - - MISSING STATEMENT - - 

  end 

  } 

Fill the missing statement. 

a.​       ​return factorial(n-1)    B. return n*factorial(n)  C. return n*(n-1)  D. return 


n*factorial(n-1) 

Ans.D 

14.​       ​Shasi wants to make a program to print the sum of the first 10 multiples of 5. She writes the 
following program, where statement 5 is missing. 

integer i=0 

integer sum=0 

while ( i <= 50) 

{  

                                 sum =sum+1 

                                - - MISSING STATEMENT - - 
 

  73 

print sum 

Which of the following options will you use for statement 5? 

A. i = 5  B. i = 5 *I  C. i = i + 1  D. i = i + 5 

Ans.D 

15.​       ​Consider the following code: 

if(condition 1) 

  if(condition 2) 

  {  

// Statement A 

   Elseif (condition 3) 

    { 

//Statement B 

  else 

    { 

 // Statement C 

  else if (condition 4) 

    { 
 

  74 

 //Statement D 

  else 

//Statement E 

Which of the following conditions will allow execution of statement C? 

A. condition1 AND condition 3 

B. condition1 AND condition4 AND NOT (condition2) 

C. NOT (condition2) AND NOT (condition3) 

D. condition1 AND NOT(condition2) AND NOT(condition3) 

Ans.D 

16.A full binary tree with ​n ​non-leaf nodes contains 

A. (log n) nodes  B.  n + 1 nodes  C. 2n+1 nodes  D. 2n nodes 

Ans. C 

17. Ravi is writing a program in C++. C++ uses the ​‘for’ ​keyword for loops. Due to distraction Ravi writes 
‘​gor’ instead​ of ​‘for’. ​What will this result to? 

A. The code will not compile 

B. The code will give an error while in execution 
 

  75 

C. The code may work for some inputs and not for others 

D. It will create no problems. 

Ans.A 

18. Aina wants to use a sorting technique to sort a list of numbers such that the running time of the 
sorting technique that she uses won’t affected by pre-order of the elements. Which of the following 
sorting techniques should she use? 

A. Merge Sort  B.  Bubble Sort  C. Insertion Sort  D. Selection Sort 

Ans. Not known please write into Comments and will be added here for students reference. 

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

A. Run time is always more than compile time.      B. Compile time is always more than run time 

C. Compile time is a function of run time     D. A program needs to be compiled once but can be 
run several times. 

Ans.D 

20. Pankaj and Mythili were both asked to write the code to evaluate the following expression. 

a-b + c/(a-b) + (a-b)​2   

1.​       ​Pankaj writes the following code statements (Code A) 

print (a-b) + c/(a-b) + (a-b) * (a-b) 

2.​       ​Mythili writes the following code statements (Code B) 

d = (a-b) 

print d + c/d + d*d 

You might also like