CS301- Data Structures
SOLVED MCQS &
SUBJECTIVE FROM MIDTERM PAPERS
December 2014
Virtual University of
Pakistan
Bhakkar Campus
(PBHK01) Pioneer
College of Commerce Bhakkar
Is it possible for
a member
function of a class
to activate another
member function of the
same class?
a. No.
b. Yes, but only public member functions.
c. Yes, but only private member functions.
d. Yes, both public and private member functions
can be activated within
another member function.
Consider this
class
definition:
class quiz
{
public:
quiz( ); int f( );
int g( ) const; private: double score;
};
Which functions can carry out an assignment score=1.0; to the private ember variable
score?
a. Both f and g can
carry out the assignment.
b. f can carry
out the assignment, but not
g.
c. g can carry out the
assignment, but not f.
d. Neither f nor g can carry out the assignment
In C++, when allocating an array of objects, what constructor is
used
to initialize all of the
objects in the array?
a. The automatic
copy
constructor.
b. The constructor specified at
the declaration.
c. The default constructor. d. None
of the above.
The list abstract
data type (ADT) is used to work with
ordered or unordered
sequence of
items such
as numbers or
strings. What of
the following
implementation
of list
ADT
is best to answer questions such as "What
is
the item at position
n?"
a. Lists implemented with
an array.
b. Doubly-linked lists.
c. Singly-linked lists.
d. Doubly-linked
or singly-linked lists are
equally best
Consider this
function declaration:
void quiz(int i)
{
if (i > 1)
{
quiz(i / 2);
}
cout << "*";
}
How many asterisks
are printed by the
function call quiz(5)?
a. 3
b. 4 c. 7 d. 8
e. Some
other number
Suppose T is
a binary tree with
14 nodes. What
is the
minimum possible depth
of T?
a. 0 b. 3 c. 4 d. 5
“Entries
in a
stack are Ordered". What is the
meaning of this statement?
a. A
collection of stacks can
be sorted.
b. Stack entries may be compared with
the < operation.
c. The entries must be stored in a linked list.
d. There is
a first entry, a second entry, and so on.
Which
of the following
applications may use a
stack?
a. A
parentheses balancing program.
b. Keeping track of local variables at run time.
c. In-order traversal of a binary tree.
d. All of the
above.
When the
compiler compiles
your program, how is a recursive call treated
differently than a
non-recursive function
call?
a. Parameters
are all treated as reference
arguments b. Parameters are
all treated as value
arguments
c. There is no duplication of local
variables
d. None
of the
above
No comments:
Post a Comment