Array of Arrays Representation in Data Structure

Data StructureAnalysis of AlgorithmsAlgorithms

In this section we will see another representation of multidimensional arrays. Here we will see the Array of Arrays representation. In this form, we have an array, that is holding the starting addresses of multiple arrays. The representation will be look like this.

This is a two-dimensional array x of size [7 x 8]. Each row is represented as a single onedimensional array. The initial array is holding the addresses of these single arrays. They are array of addresses, so we can say that, it is an array of pointers. Each pointer is holding addresses of another arrays.

create this kind of array, we can use the new keyword like below −

int [][] x = new int[7][8];

To retrieve an element present at position x[i, j], it will find the address using x[i] at first, then move to jth index in that array.

raja
Published on 10-Aug-2020 08:17:23
Advertisements