Data Structures Algorithms Mock Test
This section presents you various set of Mock Tests related to Data Structures Algorithms. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Data Structures Algorithms Mock Test IV
Q 1 - Recursion uses more memory space than iteration because
A - it uses stack instead of queue.
Answer : B
Explanation
Recursion uses stack but the main reason is, every recursive call needs to be stored separately in the memory.
Q 2 - Heap is an example of
Answer : A
Explanation
Heap maintains itself to meet all the requirements of complete binary tree.
Q 3 - In a min heap
A - minimum values are stored.
B - child nodes have less value than parent nodes.
Answer : C
Explanation
In a min heap, parent nodes store lesser values than child nodes. The minimum value of the entire heap is stored at root.
Q 4 - In the deletion operation of max heap, the root is replaced by
A - next available value in the left sub-tree.
B - next available value in the right sub-tree.
Answer : D
Explanation
Regardless of being min heap or max heap, root is always replaced by last element of the last level.
Q 5 - All possible spanning trees of graph G
A - have same number of edges and vertices.
B - have same number of edges and but not vertices.
Answer : A
Explanation
All possible spanning trees of graph G, have same number of edges and vertices.
Q 6 - From a complete graph, by removing maximum _______________ edges, we can construct a spanning tree.
Answer : A
Explanation
We can remove maximum e-n+1
edges to get a spanning tree from complete graph. Any more deletion of edges will lead the graph to be disconnected.
Q 7 - If we choose Prim's Algorithm for uniquely weighted spanning tree instead of Kruskal's Algorithm, then
A - we'll get a different spanning tree.
B - we'll get the same spanning tree.
Answer : B
Explanation
Regardless of which algorithm is used, in a graph with unique weight, resulting spanning tree will be same.
Answer : B
Explanation
AVL rotations have complexity of Ο(log n)
Q 9 - A balance factor in AVL tree is used to check
B - if all child nodes are at same level.
Answer : D
Explanation
The balance factor (BalanceFactor = height(left-sutree) − height(right-sutree)) is used to check if the tree is balanced or unbalanced.
Q 10 - Binary search tree is an example of complete binary tree with special attributes.
A - BST does not care about complete binary tree properties.
B - BST takes care of complete binary tree properties.
Answer : A
Explanation
BST does not care about complete binary tree properties.
Q 11 - The following sorting algorithms maintain two sub-lists, one sorted and one to be sorted −
Answer : D
Explanation
Both selection sort and insertion sort maintains two sublists and then checks unsorted list for next sorted element.
Q 12 - If locality is a concern, you can use _______ to traverse the graph.
Answer : B
Explanation
DFS is a better choice when locality-wise items are concerned.
Q 13 - Access time of a binary search tree may go worse in terms of time complexity upto
Answer : C
Explanation
At maximum, BST may need to search all n values in the tree in order to access an element, hence, Ο(n).
Answer : A
Explanation
Shell sort uses insertion sort when interval value is 1.
Q 15 - A pivot element to partition unsorted list is used in
Answer : B
Explanation
The quick sort partitions an array using pivot element and then calls itself recursively twice to sort the resulting two subarray.
Q 16 - A stable sorting alrithm −
B - does not run out of memory.
Answer : C
Explanation
A stable sorting algorithm like bubble sort, does not change the sequence of appearance of similar element in the sorted list.
Q 17 - An adaptive sorting algorithm −
B - takes advantage of already sorted elements.
Answer : B
Explanation
A sorting algorithm is said to be adaptive, if it takes advantage of already 'sorted' elements in the list that is to be sorted.
Q 18 - Interpolation search is an improved variant of binary search. It is necessary for this search algorithm to work that −
A - data collection should be in sorted form and equally distributed.
B - data collection should be in sorted form and but not equally distributed.
C - data collection should be equally distributed but not sorted.
Answer : A
Explanation
For this algorithm to work properly the data collection should be in sorted form and equally distributed.
Q 19 - If the data collection is in sorted form and equally distributed then the run time complexity of interpolation search is −
Answer : D
Explanation
Runtime complexity of interpolation search algorithm is Ο(log (log n)) as compared to Ο(log n) of BST in favourable situations.
Q 20 - Which of the following algorithm does not divide the list −
Answer : A
Explanation
Linear search, seaches the desired element in the target list in a sequential manner, without breaking it in any way.
Q 21 - The worst case complexity of binary search matches with −
Answer : B
Explanation
In the worst case a binary search needs to access all elements of the target list, same as linear search.
Q 22 - Apriori analysis of an algorithm assumes that −
A - the algorithm has been tested before in real environment.
B - all other factors like CPU speed are constant and have no effect on implementation.
Answer : B
Explanation
Efficiency of algorithm is measured by assuming that all other factors e.g. processor speed, are constant and have no effect on implementation.
Q 23 - Aposterior analysis are more accurate than apriori analysis because −
A - it contains the real data.
B - it assumes all other factors to be dynamic.
Answer : B
Explanation
In this analysis, actual statistics like running time and space required, are collected.
Q 24 - Project scheduling is an example of
Answer : B
Explanation
Project scheduling is an exmaple of dynamic programming.
Q 25 - In conversion from prefix to postfix using stack data-structure, if operators and operands are pushed and popped exactly once, then the run-time complexity is −
Answer : B
Explanation
Infix to postfix conversion using stack will have run time complexity of Ο(n).
Answer Sheet
Question Number | Answer Key |
---|---|
1 | B |
2 | A |
3 | C |
4 | D |
5 | A |
6 | A |
7 | B |
8 | B |
9 | D |
10 | A |
11 | D |
12 | B |
13 | C |
14 | A |
15 | B |
16 | C |
17 | B |
18 | A |
19 | D |
20 | A |
21 | B |
22 | B |
23 | B |
24 | B |
25 | B |