CS301- Data Structures SOLVED MCQS & SUBJECTIVE FROM MIDTERM PAPERS 2014 December

CS301- Data Structures
SOLVED MCQS & SUBJECTIVE FROM MIDTERM PAPERS
December 2014

Virtual University of Pakistan
Bhakkar Campus (PBHK01) Pioneer College of Commerce Bhakkar




(1)        Here is the start of a class declaration: class Foo
{
public:
void x(Foo f);

void y(const Foo f); void z(Foo f) const;
...
Which of the three member functions can change the PRIVATE member variables of the Foo object that activates the function?

a.          Only x and y b.          Only x and z c.          Only y and z
d.          None of three the functions.
e.          All three functions.




(2)        What is the common pattern of writing class definitions?


a.          Member functions and member variables are both private.
b.         Member functions are private, and member variables are public.
c.          Member functions are public, and member variables are private.
d.         Member functions and member variables are both public.




(3)        The Bag ADT is like the List ADT. The Bag ADT does not store items in any particular
order and it allows duplicates. Suppose that the Bag class is efficiently implemented with a fixed array with a capacity of 4000. Insert appends the new item at the end of the array. Choose the best description of b’s member variables size (count of items in the bag) and data (the array that holds the actual items) after we execute these statements:

Bag b;
b. insert (5); b. insert (4); b.insert(6);

What will be the values of b.size and b.data after the statements?


a.          b.size is 3, b.data[0] is 4, b.data[1] is 5, b.data[2] is 6
b.         b.size is 3, b.data[0] is 5, b.data[1] is 4, b.data[2] is 6
c.          b.size is 3, b.data[0] is 6, b.data[1] is 4, b.data[2] is 5 d.  b.size is 3, b.data[0] is 6, b.data[1] is 5, b.data[2] is 4



(4)        Consider the following pseudo code:
declare a stack of characters
while ( there are more characters in the word to read ) {
read a character
push the character on the stack
}
while ( the stack is not empty ) { pop a character off the stack write the character to the screen
}
What is written to the screen for the input “carpets?
a. serc
b. carpets
c. steprac
d. ccaarrppeettss





(5)        In the linked list implementation of the stack class, where does the push member function place the new entry on the linked list?
a.         At the head
b.         At the tail
c.          After all other entries that are greater than the new entry. d.         After all other entries that are smaller than the new entry.



(6)        One difference between a queue and a stack is:
a.          Queues require dynamic memory, but stacks do not. b.     Stacks require dynamic memory, but queues do not.
c.          Queues use two ends of the structure; stacks use only one.
d.         Stacks use two ends of the structure, queues use only one.



I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into a NONEMPTY queue?
a.          Neither changes
b.         Only front pointer changes. c.    Only rear pointer changes. d.      Both change.



I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into an EMPTY queue?
a.          Neither changes
b.         Only front pointer changes. c.    Only rear pointer changes. Both change.




In a single function declaration, what is the maximum number of statements that may be recursive calls?
a.          1
b.          2
c.          n (where n is the argument)
There is no fixed maximum




What is the maximum depth of recursive calls a function may make?
a.          1 b.     2
c.          n (where n is the argument)
d.          There is no fixed maximum




In which location do dynamic variables reside?


a.          The code segment. b.          The data segment. c.          The heap.
d.          The run-time stack



Which of the following is true regarding the maze generation?
Select correct option:   Not Sure
Randomly remove walls until the entrance and exit cells are in the same set
Removing a wall is the same as doing a union operation
Do not remove a randomly chosen wall if the cells it separates are already in the same set
All of the given
Heap can be used to implement
Select correct option: Stack
Linked list
Queue
Priority Queue









No comments:

Post a Comment