Results 1 to 3 of 3
  1. #1
    fam2315 is offline Member
    Join Date
    Feb 2011
    Posts
    78
    Rep Power
    0

    Default DoublyLinkedList

    I have an assignment to implement a Dequeue as doublyLinkedList (with methods insert left, and delete right) without a header, and not as a circular linked list

    Here is what I have, seems to simple though:

    Java Code:
    public class Dequeue {
     DoublyLinkedList dll; 
     public Dequeue(){
     dll = new DoublyLinkedList();
     }
     public void insertLeft(Object o){
         dll.insertFirst(o);
     }
     public void deleteLeft(){
         dll.deleteFirst();
     } 
     public void insertRight(Object o){
         dll.insertLast(o);
     } 
     public void deleteRight(){
         dll.deleteLast();
     }
    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Did you write the DoublyLinkedList class yourself?
    Does the DoublyLinkedList class have any error checking? If not you will have to add it to your Dequeue class. By error checking I mean what happens when you call deleteLeft on an empty List?

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,458
    Rep Power
    25

    Default

    Does it work?
    You need to write a test driver to add items to the list and manipulate the list.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •