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

前端 未结 7 926
别跟我提以往
别跟我提以往 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条回答
  • 2021-01-24 09:58

    In a singly LinkedList only adding a Node to the beginning of the list or creating a List with only one Node would take O(1). OR as they have provided the TailNode also Inserting the Node at End of list would take O(1).

    every other inserting operation will take O(n).

    0 讨论(0)
提交回复
热议问题