Answered step by step
Verified Expert Solution
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
- Create your own dequeue interface with the following method:
- 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.
- 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.
- contains() this method is used to check whether the queue contains the given element or not.
- descendingIterator() this method returns and iterator for the deque. The elements will be returned in order from last(tail) to first(head).
- iterator() - This method returns an iterator for the deque. The elements will be returned in order from first (head) to last (tail).
- element() - This method is used to retrieve, but not remove, the head of the queue represented by this deque.
- getFirst() - This method is used to retrieve, but not remove, the first element of this deque. Return null if deque is empty.
- getLast() - This method is used to retrieve, but not remove, the last element of this deque. Return null if deque is empty.
- 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.
- 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.
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started