0% found this document useful (0 votes)
80 views161 pages

150+ MCQs For OAs of Placements - GATE

The document contains 36 multiple choice questions related to computer science concepts like data structures, algorithms, object-oriented programming, and C++. It tests knowledge on topics like functions, loops, arrays, sorting, searching, trees, and more. The questions range from true/false, matching, to code snippets that require analysis to determine the output or error.

Uploaded by

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

150+ MCQs For OAs of Placements - GATE

The document contains 36 multiple choice questions related to computer science concepts like data structures, algorithms, object-oriented programming, and C++. It tests knowledge on topics like functions, loops, arrays, sorting, searching, trees, and more. The questions range from true/false, matching, to code snippets that require analysis to determine the output or error.

Uploaded by

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

1) Null function is also known as ___________.

A. Anonymous Function
B. Generic Function
C. Void Function
D. Null Operator
2) A complete binary tree has a property that
the value at each node is at least as large as the
values at its children nodes. What is this binary
tree known as?

A. Binary Search Tree


B. AVL Tree
C. Completely Balanced Tree
D. Heap
3) Which of the following is NOT a data type?

A. Integer
B. Character
C. Boolean
D. Array
4) Which of the following sorting algorithms
yields approximately the same worst-case and
average-case running time behavior in O(n
long)?

A. Bubble sort and Selection sort


B. Heap sort and Merge sort
C. Quick sort and Radix sort
D. Tree sort and Median-of-3 Quick sort
5) A programmer is making a database of animals in a
zoo along with their properties. The possible animals
are dog. Lion and zebra each one has attributes as
herbivorous. Color and nocturnal. The programmer
uses the object- oriented programming paradigm for
this. How will the system be conceptualized?

A. Class: Animal; objects: dog, lion and zebra: data


members: herbivorous, color and nocturnal
B. Class: Animal; objects: herbivorous, color and
nocturnal: data members: dog lion and Zebra
C. Classes: dog lion and zebra: objects: Animal; data
members; herbivorous, color and nocturnal
D. Nome of the above
6) A stack is implemented as a linear array A[0…N-1] A
programmer writes the function given below to pop out an
element from the stack
Function POP ( top, N)
{
if (X)
{
top = top -1
}
else
{
“Print Underflow”
}
return top
Which of the following should substitute the condition”X”?
A. top<N-1
B. top<N
C. top>1
7) A queue is implemented as a singly linked-
list. Each node has an element and a pointer to
another node. The Rear and the Front contain
the addresses of the rear and the front nodes,
respectively. What can be inferred about the
linked list if the condition (rear isequal front) is
true?

A. It has no elements
B. It has one element
C. There is an error
D. None of the above
8) Consider the code given below. Assume that “a” and “b” are
passed reference. What will the output of the program be when the
function calculate() is executed?
function modify(b,a)
{
return a –b
}
function calculate()
{
integer a = 5, b = 12, c
c = modify(a,b):
print c
}
A. 7
B. -7
C. 8
D. Error
Passage
functionmyfunc()
{
constant integer i=5
if (i> 3)
print “i am smali”
if ( i-- > 5 )
print “i am iarge”
eise print “i am different”
}
A pseudo-coed is used which is self explanatory.
9) What will be the output of the given code?

A. I am small
B. I am small am large
C. I am small am different
D. This code will generate an error
10) A librarian has to rearrange the library
books on a shelf in a proper order at the end of
each day. Which of the following sorting
techniques should be the librarian’s ideal
choice?

A. Bubble sort
B. Insertion sort
C. Selection sort
D. Heap sort
11) A tree has 5 levels and each node has either
4 or no children. All nodes on the same level
have the same number of children. How many
nodes are there in the tree?

A. 341
B. 256
C. 1024
D. None of the above
12) Why is an algorithm designer concerned
primarily about the run time and not the
compile time while calculating time complexity
of an algorithm?

A. Run time is always more than the compile


time.
B. Compile time is always more than the 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.
13. For which of the following is the stack
implementation useful?

A. Radix search
B. Breadth fist search
C. Recursion
D. None of the above
14. Passage
Function print_me(integer n) // Statement 1
{
if ( n < 1 ) return // Statement 2
print n // Statement 3
print_me(n-1) //Statement 4
}

A pseudo-code is used which is self explanatory,


// in pseudo code refers to comment
Pooja has written the following code to print numbers from 0 to n
in reverse order using the recursive approach. Find if there exists
any error in the given code.
A. Statement 1
B. Statement 2
C. Statement 3
D. There is no error
15. How can a call to an overloaded function be
ambiguous?

A. The name of the function might have been


misspelled
B. There might be two or more functions with
the same name
C. There might be two or more functions
with equally appropriate signatures
D. None of the above
16. What will the output of the following pseudocode
statements be?
(Note: Assume that when two data types are processed
through an operator. The answer maintains the same
data type as that of input. Also, all data types have
enough range to accommodate any number. If two
different data types are operated upon, the result
assumes the data type that is more expressive.)
Integer a = 456, b, c, d = 10
b = a/b
c=a–b
Print c

A. 410
B. 410.4
C. 411.4
D. 411
17. Passage
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
}

A. 0
03
B. 0 3
036
C. 0 3
036
0 3 69
D. 0 3 6
0369
036912
18. What does the following function do?

function operation (int a, int b)


{
if (a>b)
{ retum operation(b, a) }
else
{ retum a: }
}

