133k views
3 votes
What would the time complexity be for the size operation if there were not a count

User Rdesmond
by
6.5k points

1 Answer

1 vote

Answer:

O(n)

Step-by-step explanation:

If we wish to calculate the size of a list data structure where no count is available then the size 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 till we reach the end of the list. So the time complexity will be n*O(1) or O(n).

User Xonshiz
by
6.0k points