Question: Need help with data structure problem( stack and queue). Thanks! 1. ArbitraryQueue Linked List We discussed LIFO and FIFO queues in the lecture slides, calling

Need help with data structure problem( stack and queue). Thanks!  Need help with data structure problem( stack and queue). Thanks! 1.

1. ArbitraryQueue Linked List We discussed LIFO and FIFO queues in the lecture slides, calling them Stacks and Queues, respectively. For this problem, you will implement a merged stack / queue data structure that allows for arbitrary insertion at the front or back of the data structure. We'll call this the ArbitraryQueue data structure. Your data structure must generalize for any type of object. It will need to support these types of functions: a. i. Constructor ArbitraryQueue(), to initialize the queue ii. Push(Object object), inserts at the head of the ArbitraryQueue ili Enqueue(Object object), inserts at the tail of the ArbitraryQueue iv. Pop(), removes the Object at the head of the ArbitraryQueue and returns it v. Dequeue(), removes the Object at the tail of the ArbitraryQueue and returns it vi. Traverse(int index), which retrieves an Object at the required location and returns it Implement error handling with try/catch blocks for potential problems in the queue. Make considerations for what can potentially cause errors when a programmer interacts with your API and do the following: b. i. Use an appropriate Exception that describes the error Example:Accessing a null value should return a NullPointerException in Java/C++/Python/etc. 1. ii. Print out an error message describing the problem to the user. ii. Important note: The program execution should not fail. We should be able to continue run-time execution regardless of a thrown exception

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!