58.7k views
4 votes
What would be the time complexity of the add operation if we chose to add at the end of the list instead of the front?

1 Answer

6 votes

Answer:

O(n)

Step-by-step explanation:

If we chose to add an element at the end of the list instead of the front, the add operation will have a time complexity of O(n) where 'n' represents the number of existing elements of the list. This is because the operation will involve iterating through the entire list of size n via pointers and adding the new element at the end. So the time complexity will be n*O(1) or O(n).

User Uncle Iroh
by
7.0k points