Question: Programming Language: Java Create your own dequeue interface with the following method: addLast(element) this method is used to add an element at the tail of

Programming Language: Java

  1. Create your own dequeue interface with the following method:
    1. addLast(element) this method is used to add an element at the tail of the queue. It returns true on successful insertion otherwise returns false.
    2. addFirst(element) this method is used to add an element at the head of the queue. It returns true on successful insertion otherwise returns false.
    3. contains() this method is used to check whether the queue contains the given element or not.
    4. descendingIterator() this method returns and iterator for the deque. The elements will be returned in order from last(tail) to first(head).
    5. iterator() - This method returns an iterator for the deque. The elements will be returned in order from first (head) to last (tail).
    6. element() - This method is used to retrieve, but not remove, the head of the queue represented by this deque.
    7. getFirst() - This method is used to retrieve, but not remove, the first element of this deque. Return null if deque is empty.
    8. getLast() - This method is used to retrieve, but not remove, the last element of this deque. Return null if deque is empty.
    9. pollFirst() - This method is used to retrieve and remove the element at the head of the

deque. This method returns null if the deque is empty.

  1. pollLast() - This method is used to retrieve and remove the element at the tail of the deque. This method returns null if the deque is empty.
  2. size() - This method is used to find and return the size of the deque.

Write also a program to implement your interface. Test all our method, Print screen the output, write a comment and make it neat.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!