# Data Structures Algorithms Online Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to **Data Structures Algorithms**. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using **Show Answer** button. You can use **Next Quiz** button to check new set of questions in the quiz.

Q 1 - What is the worst case run-time complexity of binary search algorithm?

### Answer : D

### Explanation

In the worst case, binary search will be left or right intended, making it compare all the n values.

Q 2 - What data structure can be used to check if a syntax has balanced paranthesis ?

### Answer : D

### Explanation

Stack uses LIFO method which is good for checking matching paranthesis.

Q 3 - Minimum number of moves required to solve a *Tower of Hanoi* puzzle is

### Answer : C

### Explanation

Minimum number of moves required to solve a Tower of Hanoi puzzle is 2^{n} - 1. Where n is the number of disks. If the number of disks is 3, then minimum number of moves required are 2^{3} - 1 = 7

Q 4 - 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 5 - 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 6 - 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 7 - 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 8 - 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 9 - 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.

Q 10 - 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.