Project 2: Linked Lists

(Return to homepage)

In Project 2, you'll implement a Doubly Linked List, a list-like data structure that enables iteration in both forward and reverse directions.

The Doubly Linked List is just like the (Singly) Linked List, with a slight addition. The internal nodes inside the Doubly Linked List not only point forward to the next node like a Linked List, but also point backward to the previous node in the list. This enables clients of the Doubly Linked List to iterate in both directions. Furthermore, a node can be inserted and removed from the list-like with just a reference to the node itself, rather than the complete list, as a node can re-link both of its neighbors.

Your task is to implement a complete Doubly Linked List that provides an interface supporting operations like insertion, deletion, and iteration in both directions. This project not only involves extensive use of references to track and organize internal data nodes, but also offers several practical examples on how a data structure's performance (Big O) can vary based on a client's needs (i.e. insertion vs. iteration). For those two reasons, Linked Lists are commonly featured in technical interviews to evaluate a candidate's understanding of references, runtime, and the trade-offs between ways data can be organized.

Ready? It's interview day. Get the Project 2 starter code here! (jUnit dependencies included)

The project code should work out-of-the-box for IntelliJ (running and debugging), but if you're having trouble getting it working, try these IntelliJ setup instructions.

Classes

linkedlist.LinkedList<T>: A generic, concrete Doubly Linked List class. Implements Iterable.

Bonus Classes

This project features two additional classes that you may optionally implement for up to +15 bonus points. You are eligible to earn bonus points even if your Linked List implementation is not fully complete. These classes are the Stack and Queue, which are natural clients of the Linked List that can take advantage of O(1) append and remove. By implementing both, you will explore the differences between containment and extension, two different strategies of re-using a base class's behavior.

Running Your Code

As with the previous projects, this project contains a full test suite (see the test package) that will evaluate your code.

A run script for the entire project test suite is included as run.bat (Windows) or run.sh (Mac/Linux). This will compile your entire project and produce a run report with your estimated grade, including bonus points. Your entire project must compile for the script to work, and your entire project must compile to receive a grade after submission.

You are welcome to modify the tests for debugging purposes, though keep in mind your project will be graded using an unmodified copy of the test suite.

Submission Instructions

See the submissions page for details. Have questions or need help? Post on Piazza!

Critical Analysis Questions

These questions aren't graded, but are similar to those you may see on an exam. You are welcome to discuss these with classmates offline on on Piazza.

(Return to homepage)