CPSC 327 Data Structures and Algorithms Spring 2024

Homework 22
due Fri 4/12 in class

For each of the following problems, develop a recursive backtracking algorithm to solve the problem using the 16 step recursive backtracking 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.

For the running time, indicate the size of the search space (give the branching factor and longest path). If both process input and produce output approaches seem viable, pick the one that seems best with respect to running time and discuss your choice in the running time step.

  1. You have a set of n jobs to complete, and n contractors have each bid on each of the jobs. Let c(i,j) be the cost of having contractor j complete job i. Find an assignment of jobs to contractors so that each job is assigned to one contractor, each contractor is assigned one job, and the total cost of getting all of the jobs done is minimized.

  2. Solve the time-o problem described below.


Make your algorithms more practical. For each, consider:

    1. What you can prune beyond just illegal next choices? How effective do you think this will be?

    2. Identify whether the bound function for a branch-and-bound algorithm should be an upper bound or a lower bound. What bound function(s) can you identify? Give at least one possible (safe) bound function — for the tightest bound you can come up with, but list any that you think of even if they are trivial. Explain why your bound(s) are safe. How effective do you think they will be?

    3. Identify whether the initial solution estimate should be an upper bound or a lower bound and give at least one possible (safe) initial solution estimate. Aim for the tightest estimate you can come up with, but list any that you think of even if they are trivial. Explain why your estimate(s) are safe. How effective do you think they will be?

  1. Address the contractor assignment problem from #1.

  2. Address the time-o problem from #2.


The Time-O Problem

Orienteering is the sport of cross-country navigation - competitors must navigate to a series of checkpoints (called controls) using a map and compass. An orange-and-white flag marks the location in the terrain. Controls typically must be visited in a particular order, and the goal is to navigate to a certain sequence of controls as quickly as possible.

In contrast to point-to-point events, controls in a score-o event have associated point values and may be visited in any order. However, there is a time limit - the task is to select which controls to visit (and in what order) so as to maximize your score within the specified time limit. A penalty is assessed for each minute (or part of a minute) overtime.

In the novelty time-o variant, there is an additional constraint that each control is only available during a particular time window. Visiting a control outside of its time window incurs no penalty, but also gains no points. The map shows a sample scenario; click on it to see a larger version. Controls are shown with purple circles and the start/finish is marked with a double purple circle. The three-digit label by each circle is the control code (so you can verify that you've arrived at the right flag) and the time window (in minutes) is shown in brackets. In this event, all controls were worth 1 point.


The following assumptions will be made for this problem:

A few other notes:

The task: Given a list of controls with their point values and available time windows, the overall time limit and overtime penalty (points per minute), and the time it takes to travel between each pair of controls (including the start and finish), find which controls to visit and in what order so as to maximize your score.