Skip to content

Instantly share code, notes, and snippets.

@bmyerz
Created February 2, 2018 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmyerz/16b5ae79e47fcf313e0f1a035e17c24b to your computer and use it in GitHub Desktop.
Save bmyerz/16b5ae79e47fcf313e0f1a035e17c24b to your computer and use it in GitHub Desktop.
An incomplete implementation of a linked list with a sentinel
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