You can expect an array to be cache-friendly, why?
Array data is stored sequentially as much as possible.
When the processor loads the data for an array index, it can also load all of the data at sequential nearby addresses to the cache under the safe assumption that they are likely to be referenced soon.
What is the tradeoff between a Dynamic Array and a Standard Array?
Dynamic Arrays do not require a preset size, and therefore simplify adding/appending data from a code perspective.
The disadvantage however, is that as more entries are appended to the dynamic array, some of them will be more expensive operations as the dynamic array occasionally must increase its overall size in memory to accomodate entries that exceed its current maximum.
Appending an item to an array is usually an O(1) time operation, but a single doubling append is an O(n) time operation since we have to copy all n items from our array into the newly-extended array.
What are the built-in Array types for C++, C#, Python, and Java?
Are they standard arrays or dynamic?
array
vector<T>
N/A
list
Array<T>
ArrayList<T>
Zuletzt geändertvor einem Monat