Data Structures and Algorithms
with Object-Oriented Design Patterns in C# |
The code for the LinkedList default constructor is given in Program . 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 default constructor is clearly constant. That is, T(n)=O(1).
Program: LinkedList default constructor.