BU CAS CS 113
Introduction to Computer Science II with Intensive C

Spring 1996

Assignment 4, due Thursday February 15


These programs are to be electronically submitted by using the submit program on csa. The code you submit should conform with the program assignment guidelines.
  1. Write a subroutine that adds two polynomials f = g + h of at most degree n

    void addPolynomials(double f[], double g[], double h[], int n);

    Assume that polynomial coefficients are stored in ascending order;
    i.e., g(x) = g[0] + g[1]*x +...+ g[n]*x^n.

  2. Write a subroutine that multiplies two polynomials f = g * h of at most degree n

    void multPolynomials(double f[], double g[], double h[], int n);

    Use your addPolynomials subroutine to sum intermediate results.

    Optional part: This is not very efficient. Can you write a more efficient routine?

  3. A palindrome is a string that reads the same both forward and backward. Some examples are: "ABCBA", "123343321", "otto", "i am ma i", and "C".

    Write a function that takes a string as an argument and returns the value 1 if this string is a palindrome and returns 0 otherwise

    int isPalindrome(char *string);

    If you are on a UNIX system, one way to test this function is to use it to find all the palindromes in the file /usr/dict/words.

  4. KP exercise 2 on page 316.

You will submit four files for this assignment: a4p1.c, a4p2.c, a4p3.c, a4p4.c.

Programming assignments are due before class on the assignment due date.

Late assignments will be levied a late penalty of 10% per day. Late assignments will only be accepted up to 4 days late.


Academic Honesty and Collaboration

It is reasonable to discuss with others possible general approaches to problems. It is unreasonable to work together on a detailed solution, to copy a solution, or to give away a solution. If your common discussion can be detected by looking at the solutions, then there is too much collaboration. Such instances of academic dishonesty will result in a course grade of F or expulsion from Boston University.

Do not allow your work to be used by others:

Warning: If someone cheats by using your work, you will also be penalized


Page Created: Jan 15, 1995 Maintained by: Stan Sclaroff