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 - Which of the following usees FIFO method

A - Queue

B - Stack

C - Hash Table

D - Binary Search Tree

Answer : A

Explanation

Queue maintains two pointers − front and rear. In queue data structure, the item inserted first will always be removed first, hence FIFO!

Q 2 - Queue data structure works on

A - LIFO

B - FIFO

C - FILO

D - none of the above

Answer : B

Explanation

In queue, data item inserted first, will be available first and data item inserted last will be available in the last. FIFO stands for First In First Out and is a correct answer.

Q 3 - The following formular is of

left_subtree (keys)  ≤  node (key)  ≤  right_subtree (keys)

A - Bianry Tree

B - Complete Binary Tree

C - Binary Search Tree

D - All of the above

Answer : C

Explanation

A binary search tree (BST) is a tree in which all nodes follows the below mentioned properties −

  • The left sub-tree of a node has key less than or equal to its parent node's key.

  • The right sub-tree of a node has key greater than or equal to its parent node's key.

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

Explanation

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

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

Explanation

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

Q 6 - In binary heap, whenever the root is removed then the rightmost element of last level is replaced by the root. Why?

A - It is the easiest possible way.

B - To make sure that it is still complete binary tree.

C - Because left and right subtree might be missing.

D - None of the above!

Answer : B

Explanation

A binary heap (whether max or min) has to satisfy the property of complete binary tree at all times.

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

Explanation

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

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 - From a complete graph, by removing maximum _______________ edges, we can construct a spanning tree.

A - e-n+1

B - n-e+1

C - n+e-1

D - e-n-1

Answer : A

Explanation

We can remove maximum e-n+1 edges to get a spanning tree from complete graph. Any more deletion of edges will lead the graph to be disconnected.

Answer : B

Explanation

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

data_structures_algorithms_questions_answers.htm
Advertisements