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

Answer : A

Explanation

In a min heap, parents always have lesser or equal values than that of their childs.

Q 2 - Maximum number of nodes in a binary tree with height k, where root is height 0, is

A - 2k − 1

B - 2k+1 − 1

C - 2k-1 + 1

D - 2k − 1

Answer : B

Explanation

If the root node is at height 0, then a binary tree can have at max 2k+1 − 1 nodes.

For example: a binary tree of height 1, can have maximum 21+1 − 1 = 3 nodes.

   r    --------- 0
  / \
 L   R  --------- 1

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

Explanation

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 - 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 - What will be the running-time of Dijkstra's single source shortest path algorithm, if the graph G(V,E) is stored in form of adjacency list and binary heap is used −

A - Ο(|V|2)

B - Ο(|V| log |V|)

C - Ο(|E|+|V| log |V|)

D - None of these

Answer : C

Explanation

The runing time will be Ο(|E|+|V| log |V|) when we use adjacency list and binary heap.

Q 7 - The Θ notation in asymptotic evaluation represents −

A - Base case

B - Average case

C - Worst case

D - NULL case

Answer : A

Explanation

Θ represents average case. Ο represents worst case and Ω represents base case.

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