operations that can be performed on an array.
concise summary of operations on an array:
Access:
- Retrieve element by index.
- Time Complexity: O(1)
Insertion:
- Add element at end or specific position.
- Time Complexity: O(1) (end), O(n) (specific position)
Deletion:
- Remove element from end or specific position.
- Time Complexity: O(1) (end), O(n) (specific position)
Search:
- Find element or index.
- Time Complexity: O(n) (unsorted), O(log n) (sorted)
Update:
- Modify value at index.
- Time Complexity: O(1)
Traversal:
- Iterate through all elements.
- Time Complexity: O(n)
Resize:
- Change array size (dynamic arrays).
- Time Complexity: O(n)
Sorting:
- Arrange elements in order.
- Time Complexity: O(n log n)
Reversing:
- Reverse the order of elements.
- Time Complexity: O(n)
Copying:
- Duplicate the array.
- Time Complexity: O(n)