CS 311 Fall 2024  >  Assignment 4


CS 311 Fall 2024
Assignment 4

Assignment 4 is due at 5 pm Tuesday, October 8. It is worth 65 points.

Procedures

This assignment is to be done individually.

Turn in answers to the exercises below on the UA Canvas site, under Assignment 4 for this class.

Exercises (65 pts total)

Exercise A — Counting Holey Domino Tilings

Purpose

In this exercise, you will write code that does recursive backtracking.

This exercise does not emphasize implementation details and language features nearly as much as earlier programming exercises did. You still need to write high-quality code and follow the coding standards; however, this should be comparatively easy, for those that did a decent job on the previous assignments.

The key part of this exercise is the logic that the code must follow. When you do this exercise, it is probably worthwhile to spend more time planning, and less time coding, than you have before.

Background

See Thoughts on Assignment 4, in the Friday 9/27 lecture slides, for an illustrated discussion of the background.

Consider a rectangle divided into squares, like a checkerboard or chessboard. Two squares are marked as holes. We will call the result a board.

A domino can cover two adjacent squares of a board, where two squares are adjacent if they have a common edge.

We wish to cover the board with dominoes, so that each domino covers two adjacent squares on the board, the holes are not covered, and every other square is covered by exactly one domino. We call a way of doing this a holey domino tiling.

A board has specified x and y dimensions: dimx and dimy. The columns are numbered 0 … dimx − 1, and the rows are numbered 0 … dimy − 1. We will specify the x and y dimensions and the x and y coordinates of the two holes. We then wish to determine how many different holey domino tilings the board has.

Instructions

This assignment is to be done individually.

Write a C++ package that counts the number of holey domino tilings on a given board.

Be sure to follow the coding standards. Standards 4A, 4B, and 4C now apply. You do not yet need to follow standards 4D or 4E.

Here are the details for function holeyDTCount.

Test Program

A test program is available: holeydtcount_test.cpp. If you compile and run the test program (unmodified!) with your code, then it will test whether your code works properly.

The test program requires doctest.h, the header for the doctest unit-testing framework, version 2.

Do not turn in the test program or the doctest framework.

Notes

What about Speed?

This exercise emphasizes logic, not efficiency. For grading purposes, running in a reasonable time is all I ask; you will not be given extra credit for super-fast code.

However, for those who like a challenge, once you get your code working, see how fast you can get it to run. I will do timing tests on all working implementations; the names of top performers will be announced in class some time after the homework is graded.