Two-Dimensional Data Structure Practice Problems


  1. Write the code required to allocate a ragged 2-D int array such that the first row has space to store 1 value, the second row can store 2 values, the third row has space to store 3 values, etc. up until the 50th row which has space to store 50 values.

  2. Write a method that takes a reference to a 2-D array of ints and returns the sum of all the numbers stored in that array.

  3. Write a method that takes a reference to a 2-D array of ints and returns a distinct copy of that array.

  4. Do each of the above again but this time using an ArrayList of ArrayLists rather than an array of arrays.