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


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 - push() and pop() functions are found in

A - queues

B - lists

C - stacks

D - trees

Answer : C


Stack uses push() to insert an item in stack, and pop() to remove the top item from stack.

Q 3 - Minimum number of moves required to solve a Tower of Hanoi puzzle is

A - 2n2

B - 2n-1

C - 2n - 1

D - 2n - 1

Answer : C


Minimum number of moves required to solve a Tower of Hanoi puzzle is 2n - 1. Where n is the number of disks. If the number of disks is 3, then minimum number of moves required are 23 - 1 = 7

Q 4 - Maximum degree of any vertex in a simple graph of vertices n is

A - 2n - 1

B - n

C - n + 1

D - n - 1

Answer : D


In a simple graph, a vertex can have edge to maximum n - 1 vertices.

Q 5 - Which method can find if two vertices x & y have path between them?

A - Depth First Search

B - Breadth First Search

C - Both A & B

D - None A or B

Answer : C


By using both BFS and DFS, a path between two vertices of a connected graph can be determined.

Q 6 - How many swaps are required to sort the given array using bubble sort - { 2, 5, 1, 3, 4}

A - 4

B - 5

C - 6

D - 7

Answer : A


There will be 3 swaps in first iteration and 1 swap in second iteration.

Q 7 - Which of the following is not possible with an array in C programming langauge −

A - Declaration

B - Definition

C - Dynamic Allocation

D - Array of strings

Answer : C


Array in C are static and cannot be shrinked or expanded in run-time.

Answer : B


Recursion uses stack but the main reason is, every recursive call needs to be stored separately in the memory.

Answer : A


BST does not care about complete binary tree properties.

Q 10 - Which of the following algorithm does not divide the list −

A - linear search

B - binary search

C - merge sort

D - quick sort

Answer : A


Linear search, seaches the desired element in the target list in a sequential manner, without breaking it in any way.