# 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 - For a binary search algorithm to work, it is necessary that the array (list) must be

### Answer : A

### Explanation

As binary search divides the list and selects a the sub-list to extend search based on comparison of values, it becomes necessary that the array (list) must be in sorted form.

Q 2 - What data structure is used for breadth first traversal of a graph?

### Answer : A

### Explanation

Queue is used for breadth first traversal whereas stack is used for depth first traversal.

Q 3 - 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 4 - 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 5 - 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.

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