characteristics of Array:
All of the elements of the array are contiguous, meaning that they are all next to one another in memory.
Another key characteristic of an array is that all of the elements are the same size. i.e. array contains elements of same data type
Because all of the elements in array are:
- next to one another and
- the same size
this means that if we know the location of the first element, we can calculate the location of any other element.
For example, if the first element in the array is at memory location 00 and the elements are 24 bytes, then the next element would be at location 00 + 24 = 24. And the one after that would be at 24 + 24 = 48, and so on.
Since we can easily calculate the location of any item in the array, we can assign each item an index and use that index to quickly and directly access the item.
my question is python lists are essentially dynamic array: lists elements are also contiguous meaning that they area all next to one another in memory but python lists can have elements of different data types unlike array so, how do we calculate location of next element in memory since we can't add fixed size every time to get to know the position of next element