# 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 II

### Explanation

Quick sort divides the list using pivot and then sorts in recursive manner. It uses divide and conquer approach.

Q 2 - Which of the following asymptotic notation is the worst among all?

A - Ο(n+9378)

B - Ο(n3)

C - nΟ(1)

D - 2Ο(n)

### Explanation

Ο(n+9378) is n dependent

Ο(n3) is cubic

nΟ(1) is polynomial

2Ο(n) is exponential

Q 3 - The following formular is of

`left_subtree (keys)  ≤  node (key)  ≤  right_subtree (keys)`

A - Bianry Tree

B - Complete Binary Tree

C - Binary Search Tree

D - All of the above

### Explanation

A binary search tree (BST) is a tree in which all nodes follows the below mentioned properties −

• The left sub-tree of a node has key less than or equal to its parent node's key.

• The right sub-tree of a node has key greater than or equal to its parent node's key.

Q 4 - Travelling salesman problem is an example of

A - Dynamic Algorithm

B - Greedy Algorithm

C - Recursive Approach

D - Divide & Conquer

### Explanation

Travelling salesman is an example of greedy algorithm. Greedy algorithms tries to find localized optimum solution which may eventually land in globally optimized solutions.

### Explanation

Floyd-Warshall's All pair shortest path Algorithm uses dynamic programming approach. All other mentioned algorithms use greedy programming approach

Q 6 - Which of the following searching techniques do not require the data to be in sorted form

A - Binary Search

B - Interpolation Search

C - Linear Search

D - All of the above

### Explanation

Both binary and interpolation search requires data set to be in sorted form. Linear search can work even if the data is not sorted.

Q 7 - Minimum number of spanning tree in a connected graph is

A - n

B - nn - 1

C - 1

D - 0

### Explanation

Every connected graph at least has one spanning tree.

Q 8 - Visiting root node after visiting left and right sub-trees is called

A - In-order Traversal

B - Pre-order Traversal

C - Post-order Traveral

### Explanation

In Post-order traversal method, the root node is visited last, hence the name.

Q 9 - Binary search tree has best case run-time complexity of Ο(log n). What could the worst case?

A - Ο(n)

B - Ο(n2)

C - Ο(n3)

D - None of the above

### Explanation

In case where binary search tree is left or right intended, the worst case can be Ο(n)

Q 10 - The minimum number of edges required to create a cyclid graph of n vertices is

A - n

B - n - 1

C - n + 1

D - 2n

### Explanation

To make a graph cyclic, the number of edges should be at least equal to vertices in the graph.

Q 11 - Maximum degree of any vertex in a simple graph of vertices n is

A - 2n - 1

B - n

C - n + 1

D - n - 1

### Explanation

In a simple graph, a vertex can have edge to maximum n - 1 vertices.

Q 12 - What could be the worst case height of an AVL tree?

A - 0.97 log n

B - 2.13 log n

C - 1.44 log n

D - n2 log n

### Explanation

Worst case height of an AVL tree is 1.44 log n

### Explanation

All given options are true about insertion sort.

Q 14 - Which of the following algorithm is not stable?

A - Bubble Sort

B - Quick Sort

C - Merge Sort

D - Insertion Sort

### Explanation

Among the given, only quick sort is not stable that is it may re-arrange the already sorted items.

Q 15 - If the array is already sorted, which of these algorithms will exhibit the best performance

A - Merge Sort

B - Insertion Sort

C - Quick Sort

D - Heap Sort

### Explanation

Insertion sort, as it should then work in linear way.

Q 16 - Which of the following is example of in-place algorithm?

A - Bubble Sort

B - Merge Sort

C - Insertion Sort

D - All of the above

### Explanation

Only Merge sort requires extra space.

### Explanation

As trees do not have loops, they are easier to traverse.

Q 18 - Which method can find if two vertices x & y have path between them?

A - Depth First Search

C - Both A & B

D - None A or B

### Explanation

By using both BFS and DFS, a path between two vertices of a connected graph can be determined.

Q 19 - Time complexity of Depth First Traversal of is

A - Θ(|V|+|E|)

B - Θ(|V|)

C - Θ(|E|)

D - Θ(|V|*|E|)

### Explanation

Using Depth First Search, we traverse the whole graph i.e. visiting all Vertices and Edges.

### Explanation

An algorithm is a step by step procedure to solve a computer problem.

Q 21 - Apriory algorithm analysis does not include −

A - Time Complexity

B - Space Complexity

C - Program Complexity

D - None of the above!

### Explanation

Algorithms are independent of programming languages, hence, program complexity is not a part of algorithm analysis.

Q 22 - Which of the below given series is Non-Increasing Order −

A - 1, 3, 4, 6, 8, 9

B - 9, 8, 6, 4, 3, 1

C - 9, 8, 6, 3, 3, 1

D - 1, 3, 3, 6, 8, 9

### Explanation

A sequence of values is said to be in non-increasing order, if the successive element is less than or equal to its previous element in the sequence.

Q 23 - Which of the following has search effeciency of Ο(1) −

A - Tree

B - Heap

C - Hash Table

### Explanation

A simple hash table has the Ω(1) efficiency.

### Explanation

In one iteration of Bubble sort, the maximum of the set in hand is moved at the end of the unsorted list. Hence one less comparison.

### Explanation

Recursion is just an other way to write the same program code. But calling a function again and again makes it expensive in terms of memory, CPU cycles and delivers less performance.

1 D
2 B
3 C
4 B
5 C
6 A
7 C
8 C
9 A
10 A
11 D
12 C
13 D
14 B
15 B
16 B
17 C
18 C
19 A
20 C
21 C
22 C
23 C
24 A
25 D