## CSE 131 Module 7: Array Structures

### Practice Problems

1. Write a method that takes as its parameter an array of integers and returns the sum of the values in the array.
2. Write a method that takes as its parameter an array of integers and returns the minimum of the values in the array. (Assume the length of the array is greater than zero.)
3. Write a method that takes as its parameters two arrays of integers and returns the dot product of the two (i.e., the sum of the products of the corresponding elements). Assume the two arrays have the same length.
4. Write a method that takes as its parameter an array a of integers and returns a new array of the same length, where each entry is the corresponding value in a multiplied by its index in the array.
5. Write a method that takes as its parameters two arrays of integers and returns a new array where the value at each index is the sum of the corresponding two elements of the given arrays at the same index. Assume the arrays are of equal length.
6. Write a method that takes as its parameters two arrays of integers and returns a new array where the value at each index is the sum of the corresponding two elements of the given arrays at the same index. Do not assume the arrays are of equal length. Pretend that the shorter array is padded with zeros at the end. (For example, if the arrays are of length 3 and 5, your result should be as if the shorter array had zeros in the "missing" slots.)
7. Write a method that takes as its parameter an array a of integers and modifies the given array so that it contains a running sum of its original values. For example, if the array originally had the values [3 2 4 7], after running your method that array would instead contain [3 5 9 16], and if you ran it another time on the same array, you'd have [3 8 17 33].
8. Write a method that takes as its parameter an "two dimensional?" array a of integers and fills the main diagonal with the value 1. (The main diagonal consists of those entries whose row and column index are equal.) Assume the two dimentional array is square.
9. Write a method that takes an integer parameter n. It should create and return an array of n arrays of integers, where the array for row 0 has length 0, the array for row 1 has length 1, the array for row 2 has length 2, etc. All values in the arrays can remain uninitialized (0).
10. Write a method that takes an array of String objects and returns a single String that results from concatenating all the strings together, separated by spaces. Do not add a space after the last element, nor before the first one.