What would be the complexity of the size() method for the linked implementation of a list, if there were no count variable?

Respuesta :

If there were no count variable, the complexity of the size() method for the linked implementation of a list would be O(n).

How complicated is the size?

  • By evaluating the impacts of size rise and decrease, the link between size and complexity is examined.
  • Size increase necessitates an increase in complexity, whereas size drop permits, and occasionally necessitates, a decrease in complexity.

Since the linked list's length cannot be stored in a count variable, we must traverse the list from head to tail to get its size.

To obtain the size for n nodes, we will traverse all n nodes. As a result, the time complexity is O (n).

Learn more about complexity

brainly.com/question/13199971

#SPJ4

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE