(2 points) Suppose I have an unsorted array of integers with a size of .
- Write the pseudocode for a recursive algorithm that finds the maximum element in the array.
- What is the time-complexity (Big-) for your recursive algorithm? Prove your answer.
(5 points) Consider the Harmonic numbers, given by the series and recursion relation shown below.
- What is the value of ?
- Write the pseudocode for a recursive algorithm that calculates the nth Harmonic number.
- Sketch out a recursive trace of your function when the argument is used. Use the example of the recursive trace from your textbook as a template.
- Is your algorithm an example of linear, binary, or multiple recursion? Why?
- Prove that your recursive algorithm has a time complexity of O(n).
(1 point) An algorithm is defined by the following recurrence relation. Use the substitution method to prove that this algorithm is .
(1 point) An algorithm is defined by the following recurrence relation. Use the Master Theorem to show that this algorithm is .
(1 point) You are given an unsorted array consisting of random integers. Write the pseudocode for a function that takes the array as an argument and returns a new array that only contains the positive integers from the original array. It should be a tail-call optimized recursive algorithm.