Singly-Linked List
Node contains;
- key
- next pointer
List API
PushFront(Key) add to Front
Key TopFront return front item
PopFront() remove front item
PushBack(Key) add to back
Key TopBack() return back item
PopBack() remove back item
Boolean Find(key) is key in list?
AddBefore(Node,Key) adds key before node
AddAfter(Node,Key) adds key after node
Times for some operation
Singly Linked List | no tail | with tail |
---|---|---|
PushFront(Key) | O(1) | |
TopFront() | O(1) | |
PopFront() | O(1) | |
PushBack(Key) | O(n) | O(1) |
TopBack() | O(n) | O(1) |
PopBack() | O(n) | |
Find(Key) | O(n) | |
Erase(Key) | O(n) | |
Empty() | O(1) | |
AddBefore(Node,Key) | O(n) | |
AddAfter(Node,Key) | O(1) |