1.

What is the time complexity of pop() operation when the stack is implemented using an array?(a) O(1)(b) O(n)(c) O(logn)(d) O(nlogn)My enquiry is from Stack using Array in division Abstract Data Types of Data Structures & Algorithms II have been asked this question in an interview for job.

Answer»

The correct answer is (a) O(1)

The BEST I can explain: pop() accesses only one END of the structure, and HENCE CONSTANT time.



Discussion

No Comment Found

Related InterviewSolutions