EE 312 Project 6 - Polynomial Module



You must complete this assignment by yourself. You may not use code that you have not written by yourself. You may not give your code to another student, or help another student with this project. If you need help, seek help from the instructional staff for the class.

Description: The purpose of this assignment is to
1. Develop a module that represents polynomials and provides polynomial operations.
2. Practice using linked lists and dynamic memory.

You will implement the functions described in Poly.h. Use the poly type defined in the provided Poly.h and Poly.c files. You cannot modify the Poly.h file, or change the poly representation. In Poly.c, complete the definitions of the functions that are declared in Poly.h. The provided tests in Proj6Test.c are not intended to provide comprehensive testing. You must write your own tests. 

The format of the string that will be passed to your makePoly() function will be similar to these strings below:
5x^3 + 2x + 4
-2x - 6

Each polynomial contains only the variable x. The ^ symbol is used to represent exponentiation in the strings. Terms in the polynomial will be separated from a + (for addition) or - (for subtraction) sign by a single blank space, and there will not be whitespace embedded in a monomial term. Terms with zero coefficients will not be listed. The terms will be in decreasing order of degree, and there will not be multiple terms with the same degree. All coefficients will be integers (and of course, all exponents will be non-negative integers.) This will be the format of the string argument for your makePoly() function.

Representation
Each polynomial will be represented as a linked list in which each node represents a term of the polynomial. For a polynomial's linked list, the list nodes will occur in decreasing order of degree. There will be one node corresponding to any particular power of x which has a non-zero coefficient in the polynomial. Zero coefficient terms will not be included in the linked list representation of a polynomial. A zero polynomial will be represented by a NULL  list pointer.

The struct for each node in the linked list will contain:
1. exp: the exponent of x in the term
2. coeff: the non-zero coefficient in the term
3. next: pointer to the next node in the list

The functions that you will be implementing are the following.

You may need to write additional helper functions to reduce redundancy.  Do not modify Poly.h, or add any #includes or #defines to Poly.c. You may not use any globals. You should not add anything to Poly.c except the implementation of the functions listed above and any helper functions that you need to reduce redundancy.

Use valgrind to check for memory leaks. You will lose points for memory leaks.

At the top of your Poly.c file, add the following header, with your name replacing <NAME>.

/* Student information for project:
 *
 * Replace <NAME> with your name. (And then delete this line.)
 *
 * On my honor, <NAME>, this programming project is my own work
 * and I have not provided this code to any other student.
 *
 * Name:
 * email address:
 * UTEID:
 * Section 5 digit ID:
 * Number of slip days used on this assignment:
 */

Style
At a minimum, you must include a comment right before each function, summarizing the behavior of the function. This is minimal - you must add comments to describe complex chunks of code within your functions, as well. Follow the style guide for EE 312.

You will submit your Poly.c file on Canvas. The #includes in your Poly.c file must not be modified. The Poly.c file should only be modified by adding comments and your implementation of the functions described above and any helper functions that you need.

If your code does not compile, you will receive a 0 on the project. If your file does not have the correct name, including capitalization, your project grade will be decreased by 5 points. If the header given above is not filled in completely and correctly, you will lose points. Please check your 5 digit section ID. Sections have been combined on Canvas, so you will not see the correct number there.

For each function that you implement, include the big-Oh of your function in the comment before your function. Assume the degree of the polynomial is N. For functions that take two polynomials, assume that both polynomials have degree N. Do a worst case analysis. The efficiency of your algorithms matters.


Academic Dishonesty on Projects
This is a reminder that copying code from someone else, giving your code to someone else, finding solutions on the internet, and walking another student through a solution are all examples of cheating. Please review the syllabus for my policy on cheating. If I catch you cheating on a project, you will fail the class and I will file a report with the dean of students office. For programming projects, I use MOSS (Measure Of Software Similarity), which was developed at Stanford. MOSS is extremely effective at detecting plagiarism on coding assignments. None of these have any effect on MOSS: adding or changing comments, changing function or variable names, rearranging functions and code chunks. I recognize that most EE 312 students do not and would not cheat. It is important to detect cheating in part to protect the value of your degree and your hard-earned grades.