- Data Structures & Algorithms
- DSA - Home
- DSA - Overview
- DSA - Environment Setup
- Algorithm
- DSA - Algorithms Basics
- DSA - Asymptotic Analysis
- DSA - Greedy Algorithms
- DSA - Divide and Conquer
- DSA - Dynamic Programming
- Data Structures
- DSA - Data Structure Basics
- DSA - Data Structures and Types
- DSA - Array Data Structure
- Linked Lists
- DSA - Linked List Basics
- DSA - Doubly Linked List
- DSA - Circular Linked List
- Stack & Queue
- DSA - Stack
- DSA - Expression Parsing
- DSA - Queue
- Searching Techniques
- DSA - Linear Search
- DSA - Binary Search
- DSA - Interpolation Search
- DSA - Hash Table
- Sorting Techniques
- DSA - Sorting Algorithms
- DSA - Bubble Sort
- DSA - Insertion Sort
- DSA - Selection Sort
- DSA - Merge Sort
- DSA - Shell Sort
- DSA - Quick Sort
- Graph Data Structure
- DSA - Graph Data Structure
- DSA - Depth First Traversal
- DSA - Breadth First Traversal
- Tree Data Structure
- DSA - Tree Data Structure
- DSA - Tree Traversal
- DSA - Binary Search Tree
- DSA - AVL Tree
- DSA - Red Black Trees
- DSA - B Trees
- DSA - B+ Trees
- DSA - Splay Trees
- DSA - Spanning Tree
- DSA - Tries
- DSA - Heap
- Recursion
- DSA - Recursion Basics
- DSA - Tower of Hanoi
- DSA - Fibonacci Series
- DSA Useful Resources
- DSA - Questions and Answers
- DSA - Quick Guide
- DSA - Useful Resources
- DSA - Discussion

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# 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

Q 1 - Quick sort algorithm is an example of

### Answer : D

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

### Answer : B

### Explanation

Ο(n+9378) is n dependent

Ο(n^{3}) 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)

### Answer : C

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

### Answer : B

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

Q 5 - Find the odd out

A - Prim's Minimal Spanning Tree Algorithm

B - Kruskal's Minimal Spanning Tree Algorithm

### Answer : C

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

### Answer : A

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

### Answer : C

### Explanation

Every connected graph at least has one spanning tree.

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

### Answer : C

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

### Answer : A

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

### Answer : A

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

### Answer : D

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

### Answer : C

### Explanation

Worst case height of an AVL tree is 1.44 log n

Q 13 - What is not true about insertion sort?

A - Exhibits the worst case performance when the initial array is sorted in reverse order.

B - Worst case and average case performance is Ο(n^{2})

C - Can be compared to the way a card player arranges his card from a card deck.

### Answer : D

### Explanation

All given options are true about insertion sort.

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

### Answer : B

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

### Answer : B

### Explanation

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

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

### Answer : B

### Explanation

Only Merge sort requires extra space.

Q 17 - Graph traversal is different from a tree traversal, because

### Answer : C

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

### Answer : C

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

### Answer : A

### Explanation

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

Q 20 - An algorithm is

A - a piece of code to be executed.

B - a loosely written code to make final code.

### Answer : C

### Explanation

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

Q 21 - Apriory algorithm analysis does not include −

### Answer : C

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

### Answer : C

### 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) −

### Answer : C

### Explanation

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

Q 24 - After each iteration in bubble sort

A - at least one element is at its sorted position.

### Answer : A

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

Q 25 - What about recursion is true in comparison with iteration?

A - very expensive in terms of memory.

C - every recursive program can be written with iteration too.

### Answer : D

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

# Answer Sheet

Question Number | Answer Key |
---|---|

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 |