Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Explain internal recruitment methods.

Answered: 1 week ago