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

Answer : A

Explanation

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

Q 2 - push() and pop() functions are found in

A - queues

B - lists

C - stacks

D - trees

Answer : C

Explanation

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

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)

Answer : A

Explanation

In one iteration of Bubble sort, the maximum of the set in hand is moved at the end of the unsorted list. Hence one less comparison.

Answer : D

Explanation

Binary heap heapify operation has time-complexity of Ο(n), while other operations have time-complexity of Ο(1) only.

Q 7 - Index of arrays in C programming langauge starts from

A - 0

B - 1

C - either 0 or 1

D - undefined

Answer : A

Explanation

Arrays, in C, starts from 0 which is mapped to its base address.

Answer : A

Explanation

All possible spanning trees of graph G, have same number of edges and vertices.

Q 9 - Access time of a binary search tree may go worse in terms of time complexity upto

A - Ο(n2)

B - Ο(n log n)

C - Ο(n)

D - Ο(1)

Answer : C

Explanation

At maximum, BST may need to search all n values in the tree in order to access an element, hence, Ο(n).

Q 10 - If the data collection is in sorted form and equally distributed then the run time complexity of interpolation search is −

A - Ο(n)

B - Ο(1)

C - Ο(log n)

D - Ο(log (log n))

Answer : D

Explanation

Runtime complexity of interpolation search algorithm is Ο(log (log n)) as compared to Ο(log n) of BST in favourable situations.

data_structures_algorithms_questions_answers.htm
Advertisements