FINALTERM EXAMINATION
Spring 2010
CS301- Data Structures
Question No: 1 ( M a r k s: 1 ) http://vuzs.net
A solution is said to be efficient if it solves the problem within its resource constraints i.e. hardware and time.
► True
► False
Question No: 2 ( M a r k s: 1 ) http://vuzs.net
Which one of the following is known as "Last-In, First-Out" or LIFO Data Structure?
► Linked List
► Stack
► Queue
► Tree
Question No: 3 ( M a r k s: 1 ) http://vuzs.net
What will be postfix expression of the following infix expression?
Infix Expression : a+b*c-d
► ab+c*d-
► abc*+d-
► abc+*d-
► abcd+*-
Question No: 4 ( M a r k s: 1 ) http://vuzs.net
For compiler a postfix expression is easier to evaluate than infix expression?
► True
► False
Question No: 5 ( M a r k s: 1 ) http://vuzs.net
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 "apples"?
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 "apples"?
► selpa
► selppa
► apples
► aaappppplleess
Question No: 6 ( M a r k s: 1 ) http://vuzs.net
Consider the following function:
void test_a(int n)
{
cout << n << " ";
if (n>0)
test_a(n-2);
}
What is printed by the call test_a(4)?
► 4 2
► 0 2 4
► 0 2
► 2 4
Question No: 7 ( M a r k s: 1 ) http://vuzs.net
If there are N external nodes in a binary tree then what will be the no. of internal nodes in this binary tree?
► N -1
► N+1
► N+2
► N
Question No: 8 ( M a r k s: 1 ) http://vuzs.net
If there are N internal nodes in a binary tree then what will be the no. of external nodes in this binary tree?
► N -1
► N
► N +1
► N +2
Question No: 9 ( M a r k s: 1 ) http://vuzs.net
If we have 1000 sets each containing a single different person. Which of the following relation will be true on each set:
► Reflexive
► Symmetric
► Transitive
► Associative
Question No: 10 ( M a r k s: 1 ) http://vuzs.net
Which one of the following is NOT the property of equivalence relation:
► Reflexive
► Symmetric
► Transitive
► Associative
Question No: 11 ( M a r k s: 1 ) http://vuzs.net
A binary tree of N nodes has _______.
► Log10 N levels
► Log2 N levels
► N / 2 levels
► N x 2 levels
Question No: 12 ( M a r k s: 1 ) http://vuzs.net
The easiest case of deleting a node from BST is the case in which the node to be deleted ___________.
► Is a leaf node
► Has left subtree only
► Has right subtree only
► Has both left and right subtree
Question No: 13 ( M a r k s: 1 ) http://vuzs.net
If there are N elements in an array then the number of maximum steps needed to find an element using Binary Search is _______ .
► N
► N2
► Nlog2N
► log2N
Question No: 14 ( M a r k s: 1 ) http://vuzs.net
Merge sort and quick sort both fall into the same category of sorting algorithms. What is this category?
► O(nlogn) sorts
► Interchange sort
► Average time is quadratic
► None of the given options.
Question No: 15 ( M a r k s: 1 ) http://vuzs.net
If one pointer of the node in a binary tree is NULL then it will be a/an _______ .
► External node
► Root node
► Inner node
► Leaf node
Question No: 16 ( M a r k s: 1 ) http://vuzs.net
We convert the ________ pointers of binary to threads in threaded binary tree.
► Left
► Right
► NULL
► None of the given options
Question No: 17 ( M a r k s: 1 ) http://vuzs.net
If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT a
► Expression tree
► Threaded binary tree
► complete Binary tree
► Perfectly complete Binary tree
Question No: 18 ( M a r k s: 1 ) http://vuzs.net
What is the best definition of a collision in a hash table?
► Two entries are identical except for their keys.
► Two entries with different data have the exact same key
► Two entries with different keys have the same exact hash value.
► Two entries with the exact same key have different hash values.
Question No: 19 ( M a r k s: 1 ) http://vuzs.net
Suppose
that a selection sort of 100 items has completed 42 iterations of the
main loop. How many items are now guaranteed to be in their final spot
(never to be moved again)?
► 21
► 41
► 42
► 43
Question No: 20 ( M a r k s: 1 ) http://vuzs.net
Suppose
you implement a Min heap (with the smallest element on top) in an
array. Consider the different arrays below; determine the one that cannot possibly be a heap:
► 16, 18, 20, 22, 24, 28, 30
► 16, 20, 18, 24, 22, 30, 28
► 16, 24, 18, 28, 30, 20, 22
► 16, 24, 20, 30, 28, 18, 22
Question No: 21 ( M a r k s: 1 ) http://vuzs.net
Do you see any problem in the code of nextInOrder below:
TreeNode * nextInorder(TreeNode * p)
{
if(p->RTH == thread)
return( p->R );
else {
p = p->R;
while(p->LTH == child)
p = p->R;
return p;
}
}
► The function has no problem and will fulfill the purpose successfully.
► The function cannot be compile as it has syntax error.
► The function has logical problem, therefore, it will not work properly.
► The function will be compiled but will throw runtime exception immediately after the control is transferred to this function.
Question No: 22 ( M a r k s: 1 ) http://vuzs.net
Which of the following statement is correct about find(x) operation:
► A find(x) on element x is performed by returning exactly the same node that is found.
► A find(x) on element x is performed by returning the root of the tree containing x.
► A find(x) on element x is performed by returning the whole tree itself containing x.
► A find(x) on element x is performed by returning TRUE.
Question No: 23 ( M a r k s: 1 ) http://vuzs.n
Which of the following statement is NOT correct about find operation:
► It
is not a requirement that a find operation returns any specific name,
just that finds on two elements return the same answer if and only if
they are in the same set.
► One
idea might be to use a tree to represent each set, since each element
in a tree has the same root, thus the root can be used to name the set.
► Initially each set contains one element.
► Initially each set contains one element and it does not make sense to make a tree of one node only.
Question No: 24 ( M a r k s: 1 ) http://vuzs.net
In complete binary tree the bottom level is filled from ________
► Left to right
► Right to left
► Not filled at all
► None of the given options
Question No: 25 ( M a r k s: 1 ) http://vuzs.net
Here is an array of ten integers:
5 3 8 9 1 7 0 2 6 4
The array after the FIRST iteration of the large loop in a selection sort (sorting from smallest to largest).
► 0 3 8 9 1 7 5 2 6 4
► 2 6 4 0 3 8 9 1 7 5
► 2 6 4 9 1 7 0 3 8 5
► 0 3 8 2 6 4 9 1 7 5
Question No: 26 ( M a r k s: 1 ) http://vuzs.net
What requirement is placed on an array, so that binary search may be used to locate an entry?
► The array elements must form a heap.
► The array must have at least 2 entries.
► The array must be sorted.
► The array’s size must be a power of two.
Question No: 27 ( M a r k s: 2 )
Give one example of Hashing
Question No: 28 ( M a r k s: 2 )
How heap sort works to sort a set of data.
Question No: 29 ( M a r k s: 2 )
How we can implement Table ADT using Linked List
Question No: 30 ( M a r k s: 2 )
If we allow assignment to constants what will happen?
Question No: 31 ( M a r k s: 3 )
Explain the process of Deletion in a Min-Heap
Question No: 32 ( M a r k s: 3 )
Give any three characteristics of Union by Weight method.
Question No: 33 ( M a r k s: 3 )
"For smaller lists, linear insertion sort performs well, but for larger lists, quick sort is suitable to apply." Justify why?
Question No: 34 ( M a r k s: 5 )
Write down the C++ code to implement Insertion Sort Algorithm.
Question No: 35 ( M a r k s: 5 )
Consider the following Threaded Binary Tree,
You have to give the values that should be in the four variables given below, for the node 37
1. LTH (Left flag)
2. RTH (Right flag)
3. Left node pointer (->L)
4. Right node pointer (->R)
Question No: 36 ( M a r k s: 5 )
What is Disjoint Sets? Explain with an example.