487 views
1 votes
1 votes
Consider a stack is implemented using an array. What is the worst case time complexity of push operation?

(A) O(N)

(B) O(log N)

(C) O(N log N)

(D) O(1)

1 Answer

0 votes
0 votes

When we perform push operation on a Stack implemented as an array, we just need to insert the new element on the top of the Stack. This operation can be performed in O(1) time. Hence, answer is (D).

Related questions

1 votes
1 votes
2 answers
1
srestha asked Aug 6, 2016
838 views
An array of size n. Find the time complexity to insert a new value before an element e in the array?a)O(n)b)O(log n)c)O(1)