Write a visitor to solve each of the following problems:
Find the smallest element of a list.
Find the largest element of a list.
Compute the sum of all the elements of a list.
Compute the product of all the elements of a list.
Design and implement a class called
OrderedListAsDoublyLinkedList which represents
an ordered list using a doubly-linked list.
Select one of the approaches shown in Figure .
Consider the Polynomial class given in Program .
Implement a method that computes the value of a polynomial,
say p(x),
for a given value of x.
Hint: Use a visitor that visits all the terms in the polynomial
and accumulates the result.
Devise and implement an algorithm to multiply two polynomials.
Hint: Consider the identity
Write a method to multiply a Polynomial
by a Term and use the polynomial addition operator
defined in Program .
Devise and implement an algorithm to compute the
power of a polynomial,
where k is a positive integer.
What is the running time of your algorithm?
For some calculations it is necessary to have very large integers,
i.e., integers with an arbitrarily large number of digits.
We can represent such integers using lists.
Design and implement a class for representing arbitrarily large
integers.
Your implementation should include operations to add, subtract,
and multiply such integers,
and to compute the power of such an integer,
where k is a small positive integer.
Hint: Base your design on the Polynomial class
given in Program .