A. Always returns the first parameter


B. Returns the min of (a,b)
C. Returns the max of (a,b)
D. Loops forever
19. What is the average time required to
perform a successful sequential search for an
element in an array A(1: n)?

A. (n+1)/2
B. log 2n
C. n(n+1)/2
D. n 2
20. How are protected members of a base class
accessed in the derived class when inherited
privately in C++?

A. Privately
B. Publicly
C. Protectedly
D. Not inherited
21. How many nodes does a full binary tree
with n” non-leaf nodes contain?

A. log n
B. n + 1
C. 2n + 1
D. 2n
22. A programmer mistakenly writes “gor”
instead of the keyword “for” used in loops,
while writing a program in C++. What will this
result in?

A. The code would not compile.


B. The code would give an error while
execution.
C. The code may work for some inputs and not
for the others
D. The code would not create any problem.
23. Which of the following options is an exception to
being a part of composite date types?

A. Union
B. Array
C. Structure
D. Stack
24. Which characteristic of data does a binary
search use and a linear search does not?

A. Order of the list


B. Length of the list
C. Maximum value of the list
D. None of the above
25. 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?

A. Insertion sort
B. Selection sort
C. Heap sort
D. Quick sort
26. In which of the following methods is sorting NOT
possible?

A. Insertion
B. Selection
C. Exchange
D. Deletion
27. A programmer is making a database of animals in a
zoo along with their properties. The possible animals
are dog. Lion and zebra each one has attributes as
herbivorous. Color and nocturnal. The programmer
uses the object‐ oriented programming paradigm for
this. How will the system be conceptualized?

A. Class: Animal; objects: dog, lion and zebra: data


members: herbivorous, color and nocturnal
B. Class: Animal; objects: herbivorous, color and
nocturnal: data members: dog lion and Zebra
C. Classes: dog lion and zebra: objects: Animal; data
members; herbivorous, color and nocturnal
D. Nome of the above
28. 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).
Option 1 : 10(R) 13(F)
Option 2 : 5(R) 10(F)
Option 3 : 13(R) 10(F)
Option 4 : 10(R) 5(F)
29. 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
30. 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
31. 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 – –
}
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
32. 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
C. The code may work for some inputs and not
for others
D. It will create no problems.
33. Which of the following sorting algorithm
yield approximately the same worst-case and
average-case running time behaviour in O (n
log n)?

A. Bubble sort and Selection sort


B. Heap sort and Merge sort
C. Quick sort and Radix sort
D. Tree sort and Median-of-3 Quick sort
34. What is implied by the argument of a
function?

A. Variables passed to it when it is called


B. The value is returns on execution
C. The execution code inside it D. Its return type
35. Which of the following statements is true
regarding the sorting and searching algorithms?

A. Linear searching is faster than the most


efficient sorting algorithm
B. Linear searching is slower than the most
efficient sorting algorithm
C. Linear searching and the most efficient
sorting algorithm take up almost same time
D. Their complexities cannot be compared
36. A sorting algorithm traverses through a list,
comparing adjacent elements and switching
them under certain conditions. What is this
sorting algorithm called?

A. Insertion sort
B. Heap sort
C. Quick sort
D. Bubble sort
37. What is the space complexity of a program?

A. Amount of hard-disk space required to store


the program
B. Amount of hard-disk space required to
compile the program
C. Amount of memory required by the
program to run
D. Amount of memory required for the
program to compile
38. 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. Xis found in the first iteration
of binary search. What is the value of X?
Choose the correct answer

A. 40
B. 8
C. 70
D. 30
39. Saloni writes the code for a function that
takes as input n, an even integer and calculates
the sum of 1st n natural numbers
function sum (n)
{
if(n equals 2)
return 2
else
return ( n+ sum( n-1))
}
She then calls the function by the statement,
sum(30). How many times will the function
sum be called to compute this sum? Choose the
correct answer?
40. Shalini wants to programme to print the largest
number out of 3 inputted numbers. She writes the
following programme
Int number 1, number 2, number 3, temp;
Input number 1, number 2, number 3;
If ( number 1 > number 2)
Temp = number 1
Else
Temp= number 2
End if
If ( ??) // statement 1
Temp = number 3
End if
Print temp
Fill in the ??in statement 1 ? Choose the correct answer?
A. Number 3> number 2 B. Number 3> temp C.
Number 3< temp D. Number 3> number 1
41. How many pointers will have to be changed
when a new node is to be added in a linear
linked list in the middle?

A. 0
B. 1
C. 2
D. All the pointers will be changed
42. A variable cannot be used?

Choose the correct answer

A. Before it is declared
B. After it is declared
C. In the function it is declared in
D. Can always be used
43. In which area of a class are data and
function directly accessible outside the class?

Choose the correct answer

A. Public
B. Private
C. Protected
D. None
44. Which of the following options is true
regarding inheritance in Object Oriented
Programming ? Choose the correct answer?

A. There is reduced interaction with the


hardware

B. A class may are may not have any object

C. Two are more functions can have the same


name and number and type of arguments in a
program

D. Class- object relation can be changed at run


45. 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?

A. Linear search
B. Selection search
C. Hash coded search
D. Binary search
E. None of this
46. Which of the following abstract data types
can be used to represent many – to- many
relations? Choose the correct answer?

