Stacks and Queues - Complexity Analysis

Download Q&A
Q. In a stack, what is the time complexity of checking if it is empty?
  • A. O(1)
  • B. O(n)
  • C. O(log n)
  • D. O(n^2)
Q. What is the time complexity of clearing all elements from a queue?
  • A. O(1)
  • B. O(n)
  • C. O(log n)
  • D. O(n^2)
Q. What is the time complexity of dequeuing an element from a queue implemented using an array?
  • A. O(1)
  • B. O(n)
  • C. O(log n)
  • D. O(n^2)
Q. What is the time complexity of enqueuing an element in a queue implemented using an array?
  • A. O(1)
  • B. O(n)
  • C. O(log n)
  • D. O(n^2)
Q. What is the time complexity of implementing a queue using two stacks?
  • A. O(1) for enqueue, O(n) for dequeue
  • B. O(n) for enqueue, O(1) for dequeue
  • C. O(n) for both
  • D. O(1) for both
Q. What is the time complexity of reversing a stack using another stack?
  • A. O(n)
  • B. O(n log n)
  • C. O(n^2)
  • D. O(1)
Q. What is the time complexity of searching for an element in a stack?
  • A. O(1)
  • B. O(n)
  • C. O(log n)
  • D. O(n^2)
Showing 1 to 7 of 7 (1 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely