this is my latest class assignment, i would really appreciate some assistence with my pseudo code to help me in the right direction. my code skeleton is provided at the end of this post.

Deque

A double-ended queue, often abbreviated deque and pronounced deck, is an object with the following interface.

public interface IDeque<E> 
{
    public void addFirst(E e); 
    public void addLast(E e);
    public E removeFirst();
    public E getFirst();
    public boolean isEmpty();
}

A deque is a list of items with restrictions on how it can be manipulated. Items can be added to either end of the list but can only be removed from one of the ends. We'll call the end where removal can happen "the front" and the item there "first". We'll call the other end "the back" and the item there "last". The method getFirst returns, but does not remove, the first item on the list. If getFirst or removeFirst is invoked on an empty deque, then a NoSuchElementException is thrown.

Java has a Deque interface, but we are not using it in this project because it has far more methods than we want to implement right now. You should look at the Deque javadoc if you are not sure how the above methods should behave.

You should write a MyDeque class that implements the above methods. It should implement its list as a linked structure that your methods manipulate directly. You may not use any java Collection classes to implement your deque. All your methods should work in constant time O(1) - in other words, no loops allowed.

Hint: MyDeque and java's Deque should behave the same for the above methods. This means that you can use Deque to see how your MyDeque should behave. In other words, your unit test should work the same whether you initialize your deque as

MyDeque<String> d = new MyDeque<String>();
or

Deque<String> d = new LinkedList<String>();
You can use this fact to verify that your deque is behaving as expected.

public class deque
{       
    public void addFirst(E e) 
    {        

    }

    public void addLast(E e);
    {

    }

    public E removeFirst()
    {

    }

    public E getFirst()
    {
        //.getFirst()
    }

    public boolean isEmpty()
    {
      //checks if 
    }
}

This isn't a place for people to do your homework for you. Try it yourself, then if having trouble ask a specific question.

I understand the directions however i dont know where to begin. That is why i was asking for some pseudo code to push me in the right direction

If I'm not mistaken, which I could be because I've never even heard of a Deque, You need some sort of List to put Objects into. Then I would use that List's methods to add and remove Objects to and from, as well as getting the Objects from that List.

This article has been dead for over six months. Start a new discussion instead.