CS1500
Algorithms and Data Structures for Engineering, FALL 2012
HW3 Arrays, Matrices, Word Counts
Because there are two problems, you have to submit two separate code files: hw3_pb1_firstname_lastname.cpp, and hw3_pb2_firstname_lastname.cpp. As usual, the pseudocode for problem 2 can be submitted separately, or as a comment in the code file. Obviously, you cannot use any C++ subroutine; you have to implement your own.
Problem 1. Implement basic matrix operations. With two matrices of real numbers as inputs, write the following functions:
- addition
- multiplication
- compute determinant (function of one matrix). You can do this in many ways, we recommend the recursive
implementation (also see here), although this way is very inefficient for large
matrices (never used in in practice, because much faster methods exist
for computing the determinant).
You have to validate that the operations are possible, i.e. the matrix
dimensions are valid for each operation. For this problem you are not required to submit pseudocode.
Problem 2. Take as input the name of the text file (create your own text
document for testing purposes). Process the text in the file,
keeping track for each word of the number of occurrences.
Output each word and its count. Hint: Implement a hash function that maps words into numbers, then use the numbers as word ID-s and as vector indices.
For a larger test, you can use this file; dont output all word/count pairs - instead output the most frequent 25 words with their counts.
For this problem you are required to submit pseudocode.
EXTRA CREDIT: For problem 1, implement a function that with a matrix as input, computes the matrix inverse, if one exists.