of one of its elements and the number of elements: S t N • The total size of the array is: • The i-th element can be located at address • The array ends at memory address N ⋅ t A[i] = S + ti S + Ni
the end of the array which cannot be guaranteed to be available • Solution: Allocate new memory of size , move every element to the new location, and add the new element. • Time/space complexity: • A.insert(x, i) is the same as push(x) but shifts all elements after i 1 place to the right • Time/space complexity: N + 1 Θ(n) Θ(n)
right of i 1 place to the left. • Time complexity: • A.remove(x) is the same as delete(i) but it has to ﬁnd all occurrences of x ﬁrst. • Time complexity: O(n) O(n2)
space • Keep track of the last element/length • Whenever an insertion surpasses the underlying array capacity: • Allocate new memory of size where • Copy all elements of the original array to the new location • Add new element ρN ρ > 1