CPSC 327 Data Structures and Algorithms Spring 2024

Homework 16
due Wed 3/27 in class

For the following problem, develop a divide-and-conquer algorithm to solve the problem using the 16 step divide-and-conquer algorithm development template. Give each of the steps; don't just give an algorithm — the point here is understanding the process and being able to apply it.

  1. A watershed is the area of land that drains into a particular water system — the Seneca Lake watershed, for example, is the area from which water drains into Seneca Lake. The picture below shows a 2D version of this concept — the landscape is shown in gray, the points where water falling on the landscape would collect are shown with black dots, and the watershed for each of the collection points is shown by the span of the black lines below the landscape. Given an array of n elevation values, report the collection points (as the array index of that point) and their watersheds (as a span of array indexes).


For the following problem, develop an iterative algorithm to solve the problem using the 15 step iterative algorithm development template. Give each of the steps; don't just give an algorithm — the point here is understanding the process and being able to apply it.

  1. Given a graph with maximum degree d, color it — that is, assign a color to each vertex so that no edge connects vertices with the same color — using at most d+1 colors.