answersLogoWhite

0


Best Answer

Arrays are allocated as a contiguous block of memory divided into one or more elements of equal size and type. Knowing the start address of the array makes it possible to reference any element within the array through a zero-based index. Multiplying the index by the size of an element determines the offset from the start of the array.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

An array is simply a contiguous memory allocation, where one element immediately follows another. The array's type determines the size of an element (in bytes). Multiplying this size by the number of elements gives the total size of the array, and thus the total memory allocated to the array. In order to dereference an element you simply need to know its address, which can be determined via a zero-based index offset from the start of the array, such that index 2 means an offset of 2 times the size of an element. Adding this amount to the start address gives the address of the third element. All this is done Behind the Scenes, we simply need to know that the third element of a zero-based array can always be found at index 2.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

A two-dimensional array simply an array of one-dimensional arrays. That is, each element of the array is simply another array. This notion can be extended to any number of dimensions.

Just as an array of int is stored as a contiguous sequence of five integer elements, a two-dimensional array of int is stored as a contiguous sequence of four intelements.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Traditional arrays are typically stored in a linear fashion, and some programming languages (such as the C language) even require that they are.

Consider a one-dimensional array with tree elements A0, A1 and A2, each 11 bytes in size. A0 will be located at the array's base address A, A1 at A+11, A2 at A+22, etc. In general, Ai will be located at A+i*S, where S is the size of a single element (11 bytes in this example).

Now consider a two-dimensional array with two elements in the first dimension (A and B), with three items of size S each (A0, A1 and A2, B0, B1 and B2). The C language requires a specific arrangement in memory: first all elements of A, the followed by all elements of B.

Note that not all languages stipulate details of array storage. As an abstract data structure, an array (sometimes also called a vector) is a data structure best suited for indexed access to its items. This concept does not require specific arrangements in memory, and modern toolkits and programming languages often implement this more general concept, using a more versatile structure (for example, a list) as the underlying data structure in implementing an array. This approach allows for variable-size arrays, associative arrays and jagged arrays, neither can be supported for traditional languages such as traditional C.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Multi-dimensional arrays are stored either as pointers-to-pointers or as a uniform grid, either in order of the rows, or in the order of the columns, depending on the design of the program. The pointers-to-pointers method allows each element of the array to be dynamically sized, also known as a staggered multi-dimensional array. The other method forces the multi-dimensional array to be "rectangular" in nature; if the elements were laid out on paper, and each element were drawn to be the same size, they would fit perfectly inside a rectangle drawn by the points (0,0) (0,n) (n,n) (n,0) (0,0).

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

One dimensional array is represented as stacks in memory.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

That depends on the compiler.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How is an one dimensional array is represented in memory?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


Explain the Different types of array?

one dementional array and two dementional array


What is non linear array?

What is ARRAY, explain its typesARRAY: -It is the combination of same data type or if same data is needed more then none time then we use array.Types Normally there are two types of array.(1) One dimensional array(2) Two dimensional array(1) One dimensional array: -This array is in form a list (vertical\Horizontal) the data input output or process in one dimensional array with the help of loop.The syntax of one dimensional array will be as:Array name [strength]For exampleA [5];The structure of above syntax will be as:A (0)A (1)A (2)A (3)A (4)(2) Two dimensional array: -Two dimensional array is also called a table because it consist of rows and columns. The syntax of two dimensional arrays will be as:Data type array name [rows] [columns]For exampleInt [3] [2];The structure of above syntax will be as:A [0] [0] A [0] [1]A [1] [0] A [1] [1]A [2] [0] A [2] [1]The data input output are process in this array with the help of nested loop.


What is Array in Programming C?

Arrays allow similar types of data to be stored within a contiguous block of memory such that every data element is accessible in constant time, regardless of its physical location within the array. This is achieved through simple pointer arithmetic treating each element as a memory offset from the start of the array. Since every element is the same length (in bytes), locating any element is simply a matter of calculating its offset from its index. Indices are zero-based thus the third element can be found at index 2. The memory offset for that element is therefore the product of the element size and 2. However, C permits indices to be specified directly, while the pointer arithmetic is done in the background. Thus array_name[2] automatically returns a reference to the third element. Arrays with large and complex variable length data elements need to store those elements separately from the array, usually non-contiguously. This is achieved by using a pointer array. Pointer arrays are particularly useful when sorting extremely large data lists as it is much easier and more efficient to implement a sorting algorithm with an array than it is with a linked list, particularly when constant-time random-access is essential to the algorithm. The time and effort in building the array is generally more than compensated for by the efficiency of the algorithm. Arrays can also be divided and subdivided to better model the data they represent. For instance, a chessboard might be implemented as a one-dimensional array of 64 elements, however it makes more sense to model the chessboard in a two-dimensional array of 8x8 elements. Although the array is still allocated contiguously and can be thought of as being 8 rows and 8 columns, it's actually better to think of this two-dimensional array as being a one-dimensional array of 8 elements, where each element is another one-dimensional array of 8 elements. By thinking this way it makes it possible to allocate extremely large arrays in non-contiguous memory (as completely separate one-dimensional arrays) and also makes comprehension of a four-dimensional array in a three-dimensional world that much easier (unless you actually want to model time and space of course). A four-dimensional array can be thought of in a variety of ways: as being a one dimensional array of three-dimensional arrays, or as a two-dimensional array of two-dimensional arrays, or as a three-dimensional array of one-dimensional arrays, or even as a one-dimensional array of one-dimensional arrays of one-dimensional arrays of one-dimensional arrays. Whichever method you use to imagine your array is immaterial, so long as it makes sense to you that's all that really matters.