A. Tree
B. Stack
C. Graph
D. Queue
47. Pragya sells footballs. She has a large
container to store footballs which is closed
from below. Footballs are piled one on top of
the other in the box. When new balls are
supplied, Pragya puts the balls in the box from
the top. When a customer buys a ball, she
delivers the ball at the top of the pile to the
customer. Each ball has a code. She wants to
store the ball codes in the data structure to
keep track of her inventory. What data
structure should she use? Choose the correct
answer?
48. For the given array, find the arrangement of
the 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

A. 22, 11, 33, 66, 77, 55, 88


B. 11, 22, 33, 55, 66, 77, 88
C. 11, 22, 33, 55, 66, 88, 77
D. 11, 22, 33, 77, 66, 88, 55
49. For solving a problem, which of these in the
1st step in developing a working programme
for it? Choose the correct answer?

A. Writing the program in the programming


language
B. Writing the step by step algorithm to solve
the problem
C. Compiling the libraries required
D. Code debugging
50. The algorithm design technique used in
quick sort algorithm is?

Choose the correct answer

A. Dynamic programming
B. Back tracking
C. Divide and conquer
D. Greedy search
51. How can call to an overloaded function be
ambiguous?

A. By misspelling the name


B. There might be two or more functions with
the same name
C. There might be two or more functions
with equally appropriate signatures
D. none of these
52. Consider the given statement for their
correctness with respect to stacks data structure
1. Stacks follow a LIFO approach
2. Stacks are used to convert binary numbers to
corresponding decimal numbers.
3. Stacks use two pointers for performing PUSH
and POP respectively

A. TTF
B. TTT
C. TFF
D.FTF
53. Which of the following options gives the
lower bound on running time for an algorithm?

A. Best case complexity of the algorithm


B. Average case complexity of the algorithm
C. Worst case complexity of the algorithm
D. Number of iterations taking place in the
algorithm
54. function main() {
integeri=0.7
static float m=0.7
if (m equals i)
print ”we are Equal”
else if( m>i )
print ”I am greater”
else
print ”I am lesser”
}

A. We are equal
B. I am greater
C. I am lesser
D. This code will generate an error
55. 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?

A. A[x+1]
B. A[x+2]
C.A[x+2x]
D. All of these
56. Choose the correct answer. 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?

A. a < 1.0
B. a <sqrt (10)
C. a >sqrt (10)
D. a = 0
57. Choose the correct answer. Ankita takes as
input 2 integer numbers, a and b, whose value
can be between 0 and 31. He stores them as 5
bit numbers. He writes the following code to
process these numbers to produce a third
number c.
c = 2*(a – b)
In how many minimum bits should Ankita
store c?

A. 6 bits
B. 7 bits
C. 8 bits
D. 9 bits
58. Recursive function is executed in a
___________________________

A. Last in First Out Order


B. First in First Out Order
C. Parallel Fashion
D. All of the above
59. Yukta created an interface to use it in
different parts of the program by implementing
it. But she forgot to specify the access specifier
for each contained method. What will be the
access specifier of the methods that will be
inherited/implemented?

A. Public
B. Private
C. Protected
D. An error will be generated
60. Which of the following statements are true?

1)An Arithmetic left shift multiplies a signed


number by two
2)An Arithmetic right shift divides a signed
number by two
3)Mask operation is an AND micro-operation
and insert is an OR micro-operation
4)In a logical shift, the serial input to the shift is
one

A. Both 1 and 2
B. Both 3 and 4
C. 1, 2 and 3
61. Choose the correct answer. 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?
A. 6 B. 7
62. A 8-bit signed integer has the following
range?

A. 0 to 255 B. -128 to 127

C. -255 to 254 D. 0 to 509


63. Pankaj makes a program to print the product of
cubes of the first 10 whole numbers
She writes the following program:
integer x = 0 // statement 1
integer sum = 0 // statement 2
while ( x < 10 ) // statement 3
{
sum = x*x*x // statement 4
x = x + 1 // statement 5
}
print sum // statement 6
Is her program correct? If not, which statement will
you modify to correct it?
A. No error, the program is correct B. Statement 1

C. Statement 4 D. statement 6
64. Here is an infix notation: ((A+B)*C-(D-E))^(F+G)
Choose the correct postfix notation of the above from
the given options?

A. AB+CD*E–FG+^

B. AB+C*DE–FG+^

C. AB+C*DE-FG-+^

D. A+BC*DE-FG-+^
65. One of the following options is a form of
access used to add and remove nodes from a
queue.

A. LIFO

B. FIFO

C. Both LIFO and FIFO

D. None of these
66. What is the time complexity of adding three
matrices of size NXN cell-by-cell?

A. O (N)

B. O (N^2)

C. O (N^3)

D. None of these
67. What is the output of the pseudocode statements
given below?
(Note: Assume that when two data types are processed
through an operator, the answer maintains the same
data type as that of the input. Also, all data types have
enough range to accommodate any number. If two
different data types are operated upon, the result
assumes the data type that is more expressive.)
integer a=984, b=10
//float is a data type to store real numbers.
float c
c=a/b
print c

A. 984
B. 98.4
C. 98
68. What will be the output generated when the given code is
executed?A pseudo- code is used which is self explanatory.

