Write a program in java for the deque data structure all


This question is written in java. You are not allowed to use Java API classes for queues, stacks, arrays, arraylists and linkedlists. You have to write your own implementations for them. The problem needs to work like the example below.

A deque is a data structure consisting of a list of items, on which the following operations are possible:

push(x): Insert item x on the front end of the deque.

pop(): Remove the front item from the deque and return it.

inject(x): Insert item x on the rear end of the deque.

eject(): Remove the rear item from the deque and return it.

Write a program in Java for the deque data structure. All the above operations should take O(1) time per operation. Your program should create a menu-driven interface as shown in the example below.

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 1

Enter element to push: 5

Current Deque: 5

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 3

Enter element to inject: 79

Current Deque: 5 79

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 3

Enter element to inject: 23

Current Deque: 5 79 23

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 1

Enter element to push: 16

Current Deque: 16 5 79 23

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 1

Enter element to push: 59

Current Deque: 59 16 5 79 23

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 2

Current Deque: 16 5 79 23

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 4

Current Deque: 16 5 79

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 4

Current Deque: 16 5

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 2

Current Deque: 5

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 4

Current Deque:

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 2

Deque is empty, nothing to pop.

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 4

Deque is empty, nothing to eject.

Enter operation for deque (1: Push, 2: Pop, 3: Inject, 4: Eject, 5: Quit): 5

Bye!

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a program in java for the deque data structure all
Reference No:- TGS02910930

Expected delivery within 24 Hours