201 Data Structures Exams Trial
201 Data Structures Exams Trial
Level 200
Registration Number:
Instructions: answer the following questions by encircling the single best answer,
1. What kind of data structure allows retrieval in the same order as insertion?
A. Array
B. Stack
C. Queue
D. Priority Queue
2. The numbers 9, 8, 4, 3, and 5 are inserted into a data structure in that order. An
item in deleted using only a basic data structure operation. If the deleted item is 5,
the data
structure cannot be a....
A queue
B. stack
C. tree
D. hash table
B. the size of the structure and the data in the structure are constantly changing
Consider the unsorted array, using bubble sort method; sort the array 7, 14,
12, 33, 5, 19.
A first position
B. last position
D. second position
5. Which of the following represent the array after the first pass?
(i) by this way computer can keep track only the address of the first element and
the addresses of other element can be calculated.
(ii) the architecture of the computer memory does not allow arrays to store other
than serially
A. (i) only
B. (ii) only
7. In Fig.1 below, choose the option A-D which satisfies post order traversal.
A. [31, 25, 47, 42, 50]
8. In Fig. I above, choose the option A-D which satisfies pre-order traversal.
A. 3
B. 4
C. 2
D. 1
10. What is the disadvantage of selection sort?
B. It is not scalable
11. Given an array of 6 elements: [15, 19, 10, 7, 17, 16] sort it in ascending order
using heap sort.
12. In a max-heap, element with the greatest key is always in the .....
A. leaf node
D. root node
A. linked list
B. stack
14. In the given array arr = [3,4,5,2,1]. The number of iterations (passes) in bubble
sort and selection sort respectively are......
A. 2 and 5
B. 4 and 5
C. 2 and 4
D. 5 and 4
B. It is not scalable
D. It is scalable
16. Which of the following traversal techniques list the nodes of a binary search
tree in ascending order?
B. In order only
C. 0 or 1 or 2
D. 0 or 1
C. have to know the maximum number of nodes possible before creation of trees
D. it is difficult to implement
i. Easy to implement
A. (1) only
B. (ii) only
A. (i) only
22. Which of the following property is NOT true about linked list?
23. What is the minimum number of queues needed to implement the priority
queue?
A. One
B. Two
C. Zero
D. Three
24. There are 8, 15, 13, and 14 nodes in 4 different trees. Which one of them can
form a full binary tree?
A. 8
B. 15
C. 13
D. 14
(i) Queues
(iii) Stacks
A. (i) only
C. (ii) only
(i) when we want to insert data into a data structure that is full
(ii) When we want to insert data into a data structure that is empty
(iii) When we want to delete data from a data structure that is full
(iv) When we want to delete data from a data structure that is empty
A. (i) only
B. (ii) only
D. (iv) only
A. (i) only
B. (ii) only
D. (iv) only
29. A normal queue, if implemented using an array of size N, gets full when
A. Rear = N-1
C. Front = rear +1
D. Rear = front
B. easier computations
D. complex computations
31. A linear list of elements in which deletion can be done from one end (front)
and insertion can take place only at the other end (rear) is known as a ...
A. queue
B. stack
C. tree
D. linked list
C. Ordered array
D. Linear tree
33. The dequeue process removes data from the front of the single ended queue
A. True
B. False
34. The enqueue operation adds a node at the front of the linked list.
A. True
B. False
A. True
B. False
36. A Linked list best suited for problems requiring a sequence in which the
maximum number of elements is known up front.
A. True
B. False
37. An array is a better choice when the size of a sequence or list needs to change
after it has been created.
A. True
B. False
38. The height of a tree does NOT play any crucial role in determining the
performance of search algorithms
A. True
B. False
39. Item in priority queue can jump to the front of the line if they have priority.
A. True
B. False
A. True
B. False
SECTION B
Instruction:
Answer Question 1 and any other one (1) question from this section
QUESTION 1
a. Create Binary Search Tree (BST) for the following data: 50, 25,75, 22, 40, 60,
80, 90, 15, 30
C. Which traversal method would you apply to a binary search tree, to be able to
print numbers in ascending order? Explain.
d. Write down the order in which an In-order traversal processes elements of the
binary search tree in Fig. 2 below.
f. The five items: A,B,C,D and E are pushed in stack, one after the other starting
from A. The stack is popped four items and each element is inserted in a queue.
Then two elements are deleted from the queue and pushed back on the stack. Now
one item is popped from the stack. What is the popped item?
QUESTION 2
b. How many elements are there in a full binary tree with height 4? Explain?
e. List two (2) disadvantages of arrays and two (2) disadvantages of linked list.
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬
SOLUTION
QUESTION 1
a. In BST the right subtree is greater than the root node which is great than the left
subtree
[R>N>L]
After sorting, the numbers will be [15, 22, 25, 30, 40, 50, 60, 75, 80, 90 ]
b. Post order traversal is visiting each nodes of a binary tree / binary search tree
once by visiting the left node first and then the right node and finally the root node.
c. In order traversal. Since in binary search tree, the left node is smaller than the
root node which is smaller than the right node, visiting the left node first and then
the root node before the right node will give you an arrangement in ascending
order.
e. In every subtree, the right node is greater than the root node which is greater
than the left node
f. Stack = [A, B, C, D, E]
This is because stack follows the First in Last Out property and queue follows
the First In First Out property.
QUESTION 2
Stack Queue
4 Stacks are based on the LIFO principle, i.e., Queues are based on the
the element inserted at the last, is the first FIFO principle, i.e., the
element to come out of the list. element inserted at the
first, is the first element to
come out of the list.
5 Insertion and deletion in stacks takes place Insertion and deletion in
only from one end of the list called the top. queues takes place from
the opposite ends of the
list. The insertion takes
place at the rear of the list
and the deletion takes
place from the front of the
list.
b. For a full tree of height 4, the total number of elements will be:
Let height = h = 4
= (2(4+1)) - 1
= 2⁵ - 1
= 32 - 1
= 31.
The root node take one and there would be 15 pairs which will give you 30
d.
QUESTION 3
This is because using the top - down approach, the elements have to be swapped
until they are ordered.
b. A complete binary tree is a binary tree which have all levels completely filled
except the right side of the last level. All leaves lean to the left.
c. 4
d. Array uses index to find elements. The process uses multiplication and addition.
These two operations have constant time, hence giving array a constant access time.
e. Disadvantages of array
1. It's static
3. Hard to manipulate