function main()
{
integer a=5
switch(a)
{
default: print “hello”
case 5: print “How are you?”
break

}
A. hello
B. How are you
C. HelloHow are you?
D. This code will generate a compile time error
69. A language has 28 different letters in total.
Each word in the language consists of a
maximum of 7 letters. A programmer wants to
create a data type to store a word of this
language. She decides to store the word as an
array of letters. How many bits should she
assign to the data type to store all kinds of
words of the language?

A. 7
B. 35
C. 28
D. 196
70. How can the largest number in a list of
twenty numbers be found?

A. Use bubble sort to sort the list in a


descending order and the print the first
number of the series
B. Use selection sort to sort the list in a
descending order and the print the first
number of the series
C. Implement one iteration of selection sort
for descending order and print the first
number in the series
D. None of the above
71. A programmer writes an efficient program to sum
two square diagonal matrices (matrices with elements
only on the diagonal positions). The size of each matrix
is nXn. What is the time complexity of the algorithm?

A. O(n2)
B. O(n)
C. O(n*log(n))
D. None of the above
72. How many nodes does a full binary tree with “n”
leaves contain?

A. 2n + 1 nodes
B. log2n nodes
C. 2n – 1 nodes
D. 2n nodes
73. Refer to the pseudocode given in the ‘Passage’. The
code is similar to that in C++ and is self‐explanatory. An
accessible member function and a data member for an
object are accessed by the statements objectname.
functionname andobjectname. datamembername,
respectively. Which statement should be deleted from
the code to rectify the error in it ?

A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
74. The following values are to be stored in a
hash Table-15,22,41,19,102,18,37
Using the division method of hashing with a
table size of 10 (use sequential method of
resolving collision),give the contents of Hash
Table.

A. 41,22,102,15,37,18,19,Null, Null, Null

B. Null, Null, Null,41,22,102,15,37,18,19

C. 41,22,102,15,37,18,19

D. Null,41,22,102,Null, 15,Null, 37,18,19


75. Consider the code given below. How many
times will “Hello” be printed if m<n and exactly
one of (m,n) is even?
fori= m to n increment 2
{ print “Hello!” }

A. (n – m + 1)/2

B. 1 + (n –m)/2

C. 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is


odd

D. (n – m + 1 )/2 if m is even,1 + (n – m )/2 if m is


1.Q) What will the output of the following pseudo code
statements be?
(Note: Assume that when two data types are processed
through an operator, the answer maintains the same
data type as that of the input. Also, all data types have
enough range to accommodate any number. If two
different data types are operated upon, the result
assumes the data type that is more expressive.)
Integer a = 456, b, c, d = 10
b = a/d
c=a–b
print c

A.410
B. 410.4
C. 411.4
D. 411
2.Q) The function given below takes a number “n” as the input
and calculates the sum of first “n” natural numbers. Which of the
following statements should be inserted in place of “??” to get
the required output?
function sum(n)
{
if (??)
return 1
else
return (n + sum(n‐1))
end
}
A. n equals 1
B. n equals 2
C. n>= 1
D. n>1
3.Q) Which of the following implies that there are two loops that
are nested?

A. Two loops, one after the other


B. Two loops, one inside the other
C. One loop with two different iteration counts
D. Two loop with the same iteration count

Choose the correct answer.


Passage
function main()
{
static integer abc = 5
print abc—
if ( abc )
main() // calling main function
}
Choose the correct answer:
A pseudo-code is used which is self explanatory.
// in pseudo code refers to comment
4.Q) What will be the output of the given code?

A. 43210
B. 54321
C. This code will enter an infinite loop
D. This code will generate an error
5.Q) The function given below takes an even integer “n” as the input and
calculates the sum of first “n” even natural numbers. The function is called by
the statement “sum (30)”. How many times will the function “sum” be called
to compute the sum?
function sum(n)
{
if (n equals 2)
return 2
else
return (n + sum(n‐2)
end
}

A. 1
B. 30
C. 15
D. 16
Passage
Class rocket
{
private:
integer height, weight
public: \\statement 1
function input a, int b)
{
height = a;
weight = b;
}
}
function main( )
{
Rocket rocket1, rocket2
}
6.Q) Refer to the pseudocode given in the ‘Passage’. The
code is similar to that in C++ and is self-explanatory. An
accessible member Funcction and a data member for
an object are accessed by the statements objectname.
Functionname and objectname. Datamemnername,
respectively.
What can be inferred from this code?

A. “rocket” is a class with “rocket1” and “rocket2”


as its objects, with “height” and “weight” as its
attributes.
B. “rocket” is a class with “rocket1” and “rocket2” as its
objects, with “height” and “weight” as its objects.
C. “rocket” is a class with “rocket1” and “rocket2”,
“height” and “weight” as its attributes.
D. “rocket” is a class with “rocket1” and “rocket2”,
“height” and “weight” as its objects.
7.Q) In which of the following situations can a
constructor be invoked?

A. When an object is created


B. When an object is assigned the value 0
C. Only at the end of the code
D. When the scope of the object is over
8.Q) What will happen if some indentations are
made in some statements of a code written in
C++?

A. Faster execution of the code


B. Lower memory requirement for the code
C. Correction of errors in the code
D. Better readability of the code.
9.Q) In an implementation of a linked list, each
node contains data and address. Which of the
following can the address field possibly
contain?

A. Address of the next node in sequence


B. Its own address
C. Address of the last node
D. Address of the first node
10.Q) Consider the structure of a queue as given below

