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

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 ?

A - queue

B - tree

C - list

D - stack

Answer : D

Explanation

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

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 - Minimum number of spanning tree in a connected graph is

A - n

B - nn - 1

C - 1

D - 0

Answer : C

Explanation

Every connected graph at least has one spanning tree.

Q 5 - Which of the below given series is Non-Increasing Order −

A - 1, 3, 4, 6, 8, 9

B - 9, 8, 6, 4, 3, 1

C - 9, 8, 6, 3, 3, 1

D - 1, 3, 3, 6, 8, 9

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 6 - Match the following −

(1) Bubble Sort(A) Ο(n)
(2) Shell Sort(B) Ο(n2)
(3) Selection Sort(C) Ο(n log n)

A - 1 → A,  2 → B,  3 → C

B - 1 → B,  2 → C,  3 → A

C - 1 → A,  2 → C,  3 → B

D - 1 → B,  2 → A,  3 → C

Answer : B

Explanation

Answer : C

Explanation

Remembering the results of previously calculated solutions is called memoization.

Q 8 - Program with highest run-time complexity is

A - Tower of Hanoi

B - Fibonacci Series

C - Prime Number Series

D - None of the above

Answer : A

Explanation

Tower of hanoi has the highest run time complexity

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

Explanation

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

Q 10 - If the data collection is in sorted form and equally distributed then the run time complexity of interpolation search is −

A - Ο(n)

B - Ο(1)

C - Ο(log n)

D - Ο(log (log n))

Answer : D

Explanation

Runtime complexity of interpolation search algorithm is Ο(log (log n)) as compared to Ο(log n) of BST in favourable situations.

data_structures_algorithms_questions_answers.htm
Advertisements