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 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 - What data structure is used for breadth first traversal of a graph?

A - queue

B - stack

C - list

D - none of the above

Answer : A

Explanation

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

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 - If the array is already sorted, which of these algorithms will exhibit the best performance

A - Merge Sort

B - Insertion Sort

C - Quick Sort

D - Heap Sort

Answer : B

Explanation

Insertion sort, as it should then work in linear way.

Q 5 - Apriory algorithm analysis does not include −

A - Time Complexity

B - Space Complexity

C - Program Complexity

D - None of the above!

Answer : C

Explanation

Algorithms are independent of programming languages, hence, program complexity is not a part of algorithm analysis.

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 : A

Explanation

After applying node.next -> node.next.next; we will not have node.next stored anywhere if not explicitly mentioned.

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

Explanation

Stack can only be accessed from top of it.

Q 9 - Re-balancing of AVL tree costs

A - Ο(1)

B - Ο(log n)

C - Ο(n)

D - Ο(n2)

Answer : B

Explanation

AVL rotations have complexity of Ο(log n)

Answer : A

Explanation

For this algorithm to work properly the data collection should be in sorted form and equally distributed.

data_structures_algorithms_questions_answers.htm
Advertisements