2 years ago
in English · 1,089 Views
likes 3clips 3comments 1
Data Structures: Arrays
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
csgeek clipped in 1 collections
1 comment
Haha...we just covered arrays in my intro compSci class....guess who was ready for the material? *this guy*