Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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!

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93104988

Have any Question?


Related Questions in Computer Engineering

Why is formative evaluation importantprovide at least three

Why is formative evaluation important? Provide at least three reasons for using it. What is the difference between formative and summative evaluation? Provide any two types formative evaluation and two types of summative ...

Two manufacturing firms are located on the banks of the

Two manufacturing firms are located on the banks of the Crimea River. Riditna Paper withdraws river water for use in its paper mill, and returns it, along with waste effluent, back into the river. (Effluent is a co-produ ...

In a standard s - t maximum flow problem we assume edges

In a standard s - t maximum flow problem, we assume edges have capacities, and there is no limit on how much flow is allowed to flow through a node. In this problem, we consider the variant of the maximum flow and minimu ...

Suppose you are given an undirected graph g with weighted

Suppose you are given an undirected graph G with weighted edges and a minimum spanning tree T of G. • Design an algorithm to update the minimum spanning tree when the weight of a single edge e is increased. • Design an a ...

Directionspick one topic for word and one topic

Directions Pick one topic for Word and one topic for PowerPoint to discuss. Word Watermark: What is the purpose of watermark for a document? What do you consider when you work on a watermark in Word? Newsletter: What are ...

Answer the following question what is the relationship

Answer the following Question : What is the relationship between a role and a competency? How do roles facilitate the development and implementation of specific practices for any organization? The response must be typed, ...

Requested files diceh dicecpp diceanddangercpp

Requested files: Dice.h, Dice.cpp, DiceAndDanger.cpp, DiceAndDanger_test.cpp With this program, you will begin the practice of breaking source code into distinct modules that are responsible for limited scopes of behavio ...

Suppose a coworker approaches you and asks what an ethical

Suppose a coworker approaches you and asks what an ethical hacker does. She does not understand the role that an ethical hacker plays in the security industry and assumes that such a hacker intentionally causes damage. E ...

Question need two different postsresponses with 200 words

Question: Need two different posts(responses) with 200 words each. After reviewing the assigned reading materials, complete the following activities: 1. Develop a product service idea. A. Describe the product/service inc ...

Can someone please help me with this pleasetaskthe purpose

Can Someone please help me with this please: Task: The purpose of this assignment is to empirically measure attributes for binary search trees. Steps: Create a program that will build a binary search tree (BST) by adding ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As