All Exams Test series for 1 year @ ₹349 only
Question

Which of the following algorithms 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 

Choose the correct answer from the options given below :

The correct answer is
A and C only

Algorithm Complexity Analysis

To find algorithms with the same order of complexity, we need to determine the time complexity for each given operation:

  • A. Deletion from Queue: For standard queue implementations (like linked lists or circular arrays), removing an element from the front takes constant time. Complexity: $O(1)$.
  • B. Worst case Search in Binary Search Tree (BST): In the worst case, a BST can become unbalanced, resembling a linked list. Searching requires traversing the height of the tree. Complexity: $O(n)$, where $n$ is the number of nodes.
  • C. Insertion in Stack: For standard stack implementations (like linked lists or arrays), adding an element to the top takes constant time. Complexity: $O(1)$.
  • D. Quick Sort worst Case: The worst-case scenario for Quick Sort occurs with consistently poor pivot choices, leading to skewed partitions. Complexity: $O(n^2)$, where $n$ is the number of elements.

Comparing Complexities

Comparing the determined complexities:

  • Deletion from Queue: $O(1)$
  • Worst case Search in BST: $O(n)$
  • Insertion in Stack: $O(1)$
  • Quick Sort worst Case: $O(n^2)$

Algorithms A (Deletion from Queue) and C (Insertion in Stack) both have a time complexity of $O(1)$, meaning they have the same order of complexity.

Was this answer helpful?

Important Questions from Miscellaneous

  1. Which of the following scheduler/schedulers is/are also called CPU scheduler ?
    (A). Short Term Scheduler
    (B). Long Term Scheduler
    (C). Medium Term Scheduler
    (D). Asymmetric Scheduler
    Choose the correct answer from the options given below:
  2. A situation where two or more processes are blocked, waiting for resources held by each other is called:
  3. External fragmentation occurs ________.
  4. Which disk scheduling algorithm looks for the track closest to the current head position?
  5. Which CPU scheduling algorithm prefers the process with the shortest burst time?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App