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

Answer : D

Explanation

Quick sort divides the list using pivot and then sorts in recursive manner. It uses divide and conquer approach.

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

Explanation

Recursion is just an other way to write the same program code. But calling a function again and again makes it expensive in terms of memory, CPU cycles and delivers less performance.

Q 6 - Which of the below given sorting techniques has highest best-case runtime complexity −

A - quick sort

B - selection sort

C - insertion sort

D - bubble sort

Answer : B

Explanation

Selection sort best case time complexity is Ο(n2)

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

Explanation

Regardless of being min heap or max heap, root is always replaced by last element of the last level.

Q 9 - The following sorting algorithms maintain two sub-lists, one sorted and one to be sorted −

A - Selection Sort

B - Insertion Sort

C - Merge Sort

D - both A &am; B

Answer : D

Explanation

Both selection sort and insertion sort maintains two sublists and then checks unsorted list for next sorted element.

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

Explanation

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

data_structures_algorithms_questions_answers.htm
Advertisements