MIDTERM EXAMINATION
Spring 2010
CS301- Data Structures
Question No: 1 ( M a r k s: 1 ) http://vuzs.net
A subscript of an array may be an integer or an integer expression.
► True
► False
Question No: 2 ( M a r k s: 1 ) http://vuzs.net
Doubly Linked List always has one NULL pointer.
► True
► False
Question No: 3 ( M a r k s: 1 ) http://vuzs.net
In which of the traversal method, the recursive calls can be used to traverse a binary tree ?
► In preorder traversal only
► In inorder traversal only
► In postorder traversal only
► All of the given options
Question No: 4 ( M a r k s: 1 ) http://vuzs.net
A tree is an AVL tree if
► Any one node fulfills the AVL condition
► At least half of the nodes fulfill the AVL condition
► All the nodes fulfill the AVL condition
► None of the given options
Question No: 5 ( M a r k s: 1 ) http://vuzs.net
Suppose currentNode refers to a node in a linked list (using the Node class with member variables called data and nextNode). What boolean expression will be true when cursor refers to the tail node of the list?
► (currentNode == null)
► (currentNode->nextNode == null)
► (nextNode.data == null)
► (currentNode.data == 0.0)
Question No: 6 ( M a r k s: 1 ) - Please choose vuzs one
Suppose that the class declaration of SomeClass includes the following function prototype.
bool LessThan( SomeClass anotherObject );
Which of the following tests in the client code correctly compares two class objects alpha and beta?
► if (alpha < beta)
► if (alpha.LessThan(beta))
► if (LessThan(alpha, beta))
► if (LessThan(alpha).beta)
Question No: 7 ( M a r k s: 1 ) http://vuzs.net
In C what is the operation that you can not do with primitive types?
► Assign a value to primitive type using a literal
► Declare primitive types to be constant using the Const keyword
► Create a new instance of primitive type with New keyword
► None of these
Question No: 8 ( M a r k s: 1 ) http://vuzs.net
The operation for adding an entry to a stack is traditionally called :
► add
► append
► insert
► push
Question No: 9 ( M a r k s: 1 ) http://vuzs.net
The operation for removing an entry from a stack is traditionally called:
► delete
► peek
► pop
► remove
Question No: 10 ( M a r k s: 1 ) http://vuzs.net
Consider the following sequence of push operations in a stack:
stack.push(’7’);
stack.push(’8’);
stack.push(’9’);
stack.push(’10’);
stack.push(’11’);
stack.push(’12’);
► 7 8 9 10 11 12
► 9 8 11 10 7 12
► 9 10 8 11 12 7
► 9 10 8 12 7 11
Question No: 11 ( M a r k s: 1 ) http://vuzs.net
________ is the maximum number of nodes that you can have on a stack-linked list ?
► Zero
► 2n (where n is the number of nodes in linked list)
► Any Number
► None of these
Question No: 12 ( M a r k s: 1 ) http://vuzs.net
Which of the following can be used to reverse a string value,
► Stack
► Queue
► Both of these
► None of these
Question No: 13 ( M a r k s: 1 ) http://vuzs.net
Consider the following tree,
How many leaves does it have?
► 2
► 4
► 6
► 9
Question No: 14 ( M a r k s: 1 ) http://vuzs.net
AVL Tree is,
► Non Linear data structure
► Linear data structure
► Hybrid data structure (Mixture of Linear and Non Linear)
► None of the given options.
Question No: 15 ( M a r k s: 1 ) http://vuzs.net
The following are statements related to queues.
(i) The last item to be added to a queue is the first item to be removed
(ii) A queue is a structure in which both ends are not used
(iii) The last element hasn’t to wait until all elements preceding it on the queue are removed
(iv)A queue is said to be a last-in-first-out list or LIFO data structure.
Which of the above is/are related to normal queues?
► (iii) and (ii) only
► (i), (ii) and (iv) only
► (ii) and (iv) only
► None of the given options
Question No: 16 ( M a r k s: 1 ) http://vuzs.net
An array is a group of consecutive related memory locations.
► True
► False
Question No: 17 ( M a r k s: 1 )
In which of traversal method, recursion can not be applied.?
Question No: 18 ( M a r k s: 1 )
What is meant by an empty stack?
Question No: 19 ( M a r k s: 2 )
Is the following statement correct? If your answer is No, then correct it.
“A tree is an AVL tree if at least half of the nodes fulfill the AVL condition”
Question No: 20 ( M a r k s: 3 )
The following function is performing some operation on the elements of a singly link list please tell what this functions is doing,
void LinkList::mystery(){
Node * temp = headNode;
int result = 0;
while( temp->getNext() != NULL ){
temp = temp->getNext();
int value = temp->get();
if(value % 2 == 0)
{ value ++;
temp->set(value);
}
}
}
Question No: 21 ( M a r k s: 5 )
See the code below , give comments against each line and identify which line will result in error?
1. void main(void)
2. {
3. int actual = 123;
4. int &other = actual;
5.
6. int natural = 456;
7. other = ♮
8. }
Question No: 22 ( M a r k s: 10 )
Draw AVL Tree by following digits 78, 21, 25, 28, 38, 36, 75 and also perform necessary rotation, while showing all the intermediate trees being created in the process. In each stage, the AVL transformation should be conducted at a discrepancy that is farthest from the root.