Senin, 30 Juli 2012

Regarding The Array

Understanding about Array




Array is the array / place order / address sequence.
So for example there is an array of letters: A B C
Where the A: or B on the left before B
Where the B: between A and C
Where the C: to the right of B or after B


Understanding the above IMPORTANT because in using the "pointers" we'll play addresses the "array", so do not let confused ntar y. Remember, tu maenin address pointer, not the contents!

To be used, the array must be declared beforehand:
Example:
int A [10];
means we declare an array A by 10 integer values
jadiii, array A of type integer, it was 10, from A [0] - A [9].
do not be fooled, even if the declaration A [10], in use A [10] NO


n-Dimensional Array: Array has sub-susunan/sub-tingkatan as (n-1).
Example:
int A [5] [10];
is a 2-dimensional array that has one sub-susunan/sub-tingkatan
to the left of the array level the highest.
number of data means 50 pieces, from A [0] [0] - A [4] [9]


Well, in this example, means that the location of the earliest is A [0] [0], followed by A [0] [1], NOT A [1] [0].
Why? Since the level is higher on the left than the right.
Suppose
X = A [10], A [5] [10] = X [5]
so a bunch of arrays that diarraykan ten again by 5.
Each array X has a number of array A ten:
X [0] has a [10]
X [1] has a [10]
...
X [4] has a [10]

The first data from the array is x [0], while the first data from X [0] is A [0], the first array of A [5] [10] is A [0] [0].
Data after A [0] [0] is the second reading of X [0], which means that A [0] [1].
While the latest data from the array is X [4], while recent data from X [4] is A [9], the last array of A [5] [10] is a [4] [9].

Similarly, more than two-dimensional array:
A [3] [5] [10] means that we let X = A [10], Y = X [5],
the array A [3] [5] [10] = Y [3]
Y [0], Y [1], Y [2], each of which has X [5], while X [0], X [1], X [2], X [3], X [4], each has a [10]

write down the dimensions of the highest level (Y), intermediate (X), the lowest new (A).
A [0] [0] [0] -> data first
A [2] [4] [9] -> last data
number of records: 3 x 5 x 10 = 150


The advantage of using an array is that we can access the data at random (Random Access), so we can immediately "dirty" A [2] [0] [3] of array A [3] [5] [10] without having to read data2 before data.

Problems in the use of the array:
Limited places because we have to declare in advance that can be used.
If the data turned out to exceed the capacity that we declare, it will bring up an error because the data is deemed excessive foreign data.
Conversely, if it is a place that is declared excess or too much, the rest of the array will spend unused inventory existing memory, so that the program could be running a bit slow even though its data.

Tidak ada komentar:

Posting Komentar