Reference no: EM132361641
Exercise 1 - Complete the function 'minmax(L)', which takes a list 'L' and returns a pair---that is, 2-element Python tuple, or "2-tuple"---whose first element is the minimum value in the list and whose second element is the maximum.
Exercise 2 - Complete the function 'remove_all(L, x)' so that, given a list 'L' and a target value 'x', it returns a *copy* of the list that excludes *all* occurrences of 'x' but preserves the order of the remaining elements.
Note - Your implementation should *not* modify the list being passed into 'remove_all'.
Exercise 3 - Suppose you are given a vector, 'x', containing real values that are mostly zero.
Complete the function, 'compress_vector(x)', so that returns a dictionary 'd' with two keys, 'd['inds']' and 'd['vals']', which are lists that indicate the position and value of all the *non-zero* entries of 'x'.
Note 1. Your implementation must _not_ modify the input vector 'x'.
Note 2. If 'x' contains only zero entries, 'd['inds']' and 'd['vals']' should be empty lists.
Exercise 4 - Complete the function 'decompress_vector(d)' that takes a compressed vector 'd', which is a dictionary with keys for the indices ('inds') and values ('vals'), and returns the corresponding full vector. For any repeated index, the values should be summed.
The function should accept an _optional_ parameter, 'n', that specifies the length of the full vector. You may assume this length is at least 'max(d['inds'])+1'.