FRONT = 2, REAR = 4
Queue: _, L, M, N, _
What will be the values of FRONT and REAR
respectively after the insertion of an element ‘Q’ in the
given queue?

A. 1,4
B. 2,5
C. 1,5
D. 2,4
12.Q) Which of the following can be inherited
by a derived class from a base class?

A. Data members
B. Member functions
C. Constructors and destructors
D. Data members and member functions
13.Q) A programmer wants the program given below to print the
largest number out of three numbers entered by the user.
int number1, number 2, number 3, temp;
input number 1, number 2, number 3;
if (number1>number2)
temp = number 1
else
temp = number 2
end if
if (??) // Statement 1
temp = number 3
end if
print temp
Which of the following should be substituted in place of “??” in
Statement 1 in the code?

A. number3> number2
B. number3> temp
C. number3> temp
D. number3> number1
14.Q) Which of the given function prototypes can be considered to be
overloaded (no ambiguity)?
A. function my Func(integer Num, float me) // does not return anything
B. function my Func(integer Num, double me) // does not return anything
C. function my Func(character Num, float me) // does not return anything
D. function my Func(integer Num, float me) // return an integer
Passage
function moify(y,z)
{
y = y + 1;
z = z + 1;
return y – z
}
function calculate ( )
{
integer a = 5, b = 10, c
c = modify (a, b);
print a
print space
print c
{
15.Q) Consider the code given in the ‘Passage’. Assume that “a” and
“b” are passed by value. What will the output of the program be
when the function clculate () is executed?

A. 11 -5
B. 10 -5
C. 6 -5
D. 5 -5

Passage
function preordertraverse(node)
{
print node value
if (condition x)
{ preoedertraverse(node left)}
if condition y)
{ preordertraverse(node right)}
return
}
16.Q) Consider a binary tree implementation. The root address is
stored in the vatiable root. The address of a node is given in the
variable node. The value of the node and its right and left child
nodes can be accessed usina the statements given below.
node value,
node right,
node left.
A programmer writes the function given in the ‘Passage’ to do a
preorder traversal of the tree.
What are Condition X and Condition Y ?
A. Condition X: node left isnotequal
Condition Y: node right isnotequal
B. Condition X: node right isnotequal
Condition Y: node left isnotequal
C. Condition X: node left isequal
Condition Y: node right isequal
D. Condition X: node right isequal
Condition Y: node left isequal
17. Q) The following operations are performed on an
empity R “A”.
PUSH( 1)
PUSH (2)
POP
PUSH(5)
PUSH(6)
POP
What will the stack contain after these operations?
(Note: The top of the stack is underlined in the options
below.)
A. 5 6
B. 1 5
C. 5 6
D.1 5
18.Q) How may nodes does a full binary tree
with “n” non-leaf nodes contain?

A. log n
B. n + 1
C. 2n + 1
D. 2n
19.Q) A programmer mistakenly writes “gor”
instead of the keyword “for” used in loops.
While writing a program in C++. What will this
result in ?

A. The code would not compile.


B. The code would give an error while
execution.
C. The code may work for some inputs and not
for the others.
D. The code would not create any problem.
20.Q) 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?

A. Linear search
B. Binary search
C. Hash coded search
D. None of the above
21.Q) Which of the following abstract data
types can be used to represent a many-to-many
relation?

A. Tree
B. Stack
C. Graph
D. Queue
22.Q) Why is an algorithm designer concerned
primarily about the run time and not the compile time
while calculating time complexity of an algorithm?

A. Run time is always more than the compile time.


B. Compile time is always more than the 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.
Passage
Function main()
{
Automatic variable var
Print var
}
Choose the correct answer.
A pseudo-code is used which is self explanatory.
23.Q) What will be the output generated when
the given code is executed?

A. 0
B. 1
C. Garbage Value
D. This code will generate a compile time error
24. Q) In which of the following methods is
sorting NOT possible?

A. Insertion
B. Selection
C. Exchange
D. Deletion
25.Q) Which of the following algorithm design
techniques is used in the quick sort algorithm?

A. Dynamic programming
B. Back tracking
C. Divide and conquer
D. Greedy search
26.Q) A programmer is making a database of
animals in a zoo along with their properties.
The possible animals are dog, lion and zebra.
Each one has attributes as herbivorous, color
and nocturnal. The programmer uses the object-
oriented programming parasigm for this. How
will the system be conceptualized?
A. Class: Animal; objects: lion and zebra;
data members: herbivorous, color and
nocturnal
B. Class: Animal; objects: herbivorous, color
and nocturnal; data members: dog, lion and
zebra
C. Classes: dog, lion and zebra; objects: Animal;
27.Q) The program to print the sum of all cubes that lie
between 0 and 100 is given below. Does this program have
an error? If yes, which statement should be modified to
correct the program?
integer i = 0,a // Statement 1
integer sum = 0;
a = (i * i * i)
while (1<100) // Statement 2
{
sum = sum + a // Statement 3
i=i+1
a = (i * i * i ) // Statement 4
}
Print sum
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
28.Q) What is the output of the pseudocode statements
given below?
(Note: Assume that when two data types are processed
through an operator, the answer maintains the same
data type as that of the input. Also, all data types have
enough range to accommodate any number. If two
different data types are operated upon, the result
assumes the data type that is ore expressive.)
integer a = 984, b=10
//float is a data type to store real numbers.
float c
c=a/b
print c

