Submit to Blackboard before the deadline. You will be able to revise your answers until the deadline with no penalty.
IMPORTANT: By submitting your answers, you are certifying that these answers have been exclusively your own work.
All students enrolled in this course are expected to adhere to the UT Arlington Honor Code:
I pledge, on my honor, to uphold UT Arlington's tradition of academic
integrity, a tradition that values hard work and honest effort in the
pursuit of academic excellence.
I promise that I will submit only work that I personally create or
contribute to group collaborations, and I will appropriately reference
any work from other sources. I will follow the highest standards of
integrity and uphold the spirit of the Honor Code.
Task 1 (10 pts.)
File matrix_multiplication.c contains the implementation of a bottom-up solution for optimally ordering matrix multiplications. Modify the file, so that in addition to printing out the optimal ordering and associated cost, it also prints out the following:
- The worst possible ordering, and its associated cost.
- The cost of using the default ordering, namely multiplying matrix 1 with matrix 2, multiplying that result with matrix 3, multiplying that result with matrix 4, etc.
Save your solution into a file called matrix_multiplication.c.
Task 2 (40 pts.)
Write a program that takes in two strings as commandline arguments, computes the edit distance between those strings, and prints out both the distance and the corresponding alignment.
Additional Requirements:
- Save your solution into a file called edit_distance.c.
- The edit distance should be computed by a function with this signature:
struct EDSolution edit_distance(char * first_string, int length1, char * second_string, int length2)
Your struct EDSolution should contain whatever you consider appropriate.
- Your edit_distance function should not do any printing. Your main function should do all the printing, using the information in the EDSolution object returned by the edit_distance function.
- Your output should have format identical to the format of the output shown in the examples below.
- Your solution for this task should use bottom-up dynamic programming.
These are examples of how you would invoke the program from the commandline, and what output it would produce (assuming that your executable is called edit_distance):
./edit_distance chicken ticket
edit distance: 3
c h i c k e n
t - i c k e t
x x . . . . x
./edit_distance lazy crazy
edit distance: 2
l - a z y
c r a z y
x x . . .
./edit_distance intimidation immigration
edit distance: 5
i n t i m i d - a t i o n
i - - m m i g r a t i o n
. x x x . . x x . . . . .
Task 3 (25 pts.)
Create a C file called graph_print.c, that contains:
- A function bfs_print with the following signature and specifications:
- Signature:
void bfs_print(Graph g, int starting_vertex);
- Behavior: this function prints all vertices of the graph that are reachable using paths that start at starting_vertex. Those vertices should be printed in an order that is compatible with the order in which vertices are visited using breadth-first search (using starting_vertex as the initial vertex to visit).
- A function dfs_print with the following signature and specifications:
- Signature:
void dfs_print(Graph g, int starting_vertex);
- Behavior: this function prints all vertices of the graph that are reachable using paths that start at starting_vertex. Those vertices should be printed in an order that is compatible with the order in which vertices are visited using depth-first search (using starting_vertex as the initial vertex to visit).
- Your code should use the implementation of graphs based on adjacency lists that is defined at graphs.h and graphs_list.c.
Task 4 (25 pts.)
Create a C file called tree_check.c, that contains a function tree_check with the following signature and specifications:
- Signature:
int tree_check(Graph g);
- Behavior: this function returns 1 if graph g is a tree, and returns 0 otherwise.
- Your code should use the implementation of graphs based on adjacency lists that is defined at graphs.h and graphs_list.c.
How to submit
The assignment should be submitted via Blackboard.
Submit a ZIPPED directory called Firstname_Lastname.zip. No other forms of compression are accepted, contact the instructor or TA if you do not know how to produce .zip files. The zipped directory should contain the following documents:
- matrix_multiplication.c (your modified version)
- edit_distance.c
- graph_print.c
- tree_check.c
As stated on the course syllabus, programs must be in C or Java, and must run on omega.uta.edu. If you want to do this in any language other than C, you have to re-implement in that language all the code that is currently provided and implemented in C. If you want to use another language or platform, you must obtain prior written approval via e-mail by the instructor.
IMPORTANT: Pay close attention to all specifications on this page, including
file names and submission format. Even in cases where your answers are correct,
points will be taken off liberally for non-compliance with the instructions given on this
page (such as wrong file names, wrong compression format for the submitted code,
and so on). The reason is that non-compliance with the instructions makes the
grading process significantly (and unnecessarily) more time consuming. Contact the
instructor or TA if you have any questions.
Back to the list of assignments.