Data Structure Time Complexity Question #15254
MCQ Single Best Answer Easy

QWhat is the time complexity of a push operation in a stack implemented using an array?

ID: #15254 Time Complexity 137 views
Question Info
#15254Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log n)
  • C O(n)
  • D O(n log n)
Correct Answer: Option A

Explanation

In a stack implemented using an array, the push operation inserts an element at the top of the stack. Since the top position is known, the push operation can be performed in constant time by simply incrementing the top index and storing the element in the corresponding array position. Therefore, the time complexity of the push operation is O(1).

Share This Question

Challenge a friend or share with your study group.