What is the time complexity of popping elements from list in Python?

Yes, it is O(1) to pop the last element of a Python list, and O(N) to pop an arbitrary element (since the whole rest of the list has to be shifted).

Here’s a great article on how Python lists are stored and manipulated: http://effbot.org/zone/python-list.htm

Leave a Comment