csgeek
3 years ago500+ Views
An array is a data structure consisting of a "collection of elements (values or variables), each identified by at least one array index or key." You can have a simple, linear, one-dimensional array of length n, or a n x m two-dimensional array. Sometimes a one-dim array is referred as a "vector" and a two-dimensional array is referred to as a "matrix". Arrays are also used to implement other data structures (e.g. heaps, hash tables, deques, queues, stacks, strings...) Example: Let's say we have an array of 4 integers called arr[] +========================+ arr[] = | 64 | 56 | 84 | 109 | +========================+ To access the first element in the array, you would call it using arr[0], the second would be arr[1], the third arr[2] and so on. Arrays have some general limitations, for example, they are fixed in size. This depends, of course, on the language you are using. Overall, the array is the oldest data structure around and is essential when storing data. More info on wiki-page: http://en.wikipedia.org/wiki/Array_data_structure img: http://ycpcs.github.io/cs201-summer2014/notes/figures/arrays.png
3 Like
3 Share
1 comment
Haha...we just covered arrays in my intro compSci class....guess who was ready for the material? *this guy*
3 years ago·Reply
3
1
3