In: Computer Science
Which of the following operations for an array takes the most time to complete?
Setting the value of an element at a given index | ||
inserting an element at a given index | ||
Returning the size of the array | ||
Returning the value of an element at a given index |
b) inserting an element at a given index
inserting an element at a given index takes a time complexity of O(n)
all other operations only takes a constant time of O(1)