CS 112 Lab 4

Agenda

We provide a singly linked-list implementation and require you to complete following two tasks.

  1. Fill in methods for the given Queue class that extends LinkedList.
    Implement enqueue and dequeue methods in Queue class.

  2. Finish the method to check for cycles in the LinkedList.
  3. For this method you should only use O(1) storage (i.e. constant amount of additonal memory).

Today's example

Download class files for the lab below,

  • LinkedListNode.java
  • Implements methods: addToHead(), removeAtHead(),
    removeAtTail(), addRandomList(), makeListLoopy()

    LinkedListNode implements Iterable and defines a private class LinkedListIterator that serves to iterate over elements of the list.

  • QueueNode.java
  • Extends LinkedListNode and contains methods, enqueue() and dequeue()

  • TestADT.java
  • The client test class.

Solutions

Solutions

URL

http://cs-people.bu.edu/tvashwin/cs112_spring08/lab04.html