A.984
B. 98.4
C. 98
D. Error
29.Q) Code a contains a set of eight lines that occur ten times
in different points of the program. This code is passed to a
programmer who puts the set of eight lines in a function
definition and calls them at the ten points in the program.
Assume this new code to be Code B. Which code will run
faster using an interpreter?
Code A
Code B
Both the codes would run at the same speed
None of the above
Passage
function MyFunc 1(integer n)
{
return n*2
}
function MyFunc2(integer n)
{
print “The value is “ n
}
30.Q) Which of the given two functions can be
categorized as procedure?

A. My Func 1
B. My Func 2
C. Both MyFunc1 and MyFun2
D. A function cannot be a procedure
31.Q) Which of the following statements is
TRUE about a breadth first search?

A. Beginning from a node, all the adjacent


nodes are traversed first
B. Beginning from a node, each adjacent
node is fully explored before traversing
the next adjacent node
C. Beginning from a node, the nodes are
traversed in cyclic order
D. None of the above
32.Q) How does inheritance relate to
abstraction?

A. A base class is an abstraction of all its


derived classes.
B. A derived class is an abstraction of all its
base classes.
C. Base and derived classes are abstractions of
each other.
D. Inheritance prevents abstraction.
33.Q) Consider the code given below. How
many times will “Hello” be printed if m<n and
exactly one of (m,n) is even?

For i= m to n increment 2
{ print “Hello!”}

A. (n – m + 1)/2
B. 1 + (n – m)/2
C. 1 + (n – m )/2 if m is even, (n – m + 1)/2 if m is
odd
D. (n – m + 1)/2 if m is even, 1 + (n – m )/2 if m is
odd
34.Q) A data type is stored as a 6-bit signed
integer. Which of the following cannot be
represented by this data type?

A. -12
B. 0
C. 32
D. 18
35.Q) Consider the code given below. Assume that “a”
and “b” are passed by reference. What will the output
of the program be when the unction calculate() is
executed?
function modify(b,a)
{
return a – b
}
function calculate ()
{
Integer a = 5, b = 12, c
c = modify(a,b);
print c
}

A.7
B. -7
C. 8
36.Q) Each bucket in a Hash Table is the head of
______________.

A. A Heap
B. A Stack
C. An Array
D. A Queue
37.Q) A programmer implements a queue as a singly‐
linked list. He queue has “n” elements. What will be the
time complexity to ADD an element to the queue?

A. O(1)
B. O(log 2n)
C. O(n)
D. O(n log 2n)
passage
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( )
{
entityn black
int value 2 = 5
value = black. compare() // Statement 1
black.c = value02 // Statement2
print black a // Statement 3
38.Q) Refer to the pseudocode given in the
‘Passage’. The code is similar to that in C++ and
is self-explanatory. An accessible member
function and a data member for an object are
accessed by the statements objectname.
functionname and objectname.
datamemnername, respectively. Identify the
statement with an error.

A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. None of the above
39.Q) What is the maximum number of edges
in an undirected graph with “n” vertices?

A. n*(n-1)/2
B. n*(n+1)/2
C. n*n
D. 2*n
40.Q)What will be returned if f(a,b) is called in the following
functions?
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;
}
A. Always +1
B. 1 if a>b, ‐1 if a<b, 0 otherwise
C. ‐1 if a>b, ‐1 if a<b, 0 otherwise
D. 0 if a equals b, ‐1 otherwise
41.Q) In the execution process of a program,
this technoque involves the intermediate
representation to be compiled to native
machine code at runtime. What is the name of
this technique?

A. Static compilation
B. Run time interpretation
C. Static interpretation
D. Just in time compilation
42.Q)Choose the correct answer.
A sorting mechanism uses the binary tree
concept such that any number in the tree is
larger than all the numbers in the sub-tree
below it. What is this method called?

A. Selection sort
B. Insertion sort
C. Heap sort
D. Quick sort
43. Q) The following operations are performed
on an empty stack “A”.
PUSH( 1)
PUSH (2)
POP
PUSH(5)
PUSH(6)
POP
What will the stack contain after these
operations?
(Note: The top of the stack is underlined in the
options below.)
A. 5 6
B. 1 5
C. 5 6
44.Q) What will happen if some indentations
are made in some statements of a code written
in C++?

A. Faster execution of the code


B. Lower memory requirement for the code
C. Correction of errors in the code
D. Better readability of the code
45.Q) Which of the following abstract data
types can be used to represent a many-to-many
relation?

A. Tree
B. Stack
C. Graph
D. Queue
46.Q) A librarian has to rearrange the library
books on a shelf in a proper order at the end of
each day. Which of the following sorting
techniques should be the librarian’s ideal
choice?

A. Bubble sort
B. Insertion sort
C. Selection sort
D. Heap sort
47.Q)Tricha needs to store a list of binary data.
Which of the following data types should she
use?

A. Integer
B. Float
C. Character
D. Boolean
48.Q) A programmer writes an efficient program to add
two upper triangular 10X10 matrices with the elements
on the diagonals retained. How many total additions
will the program make?

A. 100
B. 55
C. 25
D. 10
49.Q) A problem to be solved is broken into a
sequence of smaller sub-problems until a stage
where the sub-problem can be easlved. What is
this design approach called?

