Algorithms and Data Structures · Junior · Question 25 of 75
Which operation is O(1) in a linked list but O(n) at the start of an array?
- ✓Correct answer: Inserting a new element at the beginning
- 2Reading the last element by index
- 3Sorting the elements
Explanation
Adding to the front of a list means creating a node and pointing it at the old head. In an array every element has to shift one position to make room (unshift).