l = [1,2,3,4]
popping the last element would be an O(1) operation since:
- It returns the last element
- Changes a few fixed attributes like
len
of the list
Why can't we do the same with pop(0)?
- Return the first element
- Change the pointer of the first element (index 0) to that of the second element (index 1) and change a few fixed attributes?