Use a loop with a sentinel to allow a user to enter


1. Describe a recursive algorithm for finding the maximum element in an array A of nelements. 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 is 2×5×7--------√3. 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).

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Use a loop with a sentinel to allow a user to enter
Reference No:- TGS01086532

Expected delivery within 24 Hours