Algorithm Mcq

Q 1 - Prefix notation is alsow known as

A - Reverse Polish Notation

B - Reverse Notation

C - Polish Reverse Notation

D - Polish Notation

Answer : D
Explanation
Polish Notation

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 of the below given series is Non-Increasing Order −

A - 1, 3, 4, 6, 8, 9

B - 9, 8, 6, 4, 3, 1

C - 9, 8, 6, 3, 3, 1

D - 1, 3, 3, 6, 8, 9

Answer : C
Explanation
A sequence of values is said to be in non-increasing order, if the successive element is less than or equal to its previous element in the sequence.



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 - If queue is implemented using arrays, what would be the worst run time complexity of queue and dequeue operations?

A - Ο(n), Ο(n)

B - Ο(n), Ο(1)

C - Ο(1), Ο(n)

D - Ο(1), Ο(1)

Answer : D
Explanation
As queue is maintained by two separate pointers for queue and dequeue operations, the run time for both is Ο(1).

Q 8 - In C programming, when we remove an item from bottom of the stack, then −

A - The stack will fall down.

B - Stack will rearranged items.

C - It will convert to LIFO

D - This operation is not allowed.

Answer : B
Explanation
Stack can only be accessed from top of it.

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 - In conversion from prefix to postfix using stack data-structure, if operators and operands are pushed and popped exactly once, then the run-time complexity is −

A - Ο(1)

B - Ο(n)

C - Ο(log n)

D - Ο(n2)

Answer : B
Explanation
Infix to postfix conversion using stack will have run time complexity of Ο(n).

No comments:

Post a Comment