Arrays: Time Complexity
What is the time complexity of the main array operations?
Answer
Access by index: \(O(1)\)
Search: \(O(n)\)
Insert: \(O(n)\). Inserting an element requires shifting the elements to the right to make room.
Delete: \(O(n)\). Deleting an element requires shifting the elements to the left to close the gap.