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

A - Ο(n2)

B - Ο(nlog n)

C - Ο(n3)

D - Ο(n)

Answer : D

Explanation

In the worst case, binary search will be left or right intended, making it compare all the n values.

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 - A linked-list is a dynamic structure

A - true

B - false

Answer : A

Explanation

A linked-list is dynamic structure, it can shrink and expand as required by the program.

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

Explanation

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

Answer : C

Explanation

As trees do not have loops, they are easier to traverse.

Q 6 - Time required to merge two sorted lists of size m and n, is

A - Ο(m | n)

B - Ο(m + n)

C - Ο(m log n)

D - Ο(n log m)

Answer : B

Explanation

The time required to merge two sorted list is Ο(m + n).

Q 7 - Which of these alogrithmic approach tries to achieve localized optimum solution −

A - Greedy approach

B - Divide and conquer approach

C - Dynamic approach

D - All of the above

Answer : A

Explanation

Greedy approach focuses only on localized optimum solution.

Q 8 - If there's no base criteria in a recursive program, the program will

A - not be executed.

B - execute until all conditions match.

C - execute infinitely.

D - obtain progressive approach.

Answer : C

Explanation

Without a base criteria and progressive approach, a recursion is just an infinite iteration.

Answer : A

Explanation

BST does not care about complete binary tree properties.

Answer : C

Explanation

A stable sorting algorithm like bubble sort, does not change the sequence of appearance of similar element in the sorted list.

data_structures_algorithms_questions_answers.htm
Advertisements