2.data Structures - CS301 Fall 2009 Mid Term Paper
2.data Structures - CS301 Fall 2009 Mid Term Paper
pk
MIDTERM EXAMINATION
Fall 2009
CS301- Data Structures (Session - 5)
Ref No: 885482
Time: 60 min
Marks: 38
► ab+c*d-
► abc*+d-
► abc+*d-
► (abc*)+d-
A Compound Data Structure is the data structure which can have multiple data
items of same type or of different types. Which of the following can be considered
compound data structure?
► Arrays
► LinkLists
►None of these
class foo
{
public:
void x(foo f);
void y(const foo f);
void z(foo f) const;
...
Which of the three member functions can alter the PRIVATE member variables of the foo
object that activates the function?
►Only x can alter the private member variables of the object that
activates the function.
►Only y can alter the private member variables of the object that
activates the function.
►Only z can alter the private member variables of the object that
activates the function.
►Two of the functions can alter the private member variables of the
object that activates the function.
► Stack
► Queue
► AVL Tree
►7 8 9 10 11 12
►9 8 11 10 7 12
►9 10 8 11 12 7
►9 10 8 12 7 11
►1
►2
► n (where n is the argument)
► There is no fixed maximum
void test_a(int n)
{
cout << n << " ";
if (n>0)
test_a(n-2);
}
►42
►024
►02
►24
Queue follows,
► None of these
_________ is a binary tree where every node has a value, every node's left subtree
contains only values less than or equal to the node's value, and every node's right subtree
contains only values that are greater then or equal ?
►Strictly Binary Tree
►Binary Search tree
►AVL tree
►All of these
Four statements about trees are below. Three of them are correct. Which one is
INCORRECT?
►Trees are recursively defined multi-dimensional data structures
►The order of a tree indicates a maximum number of childen allowed at
each node of the tree
►A search tree is a special type of tree where all values (i.e. keys) are
ordered
►If Tree1's size is greater than Tree2's size, then the height of Tree1 must
also be greater than Tree2's height.
Below is a binary search tree. If we delete the value 50 using the algorithm we discussed,
what value will be in the root of the remaining tree?
► 50
► 60
► 70
► 80
_________ is a data structure that can grow easily dynamically at run time without
having to copy existing elements.
► Array
► List
► Both of these
► None of these
Let’s call the node as a that requires re-balancing. Consider the two cases given
below:
1) An insertion into left subtree of the left child of a
2) An insertion into right subtree of the right child of a.
1) The insertion occurs outside (i.e., left-left or right-right) in cases 1 and 2. single
rotation can fix the balance in these two cases.
2) The insertion occurs inside ((i.e., left-left or right-right) in cases 1 and 2. single
rotation cannot fix the balance in these two cases
stack.push(’1’);
stack.push(’2’);
stack.push(’3’);
stack.push(’4’);
stack.push(’5’);
stack.push(’6’);
You can insert as many stack.pop()’s as you like in the above sequence of stack.push’s to
get a desired output. Which of the following cannot be an output?
A. 123456
B. 325416
C. 342561
D. 342615
E. 342165
Ans:
1. Linked lists do not need contiguous blocks of memory; extremely large data sets
stored in an array might not be able to fit in memory.
2. Linked list storage does not need to be preallocated (again, due to arrays needing
contiguous memory blocks).
3. Inserting or removing an element into a linked list requires one data update, inserting
or removing an element into an array requires n (all elements after the modified index
need to be shifted).
Array is a collection of same data type. In linked list there are two field one is address
and other is pointer. In array elements are arranged in a specific order
2. Why we can change the size of list after its creation when we can not do that in
simple arrays.
Some how the answer will be same as part 1 because Inserting or removing an element
into a linked list requires one data update, inserting or removing an element into an array
requires n (all elements after the modified index need to be shifted).
Array is a collection of same data type. The size of array is mentioned with its
declaration. in arrays the elements are in contiguous position. one must after another.
while in linked list we gave the address of next element in the next part of node.
Convert the following infix expression into postfix expressions using stack (Show
complete steps)
1-2 33-(4+5*6)*7
Step Post fix stack
1