What is the time complexity of a push operation in a stack, when implemented…
2023
What is the time complexity of a push operation in a stack, when implemented using an array?
- A.
O(1)
- B.
O(n)
- C.
O(n log n)
- D.
O(n^2)
Attempted by 532 students.
Show answer & explanation
Correct answer: A
The time complexity of the PUSH operation in a stack, when implemented using an array, is O(1). This is because it only takes one operation to add an element to the top of the stack.