Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

List Elements

 

The definitions of the methods of the LinkedList.Element class are given in Program gif. Altogether, there are three methods--a constructor and two accessors.

The constructor simply initializes the field to the passed values. Assigning a value to the datum and next fields takes a constant amount of time. Therefore, the running time of the constructor is O(1).

The two accessor methods, getDatum and getNext, simply return the values of the corresponding fields. Clearly, the running times of each of these methods is O(1).


next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.