{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

day21 - COP 3503 Computer Science II CLASS NOTES DAY#21...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3503 – Computer Science II CLASS NOTES - DAY #21 Doubly Linked Lists Better than singly linked list as they are bi-directional. Has both a header and a tail node (for the same reason that we added the header node to the singly linked list). null null header tail public class DLLNode { public Object data; public DLLNode next; public DLLNode prev; private DLLNode ( ) { } //defeats improper instantiation public DLLNode (Object x) //constructor for isolated DLLNode { data = x; // prev = null; // next = null; // null } //end constructor public DLLNode (Object x, DLLNode n, DDLNode p) //constructor for linked DLLNode { data = x; next = n; prev = p; } //end constructor } //end class DLLNode p n Day 21 - 1 A B prev data = x next null x
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Doubly Linked List Implementation in Java public class Doubly_Linked_List { protected DLLNode header; protected DLLNode tail; protected DLLNode current; public Doubly_Linked_List ( ) { header = new DLLNode(null); tail = new DLLNode(null); header.next = tail; tail.prev = header; } // end constructor public void resetList ( ) { header.next = tail; tail.prev = header; current = header; } //end resetList public boolean isEmpty ( ) { return (header.next = = tail);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}