Laboratory 7

Exercise 1

Circular linked lists have several applications. An important one appears in operating systems where the round robin scheduling algorithm uses a circular linked list.

We intend to develop a package to make available a generic circular linked list. The only methods required to define this type are:

  • add, which adds an element to the generic type;
  • remove, which removes an element from the generic type.

1. Model the UML the class diagram.

2. Implement it in Java.

3. Test your program (in a main method).

Exercise 2

Consider that in the same package we intend to make available a specialization of the generic circular linked list, but now, only for numeric types. Moreover, we intend to make available a new method which computes the average over all numeric elements in the list.

1. Complete the UML class diagram.

2. Implement it in Java.

3. Test your program (in a main method).