Beruflich Dokumente
Kultur Dokumente
PK
MIDTERM EXAMINATION
Spring 2010
CS301- Data Structures
Ref No: 1128537
Time: 60 min
Marks: 38
In the statement int x[6]; , we cannot assign any value to x because x is not an lvalue.
► True
► False
► ab+c*d-
► abc*+d-
► abc+*d-
► abcd+*-
► int &x ;
► int *x ;
► int x ;
► selpa
► selppa
► apples
► aaappppplleess
In the following C++ code, how many function calls are made?
int x, y, z;
x = 2;
y = 3 + x;
z = foobar(x,y);
►1
►4
►7
►8
Question No: 8 ( Marks: 1 ) - Please choose one
► Front
► Rear
► None of these
►8
►7
►5
►6
►5
►6
►7
►8
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
► A complete binary tree of depth d is a binary tree that contains 2 L Nodes at each level
L between 0 and d, both inclusive.
► The total number of nodes (Tn ) in a complete binary tree of depth d is 2 d+1 - 1 .
► The height of the complete binary tree can be written as h = log 2 (Tn+1)-1 where Tn is
Total number of Nodes.
(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.
The________ method of list data structure removes the element residing at the
current position.
► Add
► next
► remove
► find
it will be efficient to place stack elements at the start of the list because insertion and
removal take _______time.
► Variable
► Constant
► Inconsistent
Assume that numbers 1, 312, 8, 34, 11 are pushed on a stack, three numbers are popped,
then numbers 12, 44 are pushed on the stack, and one number is popped. What are the
final contents of the stack?
Ans:
11,34,8,44,12,312,1
Ans:
Ans:
11.2.15
In-order traversal:
11.15.2
Question No: 20 ( Marks: 3 )
The nodes of a binary tree have data 1, 2, 3, 4. The in-order traversal of the tree
yields 2,1,4,3. The postorder traversal is 2, 4, 3, 1. The root of the tree is at level 0.
Ans:
C(3)
Ans:
Write a recursive function that given a Binary Search Tree and a low and a high
value, prints all records (data values) in that Binary Search Tree that fall between
the two values ( Our function will print all those values which are between the low
and high value we will pass to that function).
For full credit, the function PrintRange should visit as few nodes as possible.
It's prototype is given below,
Suppose that the following is a balanced AVL tree. Insert a new node p into the tree. Then the
resulting tree may or may not remain balanced.
Ans:
int PrintRange(Node* root, int low, int high);
How many
(i) balanced;
(ii) unbalanced;