3 questions about programming

HOMEWORK SOLUTIONS!

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.

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).

3 questions about programming 25

Need Solution Email me at: Topsolutions8@gmail.com

or

https://gum.co/EFLY

 

View original post

Publicités
Par défaut