From the title, the essence of the problem is clear. Interested in what is the temporal complexity of the algorithm of the AddRange () method of the list in C #?
|
2 answers
From the documentation :
If
List<T>can hold new elements without increasingCapacity, this method requiresO(n)operations, wherenis the number of added elements. If to accommodate new elements, it is necessary to increase the capacity, this method becomesO(n + m)operations, wherenis the number of elements to add andmis theCount.
|
If, when added to the list, its capacity does not need to be increased, then O (n)
Otherwise, O (n + m) , where n is the number of added elements and m the length of the list before adding
|