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

Q 1 - What will be the running-time of Dijkstra's single source shortest path algorithm, if the graph G(V,E) is stored in form of adjacency list and binary heap is used −

### Answer : C

### Explanation

The runing time will be Ο(|E|+|V| log |V|) when we use adjacency list and binary heap.

Q 2 - How many swaps are required to sort the given array using bubble sort - { 2, 5, 1, 3, 4}

### Answer : A

### Explanation

There will be 3 swaps in first iteration and 1 swap in second iteration.

Q 3 - Match the following −

(1) Bubble Sort | (A) Ο(n) |

(2) Shell Sort | (B) Ο(n^{2}) |

(3) Selection Sort | (C) Ο(n log n) |

### Answer : B

### Explanation

Q 4 - In context with time-complexity, find the odd out −

A - Deletion from Linked List.

### Answer : D

### Explanation

Binary heap heapify operation has time-complexity of Ο(n), while other operations have time-complexity of Ο(1) only.

Q 5 - In binary heap, whenever the root is removed then the rightmost element of last level is replaced by the root. Why?

A - It is the easiest possible way.

B - To make sure that it is still complete binary tree.

### Answer : B

### Explanation

A binary heap (whether max or min) has to satisfy the property of complete binary tree at all times.

Q 6 - Time required to merge two sorted lists of size m and n, is

### Answer : B

### Explanation

The time required to merge two sorted list is Ο(m + n).

Q 7 - The number of binary trees with 3 nodes which when traversed in post order gives the sequence A,B,C is ?

### Answer : C

### Explanation

Five binary trees (of 3 nodes) are possible.

Q 8 - Quick sort running time depends on the selection of

### Answer : B

### Explanation

If the pivot element is balanced, quick sort running time will be less.

Q 9 - Which of the below given sorting techniques has highest best-case runtime complexity −

### Answer : B

### Explanation

Selection sort best case time complexity is Ο(n^{2})

Q 10 - Which of the below mentioned sorting algorithms are not stable?

### Answer : A

### Explanation

Except selection sort, all other soring algorithms are stable.

Q 11 - If queue is implemented using arrays, what would be the worst run time complexity of queue and dequeue operations?

### Answer : D

### Explanation

As queue is maintained by two separate pointers for queue and dequeue operations, the run time for both is Ο(1).

Q 12 - A queue data-structure can be used for −

### Answer : C

### Explanation

Queues can be used for limited resource allocation. For other operations, stacks are used.

Q 13 - The Θ notation in asymptotic evaluation represents −

### Answer : A

### Explanation

Θ represents average case. Ο represents worst case and Ω represents base case.

Q 14 - Which of these alogrithmic approach tries to achieve localized optimum solution −

### Answer : A

### Explanation

Greedy approach focuses only on localized optimum solution.

Q 15 - Which of the following uses memoization?

B - Divide and conquer approach

### Answer : C

### Explanation

Remembering the results of previously calculated solutions is called memoization.

Q 16 - Index of arrays in C programming langauge starts from

### Answer : A

### Explanation

Arrays, in C, starts from 0 which is mapped to its base address.

Q 17 - In doubly linked lists

A - a pointer is maintained to store both next and previous nodes.

B - two pointers are maintained to store next and previous nodes.

### Answer : B

### Explanation

One pointer variable can not store more than one address values.

Q 18 - `node.next -> node.next.next;`

will make

### Answer : A

### Explanation

After applying `node.next -> node.next.next;`

we will not have node.next stored anywhere if not explicitly mentioned.

### Answer : B

### Explanation

Linked lists has search complexity of Ο(n).

Q 20 - Which of the following is not possible with an array in C programming langauge −

### Answer : C

### Explanation

Array in C are static and cannot be shrinked or expanded in run-time.

Q 21 - In C programming, when we remove an item from bottom of the stack, then −

### Answer : B

### Explanation

Stack can only be accessed from top of it.

Q 22 - Program with highest run-time complexity is

### Answer : A

### Explanation

Tower of hanoi has the highest run time complexity

Q 23 - Tower of hanoi is a classic example of

### Answer : D

### Explanation

The recursive approach of tower of hanoi uses divide and conquer method.

Q 24 - Which of the following algorithm cannot be desiged without recursion −

### Answer : D

### Explanation

Every problem which can be solved using recursion can also be solved using iterations.

Q 25 - If there's no base criteria in a recursive program, the program will

### Answer : C

### Explanation

Without a base criteria and progressive approach, a recursion is just an infinite iteration.

# Answer Sheet

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

1 | C |

2 | A |

3 | B |

4 | D |

5 | B |

6 | B |

7 | C |

8 | B |

9 | B |

10 | A |

11 | D |

12 | C |

13 | A |

14 | A |

15 | C |

16 | A |

17 | B |

18 | A |

19 | B |

20 | C |

21 | B |

22 | A |

23 | D |

24 | D |

25 | C |