Python double linked list \ single linked list - O(1) notation while running on loop

Viewed 27

let us say I have functions I want to build in a double linked list ( or singular one, it doesnt matter ). How do I reach o(1) notation?
I have the function: return and remove last node. to get to the last I need to run a while loop to get to the end.
but for that, it will be O(n), not O(1). I know how to solve it, but I dont understand why it is O(1) and not O(N).

Edit: My question got answered, thanks to the helpers: @blhsing and @Mechanic Pig May close post if needed.

0 Answers
Related