70 likes | 224 Views
The Linked List. CS 145 Spring 2005. List. Node. Node. Node. First. Next. Next. Null. Data. Data. Data. Basic Linked List (AKA Singly Linked List). type Node; type Node_Ptr is access Node; type Node is record Next : Node_Ptr; Data : <<whatever>>; end record;.
E N D
The Linked List CS 145 Spring 2005
List Node Node Node First Next Next Null Data Data Data Basic Linked List(AKA Singly Linked List) type Node; type Node_Ptr is access Node; type Node is record Next : Node_Ptr; Data : <<whatever>>; end record; subtype List is Node_Ptr; or, type List is record First : Node_Ptr; end record;
List Node Node Node First Next Next Null DataPtr DataPtr DataPtr Data Data Data … … … Basic Linked List (Variation 1)Point to Data type Node; type Node_Ptr is access Node; type Node is record Next : Node_Ptr; Data : access <<whatever>>; end record; subtype List is Node_Ptr; or, type List is record First : Node_Ptr; end record;
Node Node Node Next Next Null Data Data Data Linked List (Variation 2)Last Pointer List First Last type Node; type Node_Ptr is access Node; type Node is record Next : Node_Ptr; Data : <<whatever>>; end record; type List is record First : Node_Ptr; Last : Node_Ptr; end record;
Node Node Node Next Next Null Data Data Data Linked List (Variation 3)Keep a Count List First Last Count type Node; type Node_Ptr is access Node; type Node is record Next : Node_Ptr; Data : <<whatever>>; end record; type List is record First : Node_Ptr; Last : Node_Ptr; Count : Natural; end record;
Node Node Node Next Next Null Null Prev Prev Data Data Data Doubly Linked List(with Optional Count) List First Last Count type Node; type Node_Ptr is access Node; type Node is record Next : Node_Ptr; Prev : Node_Ptr; Data : <<whatever>>; end record; type List is record First : Node_Ptr; Last : Node_Ptr; Count : Natural; end record;