A. Top-Down approach
B. Bottom-Up approach
C. Procedural programming
D. None of the above
50.Q)Consider an array on which bubble sort is
used. To which of the following elements will
the bubble sort compare the element A[X] with,
in a single iteration?

A. A[x + 1]
B. A[x + 2]
C. A[x + 2x]
D. All of the above

Choose the correct answer.


51.Q) A programmer is making a daaase of
animais in a zoo along with their properties.
The possible animals are dog, lion and zebra.
Each one has attributes herbivors, colorand
nocturnal. The programmer uses the object-
oriented programming paradigm for this. How
will the system be conceptualized?

A. Class: Animal; objects: dog, lion and zebra;


data members: herbivorous, color and
nocturnal
B. Class: Animal; objects: herbivorous, color
and nocturnal; data members: dog, lion and
zebra
C. Class: dog, lion and zebra; objects: Animal;
52.Q) A programmer writes a program to find
an element in the array A[5] with the elements:
8:30 40 45 70. The program is run to find a
number “X”, that is found in the first iteration
of binary search. What is the value of “X”?

A. 40
B. 8
C. 70
D. 30

Choose the correct answer.


53.Q) A stack is implemented as a linear array A[0…N-1]. A
programmer writes the function given below to pop out an
element from the stack.
function POP( top,N )
{
if (X)
{
top = top -1
}
else
{
print”Underflow”
}
return top
}
Which of the following should substitute the condition “X”?

A. top<N-1
B. top<N
C. top>1
D. top>=0
54.Q) What is the difference between a function
and a method?

A. Function is a named code unlike method


which is a part of an object
B. Function contained in an object is called a
method
C. Function cannot change variables outside its
scope unlike method
D. There is no difference between the two

Choose the correct answer.


55.Q) Which of the following is the lowest level format to which the
computer converts a program in a higher language before execution?
A. English code
B. Machine code
C. Assembly language
D. System language
Passage
class brush
{
private:
integer size, c
rcode
function getdata( ) { …. }// Statement 1
public:
integer name // Statement 2
function putdata( ) { …. }
}
function main
{
brush b1, b2
print b1.name //Statement 3
b2.getdata( ) //Statement 4
}
Choose the correct answer.
56.Q) Refer to the pseudocode given in the
‘Passage’. The code is similar to that in C++ and
is self-explanatory. An accessible member
Funcction and a data member for an object are
accessed by the statements objectname.
Functionname and objectname.
Datamemnername, respectively. Which
statement should be deleted from the code to
rectify the error in it?

A. Statement 1
B. Statement 2
C. Statement 3
D.Statement 4
57.Q) A developer writes the program given below to
print the sum of the squares of the first five whole
numbers(0…4). Is the program correct? If not, which
statement should be modified to correct the program?
integer i = 0 // Statement 1
integer sum = 0 // Statement 2
while (i<5) // Statement 3
{
sum = i*i // Statement 4
i = i + 1 // Statement 5
}
print sum // statement 6
A. No error, the program is correct
B. Statement 1
C. Statement 4
D. Statement 6

Choose the correct answer.


58.Q) The program to print the sum of all cubes that lie
between 0 and 100 is given below. Does this program
have an error? If yes, which statement should be
modified to correct the program?
integer i = 0, a // Statement 1
integer sum = 0;
a = (i * i *i)
while (i<100) // Statement 2
{
sum = sum + a // Statement 3
i=i+1
a = (i * i * i) // Statement 4
}
print sum
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
Passage
integer i = 1 // Statement 1
while (i<= 3 )
{
int j // Statement 2
while ( j<= i ) // Statement 3
{
print j
print blank space
j = j + 1 // Statement 4
}
print end-of-line //takes the cursor to the next line
i=i+1
}
Choose the correct answer.
59.Q) A programmer writes the program given
in the ‘Passage’ to print the following pattern
on the screen:
1
12
123
Will this program function properly? If not,
which statement should be modified?
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. This program will function properly
60.Q) What is the output of the program given below?
integer i = 0, j
while (i<2 )
{
j = 0;
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
}
A. 0
03
B. 0 3
036
C. 0
036

Choose the correct answer.


61.Q) An Array MyArr with 10 rows and 15
columns is stored in a row major fashion in the
memory. Given that the starting address of
MyArr is 1000 and each element’s size is 1, find
the address of MyArr[6][11]. (Assume the lower
bounds on columns and rows of this Array as 1
and 1 respectively)

A. 1105
B. 1060
C. 1160
D. 1085
62.Q) What is implied by the argument of a
function?

A. The variables passed to the function when


it is called
B. The value that the function returns on
execution
C. The execution code inside function
D. Return type of the function
63.Q) How many nodes a full binary tree with
“n” leaves contain?

A. 2n + 1 nodes
B. log 2n nodes
C. 2n – 1 nodes
D. 2n nodes

Choose the correct answer.


64.Q)A sorting mechanism uses the binary tree
concept such that any number in the tree is
larger than all the numbers in the sub-tree
below it. What is this method called?

A. Selection sort
B. Insertion sort
C. Heap sort
D. Quick sort

Choose the correct answer.


65.Q) Preeti writes a program in low level
language, now she wants to translate it into a
higher language without rewriting the program.
What another program she must use for this
purpose?

A. Compiler
B. Decompiler
C. Interpreter
D. Executer
E. Cross compiler
66.Q)A programmer prepares a questionnaire
with “true or false” type of questions. He wants
to define a data type that stores the responses
of the candidates for the questions. Which of
the following is the most suited data type for
this purpose?

