Which algorithm have same order of complexity?
A. Deletion from Queue
B. Worst case search in binary search tree
C. Insertion in stack
D. Quick sort worst case
Explanation
Solution
To find which algorithms have the same order of complexity, we analyze each operation individually:
A. Deletion from Queue:
In a standard queue (FIFO), deletion happens at the front. Using a linked list or an array with pointers, this is a constant time operation.
B. Worst case search in binary search tree (BST):
In the worst case, a BST can be skewed (like a linked list). To find an element, you might have to traverse all n nodes.
C. Insertion in stack:
In a stack (LIFO), insertion (Push) occurs at the top. This is always a constant time operation.
D. Quick sort worst case:
The worst case for Quick Sort occurs when the pivot consistently results in highly unbalanced partitions (e.g., when the array is already sorted).
Comparison:
Final Answer:
The correct option is (b) A, C.