answersLogoWhite

0

Yes. More specifically, they can be used to represent a dynamic multi-dimensional array.

As most people know, for a one-dimensional dynamic array, you simply need a pointer to the first element in the array, where each element contains an object of the same type as the pointer. The pointer can be passed around functions just as if it were a static array, the only difference being the requirement to pass the upper bound of the array as well as the array itself.

For a two-dimensional array, you need a pointer-to-pointer which points to the first element of a one-dimensional pointer array, where each pointer in that array points to a one-dimensional array of objects. The pointer-to-pointer must be the same type as the pointers and the objects.

For a three-dimensional array you need a pointer-to-pointer-to-pointer. And so on. Each additional dimension simply adds a new level of indirection, and a new level of one-dimensional pointer arrays.

Of course multi-dimensional arrays are only useful if every dimension is fully utilised and doesn't require too much in the way of resizing. If that is not the case, then you may get more efficient memory consumption from a vector of vectors (of vectors), which allows dynamic resizing at every level without having to copy existing elements. The downside is you lose the random access provided by the array.

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

What is the difference between multidimensional and dimensional scaling?

The difference between multidimensional and dimensional scaling is in terms of relationship between physical characteristic and dimension. In the case of multidimensional scaling, each dimension can be connected to 2 or more physical characteristics, unlike dimensional scaling..


What is the use of pointer in c?

A double pointer in C or C++ ... int ** ppi; ... simply means that ppi is a pointer that points to a pointer that points to an int. When defining function-parameters, another way of declaring this is ... int * ppi[]; ... which means that ppi is a pointer to an array of pointers that each point to an int, which happens to have the exact same meaning, but it is more telling in terms of what the usefulness of such a double pointer might have. Think of main() ... int main (int agrc, char ** argv); int main (int argc, char * argv[]); ... the two forms have exactly the same meaning, but the second form more clearly says what the design paradigm is, that argv is a pointer to an array of pointers that each point to an array of char, i.e. the arguments of the program's invocation.


What shoul you do when there is a leakage of space in terms of array?

If you have a memory leak, you should find it and fix it. It is a bug. It does not matter if it is an array or not. It is still a bug, and it needs to be fixed.


How do you create a two dimentional array?

A one-dimensional array is an array where each element in the array points to a specific value of the type specified by the array (all values must be of the same type). For example, we can store integer values in an integer array, character values in a character array and strings in a string array. Multi-dimensional arrays are implemented as one-dimensional arrays where every element is itself a one-dimensional array, for as many dimensions as required. The overall size of any array (in elements) is the product of all its dimensions, thus a two-dimensional array of 4x5 elements has 20 elements in total, divided into 4 arrays of 5 elements each. However, because all the elements are allocate contiguously, any multi-dimensional array can be treated as if it were one-dimensional. Note that every element of an array must be exactly the same length, even when that element is another array. The most common type of array we use is a pointer array (an array of pointer elements). Given that a non-null pointer does not store any size information (the number of elements being referred to), we typically use null-terminated pointer arrays, where a null pointer denotes the end of the array being referred to. This makes it possible to implement "jagged" or "irregular" multi-dimensional arrays, where each dimension can be a different length. An array of variable-length strings is an example of a jagged array, such that each element points to a null-terminated character array.


What is a recursive rule?

It is a term for sequences in which a finite number of terms are defined explicitly and then all subsequent terms are defined by the preceding terms. The best known example is probably the Fibonacci sequence in which the first two terms are defined explicitly and after that the definition is recursive: x1 = 1 x2 = 1 xn = xn-1 + xn-2 for n = 3, 4, ...

Related Questions

How are undefined terms and defined terms relate to each other?

"Defined items" are defined in terms of "undefined terms".


What does mode mean in a line plot?

The mode is defined as the term which is repeated for the highest number of times in an array or a sequence. If many terms are repeated for a similar number of times and highest, that array has more than one value for mode.


What is the difference between multidimensional and dimensional scaling?

The difference between multidimensional and dimensional scaling is in terms of relationship between physical characteristic and dimension. In the case of multidimensional scaling, each dimension can be connected to 2 or more physical characteristics, unlike dimensional scaling..


How are defined terms and undefined terms relate to each other?

"Defined items" are defined in terms of "undefined terms".


Which of the following properties is defined in terms of the mass of the solvent?

The property defined in terms of the mass of the solvent is molality.


How do defined terms and undefined terms relate to each other?

Defined terms in a subject are terms that have specific meanings assigned to them within that subject, while undefined terms are terms that are not explicitly defined but are fundamental concepts in that subject. In mathematics, for example, undefined terms like point, line, and plane are used to build the foundation of geometric concepts, while defined terms like circle and triangle are derived from these fundamental concepts. Therefore, defined terms are constructed based on the fundamental understanding of undefined terms in a subject.


What is the sum of the first 10 terms?

The answer depends on how the terms and defined.


Are most mathematical terms defined?

No. For example, division by 0 is not defined.


What are all the defined terms?

All capitalized terms not otherwise defined herein shall have the meaning ascribed to same in the Agreement.


What is the use of pointer in c?

A double pointer in C or C++ ... int ** ppi; ... simply means that ppi is a pointer that points to a pointer that points to an int. When defining function-parameters, another way of declaring this is ... int * ppi[]; ... which means that ppi is a pointer to an array of pointers that each point to an int, which happens to have the exact same meaning, but it is more telling in terms of what the usefulness of such a double pointer might have. Think of main() ... int main (int agrc, char ** argv); int main (int argc, char * argv[]); ... the two forms have exactly the same meaning, but the second form more clearly says what the design paradigm is, that argv is a pointer to an array of pointers that each point to an array of char, i.e. the arguments of the program's invocation.


What word is defined by the description of something unfamiliar using familiar terms?

"Analogy" is defined as the description of something unfamiliar using familiar terms.


What shoul you do when there is a leakage of space in terms of array?

If you have a memory leak, you should find it and fix it. It is a bug. It does not matter if it is an array or not. It is still a bug, and it needs to be fixed.