Data Structures Algorithms Online Quiz


Advertisements


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 time complexity of linear search algorithm?

A - Ο(1)

B - Ο(n)

C - Ο(log n)

D - Ο(n2)

Answer : D

Explanation

Linear search scans sequentially to find the target value. The best case is Ο(1) and average and worst case is Ο(n). Worst case is when data is not in the list, and it has to scan all n elements.

Q 2 - A circular linked list can be used for

A - Stack

B - Queue

C - Both Stack & Queue

D - Neither Stack or Queue

Answer : C

Explanation

Both stack and queue data structure can be represented by circular linked-list.

Q 3 - The following formula will produce

Fn = Fn-1 + Fn-2

A - Armstrong Number

B - Fibonacci Series

C - Euler Number

D - Prime Number

Answer : B

Explanation

Fibonacci Series generates subsequent number by adding two previous numbers.

Q 4 - Which of the following searching techniques do not require the data to be in sorted form

A - Binary Search

B - Interpolation Search

C - Linear Search

D - All of the above

Answer : A

Explanation

Both binary and interpolation search requires data set to be in sorted form. Linear search can work even if the data is not sorted.

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.

Answer : D

Explanation

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

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

Explanation

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

Answer : C

Explanation

In a min heap, parent nodes store lesser values than child nodes. The minimum value of the entire heap is stored at root.

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.

C - spanning will have less edges.

D - spanning will not cover all vertices.

Answer : B

Explanation

Regardless of which algorithm is used, in a graph with unique weight, resulting spanning tree will be same.

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