What are the benefits of multidimensional arrays?

Multi-dimensional arrays are accessed using more than one index: one for each dimension. Multidimensional indexing can be reduced internally to linear indexing; for example, a two-dimensional array with 6 rows and 5 columns is typically represented by a one-dimensional array of 30 elements.

Related questions

What is a multi array?

A two-dimensional array is the simplest multi-dimensional array and is implemented as a one-dimensional array where every element is itself a one-dimensional array. We can imagine a two-dimensional array as being a table of rows and columns where every row is an array in its own right. A three-dimensional array is simply a one-dimensional array of two-dimensional arrays, which can be imagined as being an array of tables. Extending the concept, a four-dimensional array is a table of tables. Multi-dimensional arrays may be jagged. That is, a two-dimensional array may have rows of unequal length. Unlike regular arrays, jagged arrays cannot be allocated in contiguous memory. Instead, we use the outer array (the first dimension) to store pointers to the inner arrays. An array of strings (character arrays) is an example of a two-dimensional jagged array.


How many types of arrays in c?

An array is simply a contiguous block of memory containing two or more elements. There are two types of array: a static array which is allocated on the stack at compile time; and a dynamic array which is allocated on the heap at runtime. Both can be one-dimensional or multi-dimensional. A one-dimensional array can be likened to a row (or column) of chessboard squares, with as many squares as required to store all the elements. A multi-dimensional array is any array with two or more dimensions. A two-dimensional array can be likened to the whole chessboard, where any square can be identified by its row and column index. However the dimensions needn't be equal. A two-dimensional array can also be imagined as a one-dimensional array where every element is simply another one-dimensional array. Three-dimensional arrays can be likened to a cube, or as a one-dimensional array of two-dimensional arrays. A four-dimensional array can be linked to a one-dimensional array of three-dimensional arrays, and so on. Although every one-dimensional array must be allocated in contiguous memory, multi-dimensional arrays can be dynamically allocated so that each dimension is itself a separately allocated one-dimensional array of pointers to the next dimension, making it possible to allocate extremely large arrays over a series of smaller allocations rather than as a single contiguous block.


How do you represent a one dimensional array in memory?

A one-dimensional array is always represented as a single contiguous block of memory. The size of the allocation is determined by the array's type and the number of elements of that type. For instance, if you create an array of 10 elements where each element is 4 bytes in length, the total allocation will be 40 bytes. The array name is a reference to the start of the allocation and individual elements are accessed via an indexed offset from this reference, such that the first element is at offset 0, the next is at offset 1, and so on.


How does two dimensional array differ from single dimensional array?

A one dimensional array is a scalar value repeated one or more times.A two dimensional array is an array of one dimensional arrays.A three dimensional array is an array of two dimensional arrays, and so forth.The one dimensional array is like a list of things, where the two dimensional array is like an array of things. (Think one row of a spreadsheet versus the whole spreadsheet.)[addendum]Every level of array depth is also a level of pointer depth. For example: A 3 dimensional int array is an int***. So a one dimensional int array is an int*, and a two dimensional int array is an int**. This is only important if you are doing pointer work, but it can become very important.


What is single dimensional array in c plus plus?

A one dimensional array is an array of objects that goes in one "direction". Any array with only one [] is a one dimensional array. For example: int numbers[6]; is a one dimensional array. int numbers[6][3]; is a two dimensional array.Graphical terms:One dimensional array[4]:14 - 75 - 8164 - 234Two dimensional array[2][3]:47 - 178108 - 8517 - 128It didn't come out quite how I wanted it...


Dope vector method for one dimentional array?

Dope Vector Method is use for one dimensional array and also two-dimensional array for one dimensional array we use MA(i)=sa+(i-1)*w MA is Memory Address Sa = Start Address i is subscript W for integer w=2 float=4 char=1 for two dimensional array MA(i,j)=SA{n(i-1)+(j-1)}*W


What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


Explain the Different types of array?

one dementional array and two dementional array


What is non linear array?

