Why is deleting in a single linked list O(1)?

后端 未结 8 2491
悲哀的现实
悲哀的现实 2020-12-25 14:50

I do not quiet understand why deleting at the end of a single linked list goes in O(1) time, as the wikipedia article says.

A single linked list consists out of node

8条回答
  •  星月不相逢
    2020-12-25 15:07

    For future reference, I must say after some research I found that none of the arguments provided in response to this question are relevant. The answer is that we simply decide for the top of the stack to be the head of the linked list (rather than the tail). This will introduce a slight change into the push routine but then the pop and push will both remain o(1).

提交回复
热议问题