Comp 116 Bonus Assignment:
Weird Stacks and Queues

Due 11:59pm Friday, May 7 2021

This is an individual assignment. You must complete this lab on your own, although you may discuss lab concepts with other students. Please keep the Academic Integrity Policy in mind---do not show your code to anyone outside of the professors and ninjas, and do not look at anyone else's code for this lab.

The goal of this lab is to introduce you to review some of the concepts we have covered since the beginning of class and to prepare you for the first test. The concepts we review are:

Each problem is relatively short, but requires a bit of planning. The obvious solution could require a lightly longer program that needs to be written very carefully. A clever solution could require much less code and be much more straightforward to implement.
Problem 1: Weird Stack

Write a class WeirdIntStack that implements our stack ADT, but which is only allowed to use queues in the implementation. Your implementation is not allowed to use objects of any kind other than queues and you are not allowed to use arrays. Integer-type variables are allowed.

The class should contain the following:

I also require that your implementation of pop and getTop run in $O(1)$ time. I have no other requirements on the other methods, except that they should not be unnecessarily slow.

You should use the STL implementation of queues. Note that no assignment operator is implemented, so copies of queues must be made manually.

Hint: You should only need one queue in your class member variables, but some of your methods will require an additional queue as temporary storage.

Problem 2: Weird Queue

This problem is essentially a mirror image of the previous one. Write a class WeirdIntQueue that implements our queue ADT, but which is only allowed to use stacks in the implementation.

The class should contain the following:

I also require that your implementation of dequeue and getFront run in $O(1)$ time. I have no requirements on the other methods except that they should not be unnecessarily slow.

You should use the STL implementation of stacks. Note that no assignment operator is implemented, so copies of queues must be made manually.

Commenting and Coding Style Requirements

I will assign minor penalties for poor commenting and coding style.
Please review the Comp 116 Coding Style for good C++ style.

Submission

Submit a .zip file containing the entire project folder for the programming assignment using the submission link on onCourse.