Reputation: 21
Time complexity to insert a node at the end of circular singly linked list containing N elements ? Suppose I have pointer to the first node.
I think that it is O(N) as I have to parse the LL to the node before the new node to modify its next field.
Have I got it right ?
Upvotes: 1
Views: 7930
Reputation: 51
Adding to the end of a circular singly linked list can be done in O(1) time.
As these are all constant time operations, this procedure is O(1).
Upvotes: 2