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

LinkedList Constructor

The code for the no-arg LinkedList constructor is given in Program gif. Since the fields head and tail are initially null, the list is empty by default. As a result, the constructor does nothing. The running time of the no-arg constructor is clearly constant. That is, T(n)=O(1).

   program3713
Program: LinkedList no-arg constructor.


next up previous contents index

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