Question: Given the following class C + + Links to an external site. I would prefer that you use C + + but if you must
Given the following class
CLinks to an external site.
I would prefer that you use C but if you must you can use JavaLinks to an external site. but do speak with me if you need help moving to C
Write two wrapper classes, one for a queue and one for a stack.
How to:
In this assignment, you will create two wrapper classes, Stack and Queue, which will utilize an underlying instance of the ResizableArray class. A wrapper class is one that wraps around an instance of another class and constrict or limits how a user can access the said instance. What I would like you to do is to use the above class to write a stack and a queue object. All the storage features are already implemented, what you need to do is add to the correct index and remove from the correct index when adding and removing.
Task
Add any setters or getters you may need to finish your task
Implement the Stack class: Utilize the methods from ResizableArray to manage elements in a LIFO Last In First Out structure.
Implement the following methods
void push
T pop
T peek
Make sure you can print the stack to the console with some other method.
You can find an example of how to in ResizableArray
Implement the Queue class: Use the methods in ResizableArrayto manage elements in a FIFO First In First Out manner.
Implement the following methods
void enqueue
T dequeue
T peek
Make sure you can print the state of the queue with another method
HINTVideo:
you don't need to write a lot of code. The idea here is to use Encapsulation to do most of the work.
The following recordings illustrate how you can build a stack and a heap using the standard vector in C and an array list in Java
Java: pdf VideoLinks to an external site.
C: pdf VideoLinks to an external site.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
