SUNY Geneseo Department of Computer Science
CSci 242, Spring 2013
Prof. Doug Baldwin
Due Friday, February 8
Solve each of the following problems.
Given a real number, x, and a natural number n, xn can be defined by the following recursive function:
Use this recursion to give a divide-and-conquer algorithm for computing xn. Explain how your algorithm meets the definition of “divide and conquer.”
Suppose you have an array, A, containing n numbers sorted into increasing order. You want to construct a balanced binary tree containing the numbers in A. Give a divide-and-conquer algorithm to do so.
A bitonic array is an array of numbers that consists of an increasing first part followed by a decreasing second part. More precisely, an array, A[1..n], is bitonic if and only if there is an index i, 1 ≤ i ≤ n, such that the A[1..i] is strictly increasing, and A[i..n] is strictly decreasing. For example the array 2, 5, 8, 7 is bitonic, with i = 3. Give a divide and conquer algorithm that finds the maximum element in a bitonic array (you can assume all elements are distinct).
I will grade this exercise in a face-to-face meeting with you. During this meeting I will look over your solutions, ask any questions I have about them, answer any questions you have, etc. Even though we will have a chance to talk about your solutions, please bring them in writing to the meeting—that will speed things along.
Each meeting should take about 15 minutes. Please schedule your meeting by signing up on the schedule sheet outside my office or electronically via Google calendar. If you work in a group on this exercise, the whole group can have a single meeting with me. Make sure that your meeting ends by the end of the day on the due date above.