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.

Questions and Answers

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

A - Ο(n2)

B - Ο(nlog n)

C - Ο(n3)

D - Ο(n)

Answer : D


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

Answer : C


Recursive procedures use stacks to execute the result of last executed procedural call.

Q 3 - Which of the following is an example of dynamic programming approach?

A - Fibonacci Series

B - Tower of Hanoi

C - Dijkstra Shortest Path

D - All of the above

Answer : D


All mentioned use dynamic programming approach. Before solving the in-hand sub-problem, dynamic algorithm will try to examine the results of previously solved sub-problems. The solutions of sub-problems are combined in order to achieve the best solution.

Q 4 - 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

Answer : A


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

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

A - Tree

B - Heap

C - Hash Table

D - Linked-List

Answer : C


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

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

A - size of array

B - pivot element

C - sequence of values

D - none of the above!

Answer : B


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

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

A - Ο(n), Ο(n)

B - Ο(n), Ο(1)

C - Ο(1), Ο(n)

D - Ο(1), Ο(1)

Answer : D


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

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

A - The stack will fall down.

B - Stack will rearranged items.

C - It will convert to LIFO

D - This operation is not allowed.

Answer : B


Stack can only be accessed from top of it.

Q 9 - A pivot element to partition unsorted list is used in

A - Merge Sort

B - Quick Sort

C - Insertion Sort

D - Selection Sort

Answer : B


The quick sort partitions an array using pivot element and then calls itself recursively twice to sort the resulting two subarray.

Answer : B


Efficiency of algorithm is measured by assuming that all other factors e.g. processor speed, are constant and have no effect on implementation.


E-Books Store