What is ARRAY, explain its typesARRAY: -It is the combination of same data type or if same data is needed more then none time then we use array.Types Normally there are two types of array.(1) One dimensional array(2) Two dimensional array(1) One dimensional array: -This array is in form a list (vertical\Horizontal) the data input output or process in one dimensional array with the help of loop.The syntax of one dimensional array will be as:Array name [strength]For exampleA [5];The structure of above syntax will be as:A (0)A (1)A (2)A (3)A (4)(2) Two dimensional array: -Two dimensional array is also called a table because it consist of rows and columns. The syntax of two dimensional arrays will be as:Data type array name [rows] [columns]For exampleInt [3] [2];The structure of above syntax will be as:A [0] [0] A [0] [1]A [1] [0] A [1] [1]A [2] [0] A [2] [1]The data input output are process in this array with the help of nested loop.


How 3d arrays are represented in memory?

All multi-dimensional arrays are represented as arrays of arrays. That is, each element of the array is itself an array. Thus a two-dimensional array can be thought of as being a one-dimensional array where every element is a one-dimensional array. A three-dimensional array is therefore a one-dimensional array of two-dimensional arrays. And so on. The actual memory layout of a multi-dimensional array is no different to that of a one-dimensional array of the same size: int a[12]; int b[3][4]; Assuming a 4-byte int, the amount of memory allocated to a is 12 x 4 = 48 bytes. The array b is essentially an array where each element holds an array of 4 integers, thus each element is 16 bytes in length. Given there are 3 such elements in total, the total size of b is 3 x 16 = 48 bytes, the same as was allocated to a. Although the allocations are exactly the same in terms of size, the layouts differ. The array a is an array of twelve 4-byte elements (of type int) whereas array b is an array of three 16-byte elements, each of which is itself an array of four 4-byte elements (of type int). This changes the way we refer to the individual elements of the array. Every element in an array is referred to by its offset address from the start of the array. This is determined by multiplying its zero-based index by the element size. In the case of a, every element is 4-bytes in length, thus element a[2] refers to the element that is offset 2 x 4 = 8 bytes from the start of the array. But in the case of b, however, b[2] would refer to the 16-byte element that is offset 2 x 16 = 32 bytes from the start of the array. Given that we're actually referring to an element which is itself a 4-element array, we must use a second subscript to refer to the elements of that array. Thus b[2][3] would refer to the integer that is offset 3 x 4 bytes from the start of the array referred to by b[2]. Extending this idea into three-dimensions is simply a matter of taking a third subscript into account.


What is Array in Programming C?

Arrays allow similar types of data to be stored within a contiguous block of memory such that every data element is accessible in constant time, regardless of its physical location within the array. This is achieved through simple pointer arithmetic treating each element as a memory offset from the start of the array. Since every element is the same length (in bytes), locating any element is simply a matter of calculating its offset from its index. Indices are zero-based thus the third element can be found at index 2. The memory offset for that element is therefore the product of the element size and 2. However, C permits indices to be specified directly, while the pointer arithmetic is done in the background. Thus array_name[2] automatically returns a reference to the third element. Arrays with large and complex variable length data elements need to store those elements separately from the array, usually non-contiguously. This is achieved by using a pointer array. Pointer arrays are particularly useful when sorting extremely large data lists as it is much easier and more efficient to implement a sorting algorithm with an array than it is with a linked list, particularly when constant-time random-access is essential to the algorithm. The time and effort in building the array is generally more than compensated for by the efficiency of the algorithm. Arrays can also be divided and subdivided to better model the data they represent. For instance, a chessboard might be implemented as a one-dimensional array of 64 elements, however it makes more sense to model the chessboard in a two-dimensional array of 8x8 elements. Although the array is still allocated contiguously and can be thought of as being 8 rows and 8 columns, it's actually better to think of this two-dimensional array as being a one-dimensional array of 8 elements, where each element is another one-dimensional array of 8 elements. By thinking this way it makes it possible to allocate extremely large arrays in non-contiguous memory (as completely separate one-dimensional arrays) and also makes comprehension of a four-dimensional array in a three-dimensional world that much easier (unless you actually want to model time and space of course). A four-dimensional array can be thought of in a variety of ways: as being a one dimensional array of three-dimensional arrays, or as a two-dimensional array of two-dimensional arrays, or as a three-dimensional array of one-dimensional arrays, or even as a one-dimensional array of one-dimensional arrays of one-dimensional arrays of one-dimensional arrays. Whichever method you use to imagine your array is immaterial, so long as it makes sense to you that's all that really matters.


What are the benefits of multidimensional arrays?

Multi-dimensional arrays are accessed using more than one index: one for each dimension. Multidimensional indexing can be reduced internally to linear indexing; for example, a two-dimensional array with 6 rows and 5 columns is typically represented by a one-dimensional array of 30 elements.