What is the worst-case time complexity to insert an element at the end of a singly linked list (without tail pointer)?
What is the worst-case time complexity to insert an element at the end of a singly linked list (without tail pointer)?
Choose an Option
Answer
O(n)
Theory
Without a tail pointer, you must traverse the entire list to find the last node before inserting.
Solution
Traversal of n nodes ⇒ O(n).