CS 151 -- Lab Nov 16

Further Extending Linked Lists

Write the following two methods within the linked list class discussed today.

Code is available on goldengate at


        * Determine if the list contains the provided object. 
        * @param r the object to be looked for.
        * @return true iff the object is in the linked list.
       boolean contains(J r);
       * Given a linked list whose items are in sorted order,
       * add the new item, r, so that the items in the linked list are 
       * still in sorted order after the addition.  
       * @param: r  the item to be added 
       * @return true iff the addition succeeded (it will always succeed).
       boolean addSorted(Comparable<J> r);
For addSorted, you should adjust the SingleLinkedList class to require that the data items are Comparable.

What to turn in

Send email to gtowell151@cs.brynmawr.edu witn the two functions (or as much of the two functions are you complete in 80 minutes).