InterviewSolution
Saved Bookmarks
| 1. |
What all are the differences between Rectangular and Jagged Array? |
|
Answer» A ‘RECTANGULAR array’ is a multidimensional array where all the rows have the same number of elements, all elements are STORED continuously in memory, these are very compact in memory example: INT[] arr = {1,2,4}; int[,] multiArr = new int[2,3];A ‘jagged array’ is also known as an array of arrays. It is also the multidimensional array one in which the length of the rows need not be the same. For example, string[][] jaggedArray = new string[3][]{ new string[] {"TeamCS", "JOHN", "James", "Garry", "Linus"}, new string[] {"TeamMath", "Ramanujan", "Hardy"}, new string[] {"TeamSc", "Albert", "Tesla", "Newton"}, };The above-jagged array consists of 3 rows, with each row having another array of different size. The elements in the jagged array are a reference of the other arrays, which can be anywhere in the memory |
|