A. Integer
B. Boolean
C. Float
D. Character
67.Q) Which of the following is NOT a data type?

A. Integer
B. Character
C. Boolean
D. Array

Choose the correct answer.


68.Q)What is the maximum number of edges in
an undirected graph with “n” vertices?

A. n*(n-1)/2
B. n*(n+1)/2
C. n*n
D. 2*n

Choose the correct answer.


69.Q)Which of the following data structures
may produce an overflow error even though
the current number of elements in it lower
than its size?

A. A queue implemented in a linear array


B. A queue implemented in a circularly
connected array
C. A stack implemented in a linear array
D. None of the above
70.Q) X and Y are asked to write a program to sum the
rows of a 2X2 matrix stored in an array A.
X writes the code (Code A) as follows:
For n = 0 to 1
sumRow1 [n] = A[n][1] + A[n][2]
end
Y writes the code (Code b) as follows:
Sum Row1[0] =A[0][1] + A[0][2]
Sum Row1[1] = A[1][1] + A[1][2]
Which of the following statements is correct about
these codes if no loop unrolling is done by the compiler?

A. Code A would execute faster than Code B.


B. Code B would execute faster than Code A.
C. Code A is logically incorrect.
D. Code B is logically incorrect.

Choose the correct answer.


71.Q)A programmer tries to debug a code of
10,000 lines. It is known that there is a logical
error in the first 25 lines of the code. Which of
the following is an efficient way to debug the
code?

A. Compile the entire code and check it line by


line.
B. Use an interpreter on the first 25lines of
code.
C. Compile the entire code and run it.
D. None of the above can be used to debug the
code.
72.Q) For the given list of numbers, how many
awaps will take place in Bubble Sort so that the
list becomes sorted?
(Assume that the list is being sorted in
ascending order)
List 23, 56, 78, 3, 11, 65

A. 4
B. 5
C. 6
D. 7
73.Q) Which of the following sorting algorithms
yields approximately the same worst-case and
average-case running time behavior in O(n
logn)?

A. Bubble sort and Selection sort


B. Heap sort and Merge sort
C. Quick sort and Radix sort
D. Tree sort and Median-of-3 Quick sort
74.Q) A programmer writes a sorting algorithm
that takes different 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 the
magnitude in the two lists 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.
75Q) A programmer is making a dase of
animais in a zoo along with their properties.
The possible animals are dog, lion and zebra.
Each one has attributes herbivors, colorand
nocturnal. The programmer uses the object-
oriented programming paradigm for this. How
will the system be conceptualized?
A. Class: Animal; objects: dog, lion and zebra;
data members: herbivorous, color and
nocturnal
B. Class: Animal; objects: herbivorous, color
and nocturnal; data members: dog, lion and
zebra
C. Class: dog, lion and zebra; objects: Animal;
data members: herbivorous, color and
76Q) Which of the following gives the
maximum number of nodes at level :I’ of a
binary tree?
(Note: The root is at level 1.)

A. 2 I-1
B. 3 I-1
C. 2I
D. 2I -1
Passage
Integer num 1, num2
Input num1, num2
Integer k=0, final=num1
//missing statements
Print final
Choose the correct answer:
A pseudo-code is used which is self explanatory.
//in pseudo code refers to comment
77.Q)Reema wanted to multiply two numbers but the * key of her
keyboard is broken. She decides to write the program without
using * operator. She writes the given code, where some
statements are missing.
What should be the missing statements in the given code?
A. While(k++ < num1)
final+=num1
B. While(k++ < num2-1)
final+=num1
C. While(k++ < num2)
final+=num1
D. While(k++ < num2)
final+=num2
78Q) The program to print the sum of all cubes that lie between 0
and 100 is given below. Does this program have an error? If yes,
which statement should be modified to correct the program?
integer i = 0,a // Statement 1
integer sum = 0;
a = (i * i * i)
while (1<100) // Statement 2
{
sum = sum + a // Statement 3
i=i+1
a = (i * i * i ) // Statement 4
}
printsum

A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. No error

Choose the correct answer.


79.Q) For which of the following is the stack
implementation useful?

A. Radix search
B. Breadth first search
C. Recursion
D. None of the above

Choose the correct answer.


80Q) A developer writes the program given below to
print the sum of the squares of the first five whole
numbers(0…4). Is the program correct? If not, which
statement should be modified to correct the program?
integer i = 0 // Statement 1
integer sum = 0 // Statement 2
while (i<5) // Statement 3
{
sum = i*i // Statement 4
i = i + 1 // Statement 5
}
print sum // statement 6

A. No error, the program is correct


B. Statement 1
C. Statement 4
D. Statement 6
Choose the correct answer.
81.Q) Which of the following data structures
may produce an overflow error even though
the current number of elements in it lower
than its size?

A. A queue implemented in a linear array


B. A queue implemented in a circularly
connected array
C. A stack implemented in a linear array
D. None of the above
Choose the correct answer.
82.Q)Which tree (s) from the given figure is/are Heap(s)?
A. Only 1
B. Only 2
C. Only 3
D. Both 1 and 2
E. Both 1 and 3
82.Q)Which tree (s) from the given figure is/are
Heap(s)?

A. Only 1
B. Only 2
C. Only 3
D. Both 1 and 2
E. Both 1 and 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy