Difference Between one-dimensional and two-dimensional array Last Updated : 02 Nov, 2023 Comments Improve Suggest changes Like Article Like Report Array is a data structure that is used to store variables that are of similar data types at contiguous locations. The main advantage of the array is random access and cache friendliness. There are mainly three types of the array: One Dimensional (1D) ArrayTwo Dimension (2D) ArrayMultidimensional Array One Dimensional Array: It is a list of the variable of similar data types.It allows random access and all the elements can be accessed with the help of their index.The size of the array is fixed.For a dynamically sized array, vector can be used in C++.Representation of 1D array: Two Dimensional Array: It is a list of lists of the variable of the same data type.It also allows random access and all the elements can be accessed with the help of their index.It can also be seen as a collection of 1D arrays. It is also known as the Matrix.Its dimension can be increased from 2 to 3 and 4 so on.They all are referred to as a multi-dimension array.The most common multidimensional array is a 2D array.Representation of 2 D array: Difference Table: BasisOne Dimension ArrayTwo Dimension ArrayDefinitionStore a single list of the element of a similar data type.Store a 'list of lists' of the element of a similar data type.RepresentationRepresent multiple data items as a list.Represent multiple data items as a table consisting of rows and columns.DeclarationThe declaration varies for different programming language: For C++, datatype variable_name[row]For Java, datatype [] variable_name= new datatype[row]The declaration varies for different programming language: For C++, datatype variable_name[row][column]For Java, datatype [][] variable_name= new datatype[row][column]DimensionOneTwoSize(bytes)size of(datatype of the variable of the array) * size of the arraysize of(datatype of the variable of the array)* the number of rows* the number of columns.Address calculation.Address of a[index] is equal to (base Address+ Size of each element of array * index).Address of a[i][j] can be calculated in two ways row-major and column-major Column Major: Base Address + Size of each element (number of rows(j-lower bound of the column)+(i-lower bound of the rows))Row Major: Base Address + Size of each element (number of columns(i-lower bound of the row)+(j-lower bound of the column))Exampleint arr[5]; //an array with one row and five columns will be created. {a , b , c , d , e} int arr[2][5]; //an array with two rows and five columns will be created. a b c d e f g h i j Applications of Arrays: 2D Arrays are used to implement matrices.Arrays can be used to implement various data structures like a heap, stack, queue, etc.They allow random access.They are cache-friendly. Comment More infoAdvertise with us Next Article Difference Between one-dimensional and two-dimensional array C CoderSaty Follow Improve Article Tags : Technical Scripter Difference Between C Language DSA Arrays +1 More Practice Tags : Arrays Similar Reads What is the difference between lists and arrays? In programming, lists and arrays are data structures used to organize and store data. Both have their unique features and purposes. Lists are dynamic and flexible, allowing for easy resizing during runtime, while arrays are static with a fixed size. This difference impacts memory usage and performan 8 min read Difference between Array and String in Java An array is a collection of similar type of elements that are stored in a contiguous memory location. Arrays can contain primitives(int, char, etc) as well as object(non-primitives) references of a class depending upon the definition of the array. In the case of primitive data type, the actual value 5 min read Difference between Array and Map Array:An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of t 12 min read Difference between Arrays and Pointers The array and pointers are derived data types that have lots of differences and similarities. In some cases, we can even use pointers in place of an array, and arrays automatically get converted to pointers when passed to a function. So, it is necessary to know about the differences between arrays a 7 min read Difference between Stack and Array Stack: A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. A stack follows the LIFO (Last In First Out) principle, i.e., the element inserted at the last is the first element to come out. The insertion of an element into a 3 min read Like