184k views
1 vote
The complexity (as a functoin of n, the number of items in the list) for the operations add and delete in your lab4 submission is:

1 Answer

5 votes

Final answer:

The complexity for the add and delete operations in the lab4 submission depends on the data structure used.

Step-by-step explanation:

The complexity for the operations add and delete in the lab4 submission depends on the data structure used to store the list.

For example, if an array is used, the complexity for adding or deleting an item at the end of the list is O(1). However, adding or deleting an item at the beginning or in the middle of the array would require shifting all the subsequent elements, resulting in a complexity of O(n).

On the other hand, if a linked list is used, adding or deleting an item at any position in the list has a complexity of O(1), as it only requires updating a few pointers.

User Gilpach
by
7.2k points