Dynamic Array
Other names: array list, growable array, resizable array, mutable array Quick reference Average Case Worst Case space O(n) O ( n ) O(n) O ( n ) lookup O(1) O ( 1 ) O(1) O ( 1 ) append O(1) O ( 1 ) O(n) O ( n ) insert O(n) O ( n ) O(n) O ( n ) delete O(n) O ( n ) O(n) O ( n ) A dynamic array is an array with a big improvement: automatic resizing. One limitation of arrays is that they're fixed size , meaning you need to specify the number of elements your array will hold ahead of time. A dynamic array expands as you add more elements. So you don't need to determine the size ahead of time. Strengths: Fast lookups . Just like arrays, retrieving the element at a given index takes O(1) O ( 1 ) time. Variable size . You can add as many items as you want, and the dynamic array will expand to hold them. Cache-friendly . Just like arrays, dynamic arrays place items right next to each other in memory, making efficient use of caches. Weak...