Back
Uncategorized

1. Describe a recursive algorithm for finding the maximum element in an array A

1. Describe a recursive algorithm for finding the maximum element in an array A of n elements. What is the running time of your algorithm?2. Draw the recursion trace for the execution of reverseArray(data 0 4) on the array data = 4 3 6 2 6.3. Suppose that we want to compute the geometric mean of a list of positive values. To compute the geometric mean of k values multiply them all together and then compute the kth root of the value. For example the geometric mean of 2 5 and 7 is2573. Use a loop with a sentinel to allow a user to enter arbitrary number of values. Compute and display the geometric mean of all values excluding the sentinel. (Hint: Math.pow(x 1.0/k) will compute the kth root of x).

David Lee
David Lee

We use cookies to give you the best experience. Cookie Policy