CS 411 Fall 2025 > Assignment 5 (A Problem, Part 2)
CS 411 Fall 2025
Assignment 5 (A Problem, Part 2)
Assignment 5 is due at 5 pm on Thursday, November 6. It is worth 85 points.
Procedures
This is, optionally, a group assignment. You may work in a group of two, if you wish. Each group only needs to turn in a single copy of the assignment. Under normal circumstances, each group member will receive the same grade on the assignment.
Turn in your answer to the exercise below on the UA Canvas site, under Assignment 5 for this class.
- Your submission must consist of
  the source code for Exercise A
  (files bridges.hppandbridges.cpp).
- I may not look at your homework submission immediately. If you have questions, e-mail me.
If you work in a group:
- The assignment files must contain the names of both group members.
- One student submits the assignment as usual, on Canvas.
- The other student submits an empty assignment (no attached source or header files) on Canvas, with a note indicating whom the assignment was done with.
Exercises (A only, 85 pts total)
Exercise A — Dynamic Programming
Purpose
In this exercise, you will write a package that finds an optimal solution to a problem via dynamic programming.Instructions
Redo Assignment 2 Exercise A (the bridge-building problem) with the following changes.
- Your code is to use dynamic programming instead of exhaustive search. You may use either a bottom-up or a top-down method.
- Efficiency expectations will be greatly increased. A new test program will call your code with larger problems than were used on Assignment 2.
The interface to your code will be identical to that specified in Assignment 2: the same filenames, the same function names & signatures, and the same expected results.
Test Program
A test program
will be available soon:
bridges_test2.cpp.
If you compile and run this program (unmodified!) with your code,
then it will test
whether your code works properly.
You may also do some of your testing with 
the test program from Assignment 2:
bridges_test.cpp.
If you have written your code properly,
then the old test program should run very quickly—it
should probably appear to run instantaneously.
You may find the older program useful if you are working
on correctness of slow code that is to be optimized later.
But you will need to run your code with the later test program
eventually.
Notes
- Coding standards are as for Assignment 2.
- There may be more than one way to solve this problem using dynamic programming. Be sure to choose a formulation that results in many overlapping subproblems, so as to obtain the greatest speed-up.
- And as before:
  - You may assume that the input your program is given will
  be reasonable.
  The items in the passed vectorwill always have size 3. Given city numbers will always be in range, and tolls will all be positive.
- Your code may be tested with additional input beyond that given in the posted test program.
- Code that passes all the tests will be timed, with the fastest solutions announced in class.
 
- You may assume that the input your program is given will
  be reasonable.
  The items in the passed