next up previous contents
Next: Using Various SLLIST Objects: Up: The CHAR LIST DATA Previous: The DLLIST MergeSort Agent:

Exercises:

1.
Following the ideas presented in the text, implement design for the circular linked list class object for the data type integer. Pay close attention to the details of how to handle the fact that the head and the tail of the list coincide. This will alter many of the details of the class methods.

2.
Write application functions to thoroughly exercise the basic singly linked and doublely linked list classes.
3.
Construct float type list classes and thoroughly exercise the class functions.

4.
For your choice of list class (type integer, char etc.), insert additional code into the constructors and destructors so that you can clearly follow the path construction and destruction as objects go in and out of scope. Do this for as many class methods as you can. If you do this sort of insertion for the cell classes to it will give you quite voluminous output! So exercise judgement.

5.
Redesign the list classes so that they are implemented without any inheritance. This is a most interesting exercise. There are many reasons for doing this. One is that there exist ways to embed existing C+ + code within a scripting language such as python or perl. This embedding allows us to call the C+ + function from within python as a loadable module. This allows us to do really cool things. However, the tools to do this currently do not allow the C+ + code to have inheritance or overloaded operators. So this is one rational for eliminating the inheritance.

6.
Redesign the list classes so that there are no overloaded operators. Note this make the input and output of the cell objects much less pleasant; definitely not aesthetic.
7.
Design a class method which tests for the equality of two lists and thoroughly test it. Think carefully about what is means to do this test for different data types. How should we do equality testing for floats, doubles and user defined data types such as fractions, unlimited size integers and so forth.

8.
Design a fraction class letting the numerator and denominator be singly linked lists of the chars { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }. Note that there is a lot of stuff to think about here. At this point, just implement a bare bones class with constructors, destructor, insertions and so forth as well as overloaded operators for +, -, * and /. You will have to write methods which implement multiplication via carry by yourself. Make sure you redesign the cell and list classes to eliminate the name field as well as there is no need to caryy that extra stuff around here.

9.
Design a class to represent DNA strings. A DNA string consists of a list of the characters { A, C, G, T } of arbitrary length. At this point, just implement a bare bones class with constructors, destructor and other useful methods. Strip out of the class methods which have no useful purpose in this object. You will still need to keep the insertion and deletion methods though. Since DNA strings can be very long, pay close attention to efficiency of computation here. There are 64 possible groupings of three letters at a time from this set of four letters. The genetic code assigns to each such triplet, an amino acid. There is redundancy too as more than one triplet can be assigned to a given amino acid. There are 20 amino acids, so the DNA string can be read from any given starting point and each triplet encountered can be mapped to its corresponding amino acid. We can continue this read until we are told to stop. The substring of the DNA string between the start and stop of the read may be called a gene and the string of amino acids associated with this string is called a protein.

Write such a read method for our DNA class. It needs to be told where to start and where to stop. It needs also to assign the correct protein to our gene. We can do more with this later, but for now this will do. Note that insertions and deletions correspond to genetic damage and/ or mutations.

Use the following table to construct the triplet code:


next up previous contents
Next: Using Various SLLIST Objects: Up: The CHAR LIST DATA Previous: The DLLIST MergeSort Agent:
Jim Peterson
1999-04-22