DU Computer Science Bootcamp: Systems Assignment 3
Due: Friday October 16 at 11:59pm
For this assignment you will be writing functions to manipulate a binary matrix.
You will need to write your own testing code.
After writing the specified functions, you will submit them via the department's Git server.
The functions
You will need to implement the following functions:
- uint64_t *createMatrix(int rows, int cols);
This will allocate space in the form of an array of 64 bit unsigned integers that is just large enough
to store a rows x cols binary matrix.
- void destroyMatrix(uint64_t *matrix);
This will free up the memory allocated to the matrix.
- void setBit(uint64_t *matrix, int total_rows, int total_cols, int row, int col);
This will set the bit at position row, col to be true.
- void clearBit(uint64_t *matrix, int total_rows, int total_cols, int row, int col);
This will set the bit at position row, col to be false.
- void toggleBit(uint64_t *matrix, int total_rows, int total_cols, int row, int col);
This will toggle the bit at position row, col to be the opposite of what it started as.
- bool testBit(uint64_t *matrix, int total_rows, int total_cols, int row, int col);
This will return true if and only if the bit at position row, col is true.
If the row and column to operate on is outside of the matrix, the behavior is undefined.
Testing
You will need to write your own testing functions that will be submitted along with your code for the above functions. You will need to test that various size matrices all work correctly and all of the functions perform correctly.
To test effectively, compare your implementation to a bool[][] oracle.
For example, part of your testing code may look like
bool testMatrix(int rows, int cols) {
uint64_t *matrix = createMatrix(rows, cols);
bool **oracle = new bool*[rows];
for (int i = 0; i < rows; ++i)
oracle[i] = new bool[cols];
// Testing code goes here
for (int i = 0; i < rows; ++i)
delete[] oracle[i];
delete[] oracle;
destroyMatrix(matrix);
}
Submission
Your work must be submitted via the department's Git server. To do so, perform the following steps:
- Use the existing "bootcamp" repository you created for Systems Assignment 1
- Create a "systems_assignment3" directory and place your source code in it
- Commit your changes and push them to the department's server
- When complete you can verify the files are present by using the web interface.
If you have any questions or problems with the submission system, email Will.