Inserting a node into a linked list in constant-time?

前端 未结 7 933
别跟我提以往
别跟我提以往 2021-01-24 09:09

I\'m working on an assignment that is telling me to assume that I have a singly linked list with a header and tail nodes. It wants me to insert an item y before position p. Ca

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 09:35

    The reason why the header and tail node is given in the question is to the update the header and tail reference if the the replacement node that your creating happens to become the header or tail. In other is words, the given previous node is either a header or tail.

提交回复
热议问题