Created
February 2, 2018 17:51
-
-
Save bmyerz/16b5ae79e47fcf313e0f1a035e17c24b to your computer and use it in GitHub Desktop.
An incomplete implementation of a linked list with a sentinel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public SLinkedList { | |
// header always points to the sentinel node; header is NEVER null | |
ListNode header; | |
public SLinkedList() { | |
// point to a dummy ListNode that serves as the sentinel node | |
// its data doesn't matter | |
header = new ListNode(-1); | |
} | |
// finish this method | |
public void add(int d) { | |
} | |
private class ListNode { | |
int data; | |
ListNode next; | |
ListNode(int d) { | |
data = d; | |
next = null; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment