Create a class mydeque to implement a circular deque

Assignment Help Computer Engineering
Reference no: EM131889424

Assignment: Data Structures and Algorithms

1. Create a class, MyDeque, to implement a circular deque. The class is based on the discussion of the deques. It should include the following methods:

insertFront()
insertRear()
removeFront()
removeRear()
peekFront()
peekRear()
isEmpty()
isFull()
toString()

• You may create the class by updating the existing class Queue.java in page 138 of the textbook.

• For practicing purpose, assume that the elements in the deque are stock items. Each item consists of two data:

- Item# (String)
- Item price (double)

Create a class called Item. Each element in the deque is an object of the Item class. The class should include set/get methods and toString() method.

• The deque is a circular queue which needs to handle wrap-around.

• Refer the given methods in the example class (Queue.java in page 138) to define the API of the class. It means that you should define the signature (method header) of the constructor(s) and each method before coding. Any ‘remove' method should return the removed item. You may safely assume that the application program tests the deque for full and empty before insert and remove (It is you to write the application class.)

2. The toString() in MyDeque should always display the data stored in the deque in the sequence from ‘front' to ‘rear'.

3. Since the deque is a circular queue, You may have to handle wrap-around not only in insert and remove, but also in ‘peek',

4. Write an application class to test all methods defined in MyDeque class. The application should allow the user to provide the length of the deque and operate on the queue as many times as he/she wants till ‘Quit'.

The selections in the menu for users are:

1) Insert to front
2) Insert to rear
3) Remove from front
4) Remove from rear
5) Peek front
6) Peek rear
7) Display queue (front -> rear)
8) Quit

[Note: 1. For an insertion operation, you have to prompt the user to type in the item# and the price. Create an object of the Item and then pass the object as the argument to the insertion method. Don't pass the item# and the price to insert() and create the Item object inside of insert().

2. Each insert or remove is for a single item. ]

You should test the functions as thoroughly as you can. For the example of a deque with size 5, one of the tests could be:

a) Insert 4 elements to rear (one by one)

a) Remove 2 elements from front (...)
b) Insert 3 elements to rear
c) Remove 3 elements from rear
d) Insert 3 elements to front

Display the contents in the deque frequently during the test to check the correctness of the functions.

5. Write a program to implement a stack class by using the Deque class you implemented. This implementation uses a technique called Delegation. See Note below. It should include the following methods:

push(), pop(), peek(), isEmpty(), isFull() and toString()

The element type is Item.

To avoid the name conflict with the Stack class defined in Java library, please pick any name other than Stack for your class.

[Note: Implementing the delegation relationship: Define a deque object in the stack class, and then use any existing methods of the deque to implement the functions of the stack. Don't use the ‘inheritance' relationship.]

6. No need to write the app class for the stack. You may put a main() inside of the stack class to do simple tests.

7. For all methods and applications you write, give comments (top doc before each method, not only // comments by the side of the sentences) to explain your strategy.

8. Make all screen-output meaningful to the user.

9. Submission:

• Item class
• MyDeque class
• MyDequeApp class
• The stack class.

Reference no: EM131889424

Questions Cloud

Conclusions concerning how much government : What are your thoughts and your conclusions concerning how much government should get involved with respect to the issue of climate change?
What interest rate makes you indifferent : Congratulations, you've just won the California Lottery. You can take 50% of the jackpot total now, or 1% of the jackpot in annual payments forever.
What strategy would you suggest for a business to discover : What strategy would you suggest for a business to discover what are the customers impressions of the ambiance or atmosphere of the business.
Business executives are better suited than politicians : What are your thoughts on why or why not business executives are better suited than politicians to deal with the U.S. economy.
Create a class mydeque to implement a circular deque : Create a class, MyDeque, to implement a circular deque. The class is based on the discussion of the deques. It should include the given methods.
Enforceable contract between karim and herbatech : Was there an enforceable contract between Karim and Herbatech?
What is the change in net operating income : What is the change in net operating income after the changes?
List key characteristics of good strategic leaders : List key characteristics of good strategic leaders that lead to high performance? List two of these characteristics and list a real person/leader.
Assess the business impact of situation : Assess the business impact of this situation, describe how this process could be improved with information technology, and identify the decisions

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd